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 CLAQGE
19
claqgs(SuperMatrix *A, float *r, float *c,
20
float rowcnd, float colcnd, float amax, char *equed)
26
CLAQGS equilibrates a general sparse M by N matrix A using the row and
27
scaling factors in the vectors R and C.
29
See supermatrix.h for the definition of 'SuperMatrix' structure.
34
A (input/output) SuperMatrix*
35
On exit, the equilibrated matrix. See EQUED for the form of
36
the equilibrated matrix. The type of A can be:
37
Stype = NC; Dtype = SLU_C; Mtype = GE.
39
R (input) float*, dimension (A->nrow)
40
The row scale factors for A.
42
C (input) float*, dimension (A->ncol)
43
The column scale factors for A.
46
Ratio of the smallest R(i) to the largest R(i).
49
Ratio of the smallest C(i) to the largest C(i).
52
Absolute value of largest matrix entry.
55
Specifies the form of equilibration that was done.
56
= 'N': No equilibration
57
= 'R': Row equilibration, i.e., A has been premultiplied by
59
= 'C': Column equilibration, i.e., A has been postmultiplied
61
= 'B': Both row and column equilibration, i.e., A has been
62
replaced by diag(R) * A * diag(C).
67
THRESH is a threshold value used to decide if row or column scaling
68
should be done based on the ratio of the row or column scaling
69
factors. If ROWCND < THRESH, row scaling is done, and if
70
COLCND < THRESH, column scaling is done.
72
LARGE and SMALL are threshold values used to decide if row scaling
73
should be done based on the absolute size of the largest matrix
74
element. If AMAX > LARGE or AMAX < SMALL, row scaling is done.
76
=====================================================================
85
float large, small, cj;
86
extern double slamch_(char *);
90
/* Quick return if possible */
91
if (A->nrow <= 0 || A->ncol <= 0) {
92
*(unsigned char *)equed = 'N';
99
/* Initialize LARGE and SMALL. */
100
small = slamch_("Safe minimum") / slamch_("Precision");
103
if (rowcnd >= THRESH && amax >= small && amax <= large) {
104
if (colcnd >= THRESH)
105
*(unsigned char *)equed = 'N';
108
for (j = 0; j < A->ncol; ++j) {
110
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
111
cs_mult(&Aval[i], &Aval[i], cj);
114
*(unsigned char *)equed = 'C';
116
} else if (colcnd >= THRESH) {
117
/* Row scaling, no column scaling */
118
for (j = 0; j < A->ncol; ++j)
119
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
120
irow = Astore->rowind[i];
121
cs_mult(&Aval[i], &Aval[i], r[irow]);
123
*(unsigned char *)equed = 'R';
125
/* Row and column scaling */
126
for (j = 0; j < A->ncol; ++j) {
128
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
129
irow = Astore->rowind[i];
131
cs_mult(&Aval[i], &Aval[i], temp);
134
*(unsigned char *)equed = 'B';