NAG FL Interface
f08kwf (zgesvj)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

f08kwf computes the one-sided Jacobi singular value decomposition (SVD) of a complex m×n, general or triangular, matrix A, mn, with fast scaled rotations and de Rijk’s pivoting, optionally computing the left and/or right singular vectors. For m<n, 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)
The routine may be called by the names f08kwf, nagf_lapackeig_zgesvj or its LAPACK name zgesvj.

3 Description

The SVD is written as
A = UΣVH ,  
where Σ is an n×n diagonal matrix, U is an m×n unitary matrix, and V is an n×n unitary matrix. The diagonal elements of Σ are the singular values of A in descending order of magnitude. The columns of U and V are the left and the right singular vectors of A, 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: joba Character(1) Input
On entry: specifies the structure of matrix A.
joba='L'
The input matrix A is lower triangular.
joba='U'
The input matrix A is upper triangular.
joba='G'
The input matrix A is a general m×n matrix, mn.
Constraint: joba='L', 'U' or 'G'.
2: jobu 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.
jobu='U'
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 tol=m×ε, where ε is the machine precision.
jobu='C'
Analogous to jobu='U', except that you can control the level of numerical orthogonality of the computed left singular vectors. The orthogonality threshold is set to tol=ctol×ε, where ctol is given on input in rwork(1). The option jobu='C' can be used if m×ε is a satisfactory orthogonality of the computed left singular vectors, so ctol=m could save a few sweeps of Jacobi rotations. See the descriptions of a and rwork(1).
jobu='N'
The matrix U is not computed. However, see the description of a.
Constraint: jobu='U', 'C' or 'N'.
3: jobv Character(1) Input
On entry: specifies whether and how to compute the right singular vectors.
jobv='V'
The matrix V is computed and returned in the array v.
jobv='A'
The Jacobi rotations are applied to the leading mv×n part of the array v. In other words, the right singular vector matrix V is not computed explicitly, instead it is applied to an mv×n matrix initially stored in the first mv rows of v.
jobv='N'
The matrix V is not computed and the array v is not referenced.
Constraint: jobv='V', 'A' or 'N'.
4: m Integer Input
On entry: m, the number of rows of the matrix A.
Constraint: m0.
5: n Integer Input
On entry: n, the number of columns of the matrix A.
Constraint: mn0.
6: a(lda,*) Complex (Kind=nag_wp) array Input/Output
Note: the second dimension of the array a must be at least max(1,n).
On entry: the m×n matrix A.
On exit: the matrix U containing the left singular vectors of A.
If jobu='U' or 'C'
if info=0
rank(A) unitary columns of U are returned in the leading rank(A) columns of the array a. Here rank(A)n is the number of computed singular values of A 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 rank(A) is returned by rounding rwork(2) to the nearest whole number. Also see the descriptions of sva and rwork. The computed columns of U are mutually numerically unitary up to approximately tol=m×ε; or tol=ctol×ε (jobu='C'), where ε is the machine precision and ctol is supplied on entry in rwork(1), see the description of jobu.
if info>0
f08kwf did not converge in 30 iterations (sweeps). In this case, the computed columns of U may not be unitary up to tol. The output U (stored in a), Σ (given by the computed singular values in sva) and V is still a decomposition of the input matrix A in the sense that the residual A-α×U×Σ×VH2/A2 is small, where α is the value returned in rwork(1).
If jobu='N'
if info=0
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 U is not an issue and iterations are stopped when the columns of the iterated matrix are numerically unitary up to approximately m×ε. Thus, on exit, a contains the columns of U scaled with the corresponding singular values.
if info>0
f08kwf did not converge in 30 iterations (sweeps).
7: lda Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f08kwf is called.
Constraint: ldamax(1,m).
8: sva(n) Real (Kind=nag_wp) array Output
On exit: the, possibly scaled, singular values of A.
If info=0
The singular values of A are σi=α×sva(i), for i=1,2,,n, where α is the scale factor stored in rwork(1). Normally α=1, however, if some of the singular values of A might underflow or overflow, then α1 and the scale factor needs to be applied to obtain the singular values.
If info>0
f08kwf did not converge in 30 iterations and α×sva may not be accurate.
9: mv Integer Input
On entry: if jobv='A', the product of Jacobi rotations is applied to the first mv rows of v.
If jobv'A', mv is ignored. See the description of jobv.
Constraint: mv0.
10: v(ldv,*) Complex (Kind=nag_wp) array Input/Output
Note: the second dimension of the array v must be at least max(1,n) if jobv='V' or 'A', and at least 1 otherwise.
On entry: if jobv='A', v must contain an mv×n matrix to be premultiplied by the matrix V of right singular vectors.
On exit: the right singular vectors of A.
If jobv='V', v contains the n×n matrix of the right singular vectors.
If jobv='A', v contains the product of the computed right singular vector matrix and the initial matrix in the array v.
If jobv='N', v is not referenced.
11: ldv Integer Input
On entry: the first dimension of the array v as declared in the (sub)program from which f08kwf is called.
Constraints:
  • if jobv='V', ldvmax(1,n);
  • if jobv='A', ldvmax(1,mv);
  • otherwise ldv1.
