4
* -- SuperLU routine (version 3.0) --
5
* Univ. of California Berkeley, Xerox Palo Alto Research Center,
6
* and Lawrence Berkeley National Lab.
13
dgssv(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
14
SuperMatrix *L, SuperMatrix *U, SuperMatrix *B,
15
SuperLUStat_t *stat, int *info )
21
* DGSSV solves the system of linear equations A*X=B, using the
22
* LU factorization from DGSTRF. It performs the following steps:
24
* 1. If A is stored column-wise (A->Stype = SLU_NC):
26
* 1.1. Permute the columns of A, forming A*Pc, where Pc
27
* is a permutation matrix. For more details of this step,
30
* 1.2. Factor A as Pr*A*Pc=L*U with the permutation Pr determined
31
* by Gaussian elimination with partial pivoting.
32
* L is unit lower triangular with offdiagonal entries
33
* bounded by 1 in magnitude, and U is upper triangular.
35
* 1.3. Solve the system of equations A*X=B using the factored
38
* 2. If A is stored row-wise (A->Stype = SLU_NR), apply the
39
* above algorithm to the transpose of A:
41
* 2.1. Permute columns of transpose(A) (rows of A),
42
* forming transpose(A)*Pc, where Pc is a permutation matrix.
43
* For more details of this step, see sp_preorder.c.
45
* 2.2. Factor A as Pr*transpose(A)*Pc=L*U with the permutation Pr
46
* determined by Gaussian elimination with partial pivoting.
47
* L is unit lower triangular with offdiagonal entries
48
* bounded by 1 in magnitude, and U is upper triangular.
50
* 2.3. Solve the system of equations A*X=B using the factored
53
* See supermatrix.h for the definition of 'SuperMatrix' structure.
58
* options (input) superlu_options_t*
59
* The structure defines the input parameters to control
60
* how the LU decomposition will be performed and how the
61
* system will be solved.
63
* A (input) SuperMatrix*
64
* Matrix A in A*X=B, of dimension (A->nrow, A->ncol). The number
65
* of linear equations is A->nrow. Currently, the type of A can be:
66
* Stype = SLU_NC or SLU_NR; Dtype = SLU_D; Mtype = SLU_GE.
67
* In the future, more general A may be handled.
69
* perm_c (input/output) int*
70
* If A->Stype = SLU_NC, column permutation vector of size A->ncol
71
* which defines the permutation matrix Pc; perm_c[i] = j means
72
* column i of A is in position j in A*Pc.
73
* If A->Stype = SLU_NR, column permutation vector of size A->nrow
74
* which describes permutation of columns of transpose(A)
75
* (rows of A) as described above.
77
* If options->ColPerm = MY_PERMC or options->Fact = SamePattern or
78
* options->Fact = SamePattern_SameRowPerm, it is an input argument.
79
* On exit, perm_c may be overwritten by the product of the input
80
* perm_c and a permutation that postorders the elimination tree
81
* of Pc'*A'*A*Pc; perm_c is not changed if the elimination tree
82
* is already in postorder.
83
* Otherwise, it is an output argument.
85
* perm_r (input/output) int*
86
* If A->Stype = SLU_NC, row permutation vector of size A->nrow,
87
* which defines the permutation matrix Pr, and is determined
88
* by partial pivoting. perm_r[i] = j means row i of A is in
90
* If A->Stype = SLU_NR, permutation vector of size A->ncol, which
91
* determines permutation of rows of transpose(A)
92
* (columns of A) as described above.
94
* If options->RowPerm = MY_PERMR or
95
* options->Fact = SamePattern_SameRowPerm, perm_r is an
97
* otherwise it is an output argument.
99
* L (output) SuperMatrix*
100
* The factor L from the factorization
101
* Pr*A*Pc=L*U (if A->Stype = SLU_NC) or
102
* Pr*transpose(A)*Pc=L*U (if A->Stype = SLU_NR).
103
* Uses compressed row subscripts storage for supernodes, i.e.,
104
* L has types: Stype = SLU_SC, Dtype = SLU_D, Mtype = SLU_TRLU.
106
* U (output) SuperMatrix*
107
* The factor U from the factorization
108
* Pr*A*Pc=L*U (if A->Stype = SLU_NC) or
109
* Pr*transpose(A)*Pc=L*U (if A->Stype = SLU_NR).
110
* Uses column-wise storage scheme, i.e., U has types:
111
* Stype = SLU_NC, Dtype = SLU_D, Mtype = SLU_TRU.
113
* B (input/output) SuperMatrix*
114
* B has types: Stype = SLU_DN, Dtype = SLU_D, Mtype = SLU_GE.
115
* On entry, the right hand side matrix.
116
* On exit, the solution matrix if info = 0;
118
* stat (output) SuperLUStat_t*
119
* Record the statistics on runtime and floating-point operation count.
120
* See util.h for the definition of 'SuperLUStat_t'.
123
* = 0: successful exit
124
* > 0: if info = i, and i is
125
* <= A->ncol: U(i,i) is exactly zero. The factorization has
126
* been completed, but the factor U is exactly singular,
127
* so the solution could not be computed.
128
* > A->ncol: number of bytes allocated when memory allocation
129
* failure occurred, plus A->ncol.
133
SuperMatrix *AA;/* A in SLU_NC format used by the factorization routine.*/
134
SuperMatrix AC; /* Matrix postmultiplied by Pc */
135
int lwork = 0, *etree, i;
137
/* Set default values for some parameters */
138
double drop_tol = 0.;
139
int panel_size; /* panel size */
140
int relax; /* no of columns in a relaxed snodes */
142
trans_t trans = NOTRANS;
144
double t; /* Temporary time */
146
/* Test the input parameters ... */
149
if ( options->Fact != DOFACT ) *info = -1;
150
else if ( A->nrow != A->ncol || A->nrow < 0 ||
151
(A->Stype != SLU_NC && A->Stype != SLU_NR) ||
152
A->Dtype != SLU_D || A->Mtype != SLU_GE )
154
else if ( B->ncol < 0 || Bstore->lda < SUPERLU_MAX(0, A->nrow) ||
155
B->Stype != SLU_DN || B->Dtype != SLU_D || B->Mtype != SLU_GE )
159
xerbla_("dgssv", &i);
165
/* Convert A to SLU_NC format when necessary. */
166
if ( A->Stype == SLU_NR ) {
167
NRformat *Astore = A->Store;
168
AA = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) );
169
dCreate_CompCol_Matrix(AA, A->ncol, A->nrow, Astore->nnz,
170
Astore->nzval, Astore->colind, Astore->rowptr,
171
SLU_NC, A->Dtype, A->Mtype);
174
if ( A->Stype == SLU_NC ) AA = A;
177
t = SuperLU_timer_();
179
* Get column permutation vector perm_c[], according to permc_spec:
180
* permc_spec = NATURAL: natural ordering
181
* permc_spec = MMD_AT_PLUS_A: minimum degree on structure of A'+A
182
* permc_spec = MMD_ATA: minimum degree on structure of A'*A
183
* permc_spec = COLAMD: approximate minimum degree column ordering
184
* permc_spec = MY_PERMC: the ordering already supplied in perm_c[]
186
permc_spec = options->ColPerm;
187
if ( permc_spec != MY_PERMC && options->Fact == DOFACT )
188
get_perm_c(permc_spec, AA, perm_c);
189
utime[COLPERM] = SuperLU_timer_() - t;
191
etree = intMalloc(A->ncol);
193
t = SuperLU_timer_();
194
sp_preorder(options, AA, perm_c, etree, &AC);
195
utime[ETREE] = SuperLU_timer_() - t;
197
panel_size = sp_ienv(1);
200
/*printf("Factor PA = LU ... relax %d\tw %d\tmaxsuper %d\trowblk %d\n",
201
relax, panel_size, sp_ienv(3), sp_ienv(4));*/
202
t = SuperLU_timer_();
203
/* Compute the LU factorization of A. */
204
dgstrf(options, &AC, drop_tol, relax, panel_size,
205
etree, NULL, lwork, perm_c, perm_r, L, U, stat, info);
206
utime[FACT] = SuperLU_timer_() - t;
208
t = SuperLU_timer_();
210
/* Solve the system A*X=B, overwriting B with X. */
211
dgstrs (trans, L, U, perm_c, perm_r, B, stat, info);
213
utime[SOLVE] = SuperLU_timer_() - t;
215
SUPERLU_FREE (etree);
216
Destroy_CompCol_Permuted(&AC);
217
if ( A->Stype == SLU_NR ) {
218
Destroy_SuperMatrix_Store(AA);