F08KBF (DGESVD) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

F08KBF (DGESVD)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

F08KBF (DGESVD) computes the singular value decomposition (SVD) of a real m by n matrix A, optionally computing the left and/or right singular vectors.

2  Specification

SUBROUTINE F08KBF ( JOBU, JOBVT, M, N, A, LDA, S, U, LDU, VT, LDVT, WORK, LWORK, INFO)
INTEGER  M, N, LDA, LDU, LDVT, LWORK, INFO
REAL (KIND=nag_wp)  A(LDA,*), S(*), U(LDU,*), VT(LDVT,*), WORK(max(1,LWORK))
CHARACTER(1)  JOBU, JOBVT
The routine may be called by its LAPACK name dgesvd.

3  Description

The SVD is written as
A = UΣVT ,
where Σ is an m by n matrix which is zero except for its minm,n diagonal elements, U is an m by m orthogonal matrix, and V is an n by n orthogonal matrix. The diagonal elements of Σ are the singular values of A; they are real and non-negative, and are returned in descending order. The first minm,n columns of U and V are the left and right singular vectors of A.
Note that the routine returns VT, not V.

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 http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

5  Parameters

Note: in the descriptions below, ucol is the number of columns of U requested.
1:     JOBU – CHARACTER(1)Input
On entry: specifies options for computing all or part of the matrix U.
JOBU='A'
All m columns of U are returned in array U.
JOBU='S'
The first minm,n columns of U (the left singular vectors) are returned in the array U.
JOBU='O'
The first minm,n columns of U (the left singular vectors) are overwritten on the array A.
JOBU='N'
No columns of U (no left singular vectors) are computed.
Constraint: JOBU='A', 'S', 'O' or 'N'.
2:     JOBVT – CHARACTER(1)Input
On entry: specifies options for computing all or part of the matrix VT.
JOBVT='A'
All n rows of VT are returned in the array VT.
JOBVT='S'
The first minm,n rows of VT (the right singular vectors) are returned in the array VT.
JOBVT='O'
The first minm,n rows of VT (the right singular vectors) are overwritten on the array A.
JOBVT='N'
No rows of VT (no right singular vectors) are computed.
JOBVT and JOBU cannot both be 'O'.
Constraint: JOBVT='A', 'S', 'O' or 'N'.
3:     M – INTEGERInput
On entry: m, the number of rows of the matrix A.
Constraint: M0.
4:     N – INTEGERInput
On entry: n, the number of columns of the matrix A.
Constraint: N0.
5:     A(LDA,*) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array A must be at least max1,N.
On entry: the m by n matrix A.
On exit: if JOBU='O', A is overwritten with the first minm,n columns of U (the left singular vectors, stored column-wise).
If JOBVT='O', A is overwritten with the first minm,n rows of VT (the right singular vectors, stored row-wise).
If JOBU'O' and JOBVT'O', the contents of A are destroyed.
6:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08KBF (DGESVD) is called.
Constraint: LDAmax1,M.
7:     S(*) – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array S must be at least max1,minM,N .
On exit: the singular values of A, sorted so that SiSi+1.
8:     U(LDU,*) – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array U must be at least max1,ucol if JOBU='A' or 'S', and at least 1 otherwise.
On exit: if JOBU='A', U contains the m by m matrix U.
If JOBU='S', U contains the first minm,n columns of U (the left singular vectors, stored column-wise).
If JOBU='N' or 'O', U is not referenced.
9:     LDU – INTEGERInput
On entry: the first dimension of the array U as declared in the (sub)program from which F08KBF (DGESVD) is called.
Constraints:
  • if JOBU='A' or 'S', LDUmax1,M;
  • otherwise LDU1.
10:   VT(LDVT,*) – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array VT must be at least max1,N if JOBVT='A', max1,minM,N if JOBVT='S', and at least 1 otherwise.
On exit: if JOBVT='A', VT contains the n by n orthogonal matrix VT.
If JOBVT='S', VT contains the first minm,n rows of VT (the right singular vectors, stored row-wise).
If JOBVT='N' or 'O', VT is not referenced.
11:   LDVT – INTEGERInput
On entry: the first dimension of the array VT as declared in the (sub)program from which F08KBF (DGESVD) is called.
Constraints:
  • if JOBVT='A', LDVTmax1,N;
  • if JOBVT='S', LDVTmax1,minM,N;
  • otherwise LDVT1.
12:   WORK(max1,LWORK) – REAL (KIND=nag_wp) arrayOutput
On exit: if INFO=0, WORK1 returns the optimal LWORK.
If INFO>0, WORK2:minM,N contains the unconverged superdiagonal elements of an upper bidiagonal matrix B whose diagonal is in S (not necessarily sorted). B satisfies A=UBVT, so it has the same singular values as A, and singular vectors related by U and VT.
13:   LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08KBF (DGESVD) is called.
If LWORK=-1, a workspace query is assumed; the routine only calculates the optimal size of the WORK array, returns this value as the first entry of the WORK array, and no error message related to LWORK is issued.
Suggested value: for optimal performance, LWORK should generally be larger. Consider increasing LWORK by at least nb×minM,N , where nb  is the optimal block size.
Constraint: LWORK max1, 3 × minM,N + maxM,N , 5 × minM,N .
14:   INFO – INTEGEROutput

6  Error Indicators and Warnings

Errors or warnings detected by the routine:
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
If F08KBF (DGESVD) did not converge, INFO specifies how many superdiagonals of an intermediate bidiagonal form did not converge to zero. See the description of WORK above for details.

7  Accuracy

The computed singular value decomposition is nearly the exact singular value decomposition for a nearby matrix A+E , where
E2 = Oε A2 ,
and ε  is the machine precision. In addition, the computed singular vectors are nearly orthogonal to working precision. See Section 4.9 of
Anderson et al. (1999) for further details.

8  Further Comments

The total number of floating point operations is approximately proportional to mn2  when m>n and m2n  otherwise.
The singular values are returned in descending order.
The complex analogue of this routine is F08KPF (ZGESVD).

9  Example

This example finds the singular values and left and right singular vectors of the 6 by 4 matrix
A = 2.27 -1.54 1.15 -1.94 0.28 -1.67 0.94 -0.78 -0.48 -3.09 0.99 -0.21 1.07 1.22 0.79 0.63 -2.35 2.93 -1.45 2.30 0.62 -7.39 1.03 -2.57 ,
together with approximate error bounds for the computed singular values and vectors.
The example program for F08KDF (DGESDD) illustrates finding a singular value decomposition for the case mn.

9.1  Program Text

Program Text (f08kbfe.f90)

9.2  Program Data

Program Data (f08kbfe.d)

9.3  Program Results

Program Results (f08kbfe.r)


F08KBF (DGESVD) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2011