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_zgeqpf (f08bs)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_lapack_zgeqpf (f08bs) computes the QR factorization, with column pivoting, of a complex m by n matrix.

Syntax

[a, jpvt, tau, info] = f08bs(a, jpvt, 'm', m, 'n', n)
[a, jpvt, tau, info] = nag_lapack_zgeqpf(a, jpvt, 'm', m, 'n', n)

Description

nag_lapack_zgeqpf (f08bs) forms the QR factorization, with column pivoting, of an arbitrary rectangular complex m by n matrix.
If mn, the factorization is given by:
AP= Q R 0 ,  
where R is an n by n upper triangular matrix (with real diagonal elements), Q is an m by m unitary matrix and P is an n by n permutation matrix. It is sometimes more convenient to write the factorization as
AP= Q1 Q2 R 0 ,  
which reduces to
AP= Q1 R ,  
where Q1 consists of the first n columns of Q, and Q2 the remaining m-n columns.
If m<n, R is trapezoidal, and the factorization can be written
AP= Q R1 R2 ,  
where R1 is upper triangular and R2 is rectangular.
The matrix Q is not formed explicitly but is represented as a product of minm,n elementary reflectors (see the F08 Chapter Introduction for details). Functions are provided to work with Q in this representation (see Further Comments).
Note also that for any k<n, the information returned in the first k columns of the array a represents a QR factorization of the first k columns of the permuted matrix AP.
The function allows specified columns of A to be moved to the leading columns of AP at the start of the factorization and fixed there. The remaining columns are free to be interchanged so that at the ith stage the pivot column is chosen to be the column which maximizes the 2-norm of elements i to m over columns i to n.

References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

Parameters

Compulsory Input Parameters

1:     alda: – complex array
The first dimension of the array a must be at least max1,m.
The second dimension of the array a must be at least max1,n.
The m by n matrix A.
2:     jpvt: int64int32nag_int array
The dimension of the array jpvt must be at least max1,n
If jpvti0, then the i th column of A is moved to the beginning of AP before the decomposition is computed and is fixed in place during the computation. Otherwise, the i th column of A is a free column (i.e., one which may be interchanged during the computation with any other free column).

Optional Input Parameters

1:     m int64int32nag_int scalar
Default: the first dimension of the array a.
m, the number of rows of the matrix A.
Constraint: m0.
2:     n int64int32nag_int scalar
Default: the second dimension of the array a.
n, the number of columns of the matrix A.
Constraint: n0.

Output Parameters

1:     alda: – complex array
The first dimension of the array a will be max1,m.
The second dimension of the array a will be max1,n.
If mn, the elements below the diagonal store details of the unitary matrix Q and the upper triangle stores the corresponding elements of the n by n upper triangular matrix R.
If m<n, the strictly lower triangular part stores details of the unitary matrix Q and the remaining elements store the corresponding elements of the m by n upper trapezoidal matrix R.
The diagonal elements of R are real.
2:     jpvt: int64int32nag_int array
The dimension of the array jpvt will be max1,n
Details of the permutation matrix P. More precisely, if jpvti=k, then the kth column of A is moved to become the i th column of AP; in other words, the columns of AP are the columns of A in the order jpvt1,jpvt2,,jpvtn.
3:     tauminm,n – complex array
Further details of the unitary matrix Q.
4:     info int64int32nag_int scalar
info=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

   info=-i
