kml_sparse_?cscmv
Computes the product of a matrix and a vector. The matrix is a sparse matrix stored in the CSC format.
- y = alpha * A * x + beta * y
- y = alpha * AT * x + beta * y
- y = alpha * AH * x + beta * y
alpha and beta are scaling coefficients, x and y are vectors, and A is a sparse vector in the CSC format.
Interface Definition
C interface:
kml_sparse_status_t kml_sparse_scscmv(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT k, const float alpha, const char *matdescra, const float *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const float *x, const float beta, float *y);
kml_sparse_status_t kml_sparse_dcscmv(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT k, const double alpha, const char *matdescra, const double *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const double *x, const double beta, double *y);
kml_sparse_status_t kml_sparse_ccscmv(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT k, const KML_Complex8 alpha, const char *matdescra, const KML_Complex8 *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const KML_Complex8 *x, const KML_Complex8 beta, KML_Complex8 *y);
kml_sparse_status_t kml_sparse_zcscmv(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT k, const KML_Complex16 alpha, const char *matdescra, const KML_Complex16 *val, const KML_INT *indx, const KML_INT *pntrb, const KML_INT *pntre, const KML_Complex16 *x, const KML_Complex16 beta, KML_Complex16 *y);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
opt |
Enumeration type kml_sparse_operation_t |
Operation on matrix A.
|
Input |
m |
Integer |
Number of rows in matrix A. The value range is [1, MAX_KML_INT]. |
Input |
k |
Integer |
Number of columns in matrix A. The value range is [1, MAX_KML_INT]. |
Input |
alpha |
|
Coefficient |
Input |
matdescra |
Char pointer |
Matrix operation attribute. For details, see the description of matdescra. |
Input |
val |
|
Non-zero elements in matrix A |
Input |
indx |
Integer array |
indx[i] indicates the row number of the ith element of the val array in matrix A. |
Input |
pntrb |
Integer array |
Array of length m, containing column indices of matrix A. pntrb[i] - pntrb[0] indicates the subscript of the first non-zero element in column i in the val and indx arrays. |
Input |
pntre |
Integer array |
Array of length m, containing column indices of matrix A. pntre[i] - pntrb[0]-1 indicates the subscript of the last non-zero element in column i in the val and indx arrays. |
Input |
x |
|
Vector x |
Input |
beta |
|
Coefficient |
Input |
y |
|
Vector y. This parameter is output after update. |
Input/Output |
Return Value
Function execution status. The enumeration type is kml_sparse_status_t.
Dependencies
C: "kspblas.h"
Fortran: "kspblas.f03"
Examples
C interface:
kml_sparse_operation_t opt = KML_SPARSE_OPERATION_NON_TRANSPOSE;
char *matdescra = "G00C";
KML_INT m = 4;
KML_INT k = 4;
float alpha = 1.0;
float beta = 1.0;
float val[9] = {2, 3, 1, 5, 7, 8, 3, 6, 7};
KML_INT indx[9] = {0, 1, 2, 1, 1, 2, 3, 0, 3};
KML_INT pntrb[4] = {0, 3, 4, 7};
KML_INT pntre[4] = {3, 4, 7, 9};
float x[4] = {6, 6, 4, 6};
float y[4] = {1, 1, 6, 1};
kml_sparse_status_t status = kml_sparse_scscmv(opt, m, k, alpha, matdescra, val, indx, pntrb, pntre, x, beta, y);
/*
* Output Y:
* 49.000000 77.000000 44.000000 55.000000
*
* */