13 #include "../../external_src/oomph_superlu_4.3/slu_zdefs.h"
61 doublecomplex *values,
int *rowind,
int *colptr,
62 doublecomplex *b,
int *ldb,
int *transpose,
int *
doc,
63 fptr *f_factors,
int *info)
74 int i, j, panel_size, permc_spec, relax;
77 mem_usage_t mem_usage;
78 superlu_options_t options;
83 doublecomplex *diagU, *dblock;
84 int_t fsupc, nsupr, nsupc, luptr;
85 int_t i2, k2, nsupers;
99 if ( *op_flag == 1 ) {
102 set_default_options(&options);
107 zCreate_CompCol_Matrix(&A, *n, *n, *nnz, values, rowind, colptr,
108 SLU_NC, SLU_Z, SLU_GE);
109 L = (SuperMatrix *) SUPERLU_MALLOC(
sizeof(SuperMatrix) );
110 U = (SuperMatrix *) SUPERLU_MALLOC(
sizeof(SuperMatrix) );
111 if ( !(perm_r = intMalloc(*n)) ) ABORT(
"Malloc fails for perm_r[].");
112 if ( !(perm_c = intMalloc(*n)) ) ABORT(
"Malloc fails for perm_c[].");
113 if ( !(etree = intMalloc(*n)) ) ABORT(
"Malloc fails for etree[].");
122 permc_spec = options.ColPerm;
123 get_perm_c(permc_spec, &A, perm_c);
125 sp_preorder(&options, &A, perm_c, etree, &AC);
127 panel_size = sp_ienv(1);
130 zgstrf(&options, &AC, relax, panel_size,
131 etree, NULL, 0, perm_c, perm_r,
L,
U, &stat, info);
134 Lstore = (SCformat *)
L->Store;
135 Ustore = (NCformat *)
U->Store;
138 printf(
" No of nonzeros in factor L = %d\n", Lstore->nnz);
139 printf(
" No of nonzeros in factor U = %d\n", Ustore->nnz);
140 printf(
" No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz);
141 zQuerySpace(
L,
U, &mem_usage);
142 printf(
" L\\U MB %.3f\ttotal MB needed %.3f\n",
144 mem_usage.for_lu/1e6, mem_usage.total_needed/1e6);
148 printf(
"dgstrf() error returns INFO= %d\n", *info);
150 zQuerySpace(
L,
U, &mem_usage);
151 printf(
" L\\U MB %.3f\ttotal MB needed %.3f\n",
153 mem_usage.for_lu/1e6, mem_usage.total_needed/1e6);
162 LUfactors->
perm_c = perm_c;
163 LUfactors->
perm_r = perm_r;
164 *f_factors = (
fptr) LUfactors;
170 Lval = Lstore->nzval;
171 nsupers = Lstore->nsuper + 1;
175 if ( !(diagU = SUPERLU_MALLOC( *n *
sizeof(SuperMatrix) )) )
176 ABORT(
"Malloc fails for diagU[].");
178 for(k2=0; k2< nsupers; k2++)
180 fsupc = L_FST_SUPC(k2);
181 nsupc = L_FST_SUPC(k2+1) - fsupc;
182 nsupr = L_SUB_START(fsupc+1) - L_SUB_START(fsupc);
183 luptr = L_NZ_START(fsupc);
185 dblock = &diagU[fsupc];
186 for(i2 = 0; i2 < nsupc; i2++)
188 dblock[i2] = Lval[luptr];
196 double determinant_mantissa=1.0;
197 int determinant_exponent = 0, iexp;
200 determinant_mantissa *= frexp(diagU[
i].r, &iexp);
201 determinant_exponent += iexp;
203 determinant_mantissa = frexp(determinant_mantissa,&iexp);
204 determinant_exponent += iexp;
210 if(perm_r[j] < perm_r[
i]) {signature *= -1;}
211 if(perm_c[j] < perm_c[
i]) {signature *= -1;}
216 if(determinant_mantissa > 0.0) {sign = 1;}
217 if(determinant_mantissa < 0.0) {sign = -1;}
225 Destroy_SuperMatrix_Store(&A);
226 Destroy_CompCol_Permuted(&AC);
232 }
else if ( *op_flag == 2 ) {
240 perm_c = LUfactors->
perm_c;
241 perm_r = LUfactors->
perm_r;
243 zCreate_Dense_Matrix(&
B, *n, *nrhs, b, *ldb, SLU_DN, SLU_Z, SLU_GE);
246 zgstrs (trans,
L,
U, perm_c, perm_r, &
B, &stat, info);
248 Destroy_SuperMatrix_Store(&
B);
254 }
else if ( *op_flag == 3 ) {
257 SUPERLU_FREE (LUfactors->
perm_r);
258 SUPERLU_FREE (LUfactors->
perm_c);
259 Destroy_SuperNode_Matrix(LUfactors->
L);
260 Destroy_CompCol_Matrix(LUfactors->
U);
261 SUPERLU_FREE (LUfactors->
L);
262 SUPERLU_FREE (LUfactors->
U);
263 SUPERLU_FREE (LUfactors);
266 fprintf(stderr,
"Invalid op_flag=%d passed to c_cpp_dgssv()\n",*op_flag);
int superlu_complex(int *op_flag, int *n, int *nnz, int *nrhs, doublecomplex *values, int *rowind, int *colptr, doublecomplex *b, int *ldb, int *transpose, int *doc, fptr *f_factors, int *info)