hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_lapack_zgesvd (f08kp)

Purpose

nag_lapack_zgesvd (f08kp) computes the singular value decomposition (SVD) of a complex mm by nn matrix AA, optionally computing the left and/or right singular vectors.

Syntax

[a, s, u, vt, rwork, info] = f08kp(jobu, jobvt, a, 'm', m, 'n', n)
[a, s, u, vt, rwork, info] = nag_lapack_zgesvd(jobu, jobvt, a, 'm', m, 'n', n)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: rwork is now an output parameter
.

Description

The SVD is written as
A = UΣVH ,
A = UΣVH ,
where ΣΣ is an mm by nn matrix which is zero except for its min (m,n)min(m,n) diagonal elements, UU is an mm by mm unitary matrix, and VV is an nn by nn unitary matrix. The diagonal elements of ΣΣ are the singular values of AA; they are real and non-negative, and are returned in descending order. The first min (m,n)min(m,n) columns of UU and VV are the left and right singular vectors of AA.
Note that the function returns VHVH, not VV.

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

Parameters

Compulsory Input Parameters

1:     jobu – string (length ≥ 1)
Specifies options for computing all or part of the matrix UU.
jobu = 'A'jobu='A'
All mm columns of UU are returned in array u.
jobu = 'S'jobu='S'
The first min (m,n)min(m,n) columns of UU (the left singular vectors) are returned in the array u.
jobu = 'O'jobu='O'
The first min (m,n)min(m,n) columns of UU (the left singular vectors) are overwritten on the array a.
jobu = 'N'jobu='N'
No columns of UU (no left singular vectors) are computed.
Constraint: jobu = 'A'jobu='A', 'S''S', 'O''O' or 'N''N'.
2:     jobvt – string (length ≥ 1)
Specifies options for computing all or part of the matrix VHVH.
jobvt = 'A'jobvt='A'
All nn rows of VHVH are returned in the array vt.
jobvt = 'S'jobvt='S'
The first min (m,n)min(m,n) rows of VHVH (the right singular vectors) are returned in the array vt.
jobvt = 'O'jobvt='O'
The first min (m,n)min(m,n) rows of VHVH (the right singular vectors) are overwritten on the array a.
jobvt = 'N'jobvt='N'
No rows of VHVH (no right singular vectors) are computed.
Constraints:
  • jobvt = 'A'jobvt='A', 'S''S', 'O''O' or 'N''N';
  • jobvt and jobu cannot both be 'O''O'.
3:     a(lda, : :) – complex array
The first dimension of the array a must be at least max (1,m)max(1,m)
The second dimension of the array must be at least max (1,n)max(1,n)
The mm by nn matrix AA.

Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array a.
mm, the number of rows of the matrix AA.
Constraint: m0m0.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array a.
nn, the number of columns of the matrix AA.
Constraint: n0n0.

Input Parameters Omitted from the MATLAB Interface

lda ldu ldvt work lwork

Output Parameters

1:     a(lda, : :) – complex array
The first dimension of the array a will be max (1,m)max(1,m)
The second dimension of the array will be max (1,n)max(1,n)
ldamax (1,m)ldamax(1,m).
If jobu = 'O'jobu='O', a is overwritten with the first min (m,n)min(m,n) columns of UU (the left singular vectors, stored column-wise).
If jobvt = 'O'jobvt='O', a is overwritten with the first min (m,n)min(m,n) rows of VHVH (the right singular vectors, stored row-wise).
If jobu'O'jobu'O' and jobvt'O'jobvt'O', the contents of a are destroyed.
2:     s( : :) – double array
Note: the dimension of the array s must be at least max (1,min (m,n)) max(1,min(m,n)) .
The singular values of AA, sorted so that s(i)s(i + 1)sisi+1.
3:     u(ldu, : :) – complex array
The first dimension, ldu, of the array u will be
  • if jobu = 'A'jobu='A' or 'S''S', ldu max (1,m) ldu max(1,m) ;
  • otherwise ldu1ldu1.
