IBM Books

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

SGEMV, DGEMV, CGEMV, ZGEMV, SGEMX, DGEMX, SGEMTX, and DGEMTX--Matrix-Vector Product for a General Matrix, Its Transpose, or Its Conjugate Transpose

SGEMV and DGEMV compute the matrix-vector product for either a real general matrix or its transpose, using the scalars alpha and beta, vectors x and y, and matrix A or its transpose:

y <--beta y+alpha Ax

y <-- betay+alpha ATx

CGEMV and ZGEMV compute the matrix-vector product for either a complex general matrix, its transpose, or its conjugate transpose, using the scalars alpha and beta, vectors x and y, and matrix A, its transpose, or its conjugate transpose:

y <-- betay+alpha Ax
y <-- betay+alpha ATx
y <-- betay+alpha AHx

SGEMX and DGEMX compute the matrix-vector product for a real general matrix, using the scalar alpha, vectors x and y, and matrix A:

y <--y+ alphaAx

SGEMTX and DGEMTX compute the matrix-vector product for the transpose of a real general matrix, using the scalar alpha, vectors x and y, and the transpose of matrix A:

y <-- y+ alphaATx

Table 62. Data Types

alpha, beta, x, y, A Subprogram
Short-precision real SGEMV, SGEMX, and SGEMTX
Long-precision real DGEMV, DGEMX, and DGEMTX
Short-precision complex CGEMV
Long-precision complex ZGEMV
Note:
SGEMV and DGEMV are Level 2 BLAS subroutines. It is suggested that these subroutines be used instead of SGEMX, DGEMX, SGEMTX, and DGEMTX, which are provided only for compatibility with earlier releases of ESSL.

Syntax

Fortran CALL SGEMV | DGEMV | CGEMV | ZGEMV (transa, m, n, alpha, a, lda, x, incx, beta, y, incy)

CALL SGEMX | DGEMX | SGEMTX | DGEMTX ( m, n, alpha, a, lda, x, incx, y, incy)

C and C++ sgemv | dgemv | cgemv | zgemv (transa, m, n, alpha, a, lda, x, incx, beta, y, incy);

sgemx | dgemx | sgemtx | dgemtx ( m, n, alpha, a, lda, x, incx, y, incy);

PL/I CALL SGEMV | DGEMV | CGEMV | ZGEMV (transa, m, n, alpha, a, lda, x, incx, beta, y, incy);

CALL SGEMX | DGEMX | SGEMTX | DGEMTX ( m, n, alpha, a, lda, x, incx, y, incy);

On Entry

transa
indicates the form of matrix A to use in the computation, where:

If transa = 'N', A is used in the computation.

If transa = 'T', AT is used in the computation.

If transa = 'C', AH is used in the computation.

Specified as: a single character. It must be 'N', 'T', or 'C'.

m
is the number of rows in matrix A, and:

For SGEMV, DGEMV, CGEMV, and ZGEMV:

If transa = 'N', it is the length of vector y.
If transa = 'T' or 'C', it is the length of vector x.

For SGEMX and DGEMX, it is the length of vector y.

For SGEMTX and DGEMTX, it is the length of vector x.

Specified as: a fullword integer; 0 <= m <= lda.

n
is the number of columns in matrix A, and:

For SGEMV, DGEMV, CGEMV, and ZGEMV:

If transa = 'N', it is the length of vector x.
If transa = 'T' or 'C', it is the length of vector y.

For SGEMX and DGEMX, it is the length of vector x.

For SGEMTX and DGEMTX, it is the length of vector y.

Specified as: a fullword integer; n >= 0.

alpha
is the scaling constant alpha. Specified as: a number of the data type indicated in Table 62.

a
is the m by n matrix A, where:

For SGEMV, DGEMV, CGEMV, and ZGEMV:

If transa = 'N', A is used in the computation.
If transa = 'T', AT is used in the computation.
If transa = 'C', AH is used in the computation.

For SGEMX and DGEMX, A is used in the computation.

For SGEMTX and DGEMTX, AT is used in the computation.

