Newer
Older
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
}
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
/**
*******************************************************************************
*
* @brief Compute a matrix-matrix product.
*
* y = alpha * op(A) * B + beta * C
*
* 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.
*
*******************************************************************************
*
* @param[in] trans
* Specifies whether the matrix spm is transposed, not transposed or conjugate transposed:
* - PastixTrans
* - PastixNoTrans
* - PastixConjTrans
*
* @param[in] n
* The number of columns of the matrices B and C.
*
* @param[in] alpha
* alpha specifies the scalar alpha.
*
* @param[in] A
* The square sparse matrix A
*
* @param[in] B
* The matrix B of size ldb-by-n
*
* @param[in] ldb
* The leading dimension of the matrix B. ldb >= A->n
*
* @param[in] beta
* beta specifies the scalar beta.
*
* @param[inout] C
* The matrix C of size ldc-by-n
*
* @param[in] ldc
* The leading dimension of the matrix C. ldc >= A->n
*
*******************************************************************************
*
* @retval PASTIX_SUCCESS if the y vector has been computed successfully,
* @retval PASTIX_ERR_BADPARAMETER otherwise.
*
*******************************************************************************/
int
spmMatMat( pastix_trans_t trans,
pastix_int_t n,
const void *alpha,
const pastix_spm_t *A,
const void *B,
pastix_int_t ldb,
const void *beta,
void *C,
pastix_int_t ldc )
{
pastix_spm_t *espm = (pastix_spm_t*)A;
int rc = PASTIX_SUCCESS;
if ( A->fmttype != PastixCSC ) {
return PASTIX_ERR_BADPARAMETER;
}
if ( A->dof != 1 ) {
espm = spmExpand( A );
}
switch (A->flttype) {
case PastixFloat:
rc = s_spmCSCMatMat( trans, n, alpha, espm, B, ldb, beta, C, ldc );
break;
case PastixComplex32:
rc = c_spmCSCMatMat( trans, n, alpha, espm, B, ldb, beta, C, ldc );
break;
case PastixComplex64:
rc = z_spmCSCMatMat( trans, n, alpha, espm, B, ldb, beta, C, ldc );
break;
case PastixDouble:
default:
rc = d_spmCSCMatMat( trans, n, alpha, espm, B, ldb, beta, C, ldc );
break;
}
if ( A != espm ) {
spmExit( espm );
free(espm);
}
return rc;
}

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
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
*
*******************************************************************************
*
* @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 tests are succesfull
* @retval PASTIX_ERR_BADPARAMETER if the input matrix is incorrect
* @retval 1, if one of the test failed

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
{
switch(spm->flttype)
{
case PastixPattern:
break;
case PastixFloat:
break;
case PastixComplex32:
break;
case PastixComplex64:
break;
case PastixDouble:
default:
}
}
PICHON Gregoire
committed
/**
*******************************************************************************
*
* @brief Scale a vector according to the spm type.
*
* x = alpha * x
*
*******************************************************************************
*
* Datatype of the elements in the vector that must be:
* @arg PastixFloat
* @arg PastixDouble
* @arg PastixComplex32
* @arg PastixComplex64
* Number of elements in the input vectors
* The scaling parameter.
* @param[inout] x
* The vector to scal of size ( 1 + (n-1) * abs(incx) ), and of type
* defined by flt.
* Storage spacing between elements of x.
*
*******************************************************************************/
void
spmScalVector( pastix_coeftype_t flt,
double alpha,
pastix_int_t n,
void *x,
{
case PastixPattern:
break;
case PastixFloat:
cblas_sscal( n, (float)alpha, x, incx );
cblas_csscal( n, (float)alpha, x, incx );
cblas_zdscal( n, alpha, x, incx );
cblas_dscal( n, alpha, x, incx );