SpM Handbook 1.2.4
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Spm_dev_matvec

Matrix-Vector and matrix-matrix product routines. More...

Files

file  c_spm_matrixvector.c
 
file  s_spm_matrixvector.c
 
file  z_spm_matrixvector.c
 
file  d_spm_matrixvector.c
 

Functions

int spm_sspmv (spm_trans_t trans, float alpha, const spmatrix_t *A, const float *x, spm_int_t incx, float beta, float *y, spm_int_t incy)
 compute the matrix-vector product:
 
int spm_sspmm (spm_side_t side, spm_trans_t transA, spm_trans_t transB, spm_int_t K, float alpha, const spmatrix_t *A, const float *B, spm_int_t ldb, float beta, float *C, spm_int_t ldc)
 Compute a matrix-matrix product.
 
int spm_dspmv (spm_trans_t trans, double alpha, const spmatrix_t *A, const double *x, spm_int_t incx, double beta, double *y, spm_int_t incy)
 compute the matrix-vector product:
 
int spm_dspmm (spm_side_t side, spm_trans_t transA, spm_trans_t transB, spm_int_t K, double alpha, const spmatrix_t *A, const double *B, spm_int_t ldb, double beta, double *C, spm_int_t ldc)
 Compute a matrix-matrix product.
 
int spm_cspmv (spm_trans_t trans, spm_complex32_t alpha, const spmatrix_t *A, const spm_complex32_t *x, spm_int_t incx, spm_complex32_t beta, spm_complex32_t *y, spm_int_t incy)
 compute the matrix-vector product:
 
int spm_cspmm (spm_side_t side, spm_trans_t transA, spm_trans_t transB, spm_int_t K, spm_complex32_t alpha, const spmatrix_t *A, const spm_complex32_t *B, spm_int_t ldb, spm_complex32_t beta, spm_complex32_t *C, spm_int_t ldc)
 Compute a matrix-matrix product.
 
int spm_zspmv (spm_trans_t trans, spm_complex64_t alpha, const spmatrix_t *A, const spm_complex64_t *x, spm_int_t incx, spm_complex64_t beta, spm_complex64_t *y, spm_int_t incy)
 compute the matrix-vector product:
 
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.
 

Detailed Description

Matrix-Vector and matrix-matrix product routines.

Function Documentation

◆ spm_sspmv()

int spm_sspmv ( spm_trans_t  trans,
float  alpha,
const spmatrix_t A,
const float *  x,
spm_int_t  incx,
float  beta,
float *  y,
spm_int_t  incy 
)

compute the matrix-vector product:

\[ y = alpha * A * x + beta * y \]

A is a SpmSymmetric spm, alpha and beta are scalars, and x and y are vectors, and A a symm.

Parameters
[in]transTODO
[in]alphaalpha specifies the scalar alpha
[in]AThe SpmSymmetric spm.
[in]xThe vector x.
[in]incxThe vector x.
[in]betabeta specifies the scalar beta
[in,out]yThe vector y.
[in]incyThe vector y.
Return values
SPM_SUCCESSif the y vector has been computed succesfully,
SPM_ERR_BADPARAMETERotherwise.

Definition at line 1245 of file s_spm_matrixvector.c.

References spmatrix_s::mtxtype, spmatrix_s::nexp, s_spmm_build_Btmp(), s_spmm_build_Ctmp(), s_spmReduceRHS(), spm_get_distribution(), SPM_SUCCESS, SpmDistByColumn, SpmDistByRow, SpmGeneral, SpmLeft, and SpmNoTrans.

Referenced by spmMatVec().

◆ spm_sspmm()

int spm_sspmm ( spm_side_t  side,
spm_trans_t  transA,
spm_trans_t  transB,
spm_int_t  K,
float  alpha,
const spmatrix_t A,
const float *  B,
spm_int_t  ldb,
float  beta,
float *  C,
spm_int_t  ldc 
)

Compute a matrix-matrix product.

C = alpha * op(A) * op(B) + beta * C or C = alpha * op(B) * op(A) + beta * C

where A is a sparse matrix, B and C two dense matrices. And op(A), op(B) are one of:

op( A ) = A or op( A ) = A' or op( A ) = conjg( A' )

