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_zgesdd (f08kr)

Purpose

nag_lapack_zgesdd (f08kr) computes the singular value decomposition (SVD) of a complex mm by nn matrix AA, optionally computing the left and/or right singular vectors, by using a divide-and-conquer method.

Syntax

[a, s, u, vt, info] = f08kr(jobz, a, 'm', m, 'n', n)
[a, s, u, vt, info] = nag_lapack_zgesdd(jobz, a, 'm', m, 'n', n)

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:     jobz – string (length ≥ 1)
Specifies options for computing all or part of the matrix UU.
jobz = 'A'jobz='A'
All mm columns of UU and all nn rows of VHVH are returned in the arrays u and vt.
jobz = 'S'jobz='S'
The first min (m,n)min(m,n) columns of UU and the first min (m,n)min(m,n) rows of VHVH are returned in the arrays u and vt.
jobz = 'O'jobz='O'
If mnmn, the first nn columns of UU are overwritten on the array a and all rows of VHVH are returned in the array vt. Otherwise, all columns of UU are returned in the array u and the first mm rows of VHVH are overwritten in the array vt.
jobz = 'N'jobz='N'
No columns of UU or rows of VHVH are computed.
Constraint: jobz = 'A'jobz='A', 'S''S', 'O''O' or 'N''N'.
2:     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 rwork iwork

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 jobz = 'O'jobz='O', a is overwritten with the first nn columns of UU (the left singular vectors, stored column-wise) if mnmn; a is overwritten with the first mm rows of VHVH (the right singular vectors, stored row-wise) otherwise.
If jobz'O'jobz'O', the contents of a are destroyed.
2:     s(min (m,n)min(m,n)) – double array
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 jobz = 'S'jobz='S' or 'A''A' or jobz = 'O'jobz='O' and m < nm<n, 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 jobz = 'A'jobz='A' or jobz = 'O'jobz='O' and m < nm<n, max (1,min (m,n))max(1,min(m,n)) if jobz = 'S'jobz='S', and at least 11 otherwise
If jobz = 'A'jobz='A' or jobz = 'O'jobz='O' and m < nm<n, u contains the mm by mm unitary matrix UU.
If jobz = 'S'jobz='S', u contains the first min (m,n)min(m,n) columns of UU (the left singular vectors, stored column-wise).
If jobz = 'O'jobz='O' and mnmn, or jobz = 'N'jobz='N', u is not referenced.
4:     vt(ldvt, : :) – complex array
The first dimension, ldvt, of the array vt will be
  • if jobz = 'A'jobz='A' or jobz = 'O'jobz='O' and mnmn, ldvt max (1,n) ldvt max(1,n) ;
  • if jobz = 'S'jobz='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 jobz = 'A'jobz='A' or 'S''S' or jobz = 'O'jobz='O' and mnmn, and at least 11 otherwise
If jobz = 'A'jobz='A' or jobz = 'O'jobz='O' and mnmn, vt contains the nn by nn unitary matrix VHVH.
If jobz = 'S'jobz='S', vt contains the first min (m,n)min(m,n) rows of VHVH (the right singular vectors, stored row-wise).
If jobz = 'O'jobz='O' and m < nm<n, or jobz = 'N'jobz='N', vt is not referenced.
5:     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: jobz, 2: m, 3: n, 4: a, 5: lda, 6: s, 7: u, 8: ldu, 9: vt, 10: ldvt, 11: work, 12: lwork, 13: rwork, 14: iwork, 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
nag_lapack_zgesdd (f08kr) did not converge, the updating process failed.

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_dgesdd (f08kd).

Example

function nag_lapack_zgesdd_example
jobz = 'Overwrite A by V**H';
a = [0,  -0.98 - 1.98i,  0.62 + 0.46i, ...
     -0.37 - 0.38i,  0.83 - 0.51i,  1.08 + 0.28i;
      0 + 0i,  -1.2 - 0.19i,  1.01 - 0.02i, ...
     0.19 + 0.54i,  0.2 - 0.01i,  0.2 + 0.12i;
      0 + 0i,  -0.66 - 0.42i,  0.63 + 0.17i, ...
     -0.98 + 0.36i,  -0.17 + 0.46i,  -0.07 - 1.23i;
      0 + 0i,  -0.81 - 0.56i, ...
     -1.11 - 0.6i,  0.22 + 0.2i,  1.47 - 1.59i,  0.26 - 0.26i];
