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

## Purpose

nag_lapack_dgesdd (f08kd) computes the singular value decomposition (SVD) of a real 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] = f08kd(jobz, a, 'm', m, 'n', n)
[a, s, u, vt, info] = nag_lapack_dgesdd(jobz, a, 'm', m, 'n', n)

## Description

The SVD is written as
 A = UΣVT , $A = UΣVT ,$
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$ orthogonal matrix, and V$V$ is an n$n$ by n$n$ orthogonal 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 VT${V}^{\mathrm{T}}$, 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 VT${V}^{\mathrm{T}}$ 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 VT${V}^{\mathrm{T}}$ 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 VT${V}^{\mathrm{T}}$ 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 VT${V}^{\mathrm{T}}$ are overwritten in the array vt.
jobz = 'N'${\mathbf{jobz}}=\text{'N'}$
No columns of U$U$ or rows of VT${V}^{\mathrm{T}}$ are computed.
Constraint: jobz = 'A'${\mathbf{jobz}}=\text{'A'}$, 'S'$\text{'S'}$, 'O'$\text{'O'}$ or 'N'$\text{'N'}$.
2:     a(lda, : $:$) – double 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 iwork

### Output Parameters

1:     a(lda, : $:$) – double 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 VT${V}^{\mathrm{T}}$ (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, : $:$) – double 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$ orthogonal 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, : $:$) – double 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$ orthogonal matrix VT${V}^{\mathrm{T}}$.
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 VT${V}^{\mathrm{T}}$ (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: iwork, 14: 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_dgesdd (f08kd) 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 complex analogue of this function is nag_lapack_zgesvd (f08kp).

## Example

```function nag_lapack_dgesdd_example
jobz = 'Overwrite A by tranpose(V)';
a = [0, 0.28, -0.48, 1.07, -2.35, 0.62;
0, -1.67, -3.09, 1.22, 2.93, -7.39;
0, 0.94, 0.99, 0.79, -1.45, 1.03;
0, -0.78, -0.21, 0.63, 2.3, -2.57];
[aOut, s, u, vt, info] = nag_lapack_dgesdd(jobz, a);
aOut, s, u, vt, info
```
```

aOut =

-0.0000   -0.2085   -0.3119    0.1069    0.4215   -0.8186
0    0.0952   -0.3347    0.4707   -0.7760   -0.2349
-0.0000    0.2686    0.6933    0.6265    0.1643   -0.1662
-0.0000    0.7233    0.1391   -0.5236   -0.1698   -0.3930

s =

9.6278
2.8739
1.3350
0.4918

u =

-0.1342    0.8243   -0.0572   -0.5470
0.9064    0.3172   -0.0878    0.2647
-0.1947    0.3526    0.7674    0.4989
0.3499   -0.3092    0.6326   -0.6179

vt =

0

info =

0

```
```function f08kd_example
jobz = 'Overwrite A by tranpose(V)';
a = [0, 0.28, -0.48, 1.07, -2.35, 0.62;
0, -1.67, -3.09, 1.22, 2.93, -7.39;
0, 0.94, 0.99, 0.79, -1.45, 1.03;
0, -0.78, -0.21, 0.63, 2.3, -2.57];
[aOut, s, u, vt, info] = f08kd(jobz, a);
aOut, s, u, vt, info
```
```

aOut =

-0.0000   -0.2085   -0.3119    0.1069    0.4215   -0.8186
0    0.0952   -0.3347    0.4707   -0.7760   -0.2349
-0.0000    0.2686    0.6933    0.6265    0.1643   -0.1662
-0.0000    0.7233    0.1391   -0.5236   -0.1698   -0.3930

s =

9.6278
2.8739
1.3350
0.4918

u =

-0.1342    0.8243   -0.0572   -0.5470
0.9064    0.3172   -0.0878    0.2647
-0.1947    0.3526    0.7674    0.4989
0.3499   -0.3092    0.6326   -0.6179

vt =

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