Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 1fd19691 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Factorize code in norm tests

parent 22a1ecd6
No related branches found
No related tags found
No related merge requests found
......@@ -87,4 +87,18 @@ 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 )
{
if ( (result >= 0.) && (result < 1.) ) {
printf("SUCCESS !\n");
} else {
printf("FAILED !\n");
ret++;
}
printf(" Nsparse = %e, Ndense = %e\n", norms, normd );
printf(" | Nsparse - Ndense | / Ndense = %e\n", result);
}
#endif /* _spm_tests_h_ */
......@@ -204,16 +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);
if ( (result >= 0.) && (result < 1.) ) {
printf("SUCCESS !\n");
} else {
printf("FAILED !\n");
ret++;
}
printf(" Nsparse = %e, Ndense = %e\n", norms, normd );
printf(" | Nsparse - Ndense | / Ndense = %e\n", result);
spm_norm_print_result( norms, normd, result );
/**
* Test Norm Inf
......@@ -223,16 +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));
if ( (result >= 0.) && (result < 1.) ) {
printf("SUCCESS !\n");
} else {
printf("FAILED !\n");
ret++;
}
printf(" Nsparse = %e, Ndense = %e\n", norms, normd );
printf(" | Nsparse - Ndense | / Ndense = %e\n", result);
spm_norm_print_result( norms, normd, result );
/**
* Test Norm One
......@@ -242,16 +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));
if ( (result >= 0.) && (result < 1.) ) {
printf("SUCCESS !\n");
} else {
printf("FAILED !\n");
ret++;
}
printf(" Nsparse = %e, Ndense = %e\n", norms, normd );
printf(" | Nsparse - Ndense | / Ndense = %e\n", result);
spm_norm_print_result( norms, normd, result );
/**
* Test Norm Frobenius
......@@ -261,16 +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);
if ( (result >= 0.) && (result < 1.) ) {
printf("SUCCESS !\n");
} else {
printf("FAILED !\n");
ret++;
}
printf(" Nsparse = %e, Ndense = %e\n", norms, normd );
printf(" | Nsparse - Ndense | / Ndense = %e\n", result);
spm_norm_print_result( norms, normd, result );
free(A);
return ret;
......
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