NAG FL Interface
f08kwf (zgesvj)
1
Purpose
f08kwf computes the one-sided Jacobi singular value decomposition (SVD) of a complex
by
, general or triangular, matrix
,
, with fast scaled rotations and de Rijk’s pivoting, optionally computing the left and/or right singular vectors. For
, the routines
f08kpf or
f08krf may be used.
2
Specification
Fortran Interface
Subroutine f08kwf ( |
joba, jobu, jobv, m, n, a, lda, sva, mv, v, ldv, cwork, lwork, rwork, lrwork, info) |
Integer, Intent (In) |
:: |
m, n, lda, mv, ldv, lwork, lrwork |
Integer, Intent (Out) |
:: |
info |
Real (Kind=nag_wp), Intent (Inout) |
:: |
rwork(lrwork) |
Real (Kind=nag_wp), Intent (Out) |
:: |
sva(n) |
Complex (Kind=nag_wp), Intent (Inout) |
:: |
a(lda,*), v(ldv,*) |
Complex (Kind=nag_wp), Intent (Out) |
:: |
cwork(lwork) |
Character (1), Intent (In) |
:: |
joba, jobu, jobv |
|
C Header Interface
#include <nag.h>
void |
f08kwf_ (const char *joba, const char *jobu, const char *jobv, const Integer *m, const Integer *n, Complex a[], const Integer *lda, double sva[], const Integer *mv, Complex v[], const Integer *ldv, Complex cwork[], const Integer *lwork, double rwork[], const Integer *lrwork, Integer *info, const Charlen length_joba, const Charlen length_jobu, const Charlen length_jobv) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
f08kwf_ (const char *joba, const char *jobu, const char *jobv, const Integer &m, const Integer &n, Complex a[], const Integer &lda, double sva[], const Integer &mv, Complex v[], const Integer &ldv, Complex cwork[], const Integer &lwork, double rwork[], const Integer &lrwork, Integer &info, const Charlen length_joba, const Charlen length_jobu, const Charlen length_jobv) |
}
|
The routine may be called by the names f08kwf, nagf_lapackeig_zgesvj or its LAPACK name zgesvj.
3
Description
The SVD is written as
where
is an
by
diagonal matrix,
is an
by
unitary matrix, and
is an
by
unitary matrix. The diagonal elements of
are the singular values of
in descending order of magnitude. The columns of
and
are the left and the right singular vectors of
, respectively.
4
References
Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999)
LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia
https://www.netlib.org/lapack/lug
Drmač Z and Veselić K (2008a) New fast and accurate Jacobi SVD Algorithm I SIAM J. Matrix Anal. Appl. 29 4
Drmač Z and Veselić K (2008b) New fast and accurate Jacobi SVD Algorithm II SIAM J. Matrix Anal. Appl. 29 4
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
5
Arguments
-
1:
– Character(1)
Input
-
On entry: specifies the structure of matrix
.
- The input matrix is lower triangular.
- The input matrix is upper triangular.
- The input matrix is a general by matrix, .
Constraint:
, or .
-
2:
– Character(1)
Input
-
On entry: specifies whether to compute the left singular vectors and if so whether you want to control their numerical orthogonality threshold.
- The left singular vectors corresponding to the nonzero singular values are computed and returned in the leading columns of a. See more details in the description of a. The numerical orthogonality threshold is set to approximately , where is the machine precision.
- Analogous to , except that you can control the level of numerical orthogonality of the computed left singular vectors. The orthogonality threshold is set to , where is given on input in . The option can be used if is a satisfactory orthogonality of the computed left singular vectors, so could save a few sweeps of Jacobi rotations. See the descriptions of a and .
- The matrix is not computed. However, see the description of a.
Constraint:
, or .
-
3:
– Character(1)
Input
-
On entry: specifies whether and how to compute the right singular vectors.
- The matrix is computed and returned in the array v.
- The Jacobi rotations are applied to the leading by part of the array v. In other words, the right singular vector matrix is not computed explicitly, instead it is applied to an by matrix initially stored in the first mv rows of v.
- The matrix is not computed and the array v is not referenced.
Constraint:
, or .
-
4:
– Integer
Input
-
On entry: , the number of rows of the matrix .
Constraint:
.
-
5:
– Integer
Input
-
On entry: , the number of columns of the matrix .
Constraint:
.
-
6:
– Complex (Kind=nag_wp) array
Input/Output
-
Note: the second dimension of the array
a
must be at least
.
On entry: the by matrix .
On exit: the matrix
containing the left singular vectors of
.
- If or
-
- if
- unitary columns of are returned in the leading columns of the array a. Here is the number of computed singular values of that are above the safe range parameter, as returned by x02amf. The singular vectors corresponding to underflowed or zero singular values are not computed. The value of is returned by rounding to the nearest whole number. Also see the descriptions of sva and rwork. The computed columns of are mutually numerically unitary up to approximately ; or (), where is the machine precision and is supplied on entry in , see the description of jobu.
- if
- f08kwf did not converge in iterations (sweeps). In this case, the computed columns of may not be unitary up to . The output (stored in a), (given by the computed singular values in sva) and is still a decomposition of the input matrix in the sense that the residual is small, where is the value returned in .
- If
-
- if
- Note that the left singular vectors are ‘for free’ in the one-sided Jacobi SVD algorithm. However, if only the singular values are needed, the level of numerical orthogonality of is not an issue and iterations are stopped when the columns of the iterated matrix are numerically unitary up to approximately . Thus, on exit, a contains the columns of scaled with the corresponding singular values.
- if
- f08kwf did not converge in iterations (sweeps).
-
7:
– Integer
Input
-
On entry: the first dimension of the array
a as declared in the (sub)program from which
f08kwf is called.
Constraint:
.
-
8:
– Real (Kind=nag_wp) array
Output
-
On exit: the, possibly scaled, singular values of
.
- If
- The singular values of are
, for , where is the scale factor stored in . Normally , however, if some of the singular values of might underflow or overflow, then and the scale factor needs to be applied to obtain the singular values.
- If
- f08kwf did not converge in iterations and may not be accurate.
-
9:
– Integer
Input
-
On entry: if
, the product of Jacobi rotations is applied to the first
rows of
v.
If
,
mv is ignored. See the description of
jobv.
Constraint:
.
-
10:
– Complex (Kind=nag_wp) array
Input/Output
-
Note: the second dimension of the array
v
must be at least
if
or
, and at least
otherwise.
On entry: if
,
v must contain an
by
matrix to be premultiplied by the matrix
of right singular vectors.
On exit: the right singular vectors of
.
If
,
v contains the
by
matrix of the right singular vectors.
If
,
v contains the product of the computed right singular vector matrix and the initial matrix in the array
v.
If
,
v is not referenced.
-
11:
– Integer
Input
-
On entry: the first dimension of the array
v as declared in the (sub)program from which
f08kwf is called.
Constraints:
- if , ;
- if , ;
- otherwise .
-
12:
– Complex (Kind=nag_wp) array
Workspace
-
On exit: if
,
contains the required minimal size of
lwork.
-
13:
– Integer
Input
-
On entry: the dimension of the array
cwork as declared in the (sub)program from which
f08kwf is called.
Constraint:
.
-
14:
– Real (Kind=nag_wp) array
Workspace
-
On entry: if , , where defines the threshold for convergence. The process stops if all columns of are mutually orthogonal up to . It is required that , i.e., it is not possible to force the routine to obtain orthogonality below . greater than is meaningless, where is the machine precision.
On exit: contains information about the completed job.
- The scaling factor, , such that
, for , are the computed singular values of . (See the description of sva.)
- gives, as nearest integer, the number of the computed nonzero singular values.
- gives, as nearest integer, the number of the computed singular values that are larger than the underflow threshold.
- gives, as nearest integer, the number of iterations (sweeps of Jacobi rotations) needed for numerical convergence.
- in the last iteration (sweep). This is useful information in cases when f08kwf did not converge, as it can be used to estimate whether the output is still useful and for subsequent analysis.
- The largest absolute value over all sines of the Jacobi rotation angles in the last sweep. It can be useful for subsequent analysis.
Constraint:
if , .
-
15:
– Integer
Input
-
On entry: the dimension of the array
rwork as declared in the (sub)program from which
f08kwf is called.
Constraint:
.
-
16:
– Integer
Output
-
On exit:
unless the routine detects an error (see
Section 6).
6
Error Indicators and Warnings
If , argument had an illegal value. An explanatory message is output, and execution of the program is terminated.
-
f08kwf did not converge in the allowed number of iterations (), but its output might still be useful.
7
Accuracy
The computed SVD is nearly the exact SVD for a nearby matrix
, where
and
is the
machine precision. In addition, the computed singular vectors are nearly unitary to working precision. See Section 4.9 of
Anderson et al. (1999) for further details.
See Section 6 of
Drmač and Veselić (2008a) for a detailed discussion of the accuracy of the computed SVD.
8
Parallelism and Performance
f08kwf 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.
This SVD algorithm is numerically superior to the bidiagonalization based
algorithm implemented by
f08kpf and the divide and conquer algorithm implemented by
f08krf and is considerably faster than previous implementations of the (equally accurate) Jacobi SVD method. Moreover, this algorithm can compute the SVD faster than
f08kpf and not much slower than
f08krf. See Section 3.3 of
Drmač and Veselić (2008b) for the details.
The real analogue of this routine is
f08kjf.
10
Example
This example finds the singular values and left and right singular vectors of the
by
matrix
together with approximate error bounds for the computed singular values and vectors.
10.1
Program Text
10.2
Program Data
10.3
Program Results