64 doublecomplex* values,
82 int i, j, panel_size, permc_spec, relax;
85 mem_usage_t mem_usage;
86 superlu_options_t options;
92 doublecomplex *diagU, *dblock;
93 int_t fsupc, nsupr, nsupc, luptr;
94 int_t i2, k2, nsupers;
112 set_default_options(&options);
117 zCreate_CompCol_Matrix(
118 &A, *n, *n, *nnz, values, rowind, colptr, SLU_NC, SLU_Z, SLU_GE);
119 L = (SuperMatrix*)SUPERLU_MALLOC(
sizeof(SuperMatrix));
120 U = (SuperMatrix*)SUPERLU_MALLOC(
sizeof(SuperMatrix));
121 if (!(perm_r = intMalloc(*n))) ABORT(
"Malloc fails for perm_r[].");
122 if (!(perm_c = intMalloc(*n))) ABORT(
"Malloc fails for perm_c[].");
123 if (!(etree = intMalloc(*n))) ABORT(
"Malloc fails for etree[].");
132 permc_spec = options.ColPerm;
133 get_perm_c(permc_spec, &A, perm_c);
135 sp_preorder(&options, &A, perm_c, etree, &AC);
137 panel_size = sp_ienv(1);
157 Lstore = (SCformat*)L->Store;
158 Ustore = (NCformat*)U->Store;
161 printf(
" No of nonzeros in factor L = %d\n", Lstore->nnz);
162 printf(
" No of nonzeros in factor U = %d\n", Ustore->nnz);
163 printf(
" No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz);
164 zQuerySpace(L, U, &mem_usage);
165 printf(
" L\\U MB %.3f\ttotal MB needed %.3f\n",
167 mem_usage.for_lu / 1e6,
168 mem_usage.total_needed / 1e6);
174 printf(
"dgstrf() error returns INFO= %d\n", *info);
177 zQuerySpace(L, U, &mem_usage);
178 printf(
" L\\U MB %.3f\ttotal MB needed %.3f\n",
180 mem_usage.for_lu / 1e6,
181 mem_usage.total_needed / 1e6);
190 LUfactors->
perm_c = perm_c;
191 LUfactors->
perm_r = perm_r;
192 *f_factors = (
fptr)LUfactors;
198 Lval = Lstore->nzval;
199 nsupers = Lstore->nsuper + 1;
203 if (!(diagU = SUPERLU_MALLOC(*n *
sizeof(SuperMatrix))))
204 ABORT(
"Malloc fails for diagU[].");
206 for (k2 = 0; k2 < nsupers; k2++)
208 fsupc = L_FST_SUPC(k2);
209 nsupc = L_FST_SUPC(k2 + 1) - fsupc;
210 nsupr = L_SUB_START(fsupc + 1) - L_SUB_START(fsupc);
211 luptr = L_NZ_START(fsupc);
213 dblock = &diagU[fsupc];
214 for (i2 = 0; i2 < nsupc; i2++)
216 dblock[i2] = Lval[luptr];
224 double determinant_mantissa = 1.0;
225 int determinant_exponent = 0, iexp;
226 for (
i = 0;
i < *n;
i++)
228 determinant_mantissa *= frexp(diagU[
i].r, &iexp);
229 determinant_exponent += iexp;
231 determinant_mantissa = frexp(determinant_mantissa, &iexp);
232 determinant_exponent += iexp;
236 for (j =
i; j < *n; j++)
238 if (perm_r[j] < perm_r[
i])
242 if (perm_c[j] < perm_c[
i])
250 if (determinant_mantissa > 0.0)
254 if (determinant_mantissa < 0.0)
265 Destroy_SuperMatrix_Store(&A);
266 Destroy_CompCol_Permuted(&AC);
272 else if (*op_flag == 2)
281 perm_c = LUfactors->
perm_c;
282 perm_r = LUfactors->
perm_r;
284 zCreate_Dense_Matrix(&B, *n, *nrhs, b, *ldb, SLU_DN, SLU_Z, SLU_GE);
287 zgstrs(trans, L, U, perm_c, perm_r, &B, &stat, info);
289 Destroy_SuperMatrix_Store(&B);
295 else if (*op_flag == 3)
299 SUPERLU_FREE(LUfactors->
perm_r);
300 SUPERLU_FREE(LUfactors->
perm_c);
301 Destroy_SuperNode_Matrix(LUfactors->
L);
302 Destroy_CompCol_Matrix(LUfactors->
U);
303 SUPERLU_FREE(LUfactors->
L);
304 SUPERLU_FREE(LUfactors->
U);
305 SUPERLU_FREE(LUfactors);
310 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)