Newer
Older
* @param[in] f
* File to print the spm matrix.
*
*******************************************************************************/
void
spmPrint( const pastix_spm_t* spm, FILE *stream )
if (stream == NULL) {
stream = stdout;
}
switch(spm->flttype)
{
case PastixPattern:
//return p_f, spmPrint(f, spm);
break;
case PastixFloat:
s_spmPrint(stream, spm);
c_spmPrint(stream, spm);
z_spmPrint(stream, spm);
d_spmPrint(stream, spm);
/**
*******************************************************************************
*
* @brief Expand a multi-dof spm matrix into an spm with constant dof set to 1.
*
* Duplicate the spm data structure given as parameter. All new arrays are
* allocated and copied from the original matrix. Both matrices need to be
* freed.
*
*******************************************************************************
*
* @param[in] spm
* The sparse matrix to copy.
*
*******************************************************************************
*
* @return
* The copy of the sparse matrix.
*
*******************************************************************************/
spmExpand( const pastix_spm_t* spm )
case PastixPattern:
return p_spmExpand(spm);
break;

Mathieu Faverge
committed
/**
*******************************************************************************
*
*
* y = alpha * op(A) * x + beta * y, where op(A) is one of
*
* op( A ) = A or op( A ) = A' or op( A ) = conjg( A' )
*
* alpha and beta are scalars, and x and y are vectors.

Mathieu Faverge
committed
*
*******************************************************************************
*
* Specifies whether the matrix spm is transposed, not transposed or conjugate transposed:
* - PastixTrans
* - PastixNoTrans
* - PastixConjTrans

Mathieu Faverge
committed
*
* @param[in] alpha
* alpha specifies the scalar alpha.
*
* @param[in] spm
* The PastixGeneral spm.
*
* @param[in] x
* The vector x.
*
* @param[in] beta
* beta specifies the scalar beta.
*
* The vector y.
*
*******************************************************************************
*
* @retval PASTIX_SUCCESS if the y vector has been computed successfully,
* @retval PASTIX_ERR_BADPARAMETER otherwise.

Mathieu Faverge
committed
*
*******************************************************************************/
int
spmMatVec(const pastix_trans_t trans,
const void *alpha,
const pastix_spm_t *spm,
const void *x,
const void *beta,
void *y )

Mathieu Faverge
committed
{
pastix_spm_t *espm = (pastix_spm_t*)spm;
int rc = PASTIX_SUCCESS;
if ( spm->fmttype != PastixCSC ) {
return PASTIX_ERR_BADPARAMETER;
}
if ( spm->dof != 1 ) {
espm = spmExpand( spm );
}
switch (spm->flttype) {
case PastixFloat:
rc = s_spmCSCMatVec( trans, alpha, espm, x, beta, y );
break;
rc = c_spmCSCMatVec( trans, alpha, espm, x, beta, y );
break;
rc = z_spmCSCMatVec( trans, alpha, espm, x, beta, y );
break;

Mathieu Faverge
committed
default:
rc = d_spmCSCMatVec( trans, alpha, espm, x, beta, y );
}
if ( spm != espm ) {
spmExit( espm );
free(espm);

Mathieu Faverge
committed
}

Mathieu Faverge
committed
}
/**
*******************************************************************************
*
* @brief Generate right hand side vectors associated to a given matrix.
* The vectors can be initialized randomly or to get a specific solution.

Mathieu Faverge
committed
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
*
*******************************************************************************
*
* @param[in] type
* Defines how to compute the vector b.
* - PastixRhsOne: b is computed such that x = 1 [ + I ]
* - PastixRhsI: b is computed such that x = i [ + i * I ]
* - PastixRhsRndX: b is computed by matrix-vector product, such that
* is a random vector in the range [-0.5, 0.5]
* - PastixRhsRndB: b is computed randomly and x is not computed.
*
* @param[in] nrhs
* Defines the number of right hand side that must be generated.
*
* @param[in] spm
* The sparse matrix uses to generate the right hand side, and the
* solution of the full problem.
*
* @param[out] x
* On exit, if x != NULL, then the x vector(s) generated to compute b
* is returned. Must be of size at least ldx * spm->n.
*
* @param[in] ldx
* Defines the leading dimension of x when multiple right hand sides
* are available. ldx >= spm->n.
*

Mathieu Faverge
committed
* b must be an allocated matrix of size at least ldb * nrhs.
* On exit, b is initialized as defined by the type parameter.
*
* @param[in] ldb
* Defines the leading dimension of b when multiple right hand sides
* are available. ldb >= spm->n.
*
*******************************************************************************
*
* @retval PASTIX_SUCCESS if the b vector has been computed successfully,
* @retval PASTIX_ERR_BADPARAMETER otherwise.

Mathieu Faverge
committed
*
*******************************************************************************/
int
spmGenRHS( pastix_rhstype_t type, pastix_int_t nrhs,
void *x, pastix_int_t ldx,
void *b, pastix_int_t ldb )

Mathieu Faverge
committed
{

Mathieu Faverge
committed
void *, int, void *, int) =
{
s_spmGenRHS, d_spmGenRHS, c_spmGenRHS, z_spmGenRHS
};
int id = spm->flttype - PastixFloat;
if ( (id < 0) || (id > 3) ) {
return PASTIX_ERR_BADPARAMETER;
}
else {
return ptrfunc[id](type, nrhs, spm, x, ldx, b, ldb );
}
}
/**
*******************************************************************************
*
* @brief Check the backward error, and the forward error if x0 is provided.

Mathieu Faverge
committed
*
*******************************************************************************
*
* @param[in] nrhs
* Defines the number of right hand side that must be generated.
*
* @param[in] spm
* The sparse matrix used to generate the right hand side, and the

Mathieu Faverge
committed
* solution of the full problem.
*

Mathieu Faverge
committed
* If x0 != NULL, the forward error is computed.

Mathieu Faverge
committed
*
* @param[in] ldx0
* Defines the leading dimension of x0 when multiple right hand sides
* are available. ldx0 >= spm->n.
*

Mathieu Faverge
committed
* b is a matrix of size at least ldb * nrhs.
* On exit, b stores Ax-b.
*
* @param[in] ldb
* Defines the leading dimension of b when multiple right hand sides
* are available. ldb >= spm->n.
*
* @param[in] x
* Contains the solution computed by the solver.
*
* @param[in] ldx
* Defines the leading dimension of x when multiple right hand sides
* are available. ldx >= spm->n.
*
*******************************************************************************
*
* @retval PASTIX_SUCCESS if the b vector has been computed successfully,
* @retval PASTIX_ERR_BADPARAMETER otherwise.

Mathieu Faverge
committed
*
*******************************************************************************/
int
spmCheckAxb( pastix_int_t nrhs,
void *x0, pastix_int_t ldx0,
void *b, pastix_int_t ldb,
const void *x, pastix_int_t ldx )

