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 SLAQGE
19
slaqgs(SuperMatrix *A, float *r, float *c,
20
float rowcnd, float colcnd, float amax, char *equed)
26
SLAQGS 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 = S_; 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 *);
89
/* Quick return if possible */
90
if (A->nrow <= 0 || A->ncol <= 0) {
91
*(unsigned char *)equed = 'N';
98
/* Initialize LARGE and SMALL. */
99
small = slamch_("Safe minimum") / slamch_("Precision");
102
if (rowcnd >= THRESH && amax >= small && amax <= large) {
103
if (colcnd >= THRESH)
104
*(unsigned char *)equed = 'N';
107
for (j = 0; j < A->ncol; ++j) {
109
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
113
*(unsigned char *)equed = 'C';
115
} else if (colcnd >= THRESH) {
116
/* Row scaling, no column scaling */
117
for (j = 0; j < A->ncol; ++j)
118
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
119
irow = Astore->rowind[i];
122
*(unsigned char *)equed = 'R';
124
/* Row and column scaling */
125
for (j = 0; j < A->ncol; ++j) {
127
for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
128
irow = Astore->rowind[i];
129
Aval[i] *= cj * r[irow];
132
*(unsigned char *)equed = 'B';