From b57674930fa7f16fc7eff32a40f27b53d007958c Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Wed, 4 Apr 2018 11:46:15 +0200 Subject: [PATCH] Fix issue in norm tests --- .gitlab-ci.yml | 1 - src/z_spm.c | 2 +- src/z_spm_2dense.c | 40 ++++++++++++++++++++-------------------- src/z_spm_integer.c | 2 +- tests/spm_tests.h | 9 ++++++--- tests/z_spm_tests.c | 8 ++++---- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93566721..4ac10f50 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,7 +57,6 @@ sonar_spm: expire_in: 1 week paths: - spm.lcov - - coverage/ - spm-coverage.xml - spm-cppcheck.xml - spm-rats.xml diff --git a/src/z_spm.c b/src/z_spm.c index 37f534d7..0b0f96c1 100644 --- a/src/z_spm.c +++ b/src/z_spm.c @@ -249,7 +249,7 @@ z_spmSymmetrize( spmatrix_t *spm ) spm_int_t lrow = oldcol[ j+1 ] - baseval; int found = 0; - for (k = frow; (k < lrow); k++) + for (k = frow; k < lrow; k++) { if (i == (oldrow[k]-baseval)) { diff --git a/src/z_spm_2dense.c b/src/z_spm_2dense.c index e236ac62..7facbc7e 100644 --- a/src/z_spm_2dense.c +++ b/src/z_spm_2dense.c @@ -150,14 +150,14 @@ z_spmCSC2dense( const spmatrix_t *spm ) case SpmSymmetric: for(j=0; j<spm->n; j++, colptr++) { - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j] - baseval; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? spm->dof * j : dofs[j] - baseval; for(k=colptr[0]; k<colptr[1]; k++, rowptr++) { i = (*rowptr - baseval); - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i] - baseval; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? spm->dof * i : dofs[i] - baseval; for(jj=0; jj<dofj; jj++) { @@ -174,14 +174,14 @@ z_spmCSC2dense( const spmatrix_t *spm ) default: for(j=0; j<spm->n; j++, colptr++) { - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j] - baseval; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? spm->dof * j : dofs[j] - baseval; for(k=colptr[0]; k<colptr[1]; k++, rowptr++) { i = (*rowptr - baseval); - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i] - baseval; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? spm->dof * i : dofs[i] - baseval; for(jj=0; jj<dofj; jj++) { @@ -298,14 +298,14 @@ z_spmCSR2dense( const spmatrix_t *spm ) case SpmHermitian: for(i=0; i<spm->n; i++, rowptr++) { - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i] - baseval; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? spm->dof * i : dofs[i] - baseval; for(k=rowptr[0]; k<rowptr[1]; k++, colptr++) { j = (*colptr - baseval); - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j] - baseval; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? spm->dof * j : dofs[j] - baseval; for(jj=0; jj<dofj; jj++) { @@ -328,14 +328,14 @@ z_spmCSR2dense( const spmatrix_t *spm ) case SpmSymmetric: for(i=0; i<spm->n; i++, rowptr++) { - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i] - baseval; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? spm->dof * i : dofs[i] - baseval; for(k=rowptr[0]; k<rowptr[1]; k++, colptr++) { j = (*colptr - baseval); - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j] - baseval; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? spm->dof * j : dofs[j] - baseval; for(jj=0; jj<dofj; jj++) { @@ -352,14 +352,14 @@ z_spmCSR2dense( const spmatrix_t *spm ) default: for(i=0; i<spm->n; i++, rowptr++) { - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i] - baseval; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? spm->dof * i : dofs[i] - baseval; for(k=rowptr[0]; k<rowptr[1]; k++, colptr++) { j = (*colptr - baseval); - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j] - baseval; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? spm->dof * j : dofs[j] - baseval; for(jj=0; jj<dofj; jj++) { diff --git a/src/z_spm_integer.c b/src/z_spm_integer.c index 760a999a..eda3f2c8 100644 --- a/src/z_spm_integer.c +++ b/src/z_spm_integer.c @@ -118,7 +118,7 @@ static inline int intsortcmp_iif( void ** const pbase, spm_int_t *p, spm_int_t *q ) { spm_int_t *int1ptr = pbase[0]; spm_int_t *int2ptr = pbase[1]; - return ( ( *p < *q ) || (( *p == *q ) && ( int2ptr[ p - int1ptr ] < int2ptr[ q - int1ptr ] )) ); + return ( *p < *q ) || (( *p == *q ) && ( int2ptr[ p - int1ptr ] < int2ptr[ q - int1ptr ] )); } #define INTSORTCMP(p,q) intsortcmp_iif( pbase, (spm_int_t*)p, (spm_int_t*)q ) #include "integer_sort_mtypes.c" diff --git a/tests/spm_tests.h b/tests/spm_tests.h index f742e181..765de234 100644 --- a/tests/spm_tests.h +++ b/tests/spm_tests.h @@ -87,18 +87,21 @@ void s_spm_print_check( char *filename, const spmatrix_t *spm ); int s_spm_matvec_check( int trans, const spmatrix_t *spm ); int s_spm_norm_check( const spmatrix_t *spm ); -static inline -void spm_norm_print_result( double norms, double normd, double result ) +static inline int +spm_norm_print_result( double norms, double normd, double result ) { + int rc = 0; if ( (result >= 0.) && (result < 1.) ) { printf("SUCCESS !\n"); } else { printf("FAILED !\n"); - ret++; + rc=1; } printf(" Nsparse = %e, Ndense = %e\n", norms, normd ); printf(" | Nsparse - Ndense | / Ndense = %e\n", result); + + return rc; } #endif /* _spm_tests_h_ */ diff --git a/tests/z_spm_tests.c b/tests/z_spm_tests.c index 71c58b2b..4a64c5ee 100644 --- a/tests/z_spm_tests.c +++ b/tests/z_spm_tests.c @@ -204,7 +204,7 @@ z_spm_norm_check( const spmatrix_t *spm ) norms = spmNorm( SpmMaxNorm, spm ); normd = LAPACKE_zlange( LAPACK_COL_MAJOR, 'M', spm->gNexp, spm->gNexp, A, spm->gNexp ); result = fabs(norms - normd) / (normd * eps); - spm_norm_print_result( norms, normd, result ); + ret += spm_norm_print_result( norms, normd, result ); /** * Test Norm Inf @@ -214,7 +214,7 @@ z_spm_norm_check( const spmatrix_t *spm ) normd = LAPACKE_zlange( LAPACK_COL_MAJOR, 'I', spm->gNexp, spm->gNexp, A, spm->gNexp ); result = fabs(norms - normd) / (normd * eps); result = result * ((double)(spm->gNexp)) / ((double)(spm->gnnzexp)); - spm_norm_print_result( norms, normd, result ); + ret += spm_norm_print_result( norms, normd, result ); /** * Test Norm One @@ -224,7 +224,7 @@ z_spm_norm_check( const spmatrix_t *spm ) normd = LAPACKE_zlange( LAPACK_COL_MAJOR, 'O', spm->gNexp, spm->gNexp, A, spm->gNexp ); result = fabs(norms - normd) / (normd * eps); result = result * ((double)(spm->gNexp)) / ((double)(spm->gnnzexp)); - spm_norm_print_result( norms, normd, result ); + ret += spm_norm_print_result( norms, normd, result ); /** * Test Norm Frobenius @@ -234,7 +234,7 @@ z_spm_norm_check( const spmatrix_t *spm ) normd = LAPACKE_zlange( LAPACK_COL_MAJOR, 'F', spm->gNexp, spm->gNexp, A, spm->gNexp ); result = fabs(norms - normd) / (normd * eps); result = result / ((double)spm->gnnzexp); - spm_norm_print_result( norms, normd, result ); + ret += spm_norm_print_result( norms, normd, result ); free(A); return ret; -- GitLab