Mentions légales du service

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

Fix corner case in C examples

parent 9456e729
No related branches found
No related tags found
1 merge request!53Fix corner cases in distributed
......@@ -65,7 +65,9 @@ int main( int argc, char **argv )
/*
* Scale the sparse matrix.
*/
spmScalMatrix( 1. / norm, &spm );
if ( norm > 0. ) {
spmScalMatrix( 1. / norm, &spm );
}
/*
* Create a random vector x to test products.
......
......@@ -189,7 +189,9 @@ int main( int argc, char **argv )
/*
* Scale the sparse matrix.
*/
spmScalMatrix( 1. / norm, &spm );
if ( norm > 0. ) {
spmScalMatrix( 1. / norm, &spm );
}
/*
* Create a random matrix x to test products (multiple right hand side).
......
......@@ -190,7 +190,9 @@ int main (int argc, char **argv)
/*
* Scale the sparse matrix.
*/
spmScalMatrix( 1. / norm, &spm );
if ( norm > 0. ) {
spmScalMatrix( 1. / norm, &spm );
}
/*
* Create a random matrix x to test products (multiple right hand side).
......
......@@ -254,7 +254,9 @@ int main( int argc, char **argv )
/*
* Scale the sparse matrix.
*/
spmScalMatrix( 1. / norm, &spm );
if ( norm > 0. ) {
spmScalMatrix( 1. / norm, &spm );
}
/*
* Create a random matrix x to test products (multiple right hand side).
......
......@@ -217,7 +217,9 @@ int main (int argc, char **argv)
/*
* Scale the sparse matrix.
*/
spmScalMatrix( 1. / norm, &spm );
if ( norm > 0. ) {
spmScalMatrix( 1. / norm, &spm );
}
/*
* Create a random matrix x to test products (multiple right hand side).
......
......@@ -119,6 +119,9 @@ z_spmGenRHS( spm_rhstype_t type,
if ( type == SpmRhsRndB ) {
/* Compute the spm norm to scale the b vector */
spm_complex64_t norm = z_spmNorm( SpmFrobeniusNorm, spm );
if ( norm == 0. ) {
norm = 1.;
}
z_spmGenMat( type, nrhs, spm, &norm, 24356, bptr, ldb );
return SPM_SUCCESS;
......@@ -228,11 +231,12 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs,
double norm;
norm = LAPACKE_zlange( LAPACK_COL_MAJOR, 'I', spm->nexp, 1, zb + i * ldb, ldb );
normB = (norm > normB ) ? norm : normB;
normB = ( norm > normB ) ? norm : normB;
norm = LAPACKE_zlange( LAPACK_COL_MAJOR, 'I', spm->nexp, 1, zx + i * ldx, ldx );
normX = (norm > normX ) ? norm : normX;
normX = ( norm > normX ) ? norm : normX;
nb2[i] = cblas_dznrm2( spm->nexp, zb + i * ldb, 1 );
if ( nb2[i] == 0. ) { nb2[i] = 1.; }
}
fprintf( stdout,
" || A ||_1 %e\n"
......@@ -254,9 +258,16 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs,
double nx = cblas_dzasum( spm->nexp, zx + i * ldx, 1 );
double nr = cblas_dzasum( spm->nexp, zb + i * ldb, 1 );
double nr2 = cblas_dznrm2( spm->nexp, zb + i * ldb, 1 ) / nb2[i];
double back = ((nr / normA) / nx) / eps;
double back = ( nr / eps );
int fail = 0;
if ( normA > 0. ) {
nr = nr / normA;
}
if ( nx > 0. ) {
nr = nr / nx;
}
normR = (nr > normR ) ? nr : normR;
normR2 = (nr2 > normR2 ) ? nr2 : normR2;
backward = (back > backward) ? back : backward;
......@@ -307,7 +318,8 @@ z_spmCheckAxb( spm_fixdbl_t eps, int nrhs,
nr = LAPACKE_zlange( LAPACK_COL_MAJOR, 'I', spm->nexp, 1, zx0, ldx0 );
forw = (nr / nx0) / eps;
forw = nr / eps;
if ( nx0 > 0. ) { forw = forw / nx0; }
normX0 = ( nx > normX0 ) ? nx : normX0;
normR = ( nr > normR ) ? nr : normR;
......
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