3
* -- SuperLU routine (version 3.0) --
4
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
5
* and Lawrence Berkeley National Lab.
11
* History: Modified from lapack routines ZGECON.
17
zgscon(char *norm, SuperMatrix *L, SuperMatrix *U,
18
double anorm, double *rcond, SuperLUStat_t *stat, int *info)
24
ZGSCON estimates the reciprocal of the condition number of a general
25
real matrix A, in either the 1-norm or the infinity-norm, using
26
the LU factorization computed by ZGETRF.
28
An estimate is obtained for norm(inv(A)), and the reciprocal of the
29
condition number is computed as
30
RCOND = 1 / ( norm(A) * norm(inv(A)) ).
32
See supermatrix.h for the definition of 'SuperMatrix' structure.
38
Specifies whether the 1-norm condition number or the
39
infinity-norm condition number is required:
43
L (input) SuperMatrix*
44
The factor L from the factorization Pr*A*Pc=L*U as computed by
45
zgstrf(). Use compressed row subscripts storage for supernodes,
46
i.e., L has types: Stype = SLU_SC, Dtype = SLU_Z, Mtype = SLU_TRLU.
48
U (input) SuperMatrix*
49
The factor U from the factorization Pr*A*Pc=L*U as computed by
50
zgstrf(). Use column-wise storage scheme, i.e., U has types:
51
Stype = SLU_NC, Dtype = SLU_Z, Mtype = TRU.
54
If NORM = '1' or 'O', the 1-norm of the original matrix A.
55
If NORM = 'I', the infinity-norm of the original matrix A.
57
RCOND (output) double*
58
The reciprocal of the condition number of the matrix A,
59
computed as RCOND = 1/(norm(A) * norm(inv(A))).
63
< 0: if INFO = -i, the i-th argument had an illegal value
65
=====================================================================
69
int kase, kase1, onenrm, i;
72
extern int zrscl_(int *, doublecomplex *, doublecomplex *, int *);
74
extern int zlacon_(int *, doublecomplex *, doublecomplex *, double *, int *);
77
/* Test the input parameters. */
79
onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
80
if (! onenrm && ! lsame_(norm, "I")) *info = -1;
81
else if (L->nrow < 0 || L->nrow != L->ncol ||
82
L->Stype != SLU_SC || L->Dtype != SLU_Z || L->Mtype != SLU_TRLU)
84
else if (U->nrow < 0 || U->nrow != U->ncol ||
85
U->Stype != SLU_NC || U->Dtype != SLU_Z || U->Mtype != SLU_TRU)
89
xerbla_("zgscon", &i);
93
/* Quick return if possible */
95
if ( L->nrow == 0 || U->nrow == 0) {
100
work = doublecomplexCalloc( 3*L->nrow );
104
ABORT("Malloc fails for work arrays in zgscon.");
106
/* Estimate the norm of inv(A). */
108
if ( onenrm ) kase1 = 1;
113
zlacon_(&L->nrow, &work[L->nrow], &work[0], &ainvnm, &kase);
115
if (kase == 0) break;
118
/* Multiply by inv(L). */
119
sp_ztrsv("L", "No trans", "Unit", L, U, &work[0], stat, info);
121
/* Multiply by inv(U). */
122
sp_ztrsv("U", "No trans", "Non-unit", L, U, &work[0], stat, info);
126
/* Multiply by inv(U'). */
127
sp_ztrsv("U", "Transpose", "Non-unit", L, U, &work[0], stat, info);
129
/* Multiply by inv(L'). */
130
sp_ztrsv("L", "Transpose", "Unit", L, U, &work[0], stat, info);
134
} while ( kase != 0 );
136
/* Compute the estimate of the reciprocal condition number. */
137
if (ainvnm != 0.) *rcond = (1. / ainvnm) / anorm;