IBM Books

Engineering and Scientific Subroutine Library for AIX Version 3 Release 3: Guide and Reference

SAXPYI, DAXPYI, CAXPYI, and ZAXPYI--Multiply a Sparse Vector X in Compressed-Vector Storage Mode by a Scalar, Add to a Sparse Vector Y in Full-Vector Storage Mode, and Store in the Vector Y

These subprograms multiply sparse vector x, stored in compressed-vector storage mode, by scalar alpha, add it to sparse vector y, stored in full-vector storage mode, and store the result in vector y.

Table 60. Data Types

alpha, x, y Subprogram
Short-precision real SAXPYI
Long-precision real DAXPYI
Short-precision complex CAXPYI
Long-precision complex ZAXPYI

Syntax

Fortran CALL SAXPYI | DAXPYI | CAXPYI | ZAXPYI (nz, alpha, x, indx, y)
C and C++ saxpyi | daxpyi | caxpyi | zaxpyi (nz, alpha, x, indx, y);
PL/I CALL SAXPYI | DAXPYI | CAXPYI | ZAXPYI (nz, alpha, x, indx, y);

On Entry

nz
is the number of elements in sparse vector x, stored in compressed-vector storage mode. Specified as: a fullword integer; nz >= 0.

alpha
is the scalar alpha. Specified as: a number of the data type indicated in Table 60.

x
is the sparse vector x, containing nz elements, stored in compressed-vector storage mode in an array, referred to as X. Specified as: a one-dimensional array of (at least) length nz, containing numbers of the data type indicated in Table 60.

indx
is the array, referred to as INDX, containing the nz indices that indicate the positions of the elements of the sparse vector x when in full-vector storage mode. They also indicate the positions of the elements in vector y that are used in the computation.

Specified as: a one-dimensional array of (at least) length nz, containing fullword integers.

y
is the sparse vector y, stored in full-vector storage mode, of (at least) length max(INDX(i)) for i = 1, nz. Specified as: a one-dimensional array of (at least) length max(INDX(i)) for i = 1, nz, containing numbers of the data type indicated in Table 60.

On Return

y
is the sparse vector y, stored in full-vector storage mode, of (at least) length max(INDX(i)) for i = 1, nz containing the results of the computation, stored at positions indicated by the indices array INDX.

Returned as: a one-dimensional array, containing numbers of the data type indicated in Table 60.

Notes
  1. Each value specified in array INDX must be unique; otherwise, results are unpredictable.
  2. Vectors x and y must have no common elements; otherwise, results are unpredictable. See Concepts.
  3. For a description of how sparse vectors are stored, see Sparse Vector.

Function

The computation is expressed as follows:

yINDX(i) <-- yINDX(i) + alphaxi    for i = 1, nz

where:

x is a sparse vector, stored in compressed-vector storage mode.
INDX is the indices array for sparse vector x.
y is a sparse vector, stored in full-vector storage mode.

See reference [29]. If alpha or nz is zero, no computation is performed. For SAXPYI and CAXPYI, intermediate results are accumulated in long-precision.

Error Conditions

Computational Errors

None

Input-Argument Errors

nz < 0

Example 1

This example shows how to use SAXPYI to perform a computation using a sparse vector x of length 5, where the elements of array INDX are in ascending order.

Call Statement and Input
             NZ ALPHA  X   INDX   Y
             |    |    |    |     |
CALL SAXPYI( 5 , 2.0 , X , INDX , Y )
 
X        =  (1.0, 2.0, 3.0, 4.0, 5.0)
INDX     =  (1, 3, 4, 7, 10)
Y        =  (1.0, 5.0, 4.0, 3.0, 6.0, 10.0, -2.0, 8.0, 9.0, 0.0)

Output
Y        =  (3.0, 5.0, 8.0, 9.0, 6.0, 10.0, 6.0, 8.0, 9.0, 10.0)

Example 2

This example shows how to use SAXPYI to perform a computation using a sparse vector x of length 5, where the elements of array INDX are in random order.

Call Statement and Input
             NZ ALPHA  X   INDX   Y
             |    |    |    |     |
CALL SAXPYI( 5 , 2.0 , X , INDX , Y )
 
X        =  (1.0, 2.0, 3.0, 4.0, 5.0)
INDX     =  (4, 3, 1, 10, 7)
Y        =  (1.0, 5.0, 4.0, 3.0, 6.0, 10.0, -2.0, 8.0, 9.0, 0.0)

Output
Y        =  (7.0, 5.0, 8.0, 5.0, 6.0, 10.0, 8.0, 8.0, 9.0, 8.0)

Example 3

This example shows how to use CAXPYI to perform a computation using a sparse vector x of length 3, where the elements of array INDX are in random order.

Call Statement and Input
             NZ  ALPHA   X   INDX   Y
             |     |     |    |     |
CALL CAXPYI( 3 , ALPHA , X , INDX , Y )
 
ALPHA    =  (2.0, 3.0)
X        =  ((1.0, 2.0), (3.0, 4.0), (5.0, 6.0))
INDX     =  (4, 1, 3)
Y        =  ((6.0, 5.0), (-2.0, 3.0), (15.0, 4.0), (9.0, 0.0))

Output
Y        =  ((0.0, 22.0), (-2.0, 3.0), (7.0, 31.0), (5.0, 7.0))


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]