alpha and beta are scalars.

Parameters
[in]sideSpecifies whether A * B is computed or B * A
  • SpmLeft: C = alpha * op(A) * op(B) + beta * C
  • SpmRight: C = alpha * op(B) * op(A) + beta * C
[in]transASpecifies whether the sparse matrix A is not transposed, transposed or conjugate transposed:
  • SpmNoTrans
  • SpmTrans
  • SpmTrans
[in]transBSpecifies whether the dense matrix B is not transposed, transposed or conjugate transposed:
  • SpmNoTrans
  • SpmTrans
  • SpmTrans
[in]KIf side == SpmLeft, specifies the number of columns of the matrices op(B) and C. If side == SpmRight, specifies the number of rows of the matrices op(B) and C.
[in]alphaalpha specifies the scalar alpha.
[in]AThe sparse matrix A
[in]BThe matrix B of size: ldb-by-Bn, with Bn = (K, A->m or A->n) based on the configuration of side, transA and transB.
[in]ldbThe leading dimension of the matrix B. ldb >= (A->m, A->n or K) based on the configuration of side, transA, and transB
[in]betabeta specifies the scalar beta.
[in,out]CThe matrix C of size ldc-by-Cn with Bn = (K, A->m or A->n) based on the configuration of side, transA and transB.
[in]ldcThe leading dimension of the matrix C. ldc >= (A->m, A->n or K) based on the configuration of side, transA, and transB

side | transA | transB | B | C |

Left | NoTrans | NoTrans | A->n by K | A->m by K | Left | NoTrans | [Conj]Trans | K by A->n | A->m by K | Left | [Conj]Trans | NoTrans | A->m by K | A->n by K | Left | [Conj]Trans | [Conj]Trans | K by A->m | A->n by K | Right | NoTrans | NoTrans | K by A->m | K by A->n | Right | NoTrans | [Conj]Trans | A->m by K | K by A->n | Right | [Conj]Trans | NoTrans | K by A->n | K by A->m | Right | [Conj]Trans | [Conj]Trans | A->n by K | K by A->m |

Return values
SPM_SUCCESSif the y vector has been computed successfully,
SPM_ERR_BADPARAMETERotherwise.

Definition at line 1111 of file s_spm_matrixvector.c.

References LAPACKE_slascl_work, spmatrix_s::mtxtype, spmatrix_s::nexp, s_spmm_build_Btmp(), s_spmm_build_Ctmp(), s_spmReduceRHS(), SPM_ERR_BADPARAMETER, SPM_ERR_INTERNAL, spm_get_distribution(), SPM_SUCCESS, SpmDistByColumn, SpmDistByRow, SpmGeneral, SpmLeft, and SpmNoTrans.

Referenced by s_spmCheckAxb(), s_spmGenRHS(), and spmMatMat().

◆ spm_dspmv()

int spm_dspmv ( spm_trans_t  trans,
double  alpha,
const spmatrix_t A,
const double *  x,
spm_int_t  incx,
double  beta,
double *  y,
spm_int_t  incy 
)

compute the matrix-vector product:

\[ y = alpha * A * x + beta * y \]

A is a SpmSymmetric spm, alpha and beta are scalars, and x and y are vectors, and A a symm.

Parameters
[in]transTODO
[in]alphaalpha specifies the scalar alpha
[in]AThe SpmSymmetric spm.
[in]xThe vector x.
[in]incxThe vector x.
[in]betabeta specifies the scalar beta
[in,out]yThe vector y.
[in]incyThe vector y.
Return values
SPM_SUCCESSif the y vector has been computed succesfully,
SPM_ERR_BADPARAMETERotherwise.

Definition at line 1245 of file d_spm_matrixvector.c.

References d_spmm_build_Btmp(), d_spmm_build_Ctmp(), d_spmReduceRHS(), spmatrix_s::mtxtype, spmatrix_s::nexp, spm_get_distribution(), SPM_SUCCESS, SpmDistByColumn, SpmDistByRow, SpmGeneral, SpmLeft, and SpmNoTrans.

Referenced by spmMatVec().

◆ spm_dspmm()

