Previous Next Contents Generated Index Doc Set Home



Rank-k Update of a Symmetric Matrix

This subroutines described in this section compute the rank-k update to a symmetric (or Hermitian) matrix. SSYRK, DSYRK, and CSYRK are subprograms to compute the following functions of the general matrix A and the symmetric matrix C:

Operation
TRANSA
Matrix A

'N' or 'n'

n x k

'T' or 't'

k x n

Calling Sequence

CALL DSYRK 
(UPLO, TRANSA, N, K, DALPHA, DA, LDA, DBETA, DC, LDC)
CALL SSYRK 
(UPLO, TRANSA, N, K, SALPHA, SA, LDA, SBETA, SC, LDC)
CALL ZSYRK 
(UPLO, TRANSA, N, K, ZALPHA, ZA, LDA, ZBETA, ZC, LDC)
CALL CSYRK 
(UPLO, TRANSA, N, K, CALPHA, CA, LDA, CBETA, CC, LDC)






void dsyrk 
(char uplo, char trans, int n, int k, double dalpha, 
double *da, int lda, double dbeta, double *dc, int ldc)
void ssyrk 
(char uplo, char trans, int n, int k, float salpha, 
float *sa, int lda, float sbeta, float *sc, int ldc)
void zsyrk 
(char uplo, char trans, int n, int k, doublecomplex 
*zalpha, doublecomplex *za, int lda, doublecomplex 
*zbeta, doublecomplex *zc, int ldc)
void csyrk 
(char uplo, char trans, int n, int k, complex *calpha, 
complex *ca, int lda, 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 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.

'T' or 't'

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

xA

Two-dimensional array in which one of the input matrix 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.

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, LDC, N
      PARAMETER        (K = 2)
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (LDC = N)
C
      DOUBLE PRECISION  A(LDA,K), ALPHA, BETA, C(LDC,N)
      INTEGER           I, J
C
      EXTERNAL          DSYRK
      INTRINSIC         DBLE
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     symmetric matrix C shown below.
C
C          3  4        1  2  3
C     A =  5  6    C = 2  4  5
C          7  8        3  5  6
C
      DATA A / 3.0D0, 5.0D0, 7.0D0, 4.0D0, 6.0D0, 8.0D0 /
      DATA C / 1.0D0, 2.0D0, 3.0D0, 8D8, 4.0D0, 5.0D0, 8D8, 8D8,
     $         6.0D0 /
C
      ALPHA = 1.0D0
      BETA = 3.0D0
      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), (C(J,I), J = I + 1, N)
  110 CONTINUE
      PRINT 1030
      PRINT 1010, ((C(I,J), J = 1, N), I = 1, N)
      CALL DSYRK ('LOWER TRIANGULAR C', 'NOT TRANSPOSED C', N, K,
     $            ALPHA, A, LDA, BETA, C, LDC)
      PRINT 1040
      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, 'A:')
 1010 FORMAT (3(2X, F6.1))
 1020 FORMAT (/1X, 'C in full form:')
 1030 FORMAT (/1X, 'C in symmetric form: (* in unused elements)')
 1040 FORMAT (/1X, 'AA'' + C:')
C
      END
 

Sample Output

 
 A:
     3.0     4.0
     5.0     6.0
     7.0     8.0



 C in full form:
     1.0     2.0     3.0
     2.0     4.0     5.0
     3.0     5.0     6.0



 C in symmetric form: (* in unused elements)
     1.0  ******  ******
     2.0     4.0  ******
     3.0     5.0     6.0



 AA' + C:
    28.0    45.0    62.0
    45.0    73.0    98.0
    62.0    98.0   131.0






Previous Next Contents Generated Index Doc Set Home