PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_lapack_dgeqpf (f08be)
Purpose
nag_lapack_dgeqpf (f08be) computes the factorization, with column pivoting, of a real by matrix.
Syntax
Description
nag_lapack_dgeqpf (f08be) forms the factorization, with column pivoting, of an arbitrary rectangular real by matrix.
If
, the factorization is given by:
where
is an
by
upper triangular matrix,
is an
by
orthogonal matrix and
is an
by
permutation matrix. It is sometimes more convenient to write the factorization as
which reduces to
where
consists of the first
columns of
, and
the remaining
columns.
If
,
is trapezoidal, and the factorization can be written
where
is upper triangular and
is rectangular.
The matrix
is not formed explicitly but is represented as a product of
elementary reflectors (see the
F08 Chapter Introduction for details). Functions are provided to work with
in this representation (see
Further Comments).
Note also that for any
, the information returned in the first
columns of the array
a represents a
factorization of the first
columns of the permuted matrix
.
The function allows specified columns of to be moved to the leading columns of at the start of the factorization and fixed there. The remaining columns are free to be interchanged so that at the th stage the pivot column is chosen to be the column which maximizes the -norm of elements to over columns to .
References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The first dimension of the array
a must be at least
.
The second dimension of the array
a must be at least
.
The by matrix .
- 2:
– int64int32nag_int array
-
The dimension of the array
jpvt
must be at least
If , then the th column of is moved to the beginning of before the decomposition is computed and is fixed in place during the computation. Otherwise, the th column of is a free column (i.e., one which may be interchanged during the computation with any other free column).
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
a.
, the number of rows of the matrix .
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
a.
, the number of columns of the matrix .
Constraint:
.
Output Parameters
- 1:
– double array
-
The first dimension of the array
a will be
.
The second dimension of the array
a will be
.
If
, the elements below the diagonal store details of the orthogonal matrix
and the upper triangle stores the corresponding elements of the
by
upper triangular matrix
.
If , the strictly lower triangular part stores details of the orthogonal matrix and the remaining elements store the corresponding elements of the by upper trapezoidal matrix .
- 2:
– int64int32nag_int array
-
The dimension of the array
jpvt will be
Details of the permutation matrix . More precisely, if , then the th column of is moved to become the th column of ; in other words, the columns of are the columns of in the order .
- 3:
– double array
-
Further details of the orthogonal matrix .
- 4:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
-
If , parameter 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:
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
, where
and
is the
machine precision.
Further Comments
The total number of floating-point operations is approximately if or if .
To form the orthogonal matrix
nag_lapack_dgeqpf (f08be) may be followed by a call to
nag_lapack_dorgqr (f08af):
[a, info] = f08af(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_dgeqpf (f08be).
When
, it is often only the first
columns of
that are required, and they may be formed by the call:
[a, info] = f08af(a, tau);
To apply
to an arbitrary real rectangular matrix
,
nag_lapack_dgeqpf (f08be) may be followed by a call to
nag_lapack_dormqr (f08ag). For example,
[c, info] = f08ag('Left','Transpose', a(:,1:min(m,n)), tau, c);
forms
, where
is
by
.
To compute a
factorization without column pivoting, use
nag_lapack_dgeqrf (f08ae).
The complex analogue of this function is
nag_lapack_zgeqpf (f08bs).
Example
This example finds the basic solutions for the linear least squares problems
where
and
are the columns of the matrix
,
Here
is approximately rank-deficient, and hence it is preferable to use
nag_lapack_dgeqpf (f08be) rather than
nag_lapack_dgeqrf (f08ae).
Open in the MATLAB editor:
f08be_example
function f08be_example
fprintf('f08be example results\n\n');
a = [-0.09, 0.14, -0.46, 0.68, 1.29;
-1.56, 0.2, 0.29, 1.09, 0.51;
-1.48, -0.43, 0.89, -0.71, -0.96;
-1.09, 0.84, 0.77, 2.11, -1.27;
0.08, 0.55, -1.13, 0.14, 1.74;
-1.59, -0.72, 1.06, 1.24, 0.34];
b = [-0.01, -0.04;
0.04, -0.03;
0.05, 0.01;
-0.03, -0.02;
0.02, 0.05;
-0.06, 0.07];
jpvt = [int64(0);0;0;0;0];
[a, jpvt, tau, info] = f08be( ...
a, jpvt);
tol = 0.01;
k = find(abs(diag(a)) <= tol*abs(a(1,1)));
if numel(k) == 0
k = numel(diag(a));
else
k = k(1)-1;
end
[c, info] = f08ag( ...
'Left', 'Transpose', a, tau, b);
c(1:k, :) = inv(triu(a(1:k,1:k)))*c(1:k,:);
c(k+1:5, :) = 0;
x = zeros(5, 2);
for i=1:5
x(jpvt(i), :) = c(i, :);
end
fprintf('\nLeast-squares solution\n');
disp(x);
f08be example results
Least-squares solution
-0.0370 -0.0044
0.0647 -0.0335
0 0
-0.0515 0.0018
0.0066 0.0102
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015