int spm_dspmm ( spm_side_t  side,
spm_trans_t  transA,
spm_trans_t  transB,
spm_int_t  K,
double  alpha,
const spmatrix_t A,
const double *  B,
spm_int_t  ldb,
double  beta,
double *  C,
spm_int_t  ldc 
)

Compute a matrix-matrix product.

C = alpha * op(A) * op(B) + beta * C or C = alpha * op(B) * op(A) + beta * C

where A is a sparse matrix, B and C two dense matrices. And op(A), op(B) are one of:

op( A ) = A or op( A ) = A' or op( A ) = conjg( A' )

alpha and beta are scalars.

Parameters
[in]sideSpecifies whether A * B is computed or B * A
  • SpmLeft: C = alpha * op(A) * op(B) + beta * C
  • SpmRight: C = alpha * op(B) * op(A) + beta * C
[in]transASpecifies whether the sparse matrix A is not transposed, transposed or conjugate transposed:
  • SpmNoTrans
  • SpmTrans
  • SpmTrans
[in]transBSpecifies whether the dense matrix B is not transposed, transposed or conjugate transposed:
  • SpmNoTrans
  • SpmTrans
  • SpmTrans
[in]KIf side == SpmLeft, specifies the number of columns of the matrices op(B) and C. If side == SpmRight, specifies the number of rows of the matrices op(B) and C.
[in]alphaalpha specifies the scalar alpha.
[in]AThe sparse matrix A
[in]BThe matrix B of size: ldb-by-Bn, with Bn = (K, A->m or A->n) based on the configuration of side, transA and transB.
[in]ldbThe leading dimension of the matrix B. ldb >= (A->m, A->n or K) based on the configuration of side, transA, and transB
[in]betabeta specifies the scalar beta.
[in,out]CThe matrix C of size ldc-by-Cn with Bn = (K, A->m or A->n) based on the configuration of side, transA and transB.
[in]ldcThe leading dimension of the matrix C. ldc >= (A->m, A->n or K) based on the configuration of side, transA, and transB

side | transA | transB | B | C |

Left | NoTrans | NoTrans | A->n by K | A->m by K | Left | NoTrans | [Conj]Trans | K by A->n | A->m by K | Left | [Conj]Trans | NoTrans | A->m by K | A->n by K | Left | [Conj]Trans | [Conj]Trans | K by A->m | A->n by K | Right | NoTrans | NoTrans | K by A->m | K by A->n | Right | NoTrans | [Conj]Trans | A->m by K | K by A->n | Right | [Conj]Trans | NoTrans | K by A->n | K by A->m | Right | [Conj]Trans | [Conj]Trans | A->n by K | K by A->m |

Return values
SPM_SUCCESSif the y vector has been computed successfully,
SPM_ERR_BADPARAMETERotherwise.

Definition at line 1111 of file d_spm_matrixvector.c.

References d_spmm_build_Btmp(), d_spmm_build_Ctmp(), d_spmReduceRHS(), LAPACKE_dlascl_work, spmatrix_s::mtxtype, spmatrix_s::nexp, SPM_ERR_BADPARAMETER, SPM_ERR_INTERNAL, spm_get_distribution(), SPM_SUCCESS, SpmDistByColumn, SpmDistByRow, SpmGeneral, SpmLeft, and SpmNoTrans.

Referenced by d_spmCheckAxb(), d_spmGenRHS(), and spmMatMat().

◆ spm_cspmv()

int spm_cspmv ( spm_trans_t  trans,
spm_complex32_t  alpha,
const spmatrix_t A,
const spm_complex32_t x,
spm_int_t  incx,
spm_complex32_t  beta,
spm_complex32_t y,
spm_int_t  incy 
)

compute the matrix-vector product:

\[ y = alpha * A * x + beta * y \]

A is a SpmHermitian spm, alpha and beta are scalars, and x and y are vectors, and A a symm.

Parameters
[in]transTODO
[in]alphaalpha specifies the scalar alpha
[in]AThe SpmHermitian spm.
[in]xThe vector x.
[in]incxThe vector x.
[in]betabeta specifies the scalar beta
[in,out]yThe vector y.
[in]incyThe vector y.
Return values
SPM_SUCCESSif the y vector has been computed succesfully,
SPM_ERR_BADPARAMETERotherwise.

