3
* -- SuperLU routine (version 2.0) --
4
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
5
* and Lawrence Berkeley National Lab.
10
#include "slu_cdefs.h"
13
cPivotGrowth(int ncols, SuperMatrix *A, int *perm_c,
14
SuperMatrix *L, SuperMatrix *U)
20
* Compute the reciprocal pivot growth factor of the leading ncols columns
21
* of the matrix, using the formula:
22
* min_j ( max_i(abs(A_ij)) / max_i(abs(U_ij)) )
28
* The number of columns of matrices A, L and U.
30
* A (input) SuperMatrix*
31
* Original matrix A, permuted by columns, of dimension
32
* (A->nrow, A->ncol). The type of A can be:
33
* Stype = NC; Dtype = SLU_C; Mtype = GE.
35
* L (output) SuperMatrix*
36
* The factor L from the factorization Pr*A=L*U; use compressed row
37
* subscripts storage for supernodes, i.e., L has type:
38
* Stype = SC; Dtype = SLU_C; Mtype = TRLU.
40
* U (output) SuperMatrix*
41
* The factor U from the factorization Pr*A*Pc=L*U. Use column-wise
42
* storage scheme, i.e., U has types: Stype = NC;
43
* Dtype = SLU_C; Mtype = TRU.
49
complex *Aval, *Lval, *Uval;
50
int fsupc, nsupr, luptr, nz_in_U;
53
float rpg, maxaj, maxuj;
54
extern double slamch_(char *);
59
/* Get machine constants. */
60
smlnum = slamch_("S");
70
inv_perm_c = (int *) SUPERLU_MALLOC(A->ncol*sizeof(int));
71
for (j = 0; j < A->ncol; ++j) inv_perm_c[perm_c[j]] = j;
73
for (k = 0; k <= Lstore->nsuper; ++k) {
74
fsupc = L_FST_SUPC(k);
75
nsupr = L_SUB_START(fsupc+1) - L_SUB_START(fsupc);
76
luptr = L_NZ_START(fsupc);
80
for (j = fsupc; j < L_FST_SUPC(k+1) && j < ncols; ++j) {
82
oldcol = inv_perm_c[j];
83
for (i = Astore->colptr[oldcol]; i < Astore->colptr[oldcol+1]; ++i)
84
maxaj = SUPERLU_MAX( maxaj, c_abs1( &Aval[i]) );
87
for (i = Ustore->colptr[j]; i < Ustore->colptr[j+1]; i++)
88
maxuj = SUPERLU_MAX( maxuj, c_abs1( &Uval[i]) );
91
for (i = 0; i < nz_in_U; ++i)
92
maxuj = SUPERLU_MAX( maxuj, c_abs1( &luval[i]) );
98
rpg = SUPERLU_MIN( rpg, 1.);
100
rpg = SUPERLU_MIN( rpg, maxaj / maxuj );
103
if ( j >= ncols ) break;
106
SUPERLU_FREE(inv_perm_c);