NAG FL Interface
f01qjf (real_gen_rq)
1
Purpose
f01qjf finds the $RQ$ factorization of the real $m$ by $n$ ($m\le n$) matrix $A$, so that $A$ is reduced to upper triangular form by means of orthogonal transformations from the right.
2
Specification
Fortran Interface
Integer, Intent (In) 
:: 
m, n, lda 
Integer, Intent (Inout) 
:: 
ifail 
Real (Kind=nag_wp), Intent (Inout) 
:: 
a(lda,*) 
Real (Kind=nag_wp), Intent (Out) 
:: 
zeta(m) 

C Header Interface
#include <nag.h>
void 
f01qjf_ (const Integer *m, const Integer *n, double a[], const Integer *lda, double zeta[], Integer *ifail) 

C++ Header Interface
#include <nag.h> extern "C" {
void 
f01qjf_ (const Integer &m, const Integer &n, double a[], const Integer &lda, double zeta[], Integer &ifail) 
}

The routine may be called by the names f01qjf or nagf_matop_real_gen_rq.
3
Description
The
$m$ by
$n$ matrix
$A$ is factorized as
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
the (
$mk+1$)th transformation matrix,
${P}_{k}$, being used to introduce zeros into the
$k$th row of
$A$.
${P}_{k}$ has the form
where
${\zeta}_{k}$ is a scalar,
${w}_{k}$ is an
$\left(k1\right)$ element vector and
${z}_{k}$ is an
$\left(nm\right)$ element vector.
${u}_{k}$ is chosen to annihilate the elements in the
$k$th row of
$A$.
The vector
${u}_{k}$ is returned in the
$k$th element of
zeta and in the
$k$th row of
a, such that
${\zeta}_{k}$ is in
${\mathbf{zeta}}\left(k\right)$, the elements of
${w}_{k}$ are in
${\mathbf{a}}\left(k,1\right),\dots ,{\mathbf{a}}\left(k,k1\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.
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
Arguments

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)$ – Real (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$ by
$n$ 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
$m$ strictly lower triangular part of
a and the
$m$ by
$\left(nm\right)$ rectangular part of
a to the right of the upper triangular part 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
f01qjf is called.
Constraint:
${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.

5:
$\mathbf{zeta}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) array
Output

On exit:
${\mathbf{zeta}}\left(k\right)$ contains the scalar
${\zeta}_{k}$ for the
$\left(mk+1\right)$th transformation. If
${P}_{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:
$\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).
6
Error 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}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{m}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{lda}}\ge {\mathbf{m}}$.
On entry, ${\mathbf{m}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{m}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}\ge {\mathbf{m}}$.
 ${\mathbf{ifail}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
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.
7
Accuracy
The computed factors
$R$ and
$P$ satisfy the relation
where
$\epsilon $ is the
machine precision (see
x02ajf),
$c$ is a modest function of
$m$ and
$n$, and
$\Vert .\Vert $ denotes the spectral (two) norm.
8
Parallelism and Performance
f01qjf 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 implementationspecific information.
The approximate number of floatingpoint operations is given by $2\times {m}^{2}\left(3nm\right)/3$.
The first
$k$ rows of the orthogonal matrix
${P}^{\mathrm{T}}$ can be obtained by calling
f01qkf, which overwrites the
$k$ rows of
${P}^{\mathrm{T}}$ on the first
$k$ rows of the array
a.
${P}^{\mathrm{T}}$ is obtained by the call:
ifail = 0
Call f01qkf('Separate',m,n,k,a,lda,zeta,work,ifail)
$\mathrm{WORK}$ must be a
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(m1,km,1\right)$ element array. If
$\mathrm{K}$ is larger than
$\mathrm{M}$, then
a must have been declared to have at least
$\mathrm{K}$ rows.
Operations involving the matrix
$R$ can readily be performed by the Level 2 BLAS routines
f06pff and
f06pjf (see
Chapter F06), but note that no test for near singularity of
$R$ is incorporated into
f06pjf. If
$R$ is singular, or nearly singular then
f02wuf can be used to determine the singular value decomposition of
$R$.
10
Example
This example obtains the
$RQ$ factorization of the
$3$ by
$5$ matrix
10.1
Program Text
10.2
Program Data
10.3
Program Results