Previous Next Contents Generated Index Doc Set Home



Rank-1 Update to a Hermitian Matrix

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

Calling Sequence

CALL ZHER 
(UPLO, N, DALPHA, ZX, INCX, ZA, LDA)
CALL CHER 
(UPLO, N, SALPHA, CX, INCX, CA, LDA)






void zher
(char uplo, int n, double dalpha, doublecomplex *zx, 
int incx, doublecomplex *za, int lda)
void cher
(char uplo, int n, float salpha, complex *cx, int incx, 
complex *ca, int lda)


Note - The type of the scalar xALPHA is real.

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.

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
      COMPLEX    ONE
      INTEGER    LDA, N
      PARAMETER (N = 3)
      PARAMETER (LDA = N)
      PARAMETER (ONE = (1.0E0,0.0E0))
      PARAMETER (RZERO = 0.0E0)
C
      COMPLEX    A(LDA,N), ONE, X(N)
      INTEGER    I, J
C
      EXTERNAL   CHER
      INTRINSIC  CONJG, REAL
C
C     Initialize the array A to store in Hermitian form the matrix
C     A shown below.  Initialize the array X to store the vector X
C     shown below.
C
C         1+0i  2+2i  3+3i        1-1i
C     A = 2-2i  2+0i  3+3i    x = 2-2i
C         3-3i  3-3i  3+0i        3-3i
C
      DATA A / (1.0,8E8), (8E8,8E8), (8E8,8E8),
     $         (2.0,2.0), (2.0,8E8), (8E8,8E8),
     $         (3.0,3.0), (3.0,3.0), (3.0,8E8) /
      DATA X / (1.0,-1.0), (2.0,-2.0), (3.0,-3.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)
  120 CONTINUE
      CALL CHER ('UPPER TRIANGULAR A', N, ONE, X, 1, A, LDA)
      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
      PRINT 1060
      DO 140, I = 1, N
        PRINT 1010, (A(I,J), J = 1, N)
  140 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 (/1X, 'x:')
 1040 FORMAT (3X, '(', F5.1, ',', F5.1, ')')
 1050 FORMAT (/1X, 'A + xx'' in full form:')
 1060 FORMAT (/1X, 'A + xx'' in Hermitian form: ',
     $        '(* in unused elements)')
C
      END
 

Sample Output

 
 A in full form:
   (  1.0,  0.0)  (  2.0, -2.0)  (  3.0, -3.0)
   (  2.0,  2.0)  (  2.0,  0.0)  (  3.0, -3.0)
   (  3.0,  3.0)  (  3.0,  3.0)  (  3.0,  0.0)



 A in Hermitian form:  (* in unused elements)
   (  1.0,*****)  (  2.0,  2.0)  (  3.0,  3.0)
   (*****,*****)  (  2.0,*****)  (  3.0,  3.0)
   (*****,*****)  (*****,*****)  (  3.0,*****)



 x:
   (  1.0, -1.0)
   (  2.0, -2.0)
   (  3.0, -3.0)



 A + xx' in full form:
   (  3.0,  0.0)  (  6.0, -2.0)  (  9.0, -3.0)
   (  6.0,  2.0)  ( 10.0,  0.0)  ( 15.0, -3.0)
   (  9.0,  3.0)  ( 15.0,  3.0)  ( 21.0,  0.0)



 A + xx' in Hermitian form: (* in unused elements)
   (  3.0,  0.0)  (  6.0,  2.0)  (  9.0,  3.0)
   (*****,*****)  ( 10.0,  0.0)  ( 15.0,  3.0)
   (*****,*****)  (*****,*****)  ( 21.0,  0.0)






Previous Next Contents Generated Index Doc Set Home