The second dimension of the array will be max (1,m)max(1,m) if jobu = 'A'jobu='A', max (1,min (m,n))max(1,min(m,n)) if jobu = 'S'jobu='S', and at least 11 otherwise
If jobu = 'A'jobu='A', u contains the mm by mm unitary matrix UU.
If jobu = 'S'jobu='S', u contains the first min (m,n)min(m,n) columns of UU (the left singular vectors, stored column-wise).
If jobu = 'N'jobu='N' or 'O''O', u is not referenced.
4:     vt(ldvt, : :) – complex array
The first dimension, ldvt, of the array vt will be
  • if jobvt = 'A'jobvt='A', ldvt max (1,n) ldvt max(1,n) ;
  • if jobvt = 'S'jobvt='S', ldvt max (1,min (m,n)) ldvt max(1,min(m,n)) ;
  • otherwise ldvt1ldvt1.
The second dimension of the array will be max (1,n)max(1,n) if jobvt = 'A'jobvt='A' or 'S''S', and at least 11 otherwise
If jobvt = 'A'jobvt='A', vt contains the nn by nn unitary matrix VHVH.
If jobvt = 'S'jobvt='S', vt contains the first min (m,n)min(m,n) rows of VHVH (the right singular vectors, stored row-wise).
If jobvt = 'N'jobvt='N' or 'O''O', vt is not referenced.
5:     rwork( : :) – double array
Note: the dimension of the array rwork must be at least max (1, 5 × min (m,n) ) max(1, 5×min(m,n) ) .
If INFO > 0INFO>0, rwork(1 : min (m,n)1)rwork1:min(m,n)-1 contains the unconverged superdiagonal elements of an upper bidiagonal matrix BB whose diagonal is in SS (not necessarily sorted). BB satisfies A = UBVHA=UBVH, so it has the same singular values as AA, and singular vectors related by UU and VHVH.
6:     info – int64int32nag_int scalar
info = 0info=0 unless the function detects an error (see Section [Error Indicators and Warnings]).

Error Indicators and Warnings

  info = iinfo=-i
If info = iinfo=-i, parameter ii had an illegal value on entry. The parameters are numbered as follows:
1: jobu, 2: jobvt, 3: m, 4: n, 5: a, 6: lda, 7: s, 8: u, 9: ldu, 10: vt, 11: ldvt, 12: work, 13: lwork, 14: rwork, 15: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
  INFO > 0INFO>0
If nag_lapack_zgesvd (f08kp) did not converge, info specifies how many superdiagonals of an intermediate bidiagonal form did not converge to zero. See the description of rwork above for details.

Accuracy

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

Further Comments

The total number of floating point operations is approximately proportional to mn2 mn2  when m > nm>n and m2n m2n  otherwise.
The singular values are returned in descending order.
The real analogue of this function is nag_lapack_dgesvd (f08kb).

Example

function nag_lapack_zgesvd_example
jobu = 'Overwrite A by U';
jobvt = 'Singular vectors (V)';
a = [ 0.96 - 0.81i,  -0.03 + 0.96i,  -0.91 + 2.06i,  -0.05 + 0.41i;
      -0.98 + 1.98i,  -1.2 + 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.6i;
      -0.37 + 0.38i,  0.19 - 0.54i,  -0.98 - 0.36i,  0.22 - 0.2i;
      0.83 + 0.51i,  0.2 + 0.01i,  -0.17 - 0.46i,  1.47 + 1.59i;
      1.08 - 0.28i,  0.2 - 0.12i,  -0.07 + 1.23i,  0.26 + 0.26i];
[aOut, s, u, vt, rwork, info] = nag_lapack_zgesvd(jobu, jobvt, a)
 

