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_dtpqrt (f08bb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_lapack_dtpqrt (f08bb) computes the QR factorization of a real m+n by n triangular-pentagonal matrix.

Syntax

[a, b, t, info] = f08bb(l, nb, a, b, 'm', m, 'n', n)
[a, b, t, info] = nag_lapack_dtpqrt(l, nb, a, b, 'm', m, 'n', n)

Description

nag_lapack_dtpqrt (f08bb) forms the QR factorization of a real m+n by n triangular-pentagonal matrix C,
C= A B  
where A is an upper triangular n by n matrix and B is an m by n pentagonal matrix consisting of an m-l by n rectangular matrix B1 on top of an l by n upper trapezoidal matrix B2:
B= B1 B2 .  
The upper trapezoidal matrix B2 consists of the first l rows of an n by n upper triangular matrix, where 0lminm,n. If l=0, B is m by n rectangular; if l=n and m=n, B is upper triangular.
A recursive, explicitly blocked, QR factorization (see nag_lapack_dgeqrt (f08ab)) is performed on the matrix C. The upper triangular matrix R, details of the orthogonal matrix Q, and further details (the block reflector factors) of Q are returned.
Typically the matrix A or B2 contains the matrix R from the QR factorization of a subproblem and nag_lapack_dtpqrt (f08bb) performs the QR update operation from the inclusion of matrix B1.
For example, consider the QR factorization of an l by n matrix B^ with l<n: B^ = Q^R^ , R^ = R1^ R2^ , where R1^ is l by l upper triangular and R2^ is n-l by n rectangular (this can be performed by nag_lapack_dgeqrt (f08ab)). Given an initial least-squares problem B^ X^ = Y^  where X and Y are l by nrhs matrices, we have R^ X^ = Q^T Y^ .
Now, adding an additional m-l rows to the original system gives the augmented least squares problem
BX=Y  
where B is an m by n matrix formed by adding m-l rows on top of R^ and Y is an m by nrhs matrix formed by adding m-l rows on top of Q^TY^.
nag_lapack_dtpqrt (f08bb) can then be used to perform the QR factorization of the pentagonal matrix B; the n by n matrix A will be zero on input and contain R on output.
In the case where B^ is r by n, rn, R^ is n by n upper triangular (forming A) on top of r-n rows of zeros (forming first r-n rows of B). Augmentation is then performed by adding rows to the bottom of B with l=0.

References

Elmroth E and Gustavson F (2000) Applying Recursion to Serial and Parallel QR Factorization Leads to Better Performance IBM Journal of Research and Development. (Volume 44) 4 605–624
Golub G H and Van Loan C F (2012) Matrix Computations (4th Edition) Johns Hopkins University Press, Baltimore

Parameters

Compulsory Input Parameters

1:     l int64int32nag_int scalar
l, the number of rows of the trapezoidal part of B (i.e., B2).
Constraint: 0lminm,n.
2:     nb int64int32nag_int scalar
The explicitly chosen block-size to be used in the algorithm for computing the QR factorization. See Further Comments for details.
Constraints:
  • nb1;
  • if n>0, nbn.
3:     alda: – double array
The first dimension of the array a must be at least max1,n.
The second dimension of the array a must be at least max1,n.
The n by n upper triangular matrix A.
4:     bldb: – double array
The first dimension of the array b must be at least max1,m.
The second dimension of the array b must be at least max1,n.
The m by n pentagonal matrix B composed of an m-l by n rectangular matrix B1 above an l by n upper trapezoidal matrix B2.

Optional Input Parameters

1:     m int64int32nag_int scalar
Default: the first dimension of the array b.
m, the number of rows of the matrix B.
Constraint: m0.
2:     n int64int32nag_int scalar
Default: the first dimension of the array a and the second dimension of the arrays a, b. (An error is raised if these dimensions are not equal.)
n, the number of columns of the matrix B and the order of the upper triangular matrix A.
Constraint: n0.

Output Parameters

1:     alda: – double array
The first dimension of the array a will be max1,n.
The second dimension of the array a will be max1,n.
The upper triangle stores the corresponding elements of the n by n upper triangular matrix R.
2:     bldb: – double array
The first dimension of the array b will be max1,m.
The second dimension of the array b will be max1,n.
Details of the orthogonal matrix Q.
3:     tldt: – double array
The first dimension of the array t will be nb.
The second dimension of the array t will be n.
Further details of the orthogonal matrix Q. The number of blocks is b=knb, where k=minm,n and each block is of order nb except for the last block, which is of order k-b-1×nb. For each of the blocks, an upper triangular block reflector factor is computed: T1,T2,,Tb. These are stored in the nb by n matrix T as T=T1|T2||Tb.
4:     info int64int32nag_int scalar
info=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

   info<0
If info=-i, argument i had an illegal value. An explanatory message is output, and execution of the program is terminated.

Accuracy

The computed factorization is the exact factorization of a nearby matrix A+E, where
E2 = Oε A2 ,  
and ε is the machine precision.

Further Comments

The total number of floating-point operations is approximately 23 n2 3m-n  if mn or 23 m2 3n-m  if m<n.
The block size, nb, used by nag_lapack_dtpqrt (f08bb) is supplied explicitly through the interface. For moderate and large sizes of matrix, the block size can have a marked effect on the efficiency of the algorithm with the optimal value being dependent on problem size and platform. A value of nb=64minm,n is likely to achieve good efficiency and it is unlikely that an optimal value would exceed 340.
To apply Q to an arbitrary real rectangular matrix C, nag_lapack_dtpqrt (f08bb) may be followed by a call to nag_lapack_dtpmqrt (f08bc). For example,
[t, c, info] = f08bc('Left','Transpose', nb, a(:,1:min(m,n)), t, c);
forms C=QTC, where C is m+n by p.
To form the orthogonal matrix Q explicitly set p=m+n, initialize C to the identity matrix and make a call to nag_lapack_dtpmqrt (f08bc) as above.

Example

This example finds the basic solutions for the linear least squares problems
minimize Axi - bi 2 ,   i=1,2  
where b1 and b2 are the columns of the matrix B,
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   and  B= -2.67 0.41 -0.55 -3.10 3.34 -4.01 -0.77 2.76 0.48 -6.17 4.10 0.21 .  
A QR factorization is performed on the first 4 rows of A using nag_lapack_dgeqrt (f08ab) after which the first 4 rows of B are updated by applying QT using nag_lapack_dgemqrt (f08ac). The remaining row is added by performing a QR update using nag_lapack_dtpqrt (f08bb); B is updated by applying the new QT using nag_lapack_dtpmqrt (f08bc); the solution is finally obtained by triangular solve using R from the updated QR.
function f08bb_example


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

% Minimize ||Ax - b|| using recursive QR for m-by-n A and m-by-p B

m = int64(6);
n = int64(4);
p = int64(2);
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];
b = [-2.67,  0.41;
     -0.55, -3.10;
      3.34, -4.01;
     -0.77,  2.76;
      0.48, -6.17;
      4.10,  0.21];

