A step-by-step example with a personal ordering (identity).
/
#include <spm.h>
int main (
int argc,
char **argv)
{
pastix_data_t *pastix_data = NULL;
pastix_int_t iparm[IPARM_SIZE];
double dparm[DPARM_SIZE];
spm_driver_t driver;
char *filename = NULL;
spmatrix_t *spm, spm2;
void *x, *b, *x0 = NULL;
size_t size;
int check = 1;
int nrhs = 1;
int rc = 0;
pastix_int_t i;
iparm, dparm,
&check, &driver, &filename );
pastixInit( &pastix_data, MPI_COMM_WORLD, iparm, dparm );
spm = malloc( sizeof( spmatrix_t ) );
rc = spmReadDriver( driver, filename, spm );
free( filename );
if ( rc != SPM_SUCCESS ) {
return rc;
}
spmPrintInfo( spm, stdout );
rc = spmCheckAndCorrect( spm, &spm2 );
if ( rc != 0 ) {
spmExit( spm );
*spm = spm2;
rc = 0;
}
if ( spm->flttype == SpmPattern ) {
spmGenFakeValues( spm );
}
{
}
double normA = spmNorm( SpmFrobeniusNorm, spm );
spmScal( 1./normA, spm );
size = pastix_size_of( spm->flttype ) * spm->nexp * nrhs;
x = malloc( size );
b = malloc( size );
if ( check )
{
if ( check > 1 ) {
x0 = malloc( size );
}
spmGenRHS( SpmRhsRndX, nrhs, spm, x0, spm->nexp, b, spm->nexp );
memcpy( x, b, size );
}
else {
spmGenRHS( SpmRhsRndB, nrhs, spm, NULL, spm->nexp, x, spm->nexp );
spmScalMat( 1./normA, spm, nrhs, b, spm->nexp );
memcpy( b, x, size );
}
if ( check )
{
if ( x0 ) {
free( x0 );
}
}
spmExit( spm );
free( spm );
free( x );
free( b );
return rc;
}