4
* -- SuperLU routine (version 2.0) --
5
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
6
* and Lawrence Berkeley National Lab.
12
* History: Modified from lapack routine CLANGE
18
float clangs(char *norm, SuperMatrix *A)
24
CLANGS returns the value of the one norm, or the Frobenius norm, or
25
the infinity norm, or the element of largest absolute value of a
31
CLANGE returns the value
33
CLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm'
35
( norm1(A), NORM = '1', 'O' or 'o'
37
( normI(A), NORM = 'I' or 'i'
39
( normF(A), NORM = 'F', 'f', 'E' or 'e'
41
where norm1 denotes the one norm of a matrix (maximum column sum),
42
normI denotes the infinity norm of a matrix (maximum row sum) and
43
normF denotes the Frobenius norm of a matrix (square root of sum of
44
squares). Note that max(abs(A(i,j))) is not a matrix norm.
49
NORM (input) CHARACTER*1
50
Specifies the value to be returned in CLANGE as described above.
51
A (input) SuperMatrix*
52
The M by N sparse matrix A.
54
=====================================================================
67
if ( SUPERLU_MIN(A->nrow, A->ncol) == 0) {
70
} else if (lsame_(norm, "M")) {
71
/* Find max(abs(A(i,j))). */
73
for (j = 0; j < A->ncol; ++j)
74
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++)
75
value = SUPERLU_MAX( value, c_abs( &Aval[i]) );
77
} else if (lsame_(norm, "O") || *(unsigned char *)norm == '1') {
80
for (j = 0; j < A->ncol; ++j) {
82
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++)
83
sum += c_abs( &Aval[i] );
84
value = SUPERLU_MAX(value,sum);
87
} else if (lsame_(norm, "I")) {
89
if ( !(rwork = (float *) SUPERLU_MALLOC(A->nrow * sizeof(float))) )
90
ABORT("SUPERLU_MALLOC fails for rwork.");
91
for (i = 0; i < A->nrow; ++i) rwork[i] = 0.;
92
for (j = 0; j < A->ncol; ++j)
93
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; i++) {
94
irow = Astore->rowind[i];
95
rwork[irow] += c_abs( &Aval[i] );
98
for (i = 0; i < A->nrow; ++i)
99
value = SUPERLU_MAX(value, rwork[i]);
101
SUPERLU_FREE (rwork);
103
} else if (lsame_(norm, "F") || lsame_(norm, "E")) {
105
ABORT("Not implemented.");
107
ABORT("Illegal norm specified.");