Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_matop_real_gen_rq_formq (f01qk)

## Purpose

nag_matop_real_gen_rq_formq (f01qk) returns the first $\ell$ rows of the real n$n$ by n$n$ orthogonal matrix PT${P}^{\mathrm{T}}$, where P$P$ is given as the product of Householder transformation matrices.
This function is intended for use following nag_matop_real_gen_rq (f01qj).

## Syntax

[a, ifail] = f01qk(wheret, m, nrowp, a, zeta, 'n', n)
[a, ifail] = nag_matop_real_gen_rq_formq(wheret, m, nrowp, a, zeta, 'n', n)

## Description

P$P$ is assumed to be given by
 P = PmPm − 1 ⋯ P1 $P=PmPm-1⋯P1$
where
$Pk = I - uk ukT , uk= wk ζk 0 zk ,$
Pk = I − uk ukT ,
 uk = ( wk ζk 0 zk ),
ζk${\zeta }_{k}$ is a scalar, wk${w}_{k}$ is a (k1$k-1$) element vector and zk${z}_{k}$ is an (nm$n-m$) element vector. wk${w}_{k}$ must be supplied in the k$k$th row of a in elements a(k,1),,a(k,k1)${\mathbf{a}}\left(k,1\right),\dots ,{\mathbf{a}}\left(k,k-1\right)$. zk${z}_{k}$ must be supplied in the k$k$th row of a in elements a(k,m + 1),,a(k,n)${\mathbf{a}}\left(k,m+1\right),\dots ,{\mathbf{a}}\left(k,n\right)$ and ζk${\zeta }_{k}$ must be supplied either in a(k,k)${\mathbf{a}}\left(k,k\right)$ or in zeta(k)${\mathbf{zeta}}\left(k\right)$, depending upon the parameter wheret.

## 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

## Parameters

### Compulsory Input Parameters

1:     wheret – string (length ≥ 1)
Indicates where the elements of ζ$\zeta$ are to be found.
wheret = 'I'${\mathbf{wheret}}=\text{'I'}$ (In a)
The elements of ζ$\zeta$ are in a.
wheret = 'S'${\mathbf{wheret}}=\text{'S'}$ (Separate)
The elements of ζ$\zeta$ are separate from a, in zeta.
Constraint: wheret = 'I'${\mathbf{wheret}}=\text{'I'}$ or 'S'$\text{'S'}$.
2:     m – int64int32nag_int scalar
m$m$, the number of rows of the matrix A$A$.
Constraint: m0${\mathbf{m}}\ge 0$.
3:     nrowp – int64int32nag_int scalar
$\ell$, the required number of rows of P$P$.
If nrowp = 0${\mathbf{nrowp}}=0$, an immediate return is effected.
Constraint: 0nrowpn$0\le {\mathbf{nrowp}}\le {\mathbf{n}}$.
4:     a(lda, : $:$) – double array
The first dimension of the array a must be at least max (1,m,nrowp)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}},{\mathbf{nrowp}}\right)$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The leading m$m$ by m$m$ strictly lower triangular part of the array a, and the m$m$ by (nm$n-m$) rectangular part of a with top left-hand corner at element a(1,m + 1)${\mathbf{a}}\left(1,{\mathbf{m}}+1\right)$ must contain details of the matrix P$P$. In addition, when wheret = 'I'${\mathbf{wheret}}=\text{'I'}$, then the diagonal elements of a must contain the elements of ζ$\zeta$.
5:     zeta( : $:$) – double array
Note: the dimension of the array zeta must be at least max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if wheret = 'S'${\mathbf{wheret}}=\text{'S'}$, and at least 1$1$ otherwise.
With wheret = 'S'${\mathbf{wheret}}=\text{'S'}$, the array zeta must contain the elements of ζ$\zeta$. If zeta(k) = 0.0${\mathbf{zeta}}\left(k\right)=0.0$ then Pk${P}_{k}$ is assumed to be I$I$, otherwise zeta(k)${\mathbf{zeta}}\left(k\right)$ is assumed to contain ζk${\zeta }_{k}$.
When wheret = 'I'${\mathbf{wheret}}=\text{'I'}$, the array zeta is not referenced.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The second dimension of the array a.
n$n$, the number of columns of the matrix A$A$.
Constraint: nm${\mathbf{n}}\ge {\mathbf{m}}$.

