# NAG Library Routine Document

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine f06qrf ( side, n, k1, k2, c, s, a, lda)
 Integer, Intent (In) :: n, k1, k2, lda Real (Kind=nag_wp), Intent (Inout) :: c(k2-1), s(k2-1), a(lda,*) Character (1), Intent (In) :: side
#include nagmk26.h
 void f06qrf_ ( const char *side, const Integer *n, const Integer *k1, const Integer *k2, double c[], double s[], double a[], const Integer *lda, const Charlen length_side)

## 3Description

f06qrf transforms an $n$ by $n$ real upper Hessenberg matrix $H$ to upper triangular form $R$ by applying an orthogonal matrix $P$ from the left or the right. $H$ is assumed to have nonzero subdiagonal elements ${h}_{\mathit{k}+1,\mathit{k}}$, for $\mathit{k}={\mathit{k}}_{1},\dots ,{\mathit{k}}_{2}-1$, only. $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={P}_{{k}_{2}-1}\cdots {P}_{{k}_{1}+1}{P}_{{k}_{1}}$.
If ${\mathbf{side}}=\text{'R'}$, the rotations are applied from the right:
 $HPT=R ,$
where $P={P}_{{k}_{1}}{P}_{{k}_{1}+1}\cdots {P}_{{k}_{2}-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
 $ck sk -sk ck .$

None.

## 5Arguments

1:     $\mathbf{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:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the order of the matrix $H$.
Constraint: ${\mathbf{n}}\ge 0$.
3:     $\mathbf{k1}$ – IntegerInput
4:     $\mathbf{k2}$ – IntegerInput
On entry: 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:     $\mathbf{c}\left({\mathbf{k2}}-1\right)$ – Real (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$.
6:     $\mathbf{s}\left({\mathbf{k2}}-1\right)$ – Real (Kind=nag_wp) arrayInput/Output
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:     $\mathbf{a}\left({\mathbf{lda}},*\right)$ – Real (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$.
8:     $\mathbf{lda}$ – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f06qrf is called.
Constraint: ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.

None.

Not applicable.

## 8Parallelism and Performance

f06qrf is not threaded in any implementation.