Skip to content

Commit

Permalink
Fix TESTING driver: when calling xgst01(), only compute the leading n…
Browse files Browse the repository at this point in the history
…onzero columns of L*U(:, 1:izero)
  • Loading branch information
xiaoyeli committed Dec 31, 2023
1 parent f24a800 commit c173a66
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 76 deletions.
52 changes: 30 additions & 22 deletions TESTING/cdrive.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ at the top-level directory.
*/

/*! \file
* CDRIVE is the main test program for the COMPLEX linear
* CDRIVE is the main test program for the SINGLE COMPLEX linear
* equation driver routines CGSSV and CGSSVX.
*
*
* The program is invoked by a shell script file -- ctest.csh.
* The output from the tests are written into a file -- ctest.out.
*
* \ingroup TestingC
*/

#include <getopt.h>
#include <string.h>
#include "slu_cdefs.h"
Expand Down Expand Up @@ -79,8 +78,9 @@ int main(int argc, char *argv[])
int prefact, equil, iequed;
int nt, nrun, nfail, nerrs, imat, fimat, nimat;
int nfact, ifact, itran;
int kl, ku, mode, lda;
int zerot, izero, ioff;
int kl, ku, mode, lda, ioff;
int zerot; /* indicate whether the matrix is singular */
int izero; /* incidate the first column that is entirely zero */
double u;
float anorm, cndnum;
singlecomplex *Afull;
Expand Down Expand Up @@ -110,6 +110,11 @@ int main(int argc, char *argv[])
extern int cgst07(trans_t, int, int, SuperMatrix *, singlecomplex *, int,
singlecomplex *, int, singlecomplex *, int,
float *, float *, float *);
extern int clatb4_slu(char *, int *, int *, int *, char *, int *, int *,
float *, int *, float *, char *);
extern int clatms_slu(int *, int *, char *, int *, char *, float *d,
int *, float *, float *, int *, int *,
char *, singlecomplex *, int *, singlecomplex *, int *);
extern int sp_cconvert(int, int, singlecomplex *, int, int, int,
singlecomplex *a, int_t *, int_t *, int_t *);

Expand Down Expand Up @@ -155,7 +160,7 @@ int main(int argc, char *argv[])
nnz = n * n; /* upper bound */
fimat = 1;
nimat = NTYPES;
Afull = complexCalloc(lda * n);
Afull = (singlecomplex *) complexCalloc(lda * n);
callocateA(n, nnz, &a, &asub, &xa);
} else {
/* Read a sparse matrix */
Expand All @@ -164,14 +169,16 @@ int main(int argc, char *argv[])
}

callocateA(n, nnz, &a_save, &asub_save, &xa_save);
rhsb = complexMalloc(m * nrhs);
bsav = complexMalloc(m * nrhs);
solx = complexMalloc(n * nrhs);
rhsb = (singlecomplex *) complexMalloc(m * nrhs);
bsav = (singlecomplex *) complexMalloc(m * nrhs);
solx = (singlecomplex *) complexMalloc(n * nrhs);
xact = (singlecomplex *) complexMalloc(n * nrhs);
wwork = (singlecomplex *) complexCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) );

ldb = m;
ldx = n;
cCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_C, SLU_GE);
cCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_C, SLU_GE);
xact = complexMalloc(n * nrhs);
etree = int32Malloc(n);
perm_r = int32Malloc(n);
perm_c = int32Malloc(n);
Expand All @@ -188,7 +195,6 @@ int main(int argc, char *argv[])
if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr");
if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr");
if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork");
wwork = complexCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) );

for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i;
options.ColPerm = MY_PERMC;
Expand Down Expand Up @@ -231,14 +237,14 @@ int main(int argc, char *argv[])
Afull[ioff + i + j*lda] = zero;
}
} else {
izero = 0;
izero = n+1; /* none of the column is zero */
}

/* Convert to sparse representation. */
sp_cconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz);

} else {
izero = 0;
izero = n+1; /* none of the column is zero */
zerot = 0;
}

