Previous Next Contents Generated Index Doc Set Home



Product of a General Matrix and a Vector

The subroutines described in this section compute one of the following results for a general matrix A and vectors x and y:



Calling Sequence

CALL DGEMV 
(TRANSA, M, N, DALPHA, DA, LDA, DX, INCX, DBETA, DY, 
INCY)
CALL SGEMV 
(TRANSA, M, N, SALPHA, SA, LDA, SX, INCX, SBETA, SY, 
INCY)
CALL ZGEMV 
(TRANSA, M, N, ZALPHA, ZA, LDA, ZX, INCX, ZBETA, ZY, 
INCY)
CALL CGEMV 
(TRANSA, M, N, CALPHA, CA, LDA, CX, INCX, CBETA, CY, 
INCY)






void dgemv 
(char trans, int m, int n, double dalpha, double *da, 
int lda, double *dx, int incx, double dbeta, double 
*dy, int incy)
void sgemv 
(char trans, int m, int n, float salpha, float *sa, int 
lda, float *sx, int incx, float sbeta, float *sy, int 
incy)
void zgemv 
(char trans, int m, int n, doublecomplex *zalpha, 
doublecomplex *za, int lda, doublecomplex *zx, int 
incx, doublecomplex *zbeta, doublecomplex *zy, int 
incy)
void cgemv 
(char trans, int m, int n, complex *calpha, complex 
*ca, int lda, complex *cx, int incx, complex *cbeta, 
complex *cy, int incy)

Arguments

TRANSA

Indicates how to use the matrix stored in the array argument. The legal values for TRANSA are listed below. Any value not listed below is illegal.

'N' or 'n'

Use the matrix as it is stored in the array.

'T' or 't'

Use the transpose of the matrix.

'C' or 'c'

Use the conjugate transpose of the matrix.

M

Number of rows in the matrix A. M 0.

N

Number of columns in the matrix A. N 0.

xALPHA

Scalar that scales the input value of the matrix A.

xA

Two-dimensional array that contains the input matrix.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA max(1,M).

xX

X and INCX describe a vector of length N if TRANSA = 'N' or 'n', otherwise of length M. X contains an input vector.

INCX

Scalar that contains the storage spacing between successive elements of the vector. INCX 0. If INCX = 1, then elements of the vector are contiguous in memory. INCX may take on values besides 1 to allow the programmer to extract from a matrix a vector that is not stored in contiguous memory locations.

If X is a one-dimensional array and INCX = -1 then the array will be accessed in reverse order.

If X is a two-dimensional array and INCX = LDA then the vector will be a row of the array.

If X is a two-dimensional array and INCX = LDA+1 then the vector will be a diagonal of the array.

xBETA

Scalar that scales the input value of the vector Y.

xY

Y and INCY describe a vector of length M if TRANSA = 'N' or 'n', otherwise of length N.

On entry, an input vector.

On exit, a result vector.

INCY

Scalar that contains the storage spacing between successive elements of the vector Y. INCY 0. If INCY = 1, then elements of the vector are contiguous in memory. INCY may take on values besides 1 to allow the programmer to extract from a matrix a vector that is not stored in contiguous memory locations.

If Y is a one-dimensional array and INCY = -1 then the array will be accessed in reverse order.

If Y is a two-dimensional array and INCY = LDA then the vector will be a row of the array.

If Y is a two-dimensional array and INCY = LDA+1 then the vector will be a diagonal of the array.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDROT, M, N
      PARAMETER        (M = 2)
      PARAMETER        (LDROT = M)
      PARAMETER        (N = 2)
C
      DOUBLE PRECISION  ALPHA, PI, ROT(LDROT,N), SCALE, THETA
      DOUBLE PRECISION  VEC1(N), VEC2(N)
      INTEGER           INCX, INCY, M, N
C
      EXTERNAL          DGEMV
      INTRINSIC         ATAN, COS, SIN
C
      PI = 4.0D0 * ATAN (1.0D0)
      THETA = PI / 2.0D0
C
C     Initialize the array ROT to contain the rotation matrix to
C     be applied to the vector stored in VEC1.
C
      ROT(1,1) = COS (THETA)
      ROT(2,1) = SIN (THETA)
      ROT(1,2) = -SIN (THETA)
      ROT(2,2) = COS (THETA)
      VEC1(1) = 3.0D0
      VEC1(2) = 4.0D0
      PRINT 1000
      PRINT 1010, VEC1
      SCALE = 5.0D-1
      INCX = 1
      ALPHA = 0.0D0
      INCY = 1
      CALL DGEMV ('NOT TRANSPOSED ROT', M, N, SCALE, ROT, LDROT,
     $            VEC1, INCX, ALPHA, VEC2, INCY)
      PRINT 1020
      PRINT 1010, VEC2
C
 1000 FORMAT (1X, 'Original vector:')
 1010 FORMAT (3X, F4.1)
 1020 FORMAT (/1X, 'Rotated vector:')
C
      END
 

Sample Output

 
 Original vector:
    3.0
    4.0



 Rotated vector:
   -2.0
    1.5






Previous Next Contents Generated Index Doc Set Home