Note:
No data should be moved to form AT or AH; that is, the matrix A should always be stored in its untransposed form.

Specified as: an lda by (at least) n array, containing numbers of the data type indicated in Table 62.

lda
is the leading dimension of the array specified for a. Specified as: a fullword integer; lda > 0 and lda >= m.

x
is the vector x, where:

For SGEMV, DGEMV, CGEMV, and ZGEMV:

If transa = 'N', it has length n.
If transa = 'T' or 'C', it has length m.

For SGEMX and DGEMX, it has length n.

For SGEMTX and DGEMTX, it has length m.

Specified as: a one-dimensional array, containing numbers of the data type indicated in Table 62, where:

For SGEMV, DGEMV, CGEMV, and ZGEMV:

If transa = 'N', it must have at least 1+(n-1)|incx| elements.
If transa = 'T' or 'C', it must have at least 1+(m-1)|incx| elements.

For SGEMX and DGEMX, it must have at least 1+(n-1)|incx| elements.

For SGEMTX and DGEMTX, it must have at least 1+(m-1)|incx| elements.

incx
is the stride for vector x. Specified as: a fullword integer; It can have any value.

beta
is the scaling constant beta. Specified as: a number of the data type indicated in Table 62.

y
is the vector y, where:

For SGEMV, DGEMV, CGEMV, and ZGEMV:

If transa = 'N', it has length m.
If transa = 'T' or 'C', it has length n.

For SGEMX and DGEMX, it has length m.

For SGEMTX and DGEMTX, it has length n.

Specified as: a one-dimensional array, containing numbers of the data type indicated in Table 62, where:

For SGEMV, DGEMV, CGEMV, and ZGEMV:

If transa = 'N', it must have at least 1+(m-1)|incy| elements.
If transa = 'T' or 'C', it must have at least 1+(n-1)|incy| elements.

For SGEMX and DGEMX, it must have at least 1+(m-1)|incy| elements.

For SGEMTX and DGEMTX, it must have at least 1+(n-1)|incy| elements.

incy
is the stride for vector y. Specified as: a fullword integer; incy > 0 or incy < 0.

On Return

y
is the vector y, containing the result of the computation, where:

For SGEMV, DGEMV, CGEMV, and ZGEMV:

If transa = 'N', it has length m.
If transa = 'T' or 'C', it has length n.

For SGEMX and DGEMX, it has length m.

For SGEMTX and DGEMTX, it has length n.

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

Notes
  1. For SGEMV and DGEMV, if you specify 'C' for the transa argument, it is interpreted as though you specified 'T'.
  2. The SGEMV, DGEMV, CGEMV, and ZGEMV subroutines accept lowercase letters for the transa argument.
  3. In the SGEMV, DGEMV, CGEMV, and ZGEMV subroutines, incx = 0 is valid; however, the Level 2 BLAS standard considers incx = 0 to be invalid. See references [34] and [35].
  4. Vector y must have no common elements with matrix A or vector x; otherwise, results are unpredictable. See Concepts.

Function

The possible computations that can be performed by these subroutines are described in the following sections. Varying implementation techniques are used for this computation to improve performance. As a result, accuracy of the computational result may vary for different computations.

For SGEMV, CGEMV, SGEMX, and SGEMTX, intermediate results are accumulated in long precision. Occasionally, for performance reasons, these intermediate results are stored.

See references [34], [35], [38], [46], and [79]. No computation is performed if m or n is 0 or if alpha is zero and beta is one.

General Matrix

For SGEMV, DGEMV, CGEMV, and ZGEMV, the matrix-vector product for a general matrix:

y<--betay+alphaAx

is expressed as follows:



Matrix-Vector Product Graphic

For SGEMX and DGEMX, the matrix-vector product for a real general matrix:

y<--y+alphaAx

is expressed as follows:



Matrix-Vector Product Graphic

In these expressions:

y is a vector of length m.
alpha is a scalar.
beta is a scalar.
A is an m by n matrix.
x is a vector of length n.

Transpose of a General Matrix