aOut =

  -0.5634 + 0.0016i   0.2687 + 0.2749i  -0.2451 - 0.4657i  -0.3787 - 0.2987i
   0.1205 - 0.6108i   0.2909 - 0.1085i  -0.4329 + 0.1758i   0.0182 + 0.0437i
  -0.0816 + 0.1613i   0.1660 - 0.3885i   0.4667 - 0.3821i   0.0800 + 0.2276i
   0.1441 - 0.1532i  -0.1984 + 0.1737i   0.0034 - 0.1555i  -0.2608 + 0.5382i
  -0.2487 - 0.0926i  -0.6253 - 0.3304i  -0.2643 + 0.0194i  -0.1002 - 0.0140i
  -0.3758 + 0.0793i   0.0307 + 0.0816i  -0.1266 - 0.1747i   0.4175 + 0.4058i


s =

    3.9994
    3.0003
    1.9944
    0.9995


u =

   0.0000 + 0.0000i


vt =

  -0.6971 + 0.0000i  -0.0867 - 0.3548i   0.0560 - 0.5400i  -0.1878 - 0.2253i
  -0.2403 + 0.0000i  -0.0725 + 0.2336i   0.2477 + 0.5291i  -0.7026 - 0.2177i
   0.5123 + 0.0000i   0.3030 + 0.1735i  -0.0678 - 0.5162i  -0.4418 - 0.3864i
   0.4403 + 0.0000i  -0.5294 - 0.6361i   0.3027 + 0.0346i  -0.1667 - 0.0258i


rwork =

     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0


info =

                    0


function f08kp_example
jobu = 'Overwrite A by U';
jobvt = 'Singular vectors (V)';
a = [ 0.96 - 0.81i,  -0.03 + 0.96i,  -0.91 + 2.06i,  -0.05 + 0.41i;
      -0.98 + 1.98i,  -1.2 + 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.6i;
      -0.37 + 0.38i,  0.19 - 0.54i,  -0.98 - 0.36i,  0.22 - 0.2i;
      0.83 + 0.51i,  0.2 + 0.01i,  -0.17 - 0.46i,  1.47 + 1.59i;
      1.08 - 0.28i,  0.2 - 0.12i,  -0.07 + 1.23i,  0.26 + 0.26i];
[aOut, s, u, vt, rwork, info] = f08kp(jobu, jobvt, a)
 

aOut =

  -0.5634 + 0.0016i   0.2687 + 0.2749i  -0.2451 - 0.4657i  -0.3787 - 0.2987i
   0.1205 - 0.6108i   0.2909 - 0.1085i  -0.4329 + 0.1758i   0.0182 + 0.0437i
  -0.0816 + 0.1613i   0.1660 - 0.3885i   0.4667 - 0.3821i   0.0800 + 0.2276i
   0.1441 - 0.1532i  -0.1984 + 0.1737i   0.0034 - 0.1555i  -0.2608 + 0.5382i
  -0.2487 - 0.0926i  -0.6253 - 0.3304i  -0.2643 + 0.0194i  -0.1002 - 0.0140i
  -0.3758 + 0.0793i   0.0307 + 0.0816i  -0.1266 - 0.1747i   0.4175 + 0.4058i


s =

    3.9994
    3.0003
    1.9944
    0.9995


u =

   0.0000 + 0.0000i


vt =

  -0.6971 + 0.0000i  -0.0867 - 0.3548i   0.0560 - 0.5400i  -0.1878 - 0.2253i
  -0.2403 + 0.0000i  -0.0725 + 0.2336i   0.2477 + 0.5291i  -0.7026 - 0.2177i
   0.5123 + 0.0000i   0.3030 + 0.1735i  -0.0678 - 0.5162i  -0.4418 - 0.3864i
   0.4403 + 0.0000i  -0.5294 - 0.6361i   0.3027 + 0.0346i  -0.1667 - 0.0258i


rwork =

     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0
     0


info =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013