PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_eigen_withdraw_real_gen_qu_svd (f02wd)
Purpose
nag_eigen_real_gen_qu_svd (f02wd) returns the Householder factorization of a real rectangular by matrix . Further, on request or if is not of full rank, part or all of the singular value decomposition of is returned.
Note: this function is scheduled to be withdrawn, please see
f02wd in
Advice on Replacement Calls for Withdrawn/Superseded Routines..
Syntax
[
a,
b,
svd,
irank,
z,
sv,
r,
pt,
work,
ifail] = f02wd(
a,
wantb,
b,
tol,
svd,
wantr,
wantpt,
lwork, 'm',
m, 'n',
n)
[
a,
b,
svd,
irank,
z,
sv,
r,
pt,
work,
ifail] = nag_eigen_withdraw_real_gen_qu_svd(
a,
wantb,
b,
tol,
svd,
wantr,
wantpt,
lwork, 'm',
m, 'n',
n)
Description
The real
by
matrix
is first factorized as
where
is an
by
orthogonal matrix and
is an
by
upper triangular matrix.
If either
is singular or
svd is supplied as
true, then the singular value decomposition (SVD) of
is obtained so that
is factorized as
where
and
are
by
orthogonal matrices and
is the
by
diagonal matrix
with
Note that the SVD of
is then given by
the diagonal elements of
being the singular values of
.
The option to form a vector , or if appropriate , is also provided.
The rank of the matrix
, based upon a user-supplied argument
tol, is also returned.
The factorization of is obtained by Householder transformations. To obtain the SVD of the matrix is first reduced to bidiagonal form by means of plane rotations and then the algorithm is used to obtain the SVD of the bidiagonal form.
References
Wilkinson J H (1978) Singular Value Decomposition – Basic Aspects Numerical Software – Needs and Availability (ed D A H Jacobs) Academic Press
Parameters
Compulsory Input Parameters
- 1:
– double array
-
lda, the first dimension of the array, must satisfy the constraint
.
The leading
by
part of
a must contain the matrix to be factorized.
- 2:
– logical scalar
-
Must be
true if
or
is required.
If on entry
,
b is not referenced.
- 3:
– double array
-
If
wantb is supplied as
true,
b must contain the
element vector
. Otherwise,
b is not referenced.
- 4:
– double scalar
-
Must specify a relative tolerance to be used to determine the rank of
.
tol should be chosen as approximately the largest relative error in the elements of
. For example, if the elements of
are correct to about
significant figures,
tol should be set to about
. See
Determining the Rank of for a description of how
tol is used to determine rank.
If
tol is outside the range
, where
is the
machine precision, the value
is used in place of
tol. For most problems this is unreasonably small.
- 5:
– logical scalar
-
Must be
true if the singular values are to be found even if
is of full rank.
If before entry, and is determined to be of full rank, only the factorization of is computed.
- 6:
– logical scalar
-
Must be
true if the orthogonal matrix
is required when the singular values are computed.
If on entry
,
r is not referenced.
- 7:
– logical scalar
-
Must be
true if the orthogonal matrix
is required when the singular values are computed.
Note that if
svd is returned as
true,
pt is referenced even if
wantpt is supplied as
false, but see argument
pt.
- 8:
– int64int32nag_int scalar
-
The dimension of the array
work.
Constraint:
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
b and the first dimension of the array
a. (An error is raised if these dimensions are not equal.)
, 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 leading
by
part of
a, together with the
-element vector
z, contains details of the Householder
factorization.
Details of the storage of the
factorization are given in
Storage Details of the Factorization.
- 2:
– double array
-
Contains
if
svd is returned as
true and
if
svd is returned as
false.
- 3:
– logical scalar
-
Is returned as false if only the factorization of has been obtained and is returned as true if the singular values of have been obtained.
- 4:
– int64int32nag_int scalar
-
Returns the rank of the matrix
. (It should be noted that it is possible for
irank to be returned as
and
svd to be returned as
true, even if
svd was supplied as
false. This means that the matrix
only just failed the test for nonsingularity.)
- 5:
– double array
-
The
-element vector
z contains some details of the Householder transformations. See
Storage Details of the Factorization for further information.
- 6:
– double array
-
If
svd is returned as
true,
sv contains the
singular values of
arranged in descending order.
- 7:
– double array
-
The first dimension,
, of the array
r will be
- if , ;
- otherwise .
The second dimension of the array
r will be
if
and
otherwise.
If
svd is returned as
true and
wantr was supplied as
true, the leading
by
part of
r will contain the left-hand orthogonal matrix of the
svd of
.
- 8:
– double array
-
If
svd is returned as
true and
wantpt was supplied as
true, the leading
by
part of
pt contains the orthogonal matrix
.
If
svd is returned as
true, but
wantpt was supplied as
false, the leading
by
part of
pt is used for internal workspace.
- 9:
– double array
-
If
svd is returned as
false,
contains the condition number
of the upper triangular matrix
.
If
svd is returned as
true,
will contain the total number of iterations taken by the
algorithm.
The rest of the array is used as workspace and so contains no meaningful information.
- 10:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , |
or | when , |
or | |
or | . |
(The function only checks
ldr if
wantr is supplied as
true.)
-
-
The algorithm has failed to converge to the singular values in iterations. In this case may not have been correctly found and the remaining singular values may not be the smallest singular values. The matrix has nevertheless been factorized as , where is an upper bidiagonal matrix with as its diagonal elements and as its superdiagonal elements.
This failure cannot occur if
svd is returned as
false and in any case is extremely rare.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The computed factors
,
,
,
and
satisfy the relations
where
,
,
being the
machine precision and
and
are modest functions of
and
. Note that
.
Further Comments
Timing
The time taken by nag_eigen_real_gen_qu_svd (f02wd) to obtain the Householder factorization is approximately proportional to .
The additional time taken to obtain the singular value decomposition is approximately proportional to , where the constant of proportionality depends upon whether or not the orthogonal matrices and are required.
General Remarks
Singular vectors associated with a zero or multiple singular value, are not uniquely determined, even in exact arithmetic, and very different results may be obtained if they are computed on different machines.
This function is called by the least squares function
nag_linsys_real_gen_solve (f04jg).
Determining the Rank of A
Following the
factorization of
, if
svd is supplied as
false, then the condition number of
given by
is found, where
denotes the Frobenius norm, and if
is such that
then
is regarded as singular and the singular values of
are computed. If this test is not satisfied, then the rank of
is set to
. Note that if
svd is supplied as
true then this test is omitted.
When the singular values are computed, then the rank of
,
, is returned as the largest integer such that
unless
in which case
is returned as zero. That is, singular values which satisfy
are regarded as negligible because relative perturbations of order
tol can make such singular values zero.
Storage Details of the QU Factorization
The
th Householder transformation matrix,
, used in the
factorization is chosen to introduce the zeros into the
th column and has the form
where
is an
element vector.
In place of
the function actually computes the vector
given by
The first element of
is stored in
and the remaining elements of
are overwritten on the subdiagonal elements of the
th column of
a. The upper triangular matrix
is overwritten on the
by
upper triangular part of
a.
Example
This example obtains the rank and the singular value decomposition of the
by
matrix
given by
the value
tol to be taken as
.
Open in the MATLAB editor:
f02wd_example
function f02wd_example
fprintf('f02wd example results\n\n');
a = [ 22.25, 31.75,-38.25, 65.5;
20.00, 26.75, 28.50,-26.5;
-15.25, 24.25, 27.75, 18.5;
27.25, 10.00, 3.00, 2.00;
-17.25,-30.75, 11.25, 7.50;
17.25, 30.75,-11.25,-7.50];
wantb = false;
b = zeros(6,1);
tol = 0.0005;
svd = true;
wantr = true;
wantpt = true;
lwork = int64(24);
[a, b, svd, irank, z, sv, r, pt, work, ifail] = ...
f02wd( ...
a, wantb, b, tol, svd, wantr, wantpt, lwork);
fprintf('Rank of A is %2d\n\n', irank);
disp('Details of QU factorization');
disp(a);
disp('Vector z');
disp(z');
disp('Matrix R');
disp(r);
disp('Singular values');
disp(sv');
disp('Matrix P');
disp(pt');
f02wd example results
Rank of A is 4
Details of QU factorization
-49.6519 -44.4092 20.3542 -8.8818
0.4028 -48.2767 -9.5887 -20.3761
-0.3071 0.8369 52.9270 -48.8806
0.5488 -0.3907 -0.8364 -50.6742
-0.3474 -0.2585 -0.1851 0.6321
0.3474 0.2585 0.1851 -0.6321
Vector z
1.4481 1.1153 1.4817 1.4482
Matrix R
-0.5639 0.6344 0.4229 0.3172
-0.3512 0.3951 -0.6791 -0.5093
-0.6403 -0.5692 0.3095 -0.4126
-0.3855 -0.3427 -0.5140 0.6854
Singular values
91.0000 68.2500 45.5000 22.7500
Matrix P
0.3077 -0.4615 -0.4615 -0.6923
0.4615 -0.6923 0.3077 0.4615
-0.4615 -0.3077 0.6923 -0.4615
0.6923 0.4615 0.4615 -0.3077
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015