Definition at line 1245 of file c_spm_matrixvector.c.

References c_spmm_build_Btmp(), c_spmm_build_Ctmp(), c_spmReduceRHS(), CBLAS_SADDR, spmatrix_s::mtxtype, spmatrix_s::nexp, spm_get_distribution(), SPM_SUCCESS, SpmDistByColumn, SpmDistByRow, SpmGeneral, SpmLeft, and SpmNoTrans.

Referenced by spmMatVec().

◆ spm_cspmm()

int spm_cspmm ( spm_side_t  side,
spm_trans_t  transA,
spm_trans_t  transB,
spm_int_t  K,
spm_complex32_t  alpha,
const spmatrix_t A,
const spm_complex32_t B,
spm_int_t  ldb,
spm_complex32_t  beta,
spm_complex32_t C,
spm_int_t  ldc 
)

Compute a matrix-matrix product.

C = alpha * op(A) * op(B) + beta * C or C = alpha * op(B) * op(A) + beta * C

where A is a sparse matrix, B and C two dense matrices. And op(A), op(B) are one of:

op( A ) = A or op( A ) = A' or op( A ) = conjg( A' )

alpha and beta are scalars.

Parameters
[in]sideSpecifies whether A * B is computed or B * A
  • SpmLeft: C = alpha * op(A) * op(B) + beta * C
  • SpmRight: C = alpha * op(B) * op(A) + beta * C
[in]transASpecifies whether the sparse matrix A is not transposed, transposed or conjugate transposed:
  • SpmNoTrans
  • SpmTrans
  • SpmConjTrans
[in]transBSpecifies whether the dense matrix B is not transposed, transposed or conjugate transposed:
  • SpmNoTrans
  • SpmTrans
  • SpmConjTrans
[in]KIf side == SpmLeft, specifies the number of columns of the matrices op(B) and C. If side == SpmRight, specifies the number of rows of the matrices op(B) and C.
[in]alphaalpha specifies the scalar alpha.
[in]AThe sparse matrix A
[in]BThe matrix B of size: ldb-by-Bn, with Bn = (K, A->m or A->n) based on the configuration of side, transA and transB.
[in]ldbThe leading dimension of the matrix B. ldb >= (A->m, A->n or K) based on the configuration of side, transA, and transB
[in]betabeta specifies the scalar beta.
[in,out]CThe matrix C of size ldc-by-Cn with Bn = (K, A->m or A->n) based on the configuration of side, transA and transB.
[in]ldcThe leading dimension of the matrix C. ldc >= (A->m, A->n or K) based on the configuration of side, transA, and transB

side | transA | transB | B | C |

Left | NoTrans | NoTrans | A->n by K | A->m by K | Left | NoTrans | [Conj]Trans | K by A->n | A->m by K | Left | [Conj]Trans | NoTrans | A->m by K | A->n by K | Left | [Conj]Trans | [Conj]Trans | K by A->m | A->n by K | Right | NoTrans | NoTrans | K by A->m | K by A->n | Right | NoTrans | [Conj]Trans | A->m by K | K by A->n | Right | [Conj]Trans | NoTrans | K by A->n | K by A->m | Right | [Conj]Trans | [Conj]Trans | A->n by K | K by A->m |

Return values
SPM_SUCCESSif the y vector has been computed successfully,
SPM_ERR_BADPARAMETERotherwise.

Definition at line 1111 of file c_spm_matrixvector.c.

References c_spmm_build_Btmp(), c_spmm_build_Ctmp(), c_spmReduceRHS(), LAPACKE_clascl_work, spmatrix_s::mtxtype, spmatrix_s::nexp, SPM_ERR_BADPARAMETER, SPM_ERR_INTERNAL, spm_get_distribution(), SPM_SUCCESS, SpmDistByColumn, SpmDistByRow, SpmGeneral, SpmLeft, and SpmNoTrans.

Referenced by c_spmCheckAxb(), c_spmGenRHS(), and spmMatMat().

◆ spm_zspmv()

int spm_zspmv ( spm_trans_t  trans,
spm_complex64_t  alpha,
const spmatrix_t A,
const spm_complex64_t *  x,
spm_int_t  incx,
spm_complex64_t  beta,
spm_complex64_t *  y,
spm_int_t  incy 
)

