Rate This Document
Findability
Accuracy
Completeness
Readability

kml_csparse_?csrgemv

Compute the product of a vector and a sparse matrix that is stored in the CSR format. The operation is defined as follows:

y = A * x, y = AT * x, or y = AH * x

x and y are vectors, and A is a sparse matrix in the CSR format (3-array variation) with zero-based indexing.

Interface Definition

C interface:

kml_sparse_status_t kml_csparse_scsrgemv(const kml_sparse_operation_t opt, const KML_INT m, const float *a, const KML_INT *ia, const KML_INT *ja, const float *x, float *y);

kml_sparse_status_t kml_csparse_dcsrgemv(const kml_sparse_operation_t opt, const KML_INT m, const double *a, const KML_INT *ia, const KML_INT *ja, const double *x, double *y);

kml_sparse_status_t kml_csparse_ccsrgemv(const kml_sparse_operation_t opt, const KML_INT m, const KML_Complex8 *a, const KML_INT *ia, const KML_INT *ja,

const KML_Complex8 *x, KML_Complex8 *y);

kml_sparse_status_t kml_csparse_zcsrgemv(const kml_sparse_operation_t opt, const KML_INT m, const KML_Complex16 *a ,const KML_INT *ia, const KML_INT *ja, const KML_Complex16 *x, KML_Complex16 *y);

Fortran interface:

RES = KML_CSPARSE_SCSRGEMV(OPT, M, A, IA, JA, X, Y);

RES = KML_CSPARSE_DCSRGEMV(OPT, M, A, IA, JA, X, Y);

RES = KML_CSPARSE_CCSRGEMV(OPT, M, A, IA, JA, X, Y);

RES = KML_CSPARSE_ZCSRGEMV(OPT, M, A, IA, JA, X, 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 .
  • If opt = KML_SPARSE_OPERATION_TRANSPOSE, then .
  • If opt = KML_SPARSE_OPERATION_CONJUGATE_TRANSPOSE, then .

Input

m

Integer

Number of rows and columns in matrix A. The value range is [1, MAX_KML_INT].

Input

a

  • For c_scsrgemv, val is a single-precision floating-point array.
  • For c_dcsrgemv, val is a double-precision floating-point array.
  • For c_ccsrgemv, val is a single-precision complex number array.
  • For c_zcsrgemv, val is a double-precision complex number array.

Non-zero elements in matrix A

Input

ia

Integer array

Vector whose length is m+1.

ia[i] indicates the index of the first non-zero element in the ith row of matrix A in the val array.

Input

ja

Integer array

ja[i] indicates the column number of the ith element of the val array in matrix A.

Input

x

  • For c_scsrgemv, x is a single-precision floating-point array.
  • For c_dcsrgemv, x is a double-precision floating-point array.
  • For c_ccsrgemv, x is a single-precision complex number array.
  • For c_zcsrgemv, x is a double-precision complex number array.

Vector x

Input

y

  • For c_scsrgemv, y is a single-precision floating-point array.
  • For c_dcsrgemv, y is a double-precision floating-point array.
  • For c_ccsrgemv, y is a single-precision complex number array.
  • For c_zcsrgemv, y is a double-precision complex number array.

Vector y, which is output after being updated.

Input/Output

The function does not verify the integrity of parameters. Ensure that the elements in ia and ja 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; 
    KML_INT m = 4; 
    float a[9] = {2, -3, 7, 1, -6, 8, -4, 5, 9}; 
    KML_INT ja[9] = {0, 1, 3, 2, 3, 0, 2, 3, 0}; 
    KML_INT ia[5] = {0, 3, 5, 8, 9}; 
    float x[4] = {1, 3, -2, 5}; 
    float y[4] = {-1, 1, 5, 3}; 
    kml_sparse_status_t status = kml_csparse_scsrgemv(opt, m, a, ia, ja, x, y); 
 
    /* 
     *  Output Y: 
     *     28.000000   -32.000000    41.000000     9.000000 
     *      
     */

Fortran interface:

  INTEGER(C_INT) :: OPT = KML_SPARSE_OPERATION_NON_TRANSPOSE 
    INTEGER(C_INT) :: M = 4 
    REAL(C_FLOAT) :: A(9), X(4), Y(4) 
    INTEGER(C_INT) :: JA(9), IA(5) 
    INTEGER(C_INT) :: STATUS 
    DATA A/2, -3, 7, 1, -6, 8, -4, 5, 9/ 
    DATA JA/0, 1, 3, 2, 3, 0, 2, 3, 0/   
    DATA IA/0, 3, 5, 8, 9/ 
    DATA X/1, 3, -2, 5/ 
    DATA Y/-1, 1, 5, 3/ 
    STATUS = KML_CSPARSE_SCSRGEMV(OPT, M, A, IA, JA, X, Y) 
    ! 
    !  OUTPUT Y: 
    !     28.000000   -32.000000    41.000000     9.000000 
    !