F01 Chapter Contents
F01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF01QGF

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

F01QGF reduces the $m$ by $n$ ($m\le n$) real upper trapezoidal matrix $A$ to upper triangular form by means of orthogonal transformations.

## 2  Specification

 SUBROUTINE F01QGF ( M, N, A, LDA, ZETA, IFAIL)
 INTEGER M, N, LDA, IFAIL REAL (KIND=nag_wp) A(LDA,*), ZETA(M)

## 3  Description

The $m$ by $n$ ($m\le n$) real upper trapezoidal matrix $A$ given by
 $A= U X ,$
where $U$ is an $m$ by $m$ upper triangular matrix, is factorized as
 $A= R 0 PT,$
where $P$ is an $n$ by $n$ orthogonal matrix and $R$ is an $m$ by $m$ upper triangular matrix.
$P$ is given as a sequence of Householder transformation matrices
 $P=Pm⋯P2P1,$
the $\left(m-k+1\right)$th transformation matrix, ${P}_{k}$, being used to introduce zeros into the $k$th row of $A$. ${P}_{k}$ has the form
 $Pk= I 0 0 Tk ,$
where
 $Tk=I-ukukT, uk= ζk 0 zk ,$
${\zeta }_{k}$ is a scalar and ${z}_{k}$ is an ($n-m$) element vector. ${\zeta }_{k}$ and ${z}_{k}$ are chosen to annihilate the elements of the $k$th row of $X$.
The vector ${u}_{k}$ is returned in the $k$th element of the array ZETA and in the $k$th row of A, such that ${\zeta }_{k}$ is in ${\mathbf{ZETA}}\left(k\right)$ and the elements of ${z}_{k}$ are in ${\mathbf{A}}\left(k,m+1\right),\dots ,{\mathbf{A}}\left(k,n\right)$. The elements of $R$ are returned in the upper triangular part of A.
For further information on this factorization and its use see Section 6.5 of Golub and Van Loan (1996).

## 4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, Oxford

## 5  Parameters

1:     M – INTEGERInput
On entry: $m$, the number of rows of the matrix $A$.
When ${\mathbf{M}}=0$ then an immediate return is effected.
Constraint: ${\mathbf{M}}\ge 0$.
2:     N – INTEGERInput
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{N}}\ge {\mathbf{M}}$.
3:     A(LDA,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array A must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the leading $m$ by $n$ upper trapezoidal part of the array A must contain the matrix to be factorized.
On exit: the $m$ by $m$ upper triangular part of A will contain the upper triangular matrix $R$, and the $m$ by $\left(n-m\right)$ upper trapezoidal part of A will contain details of the factorization as described in Section 3.
4:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F01QGF is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}}\right)$.
5:     ZETA(M) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{ZETA}}\left(k\right)$ contains the scalar ${\zeta }_{k}$ for the $\left(m-k+1\right)$th transformation. If ${T}_{k}=I$ then ${\mathbf{ZETA}}\left(k\right)=0.0$, otherwise ${\mathbf{ZETA}}\left(k\right)$ contains ${\zeta }_{k}$ as described in Section 3 and ${\zeta }_{k}$ is always in the range $\left(1.0,\sqrt{2.0}\right)$.
6:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=-1$
 On entry, ${\mathbf{M}}<0$, or ${\mathbf{N}}<{\mathbf{M}}$, or ${\mathbf{LDA}}<{\mathbf{M}}$.

## 7  Accuracy

The computed factors $R$ and $P$ satisfy the relation
 $R0PT=A+E,$
where
 $E≤cε A,$
$\epsilon$ is the machine precision (see X02AJF), $c$ is a modest function of $m$ and $n$ and $‖.‖$ denotes the spectral (two) norm.

The approximate number of floating point operations is given by $2{m}^{2}\left(n-m\right)$.

## 9  Example

This example reduces the $3$ by $5$ matrix
 $A= 2.4 0.8 -1.4 3.0 -0.8 0.0 1.6 0.8 0.4 -0.8 0.0 0.0 1.0 2.0 2.0$
to upper triangular form.

### 9.1  Program Text

Program Text (f01qgfe.f90)

### 9.2  Program Data

Program Data (f01qgfe.d)

### 9.3  Program Results

Program Results (f01qgfe.r)