/* * Generate a banded square matrix A, with dimension n and semi-bandwidth b. */ void zband(int n, int b, int nonz, doublecomplex **nzval, int **rowind, int **colptr) { int iseed[] = {1992,1993,1994,1995}; register int i, j, ub, lb, ilow, ihigh, lasta = 0; doublecomplex *a; int *asub, *xa; doublecomplex *val; int *row; extern double dlaran_(); printf("A banded matrix."); zallocateA(n, nonz, nzval, rowind, colptr); /* Allocate storage */ a = *nzval; asub = *rowind; xa = *colptr; ub = lb = b; for (i = 0; i < 4; ++i) iseed[i] = abs( iseed[i] ) % 4096; if ( iseed[3] % 2 != 1 ) ++iseed[3]; for (j = 0; j < n; ++j) { xa[j] = lasta; val = &a[lasta]; row = &asub[lasta]; ilow = SUPERLU_MAX(0, j - ub); ihigh = SUPERLU_MIN(n-1, j + lb); for (i = ilow; i <= ihigh; ++i) { val[i-ilow].r = dlaran_(iseed); row[i-ilow] = i; } lasta += ihigh - ilow + 1; } /* for j ... */ xa[n] = lasta; }
/* * Generate a block diagonal matrix A. */ void zblockdiag(int nb, /* number of blocks */ int bs, /* block size */ int nonz, doublecomplex **nzval, int **rowind, int **colptr) { int iseed[] = {1992,1993,1994,1995}; register int i, j, b, n, lasta = 0, cstart, rstart; doublecomplex *a; int *asub, *xa; doublecomplex *val; int *row; extern double dlaran_(); n = bs * nb; printf("A block diagonal matrix: nb %d, bs %d, n %d\n", nb, bs, n); zallocateA(n, nonz, nzval, rowind, colptr); /* Allocate storage */ a = *nzval; asub = *rowind; xa = *colptr; for (i = 0; i < 4; ++i) iseed[i] = abs( iseed[i] ) % 4096; if ( iseed[3] % 2 != 1 ) ++iseed[3]; for (b = 0; b < nb; ++b) { cstart = b * bs; /* start of the col # of the current block */ rstart = b * bs; /* start of the row # of the current block */ for (j = cstart; j < cstart + bs; ++j) { xa[j] = lasta; val = &a[lasta]; row = &asub[lasta]; for (i = 0; i < bs; ++i) { val[i].r = dlaran_(iseed); row[i] = i + rstart; } lasta += bs; } /* for j ... */ } /* for b ... */ xa[n] = lasta; }
void zreadhb(int *nrow, int *ncol, int *nonz, doublecomplex **nzval, int **rowind, int **colptr) { /* * Purpose * ======= * * Read a DOUBLE COMPLEX PRECISION matrix stored in Harwell-Boeing format * as described below. * * Line 1 (A72,A8) * Col. 1 - 72 Title (TITLE) * Col. 73 - 80 Key (KEY) * * Line 2 (5I14) * Col. 1 - 14 Total number of lines excluding header (TOTCRD) * Col. 15 - 28 Number of lines for pointers (PTRCRD) * Col. 29 - 42 Number of lines for row (or variable) indices (INDCRD) * Col. 43 - 56 Number of lines for numerical values (VALCRD) * Col. 57 - 70 Number of lines for right-hand sides (RHSCRD) * (including starting guesses and solution vectors * if present) * (zero indicates no right-hand side data is present) * * Line 3 (A3, 11X, 4I14) * Col. 1 - 3 Matrix type (see below) (MXTYPE) * Col. 15 - 28 Number of rows (or variables) (NROW) * Col. 29 - 42 Number of columns (or elements) (NCOL) * Col. 43 - 56 Number of row (or variable) indices (NNZERO) * (equal to number of entries for assembled matrices) * Col. 57 - 70 Number of elemental matrix entries (NELTVL) * (zero in the case of assembled matrices) * Line 4 (2A16, 2A20) * Col. 1 - 16 Format for pointers (PTRFMT) * Col. 17 - 32 Format for row (or variable) indices (INDFMT) * Col. 33 - 52 Format for numerical values of coefficient matrix (VALFMT) * Col. 53 - 72 Format for numerical values of right-hand sides (RHSFMT) * * Line 5 (A3, 11X, 2I14) Only present if there are right-hand sides present * Col. 1 Right-hand side type: * F for full storage or M for same format as matrix * Col. 2 G if a starting vector(s) (Guess) is supplied. (RHSTYP) * Col. 3 X if an exact solution vector(s) is supplied. * Col. 15 - 28 Number of right-hand sides (NRHS) * Col. 29 - 42 Number of row indices (NRHSIX) * (ignored in case of unassembled matrices) * * The three character type field on line 3 describes the matrix type. * The following table lists the permitted values for each of the three * characters. As an example of the type field, RSA denotes that the matrix * is real, symmetric, and assembled. * * First Character: * R Real matrix * C Complex matrix * P Pattern only (no numerical values supplied) * * Second Character: * S Symmetric * U Unsymmetric * H Hermitian * Z Skew symmetric * R Rectangular * * Third Character: * A Assembled * E Elemental matrices (unassembled) * */ register int i, numer_lines = 0, rhscrd = 0; int tmp, colnum, colsize, rownum, rowsize, valnum, valsize; char buf[100], type[4], key[10]; FILE *fp; fp = stdin; /* Line 1 */ fgets(buf, 100, fp); fputs(buf, stdout); #if 0 fscanf(fp, "%72c", buf); buf[72] = 0; printf("Title: %s", buf); fscanf(fp, "%8c", key); key[8] = 0; printf("Key: %s\n", key); zDumpLine(fp); #endif /* Line 2 */ for (i=0; i<5; i++) { fscanf(fp, "%14c", buf); buf[14] = 0; sscanf(buf, "%d", &tmp); if (i == 3) numer_lines = tmp; if (i == 4 && tmp) rhscrd = tmp; } zDumpLine(fp); /* Line 3 */ fscanf(fp, "%3c", type); fscanf(fp, "%11c", buf); /* pad */ type[3] = 0; #ifdef DEBUG printf("Matrix type %s\n", type); #endif fscanf(fp, "%14c", buf); sscanf(buf, "%d", nrow); fscanf(fp, "%14c", buf); sscanf(buf, "%d", ncol); fscanf(fp, "%14c", buf); sscanf(buf, "%d", nonz); fscanf(fp, "%14c", buf); sscanf(buf, "%d", &tmp); if (tmp != 0) printf("This is not an assembled matrix!\n"); if (*nrow != *ncol) printf("Matrix is not square.\n"); zDumpLine(fp); /* Allocate storage for the three arrays ( nzval, rowind, colptr ) */ zallocateA(*ncol, *nonz, nzval, rowind, colptr); /* Line 4: format statement */ fscanf(fp, "%16c", buf); zParseIntFormat(buf, &colnum, &colsize); fscanf(fp, "%16c", buf); zParseIntFormat(buf, &rownum, &rowsize); fscanf(fp, "%20c", buf); zParseFloatFormat(buf, &valnum, &valsize); fscanf(fp, "%20c", buf); zDumpLine(fp); /* Line 5: right-hand side */ if ( rhscrd ) zDumpLine(fp); /* skip RHSFMT */ #ifdef DEBUG printf("%d rows, %d nonzeros\n", *nrow, *nonz); printf("colnum %d, colsize %d\n", colnum, colsize); printf("rownum %d, rowsize %d\n", rownum, rowsize); printf("valnum %d, valsize %d\n", valnum, valsize); #endif zReadVector(fp, *ncol+1, *colptr, colnum, colsize); zReadVector(fp, *nonz, *rowind, rownum, rowsize); if ( numer_lines ) { zReadValues(fp, *nonz, *nzval, valnum, valsize); } fclose(fp); }
void zreadtriple(int *m, int *n, int *nonz, doublecomplex **nzval, int **rowind, int **colptr) { /* * Output parameters * ================= * (a,asub,xa): asub[*] contains the row subscripts of nonzeros * in columns of matrix A; a[*] the numerical values; * row i of A is given by a[k],k=xa[i],...,xa[i+1]-1. * */ int j, k, jsize, nnz, nz; doublecomplex *a, *val; int *asub, *xa, *row, *col; int zero_base = 0; /* Matrix format: * First line: #rows, #cols, #non-zero * Triplet in the rest of lines: * row, col, value */ scanf("%d%d", n, nonz); *m = *n; printf("m %d, n %d, nonz %d\n", *m, *n, *nonz); zallocateA(*n, *nonz, nzval, rowind, colptr); /* Allocate storage */ a = *nzval; asub = *rowind; xa = *colptr; val = (doublecomplex *) SUPERLU_MALLOC(*nonz * sizeof(doublecomplex)); row = (int *) SUPERLU_MALLOC(*nonz * sizeof(int)); col = (int *) SUPERLU_MALLOC(*nonz * sizeof(int)); for (j = 0; j < *n; ++j) xa[j] = 0; /* Read into the triplet array from a file */ for (nnz = 0, nz = 0; nnz < *nonz; ++nnz) { scanf("%d%d%lf%lf\n", &row[nz], &col[nz], &val[nz].r, &val[nz].i); if ( nnz == 0 ) { /* first nonzero */ if ( row[0] == 0 || col[0] == 0 ) { zero_base = 1; printf("triplet file: row/col indices are zero-based.\n"); } else printf("triplet file: row/col indices are one-based.\n"); } if ( !zero_base ) { /* Change to 0-based indexing. */ --row[nz]; --col[nz]; } if (row[nz] < 0 || row[nz] >= *m || col[nz] < 0 || col[nz] >= *n /*|| val[nz] == 0.*/) { fprintf(stderr, "nz %d, (%d, %d) = (%e,%e) out of bound, removed\n", nz, row[nz], col[nz], val[nz].r, val[nz].i); exit(-1); } else { ++xa[col[nz]]; ++nz; } } *nonz = nz; /* Initialize the array of column pointers */ k = 0; jsize = xa[0]; xa[0] = 0; for (j = 1; j < *n; ++j) { k += jsize; jsize = xa[j]; xa[j] = k; } /* Copy the triplets into the column oriented storage */ for (nz = 0; nz < *nonz; ++nz) { j = col[nz]; k = xa[j]; asub[k] = row[nz]; a[k] = val[nz]; ++xa[j]; } /* Reset the column pointers to the beginning of each column */ for (j = *n; j > 0; --j) xa[j] = xa[j-1]; xa[0] = 0; SUPERLU_FREE(val); SUPERLU_FREE(row); SUPERLU_FREE(col); #ifdef CHK_INPUT { int i; for (i = 0; i < *n; i++) { printf("Col %d, xa %d\n", i, xa[i]); for (k = xa[i]; k < xa[i+1]; k++) printf("%d\t%16.10f\n", asub[k], a[k]); } } #endif }
void zreadrb(int *nrow, int *ncol, int *nonz, doublecomplex **nzval, int **rowind, int **colptr) { register int i, numer_lines = 0; int tmp, colnum, colsize, rownum, rowsize, valnum, valsize; char buf[100], type[4]; int sym; FILE *fp; fp = stdin; /* Line 1 */ fgets(buf, 100, fp); fputs(buf, stdout); /* Line 2 */ for (i=0; i<4; i++) { fscanf(fp, "%14c", buf); buf[14] = 0; sscanf(buf, "%d", &tmp); if (i == 3) numer_lines = tmp; } zDumpLine(fp); /* Line 3 */ fscanf(fp, "%3c", type); fscanf(fp, "%11c", buf); /* pad */ type[3] = 0; #ifdef DEBUG printf("Matrix type %s\n", type); #endif fscanf(fp, "%14c", buf); sscanf(buf, "%d", nrow); fscanf(fp, "%14c", buf); sscanf(buf, "%d", ncol); fscanf(fp, "%14c", buf); sscanf(buf, "%d", nonz); fscanf(fp, "%14c", buf); sscanf(buf, "%d", &tmp); if (tmp != 0) printf("This is not an assembled matrix!\n"); if (*nrow != *ncol) printf("Matrix is not square.\n"); zDumpLine(fp); /* Allocate storage for the three arrays ( nzval, rowind, colptr ) */ zallocateA(*ncol, *nonz, nzval, rowind, colptr); /* Line 4: format statement */ fscanf(fp, "%16c", buf); zParseIntFormat(buf, &colnum, &colsize); fscanf(fp, "%16c", buf); zParseIntFormat(buf, &rownum, &rowsize); fscanf(fp, "%20c", buf); zParseFloatFormat(buf, &valnum, &valsize); zDumpLine(fp); #ifdef DEBUG printf("%d rows, %d nonzeros\n", *nrow, *nonz); printf("colnum %d, colsize %d\n", colnum, colsize); printf("rownum %d, rowsize %d\n", rownum, rowsize); printf("valnum %d, valsize %d\n", valnum, valsize); #endif ReadVector(fp, *ncol+1, *colptr, colnum, colsize); ReadVector(fp, *nonz, *rowind, rownum, rowsize); if ( numer_lines ) { zReadValues(fp, *nonz, *nzval, valnum, valsize); } sym = (type[1] == 'S' || type[1] == 's'); if ( sym ) { FormFullA(*ncol, nonz, nzval, rowind, colptr); } fclose(fp); }
main(int argc, char *argv[]) { /* * Purpose * ======= * * ZDRIVE is the main test program for the DOUBLE COMPLEX linear * equation driver routines ZGSSV and ZGSSVX. * * The program is invoked by a shell script file -- ztest.csh. * The output from the tests are written into a file -- ztest.out. * * ===================================================================== */ doublecomplex *a, *a_save; int *asub, *asub_save; int *xa, *xa_save; SuperMatrix A, B, X, L, U; SuperMatrix ASAV, AC; mem_usage_t mem_usage; int *perm_r; /* row permutation from partial pivoting */ int *perm_c, *pc_save; /* column permutation */ int *etree; doublecomplex zero = {0.0, 0.0}; double *R, *C; double *ferr, *berr; double *rwork; doublecomplex *wwork; void *work; int info, lwork, nrhs, panel_size, relax; int m, n, nnz; doublecomplex *xact; doublecomplex *rhsb, *solx, *bsav; int ldb, ldx; double rpg, rcond; int i, j, k1; double rowcnd, colcnd, amax; int maxsuper, rowblk, colblk; int prefact, nofact, equil, iequed; int nt, nrun, nfail, nerrs, imat, fimat, nimat; int nfact, ifact, itran; int kl, ku, mode, lda; int zerot, izero, ioff; double u; double anorm, cndnum; doublecomplex *Afull; double result[NTESTS]; superlu_options_t options; fact_t fact; trans_t trans; SuperLUStat_t stat; static char matrix_type[8]; static char equed[1], path[4], sym[1], dist[1]; /* Fixed set of parameters */ int iseed[] = {1988, 1989, 1990, 1991}; static char equeds[] = {'N', 'R', 'C', 'B'}; static fact_t facts[] = {FACTORED, DOFACT, SamePattern, SamePattern_SameRowPerm}; static trans_t transs[] = {NOTRANS, TRANS, CONJ}; /* Some function prototypes */ extern int zgst01(int, int, SuperMatrix *, SuperMatrix *, SuperMatrix *, int *, int *, double *); extern int zgst02(trans_t, int, int, int, SuperMatrix *, doublecomplex *, int, doublecomplex *, int, double *resid); extern int zgst04(int, int, doublecomplex *, int, doublecomplex *, int, double rcond, double *resid); extern int zgst07(trans_t, int, int, SuperMatrix *, doublecomplex *, int, doublecomplex *, int, doublecomplex *, int, double *, double *, double *); extern int zlatb4_(char *, int *, int *, int *, char *, int *, int *, double *, int *, double *, char *); extern int zlatms_(int *, int *, char *, int *, char *, double *d, int *, double *, double *, int *, int *, char *, doublecomplex *, int *, doublecomplex *, int *); extern int sp_zconvert(int, int, doublecomplex *, int, int, int, doublecomplex *a, int *, int *, int *); /* Executable statements */ strcpy(path, "ZGE"); nrun = 0; nfail = 0; nerrs = 0; /* Defaults */ lwork = 0; n = 1; nrhs = 1; panel_size = sp_ienv(1); relax = sp_ienv(2); u = 1.0; strcpy(matrix_type, "LA"); parse_command_line(argc, argv, matrix_type, &n, &panel_size, &relax, &nrhs, &maxsuper, &rowblk, &colblk, &lwork, &u); if ( lwork > 0 ) { work = SUPERLU_MALLOC(lwork); if ( !work ) { fprintf(stderr, "expert: cannot allocate %d bytes\n", lwork); exit (-1); } } /* Set the default input options. */ set_default_options(&options); options.DiagPivotThresh = u; options.PrintStat = NO; options.PivotGrowth = YES; options.ConditionNumber = YES; options.IterRefine = DOUBLE; if ( strcmp(matrix_type, "LA") == 0 ) { /* Test LAPACK matrix suite. */ m = n; lda = SUPERLU_MAX(n, 1); nnz = n * n; /* upper bound */ fimat = 1; nimat = NTYPES; Afull = doublecomplexCalloc(lda * n); zallocateA(n, nnz, &a, &asub, &xa); } else { /* Read a sparse matrix */ fimat = nimat = 0; zreadhb(&m, &n, &nnz, &a, &asub, &xa); } zallocateA(n, nnz, &a_save, &asub_save, &xa_save); rhsb = doublecomplexMalloc(m * nrhs); bsav = doublecomplexMalloc(m * nrhs); solx = doublecomplexMalloc(n * nrhs); ldb = m; ldx = n; zCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_Z, SLU_GE); zCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_Z, SLU_GE); xact = doublecomplexMalloc(n * nrhs); etree = intMalloc(n); perm_r = intMalloc(n); perm_c = intMalloc(n); pc_save = intMalloc(n); R = (double *) SUPERLU_MALLOC(m*sizeof(double)); C = (double *) SUPERLU_MALLOC(n*sizeof(double)); ferr = (double *) SUPERLU_MALLOC(nrhs*sizeof(double)); berr = (double *) SUPERLU_MALLOC(nrhs*sizeof(double)); j = SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs); rwork = (double *) SUPERLU_MALLOC(j*sizeof(double)); for (i = 0; i < j; ++i) rwork[i] = 0.; if ( !R ) ABORT("SUPERLU_MALLOC fails for R"); if ( !C ) ABORT("SUPERLU_MALLOC fails for C"); if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr"); if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr"); if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork"); wwork = doublecomplexCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i; options.ColPerm = MY_PERMC; for (imat = fimat; imat <= nimat; ++imat) { /* All matrix types */ if ( imat ) { /* Skip types 5, 6, or 7 if the matrix size is too small. */ zerot = (imat >= 5 && imat <= 7); if ( zerot && n < imat-4 ) continue; /* Set up parameters with ZLATB4 and generate a test matrix with ZLATMS. */ zlatb4_(path, &imat, &n, &n, sym, &kl, &ku, &anorm, &mode, &cndnum, dist); zlatms_(&n, &n, dist, iseed, sym, &rwork[0], &mode, &cndnum, &anorm, &kl, &ku, "No packing", Afull, &lda, &wwork[0], &info); if ( info ) { printf(FMT3, "ZLATMS", info, izero, n, nrhs, imat, nfail); continue; } /* For types 5-7, zero one or more columns of the matrix to test that INFO is returned correctly. */ if ( zerot ) { if ( imat == 5 ) izero = 1; else if ( imat == 6 ) izero = n; else izero = n / 2 + 1; ioff = (izero - 1) * lda; if ( imat < 7 ) { for (i = 0; i < n; ++i) Afull[ioff + i] = zero; } else { for (j = 0; j < n - izero + 1; ++j) for (i = 0; i < n; ++i) Afull[ioff + i + j*lda] = zero; } } else { izero = 0; } /* Convert to sparse representation. */ sp_zconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz); } else { izero = 0; zerot = 0; } zCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_Z, SLU_GE); /* Save a copy of matrix A in ASAV */ zCreate_CompCol_Matrix(&ASAV, m, n, nnz, a_save, asub_save, xa_save, SLU_NC, SLU_Z, SLU_GE); zCopy_CompCol_Matrix(&A, &ASAV); /* Form exact solution. */ zGenXtrue(n, nrhs, xact, ldx); StatInit(&stat); for (iequed = 0; iequed < 4; ++iequed) { *equed = equeds[iequed]; if (iequed == 0) nfact = 4; else nfact = 1; /* Only test factored, pre-equilibrated matrix */ for (ifact = 0; ifact < nfact; ++ifact) { fact = facts[ifact]; options.Fact = fact; for (equil = 0; equil < 2; ++equil) { options.Equil = equil; prefact = ( options.Fact == FACTORED || options.Fact == SamePattern_SameRowPerm ); /* Need a first factor */ nofact = (options.Fact != FACTORED); /* Not factored */ /* Restore the matrix A. */ zCopy_CompCol_Matrix(&ASAV, &A); if ( zerot ) { if ( prefact ) continue; } else if ( options.Fact == FACTORED ) { if ( equil || iequed ) { /* Compute row and column scale factors to equilibrate matrix A. */ zgsequ(&A, R, C, &rowcnd, &colcnd, &amax, &info); /* Force equilibration. */ if ( !info && n > 0 ) { if ( lsame_(equed, "R") ) { rowcnd = 0.; colcnd = 1.; } else if ( lsame_(equed, "C") ) { rowcnd = 1.; colcnd = 0.; } else if ( lsame_(equed, "B") ) { rowcnd = 0.; colcnd = 0.; } } /* Equilibrate the matrix. */ zlaqgs(&A, R, C, rowcnd, colcnd, amax, equed); } } if ( prefact ) { /* Need a factor for the first time */ /* Save Fact option. */ fact = options.Fact; options.Fact = DOFACT; /* Preorder the matrix, obtain the column etree. */ sp_preorder(&options, &A, perm_c, etree, &AC); /* Factor the matrix AC. */ zgstrf(&options, &AC, relax, panel_size, etree, work, lwork, perm_c, perm_r, &L, &U, &stat, &info); if ( info ) { printf("** First factor: info %d, equed %c\n", info, *equed); if ( lwork == -1 ) { printf("** Estimated memory: %d bytes\n", info - n); exit(0); } } Destroy_CompCol_Permuted(&AC); /* Restore Fact option. */ options.Fact = fact; } /* if .. first time factor */ for (itran = 0; itran < NTRAN; ++itran) { trans = transs[itran]; options.Trans = trans; /* Restore the matrix A. */ zCopy_CompCol_Matrix(&ASAV, &A); /* Set the right hand side. */ zFillRHS(trans, nrhs, xact, ldx, &A, &B); zCopy_Dense_Matrix(m, nrhs, rhsb, ldb, bsav, ldb); /*---------------- * Test zgssv *----------------*/ if ( options.Fact == DOFACT && itran == 0) { /* Not yet factored, and untransposed */ zCopy_Dense_Matrix(m, nrhs, rhsb, ldb, solx, ldx); zgssv(&options, &A, perm_c, perm_r, &L, &U, &X, &stat, &info); if ( info && info != izero ) { printf(FMT3, "zgssv", info, izero, n, nrhs, imat, nfail); } else { /* Reconstruct matrix from factors and compute residual. */ zgst01(m, n, &A, &L, &U, perm_c, perm_r, &result[0]); nt = 1; if ( izero == 0 ) { /* Compute residual of the computed solution. */ zCopy_Dense_Matrix(m, nrhs, rhsb, ldb, wwork, ldb); zgst02(trans, m, n, nrhs, &A, solx, ldx, wwork,ldb, &result[1]); nt = 2; } /* Print information about the tests that did not pass the threshold. */ for (i = 0; i < nt; ++i) { if ( result[i] >= THRESH ) { printf(FMT1, "zgssv", n, i, result[i]); ++nfail; } } nrun += nt; } /* else .. info == 0 */ /* Restore perm_c. */ for (i = 0; i < n; ++i) perm_c[i] = pc_save[i]; if (lwork == 0) { Destroy_SuperNode_Matrix(&L); Destroy_CompCol_Matrix(&U); } } /* if .. end of testing zgssv */ /*---------------- * Test zgssvx *----------------*/ /* Equilibrate the matrix if fact = FACTORED and equed = 'R', 'C', or 'B'. */ if ( options.Fact == FACTORED && (equil || iequed) && n > 0 ) { zlaqgs(&A, R, C, rowcnd, colcnd, amax, equed); } /* Solve the system and compute the condition number and error bounds using zgssvx. */ zgssvx(&options, &A, perm_c, perm_r, etree, equed, R, C, &L, &U, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &mem_usage, &stat, &info); if ( info && info != izero ) { printf(FMT3, "zgssvx", info, izero, n, nrhs, imat, nfail); if ( lwork == -1 ) { printf("** Estimated memory: %.0f bytes\n", mem_usage.total_needed); exit(0); } } else { if ( !prefact ) { /* Reconstruct matrix from factors and compute residual. */ zgst01(m, n, &A, &L, &U, perm_c, perm_r, &result[0]); k1 = 0; } else { k1 = 1; } if ( !info ) { /* Compute residual of the computed solution.*/ zCopy_Dense_Matrix(m, nrhs, bsav, ldb, wwork, ldb); zgst02(trans, m, n, nrhs, &ASAV, solx, ldx, wwork, ldb, &result[1]); /* Check solution from generated exact solution. */ zgst04(n, nrhs, solx, ldx, xact, ldx, rcond, &result[2]); /* Check the error bounds from iterative refinement. */ zgst07(trans, n, nrhs, &ASAV, bsav, ldb, solx, ldx, xact, ldx, ferr, berr, &result[3]); /* Print information about the tests that did not pass the threshold. */ for (i = k1; i < NTESTS; ++i) { if ( result[i] >= THRESH ) { printf(FMT2, "zgssvx", options.Fact, trans, *equed, n, imat, i, result[i]); ++nfail; } } nrun += NTESTS; } /* if .. info == 0 */ } /* else .. end of testing zgssvx */ } /* for itran ... */ if ( lwork == 0 ) { Destroy_SuperNode_Matrix(&L); Destroy_CompCol_Matrix(&U); } } /* for equil ... */ } /* for ifact ... */ } /* for iequed ... */ #if 0 if ( !info ) { PrintPerf(&L, &U, &mem_usage, rpg, rcond, ferr, berr, equed); } #endif } /* for imat ... */ /* Print a summary of the results. */ PrintSumm("ZGE", nfail, nrun, nerrs); SUPERLU_FREE (rhsb); SUPERLU_FREE (bsav); SUPERLU_FREE (solx); SUPERLU_FREE (xact); SUPERLU_FREE (etree); SUPERLU_FREE (perm_r); SUPERLU_FREE (perm_c); SUPERLU_FREE (pc_save); SUPERLU_FREE (R); SUPERLU_FREE (C); SUPERLU_FREE (ferr); SUPERLU_FREE (berr); SUPERLU_FREE (rwork); SUPERLU_FREE (wwork); Destroy_SuperMatrix_Store(&B); Destroy_SuperMatrix_Store(&X); Destroy_CompCol_Matrix(&A); Destroy_CompCol_Matrix(&ASAV); if ( lwork > 0 ) { SUPERLU_FREE (work); Destroy_SuperMatrix_Store(&L); Destroy_SuperMatrix_Store(&U); } StatFree(&stat); return 0; }