lda work

### Output Parameters

1:     a(lda, : $:$) – double array
The first dimension of the array a will be max (1,m,nrowp)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}},{\mathbf{nrowp}}\right)$
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
ldamax (1,m,nrowp)$\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}},{\mathbf{nrowp}}\right)$.
The first nrowp rows of the array a store the first nrowp rows of the n$n$ by n$n$ orthogonal matrix PT${P}^{\mathrm{T}}$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=-1$
 On entry, wheret ≠ 'I'${\mathbf{wheret}}\ne \text{'I'}$ or 'S'$\text{'S'}$, or m < 0${\mathbf{m}}<0$, or n < m${\mathbf{n}}<{\mathbf{m}}$, or nrowp < 0${\mathbf{nrowp}}<0$ or ${\mathbf{nrowp}}>{\mathbf{n}}$, or lda < max (m,nrowp)$\mathit{lda}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{nrowp}}\right)$.

## Accuracy

The computed matrix P$P$ satisfies the relation
 P = Q + E, $P=Q+E,$
where Q$Q$ is an exactly orthogonal matrix and
 ‖E‖ ≤ cε, $‖E‖≤cε,$
ε$\epsilon$ is the machine precision (see nag_machine_precision (x02aj)), c$c$ is a modest function of n$n$, and . $‖.‖$ denotes the spectral (two) norm. See also Section [Accuracy] in (f01qj).

The approximate number of floating point operations is given by
 (2/3)m{(3n − m)(2ℓ − m) − m(ℓ − m)}, if ​ℓ ≥ m, and ​ (2/3)ℓ2(3n − ℓ), if ​ℓ < m.
$23m{(3n-m)(2ℓ-m)-m(ℓ-m)}, if ​ℓ≥m, and ​ 23ℓ2(3n-ℓ), if ​ℓ

## Example

function nag_matop_real_gen_rq_formq_example
wheret = 'Separate';
m = int64(3);
nrowp = int64(5);
a = [-3.144584553986008, -1.070546935661071, -2.228344058124622, 0.6332849259420066, 0.7619486847328875;
0.5276878374877219, -2.834516318284424, -2.228344058124622, -0.1662468409100804, 0.0945215703740671;
0.3765535922552591, 0.3765535922552591, -5.385164807134504, 0.07531071845105182, -0.4368021670161005;
0, 0, 0, 0, 0;
0, 0, 0, 0, 0];
zeta = [1.009150337862724;
1.298065178174413;
1.232861284531129];
[aOut, ifail] = nag_matop_real_gen_rq_formq(wheret, m, nrowp, a, zeta)

aOut =

-0.1310   -0.1310   -0.3276   -0.6551   -0.6551
-0.5170   -0.5170    0.5499    0.2494   -0.3175
-0.4642   -0.4642   -0.5199   -0.0928    0.5385
-0.5054    0.5054   -0.3957    0.4946   -0.2967
-0.4946    0.4946    0.4043   -0.5054    0.3032

ifail =

0

function f01qk_example
wheret = 'Separate';
m = int64(3);
nrowp = int64(5);
a = [-3.144584553986008, -1.070546935661071, -2.228344058124622, ...
0.6332849259420066, 0.7619486847328875;
0.5276878374877219, -2.834516318284424, -2.228344058124622, ...
-0.1662468409100804, 0.0945215703740671;
0.3765535922552591, 0.3765535922552591, -5.385164807134504, ...
0.07531071845105182, -0.4368021670161005;
0, 0, 0, 0, 0;
0, 0, 0, 0, 0];
zeta = [1.009150337862724;
1.298065178174413;
1.232861284531129];
[aOut, ifail] = f01qk(wheret, m, nrowp, a, zeta)

aOut =

-0.1310   -0.1310   -0.3276   -0.6551   -0.6551
-0.5170   -0.5170    0.5499    0.2494   -0.3175
-0.4642   -0.4642   -0.5199   -0.0928    0.5385
-0.5054    0.5054   -0.3957    0.4946   -0.2967
-0.4946    0.4946    0.4043   -0.5054    0.3032

ifail =

0