[aOut, s, u, vt, info] = nag_lapack_zgesdd(jobz, a)
 

aOut =

  Columns 1 through 5

  -0.0000 - 0.0000i  -0.3233 - 0.7034i   0.1445 + 0.0453i  -0.1596 - 0.0295i   0.4588 - 0.1374i
   0.0000 - 0.0000i   0.0032 - 0.1689i   0.0278 + 0.6309i  -0.2002 - 0.2784i  -0.6182 - 0.1634i
   0.0000 + 0.0000i   0.2192 - 0.1445i  -0.4367 - 0.0070i  -0.4944 + 0.0989i   0.1108 + 0.0403i
  -0.0000 - 0.0000i   0.0822 + 0.1707i  -0.2149 + 0.2811i   0.1419 + 0.6596i   0.0497 + 0.1586i

  Column 6

   0.3490 + 0.0153i
   0.2053 - 0.0638i
  -0.2256 - 0.6490i
   0.5933 - 0.0641i


s =

    3.5551
    2.7026
    1.4892
    0.2650


u =

   0.7658 + 0.0000i   0.2193 + 0.0000i  -0.2761 + 0.0000i  -0.5379 + 0.0000i
   0.2208 - 0.2391i  -0.0863 - 0.3034i  -0.5495 - 0.2629i   0.5613 - 0.3292i
   0.1600 - 0.1855i   0.1419 - 0.5253i   0.6538 - 0.0326i  -0.0500 - 0.4615i
   0.3957 - 0.3018i  -0.3686 + 0.6484i   0.3440 - 0.0768i   0.2365 - 0.1259i


vt =

  8.9122e-317 +1.5066e-312i


info =

                    0


function f08kr_example
jobz = 'Overwrite A by V**H';
a = [0,  -0.98 - 1.98i,  0.62 + 0.46i, ...
     -0.37 - 0.38i,  0.83 - 0.51i,  1.08 + 0.28i;
      0 + 0i,  -1.2 - 0.19i,  1.01 - 0.02i, ...
     0.19 + 0.54i,  0.2 - 0.01i,  0.2 + 0.12i;
      0 + 0i,  -0.66 - 0.42i,  0.63 + 0.17i, ...
     -0.98 + 0.36i,  -0.17 + 0.46i,  -0.07 - 1.23i;
      0 + 0i,  -0.81 - 0.56i, ...
     -1.11 - 0.6i,  0.22 + 0.2i,  1.47 - 1.59i,  0.26 - 0.26i];
[aOut, s, u, vt, info] = f08kr(jobz, a)
 

aOut =

  Columns 1 through 5

  -0.0000 - 0.0000i  -0.3233 - 0.7034i   0.1445 + 0.0453i  -0.1596 - 0.0295i   0.4588 - 0.1374i
   0.0000 - 0.0000i   0.0032 - 0.1689i   0.0278 + 0.6309i  -0.2002 - 0.2784i  -0.6182 - 0.1634i
   0.0000 + 0.0000i   0.2192 - 0.1445i  -0.4367 - 0.0070i  -0.4944 + 0.0989i   0.1108 + 0.0403i
  -0.0000 - 0.0000i   0.0822 + 0.1707i  -0.2149 + 0.2811i   0.1419 + 0.6596i   0.0497 + 0.1586i

  Column 6

   0.3490 + 0.0153i
   0.2053 - 0.0638i
  -0.2256 - 0.6490i
   0.5933 - 0.0641i


s =

    3.5551
    2.7026
    1.4892
    0.2650


u =

   0.7658 + 0.0000i   0.2193 + 0.0000i  -0.2761 + 0.0000i  -0.5379 + 0.0000i
   0.2208 - 0.2391i  -0.0863 - 0.3034i  -0.5495 - 0.2629i   0.5613 - 0.3292i
   0.1600 - 0.1855i   0.1419 - 0.5253i   0.6538 - 0.0326i  -0.0500 - 0.4615i
   0.3957 - 0.3018i  -0.3686 + 0.6484i   0.3440 - 0.0768i   0.2365 - 0.1259i


vt =

  2.3168e-312 + 0.0000e+00i


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