Rate This Document
Findability
Accuracy
Completeness
Readability

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.

  • If opt = KML_SPARSE_OPERATION_NON_TRANSPOSE, then y = alpha * A * x + beta * y.
  • If opt = KML_SPARSE_OPERATION_TRANSPOSE, then y = alpha * AT * x + beta * y.
  • If opt = KML_SPARSE_OPERATION_CONJUGATE_TRANSPOSE, then y = alpha * AH * x + beta * y.

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

  • For scscmv, alpha is of the single-precision floating-point type.
  • For dcscmv, alpha is of the double-precision floating-point type.
  • For ccscmv, alpha is a single-precision complex number.
  • For zcscmv, alpha is a double-precision complex number.

Coefficient

Input

matdescra

Char pointer

Matrix operation attribute. For details, see the description of matdescra.

Input

val

  • For scscmv, val is a single-precision floating-point array.
  • For dcscmv, val is a double-precision floating-point array.
  • For ccscmv, val is a single-precision complex number array.
  • For zcscmv, val is a double-precision complex number array.

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

  • For scscmv, x is a single-precision floating-point array.
  • For dcscmv, x is a double-precision floating-point array.
  • For ccscmv, x is a single-precision complex number array.
  • For zcscmv, x is a double-precision complex number array.

Vector x

Input

beta

  • For scscmv, beta is of the single-precision floating-point type.
  • For dcscmv, beta is of the double-precision floating-point type.
  • For ccscmv, beta is a single-precision complex number.
  • For zcscmv, beta is a double-precision complex number.

Coefficient

Input

y

  • For scscmv, y is a single-precision floating-point array.
  • For dcscmv, y is a double-precision floating-point array.
  • For ccscmv, y is a single-precision complex number array.
  • For zcscmv, y is a double-precision complex number array.

Vector y.

This parameter is output after update.

Input/Output

The function does not verify the integrity of parameters. Ensure that the elements in pntrb and pntre do not exceed the maximum index value of the input matrix.

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 
     * 
     * */