Expand Down Expand Up @@ -354,12 +360,13 @@ int main(int argc, char *argv[])
printf(FMT3, "cgssv",
(int) info, izero, n, nrhs, imat, nfail);
} else {
/* Reconstruct matrix from factors and
compute residual. */
cgst01(m, n, &A, &L, &U, perm_c, perm_r,
/* Reconstruct matrix from factors and compute residual.
* Only compute the leading 'izero' nonzero columns.
*/
cgst01(m, izero-1, &A, &L, &U, perm_c, perm_r,
&result[0]);
nt = 1;
if ( izero == 0 ) {
if ( izero == (n+1) ) {
/* Compute residual of the computed
solution. */
cCopy_Dense_Matrix(m, nrhs, rhsb, ldb,
Expand Down Expand Up @@ -418,9 +425,10 @@ int main(int argc, char *argv[])
}
} else {
if ( !prefact ) {
/* Reconstruct matrix from factors and
compute residual. */
cgst01(m, n, &A, &L, &U, perm_c, perm_r,
/* Reconstruct matrix from factors and compute residual.
* Only compute the leading 'izero' nonzero columns.
*/
cgst01(m, izero-1, &A, &L, &U, perm_c, perm_r,
&result[0]);
k1 = 0;
} else {
Expand Down Expand Up @@ -513,8 +521,8 @@ int main(int argc, char *argv[])
Destroy_SuperMatrix_Store(&U);
}

return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
return (nfail == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
} /* end main */

/*!
* Parse command line options to get relaxed snode size, panel size, etc.
Expand Down
43 changes: 26 additions & 17 deletions TESTING/ddrive.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ at the top-level directory.
*/

/*! \file
* DDRIVE is the main test program for the DOUBLE linear
* DDRIVE is the main test program for the DOUBLE linear
* equation driver routines DGSSV and DGSSVX.
*
*
* The program is invoked by a shell script file -- dtest.csh.
* The output from the tests are written into a file -- dtest.out.
*
Expand Down Expand Up @@ -78,8 +78,9 @@ int main(int argc, char *argv[])
int prefact, equil, iequed;
int nt, nrun, nfail, nerrs, imat, fimat, nimat;
int nfact, ifact, itran;
int kl, ku, mode, lda;
int zerot, izero, ioff;
int kl, ku, mode, lda, ioff;
int zerot; /* indicate whether the matrix is singular */
int izero; /* incidate the first column that is entirely zero */
double u;
double anorm, cndnum;
double *Afull;
Expand Down Expand Up @@ -109,6 +110,11 @@ int main(int argc, char *argv[])
extern int dgst07(trans_t, int, int, SuperMatrix *, double *, int,
double *, int, double *, int,
double *, double *, double *);
extern int dlatb4_slu(char *, int *, int *, int *, char *, int *, int *,
double *, int *, double *, char *);
extern int dlatms_slu(int *, int *, char *, int *, char *, double *d,
int *, double *, double *, int *, int *,
char *, double *, int *, double *, int *);
extern int sp_dconvert(int, int, double *, int, int, int,
double *a, int_t *, int_t *, int_t *);

Expand Down Expand Up @@ -166,11 +172,13 @@ int main(int argc, char *argv[])
rhsb = doubleMalloc(m * nrhs);
bsav = doubleMalloc(m * nrhs);
solx = doubleMalloc(n * nrhs);
xact = doubleMalloc(n * nrhs);
wwork = doubleCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) );

ldb = m;
ldx = n;
dCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_D, SLU_GE);
dCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_D, SLU_GE);
xact = doubleMalloc(n * nrhs);
etree = int32Malloc(n);
perm_r = int32Malloc(n);
perm_c = int32Malloc(n);
Expand All @@ -187,7 +195,6 @@ int main(int argc, char *argv[])
if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr");
if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr");
if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork");
wwork = doubleCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) );

for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i;
options.ColPerm = MY_PERMC;
Expand Down Expand Up @@ -230,14 +237,14 @@ int main(int argc, char *argv[])
Afull[ioff + i + j*lda] = zero;
}
} else {
izero = 0;
izero = n+1; /* none of the column is zero */
}

/* Convert to sparse representation. */
sp_dconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz);

} else {
izero = 0;
izero = n+1; /* none of the column is zero */
zerot = 0;
}

