hide long namesshow long names
hide short namesshow short names
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 mm by nn matrix CC by the real orthogonal matrix QQ from an RQRQ 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 RQRQ factorization of a real matrix AA and represents the orthogonal matrix QQ 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 CC, which may be any real rectangular mm by nn 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 QQ or QTQT is to be applied to CC.
side = 'L'side='L'
QQ or QTQT is applied to CC from the left.
side = 'R'side='R'
QQ or QTQT is applied to CC from the right.
Constraint: side = 'L'side='L' or 'R''R'.
2:     trans – string (length ≥ 1)
Indicates whether QQ or QTQT is to be applied to CC.
trans = 'N'trans='N'
QQ is applied to CC.
trans = 'T'trans='T'
QTQT is applied to CC.
Constraint: trans = 'N'trans='N' or 'T''T'.
3:     a(lda, : :) – double array
The first dimension of the array a must be at least max (1,k)max(1,k)
The second dimension of the array must be at least max (1,m)max(1,m) if side = 'L'side='L' and at least max (1,n)max(1,n) if side = 'R'side='R'
The iith row of a must contain the vector which defines the elementary reflector HiHi, for i = 1,2,,ki=1,2,,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)max(1,k).
tau(i)taui must contain the scalar factor of the elementary reflector HiHi, 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)max(1,m)
The second dimension of the array must be at least max (1,n)max(1,n)
The mm by nn matrix CC.

Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array c.
mm, the number of rows of the matrix CC.
Constraint: m0m0.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array c.
nn, the number of columns of the matrix CC.
Constraint: n0n0.
3:     k – int64int32nag_int scalar
Default: The first dimension of the array a The dimension of the array tau.
kk, the number of elementary reflectors whose product defines the matrix QQ.
Constraints:
  • if side = 'L'side='L', m k 0 m k 0 ;
  • if side = 'R'side='R', n k 0 n k 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)max(1,k)
The second dimension of the array will be max (1,m)max(1,m) if side = 'L'side='L' and at least max (1,n)max(1,n) if side = 'R'side='R'
ldamax (1,k)ldamax(1,k).
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)max(1,m)
The second dimension of the array will be max (1,n)max(1,n)
ldcmax (1,m)ldcmax(1,m).
c stores QCQC or QTCQTC or CQCQ or CQTCQT as specified by side and trans.
3:     info – int64int32nag_int scalar
info = 0info=0 unless the function detects an error (see Section [Error Indicators and Warnings]).

Error Indicators and Warnings

  info = iinfo=-i
If info = iinfo=-i, parameter ii 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 EE such that
E2 = Oε C2
E2 = Oε C2
where εε is the machine precision.

Further Comments

The total number of floating point operations is approximately 2nk(2mk)2nk(2m-k) if side = 'L'side='L' and 2mk(2nk)2mk(2n-k) if side = 'R'side='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