12: cwork(lwork) Complex (Kind=nag_wp) array Workspace
On exit: if info=0, cwork(1) contains the required minimal size of lwork.
13: lwork Integer Input
On entry: the dimension of the array cwork as declared in the (sub)program from which f08kwf is called.
Constraint: lworkm+n.
14: rwork(lrwork) Real (Kind=nag_wp) array Workspace
On entry: if jobu='C', rwork(1)=ctol, where ctol defines the threshold for convergence. The process stops if all columns of A are mutually orthogonal up to ctol×ε. It is required that ctol1, i.e., it is not possible to force the routine to obtain orthogonality below ε. ctol greater than 1/ε is meaningless, where ε is the machine precision.
On exit: contains information about the completed job.
rwork(1)
The scaling factor, α, such that σi=α×sva(i), for i=1,2,,n, are the computed singular values of A. (See the description of sva.)
rwork(2)
rwork(2) gives, as nearest integer, the number of the computed nonzero singular values.
rwork(3)
rwork(3) gives, as nearest integer, the number of the computed singular values that are larger than the underflow threshold.
rwork(4)
rwork(4) gives, as nearest integer, the number of iterations (sweeps of Jacobi rotations) needed for numerical convergence.
rwork(5)
maxij|cos(A(:,i),A(:,j))| 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.
rwork(6)
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 jobu='C', rwork(1)1.0.
15: lrwork Integer Input
On entry: the dimension of the array rwork as declared in the (sub)program from which f08kwf is called.
Constraint: lrworkmax(6,n).
16: info Integer Output
On exit: info=0 unless the routine detects an error (see Section 6).

6 Error Indicators and Warnings

info<0
If info=-i, argument i had an illegal value. An explanatory message is output, and execution of the program is terminated.
info>0
f08kwf did not converge in the allowed number of iterations (30), but its output might still be useful.

7 Accuracy

The computed SVD is nearly the exact SVD for a nearby matrix (A+E) , where
E2 = O(ε) A2 ,  
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

Background information to multithreading can be found in the Multithreading documentation.
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.

9 Further Comments

This SVD algorithm is numerically superior to the bidiagonalization based QR 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 6×4 matrix
A = ( 0.96-0.81i -0.03+0.96i -0.91+2.06i -0.05+0.41i -0.98+1.98i -1.20+0.19i -0.66+0.42i -0.81+0.56i 0.62-0.46i 1.01+0.02i 0.63-0.17i -1.11+0.60i -0.37+0.38i 0.19-0.54i -0.98-0.36i 0.22-0.20i 0.83+0.51i 0.20+0.01i -0.17-0.46i 1.47+1.59i 1.08-0.28i 0.20-0.12i -0.07+1.23i 0.26+0.26i ) ,  
together with approximate error bounds for the computed singular values and vectors.

10.1 Program Text

Program Text (f08kwfe.f90)

10.2 Program Data

Program Data (f08kwfe.d)

10.3 Program Results

Program Results (f08kwfe.r)