# NAG FL Interfacef01rgf (complex_​trapez_​rq)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f01rgf reduces the complex $m×n$ ($m\le n$) upper trapezoidal matrix $A$ to upper triangular form by means of unitary transformations.

## 2Specification

Fortran Interface
 Subroutine f01rgf ( m, n, a, lda,
 Integer, Intent (In) :: m, n, lda Integer, Intent (Inout) :: ifail Complex (Kind=nag_wp), Intent (Inout) :: a(lda,*) Complex (Kind=nag_wp), Intent (Out) :: theta(m)
#include <nag.h>
 void f01rgf_ (const Integer *m, const Integer *n, Complex a[], const Integer *lda, Complex theta[], Integer *ifail)
The routine may be called by the names f01rgf or nagf_matop_complex_trapez_rq.

## 3Description

The $m×n\left(m\le n\right)$ upper trapezoidal matrix $A$ given by
 $A=( U X ) ,$
where $U$ is an $m×m$ upper triangular matrix, is factorized as
 $A=( R 0 ) PH,$
where $P$ is an $n×n$ unitary matrix and $R$ is an $m×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-γkukukH, uk=( ζk 0 zk cr ),$
${\gamma }_{k}$ is a scalar for which $\mathrm{Re}\left({\gamma }_{k}\right)=1.0$, ${\zeta }_{k}$ is a real scalar and ${z}_{k}$ is an $\left(n-m\right)$ element vector. ${\gamma }_{k}$, ${\zeta }_{k}$ and ${z}_{k}$ are chosen to annihilate the elements of the $k$th row of $X$ and to make the diagonal elements of $R$ real.
The scalar ${\gamma }_{k}$ and the vector ${u}_{k}$ are returned in the $k$th element of the array theta and in the $k$th row of a, such that ${\theta }_{k}$, given by
 $θk=(ζk,Im(γk)),$
is in ${\mathbf{theta}}\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).

## 4References

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

## 5Arguments

1: $\mathbf{m}$Integer Input
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: $\mathbf{n}$Integer Input
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge {\mathbf{m}}$.
3: $\mathbf{a}\left({\mathbf{lda}},*\right)$Complex (Kind=nag_wp) array Input/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×n$ upper trapezoidal part of the array a must contain the matrix to be factorized.
On exit: the $m×m$ upper triangular part of a will contain the upper triangular matrix $R$, and the $m×\left(n-m\right)$ upper trapezoidal part of a will contain details of the factorization as described in Section 3.
4: $\mathbf{lda}$Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f01rgf is called.
Constraint: ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
5: $\mathbf{theta}\left({\mathbf{m}}\right)$Complex (Kind=nag_wp) array Output
On exit: ${\mathbf{theta}}\left(k\right)$ contains the scalar ${\theta }_{k}$ for the $\left(m-k+1\right)$th transformation. If ${T}_{k}=I$ then ${\mathbf{theta}}\left(k\right)=0.0$; if
 $Tk=( α 0 0 I ), Re(α)<0.0$
then ${\mathbf{theta}}\left(k\right)=\alpha$, otherwise ${\mathbf{theta}}\left(k\right)$ contains ${\theta }_{k}$ as described in Section 3 and $\mathrm{Re}\left({\theta }_{k}\right)$ is always in the range $\left(1.0,\sqrt{2.0}\right)$.
6: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-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{lda}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lda}}\ge {\mathbf{m}}$.
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge {\mathbf{m}}$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

The computed factors $R$ and $P$ satisfy the relation
 $( R 0 ) PH=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.

## 8Parallelism and Performance

f01rgf 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.

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

## 10Example

This example reduces the $3×4$ matrix
 $( 2.4 0.8+0.8i -1.4+0.6i 3.0-1.0i 0.0 1.6i+0.0 0.8+0.3i 0.4+0.5i 0.0 0.0i+0.0 1.0i+0.0 2.0-1.0i )$
to upper triangular form.

### 10.1Program Text

Program Text (f01rgfe.f90)

### 10.2Program Data

Program Data (f01rgfe.d)

### 10.3Program Results

Program Results (f01rgfe.r)