For SGEMV, DGEMV, CGEMV and ZGEMV, the matrix-vector product for the transpose of a general matrix:

y <-- betay+alphaATx

is expressed as follows:



Matrix-Vector Product Graphic

For SGEMTX and DGEMTX, the matrix-vector product for the transpose of a real general matrix:

y <-- y+alphaATx

is expressed as follows:



Matrix-Vector Product Graphic

In these expressions:

y is a vector of length n.
alpha is a scalar.
beta is a scalar.
AT is the transpose of matrix A, where A is an m by n matrix.
x is a vector of length m.

Conjugate Transpose of a General Matrix

For CGEMV and ZGEMV, the matrix-vector product for the conjugate transpose of a general matrix:

y <-- betay+alphaAHx

is expressed as follows:



Matrix-Vector Product Graphic

where:

y is a vector of length n.
alpha is a scalar.
beta is a scalar.
AH is the conjugate transpose of matrix A, where A is an m by n matrix.
x is a vector of length m.

Error Conditions

Resource Errors

Unable to allocate internal work area (for SGEMV, DGEMV, CGEMV, and ZGEMV).

Computational Errors

None

Input-Argument Errors
  1. transa <> 'N', 'T', or 'C'
  2. m < 0
  3. m > lda
  4. n < 0
  5. lda <= 0
  6. incy = 0

Example 1

This example shows the computation for TRANSA equal to 'N', where the real general matrix A is used in the computation. Because lda is 10 and n is 3, array A must be declared as A(E1:E2,F1:F2), where E2-E1+1=10 and F2-F1+1 >= 3. In this example, array A is declared as A(1:10,0:2).

Call Statement and Input
           TRANSA M   N  ALPHA    A      LDA  X  INCX BETA   Y  INCY
             |    |   |    |      |       |   |   |     |    |   |
CALL SGEMV( 'N' , 4 , 3 , 1.0 , A(1,0) , 10 , X , 1  , 1.0 , Y , 2  )
    *               *
    | 1.0  2.0  3.0 |
    | 2.0  2.0  4.0 |
    | 3.0  2.0  2.0 |
    | 4.0  2.0  1.0 |
A = |  .    .    .  |
    |  .    .    .  |
    |  .    .    .  |
    |  .    .    .  |
    |  .    .    .  |
    |  .    .    .  |
    *               *
X        =  (3.0, 2.0, 1.0)
Y        =  (4.0, . , 5.0, . , 2.0, . , 3.0)

Output
Y        =  (14.0, . , 19.0, . , 17.0, . , 20.0)

Example 2

This example shows the computation for TRANSA equal to 'T', where the transpose of the real general matrix A is used in the computation. Array A must follow the same rules as given in Example 1. In this example, array A is declared as A(-1:8,1:3).

Call Statement and Input
           TRANSA M   N  ALPHA     A     LDA   X  INCX  BETA  Y  INCY
             |    |   |    |       |      |    |   |     |    |   |
CALL SGEMV( 'T' , 4 , 3 , 1.0 , A(-1,1) , 10 , X , 1  , 2.0 , Y , 2  )

A =(same as input A in Example 1)
X = (3.0, 2.0, 1.0, 4.0)
Y = (1.0, . , 2.0, . , 3.0)

Output
Y        =  (28.0, . , 24.0, . , 29.0)

Example 3

This example shows the computation for TRANSA equal to 'N', where the complex general matrix A is used in the computation.

Call Statement and Input
           TRANSA M   N   ALPHA   A   LDA  X  INCX  BETA   Y  INCY
             |    |   |     |     |    |   |   |     |     |   |
CALL CGEMV( 'N' , 5 , 3 , ALPHA , A , 10 , X , 1  , BETA , Y , 1  )
 
ALPHA    =  (1.0, 0.0)
    *                                    *
    | (1.0, 2.0)  (3.0, 5.0)  (2.0, 0.0) |
    | (2.0, 3.0)  (7.0, 9.0)  (4.0, 8.0) |
    | (7.0, 4.0)  (1.0, 4.0)  (6.0, 0.0) |
    | (8.0, 2.0)  (2.0, 5.0)  (8.0, 0.0) |