Expand Down Expand Up @@ -353,12 +360,13 @@ int main(int argc, char *argv[])
printf(FMT3, "dgssv",
(int) info, izero, n, nrhs, imat, nfail);
} else {
/* Reconstruct matrix from factors and
compute residual. */
dgst01(m, n, &A, &L, &U, perm_c, perm_r,
/* Reconstruct matrix from factors and compute residual.
* Only compute the leading 'izero' nonzero columns.
*/
dgst01(m, izero-1, &A, &L, &U, perm_c, perm_r,
&result[0]);
nt = 1;
if ( izero == 0 ) {
if ( izero == (n+1) ) {
/* Compute residual of the computed
solution. */
dCopy_Dense_Matrix(m, nrhs, rhsb, ldb,
Expand Down Expand Up @@ -417,9 +425,10 @@ int main(int argc, char *argv[])
}
} else {
if ( !prefact ) {
/* Reconstruct matrix from factors and
compute residual. */
dgst01(m, n, &A, &L, &U, perm_c, perm_r,
/* Reconstruct matrix from factors and compute residual.
* Only compute the leading 'izero' nonzero columns.
*/
dgst01(m, izero-1, &A, &L, &U, perm_c, perm_r,
&result[0]);
k1 = 0;
} else {
Expand Down Expand Up @@ -512,8 +521,8 @@ int main(int argc, char *argv[])
Destroy_SuperMatrix_Store(&U);
}

return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
return (nfail == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
} /* end main */

/*!
* Parse command line options to get relaxed snode size, panel size, etc.
Expand Down
44 changes: 26 additions & 18 deletions TESTING/sdrive.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ at the top-level directory.
*/

/*! \file
* SDRIVE is the main test program for the FLOAT linear
* SDRIVE is the main test program for the FLOAT linear
* equation driver routines SGSSV and SGSSVX.
*
*
* The program is invoked by a shell script file -- stest.csh.
* The output from the tests are written into a file -- stest.out.
*
* \ingroup TestingS
*/

#include <getopt.h>
#include <string.h>
#include "slu_sdefs.h"
Expand Down Expand Up @@ -79,8 +78,9 @@ int main(int argc, char *argv[])
int prefact, equil, iequed;
int nt, nrun, nfail, nerrs, imat, fimat, nimat;
int nfact, ifact, itran;
int kl, ku, mode, lda;
int zerot, izero, ioff;
int kl, ku, mode, lda, ioff;
int zerot; /* indicate whether the matrix is singular */
int izero; /* incidate the first column that is entirely zero */
double u;
float anorm, cndnum;
float *Afull;
Expand Down Expand Up @@ -110,6 +110,11 @@ int main(int argc, char *argv[])
extern int sgst07(trans_t, int, int, SuperMatrix *, float *, int,
float *, int, float *, int,
float *, float *, float *);
extern int slatb4_slu(char *, int *, int *, int *, char *, int *, int *,
float *, int *, float *, char *);
extern int slatms_slu(int *, int *, char *, int *, char *, float *d,
int *, float *, float *, int *, int *,
char *, float *, int *, float *, int *);
extern int sp_sconvert(int, int, float *, int, int, int,
float *a, int_t *, int_t *, int_t *);

Expand Down Expand Up @@ -167,11 +172,13 @@ int main(int argc, char *argv[])
rhsb = floatMalloc(m * nrhs);
bsav = floatMalloc(m * nrhs);
solx = floatMalloc(n * nrhs);
xact = floatMalloc(n * nrhs);
wwork = floatCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) );

ldb = m;
ldx = n;
sCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_S, SLU_GE);
sCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_S, SLU_GE);
xact = floatMalloc(n * nrhs);
etree = int32Malloc(n);
perm_r = int32Malloc(n);
perm_c = int32Malloc(n);
Expand All @@ -188,7 +195,6 @@ int main(int argc, char *argv[])
if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr");
if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr");
if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork");
wwork = floatCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) );

for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i;
options.ColPerm = MY_PERMC;
Expand Down Expand Up @@ -231,14 +237,14 @@ int main(int argc, char *argv[])
Afull[ioff + i + j*lda] = zero;
}
} else {
izero = 0;
izero = n+1; /* none of the column is zero */
}

/* Convert to sparse representation. */
sp_sconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz);

} else {
izero = 0;
izero = n+1; /* none of the column is zero */
zerot = 0;
}

Expand Down Expand Up @@ -354,12 +360,13 @@ int main(int argc, char *argv[])
printf(FMT3, "sgssv",
(int) info, izero, n, nrhs, imat, nfail);
} else {
/* Reconstruct matrix from factors and
compute residual. */
sgst01(m, n, &A, &L, &U, perm_c, perm_r,
/* Reconstruct matrix from factors and compute residual.
* Only compute the leading 'izero' nonzero columns.
*/
sgst01(m, izero-1, &A, &L, &U, perm_c, perm_r,
&result[0]);
nt = 1;
if ( izero == 0 ) {
if ( izero == (n+1) ) {
/* Compute residual of the computed
solution. */
sCopy_Dense_Matrix(m, nrhs, rhsb, ldb,
Expand Down Expand Up @@ -418,9 +425,10 @@ int main(int argc, char *argv[])
}
} else {
if ( !prefact ) {
/* Reconstruct matrix from factors and
compute residual. */
sgst01(m, n, &A, &L, &U, perm_c, perm_r,
/* Reconstruct matrix from factors and compute residual.
* Only compute the leading 'izero' nonzero columns.
*/
sgst01(m, izero-1, &A, &L, &U, perm_c, perm_r,
&result[0]);
k1 = 0;
} else {
Expand Down Expand Up @@ -513,8 +521,8 @@ int main(int argc, char *argv[])
Destroy_SuperMatrix_Store(&U);
}

return nfail == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
return (nfail == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
} /* end main */

/*!
* Parse command line options to get relaxed snode size, panel size, etc.
Expand Down
Loading

0 comments on commit c173a66

Please sign in to comment.