Previous Next Contents Generated Index Doc Set Home



Product of a Symmetric Matrix in Banded Storage and a Vector

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

Calling Sequence

CALL DSBMV 
(UPLO, N, NDIAG, DALPHA, ZA, LDA, ZX, INCX, DBETA, ZY, 
INCY)
CALL SSBMV 
(UPLO, N, NDIAG, SALPHA, CA, LDA, CX, INCX, SBETA, CY, 
INCY)






void dsbmv 
(char uplo, int n, int ndiag, double dalpha, double 
*da, int lda, double *dx, int incx, double dbeta, 
double *dy, int incy)
void ssbmv 
(char uplo, int n, int ndiag, float salpha, float *sa, 
int lda, 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.

NDIAG

Bandwidth of a symmetric matrix in banded storage with NDIAG superdiagonals and NDIAG subdiagonals. N-1 NDIAG 0 but if
N = 0 then NDIAG = 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 NDIAG + 1.

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           LDA, N, NDIAG
      PARAMETER        (N = 5)
      PARAMETER        (NDIAG = 1)
      PARAMETER        (LDA = NDIAG + 1)
C
      INTEGER           I, J
      DOUBLE PRECISION  A(LDA,N), ALPHA, BETA, X(N), Y(N)
C
      EXTERNAL DSBMV
C
C     Initialize the array A to store in symmetric banded 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                 1        1
C            2  3  4              2        1
C       A =     4  5  6       x = 3    y = 1
C                  6  7  8        4        1
C                     8  9        5        1
C
      DATA A /   8D8, 1.0D0, 2.0D0, 3.0D0, 4.0D0, 5.0D0, 6.0D0,
     $         7.0D0, 8.0D0, 9.0D0 /
      DATA X / 1.0D0, 2.0D0, 3.0D0, 4.0D0, 5.0D0 /
      DATA Y / 1.0D0, 1.0D0, 1.0D0, 1.0D0, 1.0D0 /
C
      PRINT 1000
      PRINT 1010, A(2,1), A(1,2), 0.0D0, 0.0D0, 0.0D0
      PRINT 1010, A(1,2), A(2,2), A(1,3), 0.0D0, 0.0D0
      PRINT 1010, 0.0D0, A(1,3), A(2,3), A(1,4), 0.0D0
      PRINT 1010, 0.0D0, 0.0D0, A(1,4), A(2,4), A(1,5)
      PRINT 1010, 0.0D0, 0.0D0, 0.0D0, A(1,5), A(2,5)
      PRINT 1020
      DO 20, I = 1, LDA
        PRINT 1010, (A(I,J), J = 1, N)
   20 CONTINUE
      PRINT 1030
      PRINT 1040, (X(I), Y(I), I = 1, N)
      ALPHA = 2.0D0
      BETA = 3.0D0
      CALL DSBMV ('UPPER TRIANGULAR A', N, NDIAG, ALPHA, A, LDA,
     $            X, 1, BETA, Y, 1)
      PRINT 1050
      PRINT 1060, (Y(I), I = 1, N)
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (1X, 5(2X, F6.1))
 1020 FORMAT (/1X, 'A in banded form: (* in unused fields)')
 1030 FORMAT (/7X, 'x', 8X, 'y')
 1040 FORMAT (3X, F6.1, 3X, F6.1)
 1050 FORMAT (/1X, 'Ax + y:')
 1060 FORMAT (1X, 3X, F6.1)
C
      END
 


Sample Output

 
 A in full form:
      1.0     2.0     0.0     0.0     0.0
      2.0     3.0     4.0     0.0     0.0
      0.0     4.0     5.0     6.0     0.0
      0.0     0.0     6.0     7.0     8.0
      0.0     0.0     0.0     8.0     9.0



 A in banded form: (* in unused fields)
   ******     2.0     4.0     6.0     8.0
      1.0     3.0     5.0     7.0     9.0



       x        y
      1.0      1.0
      2.0      1.0
      3.0      1.0
      4.0      1.0
      5.0      1.0



 Ax + y:
      13.0
      43.0
      97.0
     175.0
     157.0






Previous Next Contents Generated Index Doc Set Home