A = | (9.0, 1.0)  (3.0, 6.0)  (1.0, 0.0) |
    |     .           .           .      |
    |     .           .           .      |
    |     .           .           .      |
    |     .           .           .      |
    |     .           .           .      |
    *                                    *
X        =  ((1.0, 2.0), (4.0, 0.0), (1.0, 1.0))
BETA     =  (1.0, 0.0)
Y        =  ((1.0, 2.0), (4.0, 0.0), (1.0, -1.0), (3.0, 4.0),
             (2.0, 0.0))

Output
Y        =  ((12.0, 28.0), (24.0, 55.0), (10.0, 39.0), (23.0, 50.0),
             (22.0, 44.0))

Example 4

This example shows the computation for TRANSA equal to 'T', where the transpose of complex general matrix A is used in the computation. Because beta is zero, the result of the computation is alphaATx

Call Statement and Input
           TRANSA M   N   ALPHA   A   LDA  X  INCX  BETA   Y  INCY
             |    |   |     |     |    |   |   |     |     |   |
CALL CGEMV( 'T' , 5 , 3 , ALPHA , A , 10 , X , 1  , BETA , Y , 1  )

ALPHA = (1.0, 0.0)
A =(same as input A in Example 3)
X = ((1.0, 2.0), (4.0, 0.0), (1.0, 1.0), (3.0, 4.0),
(2.0, 0.0))
BETA = (0.0, 0.0)
Y =(not relevant)

Output
Y        =  ((42.0, 67.0), (10.0, 87.0), (50.0, 74.0))

Example 5

This example shows the computation for TRANSA equal to 'C', where the conjugate transpose of the complex general matrix A is used in the computation.

Call Statement and Input
           TRANSA M   N   ALPHA   A   LDA  X  INCX  BETA   Y  INCY
             |    |   |     |     |    |   |   |     |     |   |
CALL CGEMV( 'C' , 5 , 3 , ALPHA , A , 10 , X , 1  , BETA , Y , 1  )

ALPHA = (-1.0, 0.0)
A =(same as input A in Example 3)
X = ((1.0, 2.0), (4.0, 0.0), (1.0, 1.0), (3.0, 4.0),
(2.0, 0.0))
BETA = (1.0, 0.0)
Y = ((1.0, 2.0), (4.0, 0.0), (1.0, -1.0))

Output
Y        =  ((-73.0, -13.0), (-74.0, 57.0), (-49.0, -11.0))

Example 6

This example shows a matrix, A, contained in a larger array, A. The strides of vectors x and y are positive. Because lda is 10 and n is 3, array A must be declared as A(E1:E2,F1:F2), where E2-E1+1=10 and F2-F1+1 >= 3. For this example, array A is declared as A(1:10,0:2).

Call Statement and Input
            M   N  ALPHA    A     LDA   X  INCX  Y  INCY
            |   |    |      |      |    |   |    |   |
CALL SGEMX( 4 , 3 , 1.0 , A(1,0) , 10 , X , 1  , Y , 2  )
    *               *
    | 1.0  2.0  3.0 |
    | 2.0  2.0  4.0 |
    | 3.0  2.0  2.0 |
    | 4.0  2.0  1.0 |
A = |  .    .    .  |
    |  .    .    .  |
    |  .    .    .  |
    |  .    .    .  |
    |  .    .    .  |
    |  .    .    .  |
    *               *
X        =  (3.0, 2.0, 1.0)
Y        =  (4.0, . , 5.0, . , 2.0, . , 3.0)

Output
Y        =  (14.0, . , 19.0, . , 17.0, . , 20.0)

Example 7

This example shows a matrix, A, contained in a larger array, A. The strides of vectors x and y are of opposite sign. For y, which has negative stride, processing begins at element Y(7), which is 4.0. Array A must follow the same rules as given in Example 6. For this example, array A is declared as A(-1:8,1:3).

