update KLU to version 2.3.5

This commit is contained in:
dwarning 2024-12-02 07:34:24 +01:00
parent 4589821df3
commit c638b9678c
42 changed files with 1286 additions and 1398 deletions

View File

@ -136,7 +136,8 @@ noinst_HEADERS = \
fftext.h \
wallace.h \
wincolornames.h \
wstdio.h
wstdio.h \
SuiteSparse_config.h
if SHARED_MODULE
pkginclude_HEADERS = \

View File

@ -1,19 +1,18 @@
/* ========================================================================= */
/* === AMD: approximate minimum degree ordering =========================== */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Include/amd.h: approximate minimum degree ordering
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD Version 2.2, Copyright (c) 2007 by Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2024, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* 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 UF_long integers.
* provided, one for int32_t integers and the other for int64_t integers.
*
* The method is based on the approximate minimum degree algorithm, discussed
* in Amestoy, Davis, and Duff, "An approximate degree ordering algorithm",
@ -36,54 +35,51 @@
#ifndef AMD_H
#define AMD_H
#include "SuiteSparse_config.h"
/* make it easy for C++ programs to include AMD */
#ifdef __cplusplus
extern "C" {
#endif
/* get the definition of size_t: */
#include <stddef.h>
/* define UF_long */
#include "UFconfig.h"
int amd_order /* returns AMD_OK, AMD_OK_BUT_JUMBLED,
* AMD_INVALID, or AMD_OUT_OF_MEMORY */
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 */
int32_t n, /* A is n-by-n. n must be >= 0. */
const int32_t Ap [ ], /* column pointers for A, of size n+1 */
const int32_t Ai [ ], /* row indices of A, of size nz = Ap [n] */
int32_t P [ ], /* output permutation, of size n */
double Control [ ], /* input Control settings, of size AMD_CONTROL */
double Info [ ] /* output Info statistics, of size AMD_INFO */
) ;
UF_long amd_l_order /* see above for description of arguments */
int amd_l_order /* see above for description */
(
UF_long n,
const UF_long Ap [ ],
const UF_long Ai [ ],
UF_long P [ ],
int64_t n,
const int64_t Ap [ ],
const int64_t Ai [ ],
int64_t P [ ],
double Control [ ],
double Info [ ]
) ;
/* Input arguments (not modified):
*
* n: the matrix A is n-by-n.
* Ap: an int/UF_long array of size n+1, containing column pointers of A.
* Ai: an int/UF_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.
* n: the matrix A is n-by-n.
* Ap: an int32_t/int64_t array of size n+1, containing column
* pointers of A.
* Ai: an int32_t/int64_t 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/UF_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.
* P: an int32_t/int64_t 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].
@ -92,9 +88,8 @@ UF_long amd_l_order /* see above for description of arguments */
* 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).
*
* ordered.
*
* 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].
@ -105,25 +100,25 @@ UF_long amd_l_order /* see above for description of arguments */
* 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.cise.ufl.edu/research/sparse/umfpack.
* 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.
* 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_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_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_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.
* 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
@ -135,94 +130,94 @@ UF_long amd_l_order /* see above for description of arguments */
* 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_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 [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.
* 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_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_N]: n, the size of the input matrix
* Info [AMD_NZ]: the number of nonzeros in A, nz = Ap [n]
*
* 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_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_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_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_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_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_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_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_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_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_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 [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.
*/
* Info [14..19] are not used in the current version, but may be used in
* future versions.
*/
/* ------------------------------------------------------------------------- */
/* direct interface to AMD */
@ -238,38 +233,38 @@ UF_long amd_l_order /* see above for description of arguments */
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 [ ],
int32_t n,
int32_t Pe [ ],
int32_t Iw [ ],
int32_t Len [ ],
int32_t iwlen,
int32_t pfree,
int32_t Nv [ ],
int32_t Next [ ],
int32_t Last [ ],
int32_t Head [ ],
int32_t Elen [ ],
int32_t Degree [ ],
int32_t W [ ],
double Control [ ],
double Info [ ]
) ;
void amd_l2
(
UF_long n,
UF_long Pe [ ],
UF_long Iw [ ],
UF_long Len [ ],
UF_long iwlen,
UF_long pfree,
UF_long Nv [ ],
UF_long Next [ ],
UF_long Last [ ],
UF_long Head [ ],
UF_long Elen [ ],
UF_long Degree [ ],
UF_long W [ ],
int64_t n,
int64_t Pe [ ],
int64_t Iw [ ],
int64_t Len [ ],
int64_t iwlen,
int64_t pfree,
int64_t Nv [ ],
int64_t Next [ ],
int64_t Last [ ],
int64_t Head [ ],
int64_t Elen [ ],
int64_t Degree [ ],
int64_t W [ ],
double Control [ ],
double Info [ ]
) ;
@ -284,43 +279,24 @@ void amd_l2
* 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] */
int32_t n_row, /* # of rows */
int32_t n_col, /* # of columns */
const int32_t Ap [ ], /* column pointers, of size n_col+1 */
const int32_t Ai [ ] /* row indices, of size Ap [n_col] */
) ;
UF_long amd_l_valid
int amd_l_valid
(
UF_long n_row,
UF_long n_col,
const UF_long Ap [ ],
const UF_long Ai [ ]
int64_t n_row,
int64_t n_col,
const int64_t Ap [ ],
const int64_t 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 */
/* ------------------------------------------------------------------------- */
@ -337,6 +313,14 @@ void amd_l_control (double Control [ ]) ;
void amd_info (double Info [ ]) ;
void amd_l_info (double Info [ ]) ;
// amd_version: return AMD version. The version array is returned with
// version [0..2] = {AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION}
void amd_version (int version [3]) ;
#ifdef __cplusplus
}
#endif
#define AMD_CONTROL 5 /* size of Control array */
#define AMD_INFO 20 /* size of Info array */
@ -351,7 +335,7 @@ void amd_l_info (double Info [ ]) ;
/* 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_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' */
@ -398,15 +382,18 @@ void amd_l_info (double Info [ ]) ;
* Versions 1.1 and earlier of AMD do not include a #define'd version number.
*/
#define AMD_DATE "Dec 7, 2011"
#define AMD_VERSION_CODE(main,sub) ((main) * 1000 + (sub))
#define AMD_MAIN_VERSION 2
#define AMD_SUB_VERSION 2
#define AMD_DATE "June 20, 2024"
#define AMD_MAIN_VERSION 3
#define AMD_SUB_VERSION 3
#define AMD_SUBSUB_VERSION 3
#define AMD_VERSION AMD_VERSION_CODE(AMD_MAIN_VERSION,AMD_SUB_VERSION)
#ifdef __cplusplus
}
#define AMD_VERSION_CODE(main,sub) SUITESPARSE_VER_CODE(main,sub)
#define AMD_VERSION AMD_VERSION_CODE(3,3)
#define AMD__VERSION SUITESPARSE__VERCODE(3,3,3)
#if !defined (SUITESPARSE__VERSION) || \
(SUITESPARSE__VERSION < SUITESPARSE__VERCODE(7,8,0))
#error "AMD 3.3.3 requires SuiteSparse_config 7.8.0 or later"
#endif
#endif

View File

