Previous Next Contents Generated Index Doc Set Home



Rank-2k Update of a Hermitian Matrix

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

Operation
TRANSA
Matrices A and B

'N' or 'n'

n x k

'C' or 'c'

k x n

Calling Sequence

CALL ZHER2K 
(UPLO, TRANSA, N, K, ZALPHA, ZA, LDA, ZB, LDB, DBETA, 
ZC, LDC)
CALL CHER2K 
(UPLO, TRANSA, N, K, CALPHA, CA, LDA, CB, LDB, SBETA, 
CC, LDC)






void zher2k 
(char uplo, char trans, int n, int k, doublecomplex 
*zalpha, doublecomplex *za, int lda, doublecomplex 
*zb, int ldb, double dbeta, doublecomplex *zc, int ldc)
void cher2k 
(char uplo, char trans, int n, int k, complex *calpha, 
complex *ca, int lda, complex *cb, int ldb, 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. 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.

'C' or 'c'

Use the conjugate transpose of the matrix.

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.

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).

xB

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

LDB

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

If TRANSB = 'N' or 'n', LDB 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, LDB, LDC, N
      PARAMETER (K = 2)
      PARAMETER (N = 3)
      PARAMETER (LDA = N)
      PARAMETER (LDB = N)
      PARAMETER (LDC = N)
      PARAMETER (RZERO = 0.0E0)
C
      COMPLEX    A(LDA,K), ALPHA, B(LDB,K), BETA, C(LDC,N)
      INTEGER    I, J
C
      EXTERNAL   CHER2K
      INTRINSIC  CMPLX, CONJG, REAL
C
C     Initialize the arrays A and B to store the matrices A and B
C     shown below.  Initialize the array C to store in symmetric
C     form the Hermitian matrix C shown below.
C
C       1+1i  1+2i       2+1i  3+2i  4+3i        1+0i  2-3i  4-5i
C   A = 2+1i  2+2i   B = 3+1i  4+2i  5+3i   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 B / (2.0,1.0), (3.0,1.0), (4.0,1.0), (3.0,2.0),
     $         (4.0,2.0), (5.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 (0.0E0,3.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, (B(J,I), J = 1, K)
  110 CONTINUE
      PRINT 1030
      DO 120, I = 1, N
        PRINT 1010, (C(I,J), J = 1, I - 1), REAL (C(I,I)), RZERO,
     $              (CONJG (A(J,I)), J = I + 1, N)
  120 CONTINUE
      PRINT 1040
      DO 130, I = 1, N
        PRINT 1010, (C(I,J), J = 1, N)
  130 CONTINUE
      CALL CHER2K ('LOWER TRIANGULAR C', 'NOT TRANSPOSED C', N, K,
     $             ALPHA, A, LDA, B, LDB, BETA, C, LDC)
      PRINT 1050
      DO 140, I = 1, N
        PRINT 1010, (C(I,J), J = 1, I), (CONJG (C(J,I)), 
     $     J = I + 1, N)
  140 CONTINUE
      PRINT 1060
      DO 150, I = 1, N
        PRINT 1010, (C(I,J), J = 1, N)
  150 CONTINUE
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (3(3X, : '(', F5.1, ',', F5.1, ')'))
 1020 FORMAT (/1X, 'B:')
 1030 FORMAT (/1X, 'C in full form:')
 1040 FORMAT (/1X, 'C in Hermitian form:  (* in unused elements)')
 1050 FORMAT (/1X, 'AB'' + BA'' + C in full form:')
 1060 FORMAT (/1X, 'AB'' + BA'' + C in Hermitian form:')
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)



 B:
   (  2.0,  1.0)   (  3.0,  1.0)
   (  3.0,  2.0)   (  4.0,  2.0)
   (  1.0,*****)   (  2.0,  3.0)



 C in full form:
   (  1.0,  0.0)   (  2.0, -1.0)   (  3.0, -1.0)
   (  2.0,  3.0)   (  6.0,  0.0)   (  3.0, -2.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,*****)



 AB' + BA' + C in full form:
   ( 20.0,  0.0)   ( 27.0,  6.0)   ( 34.0, 12.0)
   ( 27.0, -6.0)   ( 38.0,  0.0)   ( 49.0,  6.0)
   ( 34.0,-12.0)   ( 49.0, -6.0)   ( 64.0,  0.0)



 AB' + BA' + C in Hermitian form:
   ( 20.0,  0.0)   (*****,*****)   (*****,*****)
   ( 27.0, -6.0)   ( 38.0,  0.0)   (*****,*****)
   ( 34.0,-12.0)   ( 49.0, -6.0)   ( 64.0,  0.0)






Previous Next Contents Generated Index Doc Set Home