/usr/share/doc/libsuperlu-dev/examples/clinsol.c is in libsuperlu3-dev 3.0+20070106-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /*
* -- SuperLU routine (version 3.0) --
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
* and Lawrence Berkeley National Lab.
* October 15, 2003
*
*/
#include "slu_cdefs.h"
main(int argc, char *argv[])
{
SuperMatrix A;
NCformat *Astore;
complex *a;
int *asub, *xa;
int *perm_c; /* column permutation vector */
int *perm_r; /* row permutations from partial pivoting */
SuperMatrix L; /* factor L */
SCformat *Lstore;
SuperMatrix U; /* factor U */
NCformat *Ustore;
SuperMatrix B;
int nrhs, ldx, info, m, n, nnz;
complex *xact, *rhs;
mem_usage_t mem_usage;
superlu_options_t options;
SuperLUStat_t stat;
#if ( DEBUGlevel>=1 )
CHECK_MALLOC("Enter main()");
#endif
/* Set the default input options:
options.Fact = DOFACT;
options.Equil = YES;
options.ColPerm = COLAMD;
options.DiagPivotThresh = 1.0;
options.Trans = NOTRANS;
options.IterRefine = NOREFINE;
options.SymmetricMode = NO;
options.PivotGrowth = NO;
options.ConditionNumber = NO;
options.PrintStat = YES;
*/
set_default_options(&options);
/* Read the matrix in Harwell-Boeing format. */
creadhb(&m, &n, &nnz, &a, &asub, &xa);
cCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_C, SLU_GE);
Astore = A.Store;
printf("Dimension %dx%d; # nonzeros %d\n", A.nrow, A.ncol, Astore->nnz);
nrhs = 1;
if ( !(rhs = complexMalloc(m * nrhs)) ) ABORT("Malloc fails for rhs[].");
cCreate_Dense_Matrix(&B, m, nrhs, rhs, m, SLU_DN, SLU_C, SLU_GE);
xact = complexMalloc(n * nrhs);
ldx = n;
cGenXtrue(n, nrhs, xact, ldx);
cFillRHS(options.Trans, nrhs, xact, ldx, &A, &B);
if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[].");
if ( !(perm_r = intMalloc(m)) ) ABORT("Malloc fails for perm_r[].");
/* Initialize the statistics variables. */
StatInit(&stat);
cgssv(&options, &A, perm_c, perm_r, &L, &U, &B, &stat, &info);
if ( info == 0 ) {
/* This is how you could access the solution matrix. */
complex *sol = (complex*) ((DNformat*) B.Store)->nzval;
/* Compute the infinity norm of the error. */
cinf_norm_error(nrhs, &B, xact);
Lstore = (SCformat *) L.Store;
Ustore = (NCformat *) U.Store;
printf("No of nonzeros in factor L = %d\n", Lstore->nnz);
printf("No of nonzeros in factor U = %d\n", Ustore->nnz);
printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz - n);
cQuerySpace(&L, &U, &mem_usage);
printf("L\\U MB %.3f\ttotal MB needed %.3f\texpansions %d\n",
mem_usage.for_lu/1e6, mem_usage.total_needed/1e6,
mem_usage.expansions);
} else {
printf("cgssv() error returns INFO= %d\n", info);
if ( info <= n ) { /* factorization completes */
cQuerySpace(&L, &U, &mem_usage);
printf("L\\U MB %.3f\ttotal MB needed %.3f\texpansions %d\n",
mem_usage.for_lu/1e6, mem_usage.total_needed/1e6,
mem_usage.expansions);
}
}
if ( options.PrintStat ) StatPrint(&stat);
StatFree(&stat);
SUPERLU_FREE (rhs);
SUPERLU_FREE (xact);
SUPERLU_FREE (perm_r);
SUPERLU_FREE (perm_c);
Destroy_CompCol_Matrix(&A);
Destroy_SuperMatrix_Store(&B);
Destroy_SuperNode_Matrix(&L);
Destroy_CompCol_Matrix(&U);
#if ( DEBUGlevel>=1 )
CHECK_MALLOC("Exit main()");
#endif
}
|