compute the matrix-vector product:

\[ y = alpha * A * x + beta * y \]

A is a SpmHermitian spm, alpha and beta are scalars, and x and y are vectors, and A a symm.

Parameters
[in]transTODO
[in]alphaalpha specifies the scalar alpha
[in]AThe SpmHermitian spm.
[in]xThe vector x.
[in]incxThe vector x.
[in]betabeta specifies the scalar beta
[in,out]yThe vector y.
[in]incyThe vector y.
Return values
SPM_SUCCESSif the y vector has been computed succesfully,
SPM_ERR_BADPARAMETERotherwise.

Definition at line 1245 of file z_spm_matrixvector.c.

References CBLAS_SADDR, spmatrix_s::mtxtype, spmatrix_s::nexp, spm_get_distribution(), SPM_SUCCESS, SpmDistByColumn, SpmDistByRow, SpmGeneral, SpmLeft, SpmNoTrans, z_spmm_build_Btmp(), z_spmm_build_Ctmp(), and z_spmReduceRHS().

Referenced by spmMatVec().

◆ spm_zspmm()

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.

C = alpha * op(A) * op(B) + beta * C or C = alpha * op(B) * op(A) + beta * C

where A is a sparse matrix, B and C two dense matrices. And op(A), op(B) are one of:

op( A ) = A or op( A ) = A' or op( A ) = conjg( A' )

alpha and beta are scalars.

Parameters
[in]sideSpecifies whether A * B is computed or B * A
  • SpmLeft: C = alpha * op(A) * op(B) + beta * C
  • SpmRight: C = alpha * op(B) * op(A) + beta * C
[in]transASpecifies whether the sparse matrix A is not transposed, transposed or conjugate transposed:
  • SpmNoTrans
  • SpmTrans
  • SpmConjTrans
[in]transBSpecifies whether the dense matrix B is not transposed, transposed or conjugate transposed:
  • SpmNoTrans
  • SpmTrans
  • SpmConjTrans
[in]KIf side == SpmLeft, specifies the number of columns of the matrices op(B) and C. If side == SpmRight, specifies the number of rows of the matrices op(B) and C.
[in]alphaalpha specifies the scalar alpha.
[in]AThe sparse matrix A
[in]BThe matrix B of size: ldb-by-Bn, with Bn = (K, A->m or A->n) based on the configuration of side, transA and transB.
[in]ldbThe leading dimension of the matrix B. ldb >= (A->m, A->n or K) based on the configuration of side, transA, and transB
[in]betabeta specifies the scalar beta.
[in,out]CThe matrix C of size ldc-by-Cn with Bn = (K, A->m or A->n) based on the configuration of side, transA and transB.
[in]ldcThe leading dimension of the matrix C. ldc >= (A->m, A->n or K) based on the configuration of side, transA, and transB

side | transA | transB | B | C |

Left | NoTrans | NoTrans | A->n by K | A->m by K | Left | NoTrans | [Conj]Trans | K by A->n | A->m by K | Left | [Conj]Trans | NoTrans | A->m by K | A->n by K | Left | [Conj]Trans | [Conj]Trans | K by A->m | A->n by K | Right | NoTrans | NoTrans | K by A->m | K by A->n | Right | NoTrans | [Conj]Trans | A->m by K | K by A->n | Right | [Conj]Trans | NoTrans | K by A->n | K by A->m | Right | [Conj]Trans | [Conj]Trans | A->n by K | K by A->m |

Return values
SPM_SUCCESSif the y vector has been computed successfully,
SPM_ERR_BADPARAMETERotherwise.

Definition at line 1111 of file z_spm_matrixvector.c.

References LAPACKE_zlascl_work, spmatrix_s::mtxtype, spmatrix_s::nexp, SPM_ERR_BADPARAMETER, SPM_ERR_INTERNAL, spm_get_distribution(), SPM_SUCCESS, SpmDistByColumn, SpmDistByRow, SpmGeneral, SpmLeft, SpmNoTrans, z_spmm_build_Btmp(), z_spmm_build_Ctmp(), and z_spmReduceRHS().

Referenced by spmMatMat(), z_spmCheckAxb(), and z_spmGenRHS().