Call Statement and Input
            M   N  ALPHA     A     LDA   X  INCX  Y   INCY
            |   |    |       |      |    |   |    |    |
CALL SGEMX( 4 , 3 , 1.0 , A(-1,1) , 10 , X , 1  , Y , -2  )

A =(same as input A in Example 6)
X = (3.0, 2.0, 1.0)
Y = (3.0, . , 2.0, . , 5.0, . , 4.0)

Output
Y        =  (20.0, . , 17.0, . , 19.0, . , 14.0)

Example 8

This example shows a matrix, A, contained in a larger array, A, and the first element of the matrix is not the first element of the array. Array A must follow the same rules as given in Example 6. For this example, array A is declared as A(1:10,1:3).

Call Statement and Input
            M   N  ALPHA    A     LDA   X  INCX  Y  INCY
            |   |    |      |      |    |   |    |   |
CALL SGEMX( 4 , 3 , 1.0 , A(5,1) , 10 , X , 1  , Y , 1  )
    *               *
    | .    .    .   |
    | .    .    .   |
    | .    .    .   |
    | .    .    .   |
A = | 1.0  2.0  3.0 |
    | 2.0  2.0  4.0 |
    | 3.0  2.0  2.0 |
    | 4.0  2.0  1.0 |
    |  .    .    .  |
    |  .    .    .  |
    *               *
X        =  (3.0, 2.0, 1.0)
Y        =  (4.0, 5.0, 2.0, 3.0)

Output
Y        =  (14.0, 19.0, 17.0, 20.0)

Example 9

This example shows a matrix, A, and an array, A, having the same number of rows. For this case, m and lda are equal. Because lda is 4 and n is 3, array A must be declared as A(E1:E2,F1:F2), where E2-E1+1=4 and F2-F1+1 >= 3. For this example, array A is declared as A(1:4,0:2).

Call Statement and Input
            M   N  ALPHA    A     LDA  X  INCX  Y  INCY
            |   |    |      |      |   |   |    |   |
CALL SGEMX( 4 , 3 , 1.0 , A(1,0) , 4 , X , 1  , Y , 1  )
 
    *               *
    | 1.0  2.0  3.0 |
A = | 2.0  2.0  4.0 |
    | 3.0  2.0  2.0 |
    | 4.0  2.0  1.0 |
    *               *
 
X        =  (3.0, 2.0, 1.0)
Y        =  (4.0, 5.0, 2.0, 3.0)

Output
Y        =  (14.0, 19.0, 17.0, 20.0)

Example 10

This example shows a matrix, A, and an array, A, having the same number of rows. For this case, m and lda are equal. Because lda is 4 and n is 3, array A must be declared as A(E1:E2,F1:F2), where E2-E1+1=4 and F2-F1+1 >= 3. For this example, array A is declared as A(1:4,0:2).

Call Statement and Input
             M   N  ALPHA    A     LDA  X  INCX  Y  INCY
             |   |    |      |      |   |   |    |   |
CALL SGEMTX( 4 , 3 , 1.0 , A(1,0) , 4 , X , 1  , Y , 1  )
 
    *               *
    | 1.0  2.0  3.0 |
A = | 2.0  2.0  4.0 |
    | 3.0  2.0  2.0 |
    | 4.0  2.0  1.0 |
    *               *
 
X        =  (3.0, 2.0, 1.0, 4.0)
Y        =  (1.0, 2.0, 3.0)

Output
Y        =  (27.0, 22.0, 26.0)

Example 11

This example shows a computation in which alpha is greater than 1. Array A must follow the same rules as given in Example 10. For this example, array A is declared as A(-1:2,1:3).

Call Statement and Input
             M   N  ALPHA     A     LDA  X  INCX  Y  INCY
             |   |    |       |      |   |   |    |   |
CALL SGEMTX( 4 , 3 , 2.0 , A(-1,1) , 4 , X , 1  , Y , 1  )

A =(same as input A in Example 10)
X = (3.0, 2.0, 1.0, 4.0)
Y = (1.0, 2.0, 3.0)

Output
Y        =  (53.0, 42.0, 49.0)


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