Rate This Document
Findability
Accuracy
Completeness
Readability

kml_sparse_?axpyi

That is, y = a * x + y. a is a scaling coefficient, x is a sparse vector, and y is a dense vector.

Interface Definition

C interface:

kml_sparse_status_t kml_sparse_saxpyi(const KML_INT nz, const float a, const float *x, const KML_INT *indx, float *y);

kml_sparse_status_t kml_sparse_daxpyi(const KML_INT nz, const double a, const double *x, const KML_INT *indx, double *y);

kml_sparse_status_t kml_sparse_caxpyi(const KML_INT nz, const KML_Complex8 a, const KML_Complex8 *x, const KML_INT *indx, KML_Complex8 *y);

kml_sparse_status_t kml_sparse_zaxpyi(const KML_INT nz, const KML_Complex16 a, const KML_Complex16 *x, const KML_INT *indx, KML_Complex16 *y);

Fortran interface:

RES = KML_SPARSE_SAXPYI(NZ, A, X, INDX, Y);

RES = KML_SPARSE_DAXPYI(NZ, A, X, INDX, Y);

RES = KML_SPARSE_CAXPYI(NZ, A, X, INDX, Y);

RES = KML_SPARSE_ZAXPYI(NZ, A, X, INDX, Y);

Parameters

Parameter

Type

Description

Input/Output

nz

Integer

Number of elements in the x and indx arrays.

Input

a

  • For saxpyi, a is of single-precision floating-point type.
  • For daxpyi, a is of double-precision floating-point type.
  • For caxpyi, a is of single-precision complex type.
  • For zaxpyi, a is of double-precision complex type.

Scalar a.

Input

x

  • For saxpyi, x is a single-precision floating-point array.
  • For daxpyi, x is a double-precision floating-point array.
  • For caxpyi, x is a single-precision complex array.
  • For zaxpyi, x is a double-precision complex array.

Array x for storing non-zero elements. The size is at least nz.

Input

indx

Integer array

indx[i] indicates the serial number of the i-th element in the x array in the dense vector. The size is at least nz.

Input

y

  • For saxpyi, y is a single-precision floating-point array.
  • For daxpyi, y is a double-precision floating-point array.
  • For caxpyi, y is a single-precision complex array.
  • For zaxpyi, y is a double-precision complex array.

Array y. The size is at least max(indx[i]).

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_INT nz = 2; 
    float alpha = 1; 
    KML_INT indx[2] = {1, 2}; 
    float x[2] = {1, 3}; 
    float y[4] = {-1, 1, 5, 3}; 
    kml_sparse_status_t status = kml_sparse_saxpyi(nz, alpha, x, indx, y); 
 
    /* 
     *  Output Y: 
     *     -1.000000     2.000000     8.000000     3.000000 
     * 
     */

Fortran interface:

    INTEGER(C_INT) :: NZ = 2 
    REAL(C_FLOAT) :: ALPHA = 1 
    INTEGER(C_INT) :: INDX(2) 
    REAL(C_FLOAT) :: X(2), Y(4) 
    DATA INDX/1, 2/ 
    DATA X/1, 3/ 
    DATA Y/-1, 1, 5, 3/ 
    INTEGER :: STATUS  
    STATUS = KML_SPARSE_SAXPYI(NZ, ALPHA, X, INDX, Y) 
    ! 
    !  OUTPUT Y: 
    !     -1.000000     2.000000     8.000000     3.000000 
    ! 
    !