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_lapack_dorgql (f08cf)

## Purpose

nag_lapack_dorgql (f08cf) generates all or part of the real $m$ by $m$ orthogonal matrix $Q$ from a $QL$ factorization computed by nag_lapack_dgeqlf (f08ce).

## Syntax

[a, info] = f08cf(a, tau, 'm', m, 'n', n, 'k', k)
[a, info] = nag_lapack_dorgql(a, tau, 'm', m, 'n', n, 'k', k)

## Description

nag_lapack_dorgql (f08cf) is intended to be used after a call to nag_lapack_dgeqlf (f08ce), which performs a $QL$ factorization of a real matrix $A$. The orthogonal matrix $Q$ is represented as a product of elementary reflectors.
This function may be used to generate $Q$ explicitly as a square matrix, or to form only its trailing columns.
Usually $Q$ is determined from the $QL$ factorization of an $m$ by $p$ matrix $A$ with $m\ge p$. The whole of $Q$ may be computed by:
```[a, info] = f08cf(a, tau);
```
(note that the array a must have at least $m$ columns) or its trailing $p$ columns by:
```[a, info] = f08cf(a(:,1:p), tau);
```
The columns of $Q$ returned by the last call form an orthonormal basis for the space spanned by the columns of $A$; thus nag_lapack_dgeqlf (f08ce) followed by nag_lapack_dorgql (f08cf) can be used to orthogonalize the columns of $A$.
The information returned by nag_lapack_dgeqlf (f08ce) also yields the $QL$ factorization of the trailing $k$ columns of $A$, where $k. The orthogonal matrix arising from this factorization can be computed by:
```[a, info] = f08cf(a, tau, 'k', k);
```
or its trailing $k$ columns by:
```[a, info] = f08cf(a(:,1:p), tau, 'k', k);
```

## 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:     $\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}}\right)$.
The second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
Details of the vectors which define the elementary reflectors, as returned by nag_lapack_dgeqlf (f08ce).
2:     $\mathrm{tau}\left(:\right)$ – double array
The dimension of the array tau must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$
Further details of the elementary reflectors, as returned by nag_lapack_dgeqlf (f08ce).

### Optional Input Parameters

1:     $\mathrm{m}$int64int32nag_int scalar
Default: the first dimension of the array a.
$m$, the number of rows of the matrix $Q$.
Constraint: ${\mathbf{m}}\ge 0$.
2:     $\mathrm{n}$int64int32nag_int scalar
Default: the second dimension of the array a.
$n$, the number of columns of the matrix $Q$.
Constraint: ${\mathbf{m}}\ge {\mathbf{n}}\ge 0$.
3:     $\mathrm{k}$int64int32nag_int scalar
Default: the dimension of the array tau.
$k$, the number of elementary reflectors whose product defines the matrix $Q$.
Constraint: ${\mathbf{n}}\ge {\mathbf{k}}\ge 0$.

### 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}}\right)$.
The second dimension of the array a will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The $m$ by $n$ matrix $Q$.
2:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

${\mathbf{info}}=-i$
If ${\mathbf{info}}=-i$, parameter $i$ had an illegal value on entry. The parameters are numbered as follows:
1: m, 2: n, 3: k, 4: a, 5: lda, 6: tau, 7: work, 8: lwork, 9: 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 matrix $Q$ differs from an exactly orthogonal matrix by a matrix $E$ such that
 $E2 = Oε ,$
where $\epsilon$ is the machine precision.

The total number of floating-point operations is approximately $4mnk-2\left(m+n\right){k}^{2}+\frac{4}{3}{k}^{3}$; when $n=k$, the number is approximately $\frac{2}{3}{n}^{2}\left(3m-n\right)$.
The complex analogue of this function is nag_lapack_zungql (f08ct).

## Example

This example generates the first four columns of the matrix $Q$ of the $QL$ factorization of $A$ as returned by nag_lapack_dgeqlf (f08ce), where
 $A = -0.57 -1.28 -0.39 0.25 -1.93 1.08 -0.31 -2.14 2.30 0.24 0.40 -0.35 -1.93 0.64 -0.66 0.08 0.15 0.30 0.15 -2.13 -0.02 1.03 -1.43 0.50 .$
Note that the block size (NB) of $64$ assumed in this example is not realistic for such a small problem, but should be suitable for large problems.
```function f08cf_example

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

% Form Q from QL factorization of A
m = 6;
n = 4;
a = [-0.57, -1.28, -0.39,  0.25;
-1.93,  1.08, -0.31, -2.14;
2.30,  0.24,  0.40, -0.35;
-1.93,  0.64, -0.66,  0.08;
0.15,  0.3,   0.15, -2.13;
-0.02,  1.03, -1.43,  0.5];

% Compute the QL factorization of A
[ql, tau, info] = f08ce(a);

% Form Q
[Q, info] = f08cf(ql, tau);
% Print Q
[ifail] = x04ca( ...
'General', ' ', Q, 'Orthogonal Q from QL of A');

```
```f08cf example results

Orthogonal Q from QL of A
1       2       3       4
1  -0.0833  0.9100 -0.2202 -0.0809
2   0.2972 -0.1080 -0.2706  0.6922
3  -0.6404 -0.2351  0.2220  0.1132
4   0.4461 -0.1620 -0.3866 -0.0259
5  -0.2938  0.2022  0.0015  0.6890
6  -0.4575 -0.1946 -0.8243 -0.1617
```