Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 9c9ecb99 authored by PICHON Gregoire's avatar PICHON Gregoire
Browse files

remove spm from laplacian parsing

parent df359214
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -98,20 +95,16 @@ laplacian_usage(void)
*
*******************************************************************************/
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 )
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 = spm->gN = 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 = spm->gN = dim1 * dim2 * dim3;
if( dim3 > 0 ) {
extended_laplacian_table3D[spm->flttype](spm, dim1, dim2, dim3);
}
......
......@@ -32,12 +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_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 );
#endif /* _laplacian_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; /**< avails datatype: PastixPattern, PastixFloat, PastixDouble,
PastixComplex32 or PastixComplex64 */
pastix_fmttype_t fmttype; /**< Matrix storage format: PastixCSC, PastixCSR, PastixIJV */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment