# NAG Library Routine Document

## 1Purpose

f06yrf (dsyr2k) performs one of the symmetric rank-$2k$ update operations
 $C←αABT + αBAT + βC or C←αATB + αBTA+βC ,$
where $A$ and $B$ are real matrices, $C$ is an $n$ by $n$ real symmetric matrix, and $\alpha$ and $\beta$ are real scalars.

## 2Specification

Fortran Interface
 Subroutine f06yrf ( uplo, n, k, a, lda, b, ldb, beta, c, ldc)
 Integer, Intent (In) :: n, k, lda, ldb, ldc Real (Kind=nag_wp), Intent (In) :: alpha, a(lda,*), b(ldb,*), beta Real (Kind=nag_wp), Intent (Inout) :: c(ldc,*) Character (1), Intent (In) :: uplo, trans
#include nagmk26.h
 void f06yrf_ (const char *uplo, const char *trans, const Integer *n, const Integer *k, const double *alpha, const double a[], const Integer *lda, const double b[], const Integer *ldb, const double *beta, double c[], const Integer *ldc, const Charlen length_uplo, const Charlen length_trans)
The routine may be called by its BLAS name dsyr2k.

None.

None.

## 5Arguments

1:     $\mathbf{uplo}$ – Character(1)Input
On entry: specifies whether the upper or lower triangular part of $C$ is stored.
${\mathbf{uplo}}=\text{'U'}$
The upper triangular part of $C$ is stored.
${\mathbf{uplo}}=\text{'L'}$
The lower triangular part of $C$ is stored.
Constraint: ${\mathbf{uplo}}=\text{'U'}$ or $\text{'L'}$.
2:     $\mathbf{trans}$ – Character(1)Input
On entry: specifies the operation to be performed.
${\mathbf{trans}}=\text{'N'}$
$C←\alpha A{B}^{\mathrm{T}}+\alpha B{A}^{\mathrm{T}}+\beta C$.
${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$
$C←\alpha {A}^{\mathrm{T}}B+\alpha {B}^{\mathrm{T}}A+\beta C$.
Constraint: ${\mathbf{trans}}=\text{'N'}$, $\text{'T'}$ or $\text{'C'}$.
3:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the order of the matrix $C$; the number of rows of $A$ and $B$ if ${\mathbf{trans}}=\text{'N'}$, or the number of columns of $A$ and $B$ if ${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$.
Constraint: ${\mathbf{n}}\ge 0$.
4:     $\mathbf{k}$ – IntegerInput
On entry: $k$, the number of columns of $A$ and $B$ if ${\mathbf{trans}}=\text{'N'}$, or the number of rows of $A$ and $B$ if ${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$.
Constraint: ${\mathbf{k}}\ge 0$.
5:     $\mathbf{alpha}$ – Real (Kind=nag_wp)Input
On entry: the scalar $\alpha$.
6:     $\mathbf{a}\left({\mathbf{lda}},*\right)$ – Real (Kind=nag_wp) arrayInput
Note: the second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$ if ${\mathbf{trans}}=\text{'N'}$ and at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if ${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$.
On entry: the matrix $A$; $A$ is $n$ by $k$ if ${\mathbf{trans}}=\text{'N'}$, or $k$ by $n$ if ${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$.
7:     $\mathbf{lda}$ – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f06yrf (dsyr2k) is called.
Constraints:
• if ${\mathbf{trans}}=\text{'N'}$, ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$, ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
8:     $\mathbf{b}\left({\mathbf{ldb}},*\right)$ – Real (Kind=nag_wp) arrayInput
Note: the second dimension of the array b must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$ if ${\mathbf{trans}}=\text{'N'}$ and at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if ${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$.
On entry: the matrix $B$; $B$ is $n$ by $k$ if ${\mathbf{trans}}=\text{'N'}$, or $k$ by $n$ if ${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$.
9:     $\mathbf{ldb}$ – IntegerInput
On entry: the first dimension of the array b as declared in the (sub)program from which f06yrf (dsyr2k) is called.
Constraints:
• if ${\mathbf{trans}}=\text{'N'}$, ${\mathbf{ldb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{trans}}=\text{'T'}$ or $\text{'C'}$, ${\mathbf{ldb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
10:   $\mathbf{beta}$ – Real (Kind=nag_wp)Input
On entry: the scalar $\beta$.
11:   $\mathbf{c}\left({\mathbf{ldc}},*\right)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array c must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the $n$ by $n$ symmetric matrix $C$.
• If ${\mathbf{uplo}}=\text{'U'}$, the upper triangular part of $C$ must be stored and the elements of the array below the diagonal are not referenced.
• If ${\mathbf{uplo}}=\text{'L'}$, the lower triangular part of $C$ must be stored and the elements of the array above the diagonal are not referenced.
On exit: the updated matrix $C$.
12:   $\mathbf{ldc}$ – IntegerInput
On entry: the first dimension of the array c as declared in the (sub)program from which f06yrf (dsyr2k) is called.
Constraint: ${\mathbf{ldc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.

None.

Not applicable.

## 8Parallelism and Performance

f06yrf (dsyr2k) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f06yrf (dsyr2k) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.