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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_dormrq (f08ck)

## Purpose

nag_lapack_dormrq (f08ck) multiplies a general real m$m$ by n$n$ matrix C$C$ by the real orthogonal matrix Q$Q$ from an RQ$RQ$ factorization computed by nag_lapack_dgerqf (f08ch).

## Syntax

[a, c, info] = f08ck(side, trans, a, tau, c, 'm', m, 'n', n, 'k', k)
[a, c, info] = nag_lapack_dormrq(side, trans, a, tau, c, 'm', m, 'n', n, 'k', k)

## Description

nag_lapack_dormrq (f08ck) is intended to be used following a call to nag_lapack_dgerqf (f08ch), which performs an RQ$RQ$ factorization of a real matrix A$A$ and represents the orthogonal matrix Q$Q$ as a product of elementary reflectors.
This function may be used to form one of the matrix products
 QC ,   QTC ,   CQ ,   CQT , $QC , QTC , CQ , CQT ,$
overwriting the result on C$C$, which may be any real rectangular m$m$ by n$n$ matrix.
A common application of this function is in solving underdetermined linear least squares problems, as described in the F08 Chapter Introduction, and illustrated in Section [Example] in (f08ch).

## References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## Parameters

### Compulsory Input Parameters

1:     side – string (length ≥ 1)
Indicates how Q$Q$ or QT${Q}^{\mathrm{T}}$ is to be applied to C$C$.
side = 'L'${\mathbf{side}}=\text{'L'}$
Q$Q$ or QT${Q}^{\mathrm{T}}$ is applied to C$C$ from the left.
side = 'R'${\mathbf{side}}=\text{'R'}$
Q$Q$ or QT${Q}^{\mathrm{T}}$ is applied to C$C$ from the right.
Constraint: side = 'L'${\mathbf{side}}=\text{'L'}$ or 'R'$\text{'R'}$.
2:     trans – string (length ≥ 1)
Indicates whether Q$Q$ or QT${Q}^{\mathrm{T}}$ is to be applied to C$C$.
trans = 'N'${\mathbf{trans}}=\text{'N'}$
Q$Q$ is applied to C$C$.
trans = 'T'${\mathbf{trans}}=\text{'T'}$
QT${Q}^{\mathrm{T}}$ is applied to C$C$.
Constraint: trans = 'N'${\mathbf{trans}}=\text{'N'}$ or 'T'$\text{'T'}$.
3:     a(lda, : $:$) – double array
The first dimension of the array a must be at least max (1,k)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$
The second dimension of the array must be at least max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if side = 'L'${\mathbf{side}}=\text{'L'}$ and at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if side = 'R'${\mathbf{side}}=\text{'R'}$
The i$\mathit{i}$th row of a must contain the vector which defines the elementary reflector Hi${H}_{\mathit{i}}$, for i = 1,2,,k$\mathit{i}=1,2,\dots ,k$, as returned by nag_lapack_dgerqf (f08ch).
4:     tau( : $:$) – double array
Note: the dimension of the array tau must be at least max (1,k)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
tau(i)${\mathbf{tau}}\left(i\right)$ must contain the scalar factor of the elementary reflector Hi${H}_{i}$, as returned by nag_lapack_dgerqf (f08ch).
5:     c(ldc, : $:$) – double array
The first dimension of the array c 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 m$m$ by n$n$ matrix C$C$.

### Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array c.
m$m$, the number of rows of the matrix C$C$.
Constraint: m0${\mathbf{m}}\ge 0$.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array c.
n$n$, the number of columns of the matrix C$C$.
Constraint: n0${\mathbf{n}}\ge 0$.
3:     k – int64int32nag_int scalar
Default: The first dimension of the array a The dimension of the array tau.
k$k$, the number of elementary reflectors whose product defines the matrix Q$Q$.
Constraints:
• if side = 'L'${\mathbf{side}}=\text{'L'}$, m k 0 ${\mathbf{m}}\ge {\mathbf{k}}\ge 0$;
• if side = 'R'${\mathbf{side}}=\text{'R'}$, n k 0 ${\mathbf{n}}\ge {\mathbf{k}}\ge 0$.

