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$ by $n$ orthogonal matrix ${P}^{\mathrm{T}}$, where $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$ is assumed to be given by
 $P=PmPm-1⋯P1$
where
 $Pk = I - uk ukT , uk= wk ζk 0 zk ,$
${\zeta }_{k}$ is a scalar, ${w}_{k}$ is a ($k-1$) element vector and ${z}_{k}$ is an ($n-m$) element vector. ${w}_{k}$ must be supplied in the $k$th row of a in elements ${\mathbf{a}}\left(k,1\right),\dots ,{\mathbf{a}}\left(k,k-1\right)$. ${z}_{k}$ must be supplied in the $k$th row of a in elements ${\mathbf{a}}\left(k,m+1\right),\dots ,{\mathbf{a}}\left(k,n\right)$ and ${\zeta }_{k}$ must be supplied either in ${\mathbf{a}}\left(k,k\right)$ or in ${\mathbf{zeta}}\left(k\right)$, depending upon the argument 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:     $\mathrm{wheret}$ – string (length ≥ 1)
Indicates where the elements of $\zeta$ are to be found.
${\mathbf{wheret}}=\text{'I'}$ (In a)
The elements of $\zeta$ are in a.
${\mathbf{wheret}}=\text{'S'}$ (Separate)
The elements of $\zeta$ are separate from a, in zeta.
Constraint: ${\mathbf{wheret}}=\text{'I'}$ or $\text{'S'}$.
2:     $\mathrm{m}$int64int32nag_int scalar
$m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
3:     $\mathrm{nrowp}$int64int32nag_int scalar
$\ell$, the required number of rows of $P$.
If ${\mathbf{nrowp}}=0$, an immediate return is effected.
Constraint: $0\le {\mathbf{nrowp}}\le {\mathbf{n}}$.
4:     $\mathrm{a}\left(\mathit{lda},:\right)$ – double array
The first dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}},{\mathbf{nrowp}}\right)$.
The second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The leading $m$ by $m$ strictly lower triangular part of the array a, and the $m$ by $\left(n-m\right)$ rectangular part of a with top left-hand corner at element ${\mathbf{a}}\left(1,{\mathbf{m}}+1\right)$ must contain details of the matrix $P$. In addition, if ${\mathbf{wheret}}=\text{'I'}$, the diagonal elements of a must contain the elements of $\zeta$.
5:     $\mathrm{zeta}\left(:\right)$ – double array
The dimension of the array zeta must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if ${\mathbf{wheret}}=\text{'S'}$, and at least $1$ otherwise
With ${\mathbf{wheret}}=\text{'S'}$, the array zeta must contain the elements of $\zeta$. If ${\mathbf{zeta}}\left(k\right)=0.0$ then ${P}_{k}$ is assumed to be $I$, otherwise ${\mathbf{zeta}}\left(k\right)$ is assumed to contain ${\zeta }_{k}$.
When ${\mathbf{wheret}}=\text{'I'}$, the array zeta is not referenced.

### Optional Input Parameters

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

### Output Parameters

1:     $\mathrm{a}\left(\mathit{lda},:\right)$ – double array
The first dimension of the array a will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}},{\mathbf{nrowp}}\right)$.
The second dimension of the array a will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The first nrowp rows of the array a store the first nrowp rows of the $n$ by $n$ orthogonal matrix ${P}^{\mathrm{T}}$.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{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:
${\mathbf{ifail}}=-1$
 On entry, ${\mathbf{wheret}}\ne \text{'I'}$ or $\text{'S'}$, or ${\mathbf{m}}<0$, or ${\mathbf{n}}<{\mathbf{m}}$, or ${\mathbf{nrowp}}<0$ or ${\mathbf{nrowp}}>{\mathbf{n}}$, or $\mathit{lda}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{nrowp}}\right)$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

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

The approximate number of floating-point operations is given by
 $23m3n-m2ℓ-m-mℓ-m, if ​ℓ≥m, and ​ 23ℓ23n-ℓ, if ​ℓ

## Example

This example obtains the $5$ by $5$ orthogonal matrix $P$ following the $RQ$ factorization of the $3$ by $5$ matrix $A$ given by
 $A= 2.0 2.0 1.6 2.0 1.2 2.5 2.5 -0.4 -0.5 -0.3 2.5 2.5 2.8 0.5 -2.9 .$
```function f01qk_example

fprintf('f01qk example results\n\n');

a = [2,   2,    1.6,  2,    1.2;
2.5, 2.5, -0.4, -0.5, -0.3;
2.5, 2.5,  2.8,  0.5, -2.9];

[RQ, zeta, ifail] = f01qj(a);

wheret = 'Separate';
m     = int64(size(a,1));
nrowp = int64(size(a,2));
RQ(m+1:nrowp,1:nrowp) = 0;

[PT, ifail] = f01qk( ...
wheret, m, nrowp, RQ, zeta);

P = PT';
disp('Matrix P');
disp(P);

```
```f01qk example results

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

```