3
* -- SuperLU routine (version 3.0) --
4
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
5
* and Lawrence Berkeley National Lab.
10
Copyright (c) 1994 by Xerox Corporation. All rights reserved.
12
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
13
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
15
Permission is hereby granted to use or copy this program for any
16
purpose, provided the above notices are retained on all copies.
17
Permission to modify the code and to distribute modified code is
18
granted, provided the above notices are retained, and a notice that
19
the code was modified is included with the above copyright notice.
30
const int jcol, /* in */
31
const float u, /* in - diagonal pivoting threshold */
32
int *usepr, /* re-use the pivot sequence given by perm_r/iperm_r */
33
int *perm_r, /* may be modified */
34
int *iperm_r, /* in - inverse of perm_r */
35
int *iperm_c, /* in - used to find diagonal of Pc*A*Pc' */
36
int *pivrow, /* out */
37
GlobalLU_t *Glu, /* modified - global LU data structures */
38
SuperLUStat_t *stat /* output */
44
* Performs the numerical pivoting on the current column of L,
45
* and the CDIV operation.
48
* (1) Compute thresh = u * max_(i>=j) abs(A_ij);
49
* (2) IF user specifies pivot row k and abs(A_kj) >= thresh THEN
51
* ELSE IF abs(A_jj) >= thresh THEN
56
* Note: If you absolutely want to use a given pivot order, then set u=0.0.
58
* Return value: 0 success;
59
* i > 0 U(i,i) is exactly zero.
62
complex one = {1.0, 0.0};
63
int fsupc; /* first column in the supernode */
64
int nsupc; /* no of columns in the supernode */
65
int nsupr; /* no of rows in the supernode */
66
int lptr; /* points to the starting subscript of the supernode */
67
int pivptr, old_pivptr, diag, diagind;
68
float pivmax, rtemp, thresh;
73
int isub, icol, k, itemp;
77
flops_t *ops = stat->ops;
79
/* Initialize pointers */
84
fsupc = (Glu->xsup)[(Glu->supno)[jcol]];
85
nsupc = jcol - fsupc; /* excluding jcol; nsupc >= 0 */
87
nsupr = xlsub[fsupc+1] - lptr;
88
lu_sup_ptr = &lusup[xlusup[fsupc]]; /* start of the current supernode */
89
lu_col_ptr = &lusup[xlusup[jcol]]; /* start of jcol in the supernode */
90
lsub_ptr = &lsub[lptr]; /* start of row indices of the supernode */
93
if ( jcol == MIN_COL ) {
94
printf("Before cdiv: col %d\n", jcol);
95
for (k = nsupc; k < nsupr; k++)
96
printf(" lu[%d] %f\n", lsub_ptr[k], lu_col_ptr[k]);
100
/* Determine the largest abs numerical value for partial pivoting;
101
Also search for user-specified pivot, and diagonal element. */
102
if ( *usepr ) *pivrow = iperm_r[jcol];
103
diagind = iperm_c[jcol];
108
for (isub = nsupc; isub < nsupr; ++isub) {
109
rtemp = c_abs1 (&lu_col_ptr[isub]);
110
if ( rtemp > pivmax ) {
114
if ( *usepr && lsub_ptr[isub] == *pivrow ) old_pivptr = isub;
115
if ( lsub_ptr[isub] == diagind ) diag = isub;
118
/* Test for singularity */
119
if ( pivmax == 0.0 ) {
120
*pivrow = lsub_ptr[pivptr];
121
perm_r[*pivrow] = jcol;
128
/* Choose appropriate pivotal element by our policy. */
130
rtemp = c_abs1 (&lu_col_ptr[old_pivptr]);
131
if ( rtemp != 0.0 && rtemp >= thresh )
137
/* Use diagonal pivot? */
138
if ( diag >= 0 ) { /* diagonal exists */
139
rtemp = c_abs1 (&lu_col_ptr[diag]);
140
if ( rtemp != 0.0 && rtemp >= thresh ) pivptr = diag;
142
*pivrow = lsub_ptr[pivptr];
145
/* Record pivot row */
146
perm_r[*pivrow] = jcol;
148
/* Interchange row subscripts */
149
if ( pivptr != nsupc ) {
150
itemp = lsub_ptr[pivptr];
151
lsub_ptr[pivptr] = lsub_ptr[nsupc];
152
lsub_ptr[nsupc] = itemp;
154
/* Interchange numerical values as well, for the whole snode, such
155
* that L is indexed the same way as A.
157
for (icol = 0; icol <= nsupc; icol++) {
158
itemp = pivptr + icol * nsupr;
159
temp = lu_sup_ptr[itemp];
160
lu_sup_ptr[itemp] = lu_sup_ptr[nsupc + icol*nsupr];
161
lu_sup_ptr[nsupc + icol*nsupr] = temp;
166
ops[FACT] += 10 * (nsupr - nsupc);
168
c_div(&temp, &one, &lu_col_ptr[nsupc]);
169
for (k = nsupc+1; k < nsupr; k++)
170
cc_mult(&lu_col_ptr[k], &lu_col_ptr[k], &temp);