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_complex_gen_rq (f01rj)

## Purpose

nag_matop_complex_gen_rq (f01rj) finds the RQ$RQ$ factorization of the complex m$m$ by n$n$ (mn$m\le n$), matrix A$A$, so that A$A$ is reduced to upper triangular form by means of unitary transformations from the right.

## Syntax

[a, theta, ifail] = f01rj(a, 'm', m, 'n', n)
[a, theta, ifail] = nag_matop_complex_gen_rq(a, 'm', m, 'n', n)

## Description

The m$m$ by n$n$ matrix A$A$ is factorized as
when ​m < n, A = RPH when ​m = n,
$A= R 0 PH when ​m
(R0)
 A = PH
where P$P$ is an n$n$ by n$n$ unitary matrix and R$R$ is an m$m$ by m$m$ upper triangular matrix.
P$P$ is given as a sequence of Householder transformation matrices
 P = Pm ⋯ P2P1, $P=Pm⋯P2P1,$
the (mk + 1)$\left(m-k+1\right)$th transformation matrix, Pk${P}_{k}$, being used to introduce zeros into the k$k$th row of A$A$. Pk${P}_{k}$ has the form
 Pk = I − γkukukH, $Pk=I-γkukukH,$
where
uk =
 wk ζk 0 zk
.
$uk= wk ζk 0 zk .$
γk${\gamma }_{k}$ is a scalar for which Re(γk) = 1.0$\mathrm{Re}\left({\gamma }_{k}\right)=1.0$, ζk${\zeta }_{k}$ is a real scalar, wk${w}_{k}$ is a (k1)$\left(k-1\right)$ element vector and zk${z}_{k}$ is an (nm)$\left(n-m\right)$ element vector. γk${\gamma }_{k}$ and uk${u}_{k}$ are chosen to annihilate the elements in the k$k$th row of A$A$.
The scalar γk${\gamma }_{k}$ and the vector uk${u}_{k}$ are returned in the k$k$th element of theta and in the k$k$th row of a, such that θk${\theta }_{k}$, given by
 θk = (ζk,Im(γk)). $θk=(ζk,Im(γk)).$
is in theta(k)${\mathbf{theta}}\left(k\right)$, the elements of wk${w}_{k}$ are in a(k,1),,a(k,k1)${\mathbf{a}}\left(k,1\right),\dots ,{\mathbf{a}}\left(k,k-1\right)$ and the elements of zk${z}_{k}$ are in a(k,m + 1),,a(k,n)${\mathbf{a}}\left(k,m+1\right),\dots ,{\mathbf{a}}\left(k,n\right)$. The elements of R$R$ are returned in the upper triangular part of a.

## 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:     a(lda, : $:$) – complex array
The first dimension of the array a must be at least max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\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 n$n$ part of the array a must contain the matrix to be factorized.

### Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array a.
m$m$, the number of rows of the matrix A$A$.
When m = 0${\mathbf{m}}=0$ then an immediate return is effected.
Constraint: m0${\mathbf{m}}\ge 0$.
2:     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

### Output Parameters

1:     a(lda, : $:$) – complex array
The first dimension of the array a will be max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\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)$\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
The m$m$ by m$m$ upper triangular part of a will contain the upper triangular matrix R$R$, and the m$m$ by m$m$ strictly lower triangular part of a and the m$m$ by (nm)$\left(n-m\right)$ rectangular part of a to the right of the upper triangular part will contain details of the factorization as described in Section [Description].
2:     theta(m) – complex array
theta(k)${\mathbf{theta}}\left(k\right)$ contains the scalar θk${\theta }_{k}$ for the (mk + 1)$\left(m-k+1\right)$th transformation. If Pk = I${P}_{k}=I$ then theta(k) = 0.0${\mathbf{theta}}\left(k\right)=0.0$; if
Tk =
 I 0 0 0 α 0 0 0 I
,  Re(α) < 0.0
$Tk= I 0 0 0 α 0 0 0 I , Re(α)<0.0$
then theta(k) = α${\mathbf{theta}}\left(k\right)=\alpha$, otherwise theta(k)${\mathbf{theta}}\left(k\right)$ contains θk${\theta }_{k}$ as described in Section [Description] and θk${\theta }_{k}$ is always in the range (1.0,sqrt(2.0))$\left(1.0,\sqrt{2.0}\right)$.
3:     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, m < 0${\mathbf{m}}<0$, or n < m${\mathbf{n}}<{\mathbf{m}}$, or lda < m$\mathit{lda}<{\mathbf{m}}$.

## Accuracy

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

The approximate number of floating point operations is given by 8 × m2(3nm) / 3$8×{m}^{2}\left(3n-m\right)/3$.
The first k$k$ rows of the unitary matrix PH${P}^{\mathrm{H}}$ can be obtained by calling nag_matop_complex_gen_rq_formq (f01rk), which overwrites the k$k$ rows of PH${P}^{\mathrm{H}}$ on the first k$k$ rows of the array a. PH${P}^{\mathrm{H}}$ is obtained by the call:
```[a, ifail] = f01qk('Separate', m, k, a, theta);
```

## Example

```function nag_matop_complex_gen_rq_example
a = [ 0 - 0.5i,  0.4 - 0.3i,  0.4 + 0i,  0.3 + 0.4i,  0 + 0.3i;
-0.5 - 1.5i,  0.9 - 1.3i,  -0.4 - 0.4i,  0.1 - 0.7i,  0.3 - 0.3i;
-1 - 1i,  0.2 - 1.4i,  1.8 + 0i,  0 + 0i,  0 - 2.4i];
[aOut, theta, ifail] = nag_matop_complex_gen_rq(a)
```
```

aOut =

0.7878 + 0.0000i  -0.2549 - 0.4006i  -0.2774 - 0.2774i  -0.2850 + 0.5586i   0.1154 + 0.7031i
0.0396 + 0.5222i  -2.1122 + 0.0000i  -1.1094 - 0.5547i   0.1283 + 0.2317i   0.0790 - 0.0361i
-0.2265 + 0.2265i   0.0453 + 0.3171i  -3.6056 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.5436i

theta =

1.0387 - 0.1006i
1.1810 + 0.3809i
1.2244 + 0.0000i

ifail =

0

```
```function f01rj_example
a = [ 0 - 0.5i,  0.4 - 0.3i,  0.4 + 0i,  0.3 + 0.4i,  0 + 0.3i;
-0.5 - 1.5i,  0.9 - 1.3i,  -0.4 - 0.4i,  0.1 - 0.7i,  0.3 - 0.3i;
-1 - 1i,  0.2 - 1.4i,  1.8 + 0i,  0 + 0i,  0 - 2.4i];
[aOut, theta, ifail] = f01rj(a)
```
```

aOut =

0.7878 + 0.0000i  -0.2549 - 0.4006i  -0.2774 - 0.2774i  -0.2850 + 0.5586i   0.1154 + 0.7031i
0.0396 + 0.5222i  -2.1122 + 0.0000i  -1.1094 - 0.5547i   0.1283 + 0.2317i   0.0790 - 0.0361i
-0.2265 + 0.2265i   0.0453 + 0.3171i  -3.6056 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.5436i

theta =

1.0387 - 0.1006i
1.1810 + 0.3809i
1.2244 + 0.0000i

ifail =

0

```