A step-by-step example that runs one full analyze (ordering, symbolic factorization, analyze), then loops over 2 factorizations that are both used for 2 solves each.
/
#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 = 10;
int rc = 0;
int nfact = 2;
int nsolv = 2;
long i,j;
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 > 1 ) {
x0 = malloc( size );
}
for (i = 0; i < nfact; i++)
{
for (j = 0; j < nsolv; j++)
{
if ( check )
{
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 ) {
}
}
}
spmExit( spm );
free( spm );
free( b );
free( x );
if ( x0 ) {
free( x0 );
}
return rc;
}