| |
| |
| |
| |
| |
| |
| |
| |
| #include "slu_zdefs.h" |
| |
| main(int argc, char *argv[]) |
| { |
| SuperMatrix A; |
| NCformat *Astore; |
| doublecomplex *a; |
| int *asub, *xa; |
| int *perm_c; |
| int *perm_r; |
| SuperMatrix L; |
| SCformat *Lstore; |
| SuperMatrix U; |
| NCformat *Ustore; |
| SuperMatrix B; |
| int nrhs, ldx, info, m, n, nnz; |
| doublecomplex *xact, *rhs; |
| mem_usage_t mem_usage; |
| superlu_options_t options; |
| SuperLUStat_t stat; |
| |
| #if ( DEBUGlevel>=1 ) |
| CHECK_MALLOC("Enter main()"); |
| #endif |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| set_default_options(&options); |
| |
| |
| zreadhb(&m, &n, &nnz, &a, &asub, &xa); |
| |
| zCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_Z, SLU_GE); |
| Astore = A.Store; |
| printf("Dimension %dx%d; # nonzeros %d\n", A.nrow, A.ncol, Astore->nnz); |
| |
| nrhs = 1; |
| if ( !(rhs = doublecomplexMalloc(m * nrhs)) ) ABORT("Malloc fails for rhs[]."); |
| zCreate_Dense_Matrix(&B, m, nrhs, rhs, m, SLU_DN, SLU_Z, SLU_GE); |
| xact = doublecomplexMalloc(n * nrhs); |
| ldx = n; |
| zGenXtrue(n, nrhs, xact, ldx); |
| zFillRHS(options.Trans, nrhs, xact, ldx, &A, &B); |
| |
| if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); |
| if ( !(perm_r = intMalloc(m)) ) ABORT("Malloc fails for perm_r[]."); |
| |
| |
| StatInit(&stat); |
| |
| zgssv(&options, &A, perm_c, perm_r, &L, &U, &B, &stat, &info); |
| |
| if ( info == 0 ) { |
| |
| |
| doublecomplex *sol = (doublecomplex*) ((DNformat*) B.Store)->nzval; |
| |
| |
| zinf_norm_error(nrhs, &B, xact); |
| |
| Lstore = (SCformat *) L.Store; |
| Ustore = (NCformat *) U.Store; |
| printf("No of nonzeros in factor L = %d\n", Lstore->nnz); |
| printf("No of nonzeros in factor U = %d\n", Ustore->nnz); |
| printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz - n); |
| printf("FILL ratio = %.1f\n", (float)(Lstore->nnz + Ustore->nnz - n)/nnz); |
| |
| zQuerySpace(&L, &U, &mem_usage); |
| printf("L\\U MB %.3f\ttotal MB needed %.3f\n", |
| mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); |
| |
| } else { |
| printf("zgssv() error returns INFO= %d\n", info); |
| if ( info <= n ) { |
| zQuerySpace(&L, &U, &mem_usage); |
| printf("L\\U MB %.3f\ttotal MB needed %.3f\n", |
| mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); |
| } |
| } |
| |
| if ( options.PrintStat ) StatPrint(&stat); |
| StatFree(&stat); |
| |
| SUPERLU_FREE (rhs); |
| SUPERLU_FREE (xact); |
| SUPERLU_FREE (perm_r); |
| SUPERLU_FREE (perm_c); |
| Destroy_CompCol_Matrix(&A); |
| Destroy_SuperMatrix_Store(&B); |
| Destroy_SuperNode_Matrix(&L); |
| Destroy_CompCol_Matrix(&U); |
| |
| #if ( DEBUGlevel>=1 ) |
| CHECK_MALLOC("Exit main()"); |
| #endif |
| } |
| |