40 for( i = 0; i < dim1; i++ )
42 for( j = 0; j < dim2; j++ )
44 for( k = 0; k < dim3; k++ )
50 spm->
rowptr[nnz] = i + dim1 * j + dim1 * dim2 * k;
51 spm->
colptr[nnz] = i + dim1 * j + dim1 * dim2 * k;
58 d += (( i + j + k ) % 3) + 1;
62 spm->
rowptr[nnz] = (i+1) + dim1 * j + dim1 * dim2 * k;
63 spm->
colptr[nnz] = i + dim1 * j + dim1 * dim2 * k;
68 spm->
rowptr[nnz] = i + dim1 * (j+1) + dim1 * dim2 * k;
69 spm->
colptr[nnz] = i + dim1 * j + dim1 * dim2 * k;
74 spm->
rowptr[nnz] = i + dim1 * j + dim1 * dim2 * (k+1);
75 spm->
colptr[nnz] = i + dim1 * j + dim1 * dim2 * k;
84 assert( nnz == ((2*(dim1)-1) * dim2 * dim3 + (dim2-1)*dim1*dim3 + dim2*dim1*(dim3-1)) );
99 double *values = spm->
values;
108 for( l=0; l<spm->
nnz; l++ )
111 k = l / ( dim1 * dim2 );
112 j = (l % ( dim1 * dim2 )) / dim1;
117 dofcol = spm->
dofs[ col+1 ] - spm->
dofs[ col ];
118 dofrow = spm->
dofs[ row+1 ] - spm->
dofs[ row ];
127 if ( i == 0 ) { value -= 1.; }
128 if ( i == mdim1 ) { value -= 1.; }
129 if ( j == 0 ) { value -= 1.; }
130 if ( j == mdim2 ) { value -= 1.; }
131 if ( k == 0 ) { value -= 1.; }
132 if ( k == mdim3 ) { value -= 1.; }
141 for ( n=0; n<dofcol; n++ ) {
142 for ( m=0; m<dofrow; m++ ) {
149 assert( v == spm->
nnzexp );
156spm_example_create_laplacian(
spmatrix_t *spm )
176 spm->
n = dim1 * dim2 * dim3;
177 spm->
nnz = dim1 * dim2 * dim3;
178 spm->
nnz += (dim1 - 1) * dim2 * dim3;
179 spm->
nnz += dim1 * (dim2 - 1) * dim3;
180 spm->
nnz += dim1 * dim2 * (dim3 - 1);
198 spm_example_fill_ijv_struct( spm, dim1, dim2, dim3 );
215 spm_example_fill_ijv_values( spm, dim1, dim2, dim3 );
218int main(
int argc,
char **argv )
224 double epsilon, norm;
232#if defined(SPM_WITH_MPI)
233 MPI_Init( &argc, &argv );
239 spm_example_create_laplacian( &spm );
255 fprintf( stdout,
" || A ||_f: %e\n", norm );
273 rc =
spmGenMat( SpmRhsRndX, nrhs, &spm, &alpha, 24356, x, ldx );
298 epsilon = epsilon * spm.
nnzexp / spm.
gN;
299 rc =
spmCheckAxb( epsilon, nrhs, &spm, NULL, 1, b, ldb, x, ldx );
305#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.