nb = n;
% Compute the QR Factorisation of first n rows of A
[QRn, Tn, info] = f08ab( ...
			 nb,a(1:n,:));

% Compute C = (C1) = (Q^T)*B
[c1, info] = f08ac( ...
		    'Left', 'Transpose', QRn, Tn, b(1:n,:));

% Compute least-squares solutions by backsubstitution in R*X = C1
[x, info] = f07te( ...
		   'Upper', 'No Transpose', 'Non-Unit', QRn, c1);

% Print first n-row solutions
disp('Solution for n rows');
disp(x(1:n,:));

% Add the remaining rows and perform QR update
nb2 = m-n;
l = int64(0);
[R, Q, T, info] = f08bb( ...
			 l, nb2, QRn, a(n+1:m,:));

% Apply orthogonal transformations to C
[c1,c2,info] = f08bc( ...
		      'Left','Transpose', l, Q, T, c1, b(n+1:m,:));

% Compute least-squares solutions for first n rows: R*X = C1
[x, info] = f07te( ...
		   'Upper', 'No transpose', 'Non-Unit', R, c1);
% Print least-squares solutions for all m rows
disp('Least squares solution');
disp(x(1:n,:));

% Compute and print estimates of the square roots of the residual
% sums of squares
for j=1:p
  rnorm(j) = norm(c2(:,j));
end
fprintf('Square roots of the residual sums of squares\n');
fprintf('%12.2e', rnorm);
fprintf('\n');


f08bb example results

Solution for n rows
    1.5179   -1.5850
    1.8629    0.5531
   -1.4608    1.3485
    0.0398    2.9619

Least squares solution
    1.5339   -1.5753
    1.8707    0.5559
   -1.5241    1.3119
    0.0392    2.9585

Square roots of the residual sums of squares
    2.22e-02    1.38e-02

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–2015