If info=-i, parameter i had an illegal value on entry. The parameters are numbered as follows:
1: m, 2: n, 3: a, 4: lda, 5: jpvt, 6: tau, 7: work, 8: rwork, 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 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 real floating-point operations is approximately 83 n2 3m-n  if mn or 83 m2 3n-m  if m<n.
To form the unitary matrix Q nag_lapack_zgeqpf (f08bs) may be followed by a call to nag_lapack_zungqr (f08at):
[a, info] = f08at(a(:,1:m), tau);
but note that the second dimension of the array a must be at least m, which may be larger than was required by nag_lapack_zgeqpf (f08bs).
When mn, it is often only the first n columns of Q that are required, and they may be formed by the call:
[a, info] = f08at(a, tau);
To apply Q to an arbitrary complex rectangular matrix C, nag_lapack_zgeqpf (f08bs) may be followed by a call to nag_lapack_zunmqr (f08au). For example,
[c, info] = f08au('Left','Conjugate Transpose', a(:,min(m,n)), tau, c);
forms C=QHC, where C is m by p.
To compute a QR factorization without column pivoting, use nag_lapack_zgeqrf (f08as).
The real analogue of this function is nag_lapack_dgeqpf (f08be).

Example

This example solves 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.47-0.34i -0.40+0.54i 0.60+0.01i 0.80-1.02i -0.32-0.23i -0.05+0.20i -0.26-0.44i -0.43+0.17i 0.35-0.60i -0.52-0.34i 0.87-0.11i -0.34-0.09i 0.89+0.71i -0.45-0.45i -0.02-0.57i 1.14-0.78i -0.19+0.06i 0.11-0.85i 1.44+0.80i 0.07+1.14i  
and
B = -0.85-1.63i 2.49+4.01i -2.16+3.52i -0.14+7.98i 4.57-5.71i 8.36-0.28i 6.38-7.40i -3.55+1.29i 8.41+9.39i -6.72+5.03i .  
Here A is approximately rank-deficient, and hence it is preferable to use nag_lapack_zgeqpf (f08bs) rather than nag_lapack_zgeqrf (f08as).
function f08bs_example


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

a = [ 0.47 - 0.34i, -0.40 + 0.54i,  0.60 + 0.01i,  0.80 - 1.02i;
     -0.32 - 0.23i, -0.05 + 0.20i, -0.26 - 0.44i, -0.43 + 0.17i;
      0.35 - 0.60i, -0.52 - 0.34i,  0.87 - 0.11i, -0.34 - 0.09i;
      0.89 + 0.71i, -0.45 - 0.45i, -0.02 - 0.57i,  1.14 - 0.78i;
     -0.19 + 0.06i,  0.11 - 0.85i,  1.44 + 0.80i,  0.07 + 1.14i];
b = [-0.85 - 1.63i,  2.49 + 4.01i;
     -2.16 + 3.52i, -0.14 + 7.98i;
      4.57 - 5.71i,  8.36 - 0.28i;
      6.38 - 7.40i, -3.55 + 1.29i;
      8.41 + 9.39i, -6.72 + 5.03i];
[m,n] = size(a);
jpvt = zeros(n,1,'int64');

% Compute the QR factorization of a
[a, jpvt, tau, info] = f08bs( ...
			      a, jpvt);

% Choose tol to reflect the relative accuracy of the input data
tol = 0.01;

% Determine which columns of R to use
k = find(abs(diag(a)) <= tol*abs(a(1,1)));
if numel(k) == 0
  k = numel(diag(a));
else
  k = k(1)-1;
end

% Compute c = (q^H)*b,
[c, info] = f08au( ...
		   'Left', 'Conjugate Transpose', a, tau, b);

% Compute least-squares solution by backsubstitution in r*b = c
c(1:k, :) = inv(triu(a(1:k,1:k)))*c(1:k,:);
c(k+1:4, :) = 0;

% Unscramble the least-squares solution stored in c
x = zeros(4, 2);
for i=1:4
  x(jpvt(i), :) = c(i, :);
end

fprintf('\nLeast-squares solution\n');
disp(x);


f08bs example results


Least-squares solution
   0.0000 + 0.0000i   0.0000 + 0.0000i
   2.6925 + 8.0446i  -2.0563 - 2.9759i
   2.7602 + 2.5455i   1.0588 + 1.4635i
   2.7383 + 0.5123i  -1.4150 + 0.2982i


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