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 m$m$ by n$n$ matrix A$A$, 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 Σ$\Sigma$ is an m$m$ by n$n$ matrix which is zero except for its min (m,n)$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$ diagonal elements, U$U$ is an m$m$ by m$m$ unitary matrix, and V$V$ is an n$n$ by n$n$ unitary matrix. The diagonal elements of Σ$\Sigma$ are the singular values of A$A$; they are real and non-negative, and are returned in descending order. The first min (m,n)$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$ columns of U$U$ and V$V$ are the left and right singular vectors of A$A$.
Note that the function returns VH${V}^{\mathrm{H}}$, not V$V$.

## 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 U$U$.
jobz = 'A'${\mathbf{jobz}}=\text{'A'}$
All m$m$ columns of U$U$ and all n$n$ rows of VH${V}^{\mathrm{H}}$ are returned in the arrays u and vt.
jobz = 'S'${\mathbf{jobz}}=\text{'S'}$
The first min (m,n)$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$ columns of U$U$ and the first min (m,n)$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$ rows of VH${V}^{\mathrm{H}}$ are returned in the arrays u and vt.
jobz = 'O'${\mathbf{jobz}}=\text{'O'}$
If mn${\mathbf{m}}\ge {\mathbf{n}}$, the first n$n$ columns of U$U$ are overwritten on the array a and all rows of VH${V}^{\mathrm{H}}$ are returned in the array vt. Otherwise, all columns of U$U$ are returned in the array u and the first m$m$ rows of VH${V}^{\mathrm{H}}$ are overwritten in the array vt.
jobz = 'N'${\mathbf{jobz}}=\text{'N'}$
No columns of U$U$ or rows of VH${V}^{\mathrm{H}}$ are computed.
Constraint: jobz = 'A'${\mathbf{jobz}}=\text{'A'}$, 'S'$\text{'S'}$, 'O'$\text{'O'}$ or 'N'$\text{'N'}$.
2:     a(lda, : $:$) – complex array
The first dimension of the array a must be at least max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The m$m$ by n$n$ matrix A$A$.

### Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array a.
m$m$, the number of rows of the matrix A$A$.
Constraint: m0${\mathbf{m}}\ge 0$.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array a.
n$n$, the number of columns of the matrix A$A$.
Constraint: n0${\mathbf{n}}\ge 0$.

### 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)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
ldamax (1,m)$\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
If jobz = 'O'${\mathbf{jobz}}=\text{'O'}$, a is overwritten with the first n$n$ columns of U$U$ (the left singular vectors, stored column-wise) if mn${\mathbf{m}}\ge {\mathbf{n}}$; a is overwritten with the first m$m$ rows of VH${V}^{\mathrm{H}}$ (the right singular vectors, stored row-wise) otherwise.
If jobz'O'${\mathbf{jobz}}\ne \text{'O'}$, the contents of a are destroyed.
2:     s(min (m,n)$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)$) – double array
The singular values of A$A$, sorted so that s(i)s(i + 1)${\mathbf{s}}\left(i\right)\ge {\mathbf{s}}\left(i+1\right)$.
3:     u(ldu, : $:$) – complex array
The first dimension, ldu, of the array u will be
• if jobz = 'S'${\mathbf{jobz}}=\text{'S'}$ or 'A'$\text{'A'}$ or jobz = 'O'${\mathbf{jobz}}=\text{'O'}$ and m < n${\mathbf{m}}<{\mathbf{n}}$, ldu max (1,m) $\mathit{ldu}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• otherwise ldu1$\mathit{ldu}\ge 1$.
The second dimension of the array will be max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if jobz = 'A'${\mathbf{jobz}}=\text{'A'}$ or jobz = 'O'${\mathbf{jobz}}=\text{'O'}$ and m < n${\mathbf{m}}<{\mathbf{n}}$, max (1,min (m,n))$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)\right)$ if jobz = 'S'${\mathbf{jobz}}=\text{'S'}$, and at least 1$1$ otherwise
If jobz = 'A'${\mathbf{jobz}}=\text{'A'}$ or jobz = 'O'${\mathbf{jobz}}=\text{'O'}$ and m < n${\mathbf{m}}<{\mathbf{n}}$, u contains the m$m$ by m$m$ unitary matrix U$U$.
If jobz = 'S'${\mathbf{jobz}}=\text{'S'}$, u contains the first min (m,n)$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$ columns of U$U$ (the left singular vectors, stored column-wise).
If jobz = 'O'${\mathbf{jobz}}=\text{'O'}$ and mn${\mathbf{m}}\ge {\mathbf{n}}$, or jobz = 'N'${\mathbf{jobz}}=\text{'N'}$, u is not referenced.
4:     vt(ldvt, : $:$) – complex array
The first dimension, ldvt, of the array vt will be
• if jobz = 'A'${\mathbf{jobz}}=\text{'A'}$ or jobz = 'O'${\mathbf{jobz}}=\text{'O'}$ and mn${\mathbf{m}}\ge {\mathbf{n}}$, ldvt max (1,n) $\mathit{ldvt}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if jobz = 'S'${\mathbf{jobz}}=\text{'S'}$, ldvt max (1,min (m,n)) $\mathit{ldvt}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)\right)$;
• otherwise ldvt1$\mathit{ldvt}\ge 1$.
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if jobz = 'A'${\mathbf{jobz}}=\text{'A'}$ or 'S'$\text{'S'}$ or jobz = 'O'${\mathbf{jobz}}=\text{'O'}$ and mn${\mathbf{m}}\ge {\mathbf{n}}$, and at least 1$1$ otherwise
If jobz = 'A'${\mathbf{jobz}}=\text{'A'}$ or jobz = 'O'${\mathbf{jobz}}=\text{'O'}$ and mn${\mathbf{m}}\ge {\mathbf{n}}$, vt contains the n$n$ by n$n$ unitary matrix VH${V}^{\mathrm{H}}$.
If jobz = 'S'${\mathbf{jobz}}=\text{'S'}$, vt contains the first min (m,n)$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n\right)$ rows of VH${V}^{\mathrm{H}}$ (the right singular vectors, stored row-wise).
If jobz = 'O'${\mathbf{jobz}}=\text{'O'}$ and m < n${\mathbf{m}}<{\mathbf{n}}$, or jobz = 'N'${\mathbf{jobz}}=\text{'N'}$, vt is not referenced.
5:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

## Error Indicators and Warnings

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ 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 > 0${\mathbf{INFO}}>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) $\left(A+E\right)$, where
 ‖E‖2 = O(ε) ‖A‖2 , $‖E‖2 = O(ε) ‖A‖2 ,$
and ε $\epsilon$ 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.

The total number of floating point operations is approximately proportional to mn2 $m{n}^{2}$ when m > n$m>n$ and m2n ${m}^{2}n$ 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