F06 Chapter Contents
F06 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF06TRF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F06TRF performs a $QR$ or $RQ$ factorization (as a sequence of plane rotations) of a complex upper Hessenberg matrix.

## 2  Specification

 SUBROUTINE F06TRF ( SIDE, N, K1, K2, C, S, A, LDA)
 INTEGER N, K1, K2, LDA REAL (KIND=nag_wp) S(*) COMPLEX (KIND=nag_wp) C(K2), A(LDA,*) CHARACTER(1) SIDE

## 3  Description

F06TRF transforms an $n$ by $n$ complex upper Hessenberg matrix $H$ to upper triangular form $R$ by applying a unitary matrix $P$ from the left or the right. $H$ is assumed to have real nonzero subdiagonal elements ${h}_{\mathit{k}+1,\mathit{k}}$, for $\mathit{k}={\mathit{k}}_{1},\dots ,{\mathit{k}}_{2}-1$, only; $R$ has real diagonal elements. $P$ is formed as a sequence of plane rotations in planes ${k}_{1}$ to ${k}_{2}$.
If ${\mathbf{SIDE}}=\text{'L'}$, the rotations are applied from the left:
 $PH=R ,$
where $P=D{P}_{{k}_{2}-1}\cdots {P}_{{k}_{1}+1}{P}_{{k}_{1}}$ and $D=\mathrm{diag}\left(1,\dots ,1,{d}_{{k}_{2}},1,\dots ,1\right)$ with $\left|{d}_{{k}_{2}}\right|=1$.
If ${\mathbf{SIDE}}=\text{'R'}$, the rotations are applied from the right:
 $HPH=R ,$
where $P=D{P}_{{k}_{1}}{P}_{{k}_{1}+1}\cdots {P}_{{k}_{2}-1}$ and $D=\mathrm{diag}\left(1,\dots ,1,{d}_{{k}_{1}},1,\dots ,1\right)$ with $\left|{d}_{{k}_{1}}\right|=1$.
In either case, ${P}_{k}$ is a rotation in the $\left(k,k+1\right)$ plane, chosen to annihilate ${h}_{k+1,k}$.
The $2$ by $2$ plane rotation part of ${P}_{k}$ has the form
 $c-k sk -sk ck$
with ${s}_{k}$ real.

None.

## 5  Parameters

1:     $\mathrm{SIDE}$ – CHARACTER(1)Input
On entry: specifies whether $H$ is operated on from the left or the right.
${\mathbf{SIDE}}=\text{'L'}$
$H$ is pre-multiplied from the left.
${\mathbf{SIDE}}=\text{'R'}$
$H$ is post-multiplied from the right.
Constraint: ${\mathbf{SIDE}}=\text{'L'}$ or $\text{'R'}$.
2:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the order of the matrix $H$.
Constraint: ${\mathbf{N}}\ge 0$.
3:     $\mathrm{K1}$ – INTEGERInput
4:     $\mathrm{K2}$ – INTEGERInput
On entry: the dimension of the array C as declared in the (sub)program from which F06TRF is called. The values ${k}_{1}$ and ${k}_{2}$.
If ${\mathbf{K1}}<1$ or ${\mathbf{K2}}\le {\mathbf{K1}}$ or ${\mathbf{K2}}>{\mathbf{N}}$, an immediate return is effected.
5:     $\mathrm{C}\left({\mathbf{K2}}\right)$ – COMPLEX (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{C}}\left(\mathit{k}\right)$ holds ${c}_{\mathit{k}}$, the cosine of the rotation ${P}_{\mathit{k}}$, for $\mathit{k}={\mathit{k}}_{1},\dots ,{\mathit{k}}_{2}-1$; ${\mathbf{C}}\left({k}_{2}\right)$ holds ${d}_{{k}_{2}}$, the ${k}_{2}$th diagonal element of $D$, if ${\mathbf{SIDE}}=\text{'L'}$, or ${d}_{{k}_{1}}$, the ${k}_{1}$th diagonal element of $D$, if ${\mathbf{SIDE}}=\text{'R'}$.
6:     $\mathrm{S}\left(*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array S must be at least ${\mathbf{K2}}-{\mathbf{K1}}$.
On entry: the nonzero subdiagonal elements of $H$: ${\mathbf{S}}\left(\mathit{k}\right)$ must hold ${h}_{\mathit{k}+1,\mathit{k}}$, for $\mathit{k}={\mathit{k}}_{1},\dots ,{\mathit{k}}_{2}-1$.
On exit: ${\mathbf{S}}\left(\mathit{k}\right)$ holds ${s}_{\mathit{k}}$, the sine of the rotation ${P}_{\mathit{k}}$, for $\mathit{k}={\mathit{k}}_{1},\dots ,{\mathit{k}}_{2}-1$.
7:     $\mathrm{A}\left({\mathbf{LDA}},*\right)$ – COMPLEX (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array A must be at least ${\mathbf{N}}$.
On entry: the upper triangular part of the $n$ by $n$ upper Hessenberg matrix $H$.
On exit: the upper triangular matrix $R$. The imaginary parts of the diagonal elements are set to zero.
8:     $\mathrm{LDA}$ – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F06TRF is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.

None.

Not applicable.

## 8  Parallelism and Performance

F06TRF is not threaded by NAG in any implementation.
F06TRF 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.