# ?syr2k

Performs a rank-2k update of a symmetric matrix.

## Syntax

FORTRAN 77:

call ssyr2k(uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc )

call dsyr2k(uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc )

call csyr2k(uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc )

call zsyr2k(uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc )

Fortran 95:

call syr2k(a, b, c [,uplo][,trans] [,alpha][,beta])

## Description

The ?syr2k routines perform a rank-2k matrix-matrix operation using symmetric matrices. The operation is defined as
`C := alpha*A*B' + alpha*B*A' + beta*C,`

or
`C := alpha*a'*B + alpha*B'*A + beta*C,`

where:

alpha and beta are scalars,

C is an n-by-n symmetric matrix,

A and B are n-by-k matrices in the first case, and k-by-n matrices in the second case.

## Input Parameters

uplo

  CHARACTER*1. Specifies whether the upper or lower triangular part of the array c is used.

  If `uplo = 'U'` or 'u', then the upper triangular part of the array c is used.

  If `uplo = 'L'` or 'l', then the low triangular part of the array c is is used.

trans

  CHARACTER*1. Specifies the operation:

  if `trans = 'N'` or `'n'`, then `C := alpha*A*B'+alpha*B*A'+beta*C`;

  if `trans = 'T'` or `'t'`, then `C := alpha*A'*B +alpha*B'*A +beta*C`;

  if `trans = 'C'` or `'c'`, then `C := alpha*A'*B +alpha*B'*A +beta*C`.

n

  INTEGER. Specifies the order of the matrix C. The value of n must be at least zero.

k

  INTEGER. On entry with `trans = 'N'` or 'n', k specifies the number of columns of the matrices A and B, and on entry with `trans = 'T'` or 't' or 'C' or 'c', k specifies the number of rows of the matrices A and B. The value of k must be at least zero.

alpha

  REAL for ssyr2k

  DOUBLE PRECISION for dsyr2k

  COMPLEX for csyr2k

  DOUBLE COMPLEX for zsyr2k

  Specifies the scalar alpha.

a

  REAL for ssyr2k

  DOUBLE PRECISION for dsyr2k

  COMPLEX for csyr2k

  DOUBLE COMPLEX for zsyr2k

  Array, DIMENSION `(lda,ka)`, where ka is k when `trans = 'N'` or 'n', and is n otherwise. Before entry with `trans = 'N'` or 'n', the leading n-by-k part of the array a must contain the matrix A, otherwise the leading k-by-n part of the array a must contain the matrix A.

lda

  INTEGER. Specifies the first dimension of a as declared in the calling (sub)program. When `trans = 'N'` or 'n', then lda must be at least `max(1, n)`, otherwise lda must be at least `max(1, k)`.

b

  REAL for ssyr2k

  DOUBLE PRECISION for dsyr2k

  COMPLEX for csyr2k

  DOUBLE COMPLEX for zsyr2k

  Array, DIMENSION (ldb, kb) where kb is k when `trans = 'N'` or 'n' and is 'n' otherwise. Before entry with `trans = 'N'` or 'n', the leading n-by-k part of the array b must contain the matrix B, otherwise the leading k-by-n part of the array b must contain the matrix B.

ldb

  INTEGER. Specifies the first dimension of a as declared in the calling (sub)program. When `trans = 'N'` or 'n', then ldb must be at least `max(1, n)`, otherwise ldb must be at least `max(1, k)`.

beta

  REAL for ssyr2k

  DOUBLE PRECISION for dsyr2k

  COMPLEX for csyr2k

  DOUBLE COMPLEX for zsyr2k

  Specifies the scalar beta.

c

  REAL for ssyr2k

  DOUBLE PRECISION for dsyr2k

  COMPLEX for csyr2k

  DOUBLE COMPLEX for zsyr2k

  Array, DIMENSION `(ldc,n)`. Before entry with `uplo = 'U'` or 'u', the leading n-by-n upper triangular part of the array c must contain the upper triangular part of the symmetric matrix and the strictly lower triangular part of c is not referenced.

  Before entry with `uplo = 'L'` or 'l', the leading n-by-n lower triangular part of the array c must contain the lower triangular part of the symmetric matrix and the strictly upper triangular part of c is not referenced.

ldc

  INTEGER. Specifies the first dimension of c as declared in the calling (sub)program. The value of ldc must be at least `max(1, n)`.

## Output Parameters

c

  With `uplo = 'U'` or 'u', the upper triangular part of the array c is overwritten by the upper triangular part of the updated matrix.

  With `uplo = 'L'` or 'l', the lower triangular part of the array c is overwritten by the lower triangular part of the updated matrix.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or reconstructible arguments, see Fortran 95 Interface Conventions.

Specific details for the routine syr2k interface are the following:

a

  Holds the matrix A of size (ma,ka) where

  `ka = k` if `trans = 'N'`,

  `ka = n` otherwise,

  `ma = n` if `trans = 'N'`,

  `ma = k` otherwise.

b

  Holds the matrix B of size (mb,kb) where

  `kb = k` if `trans = 'N'`,

  `kb = n` otherwise,

  `mb = n` if `trans = 'N'`,

  `mb = k` otherwise.

c

  Holds the matrix C of size (n,n).

uplo

  Must be 'U' or 'L'. The default value is 'U'.

trans

  Must be 'N', 'C', or 'T'.

  The default value is 'N'.

alpha

  The default value is 1.

beta

  The default value is 1.

Parent topic: BLAS Level 3 Routines