PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_eigen_real_triang_svd (f02wu)
Purpose
nag_eigen_real_triang_svd (f02wu) returns all, or part, of the singular value decomposition of a real upper triangular matrix.
Syntax
[
a,
b,
q,
sv,
work,
ifail] = f02wu(
a,
b,
wantq,
wantp, 'n',
n, 'ncolb',
ncolb)
[
a,
b,
q,
sv,
work,
ifail] = nag_eigen_real_triang_svd(
a,
b,
wantq,
wantp, 'n',
n, 'ncolb',
ncolb)
Description
The
by
upper triangular matrix
is factorized as
where
and
are
by
orthogonal matrices and
is an
by
diagonal matrix with non-negative diagonal elements,
, ordered such that
The columns of
are the left-hand singular vectors of
, the diagonal elements of
are the singular values of
and the columns of
are the right-hand singular vectors of
.
Either or both of
and
may be requested and the matrix
given by
where
is an
by
given matrix, may also be requested.
The function obtains the singular value decomposition by first reducing to bidiagonal form by means of Givens plane rotations and then using the algorithm to obtain the singular value decomposition of the bidiagonal form.
Note that if
is any orthogonal diagonal matrix so that
(that is the diagonal elements of
are
or
) then
is also a singular value decomposition of
.
References
Chan T F (1982) An improved algorithm for computing the singular value decomposition ACM Trans. Math. Software 8 72–83
Dongarra J J, Moler C B, Bunch J R and Stewart G W (1979) LINPACK Users' Guide SIAM, Philadelphia
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl. 20(3) 2–25
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
-
The first dimension of the array
a must be at least
.
The second dimension of the array
a must be at least
.
The leading
by
upper triangular part of the array
a must contain the upper triangular matrix
.
- 2:
– double array
-
The first dimension,
, of the array
b must satisfy
- if , ;
- otherwise .
The second dimension of the array
b must be at least
.
With
, the leading
by
part of the array
b must contain the matrix to be transformed.
- 3:
– logical scalar
-
Must be
true if the matrix
is required.
If
, the array
q is not referenced.
- 4:
– logical scalar
-
Must be
true if the matrix
is required, in which case
is overwritten on the array
a, otherwise
wantp must be
false.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
a and the second dimension of the array
a.
, the order of the matrix
.
If , an immediate return is effected.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
b.
, the number of columns of the matrix
.
If
, the array
b is not referenced.
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
by
part of
a will contain the
by
orthogonal matrix
, otherwise the
by
upper triangular part of
a is used as internal workspace, but the strictly lower triangular part of
a is not referenced.
- 2:
– double array
-
The first dimension,
, of the array
b will be
- if , ;
- otherwise .
The second dimension of the array
b will be
.
The leading
by
part of the array
b stores the matrix
.
- 3:
– double array
-
The first dimension,
, of the array
q will be
- if , ;
- otherwise .
The second dimension of the array
q will be
if
and
otherwise.
With
, the leading
by
part of the array
q will contain the orthogonal matrix
. Otherwise the array
q is not referenced.
- 4:
– double array
-
The array
sv will contain the
diagonal elements of the matrix
.
- 5:
– double array
-
The dimension of the array
work will be
if
and
and
,
if (
and
and
) or (
and (
or
)) and
otherwise
contains the total number of iterations taken by the
algorithm.
The rest of the array is used as internal workspace.
- 6:
– 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:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
On entry, | , |
or | , |
or | , |
or | and , |
or | and . |
- W
-
The algorithm has failed to converge in iterations. In this case may not have been found correctly and the remaining singular values may not be the smallest. The matrix will nevertheless have been factorized as , where is a bidiagonal matrix with as the diagonal elements and as the superdiagonal elements.
This failure is not likely to occur.
-
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 relation
where
is the
machine precision,
is a modest function of
and
denotes the spectral (two) norm. Note that
.
A similar result holds for the computed matrix .
The computed matrix
satisfies the relation
where
is exactly orthogonal and
where
is a modest function of
. A similar result holds for
.
Further Comments
For given values of
ncolb,
wantq and
wantp, the number of floating-point operations required is approximately proportional to
.
>Following the use of
nag_eigen_real_triang_svd (f02wu) the rank of
may be estimated as follows:
tol = eps;
irank = 1;
while (irank <= numel(sv) && sv(irank) >= tol*sv(1) )
irank = irank + 1;
end
returns the value
in
irank,
where
is the smallest integer for which
, where
is typically the
machine precision,
so that
irank is an estimate of the rank of
and thus also of
.
Example
This example finds the singular value decomposition of the
by
upper triangular matrix
together with the vector
for the vector
Open in the MATLAB editor:
f02wu_example
function f02wu_example
fprintf('f02wu example results\n\n');
a = [-4, -2, -3;
0, -3, -2;
0, 0, -4];
b = [-1; -1; -1];
wantq = true;
wantp = true;
[a, b, q, sv, work, ifail] = f02wu( ...
a, b, wantq, wantp);
fprintf('Singular value decomposition of A\n\n');
disp('Singular values');
disp(sv');
disp('Left-hand singular vectors, by column');
disp(q);
disp('Right-hand singular vectors, by column');
disp(a');
disp('Vector Q''*B');
disp(b');
f02wu example results
Singular value decomposition of A
Singular values
6.5616 3.0000 2.4384
Left-hand singular vectors, by column
-0.7699 0.5883 -0.2471
-0.4324 -0.1961 0.8801
-0.4694 -0.7845 -0.4054
Right-hand singular vectors, by column
0.4694 -0.7845 0.4054
0.4324 -0.1961 -0.8801
0.7699 0.5883 0.2471
Vector Q'*B
1.6716 0.3922 -0.2276
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015