@ -1,17 +1,19 @@
/* ========================================================================== */
/* === BTF package ========================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// BTF/Include/btf.h: include file for BTF
//------------------------------------------------------------------------------
// BTF, Copyright (c) 2004-2024, University of Florida. All Rights Reserved.
// Author: Timothy A. Davis.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* BTF_MAXTRANS: find a column permutation Q to give A*Q a zero-free diagonal
* BTF_STRONGCOMP: find a symmetric permutation P to put P*A*P' into block
* upper triangular form.
* BTF_ORDER: do both of the above (btf_maxtrans then btf_strongcomp).
*
* Copyright (c) 2004-2007. Tim Davis, University of Florida,
* with support from Sandia National Laboratories. All Rights Reserved.
*/
/* ========================================================================== */
/* === BTF_MAXTRANS ========================================================= */
/* ========================================================================== */
@ -88,20 +90,20 @@
#ifndef _BTF_H
#define _BTF_H
#include "SuiteSparse_config.h"
/* make it easy for C++ programs to include BTF */
#ifdef __cplusplus
extern "C" {
#endif
#include "UFconfig.h"
int btf_maxtrans /* returns # of columns matched */
int32_t btf_maxtrans /* returns # of columns matched */
(
/* --- input, not modified: --- */
int nrow, /* A is nrow-by-ncol in compressed column form */
int ncol,
int Ap [ ], /* size ncol+1 */
int Ai [ ], /* size nz = Ap [ncol] */
int32_t nrow, /* A is nrow-by-ncol in compressed column form */
int32_t ncol,
int32_t Ap [ ], /* size ncol+1 */
int32_t Ai [ ], /* size nz = Ap [ncol] */
double maxwork, /* maximum amount of work to do is maxwork*nnz(A); no limit
* if <= 0 */
@ -110,16 +112,17 @@ int btf_maxtrans /* returns # of columns matched */
* reached the maximum of maxwork*nnz(A).
* Otherwise, work = the total work performed. */
int Match [ ], /* size nrow. Match [i] = j if column j matched to row i
int32_t Match [ ], /* size nrow. Match [i] = j if column j matched to row i
* (see above for the singular-matrix case) */
/* --- workspace, not defined on input or output --- */
int Work [ ] /* size 5*ncol */
int32_t Work [ ] /* size 5*ncol */
) ;
/* long integer version (all "int" parameters become "UF_long") */
UF_long btf_l_maxtrans (UF_long, UF_long, UF_long *, UF_long *, double,
double *, UF_long *, UF_long *) ;
/* int64_t integer version */
int64_t btf_l_maxtrans (int64_t, int64_t,
int64_t *, int64_t *, double, double *,
int64_t *, int64_t *) ;
/* ========================================================================== */
@ -144,28 +147,29 @@ UF_long btf_l_maxtrans (UF_long, UF_long, UF_long *, UF_long *, double,
* number of strongly connected components found.
*/
int btf_strongcomp /* return # of strongly connected components */
int32_t btf_strongcomp /* return # of strongly connected components */
(
/* input, not modified: */
int n, /* A is n-by-n in compressed column form */
int Ap [ ], /* size n+1 */
int Ai [ ], /* size nz = Ap [n] */
int32_t n, /* A is n-by-n in compressed column form */
int32_t Ap [ ], /* size n+1 */
int32_t Ai [ ], /* size nz = Ap [n] */
/* optional input, modified (if present) on output: */
int Q [ ], /* size n, input column permutation */
int32_t Q [ ], /* size n, input column permutation */
/* output, not defined on input */
int P [ ], /* size n. P [k] = j if row and column j are kth row/col
int32_t P [ ], /* size n. P [k] = j if row and column j are kth row/col
* in permuted matrix. */
int R [ ], /* size n+1. block b is in rows/cols R[b] ... R[b+1]-1 */
int32_t R [ ], /* size n+1. block b is in rows/cols R[b] ... R[b+1]-1 */
/* workspace, not defined on input or output */
int Work [ ] /* size 4n */
int32_t Work [ ] /* size 4n */
) ;
UF_long btf_l_strongcomp (UF_long, UF_long *, UF_long *, UF_long *, UF_long *,
UF_long *, UF_long *) ;
int64_t btf_l_strongcomp (int64_t, int64_t *,
int64_t *, int64_t *, int64_t *,
int64_t *, int64_t *) ;
/* ========================================================================== */
@ -191,28 +195,38 @@ UF_long btf_l_strongcomp (UF_long, UF_long *, UF_long *, UF_long *, UF_long *,
* number of strongly connected components found.
*/
int btf_order /* returns number of blocks found */
int32_t btf_order /* returns number of blocks found */
(
/* --- input, not modified: --- */
int n, /* A is n-by-n in compressed column form */
int Ap [ ], /* size n+1 */
int Ai [ ], /* size nz = Ap [n] */
int32_t n, /* A is n-by-n in compressed column form */
int32_t Ap [ ], /* size n+1 */
int32_t Ai [ ], /* size nz = Ap [n] */
double maxwork, /* do at most maxwork*nnz(A) work in the maximum
* transversal; no limit if <= 0 */
/* --- output, not defined on input --- */
double *work, /* return value from btf_maxtrans */
int P [ ], /* size n, row permutation */
int Q [ ], /* size n, column permutation */
int R [ ], /* size n+1. block b is in rows/cols R[b] ... R[b+1]-1 */
int *nmatch, /* # nonzeros on diagonal of P*A*Q */
int32_t P [ ], /* size n, row permutation */
int32_t Q [ ], /* size n, column permutation */
int32_t R [ ], /* size n+1. block b is in rows/cols R[b] ... R[b+1]-1 */
int32_t *nmatch, /* # nonzeros on diagonal of P*A*Q */
/* --- workspace, not defined on input or output --- */
int Work [ ] /* size 5n */
int32_t Work [ ] /* size 5n */
) ;
UF_long btf_l_order (UF_long, UF_long *, UF_long *, double , double *,
UF_long *, UF_long *, UF_long *, UF_long *, UF_long *) ;
int64_t btf_l_order (int64_t, int64_t *, int64_t *, double , double *,
int64_t *, int64_t *, int64_t *, int64_t *, int64_t *) ;
//------------------------------------------------------------------------------
// btf_version: return BTF version
//------------------------------------------------------------------------------
void btf_version (int version [3]) ;
#ifdef __cplusplus
}
#endif
/* ========================================================================== */
@ -243,21 +257,25 @@ UF_long btf_l_order (UF_long, UF_long *, UF_long *, double , double *,
*
* This also works during compile-time:
*
* #if (BTF >= BTF_VERSION_CODE (1,2))
* #if (BTF_VERSION >= BTF_VERSION_CODE (1,2))
* printf ("This is version 1.2 or later\n") ;
* #else
* printf ("This is an early version\n") ;
* #endif
*/
#define BTF_DATE "Dec 7, 2011"
#define BTF_VERSION_CODE(main,sub) ((main) * 1000 + (sub))
#define BTF_MAIN_VERSION 1
#define BTF_SUB_VERSION 1
#define BTF_SUBSUB_VERSION 3
#define BTF_VERSION BTF_VERSION_CODE(BTF_MAIN_VERSION,BTF_SUB_VERSION)
#define BTF_DATE "Mar 22, 2024"
#define BTF_MAIN_VERSION 2
#define BTF_SUB_VERSION 3
#define BTF_SUBSUB_VERSION 2
#ifdef __cplusplus
}
#define BTF_VERSION_CODE(main,sub) SUITESPARSE_VER_CODE(main,sub)
#define BTF_VERSION BTF_VERSION_CODE(2,3)
#define BTF__VERSION SUITESPARSE__VERCODE(2,3,2)
#if !defined (SUITESPARSE__VERSION) || \
(SUITESPARSE__VERSION < SUITESPARSE__VERCODE(7,7,0))
#error "BTF 2.3.2 requires SuiteSparse_config 7.7.0 or later"
#endif
#endif

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === colamd/symamd prototypes and definitions ============================= */
/* ========================================================================== */
//------------------------------------------------------------------------------
// COLAMD/Include/colamd.h: include file for COLAMD
//------------------------------------------------------------------------------
// COLAMD, Copyright (c) 1998-2024, Timothy A. Davis and Stefan Larimore,
// All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* COLAMD / SYMAMD include file
@ -9,55 +15,33 @@
Authors:
The authors of the code itself are Stefan I. Larimore and Timothy A.
Davis (davis at cise.ufl.edu), University of Florida. The algorithm was
developed in collaboration with John Gilbert, Xerox PARC, and Esmond
Ng, Oak Ridge National Laboratory.
The authors of the code itself are Stefan I. Larimore and Timothy A.
Davis (DrTimothyAldenDavis@gmail.com). The algorithm was
developed in collaboration with John Gilbert, Xerox PARC, and Esmond
Ng, Oak Ridge National Laboratory.
Acknowledgements:
This work was supported by the National Science Foundation, under
grants DMS-9504974 and DMS-9803599.
Notice:
Copyright (c) 1998-2007, Timothy A. Davis, All Rights Reserved.
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
Permission is hereby granted to use, copy, modify, and/or distribute
this program, provided that the Copyright, this License, and the
Availability of the original version is retained on all copies and made
accessible to the end-user of any code or package that includes COLAMD
or any modified version of COLAMD.
This work was supported by the National Science Foundation, under
grants DMS-9504974 and DMS-9803599.
Availability:
The colamd/symamd library is available at
http://www.cise.ufl.edu/research/sparse/colamd/
This is the http://www.cise.ufl.edu/research/sparse/colamd/colamd.h
file. It is required by the colamd.c, colamdmex.c, and symamdmex.c
files, and by any C code that calls the routines whose prototypes are
listed below, or that uses the colamd/symamd definitions listed below.
The colamd/symamd library is available at http://www.suitesparse.com
This file is required by the colamd.c, colamdmex.c, and symamdmex.c
files, and by any C code that calls the routines whose prototypes are
listed below, or that uses the colamd/symamd definitions listed below.
*/
#ifndef COLAMD_H
#define COLAMD_H
/* make it easy for C++ programs to include COLAMD */
#ifdef __cplusplus
extern "C" {
#endif
/* ========================================================================== */
/* === Include files ======================================================== */
/* ========================================================================== */
#include <stdlib.h>
#include "SuiteSparse_config.h"
/* ========================================================================== */
/* === COLAMD version ======================================================= */
@ -67,7 +51,7 @@ extern "C" {
* As an example, to test if the version you are using is 2.4 or later:
*
* #ifdef COLAMD_VERSION
* if (COLAMD_VERSION >= COLAMD_VERSION_CODE (2,4)) ...
* if (COLAMD_VERSION >= COLAMD_VERSION_CODE (2,4)) ...
* #endif
*
* This also works during compile-time:
@ -81,13 +65,19 @@ extern "C" {
* Versions 2.3 and earlier of COLAMD do not include a #define'd version number.
*/
#define COLAMD_DATE "Dec 7, 2011"
#define COLAMD_VERSION_CODE(main,sub) ((main) * 1000 + (sub))
#define COLAMD_MAIN_VERSION 2
#define COLAMD_SUB_VERSION 7
#define COLAMD_DATE "June 20, 2024"
#define COLAMD_MAIN_VERSION 3
#define COLAMD_SUB_VERSION 3
#define COLAMD_SUBSUB_VERSION 4
#define COLAMD_VERSION \
COLAMD_VERSION_CODE(COLAMD_MAIN_VERSION,COLAMD_SUB_VERSION)
#define COLAMD_VERSION_CODE(main,sub) SUITESPARSE_VER_CODE(main,sub)
#define COLAMD_VERSION COLAMD_VERSION_CODE(3,3)
#define COLAMD__VERSION SUITESPARSE__VERCODE(3,3,4)
#if !defined (SUITESPARSE__VERSION) || \
(SUITESPARSE__VERSION < SUITESPARSE__VERCODE(7,8,0))
#error "COLAMD 3.3.4 requires SuiteSparse_config 7.8.0 or later"
#endif
/* ========================================================================== */
/* === Knob and statistics definitions ====================================== */
@ -114,139 +104,137 @@ extern "C" {
/* stats [3]: colamd status: zero OK, > 0 warning or notice, < 0 error */
#define COLAMD_STATUS 3
/* stats [4..6]: error info, or info on jumbled columns */
/* stats [4..6]: error info, or info on jumbled columns */
#define COLAMD_INFO1 4
#define COLAMD_INFO2 5
#define COLAMD_INFO3 6
/* error codes returned in stats [3]: */
#define COLAMD_OK (0)
#define COLAMD_OK_BUT_JUMBLED (1)
#define COLAMD_ERROR_A_not_present (-1)
#define COLAMD_ERROR_p_not_present (-2)
#define COLAMD_ERROR_nrow_negative (-3)
#define COLAMD_ERROR_ncol_negative (-4)
#define COLAMD_ERROR_nnz_negative (-5)
#define COLAMD_ERROR_p0_nonzero (-6)
#define COLAMD_ERROR_A_too_small (-7)
#define COLAMD_ERROR_col_length_negative (-8)
#define COLAMD_ERROR_row_index_out_of_bounds (-9)
#define COLAMD_ERROR_out_of_memory (-10)
#define COLAMD_ERROR_internal_error (-999)
#define COLAMD_OK (0)
#define COLAMD_OK_BUT_JUMBLED (1)
#define COLAMD_ERROR_A_not_present (-1)
#define COLAMD_ERROR_p_not_present (-2)
#define COLAMD_ERROR_nrow_negative (-3)
#define COLAMD_ERROR_ncol_negative (-4)
#define COLAMD_ERROR_nnz_negative (-5)
#define COLAMD_ERROR_p0_nonzero (-6)
#define COLAMD_ERROR_A_too_small (-7)
#define COLAMD_ERROR_col_length_negative (-8)
#define COLAMD_ERROR_row_index_out_of_bounds (-9)
#define COLAMD_ERROR_out_of_memory (-10)
#define COLAMD_ERROR_internal_error (-999)
/* ========================================================================== */
/* === Prototypes of user-callable routines ================================= */
/* ========================================================================== */
/* define UF_long */
#include "UFconfig.h"
/* make it easy for C++ programs to include COLAMD */
#ifdef __cplusplus
extern "C" {
#endif
size_t colamd_recommended /* returns recommended value of Alen, */
/* or 0 if input arguments are erroneous */
size_t colamd_recommended /* returns recommended value of Alen, */
/* or 0 if input arguments are erroneous */
(
int nnz, /* nonzeros in A */
int n_row, /* number of rows in A */
int n_col /* number of columns in A */
int32_t nnz, /* nonzeros in A */
int32_t n_row, /* number of rows in A */
int32_t n_col /* number of columns in A */
) ;
size_t colamd_l_recommended /* returns recommended value of Alen, */
/* or 0 if input arguments are erroneous */
size_t colamd_l_recommended /* returns recommended value of Alen, */
/* or 0 if input arguments are erroneous */
(
UF_long nnz, /* nonzeros in A */
UF_long n_row, /* number of rows in A */
UF_long n_col /* number of columns in A */
int64_t nnz, /* nonzeros in A */
int64_t n_row, /* number of rows in A */
int64_t n_col /* number of columns in A */
) ;
void colamd_set_defaults /* sets default parameters */
( /* knobs argument is modified on output */
double knobs [COLAMD_KNOBS] /* parameter settings for colamd */
void colamd_set_defaults /* sets default parameters */
( /* knobs argument is modified on output */
double knobs [COLAMD_KNOBS] /* parameter settings for colamd */
) ;
void colamd_l_set_defaults /* sets default parameters */
( /* knobs argument is modified on output */
double knobs [COLAMD_KNOBS] /* parameter settings for colamd */
void colamd_l_set_defaults /* sets default parameters */
( /* knobs argument is modified on output */
double knobs [COLAMD_KNOBS] /* parameter settings for colamd */
) ;
int colamd /* returns (1) if successful, (0) otherwise*/
( /* A and p arguments are modified on output */
int n_row, /* number of rows in A */
int n_col, /* number of columns in A */
int Alen, /* size of the array A */
int A [], /* row indices of A, of size Alen */
int p [], /* column pointers of A, of size n_col+1 */
double knobs [COLAMD_KNOBS],/* parameter settings for colamd */
int stats [COLAMD_STATS] /* colamd output statistics and error codes */
int colamd /* returns (1) if successful, (0) otherwise*/
( /* A and p arguments are modified on output */
int32_t n_row, /* number of rows in A */
int32_t n_col, /* number of columns in A */
int32_t Alen, /* size of the array A */
int32_t A [], /* row indices of A, of size Alen */
int32_t p [], /* column pointers of A, of size n_col+1 */
double knobs [COLAMD_KNOBS], /* parameter settings for colamd */
int32_t stats [COLAMD_STATS] /* colamd output stats and error codes */
) ;
UF_long colamd_l /* returns (1) if successful, (0) otherwise*/
( /* A and p arguments are modified on output */
UF_long n_row, /* number of rows in A */
UF_long n_col, /* number of columns in A */
UF_long Alen, /* size of the array A */
UF_long A [], /* row indices of A, of size Alen */
UF_long p [], /* column pointers of A, of size n_col+1 */
double knobs [COLAMD_KNOBS],/* parameter settings for colamd */
UF_long stats [COLAMD_STATS]/* colamd output statistics and error codes */
int colamd_l /* returns (1) if successful, (0) otherwise*/
( /* A and p arguments are modified on output */
int64_t n_row, /* number of rows in A */
int64_t n_col, /* number of columns in A */
int64_t Alen, /* size of the array A */
int64_t A [], /* row indices of A, of size Alen */
int64_t p [], /* column pointers of A, of size n_col+1 */
double knobs [COLAMD_KNOBS], /* parameter settings for colamd */
int64_t stats [COLAMD_STATS] /* colamd output stats and error codes */
) ;
int symamd /* return (1) if OK, (0) otherwise */
int symamd /* return (1) if OK, (0) otherwise */
(
int n, /* number of rows and columns of A */
int A [], /* row indices of A */
int p [], /* column pointers of A */
int perm [], /* output permutation, size n_col+1 */
double knobs [COLAMD_KNOBS], /* parameters (uses defaults if NULL) */
int stats [COLAMD_STATS], /* output statistics and error codes */
int32_t n, /* number of rows and columns of A */
int32_t A [], /* row indices of A */
int32_t p [], /* column pointers of A */
int32_t perm [], /* output permutation, size n_col+1 */
double knobs [COLAMD_KNOBS], /* parameters (uses defaults if NULL) */
int32_t stats [COLAMD_STATS], /* output stats and error codes */
void * (*allocate) (size_t, size_t),
/* pointer to calloc (ANSI C) or */
/* mxCalloc (for MATLAB mexFunction) */
/* pointer to calloc (ANSI C) or */
/* mxCalloc (for MATLAB mexFunction) */
void (*release) (void *)
/* pointer to free (ANSI C) or */
/* mxFree (for MATLAB mexFunction) */
/* pointer to free (ANSI C) or */
/* mxFree (for MATLAB mexFunction) */
) ;
UF_long symamd_l /* return (1) if OK, (0) otherwise */
int symamd_l /* return (1) if OK, (0) otherwise */
(
UF_long n, /* number of rows and columns of A */
UF_long A [], /* row indices of A */
UF_long p [], /* column pointers of A */
UF_long perm [], /* output permutation, size n_col+1 */
double knobs [COLAMD_KNOBS], /* parameters (uses defaults if NULL) */
UF_long stats [COLAMD_STATS], /* output statistics and error codes */
int64_t n, /* number of rows and columns of A */
int64_t A [], /* row indices of A */
int64_t p [], /* column pointers of A */
int64_t perm [], /* output permutation, size n_col+1 */
double knobs [COLAMD_KNOBS], /* parameters (uses defaults if NULL) */
int64_t stats [COLAMD_STATS], /* output stats and error codes */
void * (*allocate) (size_t, size_t),
/* pointer to calloc (ANSI C) or */
/* mxCalloc (for MATLAB mexFunction) */
/* pointer to calloc (ANSI C) or */
/* mxCalloc (for MATLAB mexFunction) */
void (*release) (void *)
/* pointer to free (ANSI C) or */
/* mxFree (for MATLAB mexFunction) */
/* pointer to free (ANSI C) or */
/* mxFree (for MATLAB mexFunction) */
) ;
void colamd_report
(
int stats [COLAMD_STATS]
int32_t stats [COLAMD_STATS]
) ;
void colamd_l_report
(
UF_long stats [COLAMD_STATS]
int64_t stats [COLAMD_STATS]
) ;
void symamd_report
(
int stats [COLAMD_STATS]
int32_t stats [COLAMD_STATS]
) ;
void symamd_l_report
(
UF_long stats [COLAMD_STATS]
int64_t stats [COLAMD_STATS]
) ;
#ifndef EXTERN
#define EXTERN extern
#endif
EXTERN int (*colamd_printf) (const char *, ...) ;
void colamd_version (int version [3]) ;
#ifdef __cplusplus
}

View File

@ -1,21 +1,27 @@
/* ========================================================================== */
/* === klu include file ===================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu.h: include file for KLU
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2024, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Include file for user programs that call klu_* routines */
#ifndef _KLU_H
#define _KLU_H
#include "amd.h"
#include "colamd.h"
#include "btf.h"
/* make it easy for C++ programs to include KLU */
#ifdef __cplusplus
extern "C" {
#endif
#include "amd.h"
#include "colamd.h"
#include "btf.h"
/* -------------------------------------------------------------------------- */
/* Symbolic object - contains the pre-ordering computed by klu_analyze */
/* -------------------------------------------------------------------------- */
@ -24,7 +30,7 @@ typedef struct
{
/* A (P,Q) is in upper block triangular form. The kth block goes from
* row/col index R [k] to R [k+1]-1. The estimated number of nonzeros
* in the L factor of the kth block is Lnz [k].
* in the L factor of the kth block is Lnz [k].
*/
/* only computed if the AMD ordering is chosen: */
@ -34,7 +40,7 @@ typedef struct
double *Lnz ; /* size n, but only Lnz [0..nblocks-1] is used */
/* computed for all orderings: */
int
int32_t
n, /* input matrix A is n-by-n */
nz, /* # entries in input matrix */
*P, /* size n */
@ -43,11 +49,11 @@ typedef struct
nzoff, /* nz in off-diagonal blocks */
nblocks, /* number of blocks */
maxblock, /* size of largest block */
ordering, /* ordering used (AMD, COLAMD, or GIVEN) */
ordering, /* ordering used (0:AMD, 1:COLAMD, 2:given, ... */
do_btf ; /* whether or not BTF preordering was requested */
/* only computed if BTF preordering requested */
int structural_rank ; /* 0 to n-1 if the matrix is structurally rank
int32_t structural_rank ; /* 0 to n-1 if the matrix is structurally rank
* deficient. -1 if not computed. n if the matrix has
* full structural rank */
@ -57,8 +63,8 @@ typedef struct /* 64-bit version (otherwise same as above) */
{
double symmetry, est_flops, lnz, unz ;
double *Lnz ;
UF_long n, nz, *P, *Q, *R, nzoff, nblocks, maxblock, ordering, do_btf,
structural_rank ;
int64_t n, nz, *P, *Q, *R, nzoff, nblocks, maxblock, ordering,
do_btf, structural_rank ;
} klu_l_symbolic ;
@ -71,20 +77,20 @@ typedef struct
/* LU factors of each block, the pivot row permutation, and the
* entries in the off-diagonal blocks */
int n ; /* A is n-by-n */
int nblocks ; /* number of diagonal blocks */
int lnz ; /* actual nz in L, including diagonal */
int unz ; /* actual nz in U, including diagonal */
int max_lnz_block ; /* max actual nz in L in any one block, incl. diag */
int max_unz_block ; /* max actual nz in U in any one block, incl. diag */
int *Pnum ; /* size n. final pivot permutation */
int *Pinv ; /* size n. inverse of final pivot permutation */
int32_t n ; /* A is n-by-n */
int32_t nblocks ; /* number of diagonal blocks */
int32_t lnz ; /* actual nz in L, including diagonal */
int32_t unz ; /* actual nz in U, including diagonal */
int32_t max_lnz_block ; /* max actual nz in L in any one block, incl. diag */
int32_t max_unz_block ; /* max actual nz in U in any one block, incl. diag */
int32_t *Pnum ; /* size n. final pivot permutation */
int32_t *Pinv ; /* size n. inverse of final pivot permutation */
/* LU factors of each block */
int *Lip ; /* size n. pointers into LUbx[block] for L */
int *Uip ; /* size n. pointers into LUbx[block] for U */
int *Llen ; /* size n. Llen [k] = # of entries in kth column of L */
int *Ulen ; /* size n. Ulen [k] = # of entries in kth column of U */
int32_t *Lip ; /* size n. pointers into LUbx[block] for L */
int32_t *Uip ; /* size n. pointers into LUbx[block] for U */
int32_t *Llen ; /* size n. Llen [k] = # of entries in kth column of L */
int32_t *Ulen ; /* size n. Ulen [k] = # of entries in kth column of U */
void **LUbx ; /* L and U indices and entries (excl. diagonal of U) */
size_t *LUsize ; /* size of each LUbx [block], in sizeof (Unit) */
void *Udiag ; /* diagonal of U */
@ -96,30 +102,30 @@ typedef struct
size_t worksize ; /* size (in bytes) of Work */
void *Work ; /* workspace */
void *Xwork ; /* alias into Numeric->Work */
int *Iwork ; /* alias into Numeric->Work */
int32_t *Iwork ; /* alias into Numeric->Work */
/* off-diagonal entries in a conventional compressed-column sparse matrix */
int *Offp ; /* size n+1, column pointers */
int *Offi ; /* size nzoff, row indices */
int32_t *Offp ; /* size n+1, column pointers */
int32_t *Offi ; /* size nzoff, row indices */
void *Offx ; /* size nzoff, numerical values */
int nzoff ;
int32_t nzoff ;
} klu_numeric ;
typedef struct /* 64-bit version (otherwise same as above) */
{
UF_long n, nblocks, lnz, unz, max_lnz_block, max_unz_block, *Pnum, *Pinv,
*Lip, *Uip, *Llen, *Ulen ;
int64_t n, nblocks, lnz, unz, max_lnz_block, max_unz_block, *Pnum,
*Pinv, *Lip, *Uip, *Llen, *Ulen ;
void **LUbx ;
size_t *LUsize ;
void *Udiag ;
double *Rs ;
size_t worksize ;
void *Work, *Xwork ;
UF_long *Iwork ;
UF_long *Offp, *Offi ;
int64_t *Iwork ;
int64_t *Offp, *Offi ;
void *Offx ;
UF_long nzoff ;
int64_t nzoff ;
} klu_l_numeric ;
@ -154,14 +160,9 @@ typedef struct klu_common_struct
int scale ; /* row scaling: -1: none (and no error check),
* 0: none, 1: sum, 2: max */
/* memory management routines */
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 */
/* pointer to user ordering function */
int (*user_order) (int, int *, int *, int *, struct klu_common_struct *) ;
int32_t (*user_order) (int32_t, int32_t *, int32_t *, int32_t *,
struct klu_common_struct *) ;
/* pointer to user data, passed unchanged as the last parameter to the
* user ordering function (optional, the user function need not use this
@ -184,23 +185,23 @@ typedef struct klu_common_struct
int status ; /* KLU_OK if OK, < 0 if error */
int nrealloc ; /* # of reallocations of L and U */
int structural_rank ; /* 0 to n-1 if the matrix is structurally rank
int32_t structural_rank ; /* 0 to n-1 if the matrix is structurally rank
* deficient (as determined by maxtrans). -1 if not computed. n if the
* matrix has full structural rank. This is computed by klu_analyze
* if a BTF preordering is requested. */
int numerical_rank ; /* First k for which a zero U(k,k) was found,
int32_t numerical_rank ; /* First k for which a zero U(k,k) was found,
* if the matrix was singular (in the range 0 to n-1). n if the matrix
* has full rank. This is not a true rank-estimation. It just reports
* where the first zero pivot was found. -1 if not computed.
* Computed by klu_factor and klu_refactor. */
int singular_col ; /* n if the matrix is not singular. If in the
int32_t singular_col ; /* n if the matrix is not singular. If in the
* range 0 to n-1, this is the column index of the original matrix A that
* corresponds to the column of U that contains a zero diagonal entry.
* -1 if not computed. Computed by klu_factor and klu_refactor. */
int noffdiag ; /* # of off-diagonal pivots, -1 if not computed */
int32_t noffdiag ; /* # of off-diagonal pivots, -1 if not computed */
double flops ; /* actual factorization flop count, from klu_flops */
double rcond ; /* crude reciprocal condition est., from klu_rcond */
@ -217,17 +218,12 @@ typedef struct klu_l_common_struct /* 64-bit version (otherwise same as above)*/
{
double tol, memgrow, initmem_amd, initmem, maxwork ;
UF_long btf, ordering, scale ;
void *(*malloc_memory) (size_t) ;
void *(*realloc_memory) (void *, size_t) ;
void (*free_memory) (void *) ;
void *(*calloc_memory) (size_t, size_t) ;
UF_long (*user_order) (UF_long, UF_long *, UF_long *, UF_long *,
int btf, ordering, scale ;
int64_t (*user_order) (int64_t, int64_t *, int64_t *, int64_t *,
struct klu_l_common_struct *) ;
void *user_data ;
UF_long halt_if_singular ;
UF_long status, nrealloc, structural_rank, numerical_rank, singular_col,
noffdiag ;
int halt_if_singular, status, nrealloc ;
int64_t structural_rank, numerical_rank, singular_col, noffdiag ;
double flops, rcond, condest, rgrowth, work ;
size_t memusage, mempeak ;
@ -242,7 +238,7 @@ int klu_defaults
klu_common *Common
) ;
UF_long klu_l_defaults (klu_l_common *Common) ;
int klu_l_defaults (klu_l_common *Common) ;
/* -------------------------------------------------------------------------- */
/* klu_analyze: orders and analyzes a matrix */
@ -254,13 +250,13 @@ UF_long klu_l_defaults (klu_l_common *Common) ;
klu_symbolic *klu_analyze
(
/* inputs, not modified */
int n, /* A is n-by-n */
int Ap [ ], /* size n+1, column pointers */
int Ai [ ], /* size nz, row indices */
int32_t n, /* A is n-by-n */
int32_t Ap [ ], /* size n+1, column pointers */
int32_t Ai [ ], /* size nz, row indices */
klu_common *Common
) ;
klu_l_symbolic *klu_l_analyze (UF_long, UF_long *, UF_long *,
klu_l_symbolic *klu_l_analyze (int64_t, int64_t *, int64_t *,
klu_l_common *Common) ;
@ -275,16 +271,16 @@ klu_l_symbolic *klu_l_analyze (UF_long, UF_long *, UF_long *,
klu_symbolic *klu_analyze_given
(
/* inputs, not modified */
int n, /* A is n-by-n */
int Ap [ ], /* size n+1, column pointers */
int Ai [ ], /* size nz, row indices */
int P [ ], /* size n, user's row permutation (may be NULL) */
int Q [ ], /* size n, user's column permutation (may be NULL) */
int32_t n, /* A is n-by-n */
int32_t Ap [ ], /* size n+1, column pointers */
int32_t Ai [ ], /* size nz, row indices */
int32_t P [ ], /* size n, user's row permutation (may be NULL) */
int32_t Q [ ], /* size n, user's column permutation (may be NULL) */
klu_common *Common
) ;
klu_l_symbolic *klu_l_analyze_given (UF_long, UF_long *, UF_long *, UF_long *,
UF_long *, klu_l_common *) ;
klu_l_symbolic *klu_l_analyze_given (int64_t, int64_t *, int64_t *, int64_t *,
int64_t *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -294,8 +290,8 @@ klu_l_symbolic *klu_l_analyze_given (UF_long, UF_long *, UF_long *, UF_long *,
klu_numeric *klu_factor /* returns KLU_OK if OK, < 0 if error */
(
/* inputs, not modified */
int Ap [ ], /* size n+1, column pointers */
int Ai [ ], /* size nz, row indices */
int32_t Ap [ ], /* size n+1, column pointers */
int32_t Ai [ ], /* size nz, row indices */
double Ax [ ], /* size nz, numerical values */
klu_symbolic *Symbolic,
klu_common *Common
@ -304,20 +300,20 @@ klu_numeric *klu_factor /* returns KLU_OK if OK, < 0 if error */
klu_numeric *klu_z_factor /* returns KLU_OK if OK, < 0 if error */
(
/* inputs, not modified */
int Ap [ ], /* size n+1, column pointers */
int Ai [ ], /* size nz, row indices */
int32_t Ap [ ], /* size n+1, column pointers */
int32_t Ai [ ], /* size nz, row indices */
double Ax [ ], /* size 2*nz, numerical values (real,imag pairs) */
klu_symbolic *Symbolic,
klu_common *Common
) ;
/* long / real version */
klu_l_numeric *klu_l_factor (UF_long *, UF_long *, double *, klu_l_symbolic *,
klu_l_common *) ;
/* int64_t / real version */
klu_l_numeric *klu_l_factor (int64_t *, int64_t *, double *,
klu_l_symbolic *, klu_l_common *) ;
/* long / complex version */
klu_l_numeric *klu_zl_factor (UF_long *, UF_long *, double *, klu_l_symbolic *,
klu_l_common *) ;
/* int64_t / complex version */
klu_l_numeric *klu_zl_factor (int64_t *, int64_t *, double *,
klu_l_symbolic *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -329,8 +325,8 @@ int klu_solve
/* inputs, not modified */
klu_symbolic *Symbolic,
klu_numeric *Numeric,
int ldim, /* leading dimension of B */
int nrhs, /* number of right-hand-sides */
int32_t ldim, /* leading dimension of B */
int32_t nrhs, /* number of right-hand-sides */
/* right-hand-side on input, overwritten with solution to Ax=b on output */
double B [ ], /* size ldim*nrhs */
@ -342,19 +338,19 @@ int klu_z_solve
/* inputs, not modified */
klu_symbolic *Symbolic,
klu_numeric *Numeric,
int ldim, /* leading dimension of B */
int nrhs, /* number of right-hand-sides */
int32_t ldim, /* leading dimension of B */
int32_t nrhs, /* number of right-hand-sides */
/* right-hand-side on input, overwritten with solution to Ax=b on output */
double B [ ], /* size 2*ldim*nrhs */
klu_common *Common
) ;
UF_long klu_l_solve (klu_l_symbolic *, klu_l_numeric *, UF_long, UF_long,
double *, klu_l_common *) ;
int klu_l_solve (klu_l_symbolic *, klu_l_numeric *,
int64_t, int64_t, double *, klu_l_common *) ;
UF_long klu_zl_solve (klu_l_symbolic *, klu_l_numeric *, UF_long, UF_long,
double *, klu_l_common *) ;
int klu_zl_solve (klu_l_symbolic *, klu_l_numeric *,
int64_t, int64_t, double *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -366,8 +362,8 @@ int klu_tsolve
/* inputs, not modified */
klu_symbolic *Symbolic,
klu_numeric *Numeric,
int ldim, /* leading dimension of B */
int nrhs, /* number of right-hand-sides */
int32_t ldim, /* leading dimension of B */
int32_t nrhs, /* number of right-hand-sides */
/* right-hand-side on input, overwritten with solution to Ax=b on output */
double B [ ], /* size ldim*nrhs */
@ -379,21 +375,21 @@ int klu_z_tsolve
/* inputs, not modified */
klu_symbolic *Symbolic,
klu_numeric *Numeric,
int ldim, /* leading dimension of B */
int nrhs, /* number of right-hand-sides */
int32_t ldim, /* leading dimension of B */
int32_t nrhs, /* number of right-hand-sides */
/* right-hand-side on input, overwritten with solution to Ax=b on output */
double B [ ], /* size 2*ldim*nrhs */
int conj_solve, /* TRUE: conjugate solve, FALSE: solve A.'x=b */
klu_common *Common
) ;
UF_long klu_l_tsolve (klu_l_symbolic *, klu_l_numeric *, UF_long, UF_long,
double *, klu_l_common *) ;
int klu_l_tsolve (klu_l_symbolic *, klu_l_numeric *,
int64_t, int64_t, double *, klu_l_common *) ;
UF_long klu_zl_tsolve (klu_l_symbolic *, klu_l_numeric *, UF_long, UF_long,
double *, UF_long, klu_l_common * ) ;
int klu_zl_tsolve (klu_l_symbolic *, klu_l_numeric *,
int64_t, int64_t, double *, int, klu_l_common * ) ;
/* -------------------------------------------------------------------------- */
@ -403,8 +399,8 @@ UF_long klu_zl_tsolve (klu_l_symbolic *, klu_l_numeric *, UF_long, UF_long,
int klu_refactor /* return TRUE if successful, FALSE otherwise */
(
/* inputs, not modified */
int Ap [ ], /* size n+1, column pointers */
int Ai [ ], /* size nz, row indices */
int32_t Ap [ ], /* size n+1, column pointers */
int32_t Ai [ ], /* size nz, row indices */
double Ax [ ], /* size nz, numerical values */
klu_symbolic *Symbolic,
/* input, and numerical values modified on output */
@ -415,8 +411,8 @@ int klu_refactor /* return TRUE if successful, FALSE otherwise */
int klu_z_refactor /* return TRUE if successful, FALSE otherwise */
(
/* inputs, not modified */
int Ap [ ], /* size n+1, column pointers */
int Ai [ ], /* size nz, row indices */
int32_t Ap [ ], /* size n+1, column pointers */
int32_t Ai [ ], /* size nz, row indices */
double Ax [ ], /* size 2*nz, numerical values */
klu_symbolic *Symbolic,
/* input, and numerical values modified on output */
@ -424,11 +420,11 @@ int klu_z_refactor /* return TRUE if successful, FALSE otherwise */
klu_common *Common
) ;
UF_long klu_l_refactor (UF_long *, UF_long *, double *, klu_l_symbolic *,
klu_l_numeric *, klu_l_common *) ;
int klu_l_refactor (int64_t *, int64_t *,
double *, klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
UF_long klu_zl_refactor (UF_long *, UF_long *, double *, klu_l_symbolic *,
klu_l_numeric *, klu_l_common *) ;
int klu_zl_refactor (int64_t *, int64_t *,
double *, klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -441,7 +437,7 @@ int klu_free_symbolic
klu_common *Common
) ;
UF_long klu_l_free_symbolic (klu_l_symbolic **, klu_l_common *) ;
int klu_l_free_symbolic (klu_l_symbolic **, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -463,8 +459,8 @@ int klu_z_free_numeric
klu_common *Common
) ;
UF_long klu_l_free_numeric (klu_l_numeric **, klu_l_common *) ;
UF_long klu_zl_free_numeric (klu_l_numeric **, klu_l_common *) ;
int klu_l_free_numeric (klu_l_numeric **, klu_l_common *) ;
int klu_zl_free_numeric (klu_l_numeric **, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -491,8 +487,8 @@ int klu_z_sort
klu_common *Common
) ;
UF_long klu_l_sort (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
UF_long klu_zl_sort (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
int klu_l_sort (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
int klu_zl_sort (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -517,9 +513,8 @@ int klu_z_flops
klu_common *Common
) ;
UF_long klu_l_flops (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
UF_long klu_zl_flops (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
int klu_l_flops (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
int klu_zl_flops (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -541,8 +536,8 @@ UF_long klu_zl_flops (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
int klu_rgrowth
(
int Ap [ ],
int Ai [ ],
int32_t Ap [ ],
int32_t Ai [ ],
double Ax [ ],
klu_symbolic *Symbolic,
klu_numeric *Numeric,
@ -551,19 +546,19 @@ int klu_rgrowth
int klu_z_rgrowth
(
int Ap [ ],
int Ai [ ],
int32_t Ap [ ],
int32_t Ai [ ],
double Ax [ ],
klu_symbolic *Symbolic,
klu_numeric *Numeric,
klu_common *Common /* Common->rgrowth = reciprocal pivot growth */
) ;
UF_long klu_l_rgrowth (UF_long *, UF_long *, double *, klu_l_symbolic *,
klu_l_numeric *, klu_l_common *) ;
int klu_l_rgrowth (int64_t *, int64_t *,
double *, klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
UF_long klu_zl_rgrowth (UF_long *, UF_long *, double *, klu_l_symbolic *,
klu_l_numeric *, klu_l_common *) ;
int klu_zl_rgrowth (int64_t *, int64_t *,
double *, klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -576,7 +571,7 @@ UF_long klu_zl_rgrowth (UF_long *, UF_long *, double *, klu_l_symbolic *,
int klu_condest
(
int Ap [ ], /* size n+1, column pointers, not modified */
int32_t Ap [ ], /* size n+1, column pointers, not modified */
double Ax [ ], /* size nz = Ap[n], numerical values, not modified*/
klu_symbolic *Symbolic, /* symbolic analysis, not modified */
klu_numeric *Numeric, /* numeric factorization, not modified */
@ -585,18 +580,18 @@ int klu_condest
int klu_z_condest
(
int Ap [ ],
int32_t Ap [ ],
double Ax [ ], /* size 2*nz */
klu_symbolic *Symbolic,
klu_numeric *Numeric,
klu_common *Common /* result returned in Common->condest */
) ;
UF_long klu_l_condest (UF_long *, double *, klu_l_symbolic *, klu_l_numeric *,
klu_l_common *) ;
int klu_l_condest (int64_t *, double *, klu_l_symbolic *,
klu_l_numeric *, klu_l_common *) ;
UF_long klu_zl_condest (UF_long *, double *, klu_l_symbolic *, klu_l_numeric *,
klu_l_common *) ;
int klu_zl_condest (int64_t *, double *, klu_l_symbolic *,
klu_l_numeric *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -617,11 +612,8 @@ int klu_z_rcond
klu_common *Common /* result in Common->rcond */
) ;
UF_long klu_l_rcond (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
UF_long klu_zl_rcond (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
int klu_l_rcond (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
int klu_zl_rcond (klu_l_symbolic *, klu_l_numeric *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
/* klu_scale */
@ -631,14 +623,14 @@ int klu_scale /* return TRUE if successful, FALSE otherwise */
(
/* inputs, not modified */
int scale, /* <0: none, no error check; 0: none, 1: sum, 2: max */
int n,
int Ap [ ], /* size n+1, column pointers */
int Ai [ ], /* size nz, row indices */
int32_t n,
int32_t Ap [ ], /* size n+1, column pointers */
int32_t Ai [ ], /* size nz, row indices */
double Ax [ ],
/* outputs, not defined on input */
double Rs [ ],
/* workspace, not defined on input or output */
int W [ ], /* size n, can be NULL */
int32_t W [ ], /* size n, can be NULL */
klu_common *Common
) ;
@ -646,22 +638,22 @@ int klu_z_scale /* return TRUE if successful, FALSE otherwise */
(
/* inputs, not modified */
int scale, /* <0: none, no error check; 0: none, 1: sum, 2: max */
int n,
int Ap [ ], /* size n+1, column pointers */
int Ai [ ], /* size nz, row indices */
int32_t n,
int32_t Ap [ ], /* size n+1, column pointers */
int32_t Ai [ ], /* size nz, row indices */
double Ax [ ],
/* outputs, not defined on input */
double Rs [ ],
/* workspace, not defined on input or output */
int W [ ], /* size n, can be NULL */
int32_t W [ ], /* size n, can be NULL */
klu_common *Common
) ;
UF_long klu_l_scale (UF_long, UF_long, UF_long *, UF_long *, double *,
double *, UF_long *, klu_l_common *) ;
int klu_l_scale (int, int64_t, int64_t *, int64_t *, double *,
double *, int64_t *, klu_l_common *) ;
UF_long klu_zl_scale (UF_long, UF_long, UF_long *, UF_long *, double *,
double *, UF_long *, klu_l_common *) ;
int klu_zl_scale (int, int64_t, int64_t *, int64_t *, double *,
double *, int64_t *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -677,36 +669,35 @@ int klu_extract /* returns TRUE if successful, FALSE otherwise */
/* outputs, either allocated on input, or ignored otherwise */
/* L */
int *Lp, /* size n+1 */
int *Li, /* size Numeric->lnz */
int32_t *Lp, /* size n+1 */
int32_t *Li, /* size Numeric->lnz */
double *Lx, /* size Numeric->lnz */
/* U */
int *Up, /* size n+1 */
int *Ui, /* size Numeric->unz */
int32_t *Up, /* size n+1 */
int32_t *Ui, /* size Numeric->unz */
double *Ux, /* size Numeric->unz */
/* F */
int *Fp, /* size n+1 */
int *Fi, /* size Numeric->nzoff */
int32_t *Fp, /* size n+1 */
int32_t *Fi, /* size Numeric->nzoff */
double *Fx, /* size Numeric->nzoff */
/* P, row permutation */
int *P, /* size n */
int32_t *P, /* size n */
/* Q, column permutation */
int *Q, /* size n */
int32_t *Q, /* size n */
/* Rs, scale factors */
double *Rs, /* size n */
/* R, block boundaries */
int *R, /* size Symbolic->nblocks+1 (nblocks is at most n) */
int32_t *R, /* size Symbolic->nblocks+1 (nblocks is at most n) */
klu_common *Common
) ;
/* Francesco - Extract only Udiag */
int klu_extract_Udiag /* returns TRUE if successful, FALSE otherwise */
(
@ -726,7 +717,6 @@ int klu_extract_Udiag /* returns TRUE if successful, FALSE otherwise */
klu_common *Common
) ;
int klu_z_extract /* returns TRUE if successful, FALSE otherwise */
(
/* inputs: */
@ -736,34 +726,34 @@ int klu_z_extract /* returns TRUE if successful, FALSE otherwise */
/* outputs, all of which must be allocated on input */
/* L */
int *Lp, /* size n+1 */
int *Li, /* size nnz(L) */
int32_t *Lp, /* size n+1 */
int32_t *Li, /* size nnz(L) */
double *Lx, /* size nnz(L) */
double *Lz, /* size nnz(L) for the complex case, ignored if real */
/* U */
int *Up, /* size n+1 */
int *Ui, /* size nnz(U) */
int32_t *Up, /* size n+1 */
int32_t *Ui, /* size nnz(U) */
double *Ux, /* size nnz(U) */
double *Uz, /* size nnz(U) for the complex case, ignored if real */
/* F */
int *Fp, /* size n+1 */
int *Fi, /* size nnz(F) */
int32_t *Fp, /* size n+1 */
int32_t *Fi, /* size nnz(F) */
double *Fx, /* size nnz(F) */
double *Fz, /* size nnz(F) for the complex case, ignored if real */
/* P, row permutation */
int *P, /* size n */
int32_t *P, /* size n */
/* Q, column permutation */
int *Q, /* size n */
int32_t *Q, /* size n */
/* Rs, scale factors */
double *Rs, /* size n */
/* R, block boundaries */
int *R, /* size Symbolic->nblocks+1 (nblocks is at most n) */
int32_t *R, /* size Symbolic->nblocks+1 (nblocks is at most n) */
klu_common *Common
) ;
@ -788,17 +778,19 @@ int klu_z_extract_Udiag /* returns TRUE if successful, FALSE otherwise */
klu_common *Common
) ;
UF_long klu_l_extract (klu_l_numeric *, klu_l_symbolic *,
UF_long *, UF_long *, double *,
UF_long *, UF_long *, double *,
UF_long *, UF_long *, double *,
UF_long *, UF_long *, double *, UF_long *, klu_l_common *) ;
int klu_l_extract (klu_l_numeric *, klu_l_symbolic *,
int64_t *, int64_t *, double *,
int64_t *, int64_t *, double *,
int64_t *, int64_t *, double *,
int64_t *, int64_t *, double *,
int64_t *, klu_l_common *) ;
UF_long klu_zl_extract (klu_l_numeric *, klu_l_symbolic *,
UF_long *, UF_long *, double *, double *,
UF_long *, UF_long *, double *, double *,
UF_long *, UF_long *, double *, double *,
UF_long *, UF_long *, double *, UF_long *, klu_l_common *) ;
int klu_zl_extract (klu_l_numeric *, klu_l_symbolic *,
int64_t *, int64_t *, double *, double *,
int64_t *, int64_t *, double *, double *,
int64_t *, int64_t *, double *, double *,
int64_t *, int64_t *, double *,
int64_t *, klu_l_common *) ;
/* -------------------------------------------------------------------------- */
@ -837,7 +829,9 @@ void *klu_realloc /* returns pointer to reallocated block */
) ;
void *klu_l_malloc (size_t, size_t, klu_l_common *) ;
void *klu_l_free (void *, size_t, size_t, klu_l_common *) ;
void *klu_l_realloc (size_t, size_t, size_t, void *, klu_l_common *) ;
int klu_print
@ -860,81 +854,6 @@ int klu_z_print
int *IntToExtColMap
) ;
int klu_constant_multiply
(
int *Ap,
double *Ax,
int n,
klu_common *Common,
double constant
) ;
int klu_z_constant_multiply
(
int *Ap,
double *Ax,
int n,
klu_common *Common,
double constant
) ;
int klu_matrix_vector_multiply
(
int *Ap, /* CSR */
int *Ai, /* CSR */
double *Ax, /* CSR */
double *RHS,
double *Solution,
int *IntToExtRowMap,
int *IntToExtColMap,
int n,
klu_common *Common
) ;
int klu_z_matrix_vector_multiply
(
int *Ap, /* CSR */
int *Ai, /* CSR */
double *Ax, /* CSR */
double *RHS,
double *Solution,
double *iRHS,
double *iSolution,
int *IntToExtRowMap,
int *IntToExtColMap,
int n,
klu_common *Common
) ;
int klu_convert_matrix_in_CSR
(
int *Ap_CSC, /* CSC */
int *Ai_CSC, /* CSC */
double *Ax_CSC, /* CSC */
int *Ap_CSR, /* CSR */
int *Ai_CSR, /* CSR */
double *Ax_CSR, /* CSR */
int n,
int nz,
klu_common *Common
) ;
int klu_z_convert_matrix_in_CSR
(
int *Ap_CSC, /* CSC */
int *Ai_CSC, /* CSC */
double *Ax_CSC, /* CSC */
int *Ap_CSR, /* CSR */
int *Ai_CSR, /* CSR */
double *Ax_CSR, /* CSR */
int n,
int nz,
klu_common *Common
) ;
typedef struct sBindElement {
double *COO ;
double *CSC ;
@ -996,6 +915,16 @@ typedef struct sKLUmatrix {
} KLUmatrix ;
//------------------------------------------------------------------------------
// klu_version: return KLU version
//------------------------------------------------------------------------------
void klu_version (int version [3]) ;
#ifdef __cplusplus
}
#endif
/* ========================================================================== */
/* === KLU version ========================================================== */
/* ========================================================================== */
@ -1014,14 +943,34 @@ typedef struct sKLUmatrix {
* #endif
*/
#define KLU_DATE "Dec 7, 2011"
#define KLU_VERSION_CODE(main,sub) ((main) * 1000 + (sub))
#define KLU_MAIN_VERSION 1
#define KLU_SUB_VERSION 1
#define KLU_SUBSUB_VERSION 3
#define KLU_VERSION KLU_VERSION_CODE(KLU_MAIN_VERSION,KLU_SUB_VERSION)
#define KLU_DATE "Oct 10, 2024"
#define KLU_MAIN_VERSION 2
#define KLU_SUB_VERSION 3
#define KLU_SUBSUB_VERSION 5
#ifdef __cplusplus
}
#define KLU_VERSION_CODE(main,sub) SUITESPARSE_VER_CODE(main,sub)
#define KLU_VERSION KLU_VERSION_CODE(2,3)
#define KLU__VERSION SUITESPARSE__VERCODE(2,3,5)
#if !defined (SUITESPARSE__VERSION) || \
(SUITESPARSE__VERSION < SUITESPARSE__VERCODE(7,8,3))
#error "KLU 2.3.5 requires SuiteSparse_config 7.8.3 or later"
#endif
#if !defined (AMD__VERSION) || \
(AMD__VERSION < SUITESPARSE__VERCODE(3,3,3))
#error "KLU 2.3.5 requires AMD 3.3.3 or later"
#endif
#if !defined (COLAMD__VERSION) || \
(COLAMD__VERSION < SUITESPARSE__VERCODE(3,3,4))
#error "KLU 2.3.5 requires COLAMD 3.3.4 or later"
#endif
#if !defined (BTF__VERSION) || \
(BTF__VERSION < SUITESPARSE__VERCODE(2,3,2))
#error "KLU 2.3.5 requires BTF 2.3.2 or later"
#endif
#endif

View File

@ -75,7 +75,8 @@ libKLU_la_SOURCES = \
klu_defaults.c \
klu_free_symbolic.c \
klu_memory.c \
klusmp.c
klusmp.c \
SuiteSparse_config.c
libKLU_la_LIBADD = \
libKLU_real.la \

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_1 =============================================================== */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_1: construct input matrix and then order with amd_2
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* AMD_1: Construct A+A' for a sparse matrix A and perform the AMD ordering.
*
@ -27,7 +26,7 @@
#include "amd_internal.h"
GLOBAL void AMD_1
void AMD_1
(
Int n, /* n > 0 */
const Int Ap [ ], /* input of size n+1, not modified */

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_2 =============================================================== */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_2: AMD ordering
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* 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
@ -40,7 +39,7 @@ static Int clear_flag (Int wflg, Int wbig, Int W [ ], Int n)
/* === AMD_2 =============================================================== */
/* ========================================================================= */
GLOBAL void AMD_2
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 */
@ -120,9 +119,9 @@ GLOBAL void AMD_2
* ouput. Many of these functions are also provided by the Fortran
* Harwell Subroutine Library routine MC47A.
*
* (6) both int and UF_long versions are provided. In the descriptions below
* and integer is and int or UF_long depending on which version is
* being used.
* (6) both int32_t and int64_t versions are provided. In the
* descriptions below an integer is int32_t or int64_t depending
* on which version is being used.
**********************************************************************
***** CAUTION: ARGUMENTS ARE NOT CHECKED FOR ERRORS ON INPUT. ******
@ -463,7 +462,7 @@ GLOBAL void AMD_2
nvi, nvj, nvpiv, slenme, wbig, we, wflg, wnvi, ok, ndense, ncmpa,
dense, aggressive ;
unsigned Int hash ; /* unsigned, so that hash % n is well defined.*/
UInt hash ; /* unsigned, so that hash % n is well defined.*/
/*
* deg: the degree of a variable or element
@ -495,8 +494,9 @@ GLOBAL void AMD_2
* 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, UF_long_max - n for the
* UF_long version. wflg is not allowed to be >= wbig.
* wbig: = (INT32_MAX - n) for the int32_t version, (INT64_MAX - n)
* for the int64_t 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]
@ -546,7 +546,7 @@ GLOBAL void AMD_2
* 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:
* p4:
* pdst: destination pointer, for compression
* pend: end of memory to compress
* pj: pointer into an element or variable

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_aat ============================================================= */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_aat: compute symmetry of A and nnz in each column of A+A'
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* 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
@ -18,7 +17,7 @@
#include "amd_internal.h"
GLOBAL size_t AMD_aat /* returns nz in A+A' */
size_t AMD_aat /* returns nz in A+A' */
(
Int n,
const Int Ap [ ],

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_control ========================================================= */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_control: print control parameters for AMD
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* User-callable. Prints the control parameters for AMD. See amd.h
* for details. If the Control array is not present, the defaults are
@ -16,7 +15,7 @@
#include "amd_internal.h"
GLOBAL void AMD_control
void AMD_control
(
double Control [ ]
)
@ -35,17 +34,18 @@ GLOBAL void AMD_control
aggressive = AMD_DEFAULT_AGGRESSIVE ;
}
PRINTF (("\nAMD version %d.%d.%d, %s: approximate minimum degree ordering\n"
SUITESPARSE_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")) ;
SUITESPARSE_PRINTF ((" no rows treated as dense\n")) ;
}
else
{
PRINTF ((
SUITESPARSE_PRINTF ((
" (rows with more than max (%g * sqrt (n), 16) entries are\n"
" considered \"dense\", and placed last in output permutation)\n",
alpha)) ;
@ -53,12 +53,12 @@ GLOBAL void AMD_control
if (aggressive)
{
PRINTF ((" aggressive absorption: yes\n")) ;
SUITESPARSE_PRINTF ((" aggressive absorption: yes\n")) ;
}
else
{
PRINTF ((" aggressive absorption: no\n")) ;
SUITESPARSE_PRINTF ((" aggressive absorption: no\n")) ;
}
PRINTF ((" size of AMD integer: %d\n\n", sizeof (Int))) ;
SUITESPARSE_PRINTF ((" size of AMD integer: %d\n\n", sizeof (Int))) ;
}

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_defaults ======================================================== */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_defaults: set defaults for AMD
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* User-callable. Sets default control parameters for AMD. See amd.h
* for details.
@ -19,7 +18,7 @@
/* === AMD defaults ======================================================== */
/* ========================================================================= */
GLOBAL void AMD_defaults
void AMD_defaults
(
double Control [ ]
)

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_dump ============================================================ */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_dump: debug routines for AMD
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* 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
@ -19,7 +18,7 @@
#ifndef NDEBUG
/* This global variable is present only when debugging */
GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */
Int AMD_debug = -999 ; /* default is no debug printing */
/* ========================================================================= */
/* === AMD_debug_init ====================================================== */
@ -27,7 +26,7 @@ GLOBAL Int AMD_debug = -999 ; /* default is no debug printing */
/* Sets the debug print level, by reading the file debug.amd (if it exists) */
GLOBAL void AMD_debug_init ( char *s )
void AMD_debug_init ( char *s )
{
FILE *f ;
f = fopen ("debug.amd", "r") ;
@ -54,7 +53,7 @@ GLOBAL void AMD_debug_init ( char *s )
* cannot be called when the hash buckets are non-empty.
*/
GLOBAL void AMD_dump (
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]

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_info ============================================================ */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_info: print output statistics for AMD
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* User-callable. Prints the output statistics for AMD. See amd.h
* for details. If the Info array is not present, nothing is printed.
@ -15,16 +14,16 @@
#include "amd_internal.h"
#define PRI(format,x) { if (x >= 0) { PRINTF ((format, x)) ; }}
#define PRI(format,x) { if (x >= 0) { SUITESPARSE_PRINTF ((format, x)) ; }}
GLOBAL void AMD_info
void AMD_info
(
double Info [ ]
)
{
double n, ndiv, nmultsubs_ldl, nmultsubs_lu, lnz, lnzd ;
PRINTF (("\nAMD version %d.%d.%d, %s, results:\n",
SUITESPARSE_PRINTF (("\nAMD version %d.%d.%d, %s, results:\n",
AMD_MAIN_VERSION, AMD_SUB_VERSION, AMD_SUBSUB_VERSION, AMD_DATE)) ;
if (!Info)
@ -40,26 +39,26 @@ GLOBAL void AMD_info
lnzd = (n >= 0 && lnz >= 0) ? (n + lnz) : (-1) ;
/* AMD return status */
PRINTF ((" status: ")) ;
SUITESPARSE_PRINTF ((" status: ")) ;
if (Info [AMD_STATUS] == AMD_OK)
{
PRINTF (("OK\n")) ;
SUITESPARSE_PRINTF (("OK\n")) ;
}
else if (Info [AMD_STATUS] == AMD_OUT_OF_MEMORY)
{
PRINTF (("out of memory\n")) ;
SUITESPARSE_PRINTF (("out of memory\n")) ;
}
else if (Info [AMD_STATUS] == AMD_INVALID)
{
PRINTF (("invalid matrix\n")) ;
SUITESPARSE_PRINTF (("invalid matrix\n")) ;
}
else if (Info [AMD_STATUS] == AMD_OK_BUT_JUMBLED)
{
PRINTF (("OK, but jumbled\n")) ;
SUITESPARSE_PRINTF (("OK, but jumbled\n")) ;
}
else
{
PRINTF (("unknown\n")) ;
SUITESPARSE_PRINTF (("unknown\n")) ;
}
/* statistics about the input matrix */
@ -82,7 +81,7 @@ GLOBAL void AMD_info
Info [AMD_NCMPA]) ;
/* statistics about the ordering quality */
PRINTF (("\n"
SUITESPARSE_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"
@ -105,7 +104,7 @@ GLOBAL void AMD_info
if (n >= 0 && ndiv >= 0 && nmultsubs_ldl >= 0 && nmultsubs_lu >= 0)
{
PRINTF (("\n"
SUITESPARSE_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"

View File

@ -1,31 +1,16 @@
/* ========================================================================= */
/* === amd_internal.h ====================================================== */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Include/amd_internal.h: internal definitions for AMD
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2023, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* 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.
*/
/* ========================================================================= */
@ -52,38 +37,10 @@
#define NDEBUG
#endif
/*
To enable debugging, uncomment the following line:
#undef NDEBUG
*/
// To enable debugging, uncomment the following line:
// #undef NDEBUG
/* ------------------------------------------------------------------------- */
/* ANSI include files */
/* ------------------------------------------------------------------------- */
/* from stdlib.h: size_t, malloc, free, realloc, and calloc */
#include <stdlib.h>
#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 <stdio.h>
#endif
/* from limits.h: INT_MAX and LONG_MAX */
#include <limits.h>
/* from math.h: sqrt */
#include <math.h>
/* ------------------------------------------------------------------------- */
/* MATLAB include files (only if being used in or via MATLAB) */
/* ------------------------------------------------------------------------- */
#ifdef MATLAB_MEX_FILE
#include "matrix.h"
#include "mex.h"
#endif
#include "ngspice/amd.h"
/* ------------------------------------------------------------------------- */
/* basic definitions */
@ -105,13 +62,7 @@
#undef EMPTY
#endif
#ifdef GLOBAL
#undef GLOBAL
#endif
#ifdef PRIVATE
#undef PRIVATE
#endif
#define PRIVATE static
/* 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
@ -139,36 +90,28 @@
#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 UF_long */
/* integer type for AMD: int32_t or int64_t */
/* ------------------------------------------------------------------------- */
/* define UF_long */
#include "ngspice/UFconfig.h"
#if defined (DLONG) || defined (ZLONG)
#define Int UF_long
#define ID UF_long_id
#define Int_MAX UF_long_max
#define Int int64_t
#define UInt uint64_t
#define ID "%" PRId64
#define Int_MAX INT64_MAX
#define AMD_order amd_l_order
#define AMD_defaults amd_l_defaults
@ -187,9 +130,10 @@
#else
#define Int int
#define Int int32_t
#define UInt uint32_t
#define ID "%d"
#define Int_MAX INT_MAX
#define Int_MAX INT32_MAX
#define AMD_order amd_order
#define AMD_defaults amd_defaults
@ -208,24 +152,11 @@
#endif
/* ========================================================================= */
/* === PRINTF macro ======================================================== */
/* ========================================================================= */
/* All output goes through the PRINTF macro. */
#define PRINTF(params) { if (amd_printf != NULL) (void) amd_printf params ; }
/* ------------------------------------------------------------------------- */
/* AMD routine definitions (user-callable) */
/* ------------------------------------------------------------------------- */
#include "ngspice/amd.h"
/* ------------------------------------------------------------------------- */
/* AMD routine definitions (not user-callable) */
/* ------------------------------------------------------------------------- */
GLOBAL size_t AMD_aat
size_t AMD_aat
(
Int n,
const Int Ap [ ],
@ -235,7 +166,7 @@ GLOBAL size_t AMD_aat
double Info [ ]
) ;
GLOBAL void AMD_1
void AMD_1
(
Int n,
const Int Ap [ ],
@ -249,7 +180,7 @@ GLOBAL void AMD_1
double Info [ ]
) ;
GLOBAL void AMD_postorder
void AMD_postorder
(
Int nn,
Int Parent [ ],
@ -261,7 +192,7 @@ GLOBAL void AMD_postorder
Int Stack [ ]
) ;
GLOBAL Int AMD_post_tree
Int AMD_post_tree
(
Int root,
Int k,
@ -274,7 +205,7 @@ GLOBAL Int AMD_post_tree
#endif
) ;
GLOBAL void AMD_preprocess
void AMD_preprocess
(
Int n,
const Int Ap [ ],
@ -294,15 +225,11 @@ GLOBAL void AMD_preprocess
/* from assert.h: assert macro */
#include <assert.h>
#ifndef EXTERN
#define EXTERN extern
#endif
extern Int AMD_debug ;
EXTERN Int AMD_debug ;
void AMD_debug_init ( char *s ) ;
GLOBAL void AMD_debug_init ( char *s ) ;
GLOBAL void AMD_dump
void AMD_dump
(
Int n,
Int Pe [ ],
@ -331,11 +258,11 @@ GLOBAL void AMD_dump
#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) ; }
#define AMD_DEBUG0(params) { SUITESPARSE_PRINTF (params) ; }
#define AMD_DEBUG1(params) { if (AMD_debug >= 1) SUITESPARSE_PRINTF (params) ; }
#define AMD_DEBUG2(params) { if (AMD_debug >= 2) SUITESPARSE_PRINTF (params) ; }
#define AMD_DEBUG3(params) { if (AMD_debug >= 3) SUITESPARSE_PRINTF (params) ; }
#define AMD_DEBUG4(params) { if (AMD_debug >= 4) SUITESPARSE_PRINTF (params) ; }
#else

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_order =========================================================== */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_order: user-callable AMD ordering method
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* User-callable AMD minimum degree ordering routine. See amd.h for
* documentation.
@ -19,7 +18,7 @@
/* === AMD_order =========================================================== */
/* ========================================================================= */
GLOBAL Int AMD_order
int AMD_order
(
Int n,
const Int Ap [ ],
@ -72,9 +71,9 @@ GLOBAL Int AMD_order
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))
/* check if n or nz will cause integer overflow */
if (((size_t) n) >= Int_MAX / sizeof (Int)
|| ((size_t) nz) >= Int_MAX / sizeof (Int))
{
if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ;
return (AMD_OUT_OF_MEMORY) ; /* problem too large */
@ -90,15 +89,16 @@ GLOBAL Int AMD_order
}
/* allocate two size-n integer workspaces */
Len = amd_malloc (n * sizeof (Int)) ;
Pinv = amd_malloc (n * sizeof (Int)) ;
size_t nn = (size_t) n ;
Len = SuiteSparse_malloc (nn, sizeof (Int)) ;
Pinv = SuiteSparse_malloc (nn, sizeof (Int)) ;
mem += n ;
mem += n ;
if (!Len || !Pinv)
{
/* :: out of memory :: */
amd_free (Len) ;
amd_free (Pinv) ;
SuiteSparse_free (Len) ;
SuiteSparse_free (Pinv) ;
if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ;
return (AMD_OUT_OF_MEMORY) ;
}
@ -107,17 +107,17 @@ GLOBAL Int AMD_order
{
/* 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)) ;
Rp = SuiteSparse_malloc (nn+1, sizeof (Int)) ;
Ri = SuiteSparse_malloc (nz, 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) ;
SuiteSparse_free (Rp) ;
SuiteSparse_free (Ri) ;
SuiteSparse_free (Len) ;
SuiteSparse_free (Pinv) ;
if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ;
return (AMD_OUT_OF_MEMORY) ;
}
@ -153,24 +153,23 @@ GLOBAL Int AMD_order
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 */
ok = ((slen + nn) > slen) ; /* check for size_t overflow */
slen += nn ; /* 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)) ;
S = SuiteSparse_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) ;
SuiteSparse_free (Rp) ;
SuiteSparse_free (Ri) ;
SuiteSparse_free (Len) ;
SuiteSparse_free (Pinv) ;
if (info) Info [AMD_STATUS] = AMD_OUT_OF_MEMORY ;
return (AMD_OUT_OF_MEMORY) ;
}
@ -190,11 +189,11 @@ GLOBAL Int AMD_order
/* free the workspace */
/* --------------------------------------------------------------------- */
amd_free (Rp) ;
amd_free (Ri) ;
amd_free (Len) ;
amd_free (Pinv) ;
amd_free (S) ;
SuiteSparse_free (Rp) ;
SuiteSparse_free (Ri) ;
SuiteSparse_free (Len) ;
SuiteSparse_free (Pinv) ;
SuiteSparse_free (S) ;
if (info) Info [AMD_STATUS] = status ;
return (status) ; /* successful ordering */
}

View File

@ -1,19 +1,18 @@
/* ========================================================================= */
/* === AMD_post_tree ======================================================= */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_post_tree: post-ordering of a single etree
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* Post-ordering of a supernodal elimination tree. */
#include "amd_internal.h"
GLOBAL Int AMD_post_tree
Int AMD_post_tree
(
Int root, /* root of the tree */
Int k, /* start numbering at k */
@ -42,7 +41,7 @@ GLOBAL Int AMD_post_tree
/* recursive version (Stack [ ] is not used): */
/* --------------------------------------------------------------------- */
/* this is simple, but can caouse stack overflow if nn is large */
/* this is simple, but can cause stack overflow if nn is large */
i = root ;
for (f = Child [i] ; f != EMPTY ; f = Sibling [f])
{

View File

@ -1,19 +1,18 @@
/* ========================================================================= */
/* === AMD_postorder ======================================================= */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_postorder: post-order the assembly tree from AMD
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* Perform a postordering (via depth-first search) of an assembly tree. */
#include "amd_internal.h"
GLOBAL void AMD_postorder
void AMD_postorder
(
/* inputs, not modified on output: */
Int nn, /* nodes are in the range 0..nn-1 */

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_preprocess ====================================================== */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_preprocess: sort, remove duplicates, transpose a matrix
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* 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
@ -19,15 +18,11 @@
#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
void AMD_preprocess
(
Int n, /* input matrix: A is n-by-n */
const Int Ap [ ], /* size n+1 */

View File

@ -1,13 +1,12 @@
/* ========================================================================= */
/* === AMD_valid =========================================================== */
/* ========================================================================= */
//------------------------------------------------------------------------------
// AMD/Source/amd_valid: check if a matrix is valid for AMD
//------------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */
/* AMD, Copyright (c) Timothy A. Davis, */
/* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
/* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
/* web: http://www.cise.ufl.edu/research/sparse/amd */
/* ------------------------------------------------------------------------- */
// AMD, Copyright (c) 1996-2022, Timothy A. Davis, Patrick R. Amestoy, and
// Iain S. Duff. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* 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
@ -36,7 +35,7 @@
#include "amd_internal.h"
GLOBAL Int AMD_valid
int AMD_valid
(
/* inputs, not modified on output: */
Int n_row, /* A is n_row-by-n_col */
@ -45,7 +44,8 @@ GLOBAL Int AMD_valid
const Int Ai [ ] /* row indices of A, of size nz = Ap [n_col] */
)
{
Int nz, j, p1, p2, ilast, i, p, result = AMD_OK ;
Int nz, j, p1, p2, ilast, i, p ;
int result = AMD_OK ;
if (n_row < 0 || n_col < 0 || Ap == NULL || Ai == NULL)
{

View File

@ -1,23 +1,24 @@
/* ========================================================================== */
/* === btf_internal include file ============================================ */
/* ========================================================================== */
//------------------------------------------------------------------------------
// BTF/Include/btf_internsl.h: internal include file for BTF
//------------------------------------------------------------------------------
// BTF, Copyright (c) 2004-2023, University of Florida. All Rights Reserved.
// Author: Timothy A. Davis.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
#ifndef _BTF_INTERNAL_H
#define _BTF_INTERNAL_H
/*
* Copyright (c) 2004-2007. Tim Davis, University of Florida,
* with support from Sandia National Laboratories. All Rights Reserved.
*/
/* Not to be included in any user program. */
#ifdef DLONG
#define Int UF_long
#define Int_id UF_long_id
#define Int int64_t
#define Int_id "%" PRId64
#define BTF(name) btf_l_ ## name
#else
#define Int int
#define Int int32_t
#define Int_id "%d"
#define BTF(name) btf_ ## name
#endif
@ -32,10 +33,10 @@
#define NPRINT
#endif
/* To enable debugging and assertions, uncomment this line:
/* To enable debugging and assertions, uncomment this line:
#undef NDEBUG
*/
/* To enable diagnostic printing, uncomment this line:
/* To enable diagnostic printing, uncomment this line:
#undef NPRINT
*/

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === BTF_ORDER ============================================================ */
/* ========================================================================== */
//------------------------------------------------------------------------------
// BTF/Source/btf_order: permute a matrix to block triangular form
//------------------------------------------------------------------------------
// BTF, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Author: Timothy A. Davis.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Find a permutation P and Q to permute a square sparse matrix into upper block
* triangular form. A(P,Q) will contain a zero-free diagonal if A has
@ -21,9 +27,6 @@
* might not be equal to the structural rank.
*
* See btf.h for more details.
*
* Copyright (c) 2004-2007. Tim Davis, University of Florida,
* with support from Sandia National Laboratories. All Rights Reserved.
*/
#include "ngspice/btf.h"

View File

@ -1,13 +1,16 @@
/* ========================================================================== */
/* === BTF_STRONGCOMP ======================================================= */
/* ========================================================================== */
//------------------------------------------------------------------------------
// BTF/Source/btf_strongcomp: strongly connected components
//------------------------------------------------------------------------------
// BTF, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Author: Timothy A. Davis.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Finds the strongly connected components of a graph, or equivalently, permutes
* the matrix into upper block triangular form. See btf.h for more details.
* Input matrix and Q are not checked on input.
*
* Copyright (c) 2004-2007. Tim Davis, University of Florida,
* with support from Sandia National Laboratories. All Rights Reserved.
*/
#include "ngspice/btf.h"

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === colamd/symamd - a sparse matrix column ordering algorithm ============ */
/* ========================================================================== */
//------------------------------------------------------------------------------
// COLAMD/Source/colamd.c: column approximate minimum degree ordering
//------------------------------------------------------------------------------
// COLAMD, Copyright (c) 1998-2022, Timothy A. Davis and Stefan Larimore,
// All Rights Reserved.
// SPDX-License-Identifier: BSD-3-clause
//------------------------------------------------------------------------------
/* COLAMD / SYMAMD
@ -30,12 +36,12 @@
floating point operations than A. Symamd constructs a matrix M such
that M'M has the same nonzero pattern of A, and then orders the columns
of M using colmmd. The column ordering of M is then returned as the
row and column ordering P of A.
row and column ordering P of A.
Authors:
The authors of the code itself are Stefan I. Larimore and Timothy A.
Davis (davis at cise.ufl.edu), University of Florida. The algorithm was
Davis (DrTimothyAldenDavis@gmail.com). The algorithm was
developed in collaboration with John Gilbert, Xerox PARC, and Esmond
Ng, Oak Ridge National Laboratory.
@ -46,44 +52,15 @@
Copyright and License:
Copyright (c) 1998-2007, Timothy A. Davis, All Rights Reserved.
Copyright (c) 1998-2022, Timothy A. Davis, All Rights Reserved.
COLAMD is also available under alternate licenses, contact T. Davis
for details.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
Permission is hereby granted to use or copy this program under the
terms of the GNU LGPL, provided that the Copyright, this License,
and the Availability of the original version is retained on all copies.
User documentation of any code that uses this code or any modified
version of this code must cite the Copyright, this License, the
Availability note, and "Used by permission." Permission to modify
the code and to distribute modified code is granted, provided the
Copyright, this License, and the Availability note are retained,
and a notice that the code was modified is included.
See COLAMD/Doc/License.txt for the license.
Availability:
The colamd/symamd library is available at
http://www.cise.ufl.edu/research/sparse/colamd/
This is the http://www.cise.ufl.edu/research/sparse/colamd/colamd.c
file. It requires the colamd.h file. It is required by the colamdmex.c
and symamdmex.c files, for the MATLAB interface to colamd and symamd.
The colamd/symamd library is available at http://www.suitesparse.com
Appears as ACM Algorithm 836.
See the ChangeLog file for changes since Version 1.0.
@ -105,9 +82,9 @@
/* === Description of user-callable routines ================================ */
/* ========================================================================== */
/* COLAMD includes both int and UF_long versions of all its routines. The
* description below is for the int version. For UF_long, all int arguments
* become UF_long. UF_long is normally defined as long, except for WIN64.
/* COLAMD includes both int32_t and int64_t versions of all its routines.
The description below is for the int32_t version. For int64_t, all
int32_t arguments become int64_t.
----------------------------------------------------------------------------
colamd_recommended:
@ -116,9 +93,9 @@
C syntax:
#include "colamd.h"
size_t colamd_recommended (int nnz, int n_row, int n_col) ;
size_t colamd_l_recommended (UF_long nnz, UF_long n_row,
UF_long n_col) ;
size_t colamd_recommended (int32_t nnz, int32_t n_row, int32_t n_col) ;
size_t colamd_l_recommended (int64_t nnz,
int64_t n_row, int64_t n_col) ;
Purpose:
@ -127,19 +104,16 @@
is optional. Not needed for symamd, which dynamically allocates
its own memory.
Note that in v2.4 and earlier, these routines returned int or long.
They now return a value of type size_t.
Arguments (all input arguments):
int nnz ; Number of nonzeros in the matrix A. This must
int32_t nnz ; Number of nonzeros in the matrix A. This must
be the same value as p [n_col] in the call to
colamd - otherwise you will get a wrong value
of the recommended memory to use.
int n_row ; Number of rows in the matrix A.
int32_t n_row ; Number of rows in the matrix A.
int n_col ; Number of columns in the matrix A.
int32_t n_col ; Number of columns in the matrix A.
----------------------------------------------------------------------------
colamd_set_defaults:
@ -168,7 +142,7 @@
entries are removed prior to ordering. Columns with more than
max (16, knobs [COLAMD_DENSE_COL] * sqrt (MIN (n_row,n_col)))
entries are removed prior to
ordering, and placed last in the output column ordering.
ordering, and placed last in the output column ordering.
Symamd: uses only knobs [COLAMD_DENSE_ROW], which is knobs [0].
Rows and columns with more than
@ -199,11 +173,12 @@
C syntax:
#include "colamd.h"
int colamd (int n_row, int n_col, int Alen, int *A, int *p,
double knobs [COLAMD_KNOBS], int stats [COLAMD_STATS]) ;
UF_long colamd_l (UF_long n_row, UF_long n_col, UF_long Alen,
UF_long *A, UF_long *p, double knobs [COLAMD_KNOBS],
UF_long stats [COLAMD_STATS]) ;
int colamd (int32_t n_row, int32_t n_col, int32_t Alen, int32_t *A, int32_t *p,
double knobs [COLAMD_KNOBS], int32_t stats [COLAMD_STATS]) ;
int colamd_l (int64_t n_row,
int64_t n_col, int64_t Alen,
int64_t *A, int64_t *p, double knobs
[COLAMD_KNOBS], int64_t stats [COLAMD_STATS]) ;
Purpose:
@ -211,26 +186,26 @@
(AQ)'AQ=LL' have less fill-in and require fewer floating point
operations than factorizing the unpermuted matrix A or A'A,
respectively.
Returns:
TRUE (1) if successful, FALSE (0) otherwise.
Arguments:
int n_row ; Input argument.
int32_t n_row ; Input argument.
Number of rows in the matrix A.
Restriction: n_row >= 0.
Colamd returns FALSE if n_row is negative.
int n_col ; Input argument.
int32_t n_col ; Input argument.
Number of columns in the matrix A.
Restriction: n_col >= 0.
Colamd returns FALSE if n_col is negative.
int Alen ; Input argument.
int32_t Alen ; Input argument.
Restriction (see note):
Alen >= 2*nnz + 6*(n_col+1) + 4*(n_row+1) + n_col
@ -246,7 +221,7 @@
for integer overflow, and thus is not recommended. Use
the colamd_recommended routine instead.
int A [Alen] ; Input argument, undefined on output.
int32_t A [Alen] ; Input argument, undefined on output.
A is an integer array of size Alen. Alen must be at least as
large as the bare minimum value given above, but this is very
@ -270,7 +245,7 @@
The contents of A are modified during ordering, and are
undefined on output.
int p [n_col+1] ; Both input and output argument.
int32_t p [n_col+1] ; Both input and output argument.
p is an integer array of size n_col+1. On input, it holds the
"pointers" for the column form of the matrix A. Column c of
@ -294,7 +269,7 @@
See colamd_set_defaults for a description.
int stats [COLAMD_STATS] ; Output argument.
int32_t stats [COLAMD_STATS] ; Output argument.
Statistics on the ordering, and error status.
See colamd.h for related definitions.
@ -378,9 +353,8 @@
Future versions may return more statistics in the stats array.
Example:
See http://www.cise.ufl.edu/research/sparse/colamd/example.c
for a complete example.
See colamd_example.c for a complete example.
To order the columns of a 5-by-4 matrix with 11 nonzero entries in
the following nonzero pattern
@ -395,9 +369,9 @@
#include "colamd.h"
#define ALEN 100
int A [ALEN] = {0, 1, 4, 2, 4, 0, 1, 2, 3, 1, 3} ;
int p [ ] = {0, 3, 5, 9, 11} ;
int stats [COLAMD_STATS] ;
int32_t A [ALEN] = {0, 1, 4, 2, 4, 0, 1, 2, 3, 1, 3} ;
int32_t p [ ] = {0, 3, 5, 9, 11} ;
int32_t stats [COLAMD_STATS] ;
colamd (5, 4, ALEN, A, p, (double *) NULL, stats) ;
The permutation is returned in the array p, and A is destroyed.
@ -409,12 +383,13 @@
C syntax:
#include "colamd.h"
int symamd (int n, int *A, int *p, int *perm,
double knobs [COLAMD_KNOBS], int stats [COLAMD_STATS],
void (*allocate) (size_t, size_t), void (*release) (void *)) ;
UF_long symamd_l (UF_long n, UF_long *A, UF_long *p, UF_long *perm,
double knobs [COLAMD_KNOBS], UF_long stats [COLAMD_STATS],
int symamd (int32_t n, int32_t *A, int32_t *p, int32_t *perm,
double knobs [COLAMD_KNOBS], int32_t stats [COLAMD_STATS],
void (*allocate) (size_t, size_t), void (*release) (void *)) ;
int symamd_l (int64_t n, int64_t *A,
int64_t *p, int64_t *perm, double knobs
[COLAMD_KNOBS], int64_t stats [COLAMD_STATS], void
(*allocate) (size_t, size_t), void (*release) (void *)) ;
Purpose:
@ -433,21 +408,21 @@
Arguments:
int n ; Input argument.
int32_t n ; Input argument.
Number of rows and columns in the symmetrix matrix A.
Restriction: n >= 0.
Symamd returns FALSE if n is negative.
int A [nnz] ; Input argument.
int32_t A [nnz] ; Input argument.
A is an integer array of size nnz, where nnz = p [n].
The row indices of the entries in column c of the matrix are
held in A [(p [c]) ... (p [c+1]-1)]. The row indices in a
given column c need not be in ascending order, and duplicate
row indices may be present. However, symamd will run faster
if the columns are in sorted order with no duplicate entries.
if the columns are in sorted order with no duplicate entries.
The matrix is 0-based. That is, rows are in the range 0 to
n-1, and columns are in the range 0 to n-1. Symamd
@ -455,7 +430,7 @@
The contents of A are not modified.
int p [n+1] ; Input argument.
int32_t p [n+1] ; Input argument.
p is an integer array of size n+1. On input, it holds the
"pointers" for the column form of the matrix A. Column c of
@ -467,7 +442,7 @@
The contents of p are not modified.
int perm [n+1] ; Output argument.
int32_t perm [n+1] ; Output argument.
On output, if symamd returns TRUE, the array perm holds the
permutation P, where perm [0] is the first index in the new
@ -482,14 +457,14 @@
See colamd_set_defaults for a description.
int stats [COLAMD_STATS] ; Output argument.
int32_t stats [COLAMD_STATS] ; Output argument.
Statistics on the ordering, and error status.
See colamd.h for related definitions.
Symamd returns FALSE if stats is not present.
stats [0]: number of dense or empty row and columns ignored
(and ordered last in the output permutation
(and ordered last in the output permutation
perm). Note that a row/column can become
"empty" if it contains only "dense" and/or
"empty" columns/rows.
@ -580,8 +555,8 @@
C syntax:
#include "colamd.h"
colamd_report (int stats [COLAMD_STATS]) ;
colamd_l_report (UF_long stats [COLAMD_STATS]) ;
colamd_report (int32_t stats [COLAMD_STATS]) ;
colamd_l_report (int64_t stats [COLAMD_STATS]) ;
Purpose:
@ -591,7 +566,7 @@
Arguments:
int stats [COLAMD_STATS] ; Input only. Statistics from colamd.
int32_t stats [COLAMD_STATS] ; Input only. Statistics from colamd.
----------------------------------------------------------------------------
@ -601,8 +576,8 @@
C syntax:
#include "colamd.h"
symamd_report (int stats [COLAMD_STATS]) ;
symamd_l_report (UF_long stats [COLAMD_STATS]) ;
symamd_report (int32_t stats [COLAMD_STATS]) ;
symamd_l_report (int64_t stats [COLAMD_STATS]) ;
Purpose:
@ -612,7 +587,7 @@
Arguments:
int stats [COLAMD_STATS] ; Input only. Statistics from symamd.
int32_t stats [COLAMD_STATS] ; Input only. Statistics from symamd.
*/
@ -664,34 +639,21 @@
/* ========================================================================== */
#include "ngspice/colamd.h"
#include <limits.h>
#include <math.h>
#ifdef MATLAB_MEX_FILE
#include "mex.h"
#include "matrix.h"
#endif /* MATLAB_MEX_FILE */
#if !defined (NPRINT) || !defined (NDEBUG)
#include <stdio.h>
#endif
#ifndef NULL
#define NULL ((void *) 0)
#endif
/* ========================================================================== */
/* === int or UF_long ======================================================= */
/* === int32_t or int64_t ============================================== */
/* ========================================================================== */
/* define UF_long */
#include "ngspice/UFconfig.h"
#ifdef DLONG
#define Int UF_long
#define ID UF_long_id
#define Int_MAX UF_long_max
#define Int int64_t
#define UInt uint64_t
#define ID "%" PRId64
#define Int_MAX INT64_MAX
#define COLAMD_recommended colamd_l_recommended
#define COLAMD_set_defaults colamd_l_set_defaults
@ -702,9 +664,10 @@
#else
#define Int int
#define Int int32_t
#define UInt uint32_t
#define ID "%d"
#define Int_MAX INT_MAX
#define Int_MAX INT32_MAX
#define COLAMD_recommended colamd_recommended
#define COLAMD_set_defaults colamd_set_defaults
@ -776,9 +739,8 @@ typedef struct Colamd_Row_struct
/* === Definitions ========================================================== */
/* ========================================================================== */
/* Routines are either PUBLIC (user-callable) or PRIVATE (not user-callable) */
#define PUBLIC
#define PRIVATE static
/* Routines are either user-callable or PRIVATE (not user-callable) */
#define PRIVATE static
#define DENSE_DEGREE(alpha,n) \
((Int) MAX (16.0, (alpha) * sqrt ((double) (n))))
@ -789,7 +751,7 @@ typedef struct Colamd_Row_struct
#define ONES_COMPLEMENT(r) (-(r)-1)
/* -------------------------------------------------------------------------- */
/* Change for version 2.1: define TRUE and FALSE only if not yet defined */
/* Change for version 2.1: define TRUE and FALSE only if not yet defined */
/* -------------------------------------------------------------------------- */
#ifndef TRUE
@ -835,9 +797,6 @@ typedef struct Colamd_Row_struct
#define INDEX(i) (i)
#endif
/* All output goes through the PRINTF macro. */
#define PRINTF(params) { if (colamd_printf != NULL) (void) colamd_printf params ; }
/* ========================================================================== */
/* === Prototypes of PRIVATE routines ======================================= */
/* ========================================================================== */
@ -941,11 +900,11 @@ PRIVATE void print_report
PRIVATE Int colamd_debug = 0 ; /* debug print level */
#define DEBUG0(params) { PRINTF (params) ; }
#define DEBUG1(params) { if (colamd_debug >= 1) PRINTF (params) ; }
#define DEBUG2(params) { if (colamd_debug >= 2) PRINTF (params) ; }
#define DEBUG3(params) { if (colamd_debug >= 3) PRINTF (params) ; }
#define DEBUG4(params) { if (colamd_debug >= 4) PRINTF (params) ; }
#define DEBUG0(params) { SUITESPARSE_PRINTF (params) ; }
#define DEBUG1(params) { if (colamd_debug >= 1) SUITESPARSE_PRINTF (params) ; }
#define DEBUG2(params) { if (colamd_debug >= 2) SUITESPARSE_PRINTF (params) ; }
#define DEBUG3(params) { if (colamd_debug >= 3) SUITESPARSE_PRINTF (params) ; }
#define DEBUG4(params) { if (colamd_debug >= 4) SUITESPARSE_PRINTF (params) ; }
#ifdef MATLAB_MEX_FILE
#define ASSERT(expression) (mxAssert ((expression), ""))
@ -1062,7 +1021,7 @@ static size_t t_mult (size_t a, size_t k, int *ok)
((t_mult (t_add (n_row, 1, ok), sizeof (Colamd_Row), ok) / sizeof (Int)))
PUBLIC size_t COLAMD_recommended /* returns recommended value of Alen. */
size_t COLAMD_recommended /* returns recommended value of Alen. */
(
/* === Parameters ======================================================= */
@ -1084,11 +1043,9 @@ PUBLIC size_t COLAMD_recommended /* returns recommended value of Alen. */
s = t_add (s, r, &ok) ;
s = t_add (s, n_col, &ok) ; /* elbow room */
s = t_add (s, nnz/5, &ok) ; /* elbow room */
ok = ok && (s < Int_MAX) ;
return (ok ? s : 0) ;
}
/* ========================================================================== */
/* === colamd_set_defaults ================================================== */
/* ========================================================================== */
@ -1100,7 +1057,7 @@ PUBLIC size_t COLAMD_recommended /* returns recommended value of Alen. */
Colamd: rows with more than max (16, knobs [0] * sqrt (n_col))
entries are removed prior to ordering. Columns with more than
max (16, knobs [1] * sqrt (MIN (n_row,n_col))) entries are removed
prior to ordering, and placed last in the output column ordering.
prior to ordering, and placed last in the output column ordering.
Symamd: Rows and columns with more than max (16, knobs [0] * sqrt (n))
entries are removed prior to ordering, and placed last in the
@ -1116,7 +1073,7 @@ PUBLIC size_t COLAMD_recommended /* returns recommended value of Alen. */
*/
PUBLIC void COLAMD_set_defaults
void COLAMD_set_defaults
(
/* === Parameters ======================================================= */
@ -1145,7 +1102,7 @@ PUBLIC void COLAMD_set_defaults
/* === symamd =============================================================== */
/* ========================================================================== */
PUBLIC Int SYMAMD_MAIN /* return TRUE if OK, FALSE otherwise */
int SYMAMD_MAIN /* return TRUE if OK, FALSE otherwise */
(
/* === Parameters ======================================================= */
@ -1173,7 +1130,7 @@ PUBLIC Int SYMAMD_MAIN /* return TRUE if OK, FALSE otherwise */
Int nnz ; /* number of entries in A */
Int i ; /* row index of A */
Int j ; /* column index of A */
Int k ; /* row index of M */
Int k ; /* row index of M */
Int mnz ; /* number of nonzeros in M */
Int pp ; /* index into a column of A */
Int last_row ; /* last row seen in the current column */
@ -1465,7 +1422,7 @@ PUBLIC Int SYMAMD_MAIN /* return TRUE if OK, FALSE otherwise */
(AQ)'(AQ) = LL' remains sparse.
*/
PUBLIC Int COLAMD_MAIN /* returns TRUE if successful, FALSE otherwise*/
int COLAMD_MAIN /* returns TRUE if successful, FALSE otherwise*/
(
/* === Parameters ======================================================= */
@ -1583,7 +1540,7 @@ PUBLIC Int COLAMD_MAIN /* returns TRUE if successful, FALSE otherwise*/
need = t_add (need, Col_size, &ok) ;
need = t_add (need, Row_size, &ok) ;
if (!ok || need > (size_t) Alen || need > Int_MAX)
if (!ok || need > (size_t) Alen)
{
/* not enough space in array A to perform the ordering */
stats [COLAMD_STATUS] = COLAMD_ERROR_A_too_small ;
@ -1625,7 +1582,7 @@ PUBLIC Int COLAMD_MAIN /* returns TRUE if successful, FALSE otherwise*/
stats [COLAMD_DENSE_ROW] = n_row - n_row2 ;
stats [COLAMD_DENSE_COL] = n_col - n_col2 ;
stats [COLAMD_DEFRAG_COUNT] = ngarbage ;
DEBUG0 (("colamd: done.\n")) ;
DEBUG0 (("colamd: done.\n")) ;
return (TRUE) ;
}
@ -1634,7 +1591,7 @@ PUBLIC Int COLAMD_MAIN /* returns TRUE if successful, FALSE otherwise*/
/* === colamd_report ======================================================== */
/* ========================================================================== */
PUBLIC void COLAMD_report
void COLAMD_report
(
Int stats [COLAMD_STATS]
)
@ -1647,7 +1604,7 @@ PUBLIC void COLAMD_report
/* === symamd_report ======================================================== */
/* ========================================================================== */
PUBLIC void SYMAMD_report
void SYMAMD_report
(
Int stats [COLAMD_STATS]
)
@ -1687,7 +1644,7 @@ PRIVATE Int init_rows_cols /* returns TRUE if OK, or FALSE otherwise */
Colamd_Col Col [], /* of size n_col+1 */
Int A [], /* row indices of A, of size Alen */
Int p [], /* pointers to columns in A, of size n_col+1 */
Int stats [COLAMD_STATS] /* colamd statistics */
Int stats [COLAMD_STATS] /* colamd statistics */
)
{
/* === Local variables ================================================== */
@ -2226,7 +2183,7 @@ PRIVATE Int find_ordering /* return the number of garbage collections */
Int col ; /* a column index */
Int max_score ; /* maximum possible score */
Int cur_score ; /* score of current column */
unsigned Int hash ; /* hash value for supernode detection */
UInt hash ; /* hash value for supernode detection */
Int head_column ; /* head of hash bucket */
Int first_col ; /* first column in hash bucket */
Int tag_mark ; /* marker value for mark array */
@ -3188,12 +3145,13 @@ PRIVATE void print_report
Int i1, i2, i3 ;
PRINTF (("\n%s version %d.%d, %s: ", method,
COLAMD_MAIN_VERSION, COLAMD_SUB_VERSION, COLAMD_DATE)) ;
SUITESPARSE_PRINTF (("\n%s version %d.%d.%d, %s: ", method,
COLAMD_MAIN_VERSION, COLAMD_SUB_VERSION, COLAMD_SUBSUB_VERSION,
COLAMD_DATE)) ;
if (!stats)
{
PRINTF (("No statistics available.\n")) ;
SUITESPARSE_PRINTF (("No statistics available.\n")) ;
return ;
}
@ -3203,11 +3161,11 @@ PRIVATE void print_report
if (stats [COLAMD_STATUS] >= 0)
{
PRINTF (("OK. ")) ;
SUITESPARSE_PRINTF (("OK. ")) ;
}
else
{
PRINTF (("ERROR. ")) ;
SUITESPARSE_PRINTF (("ERROR. ")) ;
}
switch (stats [COLAMD_STATUS])
@ -3215,87 +3173,99 @@ PRIVATE void print_report
case COLAMD_OK_BUT_JUMBLED:
PRINTF(("Matrix has unsorted or duplicate row indices.\n")) ;
SUITESPARSE_PRINTF((
"Matrix has unsorted or duplicate row indices.\n")) ;
PRINTF(("%s: number of duplicate or out-of-order row indices: %d\n",
method, i3)) ;
SUITESPARSE_PRINTF((
"%s: number of duplicate or out-of-order row indices: %d\n",
method, i3)) ;
PRINTF(("%s: last seen duplicate or out-of-order row index: %d\n",
method, INDEX (i2))) ;
SUITESPARSE_PRINTF((
"%s: last seen duplicate or out-of-order row index: %d\n",
method, INDEX (i2))) ;
PRINTF(("%s: last seen in column: %d",
method, INDEX (i1))) ;
SUITESPARSE_PRINTF((
"%s: last seen in column: %d",
method, INDEX (i1))) ;
/* no break - fall through to next case instead */
case COLAMD_OK:
PRINTF(("\n")) ;
SUITESPARSE_PRINTF(("\n")) ;
PRINTF(("%s: number of dense or empty rows ignored: %d\n",
method, stats [COLAMD_DENSE_ROW])) ;
SUITESPARSE_PRINTF((
"%s: number of dense or empty rows ignored: %d\n",
method, stats [COLAMD_DENSE_ROW])) ;
PRINTF(("%s: number of dense or empty columns ignored: %d\n",
method, stats [COLAMD_DENSE_COL])) ;
SUITESPARSE_PRINTF((
"%s: number of dense or empty columns ignored: %d\n",
method, stats [COLAMD_DENSE_COL])) ;
PRINTF(("%s: number of garbage collections performed: %d\n",
method, stats [COLAMD_DEFRAG_COUNT])) ;
SUITESPARSE_PRINTF((
"%s: number of garbage collections performed: %d\n",
method, stats [COLAMD_DEFRAG_COUNT])) ;
break ;
case COLAMD_ERROR_A_not_present:
PRINTF(("Array A (row indices of matrix) not present.\n")) ;
SUITESPARSE_PRINTF((
"Array A (row indices of matrix) not present.\n")) ;
break ;
case COLAMD_ERROR_p_not_present:
PRINTF(("Array p (column pointers for matrix) not present.\n")) ;
SUITESPARSE_PRINTF((
"Array p (column pointers for matrix) not present.\n")) ;
break ;
case COLAMD_ERROR_nrow_negative:
PRINTF(("Invalid number of rows (%d).\n", i1)) ;
SUITESPARSE_PRINTF(("Invalid number of rows (%d).\n", i1)) ;
break ;
case COLAMD_ERROR_ncol_negative:
PRINTF(("Invalid number of columns (%d).\n", i1)) ;
SUITESPARSE_PRINTF(("Invalid number of columns (%d).\n", i1)) ;
break ;
case COLAMD_ERROR_nnz_negative:
PRINTF(("Invalid number of nonzero entries (%d).\n", i1)) ;
SUITESPARSE_PRINTF((
"Invalid number of nonzero entries (%d).\n", i1)) ;
break ;
case COLAMD_ERROR_p0_nonzero:
PRINTF(("Invalid column pointer, p [0] = %d, must be zero.\n", i1));
SUITESPARSE_PRINTF((
"Invalid column pointer, p [0] = %d, must be zero.\n", i1));
break ;
case COLAMD_ERROR_A_too_small:
PRINTF(("Array A too small.\n")) ;
PRINTF((" Need Alen >= %d, but given only Alen = %d.\n",
i1, i2)) ;
SUITESPARSE_PRINTF(("Array A too small.\n")) ;
SUITESPARSE_PRINTF((
" Need Alen >= %d, but given only Alen = %d.\n",
i1, i2)) ;
break ;
case COLAMD_ERROR_col_length_negative:
PRINTF
(("Column %d has a negative number of nonzero entries (%d).\n",
INDEX (i1), i2)) ;
SUITESPARSE_PRINTF
(("Column %d has a negative number of nonzero entries (%d).\n",
INDEX (i1), i2)) ;
break ;
case COLAMD_ERROR_row_index_out_of_bounds:
PRINTF
(("Row index (row %d) out of bounds (%d to %d) in column %d.\n",
INDEX (i2), INDEX (0), INDEX (i3-1), INDEX (i1))) ;
SUITESPARSE_PRINTF
(("Row index (row %d) out of bounds (%d to %d) in column %d.\n",
INDEX (i2), INDEX (0), INDEX (i3-1), INDEX (i1))) ;
break ;
case COLAMD_ERROR_out_of_memory:
PRINTF(("Out of memory.\n")) ;
SUITESPARSE_PRINTF(("Out of memory.\n")) ;
break ;
/* v2.4: internal-error case deleted */

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === klu ================================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu: primary factorization and forward/backsolve kernels for KLU
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* KLU: factorizes P*A into L*U, using the Gilbert-Peierls algorithm [1], with
* optional symmetric pruning by Eisenstat and Liu [2]. The code is by Tim
@ -33,12 +39,6 @@
* Ai [Ap [j] ... Ap [j+1]-1] and the same range of indices in Ax holds the
* numerical values. No duplicate entries are allowed.
*
* Copyright 2004-2009, Tim Davis. All rights reserved. See the README
* file for details on permitted use. Note that no code from The MathWorks,
* Inc, or from SuperLU, or from any other source appears here. The code is
* written from scratch, from the algorithmic description in Gilbert & Peierls'
* and Eisenstat & Liu's journal papers [1,2].
*
* If an input permutation Q is provided, the factorization L*U = A (P,Q)
* is computed, where P is determined by partial pivoting, and Q is the input
* ordering. If the pivot tolerance is less than 1, the "diagonal" entry that
@ -116,11 +116,11 @@ size_t KLU_kernel_factor /* 0 if failure, size of LU if OK */
{
Lsize = -Lsize ;
Lsize = MAX (Lsize, 1.0) ;
lsize = Lsize * anz + n ;
lsize = (int) Lsize * anz + n ;
}
else
{
lsize = Lsize ;
lsize = (int) Lsize ;
}
usize = lsize ;
@ -129,7 +129,7 @@ size_t KLU_kernel_factor /* 0 if failure, size of LU if OK */
usize = MAX (n+1, usize) ;
maxlnz = (((double) n) * ((double) n) + ((double) n)) / 2. ;
maxlnz = MIN (maxlnz, ((double) INT_MAX)) ;
maxlnz = MIN (maxlnz, ((double) Int_MAX)) ;
lsize = MIN ((int) maxlnz, lsize) ;
usize = MIN ((int) maxlnz, usize) ;
@ -154,7 +154,7 @@ size_t KLU_kernel_factor /* 0 if failure, size of LU if OK */
dunits = DUNITS (Int, lsize) + DUNITS (Entry, lsize) +
DUNITS (Int, usize) + DUNITS (Entry, usize) ;
lusize = (size_t) dunits ;
ok = !INT_OVERFLOW (dunits) ;
ok = !INT_OVERFLOW (dunits) ;
LU = ok ? KLU_malloc (lusize, sizeof (Unit), Common) : NULL ;
if (LU == NULL)
{

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === klu_analyze ========================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_analyze: symbolic analysis
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Order the matrix using BTF (or not), and then AMD, COLAMD, the natural
* ordering, or the user-provided-function on the blocks. Does not support
@ -306,12 +312,6 @@ static KLU_symbolic *order_and_analyze /* returns NULL if error, or a valid
return (NULL) ;
}
/* AMD memory management routines */
amd_malloc = Common->malloc_memory ;
amd_free = Common->free_memory ;
amd_calloc = Common->calloc_memory ;
amd_realloc = Common->realloc_memory ;
/* ---------------------------------------------------------------------- */
/* allocate workspace for BTF permutation */
/* ---------------------------------------------------------------------- */

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === klu_analyze_given ==================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_analyze_given: symbolic analysis with given permutation
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Given an input permutation P and Q, create the Symbolic object. BTF can
* be done to modify the user's P and Q (does not perform the max transversal;
@ -41,12 +47,6 @@ KLU_symbolic *KLU_alloc_symbolic
if (n <= 0 || Ap == NULL || Ai == NULL)
{
if (n == 0)
{
Common->status = KLU_EMPTY_MATRIX ;
return (NULL) ;
}
/* Ap and Ai must be present, and n must be > 0 */
Common->status = KLU_INVALID ;
return (NULL) ;

View File

@ -1,12 +1,18 @@
/* ========================================================================== */
/* === KLU_defaults ========================================================= */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_defaults: default parameters for KLU
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Sets default parameters for KLU */
#include "klu_internal.h"
Int KLU_defaults
int KLU_defaults
(
KLU_common *Common
)
@ -18,8 +24,8 @@ Int KLU_defaults
/* parameters */
Common->tol = 0.001 ; /* pivot tolerance for diagonal */
Common->memgrow = 10; /* realloc size ratio increase for LU factors */
Common->initmem_amd = 10 ; /* init. mem with AMD: c*nnz(L) + n */
Common->memgrow = 1.2; /* realloc size ratio increase for LU factors */
Common->initmem_amd = 1.2 ; /* init. mem with AMD: c*nnz(L) + n */
Common->initmem = 10 ; /* init. mem otherwise: c*nnz(A) + n */
Common->btf = TRUE ; /* use BTF pre-ordering, or not */
Common->maxwork = 0 ; /* no limit to work done by btf_order */
@ -31,12 +37,6 @@ Int KLU_defaults
* 1: sum, 2: max */
Common->halt_if_singular = TRUE ; /* quick halt if matrix is singular */
/* memory management routines */
Common->malloc_memory = malloc ;
Common->calloc_memory = calloc ;
Common->free_memory = free ;
Common->realloc_memory = realloc ;
/* user ordering function and optional argument */
Common->user_order = NULL ;
Common->user_data = NULL ;

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_diagnostics ====================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_diagnostics: linear algebraic diagnostics
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Linear algebraic diagnostics:
* KLU_rgrowth: reciprocal pivot growth, takes O(|A|+|U|) time
@ -22,7 +28,7 @@
* rgrowth = min (max (abs ((R \ A (p,q)) - F))) ./ max (abs (U)))
*/
Int KLU_rgrowth /* return TRUE if successful, FALSE otherwise */
int KLU_rgrowth /* return TRUE if successful, FALSE otherwise */
(
Int *Ap,
Int *Ai,
@ -120,6 +126,8 @@ Int KLU_rgrowth /* return TRUE if successful, FALSE otherwise */
}
}
/* Ui is set but not used. This is OK, because otherwise the macro
would have to be redesigned. */
GET_POINTER (LU, Uip, Ulen, Ui, Ux, j, len) ;
for (k = 0 ; k < len ; k++)
{
@ -167,7 +175,7 @@ Int KLU_rgrowth /* return TRUE if successful, FALSE otherwise */
* 1-norm pseudospectra, SIAM J. Matrix Anal. Appl., 21(4):1185-1201, 2000.
*/
Int KLU_condest /* return TRUE if successful, FALSE otherwise */
int KLU_condest /* return TRUE if successful, FALSE otherwise */
(
Int Ap [ ],
double Ax [ ],
@ -178,8 +186,7 @@ Int KLU_condest /* return TRUE if successful, FALSE otherwise */
{
double xj, Xmax, csum, anorm, ainv_norm, est_old, est_new, abs_value ;
Entry *Udiag, *Aentry, *X, *S ;
Int *R ;
Int nblocks, i, j, jmax, jnew, pend, n ;
Int i, j, jmax, jnew, pend, n ;
#ifndef COMPLEX
Int unchanged ;
#endif
@ -212,8 +219,6 @@ Int KLU_condest /* return TRUE if successful, FALSE otherwise */
/* ---------------------------------------------------------------------- */
n = Symbolic->n ;
nblocks = Symbolic->nblocks ;
R = Symbolic->R ;
Udiag = Numeric->Udiag ;
/* ---------------------------------------------------------------------- */
@ -411,7 +416,7 @@ Int KLU_condest /* return TRUE if successful, FALSE otherwise */
/* Compute the flop count for the LU factorization (in Common->flops) */
Int KLU_flops /* return TRUE if successful, FALSE otherwise */
int KLU_flops /* return TRUE if successful, FALSE otherwise */
(
KLU_symbolic *Symbolic,
KLU_numeric *Numeric,
@ -422,7 +427,7 @@ Int KLU_flops /* return TRUE if successful, FALSE otherwise */
Int *R, *Ui, *Uip, *Llen, *Ulen ;
Unit **LUbx ;
Unit *LU ;
Int k, ulen, p, n, nk, block, nblocks, k1 ;
Int k, ulen, p, nk, block, nblocks, k1 ;
/* ---------------------------------------------------------------------- */
/* check inputs */
@ -444,7 +449,6 @@ Int KLU_flops /* return TRUE if successful, FALSE otherwise */
/* get the contents of the Symbolic object */
/* ---------------------------------------------------------------------- */
n = Symbolic->n ;
R = Symbolic->R ;
nblocks = Symbolic->nblocks ;
@ -494,9 +498,9 @@ Int KLU_flops /* return TRUE if successful, FALSE otherwise */
/* Compute a really cheap estimate of the reciprocal of the condition number,
* condition number, min(abs(diag(U))) / max(abs(diag(U))). If U has a zero
* pivot, or a NaN pivot, rcond will be zero. Takes O(n) time.
*/
*/
Int KLU_rcond /* return TRUE if successful, FALSE otherwise */
int KLU_rcond /* return TRUE if successful, FALSE otherwise */
(
KLU_symbolic *Symbolic, /* input, not modified */
KLU_numeric *Numeric, /* input, not modified */

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_dump ============================================================= */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_dump: debug routines for KLU
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Debug routines for klu. Only used when NDEBUG is not defined at
* compile-time.
@ -110,14 +116,19 @@ Int KLU_valid_LU (Int n, Int flag_test_start_ptr, Int Xip [ ],
for (j = 0 ; j < n ; j++)
{
p1 = Xip [j] ;
p2 = Xip [j+1] ;
PRINTF (("\nColumn: %d p1: %d p2: %d\n", j, p1, p2)) ;
if (p1 > p2)
PRINTF (("\nColumn of factor: %d p1: %d ", j, p1)) ;
if (j < n-1)
{
/* column pointers must be ascending */
PRINTF (("column %d pointer bad\n", j)) ;
return (FALSE) ;
p2 = Xip [j+1] ;
PRINTF (("p2: %d ", p2)) ;
if (p1 > p2)
{
/* column pointers must be ascending */
PRINTF (("column %d pointer bad\n", j)) ;
return (FALSE) ;
}
}
PRINTF (("\n")) ;
GET_POINTER (LU, Xip, Xlen, Xi, Xx, j, len) ;
for (p = 0 ; p < len ; p++)
{

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_extract ========================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_extract: extract the KLU factorization
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Extract KLU factorization into conventional compressed-column matrices.
* If any output array is NULL, that part of the LU factorization is not
@ -11,7 +17,7 @@
#include "klu_internal.h"
Int KLU_extract /* returns TRUE if successful, FALSE otherwise */
int KLU_extract /* returns TRUE if successful, FALSE otherwise */
(
/* inputs: */
KLU_numeric *Numeric,

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_factor =========================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_factor: sparse LU factorization
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Factor the matrix, after ordering and analyzing it with KLU_analyze
* or KLU_analyze_given.
@ -341,14 +347,14 @@ static void factor2
#ifndef NDEBUG
{
PRINTF (("\n ############# KLU_BTF_FACTOR done, nblocks %d\n",nblocks));
PRINTF (("\n ------------ KLU_BTF_FACTOR done, nblocks %d\n",nblocks));
Entry ss, *Udiag = Numeric->Udiag ;
for (block = 0 ; block < nblocks && Common->status == KLU_OK ; block++)
{
k1 = R [block] ;
k2 = R [block+1] ;
nk = k2 - k1 ;
PRINTF (("\n======================KLU_factor output: k1 %d k2 %d nk %d\n",k1,k2,nk)) ;
PRINTF (("\n== KLU_factor output: k1 %d k2 %d nk %d\n",k1,k2,nk)) ;
if (nk == 1)
{
PRINTF (("singleton ")) ;
@ -394,7 +400,6 @@ KLU_numeric *KLU_factor /* returns NULL if error, or a valid
)
{
Int n, nzoff, nblocks, maxblock, k, ok = TRUE ;
Int *R ;
KLU_numeric *Numeric ;
size_t n1, nzoff1, s, b6, n3 ;
@ -402,10 +407,6 @@ KLU_numeric *KLU_factor /* returns NULL if error, or a valid
{
return (NULL) ;
}
if (Common->status == KLU_EMPTY_MATRIX)
{
return (NULL) ;
}
Common->status = KLU_OK ;
Common->numerical_rank = EMPTY ;
Common->singular_col = EMPTY ;
@ -425,7 +426,6 @@ KLU_numeric *KLU_factor /* returns NULL if error, or a valid
nzoff = Symbolic->nzoff ;
nblocks = Symbolic->nblocks ;
maxblock = Symbolic->maxblock ;
R = Symbolic->R ;
PRINTF (("KLU_factor: n %d nzoff %d nblocks %d maxblock %d\n",
n, nzoff, nblocks, maxblock)) ;

View File

@ -1,12 +1,18 @@
/* ========================================================================== */
/* === KLU_free_numeric ===================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_free_numeric: free the KLU numeric factorization
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Free the KLU Numeric object. */
#include "klu_internal.h"
Int KLU_free_numeric
int KLU_free_numeric
(
KLU_numeric **NumericHandle,
KLU_common *Common

View File

@ -1,12 +1,18 @@
/* ========================================================================== */
/* === KLU_free_symbolic ==================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_free_symbolic: free the KLU symbolic analysis
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Free the KLU Symbolic object. */
#include "klu_internal.h"
Int KLU_free_symbolic
int KLU_free_symbolic
(
KLU_symbolic **SymbolicHandle,
KLU_common *Common

View File

@ -1,13 +1,19 @@
/* ========================================================================== */
/* === KLU/Include/klu_internal.h =========================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Include/klu_internal.h: internal include file for KLU
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2023, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* For internal use in KLU routines only, not for user programs */
#ifndef _KLU_INTERNAL_H
#define _KLU_INTERNAL_H
#include "ngspice/klu.h"
#include "ngspice/klu.h"
#include "ngspice/btf.h"
#include "klu_version.h"
@ -31,11 +37,7 @@
/* ========================================================================== */
#include <stdio.h>
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
#undef ASSERT
#ifndef NDEBUG
@ -47,7 +49,7 @@
#define SCALAR_IS_NAN(x) ((x) != (x))
/* true if an integer (stored in double x) would overflow (or if x is NaN) */
#define INT_OVERFLOW(x) ((!((x) * (1.0+1e-8) <= (double) INT_MAX)) \
#define INT_OVERFLOW(x) ((!((x) * (1.0+1e-8) <= (double) Int_MAX)) \
|| SCALAR_IS_NAN (x))
#undef TRUE
@ -58,7 +60,7 @@
#undef FLIP
#ifndef NPRINT
#define PRINTF(s) { printf s ; } ;
#define PRINTF(s) SUITESPARSE_PRINTF (s)
#else
#define PRINTF(s)
#endif
@ -106,7 +108,7 @@ size_t KLU_kernel /* final size of LU on output */
Int Stack [ ], /* size n */
Int Flag [ ], /* size n */
Int adj_pos [ ], /* size n */
/* workspace for pruning only */
Int Lpend [ ], /* size n workspace */
@ -217,20 +219,20 @@ void KLU_utsolve
Entry X [ ]
) ;
Int KLU_valid
Int KLU_valid
(
Int n,
Int Ap [ ],
Int Ai [ ],
Int n,
Int Ap [ ],
Int Ai [ ],
Entry Ax [ ]
) ;
Int KLU_valid_LU
Int KLU_valid_LU
(
Int n,
Int flag_test_start_ptr,
Int n,
Int flag_test_start_ptr,
Int Xip [ ],
Int Xlen [ ],
Int Xlen [ ],
Unit LU [ ]
);

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_kernel =========================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_kernel: primary sparse LU factorization kernel
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Sparse left-looking LU factorization, with partial pivoting. Based on
* Gilbert & Peierl's method, with a non-recursive DFS and with Eisenstat &
@ -119,15 +125,7 @@ static Int dfs
/* Finds the pattern of x, for the solution of Lx=b */
/* ========================================================================== */
/* === construct_column ===================================================== */
/* ========================================================================== */
/* Construct the kth column of A, and the off-diagonal part, if requested.
* Scatter the numerical values into the workspace X, and construct the
* corresponding column of the off-diagonal matrix. */
static Int lsolve_symbolic_and_construct_column
static Int lsolve_symbolic
(
/* input, not modified on output: */
Int n, /* L is n-by-n, where n >= 0 */
@ -158,29 +156,11 @@ static Int lsolve_symbolic_and_construct_column
/* ---- the following are only used in the BTF case --- */
Int k1, /* the block of A is from k1 to k2-1 */
Int PSinv [ ], /* inverse of P from symbolic factorization */
/* inputs, not modified on output */
Entry Ax [ ],
/* zero on input, modified on output */
Entry X [ ],
/* ---- the following are only used in the BTF case --- */
/* inputs, not modified on output */
double Rs [ ], /* scale factors for A */
Int scale, /* 0: no scaling, nonzero: scale the rows with Rs */
/* inputs, modified on output */
Int Offp [ ], /* off-diagonal matrix (modified by this routine) */
Int Offi [ ],
Entry Offx [ ]
Int PSinv [ ] /* inverse of P from symbolic factorization */
)
{
Entry aik ;
Int *Lik ;
Int i, p, pend, oldcol, kglobal, poff, oldrow, top, l_length ;
Int i, p, pend, oldcol, kglobal, top, l_length ;
top = n ;
l_length = 0 ;
@ -191,24 +171,94 @@ static Int lsolve_symbolic_and_construct_column
/* ---------------------------------------------------------------------- */
kglobal = k + k1 ; /* column k of the block is col kglobal of A */
poff = Offp [kglobal] ; /* start of off-diagonal column */
oldcol = Q [kglobal] ; /* Q must be present for BTF case */
pend = Ap [oldcol+1] ;
for (p = Ap [oldcol] ; p < pend ; p++)
{
i = PSinv [Ai [p]] - k1 ;
if (i < 0) continue ; /* skip entry outside the block */
/* (i,k) is an entry in the block. start a DFS at node i */
PRINTF (("\n ===== DFS at node %d in b, inew: %d\n", i, Pinv [i])) ;
if (Flag [i] != k)
{
if (Pinv [i] >= 0)
{
top = dfs (i, k, Pinv, Llen, Lip, Stack, Flag,
Lpend, top, LU, Lik, &l_length, Ap_pos) ;
}
else
{
/* i is not pivotal, and not flagged. Flag and put in L */
Flag [i] = k ;
Lik [l_length] = i ;
l_length++;
}
}
}
/* If Llen [k] is zero, the matrix is structurally singular */
Llen [k] = l_length ;
return (top) ;
}
/* ========================================================================== */
/* === construct_column ===================================================== */
/* ========================================================================== */
/* Construct the kth column of A, and the off-diagonal part, if requested.
* Scatter the numerical values into the workspace X, and construct the
* corresponding column of the off-diagonal matrix. */
static void construct_column
(
/* inputs, not modified on output */
Int k, /* the column of A (or the column of the block) to get */
Int Ap [ ],
Int Ai [ ],
Entry Ax [ ],
Int Q [ ], /* column pre-ordering */
/* zero on input, modified on output */
Entry X [ ],
/* ---- the following are only used in the BTF case --- */
/* inputs, not modified on output */
Int k1, /* the block of A is from k1 to k2-1 */
Int PSinv [ ], /* inverse of P from symbolic factorization */
double Rs [ ], /* scale factors for A */
Int scale, /* 0: no scaling, nonzero: scale the rows with Rs */
/* inputs, modified on output */
Int Offp [ ], /* off-diagonal matrix (modified by this routine) */
Int Offi [ ],
Entry Offx [ ]
)
{
Entry aik ;
Int i, p, pend, oldcol, kglobal, poff, oldrow ;
/* ---------------------------------------------------------------------- */
/* Scale and scatter the column into X. */
/* ---------------------------------------------------------------------- */
kglobal = k + k1 ; /* column k of the block is col kglobal of A */
poff = Offp [kglobal] ; /* start of off-diagonal column */
oldcol = Q [kglobal] ;
pend = Ap [oldcol+1] ;
if (scale <= 0)
{
/* no scaling */
for (p = Ap [oldcol] ; p < pend ; p++)
{
oldrow = Ai [p] ;
i = PSinv [oldrow] - k1 ;
aik = Ax [p] ;
if (i < 0)
{
/* ---------------------------------------------------------------------- */
/* Scatter the column into X. */
/* ---------------------------------------------------------------------- */
aik = Ax [p] ;
/* this is an entry in the off-diagonal part */
Offi [poff] = oldrow ;
Offx [poff] = aik ;
@ -216,31 +266,6 @@ static Int lsolve_symbolic_and_construct_column
}
else
{
/* (i,k) is an entry in the block. start a DFS at node i */
PRINTF (("\n ===== DFS at node %d in b, inew: %d\n", i, Pinv [i])) ;
if (Flag [i] != k)
{
if (Pinv [i] >= 0)
{
top = dfs (i, k, Pinv, Llen, Lip, Stack, Flag,
Lpend, top, LU, Lik, &l_length, Ap_pos) ;
}
else
{
/* i is not pivotal, and not flagged. Flag and put in L */
Flag [i] = k ;
Lik [l_length] = i ;
l_length++;
}
}
/* ---------------------------------------------------------------------- */
/* Scatter the column into X. */
/* ---------------------------------------------------------------------- */
/* no scaling */
aik = Ax [p] ;
/* (i,k) is an entry in the block. scatter into X */
X [i] = aik ;
}
@ -248,20 +273,15 @@ static Int lsolve_symbolic_and_construct_column
}
else
{
/* row scaling */
for (p = Ap [oldcol] ; p < pend ; p++)
{
oldrow = Ai [p] ;
i = PSinv [oldrow] - k1 ;
aik = Ax [p] ;
SCALE_DIV (aik, Rs [oldrow]) ;
if (i < 0)
{
/* ---------------------------------------------------------------------- */
/* Scale and scatter the column into X. */
/* ---------------------------------------------------------------------- */
/* row scaling */
aik = Ax [p] ;
SCALE_DIV (aik, Rs [oldrow]) ;
/* this is an entry in the off-diagonal part */
Offi [poff] = oldrow ;
Offx [poff] = aik ;
@ -269,32 +289,6 @@ static Int lsolve_symbolic_and_construct_column
}
else
{
/* (i,k) is an entry in the block. start a DFS at node i */
PRINTF (("\n ===== DFS at node %d in b, inew: %d\n", i, Pinv [i])) ;
if (Flag [i] != k)
{
if (Pinv [i] >= 0)
{
top = dfs (i, k, Pinv, Llen, Lip, Stack, Flag,
Lpend, top, LU, Lik, &l_length, Ap_pos) ;
}
else
{
/* i is not pivotal, and not flagged. Flag and put in L */
Flag [i] = k ;
Lik [l_length] = i ;
l_length++;
}
}
/* ---------------------------------------------------------------------- */
/* Scale and scatter the column into X. */
/* ---------------------------------------------------------------------- */
/* row scaling */
aik = Ax [p] ;
SCALE_DIV (aik, Rs [oldrow]) ;
/* (i,k) is an entry in the block. scatter into X */
X [i] = aik ;
}
@ -302,10 +296,6 @@ static Int lsolve_symbolic_and_construct_column
}
Offp [kglobal+1] = poff ; /* start of the next col of off-diag part */
/* If Llen [k] is zero, the matrix is structurally singular */
Llen [k] = l_length ;
return (top) ;
}
@ -555,6 +545,7 @@ static void prune
Int p, i, j, p2, phead, ptail, llen, ulen ;
/* check to see if any column of L can be pruned */
/* Ux is set but not used. This OK. */
GET_POINTER (LU, Uip, Ulen, Ui, Ux, k, ulen) ;
for (p = 0 ; p < ulen ; p++)
{
@ -818,15 +809,9 @@ size_t KLU_kernel /* final size of LU on output */
}
#endif
/* Francesco - Compressed 'lsolve_symbolic' and 'cosntruct_column' in one routine */
top = lsolve_symbolic_and_construct_column (n, k, Ap, Ai, Q, Pinv, Stack, Flag, Lpend,
Ap_pos, LU, lup, Llen, Lip, k1, PSinv, Ax, X, Rs, scale, Offp, Offi, Offx) ;
top = lsolve_symbolic (n, k, Ap, Ai, Q, Pinv, Stack, Flag,
Lpend, Ap_pos, LU, lup, Llen, Lip, k1, PSinv) ;
/* ------------------------------------------------------------------ */
/* get the column of the matrix to factorize and scatter into X */
/* ------------------------------------------------------------------ */
/*
#ifndef NDEBUG
PRINTF (("--- in U:\n")) ;
for (p = top ; p < n ; p++)
@ -850,7 +835,13 @@ size_t KLU_kernel /* final size of LU on output */
if (Flag [i] == k) p++ ;
}
#endif
*/
/* ------------------------------------------------------------------ */
/* get the column of the matrix to factorize and scatter into X */
/* ------------------------------------------------------------------ */
construct_column (k, Ap, Ai, Ax, Q, X,
k1, PSinv, Rs, scale, Offp, Offi, Offx) ;
/* ------------------------------------------------------------------ */
/* compute the numerical values of the kth column (s = L \ A (:,k)) */

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_memory =========================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_memory: memory management for KLU
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* KLU memory management routines:
*
@ -67,8 +73,6 @@ void *KLU_malloc /* returns pointer to the newly malloc'd block */
)
{
void *p ;
size_t s ;
Int ok = TRUE ;
if (Common == NULL)
{
@ -80,7 +84,7 @@ void *KLU_malloc /* returns pointer to the newly malloc'd block */
Common->status = KLU_INVALID ;
p = NULL ;
}
else if (n >= INT_MAX)
else if (sizeof (size_t) > sizeof (Int) && n >= Int_MAX)
{
/* object is too big to allocate; p[i] where i is an Int will not
* be enough. */
@ -90,8 +94,7 @@ void *KLU_malloc /* returns pointer to the newly malloc'd block */
else
{
/* call malloc, or its equivalent */
s = KLU_mult_size_t (MAX (1,n), size, &ok) ;
p = ok ? ((Common->malloc_memory) (s)) : NULL ;
p = SuiteSparse_malloc (n, size) ;
if (p == NULL)
{
/* failure: out of memory */
@ -99,7 +102,7 @@ void *KLU_malloc /* returns pointer to the newly malloc'd block */
}
else
{
Common->memusage += s ;
Common->memusage += (MAX (1,n) * size) ;
Common->mempeak = MAX (Common->mempeak, Common->memusage) ;
}
}
@ -128,15 +131,12 @@ void *KLU_free /* always returns NULL */
KLU_common *Common
)
{
size_t s ;
Int ok = TRUE ;
if (p != NULL && Common != NULL)
{
/* only free the object if the pointer is not NULL */
/* call free, or its equivalent */
(Common->free_memory) (p) ;
s = KLU_mult_size_t (MAX (1,n), size, &ok) ;
Common->memusage -= s ;
SuiteSparse_free (p) ;
Common->memusage -= (MAX (1,n) * size) ;
}
/* return NULL, and the caller should assign this to p. This avoids
* freeing the same pointer twice. */
@ -178,8 +178,7 @@ void *KLU_realloc /* returns pointer to reallocated block */
)
{
void *pnew ;
size_t snew, sold ;
Int ok = TRUE ;
int ok = TRUE ;
if (Common == NULL)
{
@ -196,7 +195,7 @@ void *KLU_realloc /* returns pointer to reallocated block */
/* A fresh object is being allocated. */
p = KLU_malloc (nnew, size, Common) ;
}
else if (nnew >= INT_MAX)
else if (sizeof (size_t) > sizeof (Int) && nnew >= Int_MAX)
{
/* failure: nnew is too big. Do not change p */
Common->status = KLU_TOO_LARGE ;
@ -205,21 +204,19 @@ void *KLU_realloc /* returns pointer to reallocated block */
{
/* The object exists, and is changing to some other nonzero size. */
/* call realloc, or its equivalent */
snew = KLU_mult_size_t (MAX (1,nnew), size, &ok) ;
sold = KLU_mult_size_t (MAX (1,nold), size, &ok) ;
pnew = ok ? ((Common->realloc_memory) (p, snew)) : NULL ;
if (pnew == NULL)
pnew = SuiteSparse_realloc (nnew, nold, size, p, &ok) ;
if (ok)
{
/* success: return the new p and change the size of the block */
Common->memusage += ((nnew-nold) * size) ;
Common->mempeak = MAX (Common->mempeak, Common->memusage) ;
p = pnew ;
}
else
{
/* Do not change p, since it still points to allocated memory */
Common->status = KLU_OUT_OF_MEMORY ;
}
else
{
/* success: return the new p and change the size of the block */
Common->memusage += (snew - sold) ;
Common->mempeak = MAX (Common->mempeak, Common->memusage) ;
p = pnew ;
}
}
return (p) ;
}

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_refactor ========================================================= */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_refactor: factor another matrix (no pivoting)
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Factor the matrix, after ordering and analyzing it with KLU_analyze, and
* factoring it once with KLU_factor. This routine cannot do any numerical
@ -15,7 +21,7 @@
/* === KLU_refactor ========================================================= */
/* ========================================================================== */
Int KLU_refactor /* returns TRUE if successful, FALSE otherwise */
int KLU_refactor /* returns TRUE if successful, FALSE otherwise */
(
/* inputs, not modified */
Int Ap [ ], /* size n+1, column pointers */
@ -31,8 +37,7 @@ Int KLU_refactor /* returns TRUE if successful, FALSE otherwise */
Entry ukk, ujk, s ;
Entry *Offx, *Lx, *Ux, *X, *Az, *Udiag ;
double *Rs ;
Int *P, *Q, *R, *Pnum, *Offp, *Offi, *Ui, *Li, *Pinv, *Lip, *Uip, *Llen,
*Ulen ;
Int *Q, *R, *Pnum, *Ui, *Li, *Pinv, *Lip, *Uip, *Llen, *Ulen ;
Unit **LUbx ;
Unit *LU ;
Int k1, k2, nk, k, block, oldcol, pend, oldrow, n, p, newrow, scale,
@ -46,10 +51,6 @@ Int KLU_refactor /* returns TRUE if successful, FALSE otherwise */
{
return (FALSE) ;
}
if (Common->status == KLU_EMPTY_MATRIX)
{
return (FALSE) ;
}
Common->status = KLU_OK ;
if (Numeric == NULL)
@ -69,7 +70,6 @@ Int KLU_refactor /* returns TRUE if successful, FALSE otherwise */
/* ---------------------------------------------------------------------- */
n = Symbolic->n ;
P = Symbolic->P ;
Q = Symbolic->Q ;
R = Symbolic->R ;
nblocks = Symbolic->nblocks ;
@ -80,8 +80,6 @@ Int KLU_refactor /* returns TRUE if successful, FALSE otherwise */
/* ---------------------------------------------------------------------- */
Pnum = Numeric->Pnum ;
Offp = Numeric->Offp ;
Offi = Numeric->Offi ;
Offx = (Entry *) Numeric->Offx ;
LUbx = (Unit **) Numeric->LUbx ;
@ -442,20 +440,20 @@ Int KLU_refactor /* returns TRUE if successful, FALSE otherwise */
}
#ifndef NDEBUG
ASSERT (Offp [n] == poff) ;
ASSERT (Numeric->Offp [n] == poff) ;
ASSERT (Symbolic->nzoff == poff) ;
PRINTF (("\n------------------- Off diagonal entries, new:\n")) ;
ASSERT (KLU_valid (n, Offp, Offi, Offx)) ;
ASSERT (KLU_valid (n, Numeric->Offp, Numeric->Offi, Offx)) ;
if (Common->status == KLU_OK)
{
PRINTF (("\n ########### KLU_BTF_REFACTOR done, nblocks %d\n",nblocks));
PRINTF (("\n ----------- KLU_BTF_REFACTOR done, nblocks %d\n",nblocks));
for (block = 0 ; block < nblocks ; block++)
{
k1 = R [block] ;
k2 = R [block+1] ;
nk = k2 - k1 ;
PRINTF ((
"\n================KLU_refactor output: k1 %d k2 %d nk %d\n",
"\n--------------- KLU_refactor output: k1 %d k2 %d nk %d\n",
k1, k2, nk)) ;
if (nk == 1)
{

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_scale ============================================================ */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_scale: scale a sparse matrix
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Scale a matrix and check to see if it is valid. Can be called by the user.
* This is called by KLU_factor and KLU_refactor. Returns TRUE if the input
@ -16,10 +22,10 @@
#include "klu_internal.h"
Int KLU_scale /* return TRUE if successful, FALSE otherwise */
int KLU_scale /* return TRUE if successful, FALSE otherwise */
(
/* inputs, not modified */
Int scale, /* 0: none, 1: sum, 2: max */
int scale, /* 0: none, 1: sum, 2: max */
Int n,
Int Ap [ ], /* size n+1, column pointers */
Int Ai [ ], /* size nz, row indices */

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_solve ============================================================ */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_solve: solve x=A\b using the KLU factorization
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Solve Ax=b using the symbolic and numeric objects from KLU_analyze
* (or KLU_analyze_given) and KLU_factor. Note that no iterative refinement is
@ -11,7 +17,7 @@
#include "klu_internal.h"
Int KLU_solve
int KLU_solve
(
/* inputs, not modified */
KLU_symbolic *Symbolic,
@ -41,10 +47,6 @@ Int KLU_solve
{
return (FALSE) ;
}
if (Common->status == KLU_EMPTY_MATRIX)
{
return (FALSE) ;
}
if (Numeric == NULL || Symbolic == NULL || d < Symbolic->n || nrhs < 0 ||
B == NULL)
{

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_sort ============================================================= */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_sort: sorts the L and U factors of KLU
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* sorts the columns of L and U so that the row indices appear in strictly
* increasing order.
@ -23,7 +29,7 @@ static void sort (Int n, Int *Xip, Int *Xlen, Unit *LU, Int *Tp, Int *Tj,
ASSERT (KLU_valid_LU (n, FALSE, Xip, Xlen, LU)) ;
/* count the number of entries in each row of L or U */
/* count the number of entries in each row of L or U */
for (i = 0 ; i < n ; i++)
{
W [i] = 0 ;
@ -88,7 +94,7 @@ static void sort (Int n, Int *Xip, Int *Xlen, Unit *LU, Int *Tp, Int *Tj,
/* === KLU_sort ============================================================= */
/* ========================================================================== */
Int KLU_sort
int KLU_sort
(
KLU_symbolic *Symbolic,
KLU_numeric *Numeric,

View File

@ -1,6 +1,12 @@
/* ========================================================================== */
/* === KLU_tsolve =========================================================== */
/* ========================================================================== */
//------------------------------------------------------------------------------
// KLU/Source/klu_tsolve: solve x=A'\b using the KLU factorization
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2022, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
/* Solve A'x=b using the symbolic and numeric objects from KLU_analyze
* (or KLU_analyze_given) and KLU_factor. Note that no iterative refinement is
@ -11,7 +17,7 @@
#include "klu_internal.h"
Int KLU_tsolve
int KLU_tsolve
(
/* inputs, not modified */
KLU_symbolic *Symbolic,
@ -23,7 +29,7 @@ Int KLU_tsolve
double B [ ], /* size n*nrhs, in column-oriented form, with
* leading dimension d. */
#ifdef COMPLEX
Int conj_solve, /* TRUE for conjugate transpose solve, FALSE for
int conj_solve, /* TRUE for conjugate transpose solve, FALSE for
* array transpose solve. Used for the complex
* case only. */
#endif
@ -46,10 +52,6 @@ Int KLU_tsolve
{
return (FALSE) ;
}
if (Common->status == KLU_EMPTY_MATRIX)
{
return (FALSE) ;
}
if (Numeric == NULL || Symbolic == NULL || d < Symbolic->n || nrhs < 0 ||
B == NULL)
{

View File

@ -1,17 +1,27 @@
//------------------------------------------------------------------------------
// KLU/Include/klu_version.h: internal include file for KLU
//------------------------------------------------------------------------------
// KLU, Copyright (c) 2004-2023, University of Florida. All Rights Reserved.
// Authors: Timothy A. Davis and Ekanathan Palamadai.
// SPDX-License-Identifier: LGPL-2.1+
//------------------------------------------------------------------------------
#ifndef _KLU_VERSION_H
#define _KLU_VERSION_H
#ifdef DLONG
#define Int UF_long
#define Int_id UF_long_id
#define Int_MAX UF_long_max
#define Int int64_t
#define Int_id "%" PRId64
#define Int_MAX INT64_MAX
#else
#define Int int
#define Int int32_t
#define Int_id "%d"
#define Int_MAX INT_MAX
#define Int_MAX INT32_MAX
#endif
#define NPRINT
#define NPRINT
#define BYTES(type,n) ((int) sizeof (type) * (n))
#define CEILING(b,u) (((b)+(u)-1) / (u))
@ -37,17 +47,18 @@
}
/* function names */
#ifdef COMPLEX
#ifdef COMPLEX
#ifdef DLONG
// zl: complex int64_t
#define KLU_scale klu_zl_scale
#define KLU_solve klu_zl_solve
#define KLU_tsolve klu_zl_tsolve
#define KLU_free_numeric klu_zl_free_numeric
#define KLU_factor klu_zl_factor
#define KLU_refactor klu_zl_refactor
#define KLU_kernel_factor klu_zl_kernel_factor
#define KLU_kernel_factor klu_zl_kernel_factor
#define KLU_lsolve klu_zl_lsolve
#define KLU_ltsolve klu_zl_ltsolve
#define KLU_usolve klu_zl_usolve
@ -64,13 +75,14 @@
#else
// z: complex int32_t
#define KLU_scale klu_z_scale
#define KLU_solve klu_z_solve
#define KLU_tsolve klu_z_tsolve
#define KLU_free_numeric klu_z_free_numeric
#define KLU_factor klu_z_factor
#define KLU_refactor klu_z_refactor
#define KLU_kernel_factor klu_z_kernel_factor
#define KLU_kernel_factor klu_z_kernel_factor
#define KLU_lsolve klu_z_lsolve
#define KLU_ltsolve klu_z_ltsolve
#define KLU_usolve klu_z_usolve
@ -96,13 +108,14 @@
#ifdef DLONG
// l: int64_t
#define KLU_scale klu_l_scale
#define KLU_solve klu_l_solve
#define KLU_tsolve klu_l_tsolve
#define KLU_free_numeric klu_l_free_numeric
#define KLU_factor klu_l_factor
#define KLU_refactor klu_l_refactor
#define KLU_kernel_factor klu_l_kernel_factor
#define KLU_kernel_factor klu_l_kernel_factor
#define KLU_lsolve klu_l_lsolve
#define KLU_ltsolve klu_l_ltsolve
#define KLU_usolve klu_l_usolve
@ -119,13 +132,14 @@
#else
// no prefix: int32_t
#define KLU_scale klu_scale
#define KLU_solve klu_solve
#define KLU_tsolve klu_tsolve
#define KLU_free_numeric klu_free_numeric
#define KLU_factor klu_factor
#define KLU_refactor klu_refactor
#define KLU_kernel_factor klu_kernel_factor
#define KLU_kernel_factor klu_kernel_factor
#define KLU_lsolve klu_lsolve
#define KLU_ltsolve klu_ltsolve
#define KLU_usolve klu_usolve
@ -152,6 +166,7 @@
#ifdef DLONG
// l: int64_t
#define KLU_analyze klu_l_analyze
#define KLU_analyze_given klu_l_analyze_given
#define KLU_alloc_symbolic klu_l_alloc_symbolic
@ -176,6 +191,7 @@
#else
// no prefiex: int64_t
#define KLU_analyze klu_analyze
#define KLU_analyze_given klu_analyze_given
#define KLU_alloc_symbolic klu_alloc_symbolic
@ -315,10 +331,10 @@ typedef double Unit ;
that possibility. ANSI C *does* guarantee that an array of structs has
the same size as n times the size of one struct.
The ANSI C99 version of the C language includes a "double _Complex" type.
The ANSI C11 version of the C language includes a "double complex" type.
It should be possible in that case to do the following:
#define Entry double _Complex
#define Entry double complex
and remove the Double_Complex struct. The macros, below, could then be
replaced with instrinsic operators. Note that the #define Real and
@ -365,7 +381,7 @@ typedef Double_Complex Unit ;
#define SPLIT(sz) ((sz) != (double *) NULL)
/* c = (s1) + (s2)*i, if s2 is null, then X is in "packed" format (compatible
* with Entry and ANSI C99 double _Complex type). */
* with Entry and ANSI C11 double complex type). */
/*#define ASSIGN(c,s1,s2,p,split) \
{ \
if (split) \