Rate This Document
Findability
Accuracy
Completeness
Readability

kml_csparse_?csrsymv

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

x and y are vectors, and A is a symmetric upper or lower triangle matrix stored in the CSR format (3-array variation) with zero-based indexing.

Interface Definition

C interface:

kml_sparse_status_t kml_csparse_scsrsymv(const kml_sparse_fill_mode_t uplo, 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_dcsrsymv(const kml_sparse_fill_mode_t uplo, 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_ccsrsymv(const kml_sparse_fill_mode_t uplo, 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_zcsrsymv(const kml_sparse_fill_mode_t uplo, 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_SCSRSYMV(UPLO, M, A, IA, JA, X, Y);

RES = KML_CSPARSE_DCSRSYMV(UPLO, M, A, IA, JA, X, Y);

RES = KML_CSPARSE_CCSRSYMV(UPLO, M, A, IA, JA, X, Y);

RES = KML_CSPARSE_ZCSRSYMV(UPLO, M, A, IA, JA, X, Y);

Parameters

Parameter

Type

Description

Input/Output

uplo

Enumeration type kml_sparse_fill_mode_t uplo

Indicates whether the upper triangle or lower triangle of matrix A is used.

  • U: upper triangle
  • L: lower triangle

Input

m

Integer

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

Input

a

  • For c_scsrsymv, val is a single-precision floating-point array.
  • For c_dcsrsymv, val is a double-precision floating-point array.
  • For c_ccsrsymv, val is a single-precision complex number array.
  • For c_zcsrsymv, 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_scsrsymv, x is a single-precision floating-point array.
  • For c_dcsrsymv, x is a double-precision floating-point array.
  • For c_ccsrsymv, x is a single-precision complex number array.
  • For c_zcsrsymv, x is a double-precision complex number array.

Vector x

Input

y

  • For c_scsrsymv, y is a single-precision floating-point array.
  • For c_dcsrsymv, y is a double-precision floating-point array.
  • For c_ccsrsymv, y is a single-precision complex number array.
  • For c_zcsrsymv, 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_fill_mode_t uplo = KML_SPARSE_FILL_MODE_LOWER; 
    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_scsrsymv(uplo, m, a, ia, ja, x, y); 
 
    /* 
     *  Output Y: 
     *     31.000000     0.000000    16.000000     9.000000 
     * 
     */

Fortran interface:

    INTEGER(C_INT) :: UPLO = KML_SPARSE_FILL_MODE_LOWER 
    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_SCSRSYMV(UPLO, M, A, IA, JA, X, Y) 
    ! 
    !  OUTPUT Y: 
    !     31.000000     0.000000    16.000000     9.000000 
    ! 
    !