Previous Next Contents Generated Index Doc Set Home



Product of a Symmetric Matrix in Packed Storage and a Vector

The subroutines described in this section compute the following result for a symmetric matrix A in packed storage and vectors x and y:

Calling Sequence

CALL DSPMV 
(UPLO, N, DALPHA, DA, DX, INCX, DBETA, DY, INCY)
CALL SSPMV 
(UPLO, N, SALPHA, SA, SX, INCX, SBETA, SY, INCY)






void dspmv 
(char uplo, int n, double dalpha, double *da, double 
*dx, int incx, double dbeta, double *dy, int incy)
void sspmv 
(char uplo, int n, float salpha, float *sa, float *sx, 
int incx, float sbeta, float *sy, int incy)

Arguments

UPLO

Indicates whether the values in a matrix reside in the upper or lower triangle of the array in which the matrix is stored. The legal values for UPLO are listed below. Any value not listed below is illegal.

'L' or 'l'

Only the lower triangle of the array will be referenced.

'U' or 'u'

Only the upper triangle of the array will be referenced.

N

Size of a matrix with N rows and N columns. N 0.

xALPHA

Scalar that scales the input value of the matrix A.

xA

One-dimensional array that contains the input matrix. The matrix is in packed storage; the array must have at least enough elements to store the non-redundant elements of the matrix.

xX

X and INCX describe a vector of length N. 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 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           LENGTA, N
      PARAMETER        (N = 5)
      PARAMETER        (LENGTA = (N * N + N) / 2)
C
      DOUBLE PRECISION  ALPHA, AP(LENGTA), BETA, X(N), Y(N)
      INTEGER           I
C
      EXTERNAL DSPMV
C
C     Initialize the array AP to store in packed symmetric form
C     the matrix A shown below.  Initialize the arrays X and Y
C     to store the vectors x and y shown below.
C
C          1   2   3   4   5        1        1000
C          2   6   7   8   9        2        2000
C     A =  3   7  10  11  12    x = 3    y = 3000
C          4   8  11  13  14        4        4000
C          5   9  12  14  15        5        5000
C
      DATA AP / 1.0D0, 2.0D0, 3.0D0, 4.0D0, 5.0D0,
     $          6.0D0, 7.0D0, 8.0D0, 9.0D0,
     $          1.0D1, 1.1D1, 1.2D1,
     $          1.3D1, 1.4D1,
     $          1.5D1 /
      DATA X / 1.0D0, 2.0D0, 3.0D0, 4.0D0, 5.0D0 /
      DATA Y / 1.0D3, 2.0D3, 3.0D3, 4.0D3, 5.0D3 /
C
      PRINT 1000
      PRINT 1010, AP(1), AP(2), AP(3),  AP(4),  AP(5)
      PRINT 1010, AP(2), AP(6), AP(7),  AP(8),  AP(9)
      PRINT 1010, AP(3), AP(7), AP(8),  AP(9),  AP(10)
      PRINT 1010, AP(4), AP(8), AP(9),  AP(10), AP(11)
      PRINT 1010, AP(5), AP(9), AP(10), AP(11), AP(12)
      PRINT 1020
      PRINT 1030, (X(I), Y(I), I = 1, N)
      ALPHA = 1.0D0
      BETA = 0.0D0
      CALL DSPMV ('LOWER TRIANGULAR A', N, ALPHA, AP, X, 1,
     $            BETA, Y, 1)
      PRINT 1040
      PRINT 1050, (Y(I), I = 1, N)
C
 1000 FORMAT (1X, 'Array A in full form:')
 1010 FORMAT (1X, 5(2X, F6 .1))
 1020 FORMAT (/1X, '   x       y')
 1030 FORMAT (1X, F6.1, 2X, F6.1)
 1040 FORMAT (/1X, 'Ax + y:')
 1050 FORMAT (1X, F6.1)
C
      END
 

Sample Output

 
 Array A in full form:
      1.0     2.0     3.0     4.0     5.0
      2.0     6.0     7.0     8.0     9.0
      3.0     7.0     8.0     9.0    10.0
      4.0     8.0     9.0    10.0    11.0
      5.0     9.0    10.0    11.0    12.0



    x       y
    1.0  1000.0
    2.0  2000.0
    3.0  3000.0
    4.0  4000.0
    5.0  5000.0



 Ax + y:
   55.0
  112.0
  151.0
  175.0
  190.0






Previous Next Contents Generated Index Doc Set Home