Previous Next Contents Generated Index Doc Set Home



Rank-k Update of a Hermitian Matrix

The subroutines described in this section compute one of the following results for a general matrix A and a Hermitian matrix C:

Operation
TRANSA
Matrix A

'N' or 'n'

n x k

'C' or 'c'

k x n

Calling Sequence

CALL ZHERK 
(UPLO, TRANSA, N, K, DALPHA, ZA, LDA, DBETA, ZC, LDC)
CALL CHERK 
(UPLO, TRANSA, N, K, SALPHA, CA, LDA, SBETA, CC, LDC)






void zherk 
(char uplo, char trans, int n, int k, double dalpha, 
doublecomplex *za, int lda, double dbeta, 
doublecomplex *zc, int ldc)
void cherk 
(char uplo, char trans, int n, int k, float salpha, 
complex *ca, int lda, float sbeta, complex *cc, int 
ldc)

Arguments

UPLO

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

'L' or 'l'

Only lower triangle of array will be referenced.

'U' or 'u'

Only upper triangle of array will be referenced.

TRANSA

Indicates how to use the matrix stored in the array A. The legal values for TRANSA are listed below. Any value not listed below is illegal.

'N' or 'n'

Use the matrix as it is stored in A.

'C' or 'c'

Use the conjugate transpose of the matrix stored in A.

N, K

Indicate the size of matrix A as shown in the table above. N, K 0.

xALPHA

Scalar that scales the input value of the matrix stored in A. Note that xALPHA is real.

xA

Two-dimensional array in which one of the input matrices is stored.

LDA

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

If TRANSA = 'N' or 'n', LDA max (1,N).

xBETA

Scalar that scales the input value of the matrix stored in C. Note that xBETA is real.

xC

Two-dimensional array.

On entry, an input matrix.

On exit, the result matrix.

LDC

Leading dimension of the array C as specified in the dimension or type statement. LDC max (1,N)

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      REAL       RZERO
      INTEGER    K, LDA, LDC, N
      PARAMETER (K = 2)
      PARAMETER (N = 3)
      PARAMETER (LDA = N)
      PARAMETER (LDC = N)
      PARAMETER (RZERO = 0.0E0)
C
      COMPLEX    A(LDA,K), ALPHA, BETA, C(LDC,N)
      INTEGER    I, J
C
      EXTERNAL   CHERK
      INTRINSIC  CMPLX, CONJG, REAL
C
C     Initialize the array A to store the matrix A shown below.
C     Initialize the array C to store in symmetric form the
C     Hermitian matrix C shown below.
C
C         1+1i  1+2i        1+0i  2-3i  4-5i
C     A = 2+1i  2+2i    C = 2+3i  6+0i  7-8i
C         3+1i  3+2i        4+5i  7+8i  9+0i
C
      DATA A / (1.0,1.0), (2.0,1.0), (3.0,1.0),
     $         (1.0,2.0), (2.0,2.0), (3.0,2.0) /
      DATA C / (1.0,8E8), (2.0,3.0), (4.0,5.0),
     $         (8E8,8E8), (6.0,8E8), (7.0,8.0),
     $         (8E8,8E8), (8E8,8E8), (9.0,8E8) /
C
      ALPHA = CMPLX (1.0E0,0.0E0)
      BETA = CMPLX (5.0E0,0.0E0)
      PRINT 1000
      DO 100, I = 1, N
        PRINT 1010, (A(I,J), J = 1, K)
  100 CONTINUE
      PRINT 1020
      DO 110, I = 1, N
        PRINT 1010, (C(I,J), J = 1, I - 1), REAL (C(I,I)), RZERO,
     $              (CONJG (C(J,I)), J = I + 1, N)
  110 CONTINUE
      PRINT 1030
      PRINT 1010, ((C(I,J), J = 1, 3), I = 1, 3)
      CALL CHERK ('LOWER TRIANGULAR C', 'NOT TRANSPOSED C', N, K,
     $            ALPHA, A, LDA, BETA, C, LDC)
      PRINT 1040
      DO 120, I = 1, N
        PRINT 1010, (C(I,J), J = 1, I), (CONJG (C(J,I)), 
     $     J = I + 1, N)
  120 CONTINUE
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (3(3X, : '(', F5.1, ',', F5.1, ')'))
 1020 FORMAT (/1X, 'C in full form:')
 1030 FORMAT (/1X, 'C in Hermitian form:  (* in unused elements)')
 1040 FORMAT (/1X, 'AA'' + C:')
C
      END
 

Sample Output

 
 A:
   (  1.0,  1.0)   (  1.0,  2.0)
   (  2.0,  1.0)   (  2.0,  2.0)
   (  3.0,  1.0)   (  3.0,  2.0)



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



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



 AA' + C:
   ( 12.0,  0.0)   ( 19.0,-12.0)   ( 31.0,-19.0)
   ( 19.0, 12.0)   ( 43.0,  0.0)   ( 52.0,-37.0)
   ( 31.0, 19.0)   ( 52.0, 37.0)   ( 68.0,  0.0)






Previous Next Contents Generated Index Doc Set Home