Previous Next Contents Generated Index Doc Set Home



Rank-2k Update of a Symmetric Matrix

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

Operation
TRANSA
Matrices A and B

'N' or 'n'

n x k

'T' or 't'

k x n

Calling Sequence

CALL DSYR2K 
(UPLO, TRANSA, N, K, DALPHA, DA, LDA, DB, LDB, DBETA, 
DC, LDC)
CALL SSYR2K 
(UPLO, TRANSA, N, K, SALPHA, SA, LDA, SB, LDB, SBETA, 
SC, LDC)
CALL ZSYR2K 
(UPLO, TRANSA, N, K, ZALPHA, ZA, LDA, ZB, LDB, ZBETA, 
ZC, LDC)
CALL CSYR2K 
(UPLO, TRANSA, N, K, CALPHA, CA, LDA, CB, LDB, CBETA, 
CC, LDC)






void dsyr2k 
(char uplo, char trans, int n, int k, double dalpha, 
double *da, int lda, double *db, int ldb, double dbeta, 
double *dc, int ldc)
void ssyr2k 
(char uplo, char trans, int n, int k, float salpha, 
float *sa, int lda, float *sb, int ldb, float sbeta, 
float *sc, int ldc)
void zsyr2k 
(char uplo, char trans, int n, int k, doublecomplex 
*zalpha, doublecomplex *za, int lda, doublecomplex 
*zb, int ldb, doublecomplex *zbeta, doublecomplex *zc, 
int ldc)
void csyr2k 
(char uplo, char trans, int n, int k, complex *calpha, 
complex *ca, int lda, complex *cb, int ldb, complex 
*cbeta, 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.

'T' or 't'

Use the 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.

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
      INTEGER           K, LDA, LDB, LDC, N
      PARAMETER        (K = 2)
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (LDB = N)
      PARAMETER        (LDC = N)
C
      DOUBLE PRECISION  A(LDA,K), ALPHA, B(LDB,K), BETA, C(LDC,N)
      INTEGER           I, J
C
      EXTERNAL          DSYR2K
      INTRINSIC         DBLE
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 symmetric matrix C shown below.
C
C          3  4         4  7         1  2  3
C     A =  5  6     B = 5  8     C = 2  4  5
C          7  8         6  9         3  5  6
C
      DATA A / 1.0D0, 1.0D0, 1.0D0, 2.0D0, 2.0D0, 2.0D0 /
      DATA B / 1.0D0, 2.0D0, 1.0D0, 2.0D0, 1.0D0, 2.0D0 /
      DATA C / 1.0D2, 1.0D2, 1.0D2, 8D8, 1.0D2, 1.0D2, 8D8, 8D8,
     $         1.0D2 /
C
      ALPHA = 1.0D0
      BETA = 1.0D0
      PRINT 1000
      DO 100, I = 1, N
        PRINT 1010, (C(I,J), J = 1, I), (C(J,I), J = I + 1, N)
  100 CONTINUE
      PRINT 1020
      PRINT 1010, ((C(I,J), J = 1, N), I = 1, N)
      PRINT 1030
      DO 110, I = 1, N
        PRINT 1010, (A(I,J), J = 1, K)
  110 CONTINUE
      PRINT 1040
      DO 120, I = 1, N
        PRINT 1010, (B(I,J), J = 1, K)
  120 CONTINUE
      CALL DSYR2K ('LOWER TRIANGULAR C', 'NOT TRANSPOSED C', N, K,
     $             ALPHA, A, LDA, B, LDB, BETA, C, LDC)
      PRINT 1050
      DO 130, I = 1, N
        PRINT 1010, (C(I,J), J = 1, I), (C(J,I), J = I + 1, N)
  130 CONTINUE
C
 1000 FORMAT (1X, 'C in full form:')
 1010 FORMAT (3(2X, F6.1))
 1020 FORMAT (/1X, 'C in symmetric form:  (* in unused elements)')
 1030 FORMAT (/1X, 'A:')
 1040 FORMAT (/1X, 'B:')
 1050 FORMAT (/1X, 'AB'' + BA'' + C:')
C
      END
 

Sample Output

 
 C in full form:
   100.0   100.0   100.0
   100.0   100.0   100.0
   100.0   100.0   100.0



 C in symmetric form:  (* in unused elements)
   100.0  ******  ******
   100.0   100.0  ******
   100.0   100.0   100.0



 A:
     1.0     2.0
     1.0     2.0
     1.0     2.0



 B:
     1.0     2.0
     2.0     1.0
     1.0     2.0



 AB' + BA' + C:
   110.0   109.0   110.0
   109.0   108.0   109.0
   110.0   109.0   110.0






Previous Next Contents Generated Index Doc Set Home