Mathieu Faverge
committed
{
static int (*ptrfunc[4])(int, const pastix_spm_t *,

Mathieu Faverge
committed
void *, int, void *, int, const void *, int) =
{
s_spmCheckAxb, d_spmCheckAxb, c_spmCheckAxb, z_spmCheckAxb
};
int id = spm->flttype - PastixFloat;
if ( (id < 0) || (id > 3) ) {
return PASTIX_ERR_BADPARAMETER;
}
else {
return ptrfunc[id](nrhs, spm, x0, ldx0, b, ldb, x, ldx );
}
}
/**
*******************************************************************************
*
*
*******************************************************************************
*
* @param[in] alpha
* The scaling parameter.
*
* The sparse matrix to scal.
*
*******************************************************************************/
void
PICHON Gregoire
committed
spmScalMatrix(const pastix_complex64_t alpha, pastix_spm_t* spm)
{
switch(spm->flttype)
{
case PastixPattern:
break;
case PastixFloat:
break;
case PastixComplex32:
break;
case PastixComplex64:
break;
case PastixDouble:
default:
}
}
PICHON Gregoire
committed
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
/**
*******************************************************************************
*
* @brief Scale a vector according to the spm type.
*
* x = alpha * x
*
*******************************************************************************
*
* @param[in] alpha
* The scaling parameter.
*
* @param[in] spm
* The spm structure to know the type of the vector.
*
* @param[inout] x
* The vector to scal.
*
*******************************************************************************/
void
spmScalVector(const double alpha, pastix_spm_t* spm, void *x)
{
switch(spm->flttype)
{
case PastixPattern:
break;
case PastixFloat:
cblas_sscal(spm->n, alpha, x, 1);
break;
case PastixComplex32:
cblas_csscal(spm->n, alpha, x, 1);
break;
case PastixComplex64:
cblas_zdscal(spm->n, alpha, x, 1);
break;
case PastixDouble:
default:
cblas_dscal(spm->n, alpha, x, 1);
}
}