diff --git a/R/geometryfns.R b/R/geometryfns.R index d78a651..c814a00 100644 --- a/R/geometryfns.R +++ b/R/geometryfns.R @@ -1165,6 +1165,7 @@ setMethod("map_data_to_BAUs",signature(data_sp="SpatialPolygons"), ## Attach the ID of the data polygon to the data frame data_sp$id <- row.names(data_sp) + data_sp$id <- as.character(data_sp$id) ## Assume the BAUs are so small that it is sufficient to see whether the ## BAU centroid falls in the data polygon. To do this we first make @@ -1181,10 +1182,12 @@ setMethod("map_data_to_BAUs",signature(data_sp="SpatialPolygons"), BAUs_aux_data <- .parallel_over(data_sp,BAU_as_points,fn=.safe_mean) ## Now include the ID in the table so we merge by it later - BAUs_aux_data$id <- row.names(BAUs_aux_data) + BAUs_aux_data$id <- as.character(row.names(BAUs_aux_data)) ## Do the merging - updated_df <- left_join(data_sp@data,BAUs_aux_data,by="id") + updated_df <- left_join(data_sp@data, + BAUs_aux_data, + by="id") ## Make sure the rownames are OK row.names(updated_df) <- data_sp$id diff --git a/cran-comments.md b/cran-comments.md index a099a94..2a64bdb 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,8 @@ +## v0.1.7 ++ Made compatible with new update of Hmisc ++ Added support for change of support spatio-temporal prediction ++ Changed from pred_locs to newdata in arguments to SRE.predict + ## v0.1.6 * Added scale_aperture to have control on aperture of basis functions * Adde remove_basis to easily remove basis functions diff --git a/src-i386/FRK.so b/src-i386/FRK.so deleted file mode 100644 index 6b541df..0000000 Binary files a/src-i386/FRK.so and /dev/null differ diff --git a/src-i386/RcppExports.cpp b/src-i386/RcppExports.cpp deleted file mode 100644 index 6253e43..0000000 --- a/src-i386/RcppExports.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by using Rcpp::compileAttributes() -> do not edit by hand -// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -#include - -using namespace Rcpp; - -// distR_C -NumericMatrix distR_C(NumericMatrix x, NumericMatrix y); -RcppExport SEXP _FRK_distR_C(SEXP xSEXP, SEXP ySEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< NumericMatrix >::type x(xSEXP); - Rcpp::traits::input_parameter< NumericMatrix >::type y(ySEXP); - rcpp_result_gen = Rcpp::wrap(distR_C(x, y)); - return rcpp_result_gen; -END_RCPP -} diff --git a/src-i386/RcppExports.o b/src-i386/RcppExports.o deleted file mode 100644 index 762ffb7..0000000 Binary files a/src-i386/RcppExports.o and /dev/null differ diff --git a/src-i386/SuiteSparse_config.h b/src-i386/SuiteSparse_config.h deleted file mode 100644 index fff5ea0..0000000 --- a/src-i386/SuiteSparse_config.h +++ /dev/null @@ -1,202 +0,0 @@ -/* ========================================================================== */ -/* === SuiteSparse_config =================================================== */ -/* ========================================================================== */ - -/* Configuration file for SuiteSparse: a Suite of Sparse matrix packages - * (AMD, COLAMD, CCOLAMD, CAMD, CHOLMOD, UMFPACK, CXSparse, and others). - * - * SuiteSparse_config.h provides the definition of the long integer. On most - * systems, a C program can be compiled in LP64 mode, in which long's and - * pointers are both 64-bits, and int's are 32-bits. Windows 64, however, uses - * the LLP64 model, in which int's and long's are 32-bits, and long long's and - * pointers are 64-bits. - * - * SuiteSparse packages that include long integer versions are - * intended for the LP64 mode. However, as a workaround for Windows 64 - * (and perhaps other systems), the long integer can be redefined. - * - * If _WIN64 is defined, then the __int64 type is used instead of long. - * - * The long integer can also be defined at compile time. For example, this - * could be added to SuiteSparse_config.mk: - * - * CFLAGS = -O -D'SuiteSparse_long=long long' \ - * -D'SuiteSparse_long_max=9223372036854775801' -D'SuiteSparse_long_idd="lld"' - * - * This file defines SuiteSparse_long as either long (on all but _WIN64) or - * __int64 on Windows 64. The intent is that a SuiteSparse_long is always a - * 64-bit integer in a 64-bit code. ptrdiff_t might be a better choice than - * long; it is always the same size as a pointer. - * - * This file also defines the SUITESPARSE_VERSION and related definitions. - * - * Copyright (c) 2012, Timothy A. Davis. No licensing restrictions apply - * to this file or to the SuiteSparse_config directory. - * Author: Timothy A. Davis. - */ - -#ifndef _SUITESPARSECONFIG_H -#define _SUITESPARSECONFIG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* ========================================================================== */ -/* === SuiteSparse_long ===================================================== */ -/* ========================================================================== */ - -#ifndef SuiteSparse_long - -#ifdef _WIN64 - -#define SuiteSparse_long __int64 -#define SuiteSparse_long_max _I64_MAX -#define SuiteSparse_long_idd "I64d" - -#else - -#define SuiteSparse_long long -#define SuiteSparse_long_max LONG_MAX -#define SuiteSparse_long_idd "ld" - -#endif -#define SuiteSparse_long_id "%" SuiteSparse_long_idd -#endif - -/* For backward compatibility with prior versions of SuiteSparse. The UF_* - * macros are deprecated and will be removed in a future version. */ -#ifndef UF_long -#define UF_long SuiteSparse_long -#define UF_long_max SuiteSparse_long_max -#define UF_long_idd SuiteSparse_long_idd -#define UF_long_id SuiteSparse_long_id -#endif - -/* ========================================================================== */ -/* === SuiteSparse_config parameters and functions ========================== */ -/* ========================================================================== */ - -/* SuiteSparse-wide parameters will be placed in this struct. */ - -typedef struct SuiteSparse_config_struct -{ - void *(*malloc_memory) (size_t) ; /* pointer to malloc */ - void *(*realloc_memory) (void *, size_t) ; /* pointer to realloc */ - void (*free_memory) (void *) ; /* pointer to free */ - void *(*calloc_memory) (size_t, size_t) ; /* pointer to calloc */ - -} SuiteSparse_config ; - -void *SuiteSparse_malloc /* pointer to allocated block of memory */ -( - size_t nitems, /* number of items to malloc (>=1 is enforced) */ - size_t size_of_item, /* sizeof each item */ - int *ok, /* TRUE if successful, FALSE otherwise */ - SuiteSparse_config *config /* SuiteSparse-wide configuration */ -) ; - -void *SuiteSparse_free /* always returns NULL */ -( - void *p, /* block to free */ - SuiteSparse_config *config /* SuiteSparse-wide configuration */ -) ; - -void SuiteSparse_tic /* start the timer */ -( - double tic [2] /* output, contents undefined on input */ -) ; - -double SuiteSparse_toc /* return time in seconds since last tic */ -( - double tic [2] /* input: from last call to SuiteSparse_tic */ -) ; - -double SuiteSparse_time /* returns current wall clock time in seconds */ -( - void -) ; - -/* determine which timer to use, if any */ -#ifndef NTIMER -#ifdef _POSIX_C_SOURCE -#if _POSIX_C_SOURCE >= 199309L -#define SUITESPARSE_TIMER_ENABLED -#endif -#endif -#endif - -/* ========================================================================== */ -/* === SuiteSparse version ================================================== */ -/* ========================================================================== */ - -/* SuiteSparse is not a package itself, but a collection of packages, some of - * which must be used together (UMFPACK requires AMD, CHOLMOD requires AMD, - * COLAMD, CAMD, and CCOLAMD, etc). A version number is provided here for the - * collection itself. The versions of packages within each version of - * SuiteSparse are meant to work together. Combining one packge from one - * version of SuiteSparse, with another package from another version of - * SuiteSparse, may or may not work. - * - * SuiteSparse contains the following packages: - * - * SuiteSparse_config version 4.2.1 (version always the same as SuiteSparse) - * AMD version 2.3.1 - * BTF version 1.2.0 - * CAMD version 2.3.1 - * CCOLAMD version 2.8.0 - * CHOLMOD version 2.1.2 - * COLAMD version 2.8.0 - * CSparse version 3.1.2 - * CXSparse version 3.1.2 - * KLU version 1.2.1 - * LDL version 2.1.0 - * RBio version 2.1.1 - * SPQR version 1.3.1 (full name is SuiteSparseQR) - * UMFPACK version 5.6.2 - * MATLAB_Tools various packages & M-files - * - * Other package dependencies: - * BLAS required by CHOLMOD and UMFPACK - * LAPACK required by CHOLMOD - * METIS 4.0.1 required by CHOLMOD (optional) and KLU (optional) - */ - - -int SuiteSparse_version /* returns SUITESPARSE_VERSION */ -( - /* output, not defined on input. Not used if NULL. Returns - the three version codes in version [0..2]: - version [0] is SUITESPARSE_MAIN_VERSION - version [1] is SUITESPARSE_SUB_VERSION - version [2] is SUITESPARSE_SUBSUB_VERSION - */ - int version [3] -) ; - -/* Versions prior to 4.2.0 do not have the above function. The following - code fragment will work with any version of SuiteSparse: - - #ifdef SUITESPARSE_HAS_VERSION_FUNCTION - v = SuiteSparse_version (NULL) ; - #else - v = SUITESPARSE_VERSION ; - #endif -*/ -#define SUITESPARSE_HAS_VERSION_FUNCTION - -#define SUITESPARSE_DATE "April 25, 2013" -#define SUITESPARSE_VER_CODE(main,sub) ((main) * 1000 + (sub)) -#define SUITESPARSE_MAIN_VERSION 4 -#define SUITESPARSE_SUB_VERSION 2 -#define SUITESPARSE_SUBSUB_VERSION 1 -#define SUITESPARSE_VERSION \ - SUITESPARSE_VER_CODE(SUITESPARSE_MAIN_VERSION,SUITESPARSE_SUB_VERSION) - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src-i386/amd.h b/src-i386/amd.h deleted file mode 100644 index 210967b..0000000 --- a/src-i386/amd.h +++ /dev/null @@ -1,411 +0,0 @@ -/* ========================================================================= */ -/* === AMD: approximate minimum degree ordering =========================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD Version 2.2, Copyright (c) 2007 by Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* AMD finds a symmetric ordering P of a matrix A so that the Cholesky - * factorization of P*A*P' has fewer nonzeros and takes less work than the - * Cholesky factorization of A. If A is not symmetric, then it performs its - * ordering on the matrix A+A'. Two sets of user-callable routines are - * provided, one for int integers and the other for SuiteSparse_long integers. - * - * The method is based on the approximate minimum degree algorithm, discussed - * in Amestoy, Davis, and Duff, "An approximate degree ordering algorithm", - * SIAM Journal of Matrix Analysis and Applications, vol. 17, no. 4, pp. - * 886-905, 1996. This package can perform both the AMD ordering (with - * aggressive absorption), and the AMDBAR ordering (without aggressive - * absorption) discussed in the above paper. This package differs from the - * Fortran codes discussed in the paper: - * - * (1) it can ignore "dense" rows and columns, leading to faster run times - * (2) it computes the ordering of A+A' if A is not symmetric - * (3) it is followed by a depth-first post-ordering of the assembly tree - * (or supernodal elimination tree) - * - * For historical reasons, the Fortran versions, amd.f and amdbar.f, have - * been left (nearly) unchanged. They compute the identical ordering as - * described in the above paper. - */ - -#ifndef AMD_H -#define AMD_H - -/* make it easy for C++ programs to include AMD */ -#ifdef __cplusplus -extern "C" { -#endif - -/* get the definition of size_t: */ -#include - -#include "SuiteSparse_config.h" - -int amd_order /* returns AMD_OK, AMD_OK_BUT_JUMBLED, - * AMD_INVALID, or AMD_OUT_OF_MEMORY */ -( - int n, /* A is n-by-n. n must be >= 0. */ - const int Ap [ ], /* column pointers for A, of size n+1 */ - const int Ai [ ], /* row indices of A, of size nz = Ap [n] */ - int P [ ], /* output permutation, of size n */ - double Control [ ], /* input Control settings, of size AMD_CONTROL */ - double Info [ ] /* output Info statistics, of size AMD_INFO */ -) ; - -SuiteSparse_long amd_l_order /* see above for description of arguments */ -( - SuiteSparse_long n, - const SuiteSparse_long Ap [ ], - const SuiteSparse_long Ai [ ], - SuiteSparse_long P [ ], - double Control [ ], - double Info [ ] -) ; - -/* Input arguments (not modified): - * - * n: the matrix A is n-by-n. - * Ap: an int/SuiteSparse_long array of size n+1, containing column - * pointers of A. - * Ai: an int/SuiteSparse_long array of size nz, containing the row - * indices of A, where nz = Ap [n]. - * Control: a double array of size AMD_CONTROL, containing control - * parameters. Defaults are used if Control is NULL. - * - * Output arguments (not defined on input): - * - * P: an int/SuiteSparse_long array of size n, containing the output - * permutation. If row i is the kth pivot row, then P [k] = i. In - * MATLAB notation, the reordered matrix is A (P,P). - * Info: a double array of size AMD_INFO, containing statistical - * information. Ignored if Info is NULL. - * - * On input, the matrix A is stored in column-oriented form. The row indices - * of nonzero entries in column j are stored in Ai [Ap [j] ... Ap [j+1]-1]. - * - * If the row indices appear in ascending order in each column, and there - * are no duplicate entries, then amd_order is slightly more efficient in - * terms of time and memory usage. If this condition does not hold, a copy - * of the matrix is created (where these conditions do hold), and the copy is - * ordered. This feature is new to v2.0 (v1.2 and earlier required this - * condition to hold for the input matrix). - * - * Row indices must be in the range 0 to - * n-1. Ap [0] must be zero, and thus nz = Ap [n] is the number of nonzeros - * in A. The array Ap is of size n+1, and the array Ai is of size nz = Ap [n]. - * The matrix does not need to be symmetric, and the diagonal does not need to - * be present (if diagonal entries are present, they are ignored except for - * the output statistic Info [AMD_NZDIAG]). The arrays Ai and Ap are not - * modified. This form of the Ap and Ai arrays to represent the nonzero - * pattern of the matrix A is the same as that used internally by MATLAB. - * If you wish to use a more flexible input structure, please see the - * umfpack_*_triplet_to_col routines in the UMFPACK package, at - * http://www.suitesparse.com. - * - * Restrictions: n >= 0. Ap [0] = 0. Ap [j] <= Ap [j+1] for all j in the - * range 0 to n-1. nz = Ap [n] >= 0. Ai [0..nz-1] must be in the range 0 - * to n-1. Finally, Ai, Ap, and P must not be NULL. If any of these - * restrictions are not met, AMD returns AMD_INVALID. - * - * AMD returns: - * - * AMD_OK if the matrix is valid and sufficient memory can be allocated to - * perform the ordering. - * - * AMD_OUT_OF_MEMORY if not enough memory can be allocated. - * - * AMD_INVALID if the input arguments n, Ap, Ai are invalid, or if P is - * NULL. - * - * AMD_OK_BUT_JUMBLED if the matrix had unsorted columns, and/or duplicate - * entries, but was otherwise valid. - * - * The AMD routine first forms the pattern of the matrix A+A', and then - * computes a fill-reducing ordering, P. If P [k] = i, then row/column i of - * the original is the kth pivotal row. In MATLAB notation, the permuted - * matrix is A (P,P), except that 0-based indexing is used instead of the - * 1-based indexing in MATLAB. - * - * The Control array is used to set various parameters for AMD. If a NULL - * pointer is passed, default values are used. The Control array is not - * modified. - * - * Control [AMD_DENSE]: controls the threshold for "dense" rows/columns. - * A dense row/column in A+A' can cause AMD to spend a lot of time in - * ordering the matrix. If Control [AMD_DENSE] >= 0, rows/columns - * with more than Control [AMD_DENSE] * sqrt (n) entries are ignored - * during the ordering, and placed last in the output order. The - * default value of Control [AMD_DENSE] is 10. If negative, no - * rows/columns are treated as "dense". Rows/columns with 16 or - * fewer off-diagonal entries are never considered "dense". - * - * Control [AMD_AGGRESSIVE]: controls whether or not to use aggressive - * absorption, in which a prior element is absorbed into the current - * element if is a subset of the current element, even if it is not - * adjacent to the current pivot element (refer to Amestoy, Davis, - * & Duff, 1996, for more details). The default value is nonzero, - * which means to perform aggressive absorption. This nearly always - * leads to a better ordering (because the approximate degrees are - * more accurate) and a lower execution time. There are cases where - * it can lead to a slightly worse ordering, however. To turn it off, - * set Control [AMD_AGGRESSIVE] to 0. - * - * Control [2..4] are not used in the current version, but may be used in - * future versions. - * - * The Info array provides statistics about the ordering on output. If it is - * not present, the statistics are not returned. This is not an error - * condition. - * - * Info [AMD_STATUS]: the return value of AMD, either AMD_OK, - * AMD_OK_BUT_JUMBLED, AMD_OUT_OF_MEMORY, or AMD_INVALID. - * - * Info [AMD_N]: n, the size of the input matrix - * - * Info [AMD_NZ]: the number of nonzeros in A, nz = Ap [n] - * - * Info [AMD_SYMMETRY]: the symmetry of the matrix A. It is the number - * of "matched" off-diagonal entries divided by the total number of - * off-diagonal entries. An entry A(i,j) is matched if A(j,i) is also - * an entry, for any pair (i,j) for which i != j. In MATLAB notation, - * S = spones (A) ; - * B = tril (S, -1) + triu (S, 1) ; - * symmetry = nnz (B & B') / nnz (B) ; - * - * Info [AMD_NZDIAG]: the number of entries on the diagonal of A. - * - * Info [AMD_NZ_A_PLUS_AT]: the number of nonzeros in A+A', excluding the - * diagonal. If A is perfectly symmetric (Info [AMD_SYMMETRY] = 1) - * with a fully nonzero diagonal, then Info [AMD_NZ_A_PLUS_AT] = nz-n - * (the smallest possible value). If A is perfectly unsymmetric - * (Info [AMD_SYMMETRY] = 0, for an upper triangular matrix, for - * example) with no diagonal, then Info [AMD_NZ_A_PLUS_AT] = 2*nz - * (the largest possible value). - * - * Info [AMD_NDENSE]: the number of "dense" rows/columns of A+A' that were - * removed from A prior to ordering. These are placed last in the - * output order P. - * - * Info [AMD_MEMORY]: the amount of memory used by AMD, in bytes. In the - * current version, this is 1.2 * Info [AMD_NZ_A_PLUS_AT] + 9*n - * times the size of an integer. This is at most 2.4nz + 9n. This - * excludes the size of the input arguments Ai, Ap, and P, which have - * a total size of nz + 2*n + 1 integers. - * - * Info [AMD_NCMPA]: the number of garbage collections performed. - * - * Info [AMD_LNZ]: the number of nonzeros in L (excluding the diagonal). - * This is a slight upper bound because mass elimination is combined - * with the approximate degree update. It is a rough upper bound if - * there are many "dense" rows/columns. The rest of the statistics, - * below, are also slight or rough upper bounds, for the same reasons. - * The post-ordering of the assembly tree might also not exactly - * correspond to a true elimination tree postordering. - * - * Info [AMD_NDIV]: the number of divide operations for a subsequent LDL' - * or LU factorization of the permuted matrix A (P,P). - * - * Info [AMD_NMULTSUBS_LDL]: the number of multiply-subtract pairs for a - * subsequent LDL' factorization of A (P,P). - * - * Info [AMD_NMULTSUBS_LU]: the number of multiply-subtract pairs for a - * subsequent LU factorization of A (P,P), assuming that no numerical - * pivoting is required. - * - * Info [AMD_DMAX]: the maximum number of nonzeros in any column of L, - * including the diagonal. - * - * Info [14..19] are not used in the current version, but may be used in - * future versions. - */ - -/* ------------------------------------------------------------------------- */ -/* direct interface to AMD */ -/* ------------------------------------------------------------------------- */ - -/* amd_2 is the primary AMD ordering routine. It is not meant to be - * user-callable because of its restrictive inputs and because it destroys - * the user's input matrix. It does not check its inputs for errors, either. - * However, if you can work with these restrictions it can be faster than - * amd_order and use less memory (assuming that you can create your own copy - * of the matrix for AMD to destroy). Refer to AMD/Source/amd_2.c for a - * description of each parameter. */ - -void amd_2 -( - int n, - int Pe [ ], - int Iw [ ], - int Len [ ], - int iwlen, - int pfree, - int Nv [ ], - int Next [ ], - int Last [ ], - int Head [ ], - int Elen [ ], - int Degree [ ], - int W [ ], - double Control [ ], - double Info [ ] -) ; - -void amd_l2 -( - SuiteSparse_long n, - SuiteSparse_long Pe [ ], - SuiteSparse_long Iw [ ], - SuiteSparse_long Len [ ], - SuiteSparse_long iwlen, - SuiteSparse_long pfree, - SuiteSparse_long Nv [ ], - SuiteSparse_long Next [ ], - SuiteSparse_long Last [ ], - SuiteSparse_long Head [ ], - SuiteSparse_long Elen [ ], - SuiteSparse_long Degree [ ], - SuiteSparse_long W [ ], - double Control [ ], - double Info [ ] -) ; - -/* ------------------------------------------------------------------------- */ -/* amd_valid */ -/* ------------------------------------------------------------------------- */ - -/* Returns AMD_OK or AMD_OK_BUT_JUMBLED if the matrix is valid as input to - * amd_order; the latter is returned if the matrix has unsorted and/or - * duplicate row indices in one or more columns. Returns AMD_INVALID if the - * matrix cannot be passed to amd_order. For amd_order, the matrix must also - * be square. The first two arguments are the number of rows and the number - * of columns of the matrix. For its use in AMD, these must both equal n. - * - * NOTE: this routine returned TRUE/FALSE in v1.2 and earlier. - */ - -int amd_valid -( - int n_row, /* # of rows */ - int n_col, /* # of columns */ - const int Ap [ ], /* column pointers, of size n_col+1 */ - const int Ai [ ] /* row indices, of size Ap [n_col] */ -) ; - -SuiteSparse_long amd_l_valid -( - SuiteSparse_long n_row, - SuiteSparse_long n_col, - const SuiteSparse_long Ap [ ], - const SuiteSparse_long Ai [ ] -) ; - -/* ------------------------------------------------------------------------- */ -/* AMD memory manager and printf routines */ -/* ------------------------------------------------------------------------- */ - -/* The user can redefine these to change the malloc, free, and printf routines - * that AMD uses. */ - -#ifndef EXTERN -#define EXTERN extern -#endif - -EXTERN void *(*amd_malloc) (size_t) ; /* pointer to malloc */ -EXTERN void (*amd_free) (void *) ; /* pointer to free */ -EXTERN void *(*amd_realloc) (void *, size_t) ; /* pointer to realloc */ -EXTERN void *(*amd_calloc) (size_t, size_t) ; /* pointer to calloc */ -EXTERN int (*amd_printf) (const char *, ...) ; /* pointer to printf */ - -/* ------------------------------------------------------------------------- */ -/* AMD Control and Info arrays */ -/* ------------------------------------------------------------------------- */ - -/* amd_defaults: sets the default control settings */ -void amd_defaults (double Control [ ]) ; -void amd_l_defaults (double Control [ ]) ; - -/* amd_control: prints the control settings */ -void amd_control (double Control [ ]) ; -void amd_l_control (double Control [ ]) ; - -/* amd_info: prints the statistics */ -void amd_info (double Info [ ]) ; -void amd_l_info (double Info [ ]) ; - -#define AMD_CONTROL 5 /* size of Control array */ -#define AMD_INFO 20 /* size of Info array */ - -/* contents of Control */ -#define AMD_DENSE 0 /* "dense" if degree > Control [0] * sqrt (n) */ -#define AMD_AGGRESSIVE 1 /* do aggressive absorption if Control [1] != 0 */ - -/* default Control settings */ -#define AMD_DEFAULT_DENSE 10.0 /* default "dense" degree 10*sqrt(n) */ -#define AMD_DEFAULT_AGGRESSIVE 1 /* do aggressive absorption by default */ - -/* contents of Info */ -#define AMD_STATUS 0 /* return value of amd_order and amd_l_order */ -#define AMD_N 1 /* A is n-by-n */ -#define AMD_NZ 2 /* number of nonzeros in A */ -#define AMD_SYMMETRY 3 /* symmetry of pattern (1 is sym., 0 is unsym.) */ -#define AMD_NZDIAG 4 /* # of entries on diagonal */ -#define AMD_NZ_A_PLUS_AT 5 /* nz in A+A' */ -#define AMD_NDENSE 6 /* number of "dense" rows/columns in A */ -#define AMD_MEMORY 7 /* amount of memory used by AMD */ -#define AMD_NCMPA 8 /* number of garbage collections in AMD */ -#define AMD_LNZ 9 /* approx. nz in L, excluding the diagonal */ -#define AMD_NDIV 10 /* number of fl. point divides for LU and LDL' */ -#define AMD_NMULTSUBS_LDL 11 /* number of fl. point (*,-) pairs for LDL' */ -#define AMD_NMULTSUBS_LU 12 /* number of fl. point (*,-) pairs for LU */ -#define AMD_DMAX 13 /* max nz. in any column of L, incl. diagonal */ - -/* ------------------------------------------------------------------------- */ -/* return values of AMD */ -/* ------------------------------------------------------------------------- */ - -#define AMD_OK 0 /* success */ -#define AMD_OUT_OF_MEMORY -1 /* malloc failed, or problem too large */ -#define AMD_INVALID -2 /* input arguments are not valid */ -#define AMD_OK_BUT_JUMBLED 1 /* input matrix is OK for amd_order, but - * columns were not sorted, and/or duplicate entries were present. AMD had - * to do extra work before ordering the matrix. This is a warning, not an - * error. */ - -/* ========================================================================== */ -/* === AMD version ========================================================== */ -/* ========================================================================== */ - -/* AMD Version 1.2 and later include the following definitions. - * As an example, to test if the version you are using is 1.2 or later: - * - * #ifdef AMD_VERSION - * if (AMD_VERSION >= AMD_VERSION_CODE (1,2)) ... - * #endif - * - * This also works during compile-time: - * - * #if defined(AMD_VERSION) && (AMD_VERSION >= AMD_VERSION_CODE (1,2)) - * printf ("This is version 1.2 or later\n") ; - * #else - * printf ("This is an early version\n") ; - * #endif - * - * Versions 1.1 and earlier of AMD do not include a #define'd version number. - */ - -#define AMD_DATE "Jun 20, 2012" -#define AMD_VERSION_CODE(main,sub) ((main) * 1000 + (sub)) -#define AMD_MAIN_VERSION 2 -#define AMD_SUB_VERSION 3 -#define AMD_SUBSUB_VERSION 1 -#define AMD_VERSION AMD_VERSION_CODE(AMD_MAIN_VERSION,AMD_SUB_VERSION) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src-i386/amd_1.c b/src-i386/amd_1.c deleted file mode 100644 index 296d198..0000000 --- a/src-i386/amd_1.c +++ /dev/null @@ -1,183 +0,0 @@ -/* ========================================================================= */ -/* === AMD_1 =============================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* AMD_1: Construct A+A' for a sparse matrix A and perform the AMD ordering. - * - * The n-by-n sparse matrix A can be unsymmetric. It is stored in MATLAB-style - * compressed-column form, with sorted row indices in each column, and no - * duplicate entries. Diagonal entries may be present, but they are ignored. - * Row indices of column j of A are stored in Ai [Ap [j] ... Ap [j+1]-1]. - * Ap [0] must be zero, and nz = Ap [n] is the number of entries in A. The - * size of the matrix, n, must be greater than or equal to zero. - * - * This routine must be preceded by a call to AMD_aat, which computes the - * number of entries in each row/column in A+A', excluding the diagonal. - * Len [j], on input, is the number of entries in row/column j of A+A'. This - * routine constructs the matrix A+A' and then calls AMD_2. No error checking - * is performed (this was done in AMD_valid). - */ - -#include /* required */ -#include /* for distribution functions etc. */ - -#include "amd_internal.h" - -GLOBAL void AMD_1 -( - Int n, /* n > 0 */ - const Int Ap [ ], /* input of size n+1, not modified */ - const Int Ai [ ], /* input of size nz = Ap [n], not modified */ - Int P [ ], /* size n output permutation */ - Int Pinv [ ], /* size n output inverse permutation */ - Int Len [ ], /* size n input, undefined on output */ - Int slen, /* slen >= sum (Len [0..n-1]) + 7n, - * ideally slen = 1.2 * sum (Len) + 8n */ - Int S [ ], /* size slen workspace */ - double Control [ ], /* input array of size AMD_CONTROL */ - double Info [ ] /* output array of size AMD_INFO */ -) -{ - Int i, j, k, p, pfree, iwlen, pj, p1, p2, pj2, *Iw, *Pe, *Nv, *Head, - *Elen, *Degree, *s, *W, *Sp, *Tp ; - - /* --------------------------------------------------------------------- */ - /* construct the matrix for AMD_2 */ - /* --------------------------------------------------------------------- */ - - ASSERT (n > 0) ; - - iwlen = slen - 6*n ; - s = S ; - Pe = s ; s += n ; - Nv = s ; s += n ; - Head = s ; s += n ; - Elen = s ; s += n ; - Degree = s ; s += n ; - W = s ; s += n ; - Iw = s ; s += iwlen ; - - ASSERT (AMD_valid (n, n, Ap, Ai) == AMD_OK) ; - - /* construct the pointers for A+A' */ - Sp = Nv ; /* use Nv and W as workspace for Sp and Tp [ */ - Tp = W ; - pfree = 0 ; - for (j = 0 ; j < n ; j++) - { - Pe [j] = pfree ; - Sp [j] = pfree ; - pfree += Len [j] ; - } - - /* Note that this restriction on iwlen is slightly more restrictive than - * what is strictly required in AMD_2. AMD_2 can operate with no elbow - * room at all, but it will be very slow. For better performance, at - * least size-n elbow room is enforced. */ - ASSERT (iwlen >= pfree + n) ; - -#ifndef NDEBUG - for (p = 0 ; p < iwlen ; p++) Iw [p] = EMPTY ; -#endif - - for (k = 0 ; k < n ; k++) - { - AMD_DEBUG1 (("Construct row/column k= "ID" of A+A'\n", k)) ; - p1 = Ap [k] ; - p2 = Ap [k+1] ; - - /* construct A+A' */ - for (p = p1 ; p < p2 ; ) - { - /* scan the upper triangular part of A */ - j = Ai [p] ; - ASSERT (j >= 0 && j < n) ; - if (j < k) - { - /* entry A (j,k) in the strictly upper triangular part */ - ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ; - ASSERT (Sp [k] < (k == n-1 ? pfree : Pe [k+1])) ; - Iw [Sp [j]++] = k ; - Iw [Sp [k]++] = j ; - p++ ; - } - else if (j == k) - { - /* skip the diagonal */ - p++ ; - break ; - } - else /* j > k */ - { - /* first entry below the diagonal */ - break ; - } - /* scan lower triangular part of A, in column j until reaching - * row k. Start where last scan left off. */ - ASSERT (Ap [j] <= Tp [j] && Tp [j] <= Ap [j+1]) ; - pj2 = Ap [j+1] ; - for (pj = Tp [j] ; pj < pj2 ; ) - { - i = Ai [pj] ; - ASSERT (i >= 0 && i < n) ; - if (i < k) - { - /* A (i,j) is only in the lower part, not in upper */ - ASSERT (Sp [i] < (i == n-1 ? pfree : Pe [i+1])) ; - ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ; - Iw [Sp [i]++] = j ; - Iw [Sp [j]++] = i ; - pj++ ; - } - else if (i == k) - { - /* entry A (k,j) in lower part and A (j,k) in upper */ - pj++ ; - break ; - } - else /* i > k */ - { - /* consider this entry later, when k advances to i */ - break ; - } - } - Tp [j] = pj ; - } - Tp [k] = p ; - } - - /* clean up, for remaining mismatched entries */ - for (j = 0 ; j < n ; j++) - { - for (pj = Tp [j] ; pj < Ap [j+1] ; pj++) - { - i = Ai [pj] ; - ASSERT (i >= 0 && i < n) ; - /* A (i,j) is only in the lower part, not in upper */ - ASSERT (Sp [i] < (i == n-1 ? pfree : Pe [i+1])) ; - ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ; - Iw [Sp [i]++] = j ; - Iw [Sp [j]++] = i ; - } - } - -#ifndef NDEBUG - for (j = 0 ; j < n-1 ; j++) ASSERT (Sp [j] == Pe [j+1]) ; - ASSERT (Sp [n-1] == pfree) ; -#endif - - /* Tp and Sp no longer needed ] */ - - /* --------------------------------------------------------------------- */ - /* order the matrix */ - /* --------------------------------------------------------------------- */ - - AMD_2 (n, Pe, Iw, Len, iwlen, pfree, - Nv, Pinv, P, Head, Elen, Degree, W, Control, Info) ; -} diff --git a/src-i386/amd_1.o b/src-i386/amd_1.o deleted file mode 100644 index 61f0890..0000000 Binary files a/src-i386/amd_1.o and /dev/null differ diff --git a/src-i386/amd_2.c b/src-i386/amd_2.c deleted file mode 100644 index 7e8c838..0000000 --- a/src-i386/amd_2.c +++ /dev/null @@ -1,1842 +0,0 @@ -/* ========================================================================= */ -/* === AMD_2 =============================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* AMD_2: performs the AMD ordering on a symmetric sparse matrix A, followed - * by a postordering (via depth-first search) of the assembly tree using the - * AMD_postorder routine. - */ - -#include "amd_internal.h" - -/* ========================================================================= */ -/* === clear_flag ========================================================== */ -/* ========================================================================= */ - -static Int clear_flag (Int wflg, Int wbig, Int W [ ], Int n) -{ - Int x ; - if (wflg < 2 || wflg >= wbig) - { - for (x = 0 ; x < n ; x++) - { - if (W [x] != 0) W [x] = 1 ; - } - wflg = 2 ; - } - /* at this point, W [0..n-1] < wflg holds */ - return (wflg) ; -} - - -/* ========================================================================= */ -/* === AMD_2 =============================================================== */ -/* ========================================================================= */ - -GLOBAL void AMD_2 -( - Int n, /* A is n-by-n, where n > 0 */ - Int Pe [ ], /* Pe [0..n-1]: index in Iw of row i on input */ - Int Iw [ ], /* workspace of size iwlen. Iw [0..pfree-1] - * holds the matrix on input */ - Int Len [ ], /* Len [0..n-1]: length for row/column i on input */ - Int iwlen, /* length of Iw. iwlen >= pfree + n */ - Int pfree, /* Iw [pfree ... iwlen-1] is empty on input */ - - /* 7 size-n workspaces, not defined on input: */ - Int Nv [ ], /* the size of each supernode on output */ - Int Next [ ], /* the output inverse permutation */ - Int Last [ ], /* the output permutation */ - Int Head [ ], - Int Elen [ ], /* the size columns of L for each supernode */ - Int Degree [ ], - Int W [ ], - - /* control parameters and output statistics */ - double Control [ ], /* array of size AMD_CONTROL */ - double Info [ ] /* array of size AMD_INFO */ -) -{ - -/* - * Given a representation of the nonzero pattern of a symmetric matrix, A, - * (excluding the diagonal) perform an approximate minimum (UMFPACK/MA38-style) - * degree ordering to compute a pivot order such that the introduction of - * nonzeros (fill-in) in the Cholesky factors A = LL' is kept low. At each - * step, the pivot selected is the one with the minimum UMFAPACK/MA38-style - * upper-bound on the external degree. This routine can optionally perform - * aggresive absorption (as done by MC47B in the Harwell Subroutine - * Library). - * - * The approximate degree algorithm implemented here is the symmetric analog of - * the degree update algorithm in MA38 and UMFPACK (the Unsymmetric-pattern - * MultiFrontal PACKage, both by Davis and Duff). The routine is based on the - * MA27 minimum degree ordering algorithm by Iain Duff and John Reid. - * - * This routine is a translation of the original AMDBAR and MC47B routines, - * in Fortran, with the following modifications: - * - * (1) dense rows/columns are removed prior to ordering the matrix, and placed - * last in the output order. The presence of a dense row/column can - * increase the ordering time by up to O(n^2), unless they are removed - * prior to ordering. - * - * (2) the minimum degree ordering is followed by a postordering (depth-first - * search) of the assembly tree. Note that mass elimination (discussed - * below) combined with the approximate degree update can lead to the mass - * elimination of nodes with lower exact degree than the current pivot - * element. No additional fill-in is caused in the representation of the - * Schur complement. The mass-eliminated nodes merge with the current - * pivot element. They are ordered prior to the current pivot element. - * Because they can have lower exact degree than the current element, the - * merger of two or more of these nodes in the current pivot element can - * lead to a single element that is not a "fundamental supernode". The - * diagonal block can have zeros in it. Thus, the assembly tree used here - * is not guaranteed to be the precise supernodal elemination tree (with - * "funadmental" supernodes), and the postordering performed by this - * routine is not guaranteed to be a precise postordering of the - * elimination tree. - * - * (3) input parameters are added, to control aggressive absorption and the - * detection of "dense" rows/columns of A. - * - * (4) additional statistical information is returned, such as the number of - * nonzeros in L, and the flop counts for subsequent LDL' and LU - * factorizations. These are slight upper bounds, because of the mass - * elimination issue discussed above. - * - * (5) additional routines are added to interface this routine to MATLAB - * to provide a simple C-callable user-interface, to check inputs for - * errors, compute the symmetry of the pattern of A and the number of - * nonzeros in each row/column of A+A', to compute the pattern of A+A', - * to perform the assembly tree postordering, and to provide debugging - * ouput. Many of these functions are also provided by the Fortran - * Harwell Subroutine Library routine MC47A. - * - * (6) both int and SuiteSparse_long versions are provided. In the - * descriptions below and integer is and int or SuiteSparse_long depending - * on which version is being used. - - ********************************************************************** - ***** CAUTION: ARGUMENTS ARE NOT CHECKED FOR ERRORS ON INPUT. ****** - ********************************************************************** - ** If you want error checking, a more versatile input format, and a ** - ** simpler user interface, use amd_order or amd_l_order instead. ** - ** This routine is not meant to be user-callable. ** - ********************************************************************** - - * ---------------------------------------------------------------------------- - * References: - * ---------------------------------------------------------------------------- - * - * [1] Timothy A. Davis and Iain Duff, "An unsymmetric-pattern multifrontal - * method for sparse LU factorization", SIAM J. Matrix Analysis and - * Applications, vol. 18, no. 1, pp. 140-158. Discusses UMFPACK / MA38, - * which first introduced the approximate minimum degree used by this - * routine. - * - * [2] Patrick Amestoy, Timothy A. Davis, and Iain S. Duff, "An approximate - * minimum degree ordering algorithm," SIAM J. Matrix Analysis and - * Applications, vol. 17, no. 4, pp. 886-905, 1996. Discusses AMDBAR and - * MC47B, which are the Fortran versions of this routine. - * - * [3] Alan George and Joseph Liu, "The evolution of the minimum degree - * ordering algorithm," SIAM Review, vol. 31, no. 1, pp. 1-19, 1989. - * We list below the features mentioned in that paper that this code - * includes: - * - * mass elimination: - * Yes. MA27 relied on supervariable detection for mass elimination. - * - * indistinguishable nodes: - * Yes (we call these "supervariables"). This was also in the MA27 - * code - although we modified the method of detecting them (the - * previous hash was the true degree, which we no longer keep track - * of). A supervariable is a set of rows with identical nonzero - * pattern. All variables in a supervariable are eliminated together. - * Each supervariable has as its numerical name that of one of its - * variables (its principal variable). - * - * quotient graph representation: - * Yes. We use the term "element" for the cliques formed during - * elimination. This was also in the MA27 code. The algorithm can - * operate in place, but it will work more efficiently if given some - * "elbow room." - * - * element absorption: - * Yes. This was also in the MA27 code. - * - * external degree: - * Yes. The MA27 code was based on the true degree. - * - * incomplete degree update and multiple elimination: - * No. This was not in MA27, either. Our method of degree update - * within MC47B is element-based, not variable-based. It is thus - * not well-suited for use with incomplete degree update or multiple - * elimination. - * - * Authors, and Copyright (C) 2004 by: - * Timothy A. Davis, Patrick Amestoy, Iain S. Duff, John K. Reid. - * - * Acknowledgements: This work (and the UMFPACK package) was supported by the - * National Science Foundation (ASC-9111263, DMS-9223088, and CCR-0203270). - * The UMFPACK/MA38 approximate degree update algorithm, the unsymmetric analog - * which forms the basis of AMD, was developed while Tim Davis was supported by - * CERFACS (Toulouse, France) in a post-doctoral position. This C version, and - * the etree postorder, were written while Tim Davis was on sabbatical at - * Stanford University and Lawrence Berkeley National Laboratory. - - * ---------------------------------------------------------------------------- - * INPUT ARGUMENTS (unaltered): - * ---------------------------------------------------------------------------- - - * n: The matrix order. Restriction: n >= 1. - * - * iwlen: The size of the Iw array. On input, the matrix is stored in - * Iw [0..pfree-1]. However, Iw [0..iwlen-1] should be slightly larger - * than what is required to hold the matrix, at least iwlen >= pfree + n. - * Otherwise, excessive compressions will take place. The recommended - * value of iwlen is 1.2 * pfree + n, which is the value used in the - * user-callable interface to this routine (amd_order.c). The algorithm - * will not run at all if iwlen < pfree. Restriction: iwlen >= pfree + n. - * Note that this is slightly more restrictive than the actual minimum - * (iwlen >= pfree), but AMD_2 will be very slow with no elbow room. - * Thus, this routine enforces a bare minimum elbow room of size n. - * - * pfree: On input the tail end of the array, Iw [pfree..iwlen-1], is empty, - * and the matrix is stored in Iw [0..pfree-1]. During execution, - * additional data is placed in Iw, and pfree is modified so that - * Iw [pfree..iwlen-1] is always the unused part of Iw. - * - * Control: A double array of size AMD_CONTROL containing input parameters - * that affect how the ordering is computed. If NULL, then default - * settings are used. - * - * Control [AMD_DENSE] is used to determine whether or not a given input - * row is "dense". A row is "dense" if the number of entries in the row - * exceeds Control [AMD_DENSE] times sqrt (n), except that rows with 16 or - * fewer entries are never considered "dense". To turn off the detection - * of dense rows, set Control [AMD_DENSE] to a negative number, or to a - * number larger than sqrt (n). The default value of Control [AMD_DENSE] - * is AMD_DEFAULT_DENSE, which is defined in amd.h as 10. - * - * Control [AMD_AGGRESSIVE] is used to determine whether or not aggressive - * absorption is to be performed. If nonzero, then aggressive absorption - * is performed (this is the default). - - * ---------------------------------------------------------------------------- - * INPUT/OUPUT ARGUMENTS: - * ---------------------------------------------------------------------------- - * - * Pe: An integer array of size n. On input, Pe [i] is the index in Iw of - * the start of row i. Pe [i] is ignored if row i has no off-diagonal - * entries. Thus Pe [i] must be in the range 0 to pfree-1 for non-empty - * rows. - * - * During execution, it is used for both supervariables and elements: - * - * Principal supervariable i: index into Iw of the description of - * supervariable i. A supervariable represents one or more rows of - * the matrix with identical nonzero pattern. In this case, - * Pe [i] >= 0. - * - * Non-principal supervariable i: if i has been absorbed into another - * supervariable j, then Pe [i] = FLIP (j), where FLIP (j) is defined - * as (-(j)-2). Row j has the same pattern as row i. Note that j - * might later be absorbed into another supervariable j2, in which - * case Pe [i] is still FLIP (j), and Pe [j] = FLIP (j2) which is - * < EMPTY, where EMPTY is defined as (-1) in amd_internal.h. - * - * Unabsorbed element e: the index into Iw of the description of element - * e, if e has not yet been absorbed by a subsequent element. Element - * e is created when the supervariable of the same name is selected as - * the pivot. In this case, Pe [i] >= 0. - * - * Absorbed element e: if element e is absorbed into element e2, then - * Pe [e] = FLIP (e2). This occurs when the pattern of e (which we - * refer to as Le) is found to be a subset of the pattern of e2 (that - * is, Le2). In this case, Pe [i] < EMPTY. If element e is "null" - * (it has no nonzeros outside its pivot block), then Pe [e] = EMPTY, - * and e is the root of an assembly subtree (or the whole tree if - * there is just one such root). - * - * Dense variable i: if i is "dense", then Pe [i] = EMPTY. - * - * On output, Pe holds the assembly tree/forest, which implicitly - * represents a pivot order with identical fill-in as the actual order - * (via a depth-first search of the tree), as follows. If Nv [i] > 0, - * then i represents a node in the assembly tree, and the parent of i is - * Pe [i], or EMPTY if i is a root. If Nv [i] = 0, then (i, Pe [i]) - * represents an edge in a subtree, the root of which is a node in the - * assembly tree. Note that i refers to a row/column in the original - * matrix, not the permuted matrix. - * - * Info: A double array of size AMD_INFO. If present, (that is, not NULL), - * then statistics about the ordering are returned in the Info array. - * See amd.h for a description. - - * ---------------------------------------------------------------------------- - * INPUT/MODIFIED (undefined on output): - * ---------------------------------------------------------------------------- - * - * Len: An integer array of size n. On input, Len [i] holds the number of - * entries in row i of the matrix, excluding the diagonal. The contents - * of Len are undefined on output. - * - * Iw: An integer array of size iwlen. On input, Iw [0..pfree-1] holds the - * description of each row i in the matrix. The matrix must be symmetric, - * and both upper and lower triangular parts must be present. The - * diagonal must not be present. Row i is held as follows: - * - * Len [i]: the length of the row i data structure in the Iw array. - * Iw [Pe [i] ... Pe [i] + Len [i] - 1]: - * the list of column indices for nonzeros in row i (simple - * supervariables), excluding the diagonal. All supervariables - * start with one row/column each (supervariable i is just row i). - * If Len [i] is zero on input, then Pe [i] is ignored on input. - * - * Note that the rows need not be in any particular order, and there - * may be empty space between the rows. - * - * During execution, the supervariable i experiences fill-in. This is - * represented by placing in i a list of the elements that cause fill-in - * in supervariable i: - * - * Len [i]: the length of supervariable i in the Iw array. - * Iw [Pe [i] ... Pe [i] + Elen [i] - 1]: - * the list of elements that contain i. This list is kept short - * by removing absorbed elements. - * Iw [Pe [i] + Elen [i] ... Pe [i] + Len [i] - 1]: - * the list of supervariables in i. This list is kept short by - * removing nonprincipal variables, and any entry j that is also - * contained in at least one of the elements (j in Le) in the list - * for i (e in row i). - * - * When supervariable i is selected as pivot, we create an element e of - * the same name (e=i): - * - * Len [e]: the length of element e in the Iw array. - * Iw [Pe [e] ... Pe [e] + Len [e] - 1]: - * the list of supervariables in element e. - * - * An element represents the fill-in that occurs when supervariable i is - * selected as pivot (which represents the selection of row i and all - * non-principal variables whose principal variable is i). We use the - * term Le to denote the set of all supervariables in element e. Absorbed - * supervariables and elements are pruned from these lists when - * computationally convenient. - * - * CAUTION: THE INPUT MATRIX IS OVERWRITTEN DURING COMPUTATION. - * The contents of Iw are undefined on output. - - * ---------------------------------------------------------------------------- - * OUTPUT (need not be set on input): - * ---------------------------------------------------------------------------- - * - * Nv: An integer array of size n. During execution, ABS (Nv [i]) is equal to - * the number of rows that are represented by the principal supervariable - * i. If i is a nonprincipal or dense variable, then Nv [i] = 0. - * Initially, Nv [i] = 1 for all i. Nv [i] < 0 signifies that i is a - * principal variable in the pattern Lme of the current pivot element me. - * After element me is constructed, Nv [i] is set back to a positive - * value. - * - * On output, Nv [i] holds the number of pivots represented by super - * row/column i of the original matrix, or Nv [i] = 0 for non-principal - * rows/columns. Note that i refers to a row/column in the original - * matrix, not the permuted matrix. - * - * Elen: An integer array of size n. See the description of Iw above. At the - * start of execution, Elen [i] is set to zero for all rows i. During - * execution, Elen [i] is the number of elements in the list for - * supervariable i. When e becomes an element, Elen [e] = FLIP (esize) is - * set, where esize is the size of the element (the number of pivots, plus - * the number of nonpivotal entries). Thus Elen [e] < EMPTY. - * Elen (i) = EMPTY set when variable i becomes nonprincipal. - * - * For variables, Elen (i) >= EMPTY holds until just before the - * postordering and permutation vectors are computed. For elements, - * Elen [e] < EMPTY holds. - * - * On output, Elen [i] is the degree of the row/column in the Cholesky - * factorization of the permuted matrix, corresponding to the original row - * i, if i is a super row/column. It is equal to EMPTY if i is - * non-principal. Note that i refers to a row/column in the original - * matrix, not the permuted matrix. - * - * Note that the contents of Elen on output differ from the Fortran - * version (Elen holds the inverse permutation in the Fortran version, - * which is instead returned in the Next array in this C version, - * described below). - * - * Last: In a degree list, Last [i] is the supervariable preceding i, or EMPTY - * if i is the head of the list. In a hash bucket, Last [i] is the hash - * key for i. - * - * Last [Head [hash]] is also used as the head of a hash bucket if - * Head [hash] contains a degree list (see the description of Head, - * below). - * - * On output, Last [0..n-1] holds the permutation. That is, if - * i = Last [k], then row i is the kth pivot row (where k ranges from 0 to - * n-1). Row Last [k] of A is the kth row in the permuted matrix, PAP'. - * - * Next: Next [i] is the supervariable following i in a link list, or EMPTY if - * i is the last in the list. Used for two kinds of lists: degree lists - * and hash buckets (a supervariable can be in only one kind of list at a - * time). - * - * On output Next [0..n-1] holds the inverse permutation. That is, if - * k = Next [i], then row i is the kth pivot row. Row i of A appears as - * the (Next[i])-th row in the permuted matrix, PAP'. - * - * Note that the contents of Next on output differ from the Fortran - * version (Next is undefined on output in the Fortran version). - - * ---------------------------------------------------------------------------- - * LOCAL WORKSPACE (not input or output - used only during execution): - * ---------------------------------------------------------------------------- - * - * Degree: An integer array of size n. If i is a supervariable, then - * Degree [i] holds the current approximation of the external degree of - * row i (an upper bound). The external degree is the number of nonzeros - * in row i, minus ABS (Nv [i]), the diagonal part. The bound is equal to - * the exact external degree if Elen [i] is less than or equal to two. - * - * We also use the term "external degree" for elements e to refer to - * |Le \ Lme|. If e is an element, then Degree [e] is |Le|, which is the - * degree of the off-diagonal part of the element e (not including the - * diagonal part). - * - * Head: An integer array of size n. Head is used for degree lists. - * Head [deg] is the first supervariable in a degree list. All - * supervariables i in a degree list Head [deg] have the same approximate - * degree, namely, deg = Degree [i]. If the list Head [deg] is empty then - * Head [deg] = EMPTY. - * - * During supervariable detection Head [hash] also serves as a pointer to - * a hash bucket. If Head [hash] >= 0, there is a degree list of degree - * hash. The hash bucket head pointer is Last [Head [hash]]. If - * Head [hash] = EMPTY, then the degree list and hash bucket are both - * empty. If Head [hash] < EMPTY, then the degree list is empty, and - * FLIP (Head [hash]) is the head of the hash bucket. After supervariable - * detection is complete, all hash buckets are empty, and the - * (Last [Head [hash]] = EMPTY) condition is restored for the non-empty - * degree lists. - * - * W: An integer array of size n. The flag array W determines the status of - * elements and variables, and the external degree of elements. - * - * for elements: - * if W [e] = 0, then the element e is absorbed. - * if W [e] >= wflg, then W [e] - wflg is the size of the set - * |Le \ Lme|, in terms of nonzeros (the sum of ABS (Nv [i]) for - * each principal variable i that is both in the pattern of - * element e and NOT in the pattern of the current pivot element, - * me). - * if wflg > W [e] > 0, then e is not absorbed and has not yet been - * seen in the scan of the element lists in the computation of - * |Le\Lme| in Scan 1 below. - * - * for variables: - * during supervariable detection, if W [j] != wflg then j is - * not in the pattern of variable i. - * - * The W array is initialized by setting W [i] = 1 for all i, and by - * setting wflg = 2. It is reinitialized if wflg becomes too large (to - * ensure that wflg+n does not cause integer overflow). - - * ---------------------------------------------------------------------------- - * LOCAL INTEGERS: - * ---------------------------------------------------------------------------- - */ - - Int deg, degme, dext, lemax, e, elenme, eln, i, ilast, inext, j, - jlast, jnext, k, knt1, knt2, knt3, lenj, ln, me, mindeg, nel, nleft, - nvi, nvj, nvpiv, slenme, wbig, we, wflg, wnvi, ok, ndense, ncmpa, - dense, aggressive ; - - unsigned Int hash ; /* unsigned, so that hash % n is well defined.*/ - -/* - * deg: the degree of a variable or element - * degme: size, |Lme|, of the current element, me (= Degree [me]) - * dext: external degree, |Le \ Lme|, of some element e - * lemax: largest |Le| seen so far (called dmax in Fortran version) - * e: an element - * elenme: the length, Elen [me], of element list of pivotal variable - * eln: the length, Elen [...], of an element list - * hash: the computed value of the hash function - * i: a supervariable - * ilast: the entry in a link list preceding i - * inext: the entry in a link list following i - * j: a supervariable - * jlast: the entry in a link list preceding j - * jnext: the entry in a link list, or path, following j - * k: the pivot order of an element or variable - * knt1: loop counter used during element construction - * knt2: loop counter used during element construction - * knt3: loop counter used during compression - * lenj: Len [j] - * ln: length of a supervariable list - * me: current supervariable being eliminated, and the current - * element created by eliminating that supervariable - * mindeg: current minimum degree - * nel: number of pivots selected so far - * nleft: n - nel, the number of nonpivotal rows/columns remaining - * nvi: the number of variables in a supervariable i (= Nv [i]) - * nvj: the number of variables in a supervariable j (= Nv [j]) - * nvpiv: number of pivots in current element - * slenme: number of variables in variable list of pivotal variable - * wbig: = (INT_MAX - n) for the int version, (SuiteSparse_long_max - n) - * for the SuiteSparse_long version. wflg is not allowed to - * be >= wbig. - * we: W [e] - * wflg: used for flagging the W array. See description of Iw. - * wnvi: wflg - Nv [i] - * x: either a supervariable or an element - * - * ok: true if supervariable j can be absorbed into i - * ndense: number of "dense" rows/columns - * dense: rows/columns with initial degree > dense are considered "dense" - * aggressive: true if aggressive absorption is being performed - * ncmpa: number of garbage collections - - * ---------------------------------------------------------------------------- - * LOCAL DOUBLES, used for statistical output only (except for alpha): - * ---------------------------------------------------------------------------- - */ - - double f, r, ndiv, s, nms_lu, nms_ldl, dmax, alpha, lnz, lnzme ; - -/* - * f: nvpiv - * r: degme + nvpiv - * ndiv: number of divisions for LU or LDL' factorizations - * s: number of multiply-subtract pairs for LU factorization, for the - * current element me - * nms_lu number of multiply-subtract pairs for LU factorization - * nms_ldl number of multiply-subtract pairs for LDL' factorization - * dmax: the largest number of entries in any column of L, including the - * diagonal - * alpha: "dense" degree ratio - * lnz: the number of nonzeros in L (excluding the diagonal) - * lnzme: the number of nonzeros in L (excl. the diagonal) for the - * current element me - - * ---------------------------------------------------------------------------- - * LOCAL "POINTERS" (indices into the Iw array) - * ---------------------------------------------------------------------------- -*/ - - Int p, p1, p2, p3, p4, pdst, pend, pj, pme, pme1, pme2, pn, psrc ; - -/* - * Any parameter (Pe [...] or pfree) or local variable starting with "p" (for - * Pointer) is an index into Iw, and all indices into Iw use variables starting - * with "p." The only exception to this rule is the iwlen input argument. - * - * p: pointer into lots of things - * p1: Pe [i] for some variable i (start of element list) - * p2: Pe [i] + Elen [i] - 1 for some variable i - * p3: index of first supervariable in clean list - * p4: - * pdst: destination pointer, for compression - * pend: end of memory to compress - * pj: pointer into an element or variable - * pme: pointer into the current element (pme1...pme2) - * pme1: the current element, me, is stored in Iw [pme1...pme2] - * pme2: the end of the current element - * pn: pointer into a "clean" variable, also used to compress - * psrc: source pointer, for compression -*/ - -/* ========================================================================= */ -/* INITIALIZATIONS */ -/* ========================================================================= */ - - /* Note that this restriction on iwlen is slightly more restrictive than - * what is actually required in AMD_2. AMD_2 can operate with no elbow - * room at all, but it will be slow. For better performance, at least - * size-n elbow room is enforced. */ - ASSERT (iwlen >= pfree + n) ; - ASSERT (n > 0) ; - - /* initialize output statistics */ - lnz = 0 ; - ndiv = 0 ; - nms_lu = 0 ; - nms_ldl = 0 ; - dmax = 1 ; - me = EMPTY ; - - mindeg = 0 ; - ncmpa = 0 ; - nel = 0 ; - lemax = 0 ; - - /* get control parameters */ - if (Control != (double *) NULL) - { - alpha = Control [AMD_DENSE] ; - aggressive = (Control [AMD_AGGRESSIVE] != 0) ; - } - else - { - alpha = AMD_DEFAULT_DENSE ; - aggressive = AMD_DEFAULT_AGGRESSIVE ; - } - /* Note: if alpha is NaN, this is undefined: */ - if (alpha < 0) - { - /* only remove completely dense rows/columns */ - dense = n-2 ; - } - else - { - dense = alpha * sqrt ((double) n) ; - } - dense = MAX (16, dense) ; - dense = MIN (n, dense) ; - AMD_DEBUG1 (("\n\nAMD (debug), alpha %g, aggr. "ID"\n", - alpha, aggressive)) ; - - for (i = 0 ; i < n ; i++) - { - Last [i] = EMPTY ; - Head [i] = EMPTY ; - Next [i] = EMPTY ; - /* if separate Hhead array is used for hash buckets: * - Hhead [i] = EMPTY ; - */ - Nv [i] = 1 ; - W [i] = 1 ; - Elen [i] = 0 ; - Degree [i] = Len [i] ; - } - -#ifndef NDEBUG - AMD_DEBUG1 (("\n======Nel "ID" initial\n", nel)) ; - AMD_dump (n, Pe, Iw, Len, iwlen, pfree, Nv, Next, Last, - Head, Elen, Degree, W, -1) ; -#endif - - /* initialize wflg */ - wbig = Int_MAX - n ; - wflg = clear_flag (0, wbig, W, n) ; - - /* --------------------------------------------------------------------- */ - /* initialize degree lists and eliminate dense and empty rows */ - /* --------------------------------------------------------------------- */ - - ndense = 0 ; - - for (i = 0 ; i < n ; i++) - { - deg = Degree [i] ; - ASSERT (deg >= 0 && deg < n) ; - if (deg == 0) - { - - /* ------------------------------------------------------------- - * we have a variable that can be eliminated at once because - * there is no off-diagonal non-zero in its row. Note that - * Nv [i] = 1 for an empty variable i. It is treated just - * the same as an eliminated element i. - * ------------------------------------------------------------- */ - - Elen [i] = FLIP (1) ; - nel++ ; - Pe [i] = EMPTY ; - W [i] = 0 ; - - } - else if (deg > dense) - { - - /* ------------------------------------------------------------- - * Dense variables are not treated as elements, but as unordered, - * non-principal variables that have no parent. They do not take - * part in the postorder, since Nv [i] = 0. Note that the Fortran - * version does not have this option. - * ------------------------------------------------------------- */ - - AMD_DEBUG1 (("Dense node "ID" degree "ID"\n", i, deg)) ; - ndense++ ; - Nv [i] = 0 ; /* do not postorder this node */ - Elen [i] = EMPTY ; - nel++ ; - Pe [i] = EMPTY ; - - } - else - { - - /* ------------------------------------------------------------- - * place i in the degree list corresponding to its degree - * ------------------------------------------------------------- */ - - inext = Head [deg] ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = i ; - Next [i] = inext ; - Head [deg] = i ; - - } - } - -/* ========================================================================= */ -/* WHILE (selecting pivots) DO */ -/* ========================================================================= */ - - while (nel < n) - { - -#ifndef NDEBUG - AMD_DEBUG1 (("\n======Nel "ID"\n", nel)) ; - if (AMD_debug >= 2) - { - AMD_dump (n, Pe, Iw, Len, iwlen, pfree, Nv, Next, - Last, Head, Elen, Degree, W, nel) ; - } -#endif - -/* ========================================================================= */ -/* GET PIVOT OF MINIMUM DEGREE */ -/* ========================================================================= */ - - /* ----------------------------------------------------------------- */ - /* find next supervariable for elimination */ - /* ----------------------------------------------------------------- */ - - ASSERT (mindeg >= 0 && mindeg < n) ; - for (deg = mindeg ; deg < n ; deg++) - { - me = Head [deg] ; - if (me != EMPTY) break ; - } - mindeg = deg ; - ASSERT (me >= 0 && me < n) ; - AMD_DEBUG1 (("=================me: "ID"\n", me)) ; - - /* ----------------------------------------------------------------- */ - /* remove chosen variable from link list */ - /* ----------------------------------------------------------------- */ - - inext = Next [me] ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = EMPTY ; - Head [deg] = inext ; - - /* ----------------------------------------------------------------- */ - /* me represents the elimination of pivots nel to nel+Nv[me]-1. */ - /* place me itself as the first in this set. */ - /* ----------------------------------------------------------------- */ - - elenme = Elen [me] ; - nvpiv = Nv [me] ; - ASSERT (nvpiv > 0) ; - nel += nvpiv ; - -/* ========================================================================= */ -/* CONSTRUCT NEW ELEMENT */ -/* ========================================================================= */ - - /* ----------------------------------------------------------------- - * At this point, me is the pivotal supervariable. It will be - * converted into the current element. Scan list of the pivotal - * supervariable, me, setting tree pointers and constructing new list - * of supervariables for the new element, me. p is a pointer to the - * current position in the old list. - * ----------------------------------------------------------------- */ - - /* flag the variable "me" as being in Lme by negating Nv [me] */ - Nv [me] = -nvpiv ; - degme = 0 ; - ASSERT (Pe [me] >= 0 && Pe [me] < iwlen) ; - - if (elenme == 0) - { - - /* ------------------------------------------------------------- */ - /* construct the new element in place */ - /* ------------------------------------------------------------- */ - - pme1 = Pe [me] ; - pme2 = pme1 - 1 ; - - for (p = pme1 ; p <= pme1 + Len [me] - 1 ; p++) - { - i = Iw [p] ; - ASSERT (i >= 0 && i < n && Nv [i] >= 0) ; - nvi = Nv [i] ; - if (nvi > 0) - { - - /* ----------------------------------------------------- */ - /* i is a principal variable not yet placed in Lme. */ - /* store i in new list */ - /* ----------------------------------------------------- */ - - /* flag i as being in Lme by negating Nv [i] */ - degme += nvi ; - Nv [i] = -nvi ; - Iw [++pme2] = i ; - - /* ----------------------------------------------------- */ - /* remove variable i from degree list. */ - /* ----------------------------------------------------- */ - - ilast = Last [i] ; - inext = Next [i] ; - ASSERT (ilast >= EMPTY && ilast < n) ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = ilast ; - if (ilast != EMPTY) - { - Next [ilast] = inext ; - } - else - { - /* i is at the head of the degree list */ - ASSERT (Degree [i] >= 0 && Degree [i] < n) ; - Head [Degree [i]] = inext ; - } - } - } - } - else - { - - /* ------------------------------------------------------------- */ - /* construct the new element in empty space, Iw [pfree ...] */ - /* ------------------------------------------------------------- */ - - p = Pe [me] ; - pme1 = pfree ; - slenme = Len [me] - elenme ; - - for (knt1 = 1 ; knt1 <= elenme + 1 ; knt1++) - { - - if (knt1 > elenme) - { - /* search the supervariables in me. */ - e = me ; - pj = p ; - ln = slenme ; - AMD_DEBUG2 (("Search sv: "ID" "ID" "ID"\n", me,pj,ln)) ; - } - else - { - /* search the elements in me. */ - e = Iw [p++] ; - ASSERT (e >= 0 && e < n) ; - pj = Pe [e] ; - ln = Len [e] ; - AMD_DEBUG2 (("Search element e "ID" in me "ID"\n", e,me)) ; - ASSERT (Elen [e] < EMPTY && W [e] > 0 && pj >= 0) ; - } - ASSERT (ln >= 0 && (ln == 0 || (pj >= 0 && pj < iwlen))) ; - - /* --------------------------------------------------------- - * search for different supervariables and add them to the - * new list, compressing when necessary. this loop is - * executed once for each element in the list and once for - * all the supervariables in the list. - * --------------------------------------------------------- */ - - for (knt2 = 1 ; knt2 <= ln ; knt2++) - { - i = Iw [pj++] ; - ASSERT (i >= 0 && i < n && (i == me || Elen [i] >= EMPTY)); - nvi = Nv [i] ; - AMD_DEBUG2 ((": "ID" "ID" "ID" "ID"\n", - i, Elen [i], Nv [i], wflg)) ; - - if (nvi > 0) - { - - /* ------------------------------------------------- */ - /* compress Iw, if necessary */ - /* ------------------------------------------------- */ - - if (pfree >= iwlen) - { - - AMD_DEBUG1 (("GARBAGE COLLECTION\n")) ; - - /* prepare for compressing Iw by adjusting pointers - * and lengths so that the lists being searched in - * the inner and outer loops contain only the - * remaining entries. */ - - Pe [me] = p ; - Len [me] -= knt1 ; - /* check if nothing left of supervariable me */ - if (Len [me] == 0) Pe [me] = EMPTY ; - Pe [e] = pj ; - Len [e] = ln - knt2 ; - /* nothing left of element e */ - if (Len [e] == 0) Pe [e] = EMPTY ; - - ncmpa++ ; /* one more garbage collection */ - - /* store first entry of each object in Pe */ - /* FLIP the first entry in each object */ - for (j = 0 ; j < n ; j++) - { - pn = Pe [j] ; - if (pn >= 0) - { - ASSERT (pn >= 0 && pn < iwlen) ; - Pe [j] = Iw [pn] ; - Iw [pn] = FLIP (j) ; - } - } - - /* psrc/pdst point to source/destination */ - psrc = 0 ; - pdst = 0 ; - pend = pme1 - 1 ; - - while (psrc <= pend) - { - /* search for next FLIP'd entry */ - j = FLIP (Iw [psrc++]) ; - if (j >= 0) - { - AMD_DEBUG2 (("Got object j: "ID"\n", j)) ; - Iw [pdst] = Pe [j] ; - Pe [j] = pdst++ ; - lenj = Len [j] ; - /* copy from source to destination */ - for (knt3 = 0 ; knt3 <= lenj - 2 ; knt3++) - { - Iw [pdst++] = Iw [psrc++] ; - } - } - } - - /* move the new partially-constructed element */ - p1 = pdst ; - for (psrc = pme1 ; psrc <= pfree-1 ; psrc++) - { - Iw [pdst++] = Iw [psrc] ; - } - pme1 = p1 ; - pfree = pdst ; - pj = Pe [e] ; - p = Pe [me] ; - - } - - /* ------------------------------------------------- */ - /* i is a principal variable not yet placed in Lme */ - /* store i in new list */ - /* ------------------------------------------------- */ - - /* flag i as being in Lme by negating Nv [i] */ - degme += nvi ; - Nv [i] = -nvi ; - Iw [pfree++] = i ; - AMD_DEBUG2 ((" s: "ID" nv "ID"\n", i, Nv [i])); - - /* ------------------------------------------------- */ - /* remove variable i from degree link list */ - /* ------------------------------------------------- */ - - ilast = Last [i] ; - inext = Next [i] ; - ASSERT (ilast >= EMPTY && ilast < n) ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = ilast ; - if (ilast != EMPTY) - { - Next [ilast] = inext ; - } - else - { - /* i is at the head of the degree list */ - ASSERT (Degree [i] >= 0 && Degree [i] < n) ; - Head [Degree [i]] = inext ; - } - } - } - - if (e != me) - { - /* set tree pointer and flag to indicate element e is - * absorbed into new element me (the parent of e is me) */ - AMD_DEBUG1 ((" Element "ID" => "ID"\n", e, me)) ; - Pe [e] = FLIP (me) ; - W [e] = 0 ; - } - } - - pme2 = pfree - 1 ; - } - - /* ----------------------------------------------------------------- */ - /* me has now been converted into an element in Iw [pme1..pme2] */ - /* ----------------------------------------------------------------- */ - - /* degme holds the external degree of new element */ - Degree [me] = degme ; - Pe [me] = pme1 ; - Len [me] = pme2 - pme1 + 1 ; - ASSERT (Pe [me] >= 0 && Pe [me] < iwlen) ; - - Elen [me] = FLIP (nvpiv + degme) ; - /* FLIP (Elen (me)) is now the degree of pivot (including - * diagonal part). */ - -#ifndef NDEBUG - AMD_DEBUG2 (("New element structure: length= "ID"\n", pme2-pme1+1)) ; - for (pme = pme1 ; pme <= pme2 ; pme++) AMD_DEBUG3 ((" "ID"", Iw[pme])); - AMD_DEBUG3 (("\n")) ; -#endif - - /* ----------------------------------------------------------------- */ - /* make sure that wflg is not too large. */ - /* ----------------------------------------------------------------- */ - - /* With the current value of wflg, wflg+n must not cause integer - * overflow */ - - wflg = clear_flag (wflg, wbig, W, n) ; - -/* ========================================================================= */ -/* COMPUTE (W [e] - wflg) = |Le\Lme| FOR ALL ELEMENTS */ -/* ========================================================================= */ - - /* ----------------------------------------------------------------- - * Scan 1: compute the external degrees of previous elements with - * respect to the current element. That is: - * (W [e] - wflg) = |Le \ Lme| - * for each element e that appears in any supervariable in Lme. The - * notation Le refers to the pattern (list of supervariables) of a - * previous element e, where e is not yet absorbed, stored in - * Iw [Pe [e] + 1 ... Pe [e] + Len [e]]. The notation Lme - * refers to the pattern of the current element (stored in - * Iw [pme1..pme2]). If aggressive absorption is enabled, and - * (W [e] - wflg) becomes zero, then the element e will be absorbed - * in Scan 2. - * ----------------------------------------------------------------- */ - - AMD_DEBUG2 (("me: ")) ; - for (pme = pme1 ; pme <= pme2 ; pme++) - { - i = Iw [pme] ; - ASSERT (i >= 0 && i < n) ; - eln = Elen [i] ; - AMD_DEBUG3 ((""ID" Elen "ID": \n", i, eln)) ; - if (eln > 0) - { - /* note that Nv [i] has been negated to denote i in Lme: */ - nvi = -Nv [i] ; - ASSERT (nvi > 0 && Pe [i] >= 0 && Pe [i] < iwlen) ; - wnvi = wflg - nvi ; - for (p = Pe [i] ; p <= Pe [i] + eln - 1 ; p++) - { - e = Iw [p] ; - ASSERT (e >= 0 && e < n) ; - we = W [e] ; - AMD_DEBUG4 ((" e "ID" we "ID" ", e, we)) ; - if (we >= wflg) - { - /* unabsorbed element e has been seen in this loop */ - AMD_DEBUG4 ((" unabsorbed, first time seen")) ; - we -= nvi ; - } - else if (we != 0) - { - /* e is an unabsorbed element */ - /* this is the first we have seen e in all of Scan 1 */ - AMD_DEBUG4 ((" unabsorbed")) ; - we = Degree [e] + wnvi ; - } - AMD_DEBUG4 (("\n")) ; - W [e] = we ; - } - } - } - AMD_DEBUG2 (("\n")) ; - -/* ========================================================================= */ -/* DEGREE UPDATE AND ELEMENT ABSORPTION */ -/* ========================================================================= */ - - /* ----------------------------------------------------------------- - * Scan 2: for each i in Lme, sum up the degree of Lme (which is - * degme), plus the sum of the external degrees of each Le for the - * elements e appearing within i, plus the supervariables in i. - * Place i in hash list. - * ----------------------------------------------------------------- */ - - for (pme = pme1 ; pme <= pme2 ; pme++) - { - i = Iw [pme] ; - ASSERT (i >= 0 && i < n && Nv [i] < 0 && Elen [i] >= 0) ; - AMD_DEBUG2 (("Updating: i "ID" "ID" "ID"\n", i, Elen[i], Len [i])); - p1 = Pe [i] ; - p2 = p1 + Elen [i] - 1 ; - pn = p1 ; - hash = 0 ; - deg = 0 ; - ASSERT (p1 >= 0 && p1 < iwlen && p2 >= -1 && p2 < iwlen) ; - - /* ------------------------------------------------------------- */ - /* scan the element list associated with supervariable i */ - /* ------------------------------------------------------------- */ - - /* UMFPACK/MA38-style approximate degree: */ - if (aggressive) - { - for (p = p1 ; p <= p2 ; p++) - { - e = Iw [p] ; - ASSERT (e >= 0 && e < n) ; - we = W [e] ; - if (we != 0) - { - /* e is an unabsorbed element */ - /* dext = | Le \ Lme | */ - dext = we - wflg ; - if (dext > 0) - { - deg += dext ; - Iw [pn++] = e ; - hash += e ; - AMD_DEBUG4 ((" e: "ID" hash = "ID"\n",e,hash)) ; - } - else - { - /* external degree of e is zero, absorb e into me*/ - AMD_DEBUG1 ((" Element "ID" =>"ID" (aggressive)\n", - e, me)) ; - ASSERT (dext == 0) ; - Pe [e] = FLIP (me) ; - W [e] = 0 ; - } - } - } - } - else - { - for (p = p1 ; p <= p2 ; p++) - { - e = Iw [p] ; - ASSERT (e >= 0 && e < n) ; - we = W [e] ; - if (we != 0) - { - /* e is an unabsorbed element */ - dext = we - wflg ; - ASSERT (dext >= 0) ; - deg += dext ; - Iw [pn++] = e ; - hash += e ; - AMD_DEBUG4 ((" e: "ID" hash = "ID"\n",e,hash)) ; - } - } - } - - /* count the number of elements in i (including me): */ - Elen [i] = pn - p1 + 1 ; - - /* ------------------------------------------------------------- */ - /* scan the supervariables in the list associated with i */ - /* ------------------------------------------------------------- */ - - /* The bulk of the AMD run time is typically spent in this loop, - * particularly if the matrix has many dense rows that are not - * removed prior to ordering. */ - p3 = pn ; - p4 = p1 + Len [i] ; - for (p = p2 + 1 ; p < p4 ; p++) - { - j = Iw [p] ; - ASSERT (j >= 0 && j < n) ; - nvj = Nv [j] ; - if (nvj > 0) - { - /* j is unabsorbed, and not in Lme. */ - /* add to degree and add to new list */ - deg += nvj ; - Iw [pn++] = j ; - hash += j ; - AMD_DEBUG4 ((" s: "ID" hash "ID" Nv[j]= "ID"\n", - j, hash, nvj)) ; - } - } - - /* ------------------------------------------------------------- */ - /* update the degree and check for mass elimination */ - /* ------------------------------------------------------------- */ - - /* with aggressive absorption, deg==0 is identical to the - * Elen [i] == 1 && p3 == pn test, below. */ - ASSERT (IMPLIES (aggressive, (deg==0) == (Elen[i]==1 && p3==pn))) ; - - if (Elen [i] == 1 && p3 == pn) - { - - /* --------------------------------------------------------- */ - /* mass elimination */ - /* --------------------------------------------------------- */ - - /* There is nothing left of this node except for an edge to - * the current pivot element. Elen [i] is 1, and there are - * no variables adjacent to node i. Absorb i into the - * current pivot element, me. Note that if there are two or - * more mass eliminations, fillin due to mass elimination is - * possible within the nvpiv-by-nvpiv pivot block. It is this - * step that causes AMD's analysis to be an upper bound. - * - * The reason is that the selected pivot has a lower - * approximate degree than the true degree of the two mass - * eliminated nodes. There is no edge between the two mass - * eliminated nodes. They are merged with the current pivot - * anyway. - * - * No fillin occurs in the Schur complement, in any case, - * and this effect does not decrease the quality of the - * ordering itself, just the quality of the nonzero and - * flop count analysis. It also means that the post-ordering - * is not an exact elimination tree post-ordering. */ - - AMD_DEBUG1 ((" MASS i "ID" => parent e "ID"\n", i, me)) ; - Pe [i] = FLIP (me) ; - nvi = -Nv [i] ; - degme -= nvi ; - nvpiv += nvi ; - nel += nvi ; - Nv [i] = 0 ; - Elen [i] = EMPTY ; - - } - else - { - - /* --------------------------------------------------------- */ - /* update the upper-bound degree of i */ - /* --------------------------------------------------------- */ - - /* the following degree does not yet include the size - * of the current element, which is added later: */ - - Degree [i] = MIN (Degree [i], deg) ; - - /* --------------------------------------------------------- */ - /* add me to the list for i */ - /* --------------------------------------------------------- */ - - /* move first supervariable to end of list */ - Iw [pn] = Iw [p3] ; - /* move first element to end of element part of list */ - Iw [p3] = Iw [p1] ; - /* add new element, me, to front of list. */ - Iw [p1] = me ; - /* store the new length of the list in Len [i] */ - Len [i] = pn - p1 + 1 ; - - /* --------------------------------------------------------- */ - /* place in hash bucket. Save hash key of i in Last [i]. */ - /* --------------------------------------------------------- */ - - /* NOTE: this can fail if hash is negative, because the ANSI C - * standard does not define a % b when a and/or b are negative. - * That's why hash is defined as an unsigned Int, to avoid this - * problem. */ - hash = hash % n ; - ASSERT (((Int) hash) >= 0 && ((Int) hash) < n) ; - - /* if the Hhead array is not used: */ - j = Head [hash] ; - if (j <= EMPTY) - { - /* degree list is empty, hash head is FLIP (j) */ - Next [i] = FLIP (j) ; - Head [hash] = FLIP (i) ; - } - else - { - /* degree list is not empty, use Last [Head [hash]] as - * hash head. */ - Next [i] = Last [j] ; - Last [j] = i ; - } - - /* if a separate Hhead array is used: * - Next [i] = Hhead [hash] ; - Hhead [hash] = i ; - */ - - Last [i] = hash ; - } - } - - Degree [me] = degme ; - - /* ----------------------------------------------------------------- */ - /* Clear the counter array, W [...], by incrementing wflg. */ - /* ----------------------------------------------------------------- */ - - /* make sure that wflg+n does not cause integer overflow */ - lemax = MAX (lemax, degme) ; - wflg += lemax ; - wflg = clear_flag (wflg, wbig, W, n) ; - /* at this point, W [0..n-1] < wflg holds */ - -/* ========================================================================= */ -/* SUPERVARIABLE DETECTION */ -/* ========================================================================= */ - - AMD_DEBUG1 (("Detecting supervariables:\n")) ; - for (pme = pme1 ; pme <= pme2 ; pme++) - { - i = Iw [pme] ; - ASSERT (i >= 0 && i < n) ; - AMD_DEBUG2 (("Consider i "ID" nv "ID"\n", i, Nv [i])) ; - if (Nv [i] < 0) - { - /* i is a principal variable in Lme */ - - /* --------------------------------------------------------- - * examine all hash buckets with 2 or more variables. We do - * this by examing all unique hash keys for supervariables in - * the pattern Lme of the current element, me - * --------------------------------------------------------- */ - - /* let i = head of hash bucket, and empty the hash bucket */ - ASSERT (Last [i] >= 0 && Last [i] < n) ; - hash = Last [i] ; - - /* if Hhead array is not used: */ - j = Head [hash] ; - if (j == EMPTY) - { - /* hash bucket and degree list are both empty */ - i = EMPTY ; - } - else if (j < EMPTY) - { - /* degree list is empty */ - i = FLIP (j) ; - Head [hash] = EMPTY ; - } - else - { - /* degree list is not empty, restore Last [j] of head j */ - i = Last [j] ; - Last [j] = EMPTY ; - } - - /* if separate Hhead array is used: * - i = Hhead [hash] ; - Hhead [hash] = EMPTY ; - */ - - ASSERT (i >= EMPTY && i < n) ; - AMD_DEBUG2 (("----i "ID" hash "ID"\n", i, hash)) ; - - while (i != EMPTY && Next [i] != EMPTY) - { - - /* ----------------------------------------------------- - * this bucket has one or more variables following i. - * scan all of them to see if i can absorb any entries - * that follow i in hash bucket. Scatter i into w. - * ----------------------------------------------------- */ - - ln = Len [i] ; - eln = Elen [i] ; - ASSERT (ln >= 0 && eln >= 0) ; - ASSERT (Pe [i] >= 0 && Pe [i] < iwlen) ; - /* do not flag the first element in the list (me) */ - for (p = Pe [i] + 1 ; p <= Pe [i] + ln - 1 ; p++) - { - ASSERT (Iw [p] >= 0 && Iw [p] < n) ; - W [Iw [p]] = wflg ; - } - - /* ----------------------------------------------------- */ - /* scan every other entry j following i in bucket */ - /* ----------------------------------------------------- */ - - jlast = i ; - j = Next [i] ; - ASSERT (j >= EMPTY && j < n) ; - - while (j != EMPTY) - { - /* ------------------------------------------------- */ - /* check if j and i have identical nonzero pattern */ - /* ------------------------------------------------- */ - - AMD_DEBUG3 (("compare i "ID" and j "ID"\n", i,j)) ; - - /* check if i and j have the same Len and Elen */ - ASSERT (Len [j] >= 0 && Elen [j] >= 0) ; - ASSERT (Pe [j] >= 0 && Pe [j] < iwlen) ; - ok = (Len [j] == ln) && (Elen [j] == eln) ; - /* skip the first element in the list (me) */ - for (p = Pe [j] + 1 ; ok && p <= Pe [j] + ln - 1 ; p++) - { - ASSERT (Iw [p] >= 0 && Iw [p] < n) ; - if (W [Iw [p]] != wflg) ok = 0 ; - } - if (ok) - { - /* --------------------------------------------- */ - /* found it! j can be absorbed into i */ - /* --------------------------------------------- */ - - AMD_DEBUG1 (("found it! j "ID" => i "ID"\n", j,i)); - Pe [j] = FLIP (i) ; - /* both Nv [i] and Nv [j] are negated since they */ - /* are in Lme, and the absolute values of each */ - /* are the number of variables in i and j: */ - Nv [i] += Nv [j] ; - Nv [j] = 0 ; - Elen [j] = EMPTY ; - /* delete j from hash bucket */ - ASSERT (j != Next [j]) ; - j = Next [j] ; - Next [jlast] = j ; - - } - else - { - /* j cannot be absorbed into i */ - jlast = j ; - ASSERT (j != Next [j]) ; - j = Next [j] ; - } - ASSERT (j >= EMPTY && j < n) ; - } - - /* ----------------------------------------------------- - * no more variables can be absorbed into i - * go to next i in bucket and clear flag array - * ----------------------------------------------------- */ - - wflg++ ; - i = Next [i] ; - ASSERT (i >= EMPTY && i < n) ; - - } - } - } - AMD_DEBUG2 (("detect done\n")) ; - -/* ========================================================================= */ -/* RESTORE DEGREE LISTS AND REMOVE NONPRINCIPAL SUPERVARIABLES FROM ELEMENT */ -/* ========================================================================= */ - - p = pme1 ; - nleft = n - nel ; - for (pme = pme1 ; pme <= pme2 ; pme++) - { - i = Iw [pme] ; - ASSERT (i >= 0 && i < n) ; - nvi = -Nv [i] ; - AMD_DEBUG3 (("Restore i "ID" "ID"\n", i, nvi)) ; - if (nvi > 0) - { - /* i is a principal variable in Lme */ - /* restore Nv [i] to signify that i is principal */ - Nv [i] = nvi ; - - /* --------------------------------------------------------- */ - /* compute the external degree (add size of current element) */ - /* --------------------------------------------------------- */ - - deg = Degree [i] + degme - nvi ; - deg = MIN (deg, nleft - nvi) ; - ASSERT (IMPLIES (aggressive, deg > 0) && deg >= 0 && deg < n) ; - - /* --------------------------------------------------------- */ - /* place the supervariable at the head of the degree list */ - /* --------------------------------------------------------- */ - - inext = Head [deg] ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = i ; - Next [i] = inext ; - Last [i] = EMPTY ; - Head [deg] = i ; - - /* --------------------------------------------------------- */ - /* save the new degree, and find the minimum degree */ - /* --------------------------------------------------------- */ - - mindeg = MIN (mindeg, deg) ; - Degree [i] = deg ; - - /* --------------------------------------------------------- */ - /* place the supervariable in the element pattern */ - /* --------------------------------------------------------- */ - - Iw [p++] = i ; - - } - } - AMD_DEBUG2 (("restore done\n")) ; - -/* ========================================================================= */ -/* FINALIZE THE NEW ELEMENT */ -/* ========================================================================= */ - - AMD_DEBUG2 (("ME = "ID" DONE\n", me)) ; - Nv [me] = nvpiv ; - /* save the length of the list for the new element me */ - Len [me] = p - pme1 ; - if (Len [me] == 0) - { - /* there is nothing left of the current pivot element */ - /* it is a root of the assembly tree */ - Pe [me] = EMPTY ; - W [me] = 0 ; - } - if (elenme != 0) - { - /* element was not constructed in place: deallocate part of */ - /* it since newly nonprincipal variables may have been removed */ - pfree = p ; - } - - /* The new element has nvpiv pivots and the size of the contribution - * block for a multifrontal method is degme-by-degme, not including - * the "dense" rows/columns. If the "dense" rows/columns are included, - * the frontal matrix is no larger than - * (degme+ndense)-by-(degme+ndense). - */ - - if (Info != (double *) NULL) - { - f = nvpiv ; - r = degme + ndense ; - dmax = MAX (dmax, f + r) ; - - /* number of nonzeros in L (excluding the diagonal) */ - lnzme = f*r + (f-1)*f/2 ; - lnz += lnzme ; - - /* number of divide operations for LDL' and for LU */ - ndiv += lnzme ; - - /* number of multiply-subtract pairs for LU */ - s = f*r*r + r*(f-1)*f + (f-1)*f*(2*f-1)/6 ; - nms_lu += s ; - - /* number of multiply-subtract pairs for LDL' */ - nms_ldl += (s + lnzme)/2 ; - } - -#ifndef NDEBUG - AMD_DEBUG2 (("finalize done nel "ID" n "ID"\n ::::\n", nel, n)) ; - for (pme = Pe [me] ; pme <= Pe [me] + Len [me] - 1 ; pme++) - { - AMD_DEBUG3 ((" "ID"", Iw [pme])) ; - } - AMD_DEBUG3 (("\n")) ; -#endif - - } - -/* ========================================================================= */ -/* DONE SELECTING PIVOTS */ -/* ========================================================================= */ - - if (Info != (double *) NULL) - { - - /* count the work to factorize the ndense-by-ndense submatrix */ - f = ndense ; - dmax = MAX (dmax, (double) ndense) ; - - /* number of nonzeros in L (excluding the diagonal) */ - lnzme = (f-1)*f/2 ; - lnz += lnzme ; - - /* number of divide operations for LDL' and for LU */ - ndiv += lnzme ; - - /* number of multiply-subtract pairs for LU */ - s = (f-1)*f*(2*f-1)/6 ; - nms_lu += s ; - - /* number of multiply-subtract pairs for LDL' */ - nms_ldl += (s + lnzme)/2 ; - - /* number of nz's in L (excl. diagonal) */ - Info [AMD_LNZ] = lnz ; - - /* number of divide ops for LU and LDL' */ - Info [AMD_NDIV] = ndiv ; - - /* number of multiply-subtract pairs for LDL' */ - Info [AMD_NMULTSUBS_LDL] = nms_ldl ; - - /* number of multiply-subtract pairs for LU */ - Info [AMD_NMULTSUBS_LU] = nms_lu ; - - /* number of "dense" rows/columns */ - Info [AMD_NDENSE] = ndense ; - - /* largest front is dmax-by-dmax */ - Info [AMD_DMAX] = dmax ; - - /* number of garbage collections in AMD */ - Info [AMD_NCMPA] = ncmpa ; - - /* successful ordering */ - Info [AMD_STATUS] = AMD_OK ; - } - -/* ========================================================================= */ -/* POST-ORDERING */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- - * Variables at this point: - * - * Pe: holds the elimination tree. The parent of j is FLIP (Pe [j]), - * or EMPTY if j is a root. The tree holds both elements and - * non-principal (unordered) variables absorbed into them. - * Dense variables are non-principal and unordered. - * - * Elen: holds the size of each element, including the diagonal part. - * FLIP (Elen [e]) > 0 if e is an element. For unordered - * variables i, Elen [i] is EMPTY. - * - * Nv: Nv [e] > 0 is the number of pivots represented by the element e. - * For unordered variables i, Nv [i] is zero. - * - * Contents no longer needed: - * W, Iw, Len, Degree, Head, Next, Last. - * - * The matrix itself has been destroyed. - * - * n: the size of the matrix. - * No other scalars needed (pfree, iwlen, etc.) - * ------------------------------------------------------------------------- */ - - /* restore Pe */ - for (i = 0 ; i < n ; i++) - { - Pe [i] = FLIP (Pe [i]) ; - } - - /* restore Elen, for output information, and for postordering */ - for (i = 0 ; i < n ; i++) - { - Elen [i] = FLIP (Elen [i]) ; - } - -/* Now the parent of j is Pe [j], or EMPTY if j is a root. Elen [e] > 0 - * is the size of element e. Elen [i] is EMPTY for unordered variable i. */ - -#ifndef NDEBUG - AMD_DEBUG2 (("\nTree:\n")) ; - for (i = 0 ; i < n ; i++) - { - AMD_DEBUG2 ((" "ID" parent: "ID" ", i, Pe [i])) ; - ASSERT (Pe [i] >= EMPTY && Pe [i] < n) ; - if (Nv [i] > 0) - { - /* this is an element */ - e = i ; - AMD_DEBUG2 ((" element, size is "ID"\n", Elen [i])) ; - ASSERT (Elen [e] > 0) ; - } - AMD_DEBUG2 (("\n")) ; - } - AMD_DEBUG2 (("\nelements:\n")) ; - for (e = 0 ; e < n ; e++) - { - if (Nv [e] > 0) - { - AMD_DEBUG3 (("Element e= "ID" size "ID" nv "ID" \n", e, - Elen [e], Nv [e])) ; - } - } - AMD_DEBUG2 (("\nvariables:\n")) ; - for (i = 0 ; i < n ; i++) - { - Int cnt ; - if (Nv [i] == 0) - { - AMD_DEBUG3 (("i unordered: "ID"\n", i)) ; - j = Pe [i] ; - cnt = 0 ; - AMD_DEBUG3 ((" j: "ID"\n", j)) ; - if (j == EMPTY) - { - AMD_DEBUG3 ((" i is a dense variable\n")) ; - } - else - { - ASSERT (j >= 0 && j < n) ; - while (Nv [j] == 0) - { - AMD_DEBUG3 ((" j : "ID"\n", j)) ; - j = Pe [j] ; - AMD_DEBUG3 ((" j:: "ID"\n", j)) ; - cnt++ ; - if (cnt > n) break ; - } - e = j ; - AMD_DEBUG3 ((" got to e: "ID"\n", e)) ; - } - } - } -#endif - -/* ========================================================================= */ -/* compress the paths of the variables */ -/* ========================================================================= */ - - for (i = 0 ; i < n ; i++) - { - if (Nv [i] == 0) - { - - /* ------------------------------------------------------------- - * i is an un-ordered row. Traverse the tree from i until - * reaching an element, e. The element, e, was the principal - * supervariable of i and all nodes in the path from i to when e - * was selected as pivot. - * ------------------------------------------------------------- */ - - AMD_DEBUG1 (("Path compression, i unordered: "ID"\n", i)) ; - j = Pe [i] ; - ASSERT (j >= EMPTY && j < n) ; - AMD_DEBUG3 ((" j: "ID"\n", j)) ; - if (j == EMPTY) - { - /* Skip a dense variable. It has no parent. */ - AMD_DEBUG3 ((" i is a dense variable\n")) ; - continue ; - } - - /* while (j is a variable) */ - while (Nv [j] == 0) - { - AMD_DEBUG3 ((" j : "ID"\n", j)) ; - j = Pe [j] ; - AMD_DEBUG3 ((" j:: "ID"\n", j)) ; - ASSERT (j >= 0 && j < n) ; - } - /* got to an element e */ - e = j ; - AMD_DEBUG3 (("got to e: "ID"\n", e)) ; - - /* ------------------------------------------------------------- - * traverse the path again from i to e, and compress the path - * (all nodes point to e). Path compression allows this code to - * compute in O(n) time. - * ------------------------------------------------------------- */ - - j = i ; - /* while (j is a variable) */ - while (Nv [j] == 0) - { - jnext = Pe [j] ; - AMD_DEBUG3 (("j "ID" jnext "ID"\n", j, jnext)) ; - Pe [j] = e ; - j = jnext ; - ASSERT (j >= 0 && j < n) ; - } - } - } - -/* ========================================================================= */ -/* postorder the assembly tree */ -/* ========================================================================= */ - - AMD_postorder (n, Pe, Nv, Elen, - W, /* output order */ - Head, Next, Last) ; /* workspace */ - -/* ========================================================================= */ -/* compute output permutation and inverse permutation */ -/* ========================================================================= */ - - /* W [e] = k means that element e is the kth element in the new - * order. e is in the range 0 to n-1, and k is in the range 0 to - * the number of elements. Use Head for inverse order. */ - - for (k = 0 ; k < n ; k++) - { - Head [k] = EMPTY ; - Next [k] = EMPTY ; - } - for (e = 0 ; e < n ; e++) - { - k = W [e] ; - ASSERT ((k == EMPTY) == (Nv [e] == 0)) ; - if (k != EMPTY) - { - ASSERT (k >= 0 && k < n) ; - Head [k] = e ; - } - } - - /* construct output inverse permutation in Next, - * and permutation in Last */ - nel = 0 ; - for (k = 0 ; k < n ; k++) - { - e = Head [k] ; - if (e == EMPTY) break ; - ASSERT (e >= 0 && e < n && Nv [e] > 0) ; - Next [e] = nel ; - nel += Nv [e] ; - } - ASSERT (nel == n - ndense) ; - - /* order non-principal variables (dense, & those merged into supervar's) */ - for (i = 0 ; i < n ; i++) - { - if (Nv [i] == 0) - { - e = Pe [i] ; - ASSERT (e >= EMPTY && e < n) ; - if (e != EMPTY) - { - /* This is an unordered variable that was merged - * into element e via supernode detection or mass - * elimination of i when e became the pivot element. - * Place i in order just before e. */ - ASSERT (Next [i] == EMPTY && Nv [e] > 0) ; - Next [i] = Next [e] ; - Next [e]++ ; - } - else - { - /* This is a dense unordered variable, with no parent. - * Place it last in the output order. */ - Next [i] = nel++ ; - } - } - } - ASSERT (nel == n) ; - - AMD_DEBUG2 (("\n\nPerm:\n")) ; - for (i = 0 ; i < n ; i++) - { - k = Next [i] ; - ASSERT (k >= 0 && k < n) ; - Last [k] = i ; - AMD_DEBUG2 ((" perm ["ID"] = "ID"\n", k, i)) ; - } -} diff --git a/src-i386/amd_2.o b/src-i386/amd_2.o deleted file mode 100644 index c7959ed..0000000 Binary files a/src-i386/amd_2.o and /dev/null differ diff --git a/src-i386/amd_aat.c b/src-i386/amd_aat.c deleted file mode 100644 index e5e1752..0000000 --- a/src-i386/amd_aat.c +++ /dev/null @@ -1,184 +0,0 @@ -/* ========================================================================= */ -/* === AMD_aat ============================================================= */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* AMD_aat: compute the symmetry of the pattern of A, and count the number of - * nonzeros each column of A+A' (excluding the diagonal). Assumes the input - * matrix has no errors, with sorted columns and no duplicates - * (AMD_valid (n, n, Ap, Ai) must be AMD_OK, but this condition is not - * checked). - */ - -#include "amd_internal.h" - -GLOBAL size_t AMD_aat /* returns nz in A+A' */ -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int Len [ ], /* Len [j]: length of column j of A+A', excl diagonal*/ - Int Tp [ ], /* workspace of size n */ - double Info [ ] -) -{ - Int p1, p2, p, i, j, pj, pj2, k, nzdiag, nzboth, nz ; - double sym ; - size_t nzaat ; - -#ifndef NDEBUG - AMD_debug_init ("AMD AAT") ; - for (k = 0 ; k < n ; k++) Tp [k] = EMPTY ; - ASSERT (AMD_valid (n, n, Ap, Ai) == AMD_OK) ; -#endif - - if (Info != (double *) NULL) - { - /* clear the Info array, if it exists */ - for (i = 0 ; i < AMD_INFO ; i++) - { - Info [i] = EMPTY ; - } - Info [AMD_STATUS] = AMD_OK ; - } - - for (k = 0 ; k < n ; k++) - { - Len [k] = 0 ; - } - - nzdiag = 0 ; - nzboth = 0 ; - nz = Ap [n] ; - - for (k = 0 ; k < n ; k++) - { - p1 = Ap [k] ; - p2 = Ap [k+1] ; - AMD_DEBUG2 (("\nAAT Column: "ID" p1: "ID" p2: "ID"\n", k, p1, p2)) ; - - /* construct A+A' */ - for (p = p1 ; p < p2 ; ) - { - /* scan the upper triangular part of A */ - j = Ai [p] ; - if (j < k) - { - /* entry A (j,k) is in the strictly upper triangular part, - * add both A (j,k) and A (k,j) to the matrix A+A' */ - Len [j]++ ; - Len [k]++ ; - AMD_DEBUG3 ((" upper ("ID","ID") ("ID","ID")\n", j,k, k,j)); - p++ ; - } - else if (j == k) - { - /* skip the diagonal */ - p++ ; - nzdiag++ ; - break ; - } - else /* j > k */ - { - /* first entry below the diagonal */ - break ; - } - /* scan lower triangular part of A, in column j until reaching - * row k. Start where last scan left off. */ - ASSERT (Tp [j] != EMPTY) ; - ASSERT (Ap [j] <= Tp [j] && Tp [j] <= Ap [j+1]) ; - pj2 = Ap [j+1] ; - for (pj = Tp [j] ; pj < pj2 ; ) - { - i = Ai [pj] ; - if (i < k) - { - /* A (i,j) is only in the lower part, not in upper. - * add both A (i,j) and A (j,i) to the matrix A+A' */ - Len [i]++ ; - Len [j]++ ; - AMD_DEBUG3 ((" lower ("ID","ID") ("ID","ID")\n", - i,j, j,i)) ; - pj++ ; - } - else if (i == k) - { - /* entry A (k,j) in lower part and A (j,k) in upper */ - pj++ ; - nzboth++ ; - break ; - } - else /* i > k */ - { - /* consider this entry later, when k advances to i */ - break ; - } - } - Tp [j] = pj ; - } - /* Tp [k] points to the entry just below the diagonal in column k */ - Tp [k] = p ; - } - - /* clean up, for remaining mismatched entries */ - for (j = 0 ; j < n ; j++) - { - for (pj = Tp [j] ; pj < Ap [j+1] ; pj++) - { - i = Ai [pj] ; - /* A (i,j) is only in the lower part, not in upper. - * add both A (i,j) and A (j,i) to the matrix A+A' */ - Len [i]++ ; - Len [j]++ ; - AMD_DEBUG3 ((" lower cleanup ("ID","ID") ("ID","ID")\n", - i,j, j,i)) ; - } - } - - /* --------------------------------------------------------------------- */ - /* compute the symmetry of the nonzero pattern of A */ - /* --------------------------------------------------------------------- */ - - /* Given a matrix A, the symmetry of A is: - * B = tril (spones (A), -1) + triu (spones (A), 1) ; - * sym = nnz (B & B') / nnz (B) ; - * or 1 if nnz (B) is zero. - */ - - if (nz == nzdiag) - { - sym = 1 ; - } - else - { - sym = (2 * (double) nzboth) / ((double) (nz - nzdiag)) ; - } - - nzaat = 0 ; - for (k = 0 ; k < n ; k++) - { - nzaat += Len [k] ; - } - - AMD_DEBUG1 (("AMD nz in A+A', excluding diagonal (nzaat) = %g\n", - (double) nzaat)) ; - AMD_DEBUG1 ((" nzboth: "ID" nz: "ID" nzdiag: "ID" symmetry: %g\n", - nzboth, nz, nzdiag, sym)) ; - - if (Info != (double *) NULL) - { - Info [AMD_STATUS] = AMD_OK ; - Info [AMD_N] = n ; - Info [AMD_NZ] = nz ; - Info [AMD_SYMMETRY] = sym ; /* symmetry of pattern of A */ - Info [AMD_NZDIAG] = nzdiag ; /* nonzeros on diagonal of A */ - Info [AMD_NZ_A_PLUS_AT] = nzaat ; /* nonzeros in A+A' */ - } - - return (nzaat) ; -} diff --git a/src-i386/amd_aat.o b/src-i386/amd_aat.o deleted file mode 100644 index 828f171..0000000 Binary files a/src-i386/amd_aat.o and /dev/null differ diff --git a/src-i386/amd_control.c b/src-i386/amd_control.c deleted file mode 100644 index 0b64f77..0000000 --- a/src-i386/amd_control.c +++ /dev/null @@ -1,63 +0,0 @@ -/* ========================================================================= */ -/* === AMD_control ========================================================= */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* User-callable. Prints the control parameters for AMD. See amd.h - * for details. If the Control array is not present, the defaults are - * printed instead. - */ - -#include "amd_internal.h" - -GLOBAL void AMD_control -( - double Control [ ] -) -{ - double alpha ; - Int aggressive ; - - if (Control != (double *) NULL) - { - alpha = Control [AMD_DENSE] ; - aggressive = Control [AMD_AGGRESSIVE] != 0 ; - } - else - { - alpha = AMD_DEFAULT_DENSE ; - aggressive = AMD_DEFAULT_AGGRESSIVE ; - } - - PRINTF (("\nAMD version %d.%d.%d, %s: approximate minimum degree ordering\n" - " dense row parameter: %g\n", AMD_MAIN_VERSION, AMD_SUB_VERSION, - AMD_SUBSUB_VERSION, AMD_DATE, alpha)) ; - - if (alpha < 0) - { - PRINTF ((" no rows treated as dense\n")) ; - } - else - { - PRINTF (( - " (rows with more than max (%g * sqrt (n), 16) entries are\n" - " considered \"dense\", and placed last in output permutation)\n", - alpha)) ; - } - - if (aggressive) - { - PRINTF ((" aggressive absorption: yes\n")) ; - } - else - { - PRINTF ((" aggressive absorption: no\n")) ; - } - - PRINTF ((" size of AMD integer: %d\n\n", sizeof (Int))) ; -} diff --git a/src-i386/amd_control.o b/src-i386/amd_control.o deleted file mode 100644 index c49ca67..0000000 Binary files a/src-i386/amd_control.o and /dev/null differ diff --git a/src-i386/amd_defaults.c b/src-i386/amd_defaults.c deleted file mode 100644 index 9d20023..0000000 --- a/src-i386/amd_defaults.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ========================================================================= */ -/* === AMD_defaults ======================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* User-callable. Sets default control parameters for AMD. See amd.h - * for details. - */ - -#include "amd_internal.h" - -/* ========================================================================= */ -/* === AMD defaults ======================================================== */ -/* ========================================================================= */ - -GLOBAL void AMD_defaults -( - double Control [ ] -) -{ - Int i ; - - if (Control != (double *) NULL) - { - for (i = 0 ; i < AMD_CONTROL ; i++) - { - Control [i] = 0 ; - } - Control [AMD_DENSE] = AMD_DEFAULT_DENSE ; - Control [AMD_AGGRESSIVE] = AMD_DEFAULT_AGGRESSIVE ; - } -} diff --git a/src-i386/amd_defaults.o b/src-i386/amd_defaults.o deleted file mode 100644 index 85f9933..0000000 Binary files a/src-i386/amd_defaults.o and /dev/null differ diff --git a/src-i386/amd_dump.c b/src-i386/amd_dump.c deleted file mode 100644 index 01e1fb5..0000000 --- a/src-i386/amd_dump.c +++ /dev/null @@ -1,179 +0,0 @@ -/* ========================================================================= */ -/* === AMD_dump ============================================================ */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Debugging routines for AMD. Not used if NDEBUG is not defined at compile- - * time (the default). See comments in amd_internal.h on how to enable - * debugging. Not user-callable. - */ - -#include "amd_internal.h" - -#ifndef NDEBUG - -/* This global variable is present only when debugging */ -GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */ - -/* ========================================================================= */ -/* === AMD_debug_init ====================================================== */ -/* ========================================================================= */ - -/* Sets the debug print level, by reading the file debug.amd (if it exists) */ - -GLOBAL void AMD_debug_init ( char *s ) -{ - FILE *f ; - f = fopen ("debug.amd", "r") ; - if (f == (FILE *) NULL) - { - AMD_debug = -999 ; - } - else - { - fscanf (f, ID, &AMD_debug) ; - fclose (f) ; - } - if (AMD_debug >= 0) - { - printf ("%s: AMD_debug_init, D= "ID"\n", s, AMD_debug) ; - } -} - -/* ========================================================================= */ -/* === AMD_dump ============================================================ */ -/* ========================================================================= */ - -/* Dump AMD's data structure, except for the hash buckets. This routine - * cannot be called when the hash buckets are non-empty. - */ - -GLOBAL void AMD_dump ( - Int n, /* A is n-by-n */ - Int Pe [ ], /* pe [0..n-1]: index in iw of start of row i */ - Int Iw [ ], /* workspace of size iwlen, iwlen [0..pfree-1] - * holds the matrix on input */ - Int Len [ ], /* len [0..n-1]: length for row i */ - Int iwlen, /* length of iw */ - Int pfree, /* iw [pfree ... iwlen-1] is empty on input */ - Int Nv [ ], /* nv [0..n-1] */ - Int Next [ ], /* next [0..n-1] */ - Int Last [ ], /* last [0..n-1] */ - Int Head [ ], /* head [0..n-1] */ - Int Elen [ ], /* size n */ - Int Degree [ ], /* size n */ - Int W [ ], /* size n */ - Int nel -) -{ - Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ; - - if (AMD_debug < 0) return ; - ASSERT (pfree <= iwlen) ; - AMD_DEBUG3 (("\nAMD dump, pfree: "ID"\n", pfree)) ; - for (i = 0 ; i < n ; i++) - { - pe = Pe [i] ; - elen = Elen [i] ; - nv = Nv [i] ; - len = Len [i] ; - w = W [i] ; - - if (elen >= EMPTY) - { - if (nv == 0) - { - AMD_DEBUG3 (("\nI "ID": nonprincipal: ", i)) ; - ASSERT (elen == EMPTY) ; - if (pe == EMPTY) - { - AMD_DEBUG3 ((" dense node\n")) ; - ASSERT (w == 1) ; - } - else - { - ASSERT (pe < EMPTY) ; - AMD_DEBUG3 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i]))); - } - } - else - { - AMD_DEBUG3 (("\nI "ID": active principal supervariable:\n",i)); - AMD_DEBUG3 ((" nv(i): "ID" Flag: %d\n", nv, (nv < 0))) ; - ASSERT (elen >= 0) ; - ASSERT (nv > 0 && pe >= 0) ; - p = pe ; - AMD_DEBUG3 ((" e/s: ")) ; - if (elen == 0) AMD_DEBUG3 ((" : ")) ; - ASSERT (pe + len <= pfree) ; - for (k = 0 ; k < len ; k++) - { - j = Iw [p] ; - AMD_DEBUG3 ((" "ID"", j)) ; - ASSERT (j >= 0 && j < n) ; - if (k == elen-1) AMD_DEBUG3 ((" : ")) ; - p++ ; - } - AMD_DEBUG3 (("\n")) ; - } - } - else - { - e = i ; - if (w == 0) - { - AMD_DEBUG3 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ; - ASSERT (nv > 0 && pe < 0) ; - AMD_DEBUG3 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ; - } - else - { - AMD_DEBUG3 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ; - ASSERT (nv > 0 && pe >= 0) ; - p = pe ; - AMD_DEBUG3 ((" : ")) ; - ASSERT (pe + len <= pfree) ; - for (k = 0 ; k < len ; k++) - { - j = Iw [p] ; - AMD_DEBUG3 ((" "ID"", j)) ; - ASSERT (j >= 0 && j < n) ; - p++ ; - } - AMD_DEBUG3 (("\n")) ; - } - } - } - - /* this routine cannot be called when the hash buckets are non-empty */ - AMD_DEBUG3 (("\nDegree lists:\n")) ; - if (nel >= 0) - { - cnt = 0 ; - for (deg = 0 ; deg < n ; deg++) - { - if (Head [deg] == EMPTY) continue ; - ilast = EMPTY ; - AMD_DEBUG3 ((ID": \n", deg)) ; - for (i = Head [deg] ; i != EMPTY ; i = Next [i]) - { - AMD_DEBUG3 ((" "ID" : next "ID" last "ID" deg "ID"\n", - i, Next [i], Last [i], Degree [i])) ; - ASSERT (i >= 0 && i < n && ilast == Last [i] && - deg == Degree [i]) ; - cnt += Nv [i] ; - ilast = i ; - } - AMD_DEBUG3 (("\n")) ; - } - ASSERT (cnt == n - nel) ; - } - -} - -#endif diff --git a/src-i386/amd_dump.o b/src-i386/amd_dump.o deleted file mode 100644 index 9baa310..0000000 Binary files a/src-i386/amd_dump.o and /dev/null differ diff --git a/src-i386/amd_global.c b/src-i386/amd_global.c deleted file mode 100644 index 0f3def0..0000000 --- a/src-i386/amd_global.c +++ /dev/null @@ -1,85 +0,0 @@ -/* ========================================================================= */ -/* === amd_global ========================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -#include - -#ifdef MATLAB_MEX_FILE -#include "mex.h" -#include "matrix.h" -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* ========================================================================= */ -/* === Default AMD memory manager ========================================== */ -/* ========================================================================= */ - -/* The user can redefine these global pointers at run-time to change the memory - * manager used by AMD. AMD only uses malloc and free; realloc and calloc are - * include for completeness, in case another package wants to use the same - * memory manager as AMD. - * - * If compiling as a MATLAB mexFunction, the default memory manager is mxMalloc. - * You can also compile AMD as a standard ANSI-C library and link a mexFunction - * against it, and then redefine these pointers at run-time, in your - * mexFunction. - * - * If -DNMALLOC is defined at compile-time, no memory manager is specified at - * compile-time. You must then define these functions at run-time, before - * calling AMD, for AMD to work properly. - */ - -#ifndef NMALLOC -#ifdef MATLAB_MEX_FILE -/* MATLAB mexFunction: */ -void *(*amd_malloc) (size_t) = mxMalloc ; -void (*amd_free) (void *) = mxFree ; -void *(*amd_realloc) (void *, size_t) = mxRealloc ; -void *(*amd_calloc) (size_t, size_t) = mxCalloc ; -#else -/* standard ANSI-C: */ -void *(*amd_malloc) (size_t) = malloc ; -void (*amd_free) (void *) = free ; -void *(*amd_realloc) (void *, size_t) = realloc ; -void *(*amd_calloc) (size_t, size_t) = calloc ; -#endif -#else -/* no memory manager defined at compile-time; you MUST define one at run-time */ -void *(*amd_malloc) (size_t) = NULL ; -void (*amd_free) (void *) = NULL ; -void *(*amd_realloc) (void *, size_t) = NULL ; -void *(*amd_calloc) (size_t, size_t) = NULL ; -#endif - -/* ========================================================================= */ -/* === Default AMD printf routine ========================================== */ -/* ========================================================================= */ - -/* The user can redefine this global pointer at run-time to change the printf - * routine used by AMD. If NULL, no printing occurs. - * - * If -DNPRINT is defined at compile-time, stdio.h is not included. Printing - * can then be enabled at run-time by setting amd_printf to a non-NULL function. - */ - -/*#ifndef NPRINT -#ifdef MATLAB_MEX_FILE -int (*amd_printf) (const char *, ...) = mexPrintf ; -#else -#include -int (*amd_printf) (const char *, ...) = printf ; -#endif -#else -int (*amd_printf) (const char *, ...) = NULL ; -#endif */ -#include -int (*amd_printf) (const char *, ...) = NULL ; diff --git a/src-i386/amd_global.o b/src-i386/amd_global.o deleted file mode 100644 index 747cf12..0000000 Binary files a/src-i386/amd_global.o and /dev/null differ diff --git a/src-i386/amd_info.c b/src-i386/amd_info.c deleted file mode 100644 index fec12a6..0000000 --- a/src-i386/amd_info.c +++ /dev/null @@ -1,119 +0,0 @@ -/* ========================================================================= */ -/* === AMD_info ============================================================ */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* User-callable. Prints the output statistics for AMD. See amd.h - * for details. If the Info array is not present, nothing is printed. - */ - -#include "amd_internal.h" - -#define PRI(format,x) { if (x >= 0) { PRINTF ((format, x)) ; }} - -GLOBAL void AMD_info -( - double Info [ ] -) -{ - double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ; - - PRINTF (("\nAMD version %d.%d.%d, %s, results:\n", - AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE)) ; - - if (!Info) - { - return ; - } - - n = Info [AMD_N] ; - ndiv = Info [AMD_NDIV] ; - nmultsubs_ldl = Info [AMD_NMULTSUBS_LDL] ; - nmultsubs_lu = Info [AMD_NMULTSUBS_LU] ; - lnz = Info [AMD_LNZ] ; - lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ; - - /* AMD return status */ - PRINTF ((" status: ")) ; - if (Info [AMD_STATUS] == AMD_OK) - { - PRINTF (("OK\n")) ; - } - else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY) - { - PRINTF (("out of memory\n")) ; - } - else if (Info [AMD_STATUS] == AMD_INVALID) - { - PRINTF (("invalid matrix\n")) ; - } - else if (Info [AMD_STATUS] == AMD_OK_BUT_JUMBLED) - { - PRINTF (("OK, but jumbled\n")) ; - } - else - { - PRINTF (("unknown\n")) ; - } - - /* statistics about the input matrix */ - PRI (" n, dimension of A: %.20g\n", n); - PRI (" nz, number of nonzeros in A: %.20g\n", - Info [AMD_NZ]) ; - PRI (" symmetry of A: %.4f\n", - Info [AMD_SYMMETRY]) ; - PRI (" number of nonzeros on diagonal: %.20g\n", - Info [AMD_NZDIAG]) ; - PRI (" nonzeros in pattern of A+A' (excl. diagonal): %.20g\n", - Info [AMD_NZ_A_PLUS_AT]) ; - PRI (" # dense rows/columns of A+A': %.20g\n", - Info [AMD_NDENSE]) ; - - /* statistics about AMD's behavior */ - PRI (" memory used, in bytes: %.20g\n", - Info [AMD_MEMORY]) ; - PRI (" # of memory compactions: %.20g\n", - Info [AMD_NCMPA]) ; - - /* statistics about the ordering quality */ - PRINTF (("\n" - " The following approximate statistics are for a subsequent\n" - " factorization of A(P,P) + A(P,P)'. They are slight upper\n" - " bounds if there are no dense rows/columns in A+A', and become\n" - " looser if dense rows/columns exist.\n\n")) ; - - PRI (" nonzeros in L (excluding diagonal): %.20g\n", - lnz) ; - PRI (" nonzeros in L (including diagonal): %.20g\n", - lnzd) ; - PRI (" # divide operations for LDL' or LU: %.20g\n", - ndiv) ; - PRI (" # multiply-subtract operations for LDL': %.20g\n", - nmultsubs_ldl) ; - PRI (" # multiply-subtract operations for LU: %.20g\n", - nmultsubs_lu) ; - PRI (" max nz. in any column of L (incl. diagonal): %.20g\n", - Info [AMD_DMAX]) ; - - /* total flop counts for various factorizations */ - - if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0) - { - PRINTF (("\n" - " chol flop count for real A, sqrt counted as 1 flop: %.20g\n" - " LDL' flop count for real A: %.20g\n" - " LDL' flop count for complex A: %.20g\n" - " LU flop count for real A (with no pivoting): %.20g\n" - " LU flop count for complex A (with no pivoting): %.20g\n\n", - n + ndiv + 2*nmultsubs_ldl, - ndiv + 2*nmultsubs_ldl, - 9*ndiv + 8*nmultsubs_ldl, - ndiv + 2*nmultsubs_lu, - 9*ndiv + 8*nmultsubs_lu)) ; - } -} diff --git a/src-i386/amd_info.o b/src-i386/amd_info.o deleted file mode 100644 index 047a7a1..0000000 Binary files a/src-i386/amd_info.o and /dev/null differ diff --git a/src-i386/amd_internal.h b/src-i386/amd_internal.h deleted file mode 100644 index 01a410a..0000000 --- a/src-i386/amd_internal.h +++ /dev/null @@ -1,351 +0,0 @@ -/* ========================================================================= */ -/* === amd_internal.h ====================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* This file is for internal use in AMD itself, and does not normally need to - * be included in user code (it is included in UMFPACK, however). All others - * should use amd.h instead. - * - * The following compile-time definitions affect how AMD is compiled. - * - * -DNPRINT - * - * Disable all printing. stdio.h will not be included. Printing can - * be re-enabled at run-time by setting the global pointer amd_printf - * to printf (or mexPrintf for a MATLAB mexFunction). - * - * -DNMALLOC - * - * No memory manager is defined at compile-time. You MUST define the - * function pointers amd_malloc, amd_free, amd_realloc, and - * amd_calloc at run-time for AMD to work properly. - */ - -/* ========================================================================= */ -/* === NDEBUG ============================================================== */ -/* ========================================================================= */ - -/* - * Turning on debugging takes some work (see below). If you do not edit this - * file, then debugging is always turned off, regardless of whether or not - * -DNDEBUG is specified in your compiler options. - * - * If AMD is being compiled as a mexFunction, then MATLAB_MEX_FILE is defined, - * and mxAssert is used instead of assert. If debugging is not enabled, no - * MATLAB include files or functions are used. Thus, the AMD library libamd.a - * can be safely used in either a stand-alone C program or in another - * mexFunction, without any change. - */ - -/* - AMD will be exceedingly slow when running in debug mode. The next three - lines ensure that debugging is turned off. -*/ - -#include /* required */ -#include /* for distribution functions etc. */ - -#ifndef NDEBUG -#define NDEBUG -#endif - -/* - To enable debugging, uncomment the following line: -#undef NDEBUG -*/ - -/* ------------------------------------------------------------------------- */ -/* ANSI include files */ -/* ------------------------------------------------------------------------- */ - -/* from stdlib.h: size_t, malloc, free, realloc, and calloc */ -#include - -#if !defined(NPRINT) || !defined(NDEBUG) -/* from stdio.h: printf. Not included if NPRINT is defined at compile time. - * fopen and fscanf are used when debugging. */ -#include -#endif - -/* from limits.h: INT_MAX and LONG_MAX */ -#include - -/* from math.h: sqrt */ -#include - -/* ------------------------------------------------------------------------- */ -/* MATLAB include files (only if being used in or via MATLAB) */ -/* ------------------------------------------------------------------------- */ - -#ifdef MATLAB_MEX_FILE -#include "matrix.h" -#include "mex.h" -#endif - -/* ------------------------------------------------------------------------- */ -/* basic definitions */ -/* ------------------------------------------------------------------------- */ - -#ifdef FLIP -#undef FLIP -#endif - -#ifdef MAX -#undef MAX -#endif - -#ifdef MIN -#undef MIN -#endif - -#ifdef EMPTY -#undef EMPTY -#endif - -#ifdef GLOBAL -#undef GLOBAL -#endif - -#ifdef PRIVATE -#undef PRIVATE -#endif - -/* FLIP is a "negation about -1", and is used to mark an integer i that is - * normally non-negative. FLIP (EMPTY) is EMPTY. FLIP of a number > EMPTY - * is negative, and FLIP of a number < EMTPY is positive. FLIP (FLIP (i)) = i - * for all integers i. UNFLIP (i) is >= EMPTY. */ -#define EMPTY (-1) -#define FLIP(i) (-(i)-2) -#define UNFLIP(i) ((i < EMPTY) ? FLIP (i) : (i)) - -/* for integer MAX/MIN, or for doubles when we don't care how NaN's behave: */ -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - -/* logical expression of p implies q: */ -#define IMPLIES(p,q) (!(p) || (q)) - -/* Note that the IBM RS 6000 xlc predefines TRUE and FALSE in . */ -/* The Compaq Alpha also predefines TRUE and FALSE. */ -#ifdef TRUE -#undef TRUE -#endif -#ifdef FALSE -#undef FALSE -#endif - -#define TRUE (1) -#define FALSE (0) -#define PRIVATE static -#define GLOBAL -#define EMPTY (-1) - -/* Note that Linux's gcc 2.96 defines NULL as ((void *) 0), but other */ -/* compilers (even gcc 2.95.2 on Solaris) define NULL as 0 or (0). We */ -/* need to use the ANSI standard value of 0. */ -#ifdef NULL -#undef NULL -#endif - -#define NULL 0 - -/* largest value of size_t */ -#ifndef SIZE_T_MAX -#ifdef SIZE_MAX -/* C99 only */ -#define SIZE_T_MAX SIZE_MAX -#else -#define SIZE_T_MAX ((size_t) (-1)) -#endif -#endif - -/* ------------------------------------------------------------------------- */ -/* integer type for AMD: int or SuiteSparse_long */ -/* ------------------------------------------------------------------------- */ - -#include "amd.h" - -#if defined (DLONG) || defined (ZLONG) - -#define Int SuiteSparse_long -#define ID SuiteSparse_long_id -#define Int_MAX SuiteSparse_long_max - -#define AMD_order amd_l_order -#define AMD_defaults amd_l_defaults -#define AMD_control amd_l_control -#define AMD_info amd_l_info -#define AMD_1 amd_l1 -#define AMD_2 amd_l2 -#define AMD_valid amd_l_valid -#define AMD_aat amd_l_aat -#define AMD_postorder amd_l_postorder -#define AMD_post_tree amd_l_post_tree -#define AMD_dump amd_l_dump -#define AMD_debug amd_l_debug -#define AMD_debug_init amd_l_debug_init -#define AMD_preprocess amd_l_preprocess - -#else - -#define Int int -#define ID "%d" -#define Int_MAX INT_MAX - -#define AMD_order amd_order -#define AMD_defaults amd_defaults -#define AMD_control amd_control -#define AMD_info amd_info -#define AMD_1 amd_1 -#define AMD_2 amd_2 -#define AMD_valid amd_valid -#define AMD_aat amd_aat -#define AMD_postorder amd_postorder -#define AMD_post_tree amd_post_tree -#define AMD_dump amd_dump -#define AMD_debug amd_debug -#define AMD_debug_init amd_debug_init -#define AMD_preprocess amd_preprocess - -#endif - -/* ========================================================================= */ -/* === PRINTF macro ======================================================== */ -/* ========================================================================= */ - -/* All output goes through the PRINTF macro. */ -#define PRINTF(params) { if (amd_printf != NULL) (void) amd_printf params ; } - -/* ------------------------------------------------------------------------- */ -/* AMD routine definitions (not user-callable) */ -/* ------------------------------------------------------------------------- */ - -GLOBAL size_t AMD_aat -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int Len [ ], - Int Tp [ ], - double Info [ ] -) ; - -GLOBAL void AMD_1 -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int P [ ], - Int Pinv [ ], - Int Len [ ], - Int slen, - Int S [ ], - double Control [ ], - double Info [ ] -) ; - -GLOBAL void AMD_postorder -( - Int nn, - Int Parent [ ], - Int Npiv [ ], - Int Fsize [ ], - Int Order [ ], - Int Child [ ], - Int Sibling [ ], - Int Stack [ ] -) ; - -GLOBAL Int AMD_post_tree -( - Int root, - Int k, - Int Child [ ], - const Int Sibling [ ], - Int Order [ ], - Int Stack [ ] -#ifndef NDEBUG - , Int nn -#endif -) ; - -GLOBAL void AMD_preprocess -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int Rp [ ], - Int Ri [ ], - Int W [ ], - Int Flag [ ] -) ; - -/* ------------------------------------------------------------------------- */ -/* debugging definitions */ -/* ------------------------------------------------------------------------- */ - -#ifndef NDEBUG - -/* from assert.h: assert macro */ -#include - -#ifndef EXTERN -#define EXTERN extern -#endif - -EXTERN Int AMD_debug ; - -GLOBAL void AMD_debug_init ( char *s ) ; - -GLOBAL void AMD_dump -( - Int n, - Int Pe [ ], - Int Iw [ ], - Int Len [ ], - Int iwlen, - Int pfree, - Int Nv [ ], - Int Next [ ], - Int Last [ ], - Int Head [ ], - Int Elen [ ], - Int Degree [ ], - Int W [ ], - Int nel -) ; - -#ifdef ASSERT -#undef ASSERT -#endif - -/* Use mxAssert if AMD is compiled into a mexFunction */ -#ifdef MATLAB_MEX_FILE -#define ASSERT(expression) (mxAssert ((expression), "")) -#else -#define ASSERT(expression) (assert (expression)) -#endif - -#define AMD_DEBUG0(params) { PRINTF (params) ; } -#define AMD_DEBUG1(params) { if (AMD_debug >= 1) PRINTF (params) ; } -#define AMD_DEBUG2(params) { if (AMD_debug >= 2) PRINTF (params) ; } -#define AMD_DEBUG3(params) { if (AMD_debug >= 3) PRINTF (params) ; } -#define AMD_DEBUG4(params) { if (AMD_debug >= 4) PRINTF (params) ; } - -#else - -/* no debugging */ -#define ASSERT(expression) -#define AMD_DEBUG0(params) -#define AMD_DEBUG1(params) -#define AMD_DEBUG2(params) -#define AMD_DEBUG3(params) -#define AMD_DEBUG4(params) - -#endif diff --git a/src-i386/amd_order.c b/src-i386/amd_order.c deleted file mode 100644 index f00aff6..0000000 --- a/src-i386/amd_order.c +++ /dev/null @@ -1,206 +0,0 @@ -/* ========================================================================= */ -/* === AMD_order =========================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* User-callable AMD minimum degree ordering routine. See amd.h for - * documentation. - */ - -#include "amd_internal.h" -#include /* required */ -#include /* for distribution functions etc. */ - -/* ========================================================================= */ -/* === AMD_order =========================================================== */ -/* ========================================================================= */ - -GLOBAL Int AMD_order -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int P [ ], - double Control [ ], - double Info [ ] -) -{ - Int *Len, *S, nz, i, *Pinv, info, status, *Rp, *Ri, *Cp, *Ci, ok ; - size_t nzaat, slen ; - double mem = 0 ; - - - - -#ifndef NDEBUG - AMD_debug_init ("amd") ; -#endif - - /* clear the Info array, if it exists */ - info = Info != (double *) NULL ; - if (info) - { - for (i = 0 ; i < AMD_INFO ; i++) - { - Info [i] = EMPTY ; - } - Info [AMD_N] = n ; - Info [AMD_STATUS] = AMD_OK ; - } - - /* make sure inputs exist and n is >= 0 */ - if (Ai == (Int *) NULL || Ap == (Int *) NULL || P == (Int *) NULL || n < 0) - { - if (info) Info [AMD_STATUS] = AMD_INVALID ; - return (AMD_INVALID) ; /* arguments are invalid */ - } - - - if (n == 0) - { - return (AMD_OK) ; /* n is 0 so there's nothing to do */ - } - - nz = Ap [n] ; - if (info) - { - Info [AMD_NZ] = nz ; - } - if (nz < 0) - { - if (info) Info [AMD_STATUS] = AMD_INVALID ; - return (AMD_INVALID) ; - } - - /* check if n or nz will cause size_t overflow */ - if (((size_t) n) >= SIZE_T_MAX / sizeof (Int) - || ((size_t) nz) >= SIZE_T_MAX / sizeof (Int)) - { - if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ; - return (AMD_OUT_OF_MEMORY) ; /* problem too large */ - } - - - - - /* check the input matrix: AMD_OK, AMD_INVALID, or AMD_OK_BUT_JUMBLED */ - status = AMD_valid (n, n, Ap, Ai) ; - if (status == AMD_INVALID) - { - if (info) Info [AMD_STATUS] = AMD_INVALID ; - return (AMD_INVALID) ; /* matrix is invalid */ - } - - /* allocate two size-n integer workspaces */ - Len = amd_malloc (n * sizeof (Int)) ; - Pinv = amd_malloc (n * sizeof (Int)) ; - mem += n ; - mem += n ; - if (!Len || !Pinv) - { - /* :: out of memory :: */ - amd_free (Len) ; - amd_free (Pinv) ; - if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ; - return (AMD_OUT_OF_MEMORY) ; - } - - if (status == AMD_OK_BUT_JUMBLED) - { - /* sort the input matrix and remove duplicate entries */ - AMD_DEBUG1 (("Matrix is jumbled\n")) ; - Rp = amd_malloc ((n+1) * sizeof (Int)) ; - Ri = amd_malloc (MAX (nz,1) * sizeof (Int)) ; - mem += (n+1) ; - mem += MAX (nz,1) ; - if (!Rp || !Ri) - { - /* :: out of memory :: */ - amd_free (Rp) ; - amd_free (Ri) ; - amd_free (Len) ; - amd_free (Pinv) ; - if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ; - return (AMD_OUT_OF_MEMORY) ; - } - /* use Len and Pinv as workspace to create R = A' */ - AMD_preprocess (n, Ap, Ai, Rp, Ri, Len, Pinv) ; - Cp = Rp ; - Ci = Ri ; - } - else - { - /* order the input matrix as-is. No need to compute R = A' first */ - Rp = NULL ; - Ri = NULL ; - Cp = (Int *) Ap ; - Ci = (Int *) Ai ; - } - - /* --------------------------------------------------------------------- */ - /* determine the symmetry and count off-diagonal nonzeros in A+A' */ - /* --------------------------------------------------------------------- */ - - nzaat = AMD_aat (n, Cp, Ci, Len, P, Info) ; - AMD_DEBUG1 (("nzaat: %g\n", (double) nzaat)) ; - ASSERT ((MAX (nz-n, 0) <= nzaat) && (nzaat <= 2 * (size_t) nz)) ; - - /* --------------------------------------------------------------------- */ - /* allocate workspace for matrix, elbow room, and 6 size-n vectors */ - /* --------------------------------------------------------------------- */ - - S = NULL ; - slen = nzaat ; /* space for matrix */ - ok = ((slen + nzaat/5) >= slen) ; /* check for size_t overflow */ - slen += nzaat/5 ; /* add elbow room */ - for (i = 0 ; ok && i < 7 ; i++) - { - ok = ((slen + n) > slen) ; /* check for size_t overflow */ - slen += n ; /* size-n elbow room, 6 size-n work */ - } - mem += slen ; - ok = ok && (slen < SIZE_T_MAX / sizeof (Int)) ; /* check for overflow */ - ok = ok && (slen < Int_MAX) ; /* S[i] for Int i must be OK */ - if (ok) - { - S = amd_malloc (slen * sizeof (Int)) ; - } - AMD_DEBUG1 (("slen %g\n", (double) slen)) ; - if (!S) - { - /* :: out of memory :: (or problem too large) */ - amd_free (Rp) ; - amd_free (Ri) ; - amd_free (Len) ; - amd_free (Pinv) ; - if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ; - return (AMD_OUT_OF_MEMORY) ; - } - if (info) - { - /* memory usage, in bytes. */ - Info [AMD_MEMORY] = mem * sizeof (Int) ; - } - - /* --------------------------------------------------------------------- */ - /* order the matrix */ - /* --------------------------------------------------------------------- */ - AMD_1 (n, Cp, Ci, P, Pinv, Len, slen, S, Control, Info) ; - - /* --------------------------------------------------------------------- */ - /* free the workspace */ - /* --------------------------------------------------------------------- */ - - amd_free (Rp) ; - amd_free (Ri) ; - amd_free (Len) ; - amd_free (Pinv) ; - amd_free (S) ; - if (info) Info [AMD_STATUS] = status ; - return (status) ; /* successful ordering */ -} diff --git a/src-i386/amd_order.o b/src-i386/amd_order.o deleted file mode 100644 index 0f12fa4..0000000 Binary files a/src-i386/amd_order.o and /dev/null differ diff --git a/src-i386/amd_order_wrapper.c b/src-i386/amd_order_wrapper.c deleted file mode 100644 index edd766f..0000000 --- a/src-i386/amd_order_wrapper.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "amd_internal.h" -#include /* required */ -#include /* for distribution functions etc. */ -GLOBAL void AMD_order_wrapper -( - Int *n, - const Int *Ap, - const Int *Ai, - Int *P, - double *Control, - double *Info -) { -amd_defaults (Control) ; -amd_order(*n,Ap,Ai,P,Control,Info); -return; -} diff --git a/src-i386/amd_order_wrapper.h b/src-i386/amd_order_wrapper.h deleted file mode 100644 index 8fc8d5e..0000000 --- a/src-i386/amd_order_wrapper.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _AMD_ORDER_WRAPPER_H_ -#define _AMD_ORDER_WRAPPER_H_ -#include -#define Int int - -void AMD_order_wrapper - ( - Int *n, - const Int *Ap, - const Int *Ai, - Int *P, - double *Control, - double *Info - ); - -#endif diff --git a/src-i386/amd_order_wrapper.o b/src-i386/amd_order_wrapper.o deleted file mode 100644 index 6bdeb54..0000000 Binary files a/src-i386/amd_order_wrapper.o and /dev/null differ diff --git a/src-i386/amd_post_tree.c b/src-i386/amd_post_tree.c deleted file mode 100644 index 7ab1aa5..0000000 --- a/src-i386/amd_post_tree.c +++ /dev/null @@ -1,120 +0,0 @@ -/* ========================================================================= */ -/* === AMD_post_tree ======================================================= */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Post-ordering of a supernodal elimination tree. */ - -#include "amd_internal.h" - -GLOBAL Int AMD_post_tree -( - Int root, /* root of the tree */ - Int k, /* start numbering at k */ - Int Child [ ], /* input argument of size nn, undefined on - * output. Child [i] is the head of a link - * list of all nodes that are children of node - * i in the tree. */ - const Int Sibling [ ], /* input argument of size nn, not modified. - * If f is a node in the link list of the - * children of node i, then Sibling [f] is the - * next child of node i. - */ - Int Order [ ], /* output order, of size nn. Order [i] = k - * if node i is the kth node of the reordered - * tree. */ - Int Stack [ ] /* workspace of size nn */ -#ifndef NDEBUG - , Int nn /* nodes are in the range 0..nn-1. */ -#endif -) -{ - Int f, head, h, i ; - -#if 0 - /* --------------------------------------------------------------------- */ - /* recursive version (Stack [ ] is not used): */ - /* --------------------------------------------------------------------- */ - - /* this is simple, but can caouse stack overflow if nn is large */ - i = root ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - k = AMD_post_tree (f, k, Child, Sibling, Order, Stack, nn) ; - } - Order [i] = k++ ; - return (k) ; -#endif - - /* --------------------------------------------------------------------- */ - /* non-recursive version, using an explicit stack */ - /* --------------------------------------------------------------------- */ - - /* push root on the stack */ - head = 0 ; - Stack [0] = root ; - - while (head >= 0) - { - /* get head of stack */ - ASSERT (head < nn) ; - i = Stack [head] ; - AMD_DEBUG1 (("head of stack "ID" \n", i)) ; - ASSERT (i >= 0 && i < nn) ; - - if (Child [i] != EMPTY) - { - /* the children of i are not yet ordered */ - /* push each child onto the stack in reverse order */ - /* so that small ones at the head of the list get popped first */ - /* and the biggest one at the end of the list gets popped last */ - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - head++ ; - ASSERT (head < nn) ; - ASSERT (f >= 0 && f < nn) ; - } - h = head ; - ASSERT (head < nn) ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - ASSERT (h > 0) ; - Stack [h--] = f ; - AMD_DEBUG1 (("push "ID" on stack\n", f)) ; - ASSERT (f >= 0 && f < nn) ; - } - ASSERT (Stack [h] == i) ; - - /* delete child list so that i gets ordered next time we see it */ - Child [i] = EMPTY ; - } - else - { - /* the children of i (if there were any) are already ordered */ - /* remove i from the stack and order it. Front i is kth front */ - head-- ; - AMD_DEBUG1 (("pop "ID" order "ID"\n", i, k)) ; - Order [i] = k++ ; - ASSERT (k <= nn) ; - } - -#ifndef NDEBUG - AMD_DEBUG1 (("\nStack:")) ; - for (h = head ; h >= 0 ; h--) - { - Int j = Stack [h] ; - AMD_DEBUG1 ((" "ID, j)) ; - ASSERT (j >= 0 && j < nn) ; - } - AMD_DEBUG1 (("\n\n")) ; - ASSERT (head < nn) ; -#endif - - } - return (k) ; -} diff --git a/src-i386/amd_post_tree.o b/src-i386/amd_post_tree.o deleted file mode 100644 index 250f9f9..0000000 Binary files a/src-i386/amd_post_tree.o and /dev/null differ diff --git a/src-i386/amd_postorder.c b/src-i386/amd_postorder.c deleted file mode 100644 index f262bf7..0000000 --- a/src-i386/amd_postorder.c +++ /dev/null @@ -1,206 +0,0 @@ -/* ========================================================================= */ -/* === AMD_postorder ======================================================= */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Perform a postordering (via depth-first search) of an assembly tree. */ - -#include "amd_internal.h" - -GLOBAL void AMD_postorder -( - /* inputs, not modified on output: */ - Int nn, /* nodes are in the range 0..nn-1 */ - Int Parent [ ], /* Parent [j] is the parent of j, or EMPTY if root */ - Int Nv [ ], /* Nv [j] > 0 number of pivots represented by node j, - * or zero if j is not a node. */ - Int Fsize [ ], /* Fsize [j]: size of node j */ - - /* output, not defined on input: */ - Int Order [ ], /* output post-order */ - - /* workspaces of size nn: */ - Int Child [ ], - Int Sibling [ ], - Int Stack [ ] -) -{ - Int i, j, k, parent, frsize, f, fprev, maxfrsize, bigfprev, bigf, fnext ; - - for (j = 0 ; j < nn ; j++) - { - Child [j] = EMPTY ; - Sibling [j] = EMPTY ; - } - - /* --------------------------------------------------------------------- */ - /* place the children in link lists - bigger elements tend to be last */ - /* --------------------------------------------------------------------- */ - - for (j = nn-1 ; j >= 0 ; j--) - { - if (Nv [j] > 0) - { - /* this is an element */ - parent = Parent [j] ; - if (parent != EMPTY) - { - /* place the element in link list of the children its parent */ - /* bigger elements will tend to be at the end of the list */ - Sibling [j] = Child [parent] ; - Child [parent] = j ; - } - } - } - -#ifndef NDEBUG - { - Int nels, ff, nchild ; - AMD_DEBUG1 (("\n\n================================ AMD_postorder:\n")); - nels = 0 ; - for (j = 0 ; j < nn ; j++) - { - if (Nv [j] > 0) - { - AMD_DEBUG1 (( ""ID" : nels "ID" npiv "ID" size "ID - " parent "ID" maxfr "ID"\n", j, nels, - Nv [j], Fsize [j], Parent [j], Fsize [j])) ; - /* this is an element */ - /* dump the link list of children */ - nchild = 0 ; - AMD_DEBUG1 ((" Children: ")) ; - for (ff = Child [j] ; ff != EMPTY ; ff = Sibling [ff]) - { - AMD_DEBUG1 ((ID" ", ff)) ; - ASSERT (Parent [ff] == j) ; - nchild++ ; - ASSERT (nchild < nn) ; - } - AMD_DEBUG1 (("\n")) ; - parent = Parent [j] ; - if (parent != EMPTY) - { - ASSERT (Nv [parent] > 0) ; - } - nels++ ; - } - } - } - AMD_DEBUG1 (("\n\nGo through the children of each node, and put\n" - "the biggest child last in each list:\n")) ; -#endif - - /* --------------------------------------------------------------------- */ - /* place the largest child last in the list of children for each node */ - /* --------------------------------------------------------------------- */ - - for (i = 0 ; i < nn ; i++) - { - if (Nv [i] > 0 && Child [i] != EMPTY) - { - -#ifndef NDEBUG - Int nchild ; - AMD_DEBUG1 (("Before partial sort, element "ID"\n", i)) ; - nchild = 0 ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - ASSERT (f >= 0 && f < nn) ; - AMD_DEBUG1 ((" f: "ID" size: "ID"\n", f, Fsize [f])) ; - nchild++ ; - ASSERT (nchild <= nn) ; - } -#endif - - /* find the biggest element in the child list */ - fprev = EMPTY ; - maxfrsize = EMPTY ; - bigfprev = EMPTY ; - bigf = EMPTY ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - ASSERT (f >= 0 && f < nn) ; - frsize = Fsize [f] ; - if (frsize >= maxfrsize) - { - /* this is the biggest seen so far */ - maxfrsize = frsize ; - bigfprev = fprev ; - bigf = f ; - } - fprev = f ; - } - ASSERT (bigf != EMPTY) ; - - fnext = Sibling [bigf] ; - - AMD_DEBUG1 (("bigf "ID" maxfrsize "ID" bigfprev "ID" fnext "ID - " fprev " ID"\n", bigf, maxfrsize, bigfprev, fnext, fprev)) ; - - if (fnext != EMPTY) - { - /* if fnext is EMPTY then bigf is already at the end of list */ - - if (bigfprev == EMPTY) - { - /* delete bigf from the element of the list */ - Child [i] = fnext ; - } - else - { - /* delete bigf from the middle of the list */ - Sibling [bigfprev] = fnext ; - } - - /* put bigf at the end of the list */ - Sibling [bigf] = EMPTY ; - ASSERT (Child [i] != EMPTY) ; - ASSERT (fprev != bigf) ; - ASSERT (fprev != EMPTY) ; - Sibling [fprev] = bigf ; - } - -#ifndef NDEBUG - AMD_DEBUG1 (("After partial sort, element "ID"\n", i)) ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - ASSERT (f >= 0 && f < nn) ; - AMD_DEBUG1 ((" "ID" "ID"\n", f, Fsize [f])) ; - ASSERT (Nv [f] > 0) ; - nchild-- ; - } - ASSERT (nchild == 0) ; -#endif - - } - } - - /* --------------------------------------------------------------------- */ - /* postorder the assembly tree */ - /* --------------------------------------------------------------------- */ - - for (i = 0 ; i < nn ; i++) - { - Order [i] = EMPTY ; - } - - k = 0 ; - - for (i = 0 ; i < nn ; i++) - { - if (Parent [i] == EMPTY && Nv [i] > 0) - { - AMD_DEBUG1 (("Root of assembly tree "ID"\n", i)) ; - k = AMD_post_tree (i, k, Child, Sibling, Order, Stack -#ifndef NDEBUG - , nn -#endif - ) ; - } - } -} diff --git a/src-i386/amd_postorder.o b/src-i386/amd_postorder.o deleted file mode 100644 index 48c064e..0000000 Binary files a/src-i386/amd_postorder.o and /dev/null differ diff --git a/src-i386/amd_preprocess.c b/src-i386/amd_preprocess.c deleted file mode 100644 index 1eb2d1f..0000000 --- a/src-i386/amd_preprocess.c +++ /dev/null @@ -1,118 +0,0 @@ -/* ========================================================================= */ -/* === AMD_preprocess ====================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Sorts, removes duplicate entries, and transposes from the nonzero pattern of - * a column-form matrix A, to obtain the matrix R. The input matrix can have - * duplicate entries and/or unsorted columns (AMD_valid (n,Ap,Ai) must not be - * AMD_INVALID). - * - * This input condition is NOT checked. This routine is not user-callable. - */ - -#include "amd_internal.h" - -/* ========================================================================= */ -/* === AMD_preprocess ====================================================== */ -/* ========================================================================= */ - -/* AMD_preprocess does not check its input for errors or allocate workspace. - * On input, the condition (AMD_valid (n,n,Ap,Ai) != AMD_INVALID) must hold. - */ - -GLOBAL void AMD_preprocess -( - Int n, /* input matrix: A is n-by-n */ - const Int Ap [ ], /* size n+1 */ - const Int Ai [ ], /* size nz = Ap [n] */ - - /* output matrix R: */ - Int Rp [ ], /* size n+1 */ - Int Ri [ ], /* size nz (or less, if duplicates present) */ - - Int W [ ], /* workspace of size n */ - Int Flag [ ] /* workspace of size n */ -) -{ - - /* --------------------------------------------------------------------- */ - /* local variables */ - /* --------------------------------------------------------------------- */ - - Int i, j, p, p2 ; - - ASSERT (AMD_valid (n, n, Ap, Ai) != AMD_INVALID) ; - - /* --------------------------------------------------------------------- */ - /* count the entries in each row of A (excluding duplicates) */ - /* --------------------------------------------------------------------- */ - - for (i = 0 ; i < n ; i++) - { - W [i] = 0 ; /* # of nonzeros in row i (excl duplicates) */ - Flag [i] = EMPTY ; /* Flag [i] = j if i appears in column j */ - } - for (j = 0 ; j < n ; j++) - { - p2 = Ap [j+1] ; - for (p = Ap [j] ; p < p2 ; p++) - { - i = Ai [p] ; - if (Flag [i] != j) - { - /* row index i has not yet appeared in column j */ - W [i]++ ; /* one more entry in row i */ - Flag [i] = j ; /* flag row index i as appearing in col j*/ - } - } - } - - /* --------------------------------------------------------------------- */ - /* compute the row pointers for R */ - /* --------------------------------------------------------------------- */ - - Rp [0] = 0 ; - for (i = 0 ; i < n ; i++) - { - Rp [i+1] = Rp [i] + W [i] ; - } - for (i = 0 ; i < n ; i++) - { - W [i] = Rp [i] ; - Flag [i] = EMPTY ; - } - - /* --------------------------------------------------------------------- */ - /* construct the row form matrix R */ - /* --------------------------------------------------------------------- */ - - /* R = row form of pattern of A */ - for (j = 0 ; j < n ; j++) - { - p2 = Ap [j+1] ; - for (p = Ap [j] ; p < p2 ; p++) - { - i = Ai [p] ; - if (Flag [i] != j) - { - /* row index i has not yet appeared in column j */ - Ri [W [i]++] = j ; /* put col j in row i */ - Flag [i] = j ; /* flag row index i as appearing in col j*/ - } - } - } - -#ifndef NDEBUG - ASSERT (AMD_valid (n, n, Rp, Ri) == AMD_OK) ; - for (j = 0 ; j < n ; j++) - { - ASSERT (W [j] == Rp [j+1]) ; - } -#endif -} diff --git a/src-i386/amd_preprocess.o b/src-i386/amd_preprocess.o deleted file mode 100644 index 3ca7cbe..0000000 Binary files a/src-i386/amd_preprocess.o and /dev/null differ diff --git a/src-i386/amd_valid.c b/src-i386/amd_valid.c deleted file mode 100644 index 4f7b0e0..0000000 --- a/src-i386/amd_valid.c +++ /dev/null @@ -1,92 +0,0 @@ -/* ========================================================================= */ -/* === AMD_valid =========================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Check if a column-form matrix is valid or not. The matrix A is - * n_row-by-n_col. The row indices of entries in column j are in - * Ai [Ap [j] ... Ap [j+1]-1]. Required conditions are: - * - * n_row >= 0 - * n_col >= 0 - * nz = Ap [n_col] >= 0 number of entries in the matrix - * Ap [0] == 0 - * Ap [j] <= Ap [j+1] for all j in the range 0 to n_col. - * Ai [0 ... nz-1] must be in the range 0 to n_row-1. - * - * If any of the above conditions hold, AMD_INVALID is returned. If the - * following condition holds, AMD_OK_BUT_JUMBLED is returned (a warning, - * not an error): - * - * row indices in Ai [Ap [j] ... Ap [j+1]-1] are not sorted in ascending - * order, and/or duplicate entries exist. - * - * Otherwise, AMD_OK is returned. - * - * In v1.2 and earlier, this function returned TRUE if the matrix was valid - * (now returns AMD_OK), or FALSE otherwise (now returns AMD_INVALID or - * AMD_OK_BUT_JUMBLED). - */ - -#include "amd_internal.h" - -GLOBAL Int AMD_valid -( - /* inputs, not modified on output: */ - Int n_row, /* A is n_row-by-n_col */ - Int n_col, - const Int Ap [ ], /* column pointers of A, of size n_col+1 */ - const Int Ai [ ] /* row indices of A, of size nz = Ap [n_col] */ -) -{ - Int nz, j, p1, p2, ilast, i, p, result = AMD_OK ; - - if (n_row < 0 || n_col < 0 || Ap == NULL || Ai == NULL) - { - return (AMD_INVALID) ; - } - nz = Ap [n_col] ; - if (Ap [0] != 0 || nz < 0) - { - /* column pointers must start at Ap [0] = 0, and Ap [n] must be >= 0 */ - AMD_DEBUG0 (("column 0 pointer bad or nz < 0\n")) ; - return (AMD_INVALID) ; - } - for (j = 0 ; j < n_col ; j++) - { - p1 = Ap [j] ; - p2 = Ap [j+1] ; - AMD_DEBUG2 (("\nColumn: "ID" p1: "ID" p2: "ID"\n", j, p1, p2)) ; - if (p1 > p2) - { - /* column pointers must be ascending */ - AMD_DEBUG0 (("column "ID" pointer bad\n", j)) ; - return (AMD_INVALID) ; - } - ilast = EMPTY ; - for (p = p1 ; p < p2 ; p++) - { - i = Ai [p] ; - AMD_DEBUG3 (("row: "ID"\n", i)) ; - if (i < 0 || i >= n_row) - { - /* row index out of range */ - AMD_DEBUG0 (("index out of range, col "ID" row "ID"\n", j, i)); - return (AMD_INVALID) ; - } - if (i <= ilast) - { - /* row index unsorted, or duplicate entry present */ - AMD_DEBUG1 (("index unsorted/dupl col "ID" row "ID"\n", j, i)); - result = AMD_OK_BUT_JUMBLED ; - } - ilast = i ; - } - } - return (result) ; -} diff --git a/src-i386/amd_valid.o b/src-i386/amd_valid.o deleted file mode 100644 index 1fec663..0000000 Binary files a/src-i386/amd_valid.o and /dev/null differ diff --git a/src-i386/distR.cpp b/src-i386/distR.cpp deleted file mode 100644 index 601436a..0000000 --- a/src-i386/distR.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*FRK: An R Software package for spatial and spatio-temporal prediction - with large datasets. - Copyright (c) 2017 University of Wollongong - Author: Andrew Zammit-Mangion, azm (at) uow.edu.au - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. */ - -#include -using namespace Rcpp; - -// [[Rcpp::export]] -NumericMatrix distR_C(NumericMatrix x,NumericMatrix y) { - int nrow_x = x.nrow(), ncol_x = x.ncol(); - int nrow_y = y.nrow(); - NumericMatrix out(nrow_x,nrow_y); - - for (int i = 0; i < nrow_x; i++) { - for (int j = 0; j < nrow_y; j++) { - for (int k = 0; k < ncol_x; k++) { - out(i,j) = out(i,j) + pow(x(i,k) - y(j,k),2); - } - out(i,j) = sqrt(out(i,j)); - } - } - return out; -} diff --git a/src-i386/distR.h b/src-i386/distR.h deleted file mode 100644 index 2a18952..0000000 --- a/src-i386/distR.h +++ /dev/null @@ -1,25 +0,0 @@ -/*FRK: An R Software package for spatial and spatio-temporal prediction - with large datasets. - Copyright (c) 2017 University of Wollongong -Author: Andrew Zammit-Mangion, azm (at) uow.edu.au - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. */ - -#ifndef _DISTR_H_ -#define _DISTR_H_ -#include -#include -#include - -SEXP _FRK_distR_C(SEXP xSEXP, SEXP ySEXP); -SEXP overhead_cpp(SEXP a, SEXP b); - -#endif diff --git a/src-i386/distR.o b/src-i386/distR.o deleted file mode 100644 index faa9577..0000000 Binary files a/src-i386/distR.o and /dev/null differ diff --git a/src-i386/sparseinvR.c b/src-i386/sparseinvR.c deleted file mode 100644 index 54188bb..0000000 --- a/src-i386/sparseinvR.c +++ /dev/null @@ -1,180 +0,0 @@ -#include "sparseinvR.h" -#include /* required */ -#include /* for distribution functions etc. */ - -/* sparsinv: computes the sparse inverse subset, using Takahashi's equations. - - On input, the pattern of Z must be equal to the symbolic Cholesky - factorization of A+A', where A=(L+I)*(U+I). The pattern of L+U must be a - subset of Z. Z must have zero-free diagonal. These conditions are - difficult to check, so they are assumed to hold. Results will be completely - wrong if the conditions do not hold. - - This function performs the same amount of work as the initial LU - factorization, assuming that the pattern of P*A*Q is symmetric. For large - matrices, this function can take a lot more time than LU in MATLAB, even if - P*A*Q is symmetric. This is because LU is a multifrontal method, whereas - this sparseinv function is based on gather/scatter operations. - - The basic integer type is an Int, or ptrdiff_t, which is 32 bits on a 32 - bits and 64 bits on a 64 bit system. The function returns the flop count as - an Int. This will not overflow on a 64 bit system but might on a 32 bit. - The total work is flops + O(n + nnz(Z)). Since flops > n and flops > nnz(Z), - this is O(flops). - - Copyright 2011, Timothy A. Davis, University of Florida -*/ - -Int sparseinv /* returns -1 on error, or flop count if OK */ -( - /* inputs, not modified on output: */ - Int *n, /* L, U, D, and Z are n-by-n */ - - Int *Lp, /* L is sparse, lower triangular, stored by column */ - Int *Li, /* the row indices of L must be sorted */ - double *Lx, /* diagonal of L, if present, is ignored */ - - double *d, /* diagonal of D, of size n */ - - Int *Up, /* U is sparse, upper triangular, stored by row */ - Int *Uj, /* the column indices of U need not be sorted */ - double *Ux, /* diagonal of U, if present, is ignored */ - - Int *Zp, /* Z is sparse, stored by column */ - Int *Zi, /* the row indices of Z must be sorted */ - - /* output, not defined on input: */ - double *Zx - - /* workspace: */ - //double *z, /* size n, zero on input, restored as such on output */ - //Int *Zdiagp, /* size n */ - //Int *Lmunch /* size n */ -) -{ - double ljk, zkj ; - Int j, i, k, p, znz, pdiag, up, zp, flops = *n ; - double *z = (double *) calloc(*n,sizeof(double)); - Int *Zdiagp = (Int *) malloc((*n)*sizeof(Int)); - Int *Lmunch = (Int *) malloc((*n)*sizeof(Int)); - - - /* ---------------------------------------------------------------------- */ - /* initializations */ - /* ---------------------------------------------------------------------- */ - - - - /* clear the numerical values of Z */ - znz = Zp [*n] ; - for (p = 0 ; p < znz ; p++) - { - Zx [p] = 0 ; - } - - /* find the diagonal of Z and initialize it */ - for (j = 0 ; j < *n ; j++) - { - pdiag = -1 ; - for (p = Zp [j] ; p < Zp [j+1] && pdiag == -1 ; p++) - { - if (Zi [p] == j) - { - pdiag = p ; - Zx [p] = 1 / d [j] ; - } - } - Zdiagp [j] = pdiag ; - if (pdiag == -1) return (-1) ; /* Z must have a zero-free diagonal */ - } - - /* Lmunch [k] points to the last entry in column k of L */ - for (k = 0 ; k < *n ; k++) - { - Lmunch [k] = Lp [k+1] - 1 ; - } - - /* ---------------------------------------------------------------------- */ - /* compute the sparse inverse subset */ - /* ---------------------------------------------------------------------- */ - - for (j = (*n)-1 ; j >= 0 ; j--) - { - - /* ------------------------------------------------------------------ */ - /* scatter Z (:,j) into z workspace */ - /* ------------------------------------------------------------------ */ - - /* only the lower triangular part is needed, since the upper triangular - part is all zero */ - for (p = Zdiagp [j] ; p < Zp [j+1] ; p++) - { - z [Zi [p]] = Zx [p] ; - } - - /* ------------------------------------------------------------------ */ - /* compute the strictly upper triangular part of Z (:,j) */ - /* ------------------------------------------------------------------ */ - - /* for k = (j-1):-1:1 but only for the entries Z(k,j) */ - for (p = Zdiagp [j]-1 ; p >= Zp [j] ; p--) - { - /* Z (k,j) = - U (k,k+1:n) * Z (k+1:n,j) */ - k = Zi [p] ; - zkj = 0 ; - flops += (Up [k+1] - Up [k]) ; - for (up = Up [k] ; up < Up [k+1] ; up++) - { - /* skip the diagonal of U, if present */ - i = Uj [up] ; - if (i > k) - { - zkj -= Ux [up] * z [i] ; - } - } - z [k] = zkj ; - } - - /* ------------------------------------------------------------------ */ - /* left-looking update to lower triangular part of Z */ - /* ------------------------------------------------------------------ */ - - /* for k = (j-1):-1:1 but only for the entries Z(k,j) */ - for (p = Zdiagp [j]-1 ; p >= Zp [j] ; p--) - { - k = Zi [p] ; - - /* ljk = L (j,k) */ - if (Lmunch [k] < Lp [k] || Li [Lmunch [k]] != j) - { - /* L (j,k) is zero, so there is no work to do */ - continue ; - } - ljk = Lx [Lmunch [k]--] ; - - /* Z (k+1:n,k) = Z (k+1:n,k) - Z (k+1:n,j) * L (j,k) */ - flops += (Zp [k+1] - Zdiagp [k]) ; - for (zp = Zdiagp [k] ; zp < Zp [k+1] ; zp++) - { - Zx [zp] -= z [Zi [zp]] * ljk ; - } - } - - /* ------------------------------------------------------------------ */ - /* gather Z (:,j) back from z workspace */ - /* ------------------------------------------------------------------ */ - - for (p = Zp [j] ; p < Zp [j+1] ; p++) - { - i = Zi [p] ; - Zx [p] = z [i] ; - z [i] = 0 ; - } - } - - free(z); - free(Zdiagp); - free(Lmunch); - - return (flops) ; -} diff --git a/src-i386/sparseinvR.h b/src-i386/sparseinvR.h deleted file mode 100644 index 3ac00d1..0000000 --- a/src-i386/sparseinvR.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _SPARSEINV_H_ -#define _SPARSEINV_H_ -#include -#define Int int - -Int sparseinv /* returns 1 if OK, 0 if failure */ -( - /* inputs, not modified on output: */ - Int *n, /* L, U, D, and Z are n-by-n */ - - Int *Lp, /* L is sparse, lower triangular, stored by column */ - Int *Li, /* the row indices of L must be sorted */ - double *Lx, /* diagonal of L, if present, is ignored */ - - double *d, /* diagonal of D, of size n */ - - Int *Up, /* U is sparse, upper triangular, stored by row */ - Int *Uj, /* the column indices of U need not be sorted */ - double *Ux, /* diagonal of U, if present, is ignored */ - - Int *Zp, /* Z is sparse, stored by column */ - Int *Zi, /* the row indices of Z must be sorted */ - - /* output, not defined on input: */ - double *Zx - - /* workspace: */ - // double *z, /* size n, zero on input, restored as such on output */ - // Int *Zdiagp, /* size n */ - // Int *Lmunch /* size n */ -) ; - -#endif diff --git a/src-i386/sparseinvR.o b/src-i386/sparseinvR.o deleted file mode 100644 index ac92d27..0000000 Binary files a/src-i386/sparseinvR.o and /dev/null differ diff --git a/src-x64/FRK-init.c b/src-x64/FRK-init.c deleted file mode 100644 index b12b9e1..0000000 --- a/src-x64/FRK-init.c +++ /dev/null @@ -1,51 +0,0 @@ -/*FRK: An R Software package for spatial and spatio-temporal prediction - with large datasets. - Copyright (c) 2017 University of Wollongong -Author: Andrew Zammit-Mangion, azm (at) uow.edu.au - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. */ - -#include "amd_order_wrapper.h" -#include "sparseinvR.h" -#include "distR.h" -#include -#include -#include -#include - - -void attribute_visible R_init_FRK(DllInfo *info) { - - static R_NativePrimitiveArgType sparseinv_t[] = { - INTSXP,INTSXP,INTSXP,REALSXP,REALSXP,INTSXP,INTSXP,REALSXP,INTSXP,INTSXP,REALSXP - }; - - static R_NativePrimitiveArgType AMD_order_wrapper_t[] = { - INTSXP,INTSXP,INTSXP,INTSXP,REALSXP,REALSXP - }; - - static R_CMethodDef cMethods[] = { - {"sparseinv", (DL_FUNC) &sparseinv, 11, sparseinv_t}, - {"AMD_order_wrapper", (DL_FUNC) &AMD_order_wrapper, 6, AMD_order_wrapper_t}, - {NULL, NULL, 0} - }; - - - static R_CallMethodDef callMethods[] = { - {"_FRK_distR_C", (DL_FUNC) &_FRK_distR_C, 2}, - {NULL, NULL, 0} - }; - - R_registerRoutines(info, cMethods, callMethods, NULL, NULL); - R_useDynamicSymbols(info, FALSE); - -} - diff --git a/src-x64/FRK-init.o b/src-x64/FRK-init.o deleted file mode 100644 index dcebb2a..0000000 Binary files a/src-x64/FRK-init.o and /dev/null differ diff --git a/src-x64/FRK-win.def b/src-x64/FRK-win.def deleted file mode 100644 index d4a3316..0000000 --- a/src-x64/FRK-win.def +++ /dev/null @@ -1,3 +0,0 @@ -LIBRARY FRK.dll -EXPORTS - R_init_FRK diff --git a/src-x64/FRK.so b/src-x64/FRK.so deleted file mode 100644 index 6b541df..0000000 Binary files a/src-x64/FRK.so and /dev/null differ diff --git a/src-x64/RcppExports.cpp b/src-x64/RcppExports.cpp deleted file mode 100644 index 6253e43..0000000 --- a/src-x64/RcppExports.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by using Rcpp::compileAttributes() -> do not edit by hand -// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -#include - -using namespace Rcpp; - -// distR_C -NumericMatrix distR_C(NumericMatrix x, NumericMatrix y); -RcppExport SEXP _FRK_distR_C(SEXP xSEXP, SEXP ySEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< NumericMatrix >::type x(xSEXP); - Rcpp::traits::input_parameter< NumericMatrix >::type y(ySEXP); - rcpp_result_gen = Rcpp::wrap(distR_C(x, y)); - return rcpp_result_gen; -END_RCPP -} diff --git a/src-x64/RcppExports.o b/src-x64/RcppExports.o deleted file mode 100644 index a2fee39..0000000 Binary files a/src-x64/RcppExports.o and /dev/null differ diff --git a/src-x64/SuiteSparse_config.h b/src-x64/SuiteSparse_config.h deleted file mode 100644 index fff5ea0..0000000 --- a/src-x64/SuiteSparse_config.h +++ /dev/null @@ -1,202 +0,0 @@ -/* ========================================================================== */ -/* === SuiteSparse_config =================================================== */ -/* ========================================================================== */ - -/* Configuration file for SuiteSparse: a Suite of Sparse matrix packages - * (AMD, COLAMD, CCOLAMD, CAMD, CHOLMOD, UMFPACK, CXSparse, and others). - * - * SuiteSparse_config.h provides the definition of the long integer. On most - * systems, a C program can be compiled in LP64 mode, in which long's and - * pointers are both 64-bits, and int's are 32-bits. Windows 64, however, uses - * the LLP64 model, in which int's and long's are 32-bits, and long long's and - * pointers are 64-bits. - * - * SuiteSparse packages that include long integer versions are - * intended for the LP64 mode. However, as a workaround for Windows 64 - * (and perhaps other systems), the long integer can be redefined. - * - * If _WIN64 is defined, then the __int64 type is used instead of long. - * - * The long integer can also be defined at compile time. For example, this - * could be added to SuiteSparse_config.mk: - * - * CFLAGS = -O -D'SuiteSparse_long=long long' \ - * -D'SuiteSparse_long_max=9223372036854775801' -D'SuiteSparse_long_idd="lld"' - * - * This file defines SuiteSparse_long as either long (on all but _WIN64) or - * __int64 on Windows 64. The intent is that a SuiteSparse_long is always a - * 64-bit integer in a 64-bit code. ptrdiff_t might be a better choice than - * long; it is always the same size as a pointer. - * - * This file also defines the SUITESPARSE_VERSION and related definitions. - * - * Copyright (c) 2012, Timothy A. Davis. No licensing restrictions apply - * to this file or to the SuiteSparse_config directory. - * Author: Timothy A. Davis. - */ - -#ifndef _SUITESPARSECONFIG_H -#define _SUITESPARSECONFIG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* ========================================================================== */ -/* === SuiteSparse_long ===================================================== */ -/* ========================================================================== */ - -#ifndef SuiteSparse_long - -#ifdef _WIN64 - -#define SuiteSparse_long __int64 -#define SuiteSparse_long_max _I64_MAX -#define SuiteSparse_long_idd "I64d" - -#else - -#define SuiteSparse_long long -#define SuiteSparse_long_max LONG_MAX -#define SuiteSparse_long_idd "ld" - -#endif -#define SuiteSparse_long_id "%" SuiteSparse_long_idd -#endif - -/* For backward compatibility with prior versions of SuiteSparse. The UF_* - * macros are deprecated and will be removed in a future version. */ -#ifndef UF_long -#define UF_long SuiteSparse_long -#define UF_long_max SuiteSparse_long_max -#define UF_long_idd SuiteSparse_long_idd -#define UF_long_id SuiteSparse_long_id -#endif - -/* ========================================================================== */ -/* === SuiteSparse_config parameters and functions ========================== */ -/* ========================================================================== */ - -/* SuiteSparse-wide parameters will be placed in this struct. */ - -typedef struct SuiteSparse_config_struct -{ - void *(*malloc_memory) (size_t) ; /* pointer to malloc */ - void *(*realloc_memory) (void *, size_t) ; /* pointer to realloc */ - void (*free_memory) (void *) ; /* pointer to free */ - void *(*calloc_memory) (size_t, size_t) ; /* pointer to calloc */ - -} SuiteSparse_config ; - -void *SuiteSparse_malloc /* pointer to allocated block of memory */ -( - size_t nitems, /* number of items to malloc (>=1 is enforced) */ - size_t size_of_item, /* sizeof each item */ - int *ok, /* TRUE if successful, FALSE otherwise */ - SuiteSparse_config *config /* SuiteSparse-wide configuration */ -) ; - -void *SuiteSparse_free /* always returns NULL */ -( - void *p, /* block to free */ - SuiteSparse_config *config /* SuiteSparse-wide configuration */ -) ; - -void SuiteSparse_tic /* start the timer */ -( - double tic [2] /* output, contents undefined on input */ -) ; - -double SuiteSparse_toc /* return time in seconds since last tic */ -( - double tic [2] /* input: from last call to SuiteSparse_tic */ -) ; - -double SuiteSparse_time /* returns current wall clock time in seconds */ -( - void -) ; - -/* determine which timer to use, if any */ -#ifndef NTIMER -#ifdef _POSIX_C_SOURCE -#if _POSIX_C_SOURCE >= 199309L -#define SUITESPARSE_TIMER_ENABLED -#endif -#endif -#endif - -/* ========================================================================== */ -/* === SuiteSparse version ================================================== */ -/* ========================================================================== */ - -/* SuiteSparse is not a package itself, but a collection of packages, some of - * which must be used together (UMFPACK requires AMD, CHOLMOD requires AMD, - * COLAMD, CAMD, and CCOLAMD, etc). A version number is provided here for the - * collection itself. The versions of packages within each version of - * SuiteSparse are meant to work together. Combining one packge from one - * version of SuiteSparse, with another package from another version of - * SuiteSparse, may or may not work. - * - * SuiteSparse contains the following packages: - * - * SuiteSparse_config version 4.2.1 (version always the same as SuiteSparse) - * AMD version 2.3.1 - * BTF version 1.2.0 - * CAMD version 2.3.1 - * CCOLAMD version 2.8.0 - * CHOLMOD version 2.1.2 - * COLAMD version 2.8.0 - * CSparse version 3.1.2 - * CXSparse version 3.1.2 - * KLU version 1.2.1 - * LDL version 2.1.0 - * RBio version 2.1.1 - * SPQR version 1.3.1 (full name is SuiteSparseQR) - * UMFPACK version 5.6.2 - * MATLAB_Tools various packages & M-files - * - * Other package dependencies: - * BLAS required by CHOLMOD and UMFPACK - * LAPACK required by CHOLMOD - * METIS 4.0.1 required by CHOLMOD (optional) and KLU (optional) - */ - - -int SuiteSparse_version /* returns SUITESPARSE_VERSION */ -( - /* output, not defined on input. Not used if NULL. Returns - the three version codes in version [0..2]: - version [0] is SUITESPARSE_MAIN_VERSION - version [1] is SUITESPARSE_SUB_VERSION - version [2] is SUITESPARSE_SUBSUB_VERSION - */ - int version [3] -) ; - -/* Versions prior to 4.2.0 do not have the above function. The following - code fragment will work with any version of SuiteSparse: - - #ifdef SUITESPARSE_HAS_VERSION_FUNCTION - v = SuiteSparse_version (NULL) ; - #else - v = SUITESPARSE_VERSION ; - #endif -*/ -#define SUITESPARSE_HAS_VERSION_FUNCTION - -#define SUITESPARSE_DATE "April 25, 2013" -#define SUITESPARSE_VER_CODE(main,sub) ((main) * 1000 + (sub)) -#define SUITESPARSE_MAIN_VERSION 4 -#define SUITESPARSE_SUB_VERSION 2 -#define SUITESPARSE_SUBSUB_VERSION 1 -#define SUITESPARSE_VERSION \ - SUITESPARSE_VER_CODE(SUITESPARSE_MAIN_VERSION,SUITESPARSE_SUB_VERSION) - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src-x64/amd.h b/src-x64/amd.h deleted file mode 100644 index 210967b..0000000 --- a/src-x64/amd.h +++ /dev/null @@ -1,411 +0,0 @@ -/* ========================================================================= */ -/* === AMD: approximate minimum degree ordering =========================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD Version 2.2, Copyright (c) 2007 by Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* AMD finds a symmetric ordering P of a matrix A so that the Cholesky - * factorization of P*A*P' has fewer nonzeros and takes less work than the - * Cholesky factorization of A. If A is not symmetric, then it performs its - * ordering on the matrix A+A'. Two sets of user-callable routines are - * provided, one for int integers and the other for SuiteSparse_long integers. - * - * The method is based on the approximate minimum degree algorithm, discussed - * in Amestoy, Davis, and Duff, "An approximate degree ordering algorithm", - * SIAM Journal of Matrix Analysis and Applications, vol. 17, no. 4, pp. - * 886-905, 1996. This package can perform both the AMD ordering (with - * aggressive absorption), and the AMDBAR ordering (without aggressive - * absorption) discussed in the above paper. This package differs from the - * Fortran codes discussed in the paper: - * - * (1) it can ignore "dense" rows and columns, leading to faster run times - * (2) it computes the ordering of A+A' if A is not symmetric - * (3) it is followed by a depth-first post-ordering of the assembly tree - * (or supernodal elimination tree) - * - * For historical reasons, the Fortran versions, amd.f and amdbar.f, have - * been left (nearly) unchanged. They compute the identical ordering as - * described in the above paper. - */ - -#ifndef AMD_H -#define AMD_H - -/* make it easy for C++ programs to include AMD */ -#ifdef __cplusplus -extern "C" { -#endif - -/* get the definition of size_t: */ -#include - -#include "SuiteSparse_config.h" - -int amd_order /* returns AMD_OK, AMD_OK_BUT_JUMBLED, - * AMD_INVALID, or AMD_OUT_OF_MEMORY */ -( - int n, /* A is n-by-n. n must be >= 0. */ - const int Ap [ ], /* column pointers for A, of size n+1 */ - const int Ai [ ], /* row indices of A, of size nz = Ap [n] */ - int P [ ], /* output permutation, of size n */ - double Control [ ], /* input Control settings, of size AMD_CONTROL */ - double Info [ ] /* output Info statistics, of size AMD_INFO */ -) ; - -SuiteSparse_long amd_l_order /* see above for description of arguments */ -( - SuiteSparse_long n, - const SuiteSparse_long Ap [ ], - const SuiteSparse_long Ai [ ], - SuiteSparse_long P [ ], - double Control [ ], - double Info [ ] -) ; - -/* Input arguments (not modified): - * - * n: the matrix A is n-by-n. - * Ap: an int/SuiteSparse_long array of size n+1, containing column - * pointers of A. - * Ai: an int/SuiteSparse_long array of size nz, containing the row - * indices of A, where nz = Ap [n]. - * Control: a double array of size AMD_CONTROL, containing control - * parameters. Defaults are used if Control is NULL. - * - * Output arguments (not defined on input): - * - * P: an int/SuiteSparse_long array of size n, containing the output - * permutation. If row i is the kth pivot row, then P [k] = i. In - * MATLAB notation, the reordered matrix is A (P,P). - * Info: a double array of size AMD_INFO, containing statistical - * information. Ignored if Info is NULL. - * - * On input, the matrix A is stored in column-oriented form. The row indices - * of nonzero entries in column j are stored in Ai [Ap [j] ... Ap [j+1]-1]. - * - * If the row indices appear in ascending order in each column, and there - * are no duplicate entries, then amd_order is slightly more efficient in - * terms of time and memory usage. If this condition does not hold, a copy - * of the matrix is created (where these conditions do hold), and the copy is - * ordered. This feature is new to v2.0 (v1.2 and earlier required this - * condition to hold for the input matrix). - * - * Row indices must be in the range 0 to - * n-1. Ap [0] must be zero, and thus nz = Ap [n] is the number of nonzeros - * in A. The array Ap is of size n+1, and the array Ai is of size nz = Ap [n]. - * The matrix does not need to be symmetric, and the diagonal does not need to - * be present (if diagonal entries are present, they are ignored except for - * the output statistic Info [AMD_NZDIAG]). The arrays Ai and Ap are not - * modified. This form of the Ap and Ai arrays to represent the nonzero - * pattern of the matrix A is the same as that used internally by MATLAB. - * If you wish to use a more flexible input structure, please see the - * umfpack_*_triplet_to_col routines in the UMFPACK package, at - * http://www.suitesparse.com. - * - * Restrictions: n >= 0. Ap [0] = 0. Ap [j] <= Ap [j+1] for all j in the - * range 0 to n-1. nz = Ap [n] >= 0. Ai [0..nz-1] must be in the range 0 - * to n-1. Finally, Ai, Ap, and P must not be NULL. If any of these - * restrictions are not met, AMD returns AMD_INVALID. - * - * AMD returns: - * - * AMD_OK if the matrix is valid and sufficient memory can be allocated to - * perform the ordering. - * - * AMD_OUT_OF_MEMORY if not enough memory can be allocated. - * - * AMD_INVALID if the input arguments n, Ap, Ai are invalid, or if P is - * NULL. - * - * AMD_OK_BUT_JUMBLED if the matrix had unsorted columns, and/or duplicate - * entries, but was otherwise valid. - * - * The AMD routine first forms the pattern of the matrix A+A', and then - * computes a fill-reducing ordering, P. If P [k] = i, then row/column i of - * the original is the kth pivotal row. In MATLAB notation, the permuted - * matrix is A (P,P), except that 0-based indexing is used instead of the - * 1-based indexing in MATLAB. - * - * The Control array is used to set various parameters for AMD. If a NULL - * pointer is passed, default values are used. The Control array is not - * modified. - * - * Control [AMD_DENSE]: controls the threshold for "dense" rows/columns. - * A dense row/column in A+A' can cause AMD to spend a lot of time in - * ordering the matrix. If Control [AMD_DENSE] >= 0, rows/columns - * with more than Control [AMD_DENSE] * sqrt (n) entries are ignored - * during the ordering, and placed last in the output order. The - * default value of Control [AMD_DENSE] is 10. If negative, no - * rows/columns are treated as "dense". Rows/columns with 16 or - * fewer off-diagonal entries are never considered "dense". - * - * Control [AMD_AGGRESSIVE]: controls whether or not to use aggressive - * absorption, in which a prior element is absorbed into the current - * element if is a subset of the current element, even if it is not - * adjacent to the current pivot element (refer to Amestoy, Davis, - * & Duff, 1996, for more details). The default value is nonzero, - * which means to perform aggressive absorption. This nearly always - * leads to a better ordering (because the approximate degrees are - * more accurate) and a lower execution time. There are cases where - * it can lead to a slightly worse ordering, however. To turn it off, - * set Control [AMD_AGGRESSIVE] to 0. - * - * Control [2..4] are not used in the current version, but may be used in - * future versions. - * - * The Info array provides statistics about the ordering on output. If it is - * not present, the statistics are not returned. This is not an error - * condition. - * - * Info [AMD_STATUS]: the return value of AMD, either AMD_OK, - * AMD_OK_BUT_JUMBLED, AMD_OUT_OF_MEMORY, or AMD_INVALID. - * - * Info [AMD_N]: n, the size of the input matrix - * - * Info [AMD_NZ]: the number of nonzeros in A, nz = Ap [n] - * - * Info [AMD_SYMMETRY]: the symmetry of the matrix A. It is the number - * of "matched" off-diagonal entries divided by the total number of - * off-diagonal entries. An entry A(i,j) is matched if A(j,i) is also - * an entry, for any pair (i,j) for which i != j. In MATLAB notation, - * S = spones (A) ; - * B = tril (S, -1) + triu (S, 1) ; - * symmetry = nnz (B & B') / nnz (B) ; - * - * Info [AMD_NZDIAG]: the number of entries on the diagonal of A. - * - * Info [AMD_NZ_A_PLUS_AT]: the number of nonzeros in A+A', excluding the - * diagonal. If A is perfectly symmetric (Info [AMD_SYMMETRY] = 1) - * with a fully nonzero diagonal, then Info [AMD_NZ_A_PLUS_AT] = nz-n - * (the smallest possible value). If A is perfectly unsymmetric - * (Info [AMD_SYMMETRY] = 0, for an upper triangular matrix, for - * example) with no diagonal, then Info [AMD_NZ_A_PLUS_AT] = 2*nz - * (the largest possible value). - * - * Info [AMD_NDENSE]: the number of "dense" rows/columns of A+A' that were - * removed from A prior to ordering. These are placed last in the - * output order P. - * - * Info [AMD_MEMORY]: the amount of memory used by AMD, in bytes. In the - * current version, this is 1.2 * Info [AMD_NZ_A_PLUS_AT] + 9*n - * times the size of an integer. This is at most 2.4nz + 9n. This - * excludes the size of the input arguments Ai, Ap, and P, which have - * a total size of nz + 2*n + 1 integers. - * - * Info [AMD_NCMPA]: the number of garbage collections performed. - * - * Info [AMD_LNZ]: the number of nonzeros in L (excluding the diagonal). - * This is a slight upper bound because mass elimination is combined - * with the approximate degree update. It is a rough upper bound if - * there are many "dense" rows/columns. The rest of the statistics, - * below, are also slight or rough upper bounds, for the same reasons. - * The post-ordering of the assembly tree might also not exactly - * correspond to a true elimination tree postordering. - * - * Info [AMD_NDIV]: the number of divide operations for a subsequent LDL' - * or LU factorization of the permuted matrix A (P,P). - * - * Info [AMD_NMULTSUBS_LDL]: the number of multiply-subtract pairs for a - * subsequent LDL' factorization of A (P,P). - * - * Info [AMD_NMULTSUBS_LU]: the number of multiply-subtract pairs for a - * subsequent LU factorization of A (P,P), assuming that no numerical - * pivoting is required. - * - * Info [AMD_DMAX]: the maximum number of nonzeros in any column of L, - * including the diagonal. - * - * Info [14..19] are not used in the current version, but may be used in - * future versions. - */ - -/* ------------------------------------------------------------------------- */ -/* direct interface to AMD */ -/* ------------------------------------------------------------------------- */ - -/* amd_2 is the primary AMD ordering routine. It is not meant to be - * user-callable because of its restrictive inputs and because it destroys - * the user's input matrix. It does not check its inputs for errors, either. - * However, if you can work with these restrictions it can be faster than - * amd_order and use less memory (assuming that you can create your own copy - * of the matrix for AMD to destroy). Refer to AMD/Source/amd_2.c for a - * description of each parameter. */ - -void amd_2 -( - int n, - int Pe [ ], - int Iw [ ], - int Len [ ], - int iwlen, - int pfree, - int Nv [ ], - int Next [ ], - int Last [ ], - int Head [ ], - int Elen [ ], - int Degree [ ], - int W [ ], - double Control [ ], - double Info [ ] -) ; - -void amd_l2 -( - SuiteSparse_long n, - SuiteSparse_long Pe [ ], - SuiteSparse_long Iw [ ], - SuiteSparse_long Len [ ], - SuiteSparse_long iwlen, - SuiteSparse_long pfree, - SuiteSparse_long Nv [ ], - SuiteSparse_long Next [ ], - SuiteSparse_long Last [ ], - SuiteSparse_long Head [ ], - SuiteSparse_long Elen [ ], - SuiteSparse_long Degree [ ], - SuiteSparse_long W [ ], - double Control [ ], - double Info [ ] -) ; - -/* ------------------------------------------------------------------------- */ -/* amd_valid */ -/* ------------------------------------------------------------------------- */ - -/* Returns AMD_OK or AMD_OK_BUT_JUMBLED if the matrix is valid as input to - * amd_order; the latter is returned if the matrix has unsorted and/or - * duplicate row indices in one or more columns. Returns AMD_INVALID if the - * matrix cannot be passed to amd_order. For amd_order, the matrix must also - * be square. The first two arguments are the number of rows and the number - * of columns of the matrix. For its use in AMD, these must both equal n. - * - * NOTE: this routine returned TRUE/FALSE in v1.2 and earlier. - */ - -int amd_valid -( - int n_row, /* # of rows */ - int n_col, /* # of columns */ - const int Ap [ ], /* column pointers, of size n_col+1 */ - const int Ai [ ] /* row indices, of size Ap [n_col] */ -) ; - -SuiteSparse_long amd_l_valid -( - SuiteSparse_long n_row, - SuiteSparse_long n_col, - const SuiteSparse_long Ap [ ], - const SuiteSparse_long Ai [ ] -) ; - -/* ------------------------------------------------------------------------- */ -/* AMD memory manager and printf routines */ -/* ------------------------------------------------------------------------- */ - -/* The user can redefine these to change the malloc, free, and printf routines - * that AMD uses. */ - -#ifndef EXTERN -#define EXTERN extern -#endif - -EXTERN void *(*amd_malloc) (size_t) ; /* pointer to malloc */ -EXTERN void (*amd_free) (void *) ; /* pointer to free */ -EXTERN void *(*amd_realloc) (void *, size_t) ; /* pointer to realloc */ -EXTERN void *(*amd_calloc) (size_t, size_t) ; /* pointer to calloc */ -EXTERN int (*amd_printf) (const char *, ...) ; /* pointer to printf */ - -/* ------------------------------------------------------------------------- */ -/* AMD Control and Info arrays */ -/* ------------------------------------------------------------------------- */ - -/* amd_defaults: sets the default control settings */ -void amd_defaults (double Control [ ]) ; -void amd_l_defaults (double Control [ ]) ; - -/* amd_control: prints the control settings */ -void amd_control (double Control [ ]) ; -void amd_l_control (double Control [ ]) ; - -/* amd_info: prints the statistics */ -void amd_info (double Info [ ]) ; -void amd_l_info (double Info [ ]) ; - -#define AMD_CONTROL 5 /* size of Control array */ -#define AMD_INFO 20 /* size of Info array */ - -/* contents of Control */ -#define AMD_DENSE 0 /* "dense" if degree > Control [0] * sqrt (n) */ -#define AMD_AGGRESSIVE 1 /* do aggressive absorption if Control [1] != 0 */ - -/* default Control settings */ -#define AMD_DEFAULT_DENSE 10.0 /* default "dense" degree 10*sqrt(n) */ -#define AMD_DEFAULT_AGGRESSIVE 1 /* do aggressive absorption by default */ - -/* contents of Info */ -#define AMD_STATUS 0 /* return value of amd_order and amd_l_order */ -#define AMD_N 1 /* A is n-by-n */ -#define AMD_NZ 2 /* number of nonzeros in A */ -#define AMD_SYMMETRY 3 /* symmetry of pattern (1 is sym., 0 is unsym.) */ -#define AMD_NZDIAG 4 /* # of entries on diagonal */ -#define AMD_NZ_A_PLUS_AT 5 /* nz in A+A' */ -#define AMD_NDENSE 6 /* number of "dense" rows/columns in A */ -#define AMD_MEMORY 7 /* amount of memory used by AMD */ -#define AMD_NCMPA 8 /* number of garbage collections in AMD */ -#define AMD_LNZ 9 /* approx. nz in L, excluding the diagonal */ -#define AMD_NDIV 10 /* number of fl. point divides for LU and LDL' */ -#define AMD_NMULTSUBS_LDL 11 /* number of fl. point (*,-) pairs for LDL' */ -#define AMD_NMULTSUBS_LU 12 /* number of fl. point (*,-) pairs for LU */ -#define AMD_DMAX 13 /* max nz. in any column of L, incl. diagonal */ - -/* ------------------------------------------------------------------------- */ -/* return values of AMD */ -/* ------------------------------------------------------------------------- */ - -#define AMD_OK 0 /* success */ -#define AMD_OUT_OF_MEMORY -1 /* malloc failed, or problem too large */ -#define AMD_INVALID -2 /* input arguments are not valid */ -#define AMD_OK_BUT_JUMBLED 1 /* input matrix is OK for amd_order, but - * columns were not sorted, and/or duplicate entries were present. AMD had - * to do extra work before ordering the matrix. This is a warning, not an - * error. */ - -/* ========================================================================== */ -/* === AMD version ========================================================== */ -/* ========================================================================== */ - -/* AMD Version 1.2 and later include the following definitions. - * As an example, to test if the version you are using is 1.2 or later: - * - * #ifdef AMD_VERSION - * if (AMD_VERSION >= AMD_VERSION_CODE (1,2)) ... - * #endif - * - * This also works during compile-time: - * - * #if defined(AMD_VERSION) && (AMD_VERSION >= AMD_VERSION_CODE (1,2)) - * printf ("This is version 1.2 or later\n") ; - * #else - * printf ("This is an early version\n") ; - * #endif - * - * Versions 1.1 and earlier of AMD do not include a #define'd version number. - */ - -#define AMD_DATE "Jun 20, 2012" -#define AMD_VERSION_CODE(main,sub) ((main) * 1000 + (sub)) -#define AMD_MAIN_VERSION 2 -#define AMD_SUB_VERSION 3 -#define AMD_SUBSUB_VERSION 1 -#define AMD_VERSION AMD_VERSION_CODE(AMD_MAIN_VERSION,AMD_SUB_VERSION) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src-x64/amd_1.c b/src-x64/amd_1.c deleted file mode 100644 index 296d198..0000000 --- a/src-x64/amd_1.c +++ /dev/null @@ -1,183 +0,0 @@ -/* ========================================================================= */ -/* === AMD_1 =============================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* AMD_1: Construct A+A' for a sparse matrix A and perform the AMD ordering. - * - * The n-by-n sparse matrix A can be unsymmetric. It is stored in MATLAB-style - * compressed-column form, with sorted row indices in each column, and no - * duplicate entries. Diagonal entries may be present, but they are ignored. - * Row indices of column j of A are stored in Ai [Ap [j] ... Ap [j+1]-1]. - * Ap [0] must be zero, and nz = Ap [n] is the number of entries in A. The - * size of the matrix, n, must be greater than or equal to zero. - * - * This routine must be preceded by a call to AMD_aat, which computes the - * number of entries in each row/column in A+A', excluding the diagonal. - * Len [j], on input, is the number of entries in row/column j of A+A'. This - * routine constructs the matrix A+A' and then calls AMD_2. No error checking - * is performed (this was done in AMD_valid). - */ - -#include /* required */ -#include /* for distribution functions etc. */ - -#include "amd_internal.h" - -GLOBAL void AMD_1 -( - Int n, /* n > 0 */ - const Int Ap [ ], /* input of size n+1, not modified */ - const Int Ai [ ], /* input of size nz = Ap [n], not modified */ - Int P [ ], /* size n output permutation */ - Int Pinv [ ], /* size n output inverse permutation */ - Int Len [ ], /* size n input, undefined on output */ - Int slen, /* slen >= sum (Len [0..n-1]) + 7n, - * ideally slen = 1.2 * sum (Len) + 8n */ - Int S [ ], /* size slen workspace */ - double Control [ ], /* input array of size AMD_CONTROL */ - double Info [ ] /* output array of size AMD_INFO */ -) -{ - Int i, j, k, p, pfree, iwlen, pj, p1, p2, pj2, *Iw, *Pe, *Nv, *Head, - *Elen, *Degree, *s, *W, *Sp, *Tp ; - - /* --------------------------------------------------------------------- */ - /* construct the matrix for AMD_2 */ - /* --------------------------------------------------------------------- */ - - ASSERT (n > 0) ; - - iwlen = slen - 6*n ; - s = S ; - Pe = s ; s += n ; - Nv = s ; s += n ; - Head = s ; s += n ; - Elen = s ; s += n ; - Degree = s ; s += n ; - W = s ; s += n ; - Iw = s ; s += iwlen ; - - ASSERT (AMD_valid (n, n, Ap, Ai) == AMD_OK) ; - - /* construct the pointers for A+A' */ - Sp = Nv ; /* use Nv and W as workspace for Sp and Tp [ */ - Tp = W ; - pfree = 0 ; - for (j = 0 ; j < n ; j++) - { - Pe [j] = pfree ; - Sp [j] = pfree ; - pfree += Len [j] ; - } - - /* Note that this restriction on iwlen is slightly more restrictive than - * what is strictly required in AMD_2. AMD_2 can operate with no elbow - * room at all, but it will be very slow. For better performance, at - * least size-n elbow room is enforced. */ - ASSERT (iwlen >= pfree + n) ; - -#ifndef NDEBUG - for (p = 0 ; p < iwlen ; p++) Iw [p] = EMPTY ; -#endif - - for (k = 0 ; k < n ; k++) - { - AMD_DEBUG1 (("Construct row/column k= "ID" of A+A'\n", k)) ; - p1 = Ap [k] ; - p2 = Ap [k+1] ; - - /* construct A+A' */ - for (p = p1 ; p < p2 ; ) - { - /* scan the upper triangular part of A */ - j = Ai [p] ; - ASSERT (j >= 0 && j < n) ; - if (j < k) - { - /* entry A (j,k) in the strictly upper triangular part */ - ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ; - ASSERT (Sp [k] < (k == n-1 ? pfree : Pe [k+1])) ; - Iw [Sp [j]++] = k ; - Iw [Sp [k]++] = j ; - p++ ; - } - else if (j == k) - { - /* skip the diagonal */ - p++ ; - break ; - } - else /* j > k */ - { - /* first entry below the diagonal */ - break ; - } - /* scan lower triangular part of A, in column j until reaching - * row k. Start where last scan left off. */ - ASSERT (Ap [j] <= Tp [j] && Tp [j] <= Ap [j+1]) ; - pj2 = Ap [j+1] ; - for (pj = Tp [j] ; pj < pj2 ; ) - { - i = Ai [pj] ; - ASSERT (i >= 0 && i < n) ; - if (i < k) - { - /* A (i,j) is only in the lower part, not in upper */ - ASSERT (Sp [i] < (i == n-1 ? pfree : Pe [i+1])) ; - ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ; - Iw [Sp [i]++] = j ; - Iw [Sp [j]++] = i ; - pj++ ; - } - else if (i == k) - { - /* entry A (k,j) in lower part and A (j,k) in upper */ - pj++ ; - break ; - } - else /* i > k */ - { - /* consider this entry later, when k advances to i */ - break ; - } - } - Tp [j] = pj ; - } - Tp [k] = p ; - } - - /* clean up, for remaining mismatched entries */ - for (j = 0 ; j < n ; j++) - { - for (pj = Tp [j] ; pj < Ap [j+1] ; pj++) - { - i = Ai [pj] ; - ASSERT (i >= 0 && i < n) ; - /* A (i,j) is only in the lower part, not in upper */ - ASSERT (Sp [i] < (i == n-1 ? pfree : Pe [i+1])) ; - ASSERT (Sp [j] < (j == n-1 ? pfree : Pe [j+1])) ; - Iw [Sp [i]++] = j ; - Iw [Sp [j]++] = i ; - } - } - -#ifndef NDEBUG - for (j = 0 ; j < n-1 ; j++) ASSERT (Sp [j] == Pe [j+1]) ; - ASSERT (Sp [n-1] == pfree) ; -#endif - - /* Tp and Sp no longer needed ] */ - - /* --------------------------------------------------------------------- */ - /* order the matrix */ - /* --------------------------------------------------------------------- */ - - AMD_2 (n, Pe, Iw, Len, iwlen, pfree, - Nv, Pinv, P, Head, Elen, Degree, W, Control, Info) ; -} diff --git a/src-x64/amd_1.o b/src-x64/amd_1.o deleted file mode 100644 index 105d8f8..0000000 Binary files a/src-x64/amd_1.o and /dev/null differ diff --git a/src-x64/amd_2.c b/src-x64/amd_2.c deleted file mode 100644 index 7e8c838..0000000 --- a/src-x64/amd_2.c +++ /dev/null @@ -1,1842 +0,0 @@ -/* ========================================================================= */ -/* === AMD_2 =============================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* AMD_2: performs the AMD ordering on a symmetric sparse matrix A, followed - * by a postordering (via depth-first search) of the assembly tree using the - * AMD_postorder routine. - */ - -#include "amd_internal.h" - -/* ========================================================================= */ -/* === clear_flag ========================================================== */ -/* ========================================================================= */ - -static Int clear_flag (Int wflg, Int wbig, Int W [ ], Int n) -{ - Int x ; - if (wflg < 2 || wflg >= wbig) - { - for (x = 0 ; x < n ; x++) - { - if (W [x] != 0) W [x] = 1 ; - } - wflg = 2 ; - } - /* at this point, W [0..n-1] < wflg holds */ - return (wflg) ; -} - - -/* ========================================================================= */ -/* === AMD_2 =============================================================== */ -/* ========================================================================= */ - -GLOBAL void AMD_2 -( - Int n, /* A is n-by-n, where n > 0 */ - Int Pe [ ], /* Pe [0..n-1]: index in Iw of row i on input */ - Int Iw [ ], /* workspace of size iwlen. Iw [0..pfree-1] - * holds the matrix on input */ - Int Len [ ], /* Len [0..n-1]: length for row/column i on input */ - Int iwlen, /* length of Iw. iwlen >= pfree + n */ - Int pfree, /* Iw [pfree ... iwlen-1] is empty on input */ - - /* 7 size-n workspaces, not defined on input: */ - Int Nv [ ], /* the size of each supernode on output */ - Int Next [ ], /* the output inverse permutation */ - Int Last [ ], /* the output permutation */ - Int Head [ ], - Int Elen [ ], /* the size columns of L for each supernode */ - Int Degree [ ], - Int W [ ], - - /* control parameters and output statistics */ - double Control [ ], /* array of size AMD_CONTROL */ - double Info [ ] /* array of size AMD_INFO */ -) -{ - -/* - * Given a representation of the nonzero pattern of a symmetric matrix, A, - * (excluding the diagonal) perform an approximate minimum (UMFPACK/MA38-style) - * degree ordering to compute a pivot order such that the introduction of - * nonzeros (fill-in) in the Cholesky factors A = LL' is kept low. At each - * step, the pivot selected is the one with the minimum UMFAPACK/MA38-style - * upper-bound on the external degree. This routine can optionally perform - * aggresive absorption (as done by MC47B in the Harwell Subroutine - * Library). - * - * The approximate degree algorithm implemented here is the symmetric analog of - * the degree update algorithm in MA38 and UMFPACK (the Unsymmetric-pattern - * MultiFrontal PACKage, both by Davis and Duff). The routine is based on the - * MA27 minimum degree ordering algorithm by Iain Duff and John Reid. - * - * This routine is a translation of the original AMDBAR and MC47B routines, - * in Fortran, with the following modifications: - * - * (1) dense rows/columns are removed prior to ordering the matrix, and placed - * last in the output order. The presence of a dense row/column can - * increase the ordering time by up to O(n^2), unless they are removed - * prior to ordering. - * - * (2) the minimum degree ordering is followed by a postordering (depth-first - * search) of the assembly tree. Note that mass elimination (discussed - * below) combined with the approximate degree update can lead to the mass - * elimination of nodes with lower exact degree than the current pivot - * element. No additional fill-in is caused in the representation of the - * Schur complement. The mass-eliminated nodes merge with the current - * pivot element. They are ordered prior to the current pivot element. - * Because they can have lower exact degree than the current element, the - * merger of two or more of these nodes in the current pivot element can - * lead to a single element that is not a "fundamental supernode". The - * diagonal block can have zeros in it. Thus, the assembly tree used here - * is not guaranteed to be the precise supernodal elemination tree (with - * "funadmental" supernodes), and the postordering performed by this - * routine is not guaranteed to be a precise postordering of the - * elimination tree. - * - * (3) input parameters are added, to control aggressive absorption and the - * detection of "dense" rows/columns of A. - * - * (4) additional statistical information is returned, such as the number of - * nonzeros in L, and the flop counts for subsequent LDL' and LU - * factorizations. These are slight upper bounds, because of the mass - * elimination issue discussed above. - * - * (5) additional routines are added to interface this routine to MATLAB - * to provide a simple C-callable user-interface, to check inputs for - * errors, compute the symmetry of the pattern of A and the number of - * nonzeros in each row/column of A+A', to compute the pattern of A+A', - * to perform the assembly tree postordering, and to provide debugging - * ouput. Many of these functions are also provided by the Fortran - * Harwell Subroutine Library routine MC47A. - * - * (6) both int and SuiteSparse_long versions are provided. In the - * descriptions below and integer is and int or SuiteSparse_long depending - * on which version is being used. - - ********************************************************************** - ***** CAUTION: ARGUMENTS ARE NOT CHECKED FOR ERRORS ON INPUT. ****** - ********************************************************************** - ** If you want error checking, a more versatile input format, and a ** - ** simpler user interface, use amd_order or amd_l_order instead. ** - ** This routine is not meant to be user-callable. ** - ********************************************************************** - - * ---------------------------------------------------------------------------- - * References: - * ---------------------------------------------------------------------------- - * - * [1] Timothy A. Davis and Iain Duff, "An unsymmetric-pattern multifrontal - * method for sparse LU factorization", SIAM J. Matrix Analysis and - * Applications, vol. 18, no. 1, pp. 140-158. Discusses UMFPACK / MA38, - * which first introduced the approximate minimum degree used by this - * routine. - * - * [2] Patrick Amestoy, Timothy A. Davis, and Iain S. Duff, "An approximate - * minimum degree ordering algorithm," SIAM J. Matrix Analysis and - * Applications, vol. 17, no. 4, pp. 886-905, 1996. Discusses AMDBAR and - * MC47B, which are the Fortran versions of this routine. - * - * [3] Alan George and Joseph Liu, "The evolution of the minimum degree - * ordering algorithm," SIAM Review, vol. 31, no. 1, pp. 1-19, 1989. - * We list below the features mentioned in that paper that this code - * includes: - * - * mass elimination: - * Yes. MA27 relied on supervariable detection for mass elimination. - * - * indistinguishable nodes: - * Yes (we call these "supervariables"). This was also in the MA27 - * code - although we modified the method of detecting them (the - * previous hash was the true degree, which we no longer keep track - * of). A supervariable is a set of rows with identical nonzero - * pattern. All variables in a supervariable are eliminated together. - * Each supervariable has as its numerical name that of one of its - * variables (its principal variable). - * - * quotient graph representation: - * Yes. We use the term "element" for the cliques formed during - * elimination. This was also in the MA27 code. The algorithm can - * operate in place, but it will work more efficiently if given some - * "elbow room." - * - * element absorption: - * Yes. This was also in the MA27 code. - * - * external degree: - * Yes. The MA27 code was based on the true degree. - * - * incomplete degree update and multiple elimination: - * No. This was not in MA27, either. Our method of degree update - * within MC47B is element-based, not variable-based. It is thus - * not well-suited for use with incomplete degree update or multiple - * elimination. - * - * Authors, and Copyright (C) 2004 by: - * Timothy A. Davis, Patrick Amestoy, Iain S. Duff, John K. Reid. - * - * Acknowledgements: This work (and the UMFPACK package) was supported by the - * National Science Foundation (ASC-9111263, DMS-9223088, and CCR-0203270). - * The UMFPACK/MA38 approximate degree update algorithm, the unsymmetric analog - * which forms the basis of AMD, was developed while Tim Davis was supported by - * CERFACS (Toulouse, France) in a post-doctoral position. This C version, and - * the etree postorder, were written while Tim Davis was on sabbatical at - * Stanford University and Lawrence Berkeley National Laboratory. - - * ---------------------------------------------------------------------------- - * INPUT ARGUMENTS (unaltered): - * ---------------------------------------------------------------------------- - - * n: The matrix order. Restriction: n >= 1. - * - * iwlen: The size of the Iw array. On input, the matrix is stored in - * Iw [0..pfree-1]. However, Iw [0..iwlen-1] should be slightly larger - * than what is required to hold the matrix, at least iwlen >= pfree + n. - * Otherwise, excessive compressions will take place. The recommended - * value of iwlen is 1.2 * pfree + n, which is the value used in the - * user-callable interface to this routine (amd_order.c). The algorithm - * will not run at all if iwlen < pfree. Restriction: iwlen >= pfree + n. - * Note that this is slightly more restrictive than the actual minimum - * (iwlen >= pfree), but AMD_2 will be very slow with no elbow room. - * Thus, this routine enforces a bare minimum elbow room of size n. - * - * pfree: On input the tail end of the array, Iw [pfree..iwlen-1], is empty, - * and the matrix is stored in Iw [0..pfree-1]. During execution, - * additional data is placed in Iw, and pfree is modified so that - * Iw [pfree..iwlen-1] is always the unused part of Iw. - * - * Control: A double array of size AMD_CONTROL containing input parameters - * that affect how the ordering is computed. If NULL, then default - * settings are used. - * - * Control [AMD_DENSE] is used to determine whether or not a given input - * row is "dense". A row is "dense" if the number of entries in the row - * exceeds Control [AMD_DENSE] times sqrt (n), except that rows with 16 or - * fewer entries are never considered "dense". To turn off the detection - * of dense rows, set Control [AMD_DENSE] to a negative number, or to a - * number larger than sqrt (n). The default value of Control [AMD_DENSE] - * is AMD_DEFAULT_DENSE, which is defined in amd.h as 10. - * - * Control [AMD_AGGRESSIVE] is used to determine whether or not aggressive - * absorption is to be performed. If nonzero, then aggressive absorption - * is performed (this is the default). - - * ---------------------------------------------------------------------------- - * INPUT/OUPUT ARGUMENTS: - * ---------------------------------------------------------------------------- - * - * Pe: An integer array of size n. On input, Pe [i] is the index in Iw of - * the start of row i. Pe [i] is ignored if row i has no off-diagonal - * entries. Thus Pe [i] must be in the range 0 to pfree-1 for non-empty - * rows. - * - * During execution, it is used for both supervariables and elements: - * - * Principal supervariable i: index into Iw of the description of - * supervariable i. A supervariable represents one or more rows of - * the matrix with identical nonzero pattern. In this case, - * Pe [i] >= 0. - * - * Non-principal supervariable i: if i has been absorbed into another - * supervariable j, then Pe [i] = FLIP (j), where FLIP (j) is defined - * as (-(j)-2). Row j has the same pattern as row i. Note that j - * might later be absorbed into another supervariable j2, in which - * case Pe [i] is still FLIP (j), and Pe [j] = FLIP (j2) which is - * < EMPTY, where EMPTY is defined as (-1) in amd_internal.h. - * - * Unabsorbed element e: the index into Iw of the description of element - * e, if e has not yet been absorbed by a subsequent element. Element - * e is created when the supervariable of the same name is selected as - * the pivot. In this case, Pe [i] >= 0. - * - * Absorbed element e: if element e is absorbed into element e2, then - * Pe [e] = FLIP (e2). This occurs when the pattern of e (which we - * refer to as Le) is found to be a subset of the pattern of e2 (that - * is, Le2). In this case, Pe [i] < EMPTY. If element e is "null" - * (it has no nonzeros outside its pivot block), then Pe [e] = EMPTY, - * and e is the root of an assembly subtree (or the whole tree if - * there is just one such root). - * - * Dense variable i: if i is "dense", then Pe [i] = EMPTY. - * - * On output, Pe holds the assembly tree/forest, which implicitly - * represents a pivot order with identical fill-in as the actual order - * (via a depth-first search of the tree), as follows. If Nv [i] > 0, - * then i represents a node in the assembly tree, and the parent of i is - * Pe [i], or EMPTY if i is a root. If Nv [i] = 0, then (i, Pe [i]) - * represents an edge in a subtree, the root of which is a node in the - * assembly tree. Note that i refers to a row/column in the original - * matrix, not the permuted matrix. - * - * Info: A double array of size AMD_INFO. If present, (that is, not NULL), - * then statistics about the ordering are returned in the Info array. - * See amd.h for a description. - - * ---------------------------------------------------------------------------- - * INPUT/MODIFIED (undefined on output): - * ---------------------------------------------------------------------------- - * - * Len: An integer array of size n. On input, Len [i] holds the number of - * entries in row i of the matrix, excluding the diagonal. The contents - * of Len are undefined on output. - * - * Iw: An integer array of size iwlen. On input, Iw [0..pfree-1] holds the - * description of each row i in the matrix. The matrix must be symmetric, - * and both upper and lower triangular parts must be present. The - * diagonal must not be present. Row i is held as follows: - * - * Len [i]: the length of the row i data structure in the Iw array. - * Iw [Pe [i] ... Pe [i] + Len [i] - 1]: - * the list of column indices for nonzeros in row i (simple - * supervariables), excluding the diagonal. All supervariables - * start with one row/column each (supervariable i is just row i). - * If Len [i] is zero on input, then Pe [i] is ignored on input. - * - * Note that the rows need not be in any particular order, and there - * may be empty space between the rows. - * - * During execution, the supervariable i experiences fill-in. This is - * represented by placing in i a list of the elements that cause fill-in - * in supervariable i: - * - * Len [i]: the length of supervariable i in the Iw array. - * Iw [Pe [i] ... Pe [i] + Elen [i] - 1]: - * the list of elements that contain i. This list is kept short - * by removing absorbed elements. - * Iw [Pe [i] + Elen [i] ... Pe [i] + Len [i] - 1]: - * the list of supervariables in i. This list is kept short by - * removing nonprincipal variables, and any entry j that is also - * contained in at least one of the elements (j in Le) in the list - * for i (e in row i). - * - * When supervariable i is selected as pivot, we create an element e of - * the same name (e=i): - * - * Len [e]: the length of element e in the Iw array. - * Iw [Pe [e] ... Pe [e] + Len [e] - 1]: - * the list of supervariables in element e. - * - * An element represents the fill-in that occurs when supervariable i is - * selected as pivot (which represents the selection of row i and all - * non-principal variables whose principal variable is i). We use the - * term Le to denote the set of all supervariables in element e. Absorbed - * supervariables and elements are pruned from these lists when - * computationally convenient. - * - * CAUTION: THE INPUT MATRIX IS OVERWRITTEN DURING COMPUTATION. - * The contents of Iw are undefined on output. - - * ---------------------------------------------------------------------------- - * OUTPUT (need not be set on input): - * ---------------------------------------------------------------------------- - * - * Nv: An integer array of size n. During execution, ABS (Nv [i]) is equal to - * the number of rows that are represented by the principal supervariable - * i. If i is a nonprincipal or dense variable, then Nv [i] = 0. - * Initially, Nv [i] = 1 for all i. Nv [i] < 0 signifies that i is a - * principal variable in the pattern Lme of the current pivot element me. - * After element me is constructed, Nv [i] is set back to a positive - * value. - * - * On output, Nv [i] holds the number of pivots represented by super - * row/column i of the original matrix, or Nv [i] = 0 for non-principal - * rows/columns. Note that i refers to a row/column in the original - * matrix, not the permuted matrix. - * - * Elen: An integer array of size n. See the description of Iw above. At the - * start of execution, Elen [i] is set to zero for all rows i. During - * execution, Elen [i] is the number of elements in the list for - * supervariable i. When e becomes an element, Elen [e] = FLIP (esize) is - * set, where esize is the size of the element (the number of pivots, plus - * the number of nonpivotal entries). Thus Elen [e] < EMPTY. - * Elen (i) = EMPTY set when variable i becomes nonprincipal. - * - * For variables, Elen (i) >= EMPTY holds until just before the - * postordering and permutation vectors are computed. For elements, - * Elen [e] < EMPTY holds. - * - * On output, Elen [i] is the degree of the row/column in the Cholesky - * factorization of the permuted matrix, corresponding to the original row - * i, if i is a super row/column. It is equal to EMPTY if i is - * non-principal. Note that i refers to a row/column in the original - * matrix, not the permuted matrix. - * - * Note that the contents of Elen on output differ from the Fortran - * version (Elen holds the inverse permutation in the Fortran version, - * which is instead returned in the Next array in this C version, - * described below). - * - * Last: In a degree list, Last [i] is the supervariable preceding i, or EMPTY - * if i is the head of the list. In a hash bucket, Last [i] is the hash - * key for i. - * - * Last [Head [hash]] is also used as the head of a hash bucket if - * Head [hash] contains a degree list (see the description of Head, - * below). - * - * On output, Last [0..n-1] holds the permutation. That is, if - * i = Last [k], then row i is the kth pivot row (where k ranges from 0 to - * n-1). Row Last [k] of A is the kth row in the permuted matrix, PAP'. - * - * Next: Next [i] is the supervariable following i in a link list, or EMPTY if - * i is the last in the list. Used for two kinds of lists: degree lists - * and hash buckets (a supervariable can be in only one kind of list at a - * time). - * - * On output Next [0..n-1] holds the inverse permutation. That is, if - * k = Next [i], then row i is the kth pivot row. Row i of A appears as - * the (Next[i])-th row in the permuted matrix, PAP'. - * - * Note that the contents of Next on output differ from the Fortran - * version (Next is undefined on output in the Fortran version). - - * ---------------------------------------------------------------------------- - * LOCAL WORKSPACE (not input or output - used only during execution): - * ---------------------------------------------------------------------------- - * - * Degree: An integer array of size n. If i is a supervariable, then - * Degree [i] holds the current approximation of the external degree of - * row i (an upper bound). The external degree is the number of nonzeros - * in row i, minus ABS (Nv [i]), the diagonal part. The bound is equal to - * the exact external degree if Elen [i] is less than or equal to two. - * - * We also use the term "external degree" for elements e to refer to - * |Le \ Lme|. If e is an element, then Degree [e] is |Le|, which is the - * degree of the off-diagonal part of the element e (not including the - * diagonal part). - * - * Head: An integer array of size n. Head is used for degree lists. - * Head [deg] is the first supervariable in a degree list. All - * supervariables i in a degree list Head [deg] have the same approximate - * degree, namely, deg = Degree [i]. If the list Head [deg] is empty then - * Head [deg] = EMPTY. - * - * During supervariable detection Head [hash] also serves as a pointer to - * a hash bucket. If Head [hash] >= 0, there is a degree list of degree - * hash. The hash bucket head pointer is Last [Head [hash]]. If - * Head [hash] = EMPTY, then the degree list and hash bucket are both - * empty. If Head [hash] < EMPTY, then the degree list is empty, and - * FLIP (Head [hash]) is the head of the hash bucket. After supervariable - * detection is complete, all hash buckets are empty, and the - * (Last [Head [hash]] = EMPTY) condition is restored for the non-empty - * degree lists. - * - * W: An integer array of size n. The flag array W determines the status of - * elements and variables, and the external degree of elements. - * - * for elements: - * if W [e] = 0, then the element e is absorbed. - * if W [e] >= wflg, then W [e] - wflg is the size of the set - * |Le \ Lme|, in terms of nonzeros (the sum of ABS (Nv [i]) for - * each principal variable i that is both in the pattern of - * element e and NOT in the pattern of the current pivot element, - * me). - * if wflg > W [e] > 0, then e is not absorbed and has not yet been - * seen in the scan of the element lists in the computation of - * |Le\Lme| in Scan 1 below. - * - * for variables: - * during supervariable detection, if W [j] != wflg then j is - * not in the pattern of variable i. - * - * The W array is initialized by setting W [i] = 1 for all i, and by - * setting wflg = 2. It is reinitialized if wflg becomes too large (to - * ensure that wflg+n does not cause integer overflow). - - * ---------------------------------------------------------------------------- - * LOCAL INTEGERS: - * ---------------------------------------------------------------------------- - */ - - Int deg, degme, dext, lemax, e, elenme, eln, i, ilast, inext, j, - jlast, jnext, k, knt1, knt2, knt3, lenj, ln, me, mindeg, nel, nleft, - nvi, nvj, nvpiv, slenme, wbig, we, wflg, wnvi, ok, ndense, ncmpa, - dense, aggressive ; - - unsigned Int hash ; /* unsigned, so that hash % n is well defined.*/ - -/* - * deg: the degree of a variable or element - * degme: size, |Lme|, of the current element, me (= Degree [me]) - * dext: external degree, |Le \ Lme|, of some element e - * lemax: largest |Le| seen so far (called dmax in Fortran version) - * e: an element - * elenme: the length, Elen [me], of element list of pivotal variable - * eln: the length, Elen [...], of an element list - * hash: the computed value of the hash function - * i: a supervariable - * ilast: the entry in a link list preceding i - * inext: the entry in a link list following i - * j: a supervariable - * jlast: the entry in a link list preceding j - * jnext: the entry in a link list, or path, following j - * k: the pivot order of an element or variable - * knt1: loop counter used during element construction - * knt2: loop counter used during element construction - * knt3: loop counter used during compression - * lenj: Len [j] - * ln: length of a supervariable list - * me: current supervariable being eliminated, and the current - * element created by eliminating that supervariable - * mindeg: current minimum degree - * nel: number of pivots selected so far - * nleft: n - nel, the number of nonpivotal rows/columns remaining - * nvi: the number of variables in a supervariable i (= Nv [i]) - * nvj: the number of variables in a supervariable j (= Nv [j]) - * nvpiv: number of pivots in current element - * slenme: number of variables in variable list of pivotal variable - * wbig: = (INT_MAX - n) for the int version, (SuiteSparse_long_max - n) - * for the SuiteSparse_long version. wflg is not allowed to - * be >= wbig. - * we: W [e] - * wflg: used for flagging the W array. See description of Iw. - * wnvi: wflg - Nv [i] - * x: either a supervariable or an element - * - * ok: true if supervariable j can be absorbed into i - * ndense: number of "dense" rows/columns - * dense: rows/columns with initial degree > dense are considered "dense" - * aggressive: true if aggressive absorption is being performed - * ncmpa: number of garbage collections - - * ---------------------------------------------------------------------------- - * LOCAL DOUBLES, used for statistical output only (except for alpha): - * ---------------------------------------------------------------------------- - */ - - double f, r, ndiv, s, nms_lu, nms_ldl, dmax, alpha, lnz, lnzme ; - -/* - * f: nvpiv - * r: degme + nvpiv - * ndiv: number of divisions for LU or LDL' factorizations - * s: number of multiply-subtract pairs for LU factorization, for the - * current element me - * nms_lu number of multiply-subtract pairs for LU factorization - * nms_ldl number of multiply-subtract pairs for LDL' factorization - * dmax: the largest number of entries in any column of L, including the - * diagonal - * alpha: "dense" degree ratio - * lnz: the number of nonzeros in L (excluding the diagonal) - * lnzme: the number of nonzeros in L (excl. the diagonal) for the - * current element me - - * ---------------------------------------------------------------------------- - * LOCAL "POINTERS" (indices into the Iw array) - * ---------------------------------------------------------------------------- -*/ - - Int p, p1, p2, p3, p4, pdst, pend, pj, pme, pme1, pme2, pn, psrc ; - -/* - * Any parameter (Pe [...] or pfree) or local variable starting with "p" (for - * Pointer) is an index into Iw, and all indices into Iw use variables starting - * with "p." The only exception to this rule is the iwlen input argument. - * - * p: pointer into lots of things - * p1: Pe [i] for some variable i (start of element list) - * p2: Pe [i] + Elen [i] - 1 for some variable i - * p3: index of first supervariable in clean list - * p4: - * pdst: destination pointer, for compression - * pend: end of memory to compress - * pj: pointer into an element or variable - * pme: pointer into the current element (pme1...pme2) - * pme1: the current element, me, is stored in Iw [pme1...pme2] - * pme2: the end of the current element - * pn: pointer into a "clean" variable, also used to compress - * psrc: source pointer, for compression -*/ - -/* ========================================================================= */ -/* INITIALIZATIONS */ -/* ========================================================================= */ - - /* Note that this restriction on iwlen is slightly more restrictive than - * what is actually required in AMD_2. AMD_2 can operate with no elbow - * room at all, but it will be slow. For better performance, at least - * size-n elbow room is enforced. */ - ASSERT (iwlen >= pfree + n) ; - ASSERT (n > 0) ; - - /* initialize output statistics */ - lnz = 0 ; - ndiv = 0 ; - nms_lu = 0 ; - nms_ldl = 0 ; - dmax = 1 ; - me = EMPTY ; - - mindeg = 0 ; - ncmpa = 0 ; - nel = 0 ; - lemax = 0 ; - - /* get control parameters */ - if (Control != (double *) NULL) - { - alpha = Control [AMD_DENSE] ; - aggressive = (Control [AMD_AGGRESSIVE] != 0) ; - } - else - { - alpha = AMD_DEFAULT_DENSE ; - aggressive = AMD_DEFAULT_AGGRESSIVE ; - } - /* Note: if alpha is NaN, this is undefined: */ - if (alpha < 0) - { - /* only remove completely dense rows/columns */ - dense = n-2 ; - } - else - { - dense = alpha * sqrt ((double) n) ; - } - dense = MAX (16, dense) ; - dense = MIN (n, dense) ; - AMD_DEBUG1 (("\n\nAMD (debug), alpha %g, aggr. "ID"\n", - alpha, aggressive)) ; - - for (i = 0 ; i < n ; i++) - { - Last [i] = EMPTY ; - Head [i] = EMPTY ; - Next [i] = EMPTY ; - /* if separate Hhead array is used for hash buckets: * - Hhead [i] = EMPTY ; - */ - Nv [i] = 1 ; - W [i] = 1 ; - Elen [i] = 0 ; - Degree [i] = Len [i] ; - } - -#ifndef NDEBUG - AMD_DEBUG1 (("\n======Nel "ID" initial\n", nel)) ; - AMD_dump (n, Pe, Iw, Len, iwlen, pfree, Nv, Next, Last, - Head, Elen, Degree, W, -1) ; -#endif - - /* initialize wflg */ - wbig = Int_MAX - n ; - wflg = clear_flag (0, wbig, W, n) ; - - /* --------------------------------------------------------------------- */ - /* initialize degree lists and eliminate dense and empty rows */ - /* --------------------------------------------------------------------- */ - - ndense = 0 ; - - for (i = 0 ; i < n ; i++) - { - deg = Degree [i] ; - ASSERT (deg >= 0 && deg < n) ; - if (deg == 0) - { - - /* ------------------------------------------------------------- - * we have a variable that can be eliminated at once because - * there is no off-diagonal non-zero in its row. Note that - * Nv [i] = 1 for an empty variable i. It is treated just - * the same as an eliminated element i. - * ------------------------------------------------------------- */ - - Elen [i] = FLIP (1) ; - nel++ ; - Pe [i] = EMPTY ; - W [i] = 0 ; - - } - else if (deg > dense) - { - - /* ------------------------------------------------------------- - * Dense variables are not treated as elements, but as unordered, - * non-principal variables that have no parent. They do not take - * part in the postorder, since Nv [i] = 0. Note that the Fortran - * version does not have this option. - * ------------------------------------------------------------- */ - - AMD_DEBUG1 (("Dense node "ID" degree "ID"\n", i, deg)) ; - ndense++ ; - Nv [i] = 0 ; /* do not postorder this node */ - Elen [i] = EMPTY ; - nel++ ; - Pe [i] = EMPTY ; - - } - else - { - - /* ------------------------------------------------------------- - * place i in the degree list corresponding to its degree - * ------------------------------------------------------------- */ - - inext = Head [deg] ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = i ; - Next [i] = inext ; - Head [deg] = i ; - - } - } - -/* ========================================================================= */ -/* WHILE (selecting pivots) DO */ -/* ========================================================================= */ - - while (nel < n) - { - -#ifndef NDEBUG - AMD_DEBUG1 (("\n======Nel "ID"\n", nel)) ; - if (AMD_debug >= 2) - { - AMD_dump (n, Pe, Iw, Len, iwlen, pfree, Nv, Next, - Last, Head, Elen, Degree, W, nel) ; - } -#endif - -/* ========================================================================= */ -/* GET PIVOT OF MINIMUM DEGREE */ -/* ========================================================================= */ - - /* ----------------------------------------------------------------- */ - /* find next supervariable for elimination */ - /* ----------------------------------------------------------------- */ - - ASSERT (mindeg >= 0 && mindeg < n) ; - for (deg = mindeg ; deg < n ; deg++) - { - me = Head [deg] ; - if (me != EMPTY) break ; - } - mindeg = deg ; - ASSERT (me >= 0 && me < n) ; - AMD_DEBUG1 (("=================me: "ID"\n", me)) ; - - /* ----------------------------------------------------------------- */ - /* remove chosen variable from link list */ - /* ----------------------------------------------------------------- */ - - inext = Next [me] ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = EMPTY ; - Head [deg] = inext ; - - /* ----------------------------------------------------------------- */ - /* me represents the elimination of pivots nel to nel+Nv[me]-1. */ - /* place me itself as the first in this set. */ - /* ----------------------------------------------------------------- */ - - elenme = Elen [me] ; - nvpiv = Nv [me] ; - ASSERT (nvpiv > 0) ; - nel += nvpiv ; - -/* ========================================================================= */ -/* CONSTRUCT NEW ELEMENT */ -/* ========================================================================= */ - - /* ----------------------------------------------------------------- - * At this point, me is the pivotal supervariable. It will be - * converted into the current element. Scan list of the pivotal - * supervariable, me, setting tree pointers and constructing new list - * of supervariables for the new element, me. p is a pointer to the - * current position in the old list. - * ----------------------------------------------------------------- */ - - /* flag the variable "me" as being in Lme by negating Nv [me] */ - Nv [me] = -nvpiv ; - degme = 0 ; - ASSERT (Pe [me] >= 0 && Pe [me] < iwlen) ; - - if (elenme == 0) - { - - /* ------------------------------------------------------------- */ - /* construct the new element in place */ - /* ------------------------------------------------------------- */ - - pme1 = Pe [me] ; - pme2 = pme1 - 1 ; - - for (p = pme1 ; p <= pme1 + Len [me] - 1 ; p++) - { - i = Iw [p] ; - ASSERT (i >= 0 && i < n && Nv [i] >= 0) ; - nvi = Nv [i] ; - if (nvi > 0) - { - - /* ----------------------------------------------------- */ - /* i is a principal variable not yet placed in Lme. */ - /* store i in new list */ - /* ----------------------------------------------------- */ - - /* flag i as being in Lme by negating Nv [i] */ - degme += nvi ; - Nv [i] = -nvi ; - Iw [++pme2] = i ; - - /* ----------------------------------------------------- */ - /* remove variable i from degree list. */ - /* ----------------------------------------------------- */ - - ilast = Last [i] ; - inext = Next [i] ; - ASSERT (ilast >= EMPTY && ilast < n) ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = ilast ; - if (ilast != EMPTY) - { - Next [ilast] = inext ; - } - else - { - /* i is at the head of the degree list */ - ASSERT (Degree [i] >= 0 && Degree [i] < n) ; - Head [Degree [i]] = inext ; - } - } - } - } - else - { - - /* ------------------------------------------------------------- */ - /* construct the new element in empty space, Iw [pfree ...] */ - /* ------------------------------------------------------------- */ - - p = Pe [me] ; - pme1 = pfree ; - slenme = Len [me] - elenme ; - - for (knt1 = 1 ; knt1 <= elenme + 1 ; knt1++) - { - - if (knt1 > elenme) - { - /* search the supervariables in me. */ - e = me ; - pj = p ; - ln = slenme ; - AMD_DEBUG2 (("Search sv: "ID" "ID" "ID"\n", me,pj,ln)) ; - } - else - { - /* search the elements in me. */ - e = Iw [p++] ; - ASSERT (e >= 0 && e < n) ; - pj = Pe [e] ; - ln = Len [e] ; - AMD_DEBUG2 (("Search element e "ID" in me "ID"\n", e,me)) ; - ASSERT (Elen [e] < EMPTY && W [e] > 0 && pj >= 0) ; - } - ASSERT (ln >= 0 && (ln == 0 || (pj >= 0 && pj < iwlen))) ; - - /* --------------------------------------------------------- - * search for different supervariables and add them to the - * new list, compressing when necessary. this loop is - * executed once for each element in the list and once for - * all the supervariables in the list. - * --------------------------------------------------------- */ - - for (knt2 = 1 ; knt2 <= ln ; knt2++) - { - i = Iw [pj++] ; - ASSERT (i >= 0 && i < n && (i == me || Elen [i] >= EMPTY)); - nvi = Nv [i] ; - AMD_DEBUG2 ((": "ID" "ID" "ID" "ID"\n", - i, Elen [i], Nv [i], wflg)) ; - - if (nvi > 0) - { - - /* ------------------------------------------------- */ - /* compress Iw, if necessary */ - /* ------------------------------------------------- */ - - if (pfree >= iwlen) - { - - AMD_DEBUG1 (("GARBAGE COLLECTION\n")) ; - - /* prepare for compressing Iw by adjusting pointers - * and lengths so that the lists being searched in - * the inner and outer loops contain only the - * remaining entries. */ - - Pe [me] = p ; - Len [me] -= knt1 ; - /* check if nothing left of supervariable me */ - if (Len [me] == 0) Pe [me] = EMPTY ; - Pe [e] = pj ; - Len [e] = ln - knt2 ; - /* nothing left of element e */ - if (Len [e] == 0) Pe [e] = EMPTY ; - - ncmpa++ ; /* one more garbage collection */ - - /* store first entry of each object in Pe */ - /* FLIP the first entry in each object */ - for (j = 0 ; j < n ; j++) - { - pn = Pe [j] ; - if (pn >= 0) - { - ASSERT (pn >= 0 && pn < iwlen) ; - Pe [j] = Iw [pn] ; - Iw [pn] = FLIP (j) ; - } - } - - /* psrc/pdst point to source/destination */ - psrc = 0 ; - pdst = 0 ; - pend = pme1 - 1 ; - - while (psrc <= pend) - { - /* search for next FLIP'd entry */ - j = FLIP (Iw [psrc++]) ; - if (j >= 0) - { - AMD_DEBUG2 (("Got object j: "ID"\n", j)) ; - Iw [pdst] = Pe [j] ; - Pe [j] = pdst++ ; - lenj = Len [j] ; - /* copy from source to destination */ - for (knt3 = 0 ; knt3 <= lenj - 2 ; knt3++) - { - Iw [pdst++] = Iw [psrc++] ; - } - } - } - - /* move the new partially-constructed element */ - p1 = pdst ; - for (psrc = pme1 ; psrc <= pfree-1 ; psrc++) - { - Iw [pdst++] = Iw [psrc] ; - } - pme1 = p1 ; - pfree = pdst ; - pj = Pe [e] ; - p = Pe [me] ; - - } - - /* ------------------------------------------------- */ - /* i is a principal variable not yet placed in Lme */ - /* store i in new list */ - /* ------------------------------------------------- */ - - /* flag i as being in Lme by negating Nv [i] */ - degme += nvi ; - Nv [i] = -nvi ; - Iw [pfree++] = i ; - AMD_DEBUG2 ((" s: "ID" nv "ID"\n", i, Nv [i])); - - /* ------------------------------------------------- */ - /* remove variable i from degree link list */ - /* ------------------------------------------------- */ - - ilast = Last [i] ; - inext = Next [i] ; - ASSERT (ilast >= EMPTY && ilast < n) ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = ilast ; - if (ilast != EMPTY) - { - Next [ilast] = inext ; - } - else - { - /* i is at the head of the degree list */ - ASSERT (Degree [i] >= 0 && Degree [i] < n) ; - Head [Degree [i]] = inext ; - } - } - } - - if (e != me) - { - /* set tree pointer and flag to indicate element e is - * absorbed into new element me (the parent of e is me) */ - AMD_DEBUG1 ((" Element "ID" => "ID"\n", e, me)) ; - Pe [e] = FLIP (me) ; - W [e] = 0 ; - } - } - - pme2 = pfree - 1 ; - } - - /* ----------------------------------------------------------------- */ - /* me has now been converted into an element in Iw [pme1..pme2] */ - /* ----------------------------------------------------------------- */ - - /* degme holds the external degree of new element */ - Degree [me] = degme ; - Pe [me] = pme1 ; - Len [me] = pme2 - pme1 + 1 ; - ASSERT (Pe [me] >= 0 && Pe [me] < iwlen) ; - - Elen [me] = FLIP (nvpiv + degme) ; - /* FLIP (Elen (me)) is now the degree of pivot (including - * diagonal part). */ - -#ifndef NDEBUG - AMD_DEBUG2 (("New element structure: length= "ID"\n", pme2-pme1+1)) ; - for (pme = pme1 ; pme <= pme2 ; pme++) AMD_DEBUG3 ((" "ID"", Iw[pme])); - AMD_DEBUG3 (("\n")) ; -#endif - - /* ----------------------------------------------------------------- */ - /* make sure that wflg is not too large. */ - /* ----------------------------------------------------------------- */ - - /* With the current value of wflg, wflg+n must not cause integer - * overflow */ - - wflg = clear_flag (wflg, wbig, W, n) ; - -/* ========================================================================= */ -/* COMPUTE (W [e] - wflg) = |Le\Lme| FOR ALL ELEMENTS */ -/* ========================================================================= */ - - /* ----------------------------------------------------------------- - * Scan 1: compute the external degrees of previous elements with - * respect to the current element. That is: - * (W [e] - wflg) = |Le \ Lme| - * for each element e that appears in any supervariable in Lme. The - * notation Le refers to the pattern (list of supervariables) of a - * previous element e, where e is not yet absorbed, stored in - * Iw [Pe [e] + 1 ... Pe [e] + Len [e]]. The notation Lme - * refers to the pattern of the current element (stored in - * Iw [pme1..pme2]). If aggressive absorption is enabled, and - * (W [e] - wflg) becomes zero, then the element e will be absorbed - * in Scan 2. - * ----------------------------------------------------------------- */ - - AMD_DEBUG2 (("me: ")) ; - for (pme = pme1 ; pme <= pme2 ; pme++) - { - i = Iw [pme] ; - ASSERT (i >= 0 && i < n) ; - eln = Elen [i] ; - AMD_DEBUG3 ((""ID" Elen "ID": \n", i, eln)) ; - if (eln > 0) - { - /* note that Nv [i] has been negated to denote i in Lme: */ - nvi = -Nv [i] ; - ASSERT (nvi > 0 && Pe [i] >= 0 && Pe [i] < iwlen) ; - wnvi = wflg - nvi ; - for (p = Pe [i] ; p <= Pe [i] + eln - 1 ; p++) - { - e = Iw [p] ; - ASSERT (e >= 0 && e < n) ; - we = W [e] ; - AMD_DEBUG4 ((" e "ID" we "ID" ", e, we)) ; - if (we >= wflg) - { - /* unabsorbed element e has been seen in this loop */ - AMD_DEBUG4 ((" unabsorbed, first time seen")) ; - we -= nvi ; - } - else if (we != 0) - { - /* e is an unabsorbed element */ - /* this is the first we have seen e in all of Scan 1 */ - AMD_DEBUG4 ((" unabsorbed")) ; - we = Degree [e] + wnvi ; - } - AMD_DEBUG4 (("\n")) ; - W [e] = we ; - } - } - } - AMD_DEBUG2 (("\n")) ; - -/* ========================================================================= */ -/* DEGREE UPDATE AND ELEMENT ABSORPTION */ -/* ========================================================================= */ - - /* ----------------------------------------------------------------- - * Scan 2: for each i in Lme, sum up the degree of Lme (which is - * degme), plus the sum of the external degrees of each Le for the - * elements e appearing within i, plus the supervariables in i. - * Place i in hash list. - * ----------------------------------------------------------------- */ - - for (pme = pme1 ; pme <= pme2 ; pme++) - { - i = Iw [pme] ; - ASSERT (i >= 0 && i < n && Nv [i] < 0 && Elen [i] >= 0) ; - AMD_DEBUG2 (("Updating: i "ID" "ID" "ID"\n", i, Elen[i], Len [i])); - p1 = Pe [i] ; - p2 = p1 + Elen [i] - 1 ; - pn = p1 ; - hash = 0 ; - deg = 0 ; - ASSERT (p1 >= 0 && p1 < iwlen && p2 >= -1 && p2 < iwlen) ; - - /* ------------------------------------------------------------- */ - /* scan the element list associated with supervariable i */ - /* ------------------------------------------------------------- */ - - /* UMFPACK/MA38-style approximate degree: */ - if (aggressive) - { - for (p = p1 ; p <= p2 ; p++) - { - e = Iw [p] ; - ASSERT (e >= 0 && e < n) ; - we = W [e] ; - if (we != 0) - { - /* e is an unabsorbed element */ - /* dext = | Le \ Lme | */ - dext = we - wflg ; - if (dext > 0) - { - deg += dext ; - Iw [pn++] = e ; - hash += e ; - AMD_DEBUG4 ((" e: "ID" hash = "ID"\n",e,hash)) ; - } - else - { - /* external degree of e is zero, absorb e into me*/ - AMD_DEBUG1 ((" Element "ID" =>"ID" (aggressive)\n", - e, me)) ; - ASSERT (dext == 0) ; - Pe [e] = FLIP (me) ; - W [e] = 0 ; - } - } - } - } - else - { - for (p = p1 ; p <= p2 ; p++) - { - e = Iw [p] ; - ASSERT (e >= 0 && e < n) ; - we = W [e] ; - if (we != 0) - { - /* e is an unabsorbed element */ - dext = we - wflg ; - ASSERT (dext >= 0) ; - deg += dext ; - Iw [pn++] = e ; - hash += e ; - AMD_DEBUG4 ((" e: "ID" hash = "ID"\n",e,hash)) ; - } - } - } - - /* count the number of elements in i (including me): */ - Elen [i] = pn - p1 + 1 ; - - /* ------------------------------------------------------------- */ - /* scan the supervariables in the list associated with i */ - /* ------------------------------------------------------------- */ - - /* The bulk of the AMD run time is typically spent in this loop, - * particularly if the matrix has many dense rows that are not - * removed prior to ordering. */ - p3 = pn ; - p4 = p1 + Len [i] ; - for (p = p2 + 1 ; p < p4 ; p++) - { - j = Iw [p] ; - ASSERT (j >= 0 && j < n) ; - nvj = Nv [j] ; - if (nvj > 0) - { - /* j is unabsorbed, and not in Lme. */ - /* add to degree and add to new list */ - deg += nvj ; - Iw [pn++] = j ; - hash += j ; - AMD_DEBUG4 ((" s: "ID" hash "ID" Nv[j]= "ID"\n", - j, hash, nvj)) ; - } - } - - /* ------------------------------------------------------------- */ - /* update the degree and check for mass elimination */ - /* ------------------------------------------------------------- */ - - /* with aggressive absorption, deg==0 is identical to the - * Elen [i] == 1 && p3 == pn test, below. */ - ASSERT (IMPLIES (aggressive, (deg==0) == (Elen[i]==1 && p3==pn))) ; - - if (Elen [i] == 1 && p3 == pn) - { - - /* --------------------------------------------------------- */ - /* mass elimination */ - /* --------------------------------------------------------- */ - - /* There is nothing left of this node except for an edge to - * the current pivot element. Elen [i] is 1, and there are - * no variables adjacent to node i. Absorb i into the - * current pivot element, me. Note that if there are two or - * more mass eliminations, fillin due to mass elimination is - * possible within the nvpiv-by-nvpiv pivot block. It is this - * step that causes AMD's analysis to be an upper bound. - * - * The reason is that the selected pivot has a lower - * approximate degree than the true degree of the two mass - * eliminated nodes. There is no edge between the two mass - * eliminated nodes. They are merged with the current pivot - * anyway. - * - * No fillin occurs in the Schur complement, in any case, - * and this effect does not decrease the quality of the - * ordering itself, just the quality of the nonzero and - * flop count analysis. It also means that the post-ordering - * is not an exact elimination tree post-ordering. */ - - AMD_DEBUG1 ((" MASS i "ID" => parent e "ID"\n", i, me)) ; - Pe [i] = FLIP (me) ; - nvi = -Nv [i] ; - degme -= nvi ; - nvpiv += nvi ; - nel += nvi ; - Nv [i] = 0 ; - Elen [i] = EMPTY ; - - } - else - { - - /* --------------------------------------------------------- */ - /* update the upper-bound degree of i */ - /* --------------------------------------------------------- */ - - /* the following degree does not yet include the size - * of the current element, which is added later: */ - - Degree [i] = MIN (Degree [i], deg) ; - - /* --------------------------------------------------------- */ - /* add me to the list for i */ - /* --------------------------------------------------------- */ - - /* move first supervariable to end of list */ - Iw [pn] = Iw [p3] ; - /* move first element to end of element part of list */ - Iw [p3] = Iw [p1] ; - /* add new element, me, to front of list. */ - Iw [p1] = me ; - /* store the new length of the list in Len [i] */ - Len [i] = pn - p1 + 1 ; - - /* --------------------------------------------------------- */ - /* place in hash bucket. Save hash key of i in Last [i]. */ - /* --------------------------------------------------------- */ - - /* NOTE: this can fail if hash is negative, because the ANSI C - * standard does not define a % b when a and/or b are negative. - * That's why hash is defined as an unsigned Int, to avoid this - * problem. */ - hash = hash % n ; - ASSERT (((Int) hash) >= 0 && ((Int) hash) < n) ; - - /* if the Hhead array is not used: */ - j = Head [hash] ; - if (j <= EMPTY) - { - /* degree list is empty, hash head is FLIP (j) */ - Next [i] = FLIP (j) ; - Head [hash] = FLIP (i) ; - } - else - { - /* degree list is not empty, use Last [Head [hash]] as - * hash head. */ - Next [i] = Last [j] ; - Last [j] = i ; - } - - /* if a separate Hhead array is used: * - Next [i] = Hhead [hash] ; - Hhead [hash] = i ; - */ - - Last [i] = hash ; - } - } - - Degree [me] = degme ; - - /* ----------------------------------------------------------------- */ - /* Clear the counter array, W [...], by incrementing wflg. */ - /* ----------------------------------------------------------------- */ - - /* make sure that wflg+n does not cause integer overflow */ - lemax = MAX (lemax, degme) ; - wflg += lemax ; - wflg = clear_flag (wflg, wbig, W, n) ; - /* at this point, W [0..n-1] < wflg holds */ - -/* ========================================================================= */ -/* SUPERVARIABLE DETECTION */ -/* ========================================================================= */ - - AMD_DEBUG1 (("Detecting supervariables:\n")) ; - for (pme = pme1 ; pme <= pme2 ; pme++) - { - i = Iw [pme] ; - ASSERT (i >= 0 && i < n) ; - AMD_DEBUG2 (("Consider i "ID" nv "ID"\n", i, Nv [i])) ; - if (Nv [i] < 0) - { - /* i is a principal variable in Lme */ - - /* --------------------------------------------------------- - * examine all hash buckets with 2 or more variables. We do - * this by examing all unique hash keys for supervariables in - * the pattern Lme of the current element, me - * --------------------------------------------------------- */ - - /* let i = head of hash bucket, and empty the hash bucket */ - ASSERT (Last [i] >= 0 && Last [i] < n) ; - hash = Last [i] ; - - /* if Hhead array is not used: */ - j = Head [hash] ; - if (j == EMPTY) - { - /* hash bucket and degree list are both empty */ - i = EMPTY ; - } - else if (j < EMPTY) - { - /* degree list is empty */ - i = FLIP (j) ; - Head [hash] = EMPTY ; - } - else - { - /* degree list is not empty, restore Last [j] of head j */ - i = Last [j] ; - Last [j] = EMPTY ; - } - - /* if separate Hhead array is used: * - i = Hhead [hash] ; - Hhead [hash] = EMPTY ; - */ - - ASSERT (i >= EMPTY && i < n) ; - AMD_DEBUG2 (("----i "ID" hash "ID"\n", i, hash)) ; - - while (i != EMPTY && Next [i] != EMPTY) - { - - /* ----------------------------------------------------- - * this bucket has one or more variables following i. - * scan all of them to see if i can absorb any entries - * that follow i in hash bucket. Scatter i into w. - * ----------------------------------------------------- */ - - ln = Len [i] ; - eln = Elen [i] ; - ASSERT (ln >= 0 && eln >= 0) ; - ASSERT (Pe [i] >= 0 && Pe [i] < iwlen) ; - /* do not flag the first element in the list (me) */ - for (p = Pe [i] + 1 ; p <= Pe [i] + ln - 1 ; p++) - { - ASSERT (Iw [p] >= 0 && Iw [p] < n) ; - W [Iw [p]] = wflg ; - } - - /* ----------------------------------------------------- */ - /* scan every other entry j following i in bucket */ - /* ----------------------------------------------------- */ - - jlast = i ; - j = Next [i] ; - ASSERT (j >= EMPTY && j < n) ; - - while (j != EMPTY) - { - /* ------------------------------------------------- */ - /* check if j and i have identical nonzero pattern */ - /* ------------------------------------------------- */ - - AMD_DEBUG3 (("compare i "ID" and j "ID"\n", i,j)) ; - - /* check if i and j have the same Len and Elen */ - ASSERT (Len [j] >= 0 && Elen [j] >= 0) ; - ASSERT (Pe [j] >= 0 && Pe [j] < iwlen) ; - ok = (Len [j] == ln) && (Elen [j] == eln) ; - /* skip the first element in the list (me) */ - for (p = Pe [j] + 1 ; ok && p <= Pe [j] + ln - 1 ; p++) - { - ASSERT (Iw [p] >= 0 && Iw [p] < n) ; - if (W [Iw [p]] != wflg) ok = 0 ; - } - if (ok) - { - /* --------------------------------------------- */ - /* found it! j can be absorbed into i */ - /* --------------------------------------------- */ - - AMD_DEBUG1 (("found it! j "ID" => i "ID"\n", j,i)); - Pe [j] = FLIP (i) ; - /* both Nv [i] and Nv [j] are negated since they */ - /* are in Lme, and the absolute values of each */ - /* are the number of variables in i and j: */ - Nv [i] += Nv [j] ; - Nv [j] = 0 ; - Elen [j] = EMPTY ; - /* delete j from hash bucket */ - ASSERT (j != Next [j]) ; - j = Next [j] ; - Next [jlast] = j ; - - } - else - { - /* j cannot be absorbed into i */ - jlast = j ; - ASSERT (j != Next [j]) ; - j = Next [j] ; - } - ASSERT (j >= EMPTY && j < n) ; - } - - /* ----------------------------------------------------- - * no more variables can be absorbed into i - * go to next i in bucket and clear flag array - * ----------------------------------------------------- */ - - wflg++ ; - i = Next [i] ; - ASSERT (i >= EMPTY && i < n) ; - - } - } - } - AMD_DEBUG2 (("detect done\n")) ; - -/* ========================================================================= */ -/* RESTORE DEGREE LISTS AND REMOVE NONPRINCIPAL SUPERVARIABLES FROM ELEMENT */ -/* ========================================================================= */ - - p = pme1 ; - nleft = n - nel ; - for (pme = pme1 ; pme <= pme2 ; pme++) - { - i = Iw [pme] ; - ASSERT (i >= 0 && i < n) ; - nvi = -Nv [i] ; - AMD_DEBUG3 (("Restore i "ID" "ID"\n", i, nvi)) ; - if (nvi > 0) - { - /* i is a principal variable in Lme */ - /* restore Nv [i] to signify that i is principal */ - Nv [i] = nvi ; - - /* --------------------------------------------------------- */ - /* compute the external degree (add size of current element) */ - /* --------------------------------------------------------- */ - - deg = Degree [i] + degme - nvi ; - deg = MIN (deg, nleft - nvi) ; - ASSERT (IMPLIES (aggressive, deg > 0) && deg >= 0 && deg < n) ; - - /* --------------------------------------------------------- */ - /* place the supervariable at the head of the degree list */ - /* --------------------------------------------------------- */ - - inext = Head [deg] ; - ASSERT (inext >= EMPTY && inext < n) ; - if (inext != EMPTY) Last [inext] = i ; - Next [i] = inext ; - Last [i] = EMPTY ; - Head [deg] = i ; - - /* --------------------------------------------------------- */ - /* save the new degree, and find the minimum degree */ - /* --------------------------------------------------------- */ - - mindeg = MIN (mindeg, deg) ; - Degree [i] = deg ; - - /* --------------------------------------------------------- */ - /* place the supervariable in the element pattern */ - /* --------------------------------------------------------- */ - - Iw [p++] = i ; - - } - } - AMD_DEBUG2 (("restore done\n")) ; - -/* ========================================================================= */ -/* FINALIZE THE NEW ELEMENT */ -/* ========================================================================= */ - - AMD_DEBUG2 (("ME = "ID" DONE\n", me)) ; - Nv [me] = nvpiv ; - /* save the length of the list for the new element me */ - Len [me] = p - pme1 ; - if (Len [me] == 0) - { - /* there is nothing left of the current pivot element */ - /* it is a root of the assembly tree */ - Pe [me] = EMPTY ; - W [me] = 0 ; - } - if (elenme != 0) - { - /* element was not constructed in place: deallocate part of */ - /* it since newly nonprincipal variables may have been removed */ - pfree = p ; - } - - /* The new element has nvpiv pivots and the size of the contribution - * block for a multifrontal method is degme-by-degme, not including - * the "dense" rows/columns. If the "dense" rows/columns are included, - * the frontal matrix is no larger than - * (degme+ndense)-by-(degme+ndense). - */ - - if (Info != (double *) NULL) - { - f = nvpiv ; - r = degme + ndense ; - dmax = MAX (dmax, f + r) ; - - /* number of nonzeros in L (excluding the diagonal) */ - lnzme = f*r + (f-1)*f/2 ; - lnz += lnzme ; - - /* number of divide operations for LDL' and for LU */ - ndiv += lnzme ; - - /* number of multiply-subtract pairs for LU */ - s = f*r*r + r*(f-1)*f + (f-1)*f*(2*f-1)/6 ; - nms_lu += s ; - - /* number of multiply-subtract pairs for LDL' */ - nms_ldl += (s + lnzme)/2 ; - } - -#ifndef NDEBUG - AMD_DEBUG2 (("finalize done nel "ID" n "ID"\n ::::\n", nel, n)) ; - for (pme = Pe [me] ; pme <= Pe [me] + Len [me] - 1 ; pme++) - { - AMD_DEBUG3 ((" "ID"", Iw [pme])) ; - } - AMD_DEBUG3 (("\n")) ; -#endif - - } - -/* ========================================================================= */ -/* DONE SELECTING PIVOTS */ -/* ========================================================================= */ - - if (Info != (double *) NULL) - { - - /* count the work to factorize the ndense-by-ndense submatrix */ - f = ndense ; - dmax = MAX (dmax, (double) ndense) ; - - /* number of nonzeros in L (excluding the diagonal) */ - lnzme = (f-1)*f/2 ; - lnz += lnzme ; - - /* number of divide operations for LDL' and for LU */ - ndiv += lnzme ; - - /* number of multiply-subtract pairs for LU */ - s = (f-1)*f*(2*f-1)/6 ; - nms_lu += s ; - - /* number of multiply-subtract pairs for LDL' */ - nms_ldl += (s + lnzme)/2 ; - - /* number of nz's in L (excl. diagonal) */ - Info [AMD_LNZ] = lnz ; - - /* number of divide ops for LU and LDL' */ - Info [AMD_NDIV] = ndiv ; - - /* number of multiply-subtract pairs for LDL' */ - Info [AMD_NMULTSUBS_LDL] = nms_ldl ; - - /* number of multiply-subtract pairs for LU */ - Info [AMD_NMULTSUBS_LU] = nms_lu ; - - /* number of "dense" rows/columns */ - Info [AMD_NDENSE] = ndense ; - - /* largest front is dmax-by-dmax */ - Info [AMD_DMAX] = dmax ; - - /* number of garbage collections in AMD */ - Info [AMD_NCMPA] = ncmpa ; - - /* successful ordering */ - Info [AMD_STATUS] = AMD_OK ; - } - -/* ========================================================================= */ -/* POST-ORDERING */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- - * Variables at this point: - * - * Pe: holds the elimination tree. The parent of j is FLIP (Pe [j]), - * or EMPTY if j is a root. The tree holds both elements and - * non-principal (unordered) variables absorbed into them. - * Dense variables are non-principal and unordered. - * - * Elen: holds the size of each element, including the diagonal part. - * FLIP (Elen [e]) > 0 if e is an element. For unordered - * variables i, Elen [i] is EMPTY. - * - * Nv: Nv [e] > 0 is the number of pivots represented by the element e. - * For unordered variables i, Nv [i] is zero. - * - * Contents no longer needed: - * W, Iw, Len, Degree, Head, Next, Last. - * - * The matrix itself has been destroyed. - * - * n: the size of the matrix. - * No other scalars needed (pfree, iwlen, etc.) - * ------------------------------------------------------------------------- */ - - /* restore Pe */ - for (i = 0 ; i < n ; i++) - { - Pe [i] = FLIP (Pe [i]) ; - } - - /* restore Elen, for output information, and for postordering */ - for (i = 0 ; i < n ; i++) - { - Elen [i] = FLIP (Elen [i]) ; - } - -/* Now the parent of j is Pe [j], or EMPTY if j is a root. Elen [e] > 0 - * is the size of element e. Elen [i] is EMPTY for unordered variable i. */ - -#ifndef NDEBUG - AMD_DEBUG2 (("\nTree:\n")) ; - for (i = 0 ; i < n ; i++) - { - AMD_DEBUG2 ((" "ID" parent: "ID" ", i, Pe [i])) ; - ASSERT (Pe [i] >= EMPTY && Pe [i] < n) ; - if (Nv [i] > 0) - { - /* this is an element */ - e = i ; - AMD_DEBUG2 ((" element, size is "ID"\n", Elen [i])) ; - ASSERT (Elen [e] > 0) ; - } - AMD_DEBUG2 (("\n")) ; - } - AMD_DEBUG2 (("\nelements:\n")) ; - for (e = 0 ; e < n ; e++) - { - if (Nv [e] > 0) - { - AMD_DEBUG3 (("Element e= "ID" size "ID" nv "ID" \n", e, - Elen [e], Nv [e])) ; - } - } - AMD_DEBUG2 (("\nvariables:\n")) ; - for (i = 0 ; i < n ; i++) - { - Int cnt ; - if (Nv [i] == 0) - { - AMD_DEBUG3 (("i unordered: "ID"\n", i)) ; - j = Pe [i] ; - cnt = 0 ; - AMD_DEBUG3 ((" j: "ID"\n", j)) ; - if (j == EMPTY) - { - AMD_DEBUG3 ((" i is a dense variable\n")) ; - } - else - { - ASSERT (j >= 0 && j < n) ; - while (Nv [j] == 0) - { - AMD_DEBUG3 ((" j : "ID"\n", j)) ; - j = Pe [j] ; - AMD_DEBUG3 ((" j:: "ID"\n", j)) ; - cnt++ ; - if (cnt > n) break ; - } - e = j ; - AMD_DEBUG3 ((" got to e: "ID"\n", e)) ; - } - } - } -#endif - -/* ========================================================================= */ -/* compress the paths of the variables */ -/* ========================================================================= */ - - for (i = 0 ; i < n ; i++) - { - if (Nv [i] == 0) - { - - /* ------------------------------------------------------------- - * i is an un-ordered row. Traverse the tree from i until - * reaching an element, e. The element, e, was the principal - * supervariable of i and all nodes in the path from i to when e - * was selected as pivot. - * ------------------------------------------------------------- */ - - AMD_DEBUG1 (("Path compression, i unordered: "ID"\n", i)) ; - j = Pe [i] ; - ASSERT (j >= EMPTY && j < n) ; - AMD_DEBUG3 ((" j: "ID"\n", j)) ; - if (j == EMPTY) - { - /* Skip a dense variable. It has no parent. */ - AMD_DEBUG3 ((" i is a dense variable\n")) ; - continue ; - } - - /* while (j is a variable) */ - while (Nv [j] == 0) - { - AMD_DEBUG3 ((" j : "ID"\n", j)) ; - j = Pe [j] ; - AMD_DEBUG3 ((" j:: "ID"\n", j)) ; - ASSERT (j >= 0 && j < n) ; - } - /* got to an element e */ - e = j ; - AMD_DEBUG3 (("got to e: "ID"\n", e)) ; - - /* ------------------------------------------------------------- - * traverse the path again from i to e, and compress the path - * (all nodes point to e). Path compression allows this code to - * compute in O(n) time. - * ------------------------------------------------------------- */ - - j = i ; - /* while (j is a variable) */ - while (Nv [j] == 0) - { - jnext = Pe [j] ; - AMD_DEBUG3 (("j "ID" jnext "ID"\n", j, jnext)) ; - Pe [j] = e ; - j = jnext ; - ASSERT (j >= 0 && j < n) ; - } - } - } - -/* ========================================================================= */ -/* postorder the assembly tree */ -/* ========================================================================= */ - - AMD_postorder (n, Pe, Nv, Elen, - W, /* output order */ - Head, Next, Last) ; /* workspace */ - -/* ========================================================================= */ -/* compute output permutation and inverse permutation */ -/* ========================================================================= */ - - /* W [e] = k means that element e is the kth element in the new - * order. e is in the range 0 to n-1, and k is in the range 0 to - * the number of elements. Use Head for inverse order. */ - - for (k = 0 ; k < n ; k++) - { - Head [k] = EMPTY ; - Next [k] = EMPTY ; - } - for (e = 0 ; e < n ; e++) - { - k = W [e] ; - ASSERT ((k == EMPTY) == (Nv [e] == 0)) ; - if (k != EMPTY) - { - ASSERT (k >= 0 && k < n) ; - Head [k] = e ; - } - } - - /* construct output inverse permutation in Next, - * and permutation in Last */ - nel = 0 ; - for (k = 0 ; k < n ; k++) - { - e = Head [k] ; - if (e == EMPTY) break ; - ASSERT (e >= 0 && e < n && Nv [e] > 0) ; - Next [e] = nel ; - nel += Nv [e] ; - } - ASSERT (nel == n - ndense) ; - - /* order non-principal variables (dense, & those merged into supervar's) */ - for (i = 0 ; i < n ; i++) - { - if (Nv [i] == 0) - { - e = Pe [i] ; - ASSERT (e >= EMPTY && e < n) ; - if (e != EMPTY) - { - /* This is an unordered variable that was merged - * into element e via supernode detection or mass - * elimination of i when e became the pivot element. - * Place i in order just before e. */ - ASSERT (Next [i] == EMPTY && Nv [e] > 0) ; - Next [i] = Next [e] ; - Next [e]++ ; - } - else - { - /* This is a dense unordered variable, with no parent. - * Place it last in the output order. */ - Next [i] = nel++ ; - } - } - } - ASSERT (nel == n) ; - - AMD_DEBUG2 (("\n\nPerm:\n")) ; - for (i = 0 ; i < n ; i++) - { - k = Next [i] ; - ASSERT (k >= 0 && k < n) ; - Last [k] = i ; - AMD_DEBUG2 ((" perm ["ID"] = "ID"\n", k, i)) ; - } -} diff --git a/src-x64/amd_2.o b/src-x64/amd_2.o deleted file mode 100644 index 0dd88a7..0000000 Binary files a/src-x64/amd_2.o and /dev/null differ diff --git a/src-x64/amd_aat.c b/src-x64/amd_aat.c deleted file mode 100644 index e5e1752..0000000 --- a/src-x64/amd_aat.c +++ /dev/null @@ -1,184 +0,0 @@ -/* ========================================================================= */ -/* === AMD_aat ============================================================= */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* AMD_aat: compute the symmetry of the pattern of A, and count the number of - * nonzeros each column of A+A' (excluding the diagonal). Assumes the input - * matrix has no errors, with sorted columns and no duplicates - * (AMD_valid (n, n, Ap, Ai) must be AMD_OK, but this condition is not - * checked). - */ - -#include "amd_internal.h" - -GLOBAL size_t AMD_aat /* returns nz in A+A' */ -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int Len [ ], /* Len [j]: length of column j of A+A', excl diagonal*/ - Int Tp [ ], /* workspace of size n */ - double Info [ ] -) -{ - Int p1, p2, p, i, j, pj, pj2, k, nzdiag, nzboth, nz ; - double sym ; - size_t nzaat ; - -#ifndef NDEBUG - AMD_debug_init ("AMD AAT") ; - for (k = 0 ; k < n ; k++) Tp [k] = EMPTY ; - ASSERT (AMD_valid (n, n, Ap, Ai) == AMD_OK) ; -#endif - - if (Info != (double *) NULL) - { - /* clear the Info array, if it exists */ - for (i = 0 ; i < AMD_INFO ; i++) - { - Info [i] = EMPTY ; - } - Info [AMD_STATUS] = AMD_OK ; - } - - for (k = 0 ; k < n ; k++) - { - Len [k] = 0 ; - } - - nzdiag = 0 ; - nzboth = 0 ; - nz = Ap [n] ; - - for (k = 0 ; k < n ; k++) - { - p1 = Ap [k] ; - p2 = Ap [k+1] ; - AMD_DEBUG2 (("\nAAT Column: "ID" p1: "ID" p2: "ID"\n", k, p1, p2)) ; - - /* construct A+A' */ - for (p = p1 ; p < p2 ; ) - { - /* scan the upper triangular part of A */ - j = Ai [p] ; - if (j < k) - { - /* entry A (j,k) is in the strictly upper triangular part, - * add both A (j,k) and A (k,j) to the matrix A+A' */ - Len [j]++ ; - Len [k]++ ; - AMD_DEBUG3 ((" upper ("ID","ID") ("ID","ID")\n", j,k, k,j)); - p++ ; - } - else if (j == k) - { - /* skip the diagonal */ - p++ ; - nzdiag++ ; - break ; - } - else /* j > k */ - { - /* first entry below the diagonal */ - break ; - } - /* scan lower triangular part of A, in column j until reaching - * row k. Start where last scan left off. */ - ASSERT (Tp [j] != EMPTY) ; - ASSERT (Ap [j] <= Tp [j] && Tp [j] <= Ap [j+1]) ; - pj2 = Ap [j+1] ; - for (pj = Tp [j] ; pj < pj2 ; ) - { - i = Ai [pj] ; - if (i < k) - { - /* A (i,j) is only in the lower part, not in upper. - * add both A (i,j) and A (j,i) to the matrix A+A' */ - Len [i]++ ; - Len [j]++ ; - AMD_DEBUG3 ((" lower ("ID","ID") ("ID","ID")\n", - i,j, j,i)) ; - pj++ ; - } - else if (i == k) - { - /* entry A (k,j) in lower part and A (j,k) in upper */ - pj++ ; - nzboth++ ; - break ; - } - else /* i > k */ - { - /* consider this entry later, when k advances to i */ - break ; - } - } - Tp [j] = pj ; - } - /* Tp [k] points to the entry just below the diagonal in column k */ - Tp [k] = p ; - } - - /* clean up, for remaining mismatched entries */ - for (j = 0 ; j < n ; j++) - { - for (pj = Tp [j] ; pj < Ap [j+1] ; pj++) - { - i = Ai [pj] ; - /* A (i,j) is only in the lower part, not in upper. - * add both A (i,j) and A (j,i) to the matrix A+A' */ - Len [i]++ ; - Len [j]++ ; - AMD_DEBUG3 ((" lower cleanup ("ID","ID") ("ID","ID")\n", - i,j, j,i)) ; - } - } - - /* --------------------------------------------------------------------- */ - /* compute the symmetry of the nonzero pattern of A */ - /* --------------------------------------------------------------------- */ - - /* Given a matrix A, the symmetry of A is: - * B = tril (spones (A), -1) + triu (spones (A), 1) ; - * sym = nnz (B & B') / nnz (B) ; - * or 1 if nnz (B) is zero. - */ - - if (nz == nzdiag) - { - sym = 1 ; - } - else - { - sym = (2 * (double) nzboth) / ((double) (nz - nzdiag)) ; - } - - nzaat = 0 ; - for (k = 0 ; k < n ; k++) - { - nzaat += Len [k] ; - } - - AMD_DEBUG1 (("AMD nz in A+A', excluding diagonal (nzaat) = %g\n", - (double) nzaat)) ; - AMD_DEBUG1 ((" nzboth: "ID" nz: "ID" nzdiag: "ID" symmetry: %g\n", - nzboth, nz, nzdiag, sym)) ; - - if (Info != (double *) NULL) - { - Info [AMD_STATUS] = AMD_OK ; - Info [AMD_N] = n ; - Info [AMD_NZ] = nz ; - Info [AMD_SYMMETRY] = sym ; /* symmetry of pattern of A */ - Info [AMD_NZDIAG] = nzdiag ; /* nonzeros on diagonal of A */ - Info [AMD_NZ_A_PLUS_AT] = nzaat ; /* nonzeros in A+A' */ - } - - return (nzaat) ; -} diff --git a/src-x64/amd_aat.o b/src-x64/amd_aat.o deleted file mode 100644 index ac243f6..0000000 Binary files a/src-x64/amd_aat.o and /dev/null differ diff --git a/src-x64/amd_control.c b/src-x64/amd_control.c deleted file mode 100644 index 0b64f77..0000000 --- a/src-x64/amd_control.c +++ /dev/null @@ -1,63 +0,0 @@ -/* ========================================================================= */ -/* === AMD_control ========================================================= */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* User-callable. Prints the control parameters for AMD. See amd.h - * for details. If the Control array is not present, the defaults are - * printed instead. - */ - -#include "amd_internal.h" - -GLOBAL void AMD_control -( - double Control [ ] -) -{ - double alpha ; - Int aggressive ; - - if (Control != (double *) NULL) - { - alpha = Control [AMD_DENSE] ; - aggressive = Control [AMD_AGGRESSIVE] != 0 ; - } - else - { - alpha = AMD_DEFAULT_DENSE ; - aggressive = AMD_DEFAULT_AGGRESSIVE ; - } - - PRINTF (("\nAMD version %d.%d.%d, %s: approximate minimum degree ordering\n" - " dense row parameter: %g\n", AMD_MAIN_VERSION, AMD_SUB_VERSION, - AMD_SUBSUB_VERSION, AMD_DATE, alpha)) ; - - if (alpha < 0) - { - PRINTF ((" no rows treated as dense\n")) ; - } - else - { - PRINTF (( - " (rows with more than max (%g * sqrt (n), 16) entries are\n" - " considered \"dense\", and placed last in output permutation)\n", - alpha)) ; - } - - if (aggressive) - { - PRINTF ((" aggressive absorption: yes\n")) ; - } - else - { - PRINTF ((" aggressive absorption: no\n")) ; - } - - PRINTF ((" size of AMD integer: %d\n\n", sizeof (Int))) ; -} diff --git a/src-x64/amd_control.o b/src-x64/amd_control.o deleted file mode 100644 index 75af24c..0000000 Binary files a/src-x64/amd_control.o and /dev/null differ diff --git a/src-x64/amd_defaults.c b/src-x64/amd_defaults.c deleted file mode 100644 index 9d20023..0000000 --- a/src-x64/amd_defaults.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ========================================================================= */ -/* === AMD_defaults ======================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* User-callable. Sets default control parameters for AMD. See amd.h - * for details. - */ - -#include "amd_internal.h" - -/* ========================================================================= */ -/* === AMD defaults ======================================================== */ -/* ========================================================================= */ - -GLOBAL void AMD_defaults -( - double Control [ ] -) -{ - Int i ; - - if (Control != (double *) NULL) - { - for (i = 0 ; i < AMD_CONTROL ; i++) - { - Control [i] = 0 ; - } - Control [AMD_DENSE] = AMD_DEFAULT_DENSE ; - Control [AMD_AGGRESSIVE] = AMD_DEFAULT_AGGRESSIVE ; - } -} diff --git a/src-x64/amd_defaults.o b/src-x64/amd_defaults.o deleted file mode 100644 index 83dd167..0000000 Binary files a/src-x64/amd_defaults.o and /dev/null differ diff --git a/src-x64/amd_dump.c b/src-x64/amd_dump.c deleted file mode 100644 index 01e1fb5..0000000 --- a/src-x64/amd_dump.c +++ /dev/null @@ -1,179 +0,0 @@ -/* ========================================================================= */ -/* === AMD_dump ============================================================ */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Debugging routines for AMD. Not used if NDEBUG is not defined at compile- - * time (the default). See comments in amd_internal.h on how to enable - * debugging. Not user-callable. - */ - -#include "amd_internal.h" - -#ifndef NDEBUG - -/* This global variable is present only when debugging */ -GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */ - -/* ========================================================================= */ -/* === AMD_debug_init ====================================================== */ -/* ========================================================================= */ - -/* Sets the debug print level, by reading the file debug.amd (if it exists) */ - -GLOBAL void AMD_debug_init ( char *s ) -{ - FILE *f ; - f = fopen ("debug.amd", "r") ; - if (f == (FILE *) NULL) - { - AMD_debug = -999 ; - } - else - { - fscanf (f, ID, &AMD_debug) ; - fclose (f) ; - } - if (AMD_debug >= 0) - { - printf ("%s: AMD_debug_init, D= "ID"\n", s, AMD_debug) ; - } -} - -/* ========================================================================= */ -/* === AMD_dump ============================================================ */ -/* ========================================================================= */ - -/* Dump AMD's data structure, except for the hash buckets. This routine - * cannot be called when the hash buckets are non-empty. - */ - -GLOBAL void AMD_dump ( - Int n, /* A is n-by-n */ - Int Pe [ ], /* pe [0..n-1]: index in iw of start of row i */ - Int Iw [ ], /* workspace of size iwlen, iwlen [0..pfree-1] - * holds the matrix on input */ - Int Len [ ], /* len [0..n-1]: length for row i */ - Int iwlen, /* length of iw */ - Int pfree, /* iw [pfree ... iwlen-1] is empty on input */ - Int Nv [ ], /* nv [0..n-1] */ - Int Next [ ], /* next [0..n-1] */ - Int Last [ ], /* last [0..n-1] */ - Int Head [ ], /* head [0..n-1] */ - Int Elen [ ], /* size n */ - Int Degree [ ], /* size n */ - Int W [ ], /* size n */ - Int nel -) -{ - Int i, pe, elen, nv, len, e, p, k, j, deg, w, cnt, ilast ; - - if (AMD_debug < 0) return ; - ASSERT (pfree <= iwlen) ; - AMD_DEBUG3 (("\nAMD dump, pfree: "ID"\n", pfree)) ; - for (i = 0 ; i < n ; i++) - { - pe = Pe [i] ; - elen = Elen [i] ; - nv = Nv [i] ; - len = Len [i] ; - w = W [i] ; - - if (elen >= EMPTY) - { - if (nv == 0) - { - AMD_DEBUG3 (("\nI "ID": nonprincipal: ", i)) ; - ASSERT (elen == EMPTY) ; - if (pe == EMPTY) - { - AMD_DEBUG3 ((" dense node\n")) ; - ASSERT (w == 1) ; - } - else - { - ASSERT (pe < EMPTY) ; - AMD_DEBUG3 ((" i "ID" -> parent "ID"\n", i, FLIP (Pe[i]))); - } - } - else - { - AMD_DEBUG3 (("\nI "ID": active principal supervariable:\n",i)); - AMD_DEBUG3 ((" nv(i): "ID" Flag: %d\n", nv, (nv < 0))) ; - ASSERT (elen >= 0) ; - ASSERT (nv > 0 && pe >= 0) ; - p = pe ; - AMD_DEBUG3 ((" e/s: ")) ; - if (elen == 0) AMD_DEBUG3 ((" : ")) ; - ASSERT (pe + len <= pfree) ; - for (k = 0 ; k < len ; k++) - { - j = Iw [p] ; - AMD_DEBUG3 ((" "ID"", j)) ; - ASSERT (j >= 0 && j < n) ; - if (k == elen-1) AMD_DEBUG3 ((" : ")) ; - p++ ; - } - AMD_DEBUG3 (("\n")) ; - } - } - else - { - e = i ; - if (w == 0) - { - AMD_DEBUG3 (("\nE "ID": absorbed element: w "ID"\n", e, w)) ; - ASSERT (nv > 0 && pe < 0) ; - AMD_DEBUG3 ((" e "ID" -> parent "ID"\n", e, FLIP (Pe [e]))) ; - } - else - { - AMD_DEBUG3 (("\nE "ID": unabsorbed element: w "ID"\n", e, w)) ; - ASSERT (nv > 0 && pe >= 0) ; - p = pe ; - AMD_DEBUG3 ((" : ")) ; - ASSERT (pe + len <= pfree) ; - for (k = 0 ; k < len ; k++) - { - j = Iw [p] ; - AMD_DEBUG3 ((" "ID"", j)) ; - ASSERT (j >= 0 && j < n) ; - p++ ; - } - AMD_DEBUG3 (("\n")) ; - } - } - } - - /* this routine cannot be called when the hash buckets are non-empty */ - AMD_DEBUG3 (("\nDegree lists:\n")) ; - if (nel >= 0) - { - cnt = 0 ; - for (deg = 0 ; deg < n ; deg++) - { - if (Head [deg] == EMPTY) continue ; - ilast = EMPTY ; - AMD_DEBUG3 ((ID": \n", deg)) ; - for (i = Head [deg] ; i != EMPTY ; i = Next [i]) - { - AMD_DEBUG3 ((" "ID" : next "ID" last "ID" deg "ID"\n", - i, Next [i], Last [i], Degree [i])) ; - ASSERT (i >= 0 && i < n && ilast == Last [i] && - deg == Degree [i]) ; - cnt += Nv [i] ; - ilast = i ; - } - AMD_DEBUG3 (("\n")) ; - } - ASSERT (cnt == n - nel) ; - } - -} - -#endif diff --git a/src-x64/amd_dump.o b/src-x64/amd_dump.o deleted file mode 100644 index aae27c1..0000000 Binary files a/src-x64/amd_dump.o and /dev/null differ diff --git a/src-x64/amd_global.c b/src-x64/amd_global.c deleted file mode 100644 index 0f3def0..0000000 --- a/src-x64/amd_global.c +++ /dev/null @@ -1,85 +0,0 @@ -/* ========================================================================= */ -/* === amd_global ========================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -#include - -#ifdef MATLAB_MEX_FILE -#include "mex.h" -#include "matrix.h" -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* ========================================================================= */ -/* === Default AMD memory manager ========================================== */ -/* ========================================================================= */ - -/* The user can redefine these global pointers at run-time to change the memory - * manager used by AMD. AMD only uses malloc and free; realloc and calloc are - * include for completeness, in case another package wants to use the same - * memory manager as AMD. - * - * If compiling as a MATLAB mexFunction, the default memory manager is mxMalloc. - * You can also compile AMD as a standard ANSI-C library and link a mexFunction - * against it, and then redefine these pointers at run-time, in your - * mexFunction. - * - * If -DNMALLOC is defined at compile-time, no memory manager is specified at - * compile-time. You must then define these functions at run-time, before - * calling AMD, for AMD to work properly. - */ - -#ifndef NMALLOC -#ifdef MATLAB_MEX_FILE -/* MATLAB mexFunction: */ -void *(*amd_malloc) (size_t) = mxMalloc ; -void (*amd_free) (void *) = mxFree ; -void *(*amd_realloc) (void *, size_t) = mxRealloc ; -void *(*amd_calloc) (size_t, size_t) = mxCalloc ; -#else -/* standard ANSI-C: */ -void *(*amd_malloc) (size_t) = malloc ; -void (*amd_free) (void *) = free ; -void *(*amd_realloc) (void *, size_t) = realloc ; -void *(*amd_calloc) (size_t, size_t) = calloc ; -#endif -#else -/* no memory manager defined at compile-time; you MUST define one at run-time */ -void *(*amd_malloc) (size_t) = NULL ; -void (*amd_free) (void *) = NULL ; -void *(*amd_realloc) (void *, size_t) = NULL ; -void *(*amd_calloc) (size_t, size_t) = NULL ; -#endif - -/* ========================================================================= */ -/* === Default AMD printf routine ========================================== */ -/* ========================================================================= */ - -/* The user can redefine this global pointer at run-time to change the printf - * routine used by AMD. If NULL, no printing occurs. - * - * If -DNPRINT is defined at compile-time, stdio.h is not included. Printing - * can then be enabled at run-time by setting amd_printf to a non-NULL function. - */ - -/*#ifndef NPRINT -#ifdef MATLAB_MEX_FILE -int (*amd_printf) (const char *, ...) = mexPrintf ; -#else -#include -int (*amd_printf) (const char *, ...) = printf ; -#endif -#else -int (*amd_printf) (const char *, ...) = NULL ; -#endif */ -#include -int (*amd_printf) (const char *, ...) = NULL ; diff --git a/src-x64/amd_global.o b/src-x64/amd_global.o deleted file mode 100644 index 8e566a3..0000000 Binary files a/src-x64/amd_global.o and /dev/null differ diff --git a/src-x64/amd_info.c b/src-x64/amd_info.c deleted file mode 100644 index fec12a6..0000000 --- a/src-x64/amd_info.c +++ /dev/null @@ -1,119 +0,0 @@ -/* ========================================================================= */ -/* === AMD_info ============================================================ */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* User-callable. Prints the output statistics for AMD. See amd.h - * for details. If the Info array is not present, nothing is printed. - */ - -#include "amd_internal.h" - -#define PRI(format,x) { if (x >= 0) { PRINTF ((format, x)) ; }} - -GLOBAL void AMD_info -( - double Info [ ] -) -{ - double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ; - - PRINTF (("\nAMD version %d.%d.%d, %s, results:\n", - AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE)) ; - - if (!Info) - { - return ; - } - - n = Info [AMD_N] ; - ndiv = Info [AMD_NDIV] ; - nmultsubs_ldl = Info [AMD_NMULTSUBS_LDL] ; - nmultsubs_lu = Info [AMD_NMULTSUBS_LU] ; - lnz = Info [AMD_LNZ] ; - lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ; - - /* AMD return status */ - PRINTF ((" status: ")) ; - if (Info [AMD_STATUS] == AMD_OK) - { - PRINTF (("OK\n")) ; - } - else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY) - { - PRINTF (("out of memory\n")) ; - } - else if (Info [AMD_STATUS] == AMD_INVALID) - { - PRINTF (("invalid matrix\n")) ; - } - else if (Info [AMD_STATUS] == AMD_OK_BUT_JUMBLED) - { - PRINTF (("OK, but jumbled\n")) ; - } - else - { - PRINTF (("unknown\n")) ; - } - - /* statistics about the input matrix */ - PRI (" n, dimension of A: %.20g\n", n); - PRI (" nz, number of nonzeros in A: %.20g\n", - Info [AMD_NZ]) ; - PRI (" symmetry of A: %.4f\n", - Info [AMD_SYMMETRY]) ; - PRI (" number of nonzeros on diagonal: %.20g\n", - Info [AMD_NZDIAG]) ; - PRI (" nonzeros in pattern of A+A' (excl. diagonal): %.20g\n", - Info [AMD_NZ_A_PLUS_AT]) ; - PRI (" # dense rows/columns of A+A': %.20g\n", - Info [AMD_NDENSE]) ; - - /* statistics about AMD's behavior */ - PRI (" memory used, in bytes: %.20g\n", - Info [AMD_MEMORY]) ; - PRI (" # of memory compactions: %.20g\n", - Info [AMD_NCMPA]) ; - - /* statistics about the ordering quality */ - PRINTF (("\n" - " The following approximate statistics are for a subsequent\n" - " factorization of A(P,P) + A(P,P)'. They are slight upper\n" - " bounds if there are no dense rows/columns in A+A', and become\n" - " looser if dense rows/columns exist.\n\n")) ; - - PRI (" nonzeros in L (excluding diagonal): %.20g\n", - lnz) ; - PRI (" nonzeros in L (including diagonal): %.20g\n", - lnzd) ; - PRI (" # divide operations for LDL' or LU: %.20g\n", - ndiv) ; - PRI (" # multiply-subtract operations for LDL': %.20g\n", - nmultsubs_ldl) ; - PRI (" # multiply-subtract operations for LU: %.20g\n", - nmultsubs_lu) ; - PRI (" max nz. in any column of L (incl. diagonal): %.20g\n", - Info [AMD_DMAX]) ; - - /* total flop counts for various factorizations */ - - if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0) - { - PRINTF (("\n" - " chol flop count for real A, sqrt counted as 1 flop: %.20g\n" - " LDL' flop count for real A: %.20g\n" - " LDL' flop count for complex A: %.20g\n" - " LU flop count for real A (with no pivoting): %.20g\n" - " LU flop count for complex A (with no pivoting): %.20g\n\n", - n + ndiv + 2*nmultsubs_ldl, - ndiv + 2*nmultsubs_ldl, - 9*ndiv + 8*nmultsubs_ldl, - ndiv + 2*nmultsubs_lu, - 9*ndiv + 8*nmultsubs_lu)) ; - } -} diff --git a/src-x64/amd_info.o b/src-x64/amd_info.o deleted file mode 100644 index d14f148..0000000 Binary files a/src-x64/amd_info.o and /dev/null differ diff --git a/src-x64/amd_internal.h b/src-x64/amd_internal.h deleted file mode 100644 index 01a410a..0000000 --- a/src-x64/amd_internal.h +++ /dev/null @@ -1,351 +0,0 @@ -/* ========================================================================= */ -/* === amd_internal.h ====================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* This file is for internal use in AMD itself, and does not normally need to - * be included in user code (it is included in UMFPACK, however). All others - * should use amd.h instead. - * - * The following compile-time definitions affect how AMD is compiled. - * - * -DNPRINT - * - * Disable all printing. stdio.h will not be included. Printing can - * be re-enabled at run-time by setting the global pointer amd_printf - * to printf (or mexPrintf for a MATLAB mexFunction). - * - * -DNMALLOC - * - * No memory manager is defined at compile-time. You MUST define the - * function pointers amd_malloc, amd_free, amd_realloc, and - * amd_calloc at run-time for AMD to work properly. - */ - -/* ========================================================================= */ -/* === NDEBUG ============================================================== */ -/* ========================================================================= */ - -/* - * Turning on debugging takes some work (see below). If you do not edit this - * file, then debugging is always turned off, regardless of whether or not - * -DNDEBUG is specified in your compiler options. - * - * If AMD is being compiled as a mexFunction, then MATLAB_MEX_FILE is defined, - * and mxAssert is used instead of assert. If debugging is not enabled, no - * MATLAB include files or functions are used. Thus, the AMD library libamd.a - * can be safely used in either a stand-alone C program or in another - * mexFunction, without any change. - */ - -/* - AMD will be exceedingly slow when running in debug mode. The next three - lines ensure that debugging is turned off. -*/ - -#include /* required */ -#include /* for distribution functions etc. */ - -#ifndef NDEBUG -#define NDEBUG -#endif - -/* - To enable debugging, uncomment the following line: -#undef NDEBUG -*/ - -/* ------------------------------------------------------------------------- */ -/* ANSI include files */ -/* ------------------------------------------------------------------------- */ - -/* from stdlib.h: size_t, malloc, free, realloc, and calloc */ -#include - -#if !defined(NPRINT) || !defined(NDEBUG) -/* from stdio.h: printf. Not included if NPRINT is defined at compile time. - * fopen and fscanf are used when debugging. */ -#include -#endif - -/* from limits.h: INT_MAX and LONG_MAX */ -#include - -/* from math.h: sqrt */ -#include - -/* ------------------------------------------------------------------------- */ -/* MATLAB include files (only if being used in or via MATLAB) */ -/* ------------------------------------------------------------------------- */ - -#ifdef MATLAB_MEX_FILE -#include "matrix.h" -#include "mex.h" -#endif - -/* ------------------------------------------------------------------------- */ -/* basic definitions */ -/* ------------------------------------------------------------------------- */ - -#ifdef FLIP -#undef FLIP -#endif - -#ifdef MAX -#undef MAX -#endif - -#ifdef MIN -#undef MIN -#endif - -#ifdef EMPTY -#undef EMPTY -#endif - -#ifdef GLOBAL -#undef GLOBAL -#endif - -#ifdef PRIVATE -#undef PRIVATE -#endif - -/* FLIP is a "negation about -1", and is used to mark an integer i that is - * normally non-negative. FLIP (EMPTY) is EMPTY. FLIP of a number > EMPTY - * is negative, and FLIP of a number < EMTPY is positive. FLIP (FLIP (i)) = i - * for all integers i. UNFLIP (i) is >= EMPTY. */ -#define EMPTY (-1) -#define FLIP(i) (-(i)-2) -#define UNFLIP(i) ((i < EMPTY) ? FLIP (i) : (i)) - -/* for integer MAX/MIN, or for doubles when we don't care how NaN's behave: */ -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) - -/* logical expression of p implies q: */ -#define IMPLIES(p,q) (!(p) || (q)) - -/* Note that the IBM RS 6000 xlc predefines TRUE and FALSE in . */ -/* The Compaq Alpha also predefines TRUE and FALSE. */ -#ifdef TRUE -#undef TRUE -#endif -#ifdef FALSE -#undef FALSE -#endif - -#define TRUE (1) -#define FALSE (0) -#define PRIVATE static -#define GLOBAL -#define EMPTY (-1) - -/* Note that Linux's gcc 2.96 defines NULL as ((void *) 0), but other */ -/* compilers (even gcc 2.95.2 on Solaris) define NULL as 0 or (0). We */ -/* need to use the ANSI standard value of 0. */ -#ifdef NULL -#undef NULL -#endif - -#define NULL 0 - -/* largest value of size_t */ -#ifndef SIZE_T_MAX -#ifdef SIZE_MAX -/* C99 only */ -#define SIZE_T_MAX SIZE_MAX -#else -#define SIZE_T_MAX ((size_t) (-1)) -#endif -#endif - -/* ------------------------------------------------------------------------- */ -/* integer type for AMD: int or SuiteSparse_long */ -/* ------------------------------------------------------------------------- */ - -#include "amd.h" - -#if defined (DLONG) || defined (ZLONG) - -#define Int SuiteSparse_long -#define ID SuiteSparse_long_id -#define Int_MAX SuiteSparse_long_max - -#define AMD_order amd_l_order -#define AMD_defaults amd_l_defaults -#define AMD_control amd_l_control -#define AMD_info amd_l_info -#define AMD_1 amd_l1 -#define AMD_2 amd_l2 -#define AMD_valid amd_l_valid -#define AMD_aat amd_l_aat -#define AMD_postorder amd_l_postorder -#define AMD_post_tree amd_l_post_tree -#define AMD_dump amd_l_dump -#define AMD_debug amd_l_debug -#define AMD_debug_init amd_l_debug_init -#define AMD_preprocess amd_l_preprocess - -#else - -#define Int int -#define ID "%d" -#define Int_MAX INT_MAX - -#define AMD_order amd_order -#define AMD_defaults amd_defaults -#define AMD_control amd_control -#define AMD_info amd_info -#define AMD_1 amd_1 -#define AMD_2 amd_2 -#define AMD_valid amd_valid -#define AMD_aat amd_aat -#define AMD_postorder amd_postorder -#define AMD_post_tree amd_post_tree -#define AMD_dump amd_dump -#define AMD_debug amd_debug -#define AMD_debug_init amd_debug_init -#define AMD_preprocess amd_preprocess - -#endif - -/* ========================================================================= */ -/* === PRINTF macro ======================================================== */ -/* ========================================================================= */ - -/* All output goes through the PRINTF macro. */ -#define PRINTF(params) { if (amd_printf != NULL) (void) amd_printf params ; } - -/* ------------------------------------------------------------------------- */ -/* AMD routine definitions (not user-callable) */ -/* ------------------------------------------------------------------------- */ - -GLOBAL size_t AMD_aat -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int Len [ ], - Int Tp [ ], - double Info [ ] -) ; - -GLOBAL void AMD_1 -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int P [ ], - Int Pinv [ ], - Int Len [ ], - Int slen, - Int S [ ], - double Control [ ], - double Info [ ] -) ; - -GLOBAL void AMD_postorder -( - Int nn, - Int Parent [ ], - Int Npiv [ ], - Int Fsize [ ], - Int Order [ ], - Int Child [ ], - Int Sibling [ ], - Int Stack [ ] -) ; - -GLOBAL Int AMD_post_tree -( - Int root, - Int k, - Int Child [ ], - const Int Sibling [ ], - Int Order [ ], - Int Stack [ ] -#ifndef NDEBUG - , Int nn -#endif -) ; - -GLOBAL void AMD_preprocess -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int Rp [ ], - Int Ri [ ], - Int W [ ], - Int Flag [ ] -) ; - -/* ------------------------------------------------------------------------- */ -/* debugging definitions */ -/* ------------------------------------------------------------------------- */ - -#ifndef NDEBUG - -/* from assert.h: assert macro */ -#include - -#ifndef EXTERN -#define EXTERN extern -#endif - -EXTERN Int AMD_debug ; - -GLOBAL void AMD_debug_init ( char *s ) ; - -GLOBAL void AMD_dump -( - Int n, - Int Pe [ ], - Int Iw [ ], - Int Len [ ], - Int iwlen, - Int pfree, - Int Nv [ ], - Int Next [ ], - Int Last [ ], - Int Head [ ], - Int Elen [ ], - Int Degree [ ], - Int W [ ], - Int nel -) ; - -#ifdef ASSERT -#undef ASSERT -#endif - -/* Use mxAssert if AMD is compiled into a mexFunction */ -#ifdef MATLAB_MEX_FILE -#define ASSERT(expression) (mxAssert ((expression), "")) -#else -#define ASSERT(expression) (assert (expression)) -#endif - -#define AMD_DEBUG0(params) { PRINTF (params) ; } -#define AMD_DEBUG1(params) { if (AMD_debug >= 1) PRINTF (params) ; } -#define AMD_DEBUG2(params) { if (AMD_debug >= 2) PRINTF (params) ; } -#define AMD_DEBUG3(params) { if (AMD_debug >= 3) PRINTF (params) ; } -#define AMD_DEBUG4(params) { if (AMD_debug >= 4) PRINTF (params) ; } - -#else - -/* no debugging */ -#define ASSERT(expression) -#define AMD_DEBUG0(params) -#define AMD_DEBUG1(params) -#define AMD_DEBUG2(params) -#define AMD_DEBUG3(params) -#define AMD_DEBUG4(params) - -#endif diff --git a/src-x64/amd_order.c b/src-x64/amd_order.c deleted file mode 100644 index f00aff6..0000000 --- a/src-x64/amd_order.c +++ /dev/null @@ -1,206 +0,0 @@ -/* ========================================================================= */ -/* === AMD_order =========================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* User-callable AMD minimum degree ordering routine. See amd.h for - * documentation. - */ - -#include "amd_internal.h" -#include /* required */ -#include /* for distribution functions etc. */ - -/* ========================================================================= */ -/* === AMD_order =========================================================== */ -/* ========================================================================= */ - -GLOBAL Int AMD_order -( - Int n, - const Int Ap [ ], - const Int Ai [ ], - Int P [ ], - double Control [ ], - double Info [ ] -) -{ - Int *Len, *S, nz, i, *Pinv, info, status, *Rp, *Ri, *Cp, *Ci, ok ; - size_t nzaat, slen ; - double mem = 0 ; - - - - -#ifndef NDEBUG - AMD_debug_init ("amd") ; -#endif - - /* clear the Info array, if it exists */ - info = Info != (double *) NULL ; - if (info) - { - for (i = 0 ; i < AMD_INFO ; i++) - { - Info [i] = EMPTY ; - } - Info [AMD_N] = n ; - Info [AMD_STATUS] = AMD_OK ; - } - - /* make sure inputs exist and n is >= 0 */ - if (Ai == (Int *) NULL || Ap == (Int *) NULL || P == (Int *) NULL || n < 0) - { - if (info) Info [AMD_STATUS] = AMD_INVALID ; - return (AMD_INVALID) ; /* arguments are invalid */ - } - - - if (n == 0) - { - return (AMD_OK) ; /* n is 0 so there's nothing to do */ - } - - nz = Ap [n] ; - if (info) - { - Info [AMD_NZ] = nz ; - } - if (nz < 0) - { - if (info) Info [AMD_STATUS] = AMD_INVALID ; - return (AMD_INVALID) ; - } - - /* check if n or nz will cause size_t overflow */ - if (((size_t) n) >= SIZE_T_MAX / sizeof (Int) - || ((size_t) nz) >= SIZE_T_MAX / sizeof (Int)) - { - if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ; - return (AMD_OUT_OF_MEMORY) ; /* problem too large */ - } - - - - - /* check the input matrix: AMD_OK, AMD_INVALID, or AMD_OK_BUT_JUMBLED */ - status = AMD_valid (n, n, Ap, Ai) ; - if (status == AMD_INVALID) - { - if (info) Info [AMD_STATUS] = AMD_INVALID ; - return (AMD_INVALID) ; /* matrix is invalid */ - } - - /* allocate two size-n integer workspaces */ - Len = amd_malloc (n * sizeof (Int)) ; - Pinv = amd_malloc (n * sizeof (Int)) ; - mem += n ; - mem += n ; - if (!Len || !Pinv) - { - /* :: out of memory :: */ - amd_free (Len) ; - amd_free (Pinv) ; - if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ; - return (AMD_OUT_OF_MEMORY) ; - } - - if (status == AMD_OK_BUT_JUMBLED) - { - /* sort the input matrix and remove duplicate entries */ - AMD_DEBUG1 (("Matrix is jumbled\n")) ; - Rp = amd_malloc ((n+1) * sizeof (Int)) ; - Ri = amd_malloc (MAX (nz,1) * sizeof (Int)) ; - mem += (n+1) ; - mem += MAX (nz,1) ; - if (!Rp || !Ri) - { - /* :: out of memory :: */ - amd_free (Rp) ; - amd_free (Ri) ; - amd_free (Len) ; - amd_free (Pinv) ; - if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ; - return (AMD_OUT_OF_MEMORY) ; - } - /* use Len and Pinv as workspace to create R = A' */ - AMD_preprocess (n, Ap, Ai, Rp, Ri, Len, Pinv) ; - Cp = Rp ; - Ci = Ri ; - } - else - { - /* order the input matrix as-is. No need to compute R = A' first */ - Rp = NULL ; - Ri = NULL ; - Cp = (Int *) Ap ; - Ci = (Int *) Ai ; - } - - /* --------------------------------------------------------------------- */ - /* determine the symmetry and count off-diagonal nonzeros in A+A' */ - /* --------------------------------------------------------------------- */ - - nzaat = AMD_aat (n, Cp, Ci, Len, P, Info) ; - AMD_DEBUG1 (("nzaat: %g\n", (double) nzaat)) ; - ASSERT ((MAX (nz-n, 0) <= nzaat) && (nzaat <= 2 * (size_t) nz)) ; - - /* --------------------------------------------------------------------- */ - /* allocate workspace for matrix, elbow room, and 6 size-n vectors */ - /* --------------------------------------------------------------------- */ - - S = NULL ; - slen = nzaat ; /* space for matrix */ - ok = ((slen + nzaat/5) >= slen) ; /* check for size_t overflow */ - slen += nzaat/5 ; /* add elbow room */ - for (i = 0 ; ok && i < 7 ; i++) - { - ok = ((slen + n) > slen) ; /* check for size_t overflow */ - slen += n ; /* size-n elbow room, 6 size-n work */ - } - mem += slen ; - ok = ok && (slen < SIZE_T_MAX / sizeof (Int)) ; /* check for overflow */ - ok = ok && (slen < Int_MAX) ; /* S[i] for Int i must be OK */ - if (ok) - { - S = amd_malloc (slen * sizeof (Int)) ; - } - AMD_DEBUG1 (("slen %g\n", (double) slen)) ; - if (!S) - { - /* :: out of memory :: (or problem too large) */ - amd_free (Rp) ; - amd_free (Ri) ; - amd_free (Len) ; - amd_free (Pinv) ; - if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ; - return (AMD_OUT_OF_MEMORY) ; - } - if (info) - { - /* memory usage, in bytes. */ - Info [AMD_MEMORY] = mem * sizeof (Int) ; - } - - /* --------------------------------------------------------------------- */ - /* order the matrix */ - /* --------------------------------------------------------------------- */ - AMD_1 (n, Cp, Ci, P, Pinv, Len, slen, S, Control, Info) ; - - /* --------------------------------------------------------------------- */ - /* free the workspace */ - /* --------------------------------------------------------------------- */ - - amd_free (Rp) ; - amd_free (Ri) ; - amd_free (Len) ; - amd_free (Pinv) ; - amd_free (S) ; - if (info) Info [AMD_STATUS] = status ; - return (status) ; /* successful ordering */ -} diff --git a/src-x64/amd_order.o b/src-x64/amd_order.o deleted file mode 100644 index e1daf3e..0000000 Binary files a/src-x64/amd_order.o and /dev/null differ diff --git a/src-x64/amd_order_wrapper.c b/src-x64/amd_order_wrapper.c deleted file mode 100644 index edd766f..0000000 --- a/src-x64/amd_order_wrapper.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "amd_internal.h" -#include /* required */ -#include /* for distribution functions etc. */ -GLOBAL void AMD_order_wrapper -( - Int *n, - const Int *Ap, - const Int *Ai, - Int *P, - double *Control, - double *Info -) { -amd_defaults (Control) ; -amd_order(*n,Ap,Ai,P,Control,Info); -return; -} diff --git a/src-x64/amd_order_wrapper.h b/src-x64/amd_order_wrapper.h deleted file mode 100644 index 8fc8d5e..0000000 --- a/src-x64/amd_order_wrapper.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _AMD_ORDER_WRAPPER_H_ -#define _AMD_ORDER_WRAPPER_H_ -#include -#define Int int - -void AMD_order_wrapper - ( - Int *n, - const Int *Ap, - const Int *Ai, - Int *P, - double *Control, - double *Info - ); - -#endif diff --git a/src-x64/amd_order_wrapper.o b/src-x64/amd_order_wrapper.o deleted file mode 100644 index ca49349..0000000 Binary files a/src-x64/amd_order_wrapper.o and /dev/null differ diff --git a/src-x64/amd_post_tree.c b/src-x64/amd_post_tree.c deleted file mode 100644 index 7ab1aa5..0000000 --- a/src-x64/amd_post_tree.c +++ /dev/null @@ -1,120 +0,0 @@ -/* ========================================================================= */ -/* === AMD_post_tree ======================================================= */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Post-ordering of a supernodal elimination tree. */ - -#include "amd_internal.h" - -GLOBAL Int AMD_post_tree -( - Int root, /* root of the tree */ - Int k, /* start numbering at k */ - Int Child [ ], /* input argument of size nn, undefined on - * output. Child [i] is the head of a link - * list of all nodes that are children of node - * i in the tree. */ - const Int Sibling [ ], /* input argument of size nn, not modified. - * If f is a node in the link list of the - * children of node i, then Sibling [f] is the - * next child of node i. - */ - Int Order [ ], /* output order, of size nn. Order [i] = k - * if node i is the kth node of the reordered - * tree. */ - Int Stack [ ] /* workspace of size nn */ -#ifndef NDEBUG - , Int nn /* nodes are in the range 0..nn-1. */ -#endif -) -{ - Int f, head, h, i ; - -#if 0 - /* --------------------------------------------------------------------- */ - /* recursive version (Stack [ ] is not used): */ - /* --------------------------------------------------------------------- */ - - /* this is simple, but can caouse stack overflow if nn is large */ - i = root ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - k = AMD_post_tree (f, k, Child, Sibling, Order, Stack, nn) ; - } - Order [i] = k++ ; - return (k) ; -#endif - - /* --------------------------------------------------------------------- */ - /* non-recursive version, using an explicit stack */ - /* --------------------------------------------------------------------- */ - - /* push root on the stack */ - head = 0 ; - Stack [0] = root ; - - while (head >= 0) - { - /* get head of stack */ - ASSERT (head < nn) ; - i = Stack [head] ; - AMD_DEBUG1 (("head of stack "ID" \n", i)) ; - ASSERT (i >= 0 && i < nn) ; - - if (Child [i] != EMPTY) - { - /* the children of i are not yet ordered */ - /* push each child onto the stack in reverse order */ - /* so that small ones at the head of the list get popped first */ - /* and the biggest one at the end of the list gets popped last */ - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - head++ ; - ASSERT (head < nn) ; - ASSERT (f >= 0 && f < nn) ; - } - h = head ; - ASSERT (head < nn) ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - ASSERT (h > 0) ; - Stack [h--] = f ; - AMD_DEBUG1 (("push "ID" on stack\n", f)) ; - ASSERT (f >= 0 && f < nn) ; - } - ASSERT (Stack [h] == i) ; - - /* delete child list so that i gets ordered next time we see it */ - Child [i] = EMPTY ; - } - else - { - /* the children of i (if there were any) are already ordered */ - /* remove i from the stack and order it. Front i is kth front */ - head-- ; - AMD_DEBUG1 (("pop "ID" order "ID"\n", i, k)) ; - Order [i] = k++ ; - ASSERT (k <= nn) ; - } - -#ifndef NDEBUG - AMD_DEBUG1 (("\nStack:")) ; - for (h = head ; h >= 0 ; h--) - { - Int j = Stack [h] ; - AMD_DEBUG1 ((" "ID, j)) ; - ASSERT (j >= 0 && j < nn) ; - } - AMD_DEBUG1 (("\n\n")) ; - ASSERT (head < nn) ; -#endif - - } - return (k) ; -} diff --git a/src-x64/amd_post_tree.o b/src-x64/amd_post_tree.o deleted file mode 100644 index 2537790..0000000 Binary files a/src-x64/amd_post_tree.o and /dev/null differ diff --git a/src-x64/amd_postorder.c b/src-x64/amd_postorder.c deleted file mode 100644 index f262bf7..0000000 --- a/src-x64/amd_postorder.c +++ /dev/null @@ -1,206 +0,0 @@ -/* ========================================================================= */ -/* === AMD_postorder ======================================================= */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Perform a postordering (via depth-first search) of an assembly tree. */ - -#include "amd_internal.h" - -GLOBAL void AMD_postorder -( - /* inputs, not modified on output: */ - Int nn, /* nodes are in the range 0..nn-1 */ - Int Parent [ ], /* Parent [j] is the parent of j, or EMPTY if root */ - Int Nv [ ], /* Nv [j] > 0 number of pivots represented by node j, - * or zero if j is not a node. */ - Int Fsize [ ], /* Fsize [j]: size of node j */ - - /* output, not defined on input: */ - Int Order [ ], /* output post-order */ - - /* workspaces of size nn: */ - Int Child [ ], - Int Sibling [ ], - Int Stack [ ] -) -{ - Int i, j, k, parent, frsize, f, fprev, maxfrsize, bigfprev, bigf, fnext ; - - for (j = 0 ; j < nn ; j++) - { - Child [j] = EMPTY ; - Sibling [j] = EMPTY ; - } - - /* --------------------------------------------------------------------- */ - /* place the children in link lists - bigger elements tend to be last */ - /* --------------------------------------------------------------------- */ - - for (j = nn-1 ; j >= 0 ; j--) - { - if (Nv [j] > 0) - { - /* this is an element */ - parent = Parent [j] ; - if (parent != EMPTY) - { - /* place the element in link list of the children its parent */ - /* bigger elements will tend to be at the end of the list */ - Sibling [j] = Child [parent] ; - Child [parent] = j ; - } - } - } - -#ifndef NDEBUG - { - Int nels, ff, nchild ; - AMD_DEBUG1 (("\n\n================================ AMD_postorder:\n")); - nels = 0 ; - for (j = 0 ; j < nn ; j++) - { - if (Nv [j] > 0) - { - AMD_DEBUG1 (( ""ID" : nels "ID" npiv "ID" size "ID - " parent "ID" maxfr "ID"\n", j, nels, - Nv [j], Fsize [j], Parent [j], Fsize [j])) ; - /* this is an element */ - /* dump the link list of children */ - nchild = 0 ; - AMD_DEBUG1 ((" Children: ")) ; - for (ff = Child [j] ; ff != EMPTY ; ff = Sibling [ff]) - { - AMD_DEBUG1 ((ID" ", ff)) ; - ASSERT (Parent [ff] == j) ; - nchild++ ; - ASSERT (nchild < nn) ; - } - AMD_DEBUG1 (("\n")) ; - parent = Parent [j] ; - if (parent != EMPTY) - { - ASSERT (Nv [parent] > 0) ; - } - nels++ ; - } - } - } - AMD_DEBUG1 (("\n\nGo through the children of each node, and put\n" - "the biggest child last in each list:\n")) ; -#endif - - /* --------------------------------------------------------------------- */ - /* place the largest child last in the list of children for each node */ - /* --------------------------------------------------------------------- */ - - for (i = 0 ; i < nn ; i++) - { - if (Nv [i] > 0 && Child [i] != EMPTY) - { - -#ifndef NDEBUG - Int nchild ; - AMD_DEBUG1 (("Before partial sort, element "ID"\n", i)) ; - nchild = 0 ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - ASSERT (f >= 0 && f < nn) ; - AMD_DEBUG1 ((" f: "ID" size: "ID"\n", f, Fsize [f])) ; - nchild++ ; - ASSERT (nchild <= nn) ; - } -#endif - - /* find the biggest element in the child list */ - fprev = EMPTY ; - maxfrsize = EMPTY ; - bigfprev = EMPTY ; - bigf = EMPTY ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - ASSERT (f >= 0 && f < nn) ; - frsize = Fsize [f] ; - if (frsize >= maxfrsize) - { - /* this is the biggest seen so far */ - maxfrsize = frsize ; - bigfprev = fprev ; - bigf = f ; - } - fprev = f ; - } - ASSERT (bigf != EMPTY) ; - - fnext = Sibling [bigf] ; - - AMD_DEBUG1 (("bigf "ID" maxfrsize "ID" bigfprev "ID" fnext "ID - " fprev " ID"\n", bigf, maxfrsize, bigfprev, fnext, fprev)) ; - - if (fnext != EMPTY) - { - /* if fnext is EMPTY then bigf is already at the end of list */ - - if (bigfprev == EMPTY) - { - /* delete bigf from the element of the list */ - Child [i] = fnext ; - } - else - { - /* delete bigf from the middle of the list */ - Sibling [bigfprev] = fnext ; - } - - /* put bigf at the end of the list */ - Sibling [bigf] = EMPTY ; - ASSERT (Child [i] != EMPTY) ; - ASSERT (fprev != bigf) ; - ASSERT (fprev != EMPTY) ; - Sibling [fprev] = bigf ; - } - -#ifndef NDEBUG - AMD_DEBUG1 (("After partial sort, element "ID"\n", i)) ; - for (f = Child [i] ; f != EMPTY ; f = Sibling [f]) - { - ASSERT (f >= 0 && f < nn) ; - AMD_DEBUG1 ((" "ID" "ID"\n", f, Fsize [f])) ; - ASSERT (Nv [f] > 0) ; - nchild-- ; - } - ASSERT (nchild == 0) ; -#endif - - } - } - - /* --------------------------------------------------------------------- */ - /* postorder the assembly tree */ - /* --------------------------------------------------------------------- */ - - for (i = 0 ; i < nn ; i++) - { - Order [i] = EMPTY ; - } - - k = 0 ; - - for (i = 0 ; i < nn ; i++) - { - if (Parent [i] == EMPTY && Nv [i] > 0) - { - AMD_DEBUG1 (("Root of assembly tree "ID"\n", i)) ; - k = AMD_post_tree (i, k, Child, Sibling, Order, Stack -#ifndef NDEBUG - , nn -#endif - ) ; - } - } -} diff --git a/src-x64/amd_postorder.o b/src-x64/amd_postorder.o deleted file mode 100644 index cc72738..0000000 Binary files a/src-x64/amd_postorder.o and /dev/null differ diff --git a/src-x64/amd_preprocess.c b/src-x64/amd_preprocess.c deleted file mode 100644 index 1eb2d1f..0000000 --- a/src-x64/amd_preprocess.c +++ /dev/null @@ -1,118 +0,0 @@ -/* ========================================================================= */ -/* === AMD_preprocess ====================================================== */ -/* ========================================================================= */ - -/* ------------------------------------------------------------------------- */ -/* AMD, Copyright (c) Timothy A. Davis, */ -/* Patrick R. Amestoy, and Iain S. Duff. See ../LICENSE.note for License. */ -/* email: DrTimothyAldenDavis@gmail.com */ -/* ------------------------------------------------------------------------- */ - -/* Sorts, removes duplicate entries, and transposes from the nonzero pattern of - * a column-form matrix A, to obtain the matrix R. The input matrix can have - * duplicate entries and/or unsorted columns (AMD_valid (n,Ap,Ai) must not be - * AMD_INVALID). - * - * This input condition is NOT checked. This routine is not user-callable. - */ - -#include "amd_internal.h" - -/* ========================================================================= */ -/* === AMD_preprocess ====================================================== */ -/* ========================================================================= */ - -/* AMD_preprocess does not check its input for errors or allocate workspace. - * On input, the condition (AMD_valid (n,n,Ap,Ai) != AMD_INVALID) must hold. - */ - -GLOBAL void AMD_preprocess -( - Int n, /* input matrix: A is n-by-n */ - const Int Ap [ ], /* size n+1 */ - const Int Ai [ ], /* size nz = Ap [n] */ - - /* output matrix R: */ - Int Rp [ ], /* size n+1 */ - Int Ri [ ], /* size nz (or less, if duplicates present) */ - - Int W [ ], /* workspace of size n */ - Int Flag [ ] /* workspace of size n */ -) -{ - - /* --------------------------------------------------------------------- */ - /* local variables */ - /* --------------------------------------------------------------------- */ - - Int i, j, p, p2 ; - - ASSERT (AMD_valid (n, n, Ap, Ai) != AMD_INVALID) ; - - /* --------------------------------------------------------------------- */ - /* count the entries in each row of A (excluding duplicates) */ - /* --------------------------------------------------------------------- */ - - for (i = 0 ; i < n ; i++) - { - W [i] = 0 ; /* # of nonzeros in row i (excl duplicates) */ - Flag [i] = EMPTY ; /* Flag [i] = j if i appears in column j */ - } - for (j = 0 ; j < n ; j++) - { - p2 = Ap [j+1] ; - for (p = Ap [j] ; p < p2 ; p++) - { - i = Ai [p] ; - if (Flag [i] != j) - { - /* row index i has not yet appeared in column j */ - W [i]++ ; /* one more entry in row i */ - Flag [i] = j ; /* flag row index i as appearing in col j*/ - } - } - } - - /* --------------------------------------------------------------------- */ - /* compute the row pointers for R */ - /* --------------------------------------------------------------------- */ - - Rp [0] = 0 ; - for (i = 0 ; i < n ; i++) - { - Rp [i+1] = Rp [i] + W [i] ; - } - for (i = 0 ; i < n ; i++) - { - W [i] = Rp [i] ; - Flag [i] = EMPTY ; - } - - /* --------------------------------------------------------------------- */ - /* construct the row form matrix R */ - /* --------------------------------------------------------------------- */ - - /* R = row form of pattern of A */ - for (j = 0 ; j < n ; j++) - { - p2 = Ap [j+1] ; - for (p = Ap [j] ; p < p2 ; p++) - { - i = Ai [p] ; - if (Flag [i] != j) - { - /* row index i has not yet appeared in column j */ - Ri [W [i]++] = j ; /* put col j in row i */ - Flag [i] = j ; /* flag row index i as appearing in col j*/ - } - } - } - -#ifndef NDEBUG - ASSERT (AMD_valid (n, n, Rp, Ri) == AMD_OK) ; - for (j = 0 ; j < n ; j++) - { - ASSERT (W [j] == Rp [j+1]) ; - } -#endif -} diff --git a/src-x64/amd_preprocess.o b/src-x64/amd_preprocess.o deleted file mode 100644 index f9ba4f3..0000000 Binary files a/src-x64/amd_preprocess.o and /dev/null differ diff --git a/vignettes/FRK_intro.pdf b/vignettes/FRK_intro.pdf index 8cd8f08..532c290 100644 Binary files a/vignettes/FRK_intro.pdf and b/vignettes/FRK_intro.pdf differ