diff --git a/drivers/laplacian.c b/drivers/laplacian.c index 3de05664c36bb98f29d5ee416756eedef1599b47..b49b85581d5303001815861e55ee1bb78753b405 100644 --- a/drivers/laplacian.c +++ b/drivers/laplacian.c @@ -70,11 +70,8 @@ laplacian_usage(void) * Configuration string of the Laplacian. See laplacian_usage() for * more information. * - * @param[inout] spm - * At start, an allocated spm structure that will store the Lapalcian - * matrix. - * At exit, the fields of the spm are initialized and especially the - * type, symmetry and number of unknows are setup. + * @param[out] flttype + * The floating type of the elements in the matrix. * * @param[out] dim1 * The first dimension of the laplacian @@ -97,21 +94,17 @@ laplacian_usage(void) * @retval PASTIX_ERR_BADPARAMETER if the configuration string is incorrect * *******************************************************************************/ -static inline int -laplacian_parse_info( const char *filename, - pastix_spm_t *spm, - pastix_int_t *dim1, - pastix_int_t *dim2, - pastix_int_t *dim3, - double *alpha, - double *beta ) +int +laplacian_parse_info( const char *filename, + pastix_coeftype_t *flttype, + pastix_int_t *dim1, + pastix_int_t *dim2, + pastix_int_t *dim3, + double *alpha, + double *beta ) { double val1, val2; long tmp1, tmp2, tmp3; - spm->colptr = NULL; - spm->rowptr = NULL; - spm->values = NULL; - spm->loc2glob = NULL; *alpha = 1.; *beta = 1.; @@ -126,27 +119,27 @@ laplacian_parse_info( const char *filename, switch( flt ){ case 'Z': case 'z': - spm->flttype = PastixComplex64; + *flttype = PastixComplex64; break; case 'C': case 'c': - spm->flttype = PastixComplex32; + *flttype = PastixComplex32; break; case 'D': case 'd': - spm->flttype = PastixDouble; + *flttype = PastixDouble; break; case 'S': case 's': - spm->flttype = PastixFloat; + *flttype = PastixFloat; break; case 'P': case 'p': - spm->flttype = PastixPattern; + *flttype = PastixPattern; break; case '1': @@ -158,7 +151,7 @@ laplacian_parse_info( const char *filename, case '7': case '8': case '9': - spm->flttype = PastixDouble; + *flttype = PastixDouble; /* * The first dimension is only one character long so we come * back to the beginning of the string @@ -172,7 +165,7 @@ laplacian_parse_info( const char *filename, } } else { - spm->flttype = PastixDouble; + *flttype = PastixDouble; } free(tmpf); @@ -187,29 +180,24 @@ laplacian_parse_info( const char *filename, *dim3 = (pastix_int_t)tmp3; *alpha = val1; *beta = val2; - spm->gN = (*dim1)*(*dim2)*(*dim3); } else if ( sscanf( filename, "%ld:%ld:%ld:%lf", &tmp1, &tmp2, &tmp3, &val1 ) == 4 ) { *dim1 = (pastix_int_t)tmp1; *dim2 = (pastix_int_t)tmp2; *dim3 = (pastix_int_t)tmp3; *alpha = val1; - spm->gN = (*dim1)*(*dim2)*(*dim3); } else if ( sscanf( filename, "%ld:%ld:%ld", &tmp1, &tmp2, &tmp3 ) == 3 ) { *dim1 = (pastix_int_t)tmp1; *dim2 = (pastix_int_t)tmp2; *dim3 = (pastix_int_t)tmp3; - spm->gN = (*dim1)*(*dim2)*(*dim3); } else if ( sscanf( filename, "%ld:%ld", &tmp1, &tmp2 ) == 2 ) { *dim1 = (pastix_int_t)tmp1; *dim2 = (pastix_int_t)tmp2; - spm->gN = (*dim1)*(*dim2); } else if ( sscanf( filename, "%ld", &tmp1 ) == 1 ) { *dim1 = (pastix_int_t)tmp1; - spm->gN = *dim1; } else { laplacian_usage(); @@ -217,12 +205,11 @@ laplacian_parse_info( const char *filename, } /* One of the dimension was set to 0 */ - if ( spm->gN == 0 ) { + if ( (*dim1 == 0) || (*dim2 == 0) || (*dim3 == 0) ) { laplacian_usage(); return PASTIX_ERR_BADPARAMETER; } - spm->n = spm->gN; return PASTIX_SUCCESS; } @@ -292,15 +279,19 @@ int genLaplacian( const char *filename, pastix_spm_t *spm ) { + pastix_coeftype_t flttype; pastix_int_t dim1, dim2, dim3; double alpha = 1.; double beta = 1.; int rc; - rc = laplacian_parse_info(filename, spm, &dim1, &dim2, &dim3, &alpha, &beta ); + rc = laplacian_parse_info(filename, &flttype, &dim1, &dim2, &dim3, &alpha, &beta ); if (rc != PASTIX_SUCCESS) return rc; + spm->flttype = flttype; + spm->n = dim1 * dim2 * dim3; + laplacian_7points[spm->flttype](spm, dim1, dim2, dim3, alpha, beta); return PASTIX_SUCCESS; @@ -342,15 +333,19 @@ int genExtendedLaplacian( const char *filename, pastix_spm_t *spm ) { + pastix_coeftype_t flttype; pastix_int_t dim1, dim2, dim3; double alpha = 1.; double beta = 1.; int rc; - rc = laplacian_parse_info(filename, spm, &dim1, &dim2, &dim3, &alpha, &beta); + rc = laplacian_parse_info(filename, &flttype, &dim1, &dim2, &dim3, &alpha, &beta); if (rc != PASTIX_SUCCESS) return rc; + spm->flttype = flttype; + spm->n = dim1 * dim2 * dim3; + if( dim3 > 0 ) { extended_laplacian_table3D[spm->flttype](spm, dim1, dim2, dim3); } diff --git a/drivers/laplacian.h b/drivers/laplacian.h index a13e0065fb7cb3beb7d16b4a2d6d6b2dc9969488..29d8395eb0aa8114b096a3e0ad61c5c93c6d5f1e 100644 --- a/drivers/laplacian.h +++ b/drivers/laplacian.h @@ -32,4 +32,12 @@ void d_spmExtendedLaplacian3D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_ void s_spmExtendedLaplacian3D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3 ); void p_spmExtendedLaplacian3D( pastix_spm_t *spm, pastix_int_t dim1, pastix_int_t dim2, pastix_int_t dim3 ); +int laplacian_parse_info( const char *filename, + pastix_coeftype_t *flttype, + pastix_int_t *dim1, + pastix_int_t *dim2, + pastix_int_t *dim3, + double *alpha, + double *beta ); + #endif /* _laplacian_h_ */ diff --git a/spm.h b/spm.h index 037116eee4f96e44792e05bce6044bde19a30bd3..0f782dcb89b8a6df859d12950dede38a994a9970 100644 --- a/spm.h +++ b/spm.h @@ -44,7 +44,7 @@ typedef struct pastix_spm_s { pastix_mtxtype_t mtxtype; /**< Matrix structure: PastixGeneral, PastixSymmetric or PastixHermitian. */ - pastix_coeftype_t flttype; /**< avals datatype: PastixPattern, PastixFloat, PastixDouble, + pastix_coeftype_t flttype; /**< values datatype: PastixPattern, PastixFloat, PastixDouble, PastixComplex32 or PastixComplex64 */ pastix_fmttype_t fmttype; /**< Matrix storage format: PastixCSC, PastixCSR, PastixIJV */ diff --git a/z_spm_laplacian.c b/z_spm_laplacian.c index ba5fd0b675780c4b8ebe29e53dd61e2bd7665439..e719f6182fa6b09536c32a492f984f2d479f5f83 100644 --- a/z_spm_laplacian.c +++ b/z_spm_laplacian.c @@ -77,11 +77,10 @@ z_spmLaplacian_7points( pastix_spm_t *spm, spm->mtxtype = PastixHermitian; spm->flttype = PastixComplex64; spm->fmttype = PastixCSC; - spm->gnnz = nnz; spm->nnz = nnz; spm->dof = 1; - assert( spm->gN == dim1*dim2*dim3 ); + assert( spm->n == dim1*dim2*dim3 ); /* Allocating */ spm->colptr = malloc((spm->n+1)*sizeof(pastix_int_t)); @@ -161,7 +160,7 @@ z_spmLaplacian_7points( pastix_spm_t *spm, } } - assert( (spm->colptr[ spm->gN ] - spm->colptr[0]) == nnz ); + assert( (spm->colptr[ spm->n ] - spm->colptr[0]) == nnz ); (void)alpha; (void)beta; } @@ -199,11 +198,10 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm, spm->mtxtype = PastixSymmetric; spm->flttype = PastixComplex64; spm->fmttype = PastixCSC; - spm->gnnz = nnz; spm->nnz = nnz; spm->dof = 1; - assert( spm->gN == dim1*dim2 ); + assert( spm->n == dim1*dim2 ); /* Allocating */ spm->colptr = malloc((spm->n+1)*sizeof(pastix_int_t)); @@ -285,7 +283,7 @@ z_spmExtendedLaplacian2D( pastix_spm_t *spm, } } - assert( (spm->colptr[ spm->gN ] - spm->colptr[0]) == nnz ); + assert( (spm->colptr[ spm->n ] - spm->colptr[0]) == nnz ); } /** @@ -330,11 +328,10 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, spm->mtxtype = PastixSymmetric; spm->flttype = PastixComplex64; spm->fmttype = PastixCSC; - spm->gnnz = nnz; spm->nnz = nnz; spm->dof = 1; - assert( spm->gN == dim1*dim2*dim3 ); + assert( spm->n == dim1*dim2*dim3 ); /* Allocating */ spm->colptr = malloc((spm->n+1)*sizeof(pastix_int_t)); @@ -515,5 +512,5 @@ z_spmExtendedLaplacian3D( pastix_spm_t *spm, } } - assert( (spm->colptr[ spm->gN ] - spm->colptr[0]) == nnz ); + assert( (spm->colptr[ spm->n ] - spm->colptr[0]) == nnz ); }