Example to show how to use the SpM drivers to read a sparse matrix form file, here with the Laplacian generator driver.
/
int main( int argc, char **argv )
{
double alpha = 2.;
double epsilon, norm;
void *x, *b;
int rc = 0;
#if defined(SPM_WITH_MPI)
MPI_Init( &argc, &argv );
#endif
return rc;
}
}
fprintf( stdout, " || A ||_f: %e\n", norm );
if ( norm > 0. ) {
}
x = malloc( size );
rc =
spmGenVec( SpmRhsRndX, &spm, &alpha, 24356, x, 1 );
free( x );
return rc;
}
b = malloc( size );
{
epsilon = 1e-15;
}
else {
epsilon = 1e-7;
}
epsilon = epsilon * spm.
nnzexp / spm.
gN;
rc =
spmCheckAxb( epsilon, 1, &spm, NULL, 1, b, ldb, x, ldx );
free( x );
free( b );
#if defined(SPM_WITH_MPI)
MPI_Finalize();
#endif
(void)argc;
(void)argv;
return rc;
}
static size_t spm_size_of(spm_coeftype_t type)
Double datatype that is not converted through precision generator functions.
void spmExit(spmatrix_t *spm)
Cleanup the spm structure but do not free the spm pointer.
struct spmatrix_s spmatrix_t
The sparse matrix data structure.
int spmMatVec(spm_trans_t trans, double alpha, const spmatrix_t *spm, const void *x, double beta, void *y)
Compute a matrix-vector product.
int spmCheckAxb(double eps, spm_int_t nrhs, const spmatrix_t *spm, void *opt_X0, spm_int_t opt_ldx0, void *B, spm_int_t ldb, const void *X, spm_int_t ldx)
Check the backward error, and the forward error if x0 is provided.
void spmGenFakeValues(spmatrix_t *spm)
Generate the fake values array such that .
int spmReadDriver(spm_driver_t driver, const char *filename, spmatrix_t *spm)
Import a matrix file into a spm structure.
void spmScal(double alpha, spmatrix_t *spm)
Scale the spm.
int spmGenVec(spm_rhstype_t type, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *x, spm_int_t incx)
Generate a vector associated to a given matrix.
double spmNorm(spm_normtype_t ntype, const spmatrix_t *spm)
Compute the norm of the spm.
int spm_int_t
The main integer datatype used in spm arrays.
void spmPrintInfo(const spmatrix_t *spm, FILE *f)
Print basic informations about the spm matrix into a given stream.