### Input Parameters Omitted from the MATLAB Interface

lda ldc work lwork

### Output Parameters

1:     a(lda, : $:$) – double array
The first dimension of the array a will be max (1,k)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$
The second dimension of the array will be max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if side = 'L'${\mathbf{side}}=\text{'L'}$ and at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if side = 'R'${\mathbf{side}}=\text{'R'}$
ldamax (1,k)$\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
Is modified by nag_lapack_dormrq (f08ck) but restored on exit.
2:     c(ldc, : $:$) – double array
The first dimension of the array c 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)$
ldcmax (1,m)$\mathit{ldc}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
c stores QC$QC$ or QTC${Q}^{\mathrm{T}}C$ or CQ$CQ$ or CQT$C{Q}^{\mathrm{T}}$ as specified by side and trans.
3:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

## Error Indicators and Warnings

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: side, 2: trans, 3: m, 4: n, 5: k, 6: a, 7: lda, 8: tau, 9: c, 10: ldc, 11: work, 12: lwork, 13: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.

## Accuracy

The computed result differs from the exact result by a matrix E$E$ such that
 ‖E‖2 = Oε ‖C‖2 $‖E‖2 = O⁡ε ‖C‖2$
where ε$\epsilon$ is the machine precision.

The total number of floating point operations is approximately 2nk(2mk)$2nk\left(2m-k\right)$ if side = 'L'${\mathbf{side}}=\text{'L'}$ and 2mk(2nk)$2mk\left(2n-k\right)$ if side = 'R'${\mathbf{side}}=\text{'R'}$.
The complex analogue of this function is nag_lapack_zunmrq (f08cx).

## Example

```function nag_lapack_dormrq_example
a = [-5.42, 3.28, -3.68, 0.27, 2.06, 0.46;
-1.65, -3.4, -3.2, -1.03, -4.06, -0.01;
-0.37, 2.35, 1.9, 4.31, -1.76, 1.13;
-3.15, -0.11, 1.99, -2.7, 0.26, 4.5];
b = [-2.87; 1.63; -3.52; 0.45];
% Compute the RQ factorization of a
[a, tau, info] = nag_lapack_dgerqf(a);

% Solve R*y2 = b
c = zeros(6,1);
[c(3:6), info] = nag_lapack_dtrtrs('Upper', 'No transpose', 'Non-Unit', a(:, 3:6), b);

if (info >0)
fprintf('The upper triangular factor, R, of A is singular,\n');
fprintf('the least squares solution could not be computed.\n');
else
% Compute the minimum-norm solution x = (Q^T)*y
[a, c, info] = nag_lapack_dormrq('Left', 'Transpose', a, tau, c);

fprintf('\nMinimum-norm solution\n');
disp(transpose(c));
end
```
```

Minimum-norm solution
0.2371   -0.4575   -0.0085   -0.5192    0.0239   -0.0543

```
```function f08ck_example
a = [-5.42, 3.28, -3.68, 0.27, 2.06, 0.46;
-1.65, -3.4, -3.2, -1.03, -4.06, -0.01;
-0.37, 2.35, 1.9, 4.31, -1.76, 1.13;
-3.15, -0.11, 1.99, -2.7, 0.26, 4.5];
b = [-2.87; 1.63; -3.52; 0.45];
% Compute the RQ factorization of a
[a, tau, info] = f08ch(a);

% Solve R*y2 = b
c = zeros(6,1);
[c(3:6), info] = f07te('Upper', 'No transpose', 'Non-Unit', a(:, 3:6), b);

if (info >0)
fprintf('The upper triangular factor, R, of A is singular,\n');
fprintf('the least squares solution could not be computed.\n');
else
% Compute the minimum-norm solution x = (Q^T)*y
[a, c, info] = f08ck('Left', 'Transpose', a, tau, c);

fprintf('\nMinimum-norm solution\n');
disp(transpose(c));
end
```
```

Minimum-norm solution
0.2371   -0.4575   -0.0085   -0.5192    0.0239   -0.0543

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013