Previous Next Contents Generated Index Doc Set Home



Rank-2 Update to a Hermitian Matrix

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

Calling Sequence

CALL ZHER2 
(UPLO, N, ZALPHA, ZX, INCX, ZY, INCY, ZA, LDA)
CALL CHER2 
(UPLO, N, CALPHA, CX, INCX, CY, INCY, CA, LDA)






void zher2 
(char uplo, int n, doublecomplex *zalpha, doublecomplex 
*zx, int incx, doublecomplex *zy, int incy, 
doublecomplex *za, int lda)
void cher2 
(char uplo, int n, complex *calpha, complex *cx, int 
incx, complex *cy, int incy, complex *ca, int lda)

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.

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.

xY

Y and INCY describe a vector of length N. Y contains an input 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.

xA

Two-dimensional array.

On entry, the input matrix.

On exit, the result matrix.

LDA

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

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      REAL       RZERO
      INTEGER    LDA, N
      PARAMETER (N = 3)
      PARAMETER (LDA = N)
      PARAMETER (RZERO = 0.0E0)
C
      COMPLEX    A(LDA,N), X(N), Y(N)
      INTEGER    I, J
C
      EXTERNAL   CHER2
      INTRINSIC  CONJG, REAL
C
C     Initialize the array A to store in symmetric form the
C     Hermitian matrix A shown below.  Initialize the arrays
C     X and Y to store the vectors x and y shown below.
C
C          1+0i  2+3i  5+6i        1-1i        4-4i
C     A =  2-3i  4+0i  7+8i    x = 2-2i    y = 4-4i
C          5-6i  7-8i  9+0i        3-3i        4-4i
C
      DATA A / (1.0,8E8), (8E8,8E8), (8E8,8E8),
     $         (2.0,3.0), (4.0,8E8), (8E8,8E8),
     $         (5.0,6.0), (7.0,8.0), (9.0,8E8) /
      DATA X / (1.0,-1.0), (2.0,-2.0), (3.0,-3.0) /
      DATA Y / (4.0,-4.0), (4.0,-4.0), (4.0,-4.0) /
C
      PRINT 1000
      DO 100, I = 1, N
        PRINT 1010, (A(J,I), J = 1, I - 1), REAL(A(I,I)), RZERO,
     $     (CONJG(A(I,J)), J = I + 1, N)
  100 CONTINUE
      PRINT 1020
      DO 110, I = 1, N
        PRINT 1010, (A(I,J), J = 1, N)
  110 CONTINUE
      PRINT 1030
      DO 120, I = 1, N
        PRINT 1040, X(I), Y(I)
  120 CONTINUE
      CALL CHER2 ('UPPER TRIANGULAR A', 3, 1.0D0, X, 1, Y, 1, 
     $             A, 3)
      PRINT 1050
      DO 130, I = 1, N
        PRINT 1010, (A(J,I), J = 1, I - 1), REAL(A(I,I)), RZERO,
     $     (CONJG(A(I,J)), J = I + 1, N)
  130 CONTINUE
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (1X, 3(2X, '(', F5.1, ',', F5.1, ')'))
 1020 FORMAT (/1X, 'A in Hermitian form:  (* in unused elements)')
 1030 FORMAT (/10X, 'x ', 13X, 'y')
 1040 FORMAT (1X, 2(2X, '(', F5.1, ',', F5.1, ')'))
 1050 FORMAT (/1X, 'A + xy'' + yx''')
C
      END
 

Sample Output

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



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



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



 A + xy' + yx'
   ( 31.0,  0.0)  ( 47.0, -3.0)  ( 65.0, -6.0)
   ( 47.0,  3.0)  ( 64.0,  0.0)  ( 82.0, -8.0)
   ( 65.0,  6.0)  ( 82.0,  8.0)  ( 99.0,  0.0)






Previous Next Contents Generated Index Doc Set Home