# NAG Library Routine Document

## 1Purpose

f06qtf performs a $QR$ or $RQ$ factorization of the product of a real upper triangular matrix and a real matrix of plane rotations.

## 2Specification

Fortran Interface
 Subroutine f06qtf ( side, n, k1, k2, c, s, a, lda)
 Integer, Intent (In) :: n, k1, k2, lda Real (Kind=nag_wp), Intent (Inout) :: c(*), s(*), a(lda,*) Character (1), Intent (In) :: side
#include nagmk26.h
 void f06qtf_ ( 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

f06qtf performs one of the transformations
 $R←PUQT or R←QUPT ,$
where $U$ is a given $n$ by $n$ real upper triangular matrix, $P$ is a given real orthogonal matrix, and $Q$ is a real orthogonal matrix chosen to make $R$ upper triangular. Both $P$ and $Q$ are represented as sequences of plane rotations in planes ${k}_{1}$ to ${k}_{2}$.
If ${\mathbf{side}}=\text{'L'}$,
 $R←PUQT ,$
where $P={P}_{{k}_{2}-1}\dots {P}_{{k}_{1}+1}{P}_{{k}_{1}}$ and $Q={Q}_{{k}_{2}-1}\dots {Q}_{{k}_{1}+1}{Q}_{{k}_{1}}$.
If ${\mathbf{side}}=\text{'R'}$,
 $R←QUPT ,$
where $P={P}_{{k}_{1}}{P}_{{k}_{1}+1}\dots {P}_{{k}_{2}-1}$ and $Q={Q}_{{k}_{1}}{Q}_{{k}_{1}+1}\dots {Q}_{{k}_{2}-1}$.
In either case ${P}_{k}$ and ${Q}_{k}$ are rotations in the $\left(k,k+1\right)$ plane.
The $2$ by $2$ rotation part of ${P}_{k}$ or ${Q}_{k}$ has the form
 $ck sk -sk ck .$

None.

## 5Arguments

1:     $\mathbf{side}$ – Character(1)Input
On entry: specifies whether $P$ is applied from the left or the right in the transformation.
${\mathbf{side}}=\text{'L'}$
$P$ is applied from the left.
${\mathbf{side}}=\text{'R'}$
$P$ is applied from the right.
Constraint: ${\mathbf{side}}=\text{'L'}$ or $\text{'R'}$.
2:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the order of the matrices $U$ and $R$.
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(*\right)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the dimension of the array c must be at least ${\mathbf{k2}}-1$.
On entry: ${\mathbf{c}}\left(\mathit{k}\right)$ must hold the cosine of the rotation ${P}_{\mathit{k}}$, for $\mathit{k}={\mathit{k}}_{1},\dots ,{\mathit{k}}_{2}-1$.
On exit: ${\mathbf{c}}\left(\mathit{k}\right)$ holds the cosine of the rotation ${Q}_{\mathit{k}}$, for $\mathit{k}={\mathit{k}}_{1},\dots ,{\mathit{k}}_{2}-1$.
6:     $\mathbf{s}\left(*\right)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the dimension of the array s must be at least ${\mathbf{k2}}-1$.
On entry: ${\mathbf{s}}\left(\mathit{k}\right)$ must hold the sine of the rotation ${P}_{\mathit{k}}$, for $\mathit{k}={\mathit{k}}_{1},\dots ,{\mathit{k}}_{2}-1$.
On exit: ${\mathbf{s}}\left(\mathit{k}\right)$ holds the sine of the rotation ${Q}_{\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 $n$ by $n$ upper triangular matrix $U$.
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 f06qtf is called.
Constraint: ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.

None.

Not applicable.

## 8Parallelism and Performance

f06qtf is not threaded in any implementation.