Rate This Document
Findability
Accuracy
Completeness
Readability

kml_sparse_?cscsm

Solve a system of triangular matrix equations. One of the matrices is a sparse matrix in the CSC format. The operation is defined as follows:

  • A * y = alpha * x
  • AT * y = alpha * x
  • AH * y = alpha * x

x and y are m*n dense matrices, and A is an m*m sparse matrix stored in the CSC format. The non-zero elements of a given column in matrix A must be stored in the same order as they are displayed in the column (from top to bottom).

Table 1 describes the relationship between layout and sparse matrix indexing.

Table 1 Relationship between layout and sparse matrix indexing

Sparse matrix indexing

Dense matrix layout

KML_SPARSE_INDEX_BASE_ZERO

KML_SPARSE_LAYOUT_ROW_MAJOR

KML_SPARSE_INDEX_BASE_ONE

KML_SPARSE_LAYOUT_COLUMN_MAJOR

Interface Definition

C interface:

kml_sparse_status_t kml_sparse_scscsm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, 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 KML_INT ldx, float *y , const KML_INT ldy);

kml_sparse_status_t kml_sparse_dcscsm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, 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 KML_INT ldx, double *y , const KML_INT ldy);

kml_sparse_status_t kml_sparse_ccscsm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, 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_INT ldx, KML_Complex8 *y, const KML_INT ldy);

kml_sparse_status_t kml_sparse_zcscsm(const kml_sparse_operation_t opt, const KML_INT m, const KML_INT n, 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_INT ldx, KML_Complex16 *y , const KML_INT ldy);

Parameters

Parameter

Type

Description

Input/Output

opt

Enumeration type kml_sparse_operation_t

Indicates whether to transpose.

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

Input

m

Integer

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

Input

n

Integer

Number of columns in matrix x. The value range is [1, MAX_KML_INT].

Input

alpha

  • For scscsm, alpha is of the single-precision floating-point type.
  • For dcscsm, alpha is of the double-precision floating-point type.
  • For ccscsm, alpha is a single-precision complex number.
  • For zcscsm, alpha is a double-precision complex number.

Scalar alpha

Input

matdescra

Char pointer

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

Input

val

  • For scscsm, val is a single-precision floating-point array.
  • For dcscsm, val is a double-precision floating-point array.
  • For ccscsm, val is a single-precision complex number array.
  • For zcscsm, val is a double-precision complex number array.

Array values storing non-zero elements of matrix A in the CSC format. The length is pntre[m-1] - pntrb[0].

Input

indx

Integer array

Array columns in the CSC format, which contains the row indices for non-zero elements 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 scscsm, x is a single-precision floating-point array.
  • For dcscsm, x is a double-precision floating-point array.
  • For ccscsm, x is a single-precision complex number array.
  • For zcscsm, x is a double-precision complex number array.

Array value of matrix x

Input

ldx

Integer array

  • Size of the leading dimension of matrix x for one-based indexing
  • Size of the second dimension of matrix x for zero-based indexing

Input

y

  • For scscsm, y is a single-precision floating-point array.
  • For dcscsm, y is a double-precision floating-point array.
  • For ccscsm, y is a single-precision complex number array.
  • For zcscsm, y is a double-precision complex number array.

Array value of matrix y

Input/Output

ldy

Integer array

  • Size of the leading dimension of matrix y for one-based indexing
  • Size of the second dimension of matrix y for zero-based indexing

Input

Table 2 describes the parameter constraints on matrix x.

Table 2 Parameter constraints on matrix x

opt

Matrix Scale

Data Layout

Value Range

op(A) = A, AT, or AH

m x n

Row-major order

m * ldbMAX_KML_INT

op(A) = A, AT, or AH

m x n

Column-major order

ldb * nMAX_KML_INT

Table 3 describes the parameter constraints on matrix y.

Table 3 Parameter constraints on matrix y

opt

Matrix Scale

Data Layout

Value Range

op(A) = A, AT, or AH

m x n

Row-major order

m * ldcMAX_KML_INT

op(A) = A, AT, or AH

m x n

Column-major order

ldc * nMAX_KML_INT

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; 
    KML_INT m = 4; 
    KML_INT n = 2; 
    float alpha = 1.0; 
    char *matdescra = "TLNC"; // Triangular matrix with zero-based indexing
    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[8] = {6, 7, 6, -3, 4, 6, 6, 8}; 
    float y[8] = {0, 0, 0, 0, 0, 0, 0, 0}; 
    KML_INT ldx = 2; 
    KML_INT ldy = 2; 
    kml_sparse_status_t status = kml_sparse_scscsm(opt, m, n, alpha, matdescra, val, indx, pntrb, pntre, x, ldx, y, ldy); 
    /* 
     *  Output Y: 
     *      3.000000  3.500000   
-0.600000  -2.700000   
0.125000  0.312500   
0.803571  1.008929 
     * 
     * */