81 spm_complex64_t *xptr = (spm_complex64_t*)x;
82 spm_complex64_t *bptr = (spm_complex64_t*)b;
83 spm_complex64_t alpha = (spm_complex64_t)1.;
86 if( ( spm == NULL ) ||
87 ( spm->
values == NULL ) ) {
99 if( (xptr != NULL) && (nrhs > 1) && (ldx < spm->nexp) ) {
107 if( ( nrhs > 1 ) && ( ldb < spm->
nexp ) ) {
117 if ( type == SpmRhsRndB ) {
123 z_spmGenMat( type, nrhs, spm, &norm, 24356, bptr, ldb );
128 if ( (type == SpmRhsOne ) ||
129 (type == SpmRhsI ) ||
130 (type == SpmRhsRndX ) )
132 if ( xptr == NULL ) {
134 xptr = malloc( ldx * nrhs *
sizeof(spm_complex64_t) );
137 z_spmGenMat( type, nrhs, spm, &alpha, 24356, xptr, ldx );
140 rc =
spm_zspmm(
SpmLeft,
SpmNoTrans,
SpmNoTrans, nrhs, alpha, spm, xptr, ldx, 0., bptr, ldb );
148 fprintf(stderr,
"z_spmGenRHS: Generator not implemented yet\n");
207 const void *x,
int ldx )
209 const spm_complex64_t *zx = (
const spm_complex64_t *)x;
210 spm_complex64_t *zx0 = (spm_complex64_t *)x0;
211 spm_complex64_t *zb = (spm_complex64_t *)b;
212 double *nb2 = malloc( nrhs *
sizeof(
double) );
213 double normA, normB, normX, normR, normR2;
214 double backward, forward;
219 eps = LAPACKE_dlamch(
'e');
229 for( i=0; i<nrhs; i++ ) {
233 normB = ( norm > normB ) ? norm : normB;
235 normX = ( norm > normX ) ? norm : normX;
238 if ( nb2[i] == 0. ) { nb2[i] = 1.; }
242 " max(|| b_i ||_oo) %e\n"
243 " max(|| x_i ||_oo) %e\n",
244 normA, normB, normX );
249 spm_zspmm(
SpmLeft,
SpmNoTrans,
SpmNoTrans, nrhs, -1., spm, x, ldx, 1., b, ldb );
256 for( i=0; i<nrhs; i++ ) {
260 double back = ( nr / eps );
270 normR = (nr > normR ) ? nr : normR;
271 normR2 = (nr2 > normR2 ) ? nr2 : normR2;
272 backward = (back > backward) ? back : backward;
274 fail = isnan(nr) || isinf(nr) || isnan(back) || isinf(back) || (back > 1.e2);
277 " || b_%d - A x_%d ||_2 / || b_%d ||_2 %e\n"
278 " || b_%d - A x_%d ||_1 %e\n"
279 " || b_%d - A x_%d ||_1 / (||A||_1 * ||x_%d||_oo * eps) %e (FAILED)\n",
285 failure = failure || fail;
289 " max(|| b_i - A x_i ||_2 / || b_i ||_2) %e\n"
290 " max(|| b_i - A x_i ||_1) %e\n"
291 " max(|| b_i - A x_i ||_1 / (||A||_1 * ||x_i||_oo * eps)) %e (%s)\n",
292 normR2, normR, backward,
293 failure ?
"FAILED" :
"SUCCESS" );
302 double forw, nr, nx, nx0;
310 for( i=0; i<nrhs; i++, zx += ldx, zx0 += ldx0 ) {
321 if ( nx0 > 0. ) { forw = forw / nx0; }
323 normX0 = ( nx > normX0 ) ? nx : normX0;
324 normR = ( nr > normR ) ? nr : normR;
325 forward = ( forw > forward ) ? forw : forward;
327 fail = isnan(nx) || isinf(nx) || isnan(forw) || isinf(forw) || (forw > 1.e2);
330 " || x_%d ||_oo %e\n"
331 " || x0_%d - x_%d ||_oo %e\n"
332 " || x0_%d - x_%d ||_oo / (||x0_%d||_oo * eps) %e (FAILED)\n",
338 failure = failure || fail;
342 " max(|| x_i ||_oo) %e\n"
343 " max(|| x0_i - x_i ||_oo) %e\n"
344 " max(|| x0_i - x_i ||_oo / || x0_i ||_oo) %e (%s)\n",
345 normX0, normR, forward,
346 failure ?
"FAILED" :
"SUCCESS" );
int spm_zspmm(spm_side_t side, spm_trans_t transA, spm_trans_t transB, spm_int_t K, spm_complex64_t alpha, const spmatrix_t *A, const spm_complex64_t *B, spm_int_t ldb, spm_complex64_t beta, spm_complex64_t *C, spm_int_t ldc)
Compute a matrix-matrix product.
double z_spmNormMat(spm_normtype_t ntype, const spmatrix_t *spm, spm_int_t n, const spm_complex64_t *A, spm_int_t lda)
Compute the norm of a dense matrix that follows the distribution of an spm matrix.
int z_spmGenMat(spm_rhstype_t type, int nrhs, const spmatrix_t *spm, void *alpha, unsigned long long int seed, void *A, int lda)
Generate nrhs right hand side vectors associated to a given matrix to test a problem with a solver.
int z_spmGenRHS(spm_rhstype_t type, int nrhs, const spmatrix_t *spm, void *x, int ldx, void *b, int ldb)
Generate nrhs right hand side vectors associated to a given matrix to test a problem with a solver.
int z_spmCheckAxb(spm_fixdbl_t eps, int nrhs, const spmatrix_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx)
Check the backward error, and the forward error if x0 is provided.