4
* -- SuperLU routine (version 2.0) --
5
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
6
* and Lawrence Berkeley National Lab.
11
Copyright (c) 1994 by Xerox Corporation. All rights reserved.
13
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
14
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
16
Permission is hereby granted to use or copy this program for any
17
purpose, provided the above notices are retained on all copies.
18
Permission to modify the code and to distribute modified code is
19
granted, provided the above notices are retained, and a notice that
20
the code was modified is included with the above copyright notice.
32
const int jcol, /* in */
33
const float u, /* in - diagonal pivoting threshold */
34
int *usepr, /* re-use the pivot sequence given by perm_r/iperm_r */
35
int *perm_r, /* may be modified */
36
int *iperm_r, /* in - inverse of perm_r */
37
int *iperm_c, /* in - used to find diagonal of Pc*A*Pc' */
38
int *pivrow, /* out */
39
GlobalLU_t *Glu /* modified - global LU data structures */
45
* Performs the numerical pivoting on the current column of L,
46
* and the CDIV operation.
49
* (1) Compute thresh = u * max_(i>=j) abs(A_ij);
50
* (2) IF user specifies pivot row k and abs(A_kj) >= thresh THEN
52
* ELSE IF abs(A_jj) >= thresh THEN
57
* Note: If you absolutely want to use a given pivot order, then set u=0.0.
59
* Return value: 0 success;
60
* i > 0 U(i,i) is exactly zero.
63
complex one = {1.0, 0.0};
64
int fsupc; /* first column in the supernode */
65
int nsupc; /* no of columns in the supernode */
66
int nsupr; /* no of rows in the supernode */
67
int lptr; /* points to the starting subscript of the supernode */
68
int pivptr, old_pivptr, diag, diagind;
69
float pivmax, rtemp, thresh;
74
int isub, icol, k, itemp;
78
extern SuperLUStat_t SuperLUStat;
79
flops_t *ops = SuperLUStat.ops;
81
/* Initialize pointers */
86
fsupc = (Glu->xsup)[(Glu->supno)[jcol]];
87
nsupc = jcol - fsupc; /* excluding jcol; nsupc >= 0 */
89
nsupr = xlsub[fsupc+1] - lptr;
90
lu_sup_ptr = &lusup[xlusup[fsupc]]; /* start of the current supernode */
91
lu_col_ptr = &lusup[xlusup[jcol]]; /* start of jcol in the supernode */
92
lsub_ptr = &lsub[lptr]; /* start of row indices of the supernode */
95
if ( jcol == MIN_COL ) {
96
printf("Before cdiv: col %d\n", jcol);
97
for (k = nsupc; k < nsupr; k++)
98
printf(" lu[%d] %f\n", lsub_ptr[k], lu_col_ptr[k]);
102
/* Determine the largest abs numerical value for partial pivoting;
103
Also search for user-specified pivot, and diagonal element. */
104
if ( *usepr ) *pivrow = iperm_r[jcol];
105
diagind = iperm_c[jcol];
110
for (isub = nsupc; isub < nsupr; ++isub) {
111
rtemp = c_abs1 (&lu_col_ptr[isub]);
112
if ( rtemp > pivmax ) {
116
if ( *usepr && lsub_ptr[isub] == *pivrow ) old_pivptr = isub;
117
if ( lsub_ptr[isub] == diagind ) diag = isub;
120
/* Test for singularity */
121
if ( pivmax == 0.0 ) {
122
*pivrow = lsub_ptr[pivptr];
123
perm_r[*pivrow] = jcol;
130
/* Choose appropriate pivotal element by our policy. */
132
rtemp = c_abs1 (&lu_col_ptr[old_pivptr]);
133
if ( rtemp != 0.0 && rtemp >= thresh )
139
/* Use diagonal pivot? */
140
if ( diag >= 0 ) { /* diagonal exists */
141
rtemp = c_abs1 (&lu_col_ptr[diag]);
142
if ( rtemp != 0.0 && rtemp >= thresh ) pivptr = diag;
144
*pivrow = lsub_ptr[pivptr];
147
/* Record pivot row */
148
perm_r[*pivrow] = jcol;
150
/* Interchange row subscripts */
151
if ( pivptr != nsupc ) {
152
itemp = lsub_ptr[pivptr];
153
lsub_ptr[pivptr] = lsub_ptr[nsupc];
154
lsub_ptr[nsupc] = itemp;
156
/* Interchange numerical values as well, for the whole snode, such
157
* that L is indexed the same way as A.
159
for (icol = 0; icol <= nsupc; icol++) {
160
itemp = pivptr + icol * nsupr;
161
temp = lu_sup_ptr[itemp];
162
lu_sup_ptr[itemp] = lu_sup_ptr[nsupc + icol*nsupr];
163
lu_sup_ptr[nsupc + icol*nsupr] = temp;
168
ops[FACT] += 10 * (nsupr - nsupc);
170
c_div(&temp, &one, &lu_col_ptr[nsupc]);
171
for (k = nsupc+1; k < nsupr; k++)
172
cc_mult(&lu_col_ptr[k], &lu_col_ptr[k], &temp);