26spm_example_fill_ijv_spm(
spm_int_t *colptr,
42 for( i = 0; i < dim1; i++ )
44 for( j = 0; j < dim2; j++ )
46 for( k = 0; k < dim3; k++ )
52 rowptr[l] = i + dim1 * j + dim1 * dim2 * k + 1;
53 colptr[l] = i + dim1 * j + dim1 * dim2 * k + 1;
59 if ( i == 0 ) { values[l] -= 1.; }
60 if ( i == mdim1 ) { values[l] -= 1.; }
61 if ( j == 0 ) { values[l] -= 1.; }
62 if ( j == mdim2 ) { values[l] -= 1.; }
63 if ( k == 0 ) { values[l] -= 1.; }
64 if ( k == mdim3 ) { values[l] -= 1.; }
72 rowptr[l] = (i+1) + dim1 * j + dim1 * dim2 * k + 1;
73 colptr[l] = i + dim1 * j + dim1 * dim2 * k + 1;
79 rowptr[l] = i + dim1 * (j+1) + dim1 * dim2 * k + 1;
80 colptr[l] = i + dim1 * j + dim1 * dim2 * k + 1;
86 rowptr[l] = i + dim1 * j + dim1 * dim2 * (k+1) + 1;
87 colptr[l] = i + dim1 * j + dim1 * dim2 * k + 1;
95 assert( l == ((2*(dim1)-1) * dim2 * dim3 + (dim2-1)*dim1*dim3 + dim2*dim1*(dim3-1)) );
102spm_example_create_laplacian(
spmatrix_t *spm )
110 n = dim1 * dim2 * dim3;
111 nnz = (2*(dim1)-1) * dim2 * dim3 + (dim2-1)*dim1*dim3 + dim2*dim1*(dim3-1);
147 spm_example_fill_ijv_spm( spm->
colptr,
153int main(
int argc,
char **argv )
159 double epsilon, norm;
167#if defined(SPM_WITH_MPI)
168 MPI_Init( &argc, &argv );
174 spm_example_create_laplacian( &spm );
190 fprintf( stdout,
" || A ||_f: %e\n", norm );
208 rc =
spmGenMat( SpmRhsRndX, nrhs, &spm, &alpha, 24356, x, ldx );
233 epsilon = epsilon * spm.
nnzexp / spm.
gN;
234 rc =
spmCheckAxb( epsilon, nrhs, &spm, NULL, 1, b, ldb, x, ldx );
240#if defined(SPM_WITH_MPI)
static size_t spm_size_of(spm_coeftype_t type)
Double datatype that is not converted through precision generator functions.
void spmAlloc(spmatrix_t *spm)
Allocate the arrays of an spm structure.
void spmExit(spmatrix_t *spm)
Cleanup the spm structure but do not free the spm pointer.
void spmUpdateComputedFields(spmatrix_t *spm)
Update all the computed fields based on the static values stored.
int spm_int_t
The main integer datatype used in spm arrays.
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.
int spmConvert(int ofmttype, spmatrix_t *ospm)
Convert the storage format of the spm.
int spmMatMat(spm_trans_t trans, spm_int_t n, double alpha, const spmatrix_t *A, const void *B, spm_int_t ldb, double beta, void *C, spm_int_t ldc)
Compute a matrix-matrix product.
void spmScal(double alpha, spmatrix_t *spm)
Scale the spm.
double spmNorm(spm_normtype_t ntype, const spmatrix_t *spm)
Compute the norm of the spm.
void spmInit(spmatrix_t *spm)
Init the spm structure.
int spmGenMat(spm_rhstype_t type, spm_int_t nrhs, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *A, spm_int_t lda)
Generate a set of vectors associated to a given matrix.
void spmPrintInfo(const spmatrix_t *spm, FILE *f)
Print basic informations about the spm matrix into a given stream.
The sparse matrix data structure.