Previous Next Contents Generated Index Doc Set Home



Product of a Hermitian Matrix in Banded Storage and a Vector

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

Calling Sequence

CALL ZHBMV 
(UPLO, N, NDIAG, ZALPHA, ZA, LDA, ZX, INCX, ZBETA, ZY, 
INCY)
CALL CHBMV 
(UPLO, N, NDIAG, CALPHA, CA, LDA, CX, INCX, CBETA, CY, 
INCY)






void zhbmv 
(char uplo, int n, int ndiag, doublecomplex *zalpha, 
doublecomplex *za, int lda, doublecomplex *zx, int 
incx, doublecomplex *zbeta, doublecomplex *zy, int 
incy)
void chbmv 
(char uplo, int n, int ndiag, complex *calpha, complex 
*ca, int lda, complex *cx, int incx, complex *cbeta, 
complex *cy, 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 Hermitian 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
      REAL       RZERO
      COMPLEX    ZERO
      INTEGER    LDA, N, NDIAG
      PARAMETER (LDA = 3)
      PARAMETER (N = 4)
      PARAMETER (NDIAG = 2)
      PARAMETER (RZERO = 0.0E0)
      PARAMETER (ZERO = (0.0E0,0.0E0))
C
      INTEGER    I, J
      COMPLEX    A(LDA,N), ALPHA, BETA, X(N), Y(N)
C
      EXTERNAL   CHBMV
      INTRINSIC  CMPLX, CONJG, REAL
C
C     Initialize the array A to store in Hermitian banded form the
C     matrix A with two diagonals shown below.  Initialize the
C     arrays X and Y to store the vectors x and y shown below.
C
C           1+0i  2+1i  3+2i              1+4i        1+1i
C     A =   2-1i  4+0i  5+3i  6+4i    x = 2+3i    y = 1+2i
C           3-2i  5-3i  7+0i  8+5i        3+2i        1+3i
C                 6-4i  8-5i  9+0i        4+1i        1+4i
C
      DATA A /(8E8,8E8), (8E8,8E8), (1.0,8E8),
     $        (8E8,8E8), (2.0,1.0), (4.0,8E8),
     $        (3.0,2.0), (5.0,3.0), (7.0,8E8),
     $        (6.0,4.0), (8.0,5.0), (9.0,8E8) /
C
      DO 10, I = 1, N
        X(I) = CMPLX (REAL (I), REAL (5-I))
        Y(I) = CMPLX (1.0, REAL (I))
   10 CONTINUE
      ALPHA = CMPLX (1.0,0.0)
      BETA = CMPLX (1.0, 0.0)
      PRINT 1000
      PRINT 1010, REAL (A(3,1)), RZERO, A(2,2), A(1,3), ZERO
      PRINT 1010, CONJG (A(2,2)), REAL (A(3,2)), RZERO, A(2,3), 
     $   A(1,4)
      PRINT 1010, CONJG (A(1,3)), CONJG (A(2,3)),
     $   REAL (A(3,3)), RZERO, A(2,4)
      PRINT 1010, ZERO, CONJG (A(1,4)), CONJG (A(2,4)),
     $   REAL (A(3,4)), RZERO
      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)
      CALL CHBMV ('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, 'Array A in full form:')
 1010 FORMAT (1X, 4(2X, '(', F5.1, ',', F5.1, ')'))
 1020 FORMAT (/1X, 'Array A in banded form:  ',
     $        '(* in unused elements)')
 1030 FORMAT (/10X, 'x', 15X, 'y')
 1040 FORMAT (2(3X, '(', F5.1, ',', F5.1, ')'))
 1050 FORMAT (/1X, 'Ax + y:')
 1060 FORMAT (1X, 2X, '(', F5.1, ',', F5.1, ')')
C
      END
 

Sample Output

 
 Array A in full form:
   (  1.0,  0.0)  (  2.0,  1.0)  (  3.0,  2.0)  (  0.0,  0.0)
   (  2.0, -1.0)  (  4.0,  0.0)  (  5.0,  3.0)  (  6.0,  4.0)
   (  3.0, -2.0)  (  5.0, -3.0)  (  7.0,  0.0)  (  8.0,  5.0)
   (  0.0,  0.0)  (  6.0, -4.0)  (  8.0, -5.0)  (  9.0,  0.0)



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



          x               y
   (  1.0,  4.0)   (  1.0,  1.0)
   (  2.0,  3.0)   (  1.0,  2.0)
   (  3.0,  2.0)   (  1.0,  3.0)
   (  4.0,  1.0)   (  1.0,  4.0)



 Ax + y:
   (  8.0, 25.0)
   ( 44.0, 62.0)
   ( 79.0, 64.0)
   ( 95.0, 24.0)






Previous Next Contents Generated Index Doc Set Home