NAG FL Interface
f02wuf (real_triang_svd)
1
Purpose
f02wuf returns all, or part, of the singular value decomposition of a real upper triangular matrix.
2
Specification
Fortran Interface
Subroutine f02wuf ( |
n, a, lda, ncolb, b, ldb, wantq, q, ldq, sv, wantp, work, ifail) |
Integer, Intent (In) |
:: |
n, lda, ncolb, ldb, ldq |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (Inout) |
:: |
a(lda,*), b(ldb,*), q(ldq,*), work(*) |
Real (Kind=nag_wp), Intent (Out) |
:: |
sv(n) |
Logical, Intent (In) |
:: |
wantq, wantp |
|
C Header Interface
#include <nag.h>
void |
f02wuf_ (const Integer *n, double a[], const Integer *lda, const Integer *ncolb, double b[], const Integer *ldb, const logical *wantq, double q[], const Integer *ldq, double sv[], const logical *wantp, double work[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
f02wuf_ (const Integer &n, double a[], const Integer &lda, const Integer &ncolb, double b[], const Integer &ldb, const logical &wantq, double q[], const Integer &ldq, double sv[], const logical &wantp, double work[], Integer &ifail) |
}
|
The routine may be called by the names f02wuf or nagf_eigen_real_triang_svd.
3
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 routine 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
.
4
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
5
Arguments
-
1:
– Integer
Input
-
On entry:
, the order of the matrix
.
If , an immediate return is effected.
Constraint:
.
-
2:
– Real (Kind=nag_wp) array
Input/Output
-
Note: the second dimension of the array
a
must be at least
.
On entry: the leading
by
upper triangular part of the array
a must contain the upper triangular matrix
.
On exit: 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.
-
3:
– Integer
Input
-
On entry: the first dimension of the array
a as declared in the (sub)program from which
f02wuf is called.
Constraint:
.
-
4:
– Integer
Input
-
On entry:
, the number of columns of the matrix
.
If
, the array
b is not referenced.
Constraint:
.
-
5:
– Real (Kind=nag_wp) array
Input/Output
-
Note: the second dimension of the array
b
must be at least
.
On entry: with
, the leading
by
part of the array
b must contain the matrix to be transformed.
On exit: the leading
by
part of the array
b is overwritten by the matrix
.
-
6:
– Integer
Input
-
On entry: the first dimension of the array
b as declared in the (sub)program from which
f02wuf is called.
Constraints:
- if , ;
- otherwise .
-
7:
– Logical
Input
-
On entry: must be .TRUE. if the matrix
is required.
If
, the array
q is not referenced.
-
8:
– Real (Kind=nag_wp) array
Output
-
Note: the second dimension of the array
q
must be at least
if
, and at least
otherwise.
On exit: with
, the leading
by
part of the array
q will contain the orthogonal matrix
. Otherwise the array
q is not referenced.
-
9:
– Integer
Input
-
On entry: the first dimension of the array
q as declared in the (sub)program from which
f02wuf is called.
Constraints:
- if , ;
- otherwise .
-
10:
– Real (Kind=nag_wp) array
Output
-
On exit:
- If the array sv will contain the diagonal elements of the matrix.
- If the array sv will contain the diagonal elements of the bidiagonal matrix in the factorization ; the superdiagonal elements of will be contained in the first elements of work.
-
11:
– Logical
Input
-
On entry: must be .TRUE. if the matrix
is required, in which case
is overwritten on the array
a, otherwise
wantp must be .FALSE..
-
12:
– Real (Kind=nag_wp) array
Output
-
Note: the dimension of the array
work
must be at least
if
and
and
,
if (
and
and
) or (
and (
or
)), and at least
otherwise.
On exit:
contains the super-diagonal elements of the bidiagonal matrix
computed during the bidiagonalization stage;
contains the total number of iterations taken by the
algorithm.
The rest of the array is used as internal workspace.
-
13:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
The algorithm has failed to converge. singular values have not been found.
-
On entry, and .
Constraint: .
On entry, , and .
Constraint: if , .
On entry, and .
Constraint: if , .
On entry, .
Constraint: .
On entry, .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
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
.
8
Parallelism and Performance
f02wuf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f02wuf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
For given values of
ncolb,
wantq and
wantp, the number of floating-point operations required is approximately proportional to
.
Following the use of this routine the rank of
may be estimated by a call to
f06klf. The statement
irank = f06klf(n,sv,1,tol)
returns the value
in
irank, where
is the smallest integer for which
, and
is the tolerance supplied in
tol, so that
irank is an estimate of the rank of
and thus also of
. If
tol is supplied as negative then the
machine precision is used in place of
tol.
10
Example
This example finds the singular value decomposition of the
by
upper triangular matrix
together with the vector
for the vector
10.1
Program Text
10.2
Program Data
10.3
Program Results