F08MDF (DBDSDC) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08MDF (DBDSDC)

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.

## 1  Purpose

F08MDF (DBDSDC) computes the singular values and, optionally, the left and right singular vectors of a real $n$ by $n$ (upper or lower) bidiagonal matrix $B$.

## 2  Specification

 SUBROUTINE F08MDF ( UPLO, COMPQ, N, D, E, U, LDU, VT, LDVT, Q, IQ, WORK, IWORK, INFO)
 INTEGER N, LDU, LDVT, IQ(*), IWORK(8*N), INFO REAL (KIND=nag_wp) D(*), E(*), U(LDU,*), VT(LDVT,*), Q(*), WORK(*) CHARACTER(1) UPLO, COMPQ
The routine may be called by its LAPACK name dbdsdc.

## 3  Description

F08MDF (DBDSDC) computes the singular value decomposition (SVD) of the (upper or lower) bidiagonal matrix $B$ as
 $B = USVT ,$
where $S$ is a diagonal matrix with non-negative diagonal elements ${s}_{ii}={s}_{i}$, such that
 $s1 ≥ s2 ≥ ⋯ ≥ sn ≥ 0 ,$
and $U$ and $V$ are orthogonal matrices. The diagonal elements of $S$ are the singular values of $B$ and the columns of $U$ and $V$ are respectively the corresponding left and right singular vectors of $B$.
When only singular values are required the routine uses the $QR$ algorithm, but when singular vectors are required a divide and conquer method is used. The singular values can optionally be returned in compact form, although currently no routine is available to apply $U$ or $V$ when stored in compact form.

## 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  Arguments

1:     $\mathrm{UPLO}$ – CHARACTER(1)Input
On entry: indicates whether $B$ is upper or lower bidiagonal.
${\mathbf{UPLO}}=\text{'U'}$
$B$ is upper bidiagonal.
${\mathbf{UPLO}}=\text{'L'}$
$B$ is lower bidiagonal.
Constraint: ${\mathbf{UPLO}}=\text{'U'}$ or $\text{'L'}$.
2:     $\mathrm{COMPQ}$ – CHARACTER(1)Input
On entry: specifies whether singular vectors are to be computed.
${\mathbf{COMPQ}}=\text{'N'}$
Compute singular values only.
${\mathbf{COMPQ}}=\text{'P'}$
Compute singular values and compute singular vectors in compact form.
${\mathbf{COMPQ}}=\text{'I'}$
Compute singular values and singular vectors.
Constraint: ${\mathbf{COMPQ}}=\text{'N'}$, $\text{'P'}$ or $\text{'I'}$.
3:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the order of the matrix $B$.
Constraint: ${\mathbf{N}}\ge 0$.
4:     $\mathrm{D}\left(*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array D must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the $n$ diagonal elements of the bidiagonal matrix $B$.
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, the singular values of $B$.
5:     $\mathrm{E}\left(*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array E must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}-1\right)$.
On entry: the $\left(n-1\right)$ off-diagonal elements of the bidiagonal matrix $B$.
On exit: the contents of E are destroyed.
6:     $\mathrm{U}\left({\mathbf{LDU}},*\right)$ – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array U must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{COMPQ}}=\text{'I'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{COMPQ}}=\text{'I'}$, then if ${\mathbf{INFO}}={\mathbf{0}}$, U contains the left singular vectors of the bidiagonal matrix $B$.
If ${\mathbf{COMPQ}}\ne \text{'I'}$, U is not referenced.
7:     $\mathrm{LDU}$ – INTEGERInput
On entry: the first dimension of the array U as declared in the (sub)program from which F08MDF (DBDSDC) is called.
Constraints:
• if ${\mathbf{COMPQ}}=\text{'I'}$, ${\mathbf{LDU}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDU}}\ge 1$.
8:     $\mathrm{VT}\left({\mathbf{LDVT}},*\right)$ – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array VT must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{COMPQ}}=\text{'I'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{COMPQ}}=\text{'I'}$, then if ${\mathbf{INFO}}={\mathbf{0}}$, the rows of VT contain the right singular vectors of the bidiagonal matrix $B$.
If ${\mathbf{COMPQ}}\ne \text{'I'}$, VT is not referenced.
9:     $\mathrm{LDVT}$ – INTEGERInput
On entry: the first dimension of the array VT as declared in the (sub)program from which F08MDF (DBDSDC) is called.
Constraints:
• if ${\mathbf{COMPQ}}=\text{'I'}$, ${\mathbf{LDVT}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDVT}}\ge 1$.
10:   $\mathrm{Q}\left(*\right)$ – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array Q must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{{\mathbf{N}}}^{2}+5{\mathbf{N}},\mathit{ldq}\right)$.
On exit: if ${\mathbf{COMPQ}}=\text{'P'}$, then if ${\mathbf{INFO}}={\mathbf{0}}$, Q and IQ contain the left and right singular vectors in a compact form, requiring $\mathit{O}\left({\mathbf{N}}{\mathrm{log}}_{2}{\mathbf{N}}\right)$ space instead of $2×{{\mathbf{N}}}^{2}$. In particular, Q contains all the real data in the first $\mathit{ldq}={\mathbf{N}}×\left(11+2×\mathit{smlsiz}+8×\mathrm{int}\left({\mathrm{log}}_{2}\left({\mathbf{N}}/\left(\mathit{smlsiz}+1\right)\right)\right)\right)$ elements of Q, where $\mathit{smlsiz}$ is equal to the maximum size of the subproblems at the bottom of the computation tree (usually about $25$).
If ${\mathbf{COMPQ}}\ne \text{'P'}$, Q is not referenced.
11:   $\mathrm{IQ}\left(*\right)$ – INTEGER arrayOutput
Note: the dimension of the array IQ must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathit{ldiq}\right)$.
On exit: if ${\mathbf{COMPQ}}=\text{'P'}$, then if ${\mathbf{INFO}}={\mathbf{0}}$, Q and IQ contain the left and right singular vectors in a compact form, requiring $\mathit{O}\left({\mathbf{N}}{\mathrm{log}}_{2}{\mathbf{N}}\right)$ space instead of $2×{{\mathbf{N}}}^{2}$. In particular, IQ contains all integer data in the first $\mathit{ldiq}={\mathbf{N}}×\left(3+3×\mathrm{int}\left({\mathrm{log}}_{2}\left({\mathbf{N}}/\left(\mathit{smlsiz}+1\right)\right)\right)\right)$ elements of IQ, where $\mathit{smlsiz}$ is equal to the maximum size of the subproblems at the bottom of the computation tree (usually about $25$).
If ${\mathbf{COMPQ}}\ne \text{'P'}$, IQ is not referenced.
12:   $\mathrm{WORK}\left(*\right)$ – REAL (KIND=nag_wp) arrayWorkspace
Note: the dimension of the array WORK must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,6×{\mathbf{N}}-2\right)$ if ${\mathbf{COMPQ}}=\text{'N'}$, $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,6×{\mathbf{N}}\right)$ if ${\mathbf{COMPQ}}=\text{'P'}$, $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,3×{{\mathbf{N}}}^{2}+4×{\mathbf{N}}\right)$ if ${\mathbf{COMPQ}}=\text{'I'}$, and at least $1$ otherwise.
13:   $\mathrm{IWORK}\left(8×{\mathbf{N}}\right)$ – INTEGER arrayWorkspace
14:   $\mathrm{INFO}$ – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{INFO}}>0$
The algorithm failed to compute a singular value. The update process of divide-and-conquer failed.

## 7  Accuracy

Each computed singular value of $B$ is accurate to nearly full relative precision, no matter how tiny the singular value. The $i$th computed singular value, ${\stackrel{^}{s}}_{i}$, satisfies the bound
 $s^i-si ≤ pnεsi$
where $\epsilon$ is the machine precision and $p\left(n\right)$ is a modest function of $n$.
For bounds on the computed singular values, see Section 4.9.1 of Anderson et al. (1999). See also F08FLF (DDISNA).

## 8  Parallelism and Performance

F08MDF (DBDSDC) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
F08MDF (DBDSDC) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9  Further Comments

If only singular values are required, the total number of floating-point operations is approximately proportional to ${n}^{2}$. When singular vectors are required the number of operations is bounded above by approximately the same number of operations as F08MEF (DBDSQR), but for large matrices F08MDF (DBDSDC) is usually much faster.
There is no complex analogue of F08MDF (DBDSDC).

## 10  Example

This example computes the singular value decomposition of the upper bidiagonal matrix
 $B = 3.62 1.26 0.00 0.00 0.00 -2.41 -1.53 0.00 0.00 0.00 1.92 1.19 0.00 0.00 0.00 -1.43 .$

### 10.1  Program Text

Program Text (f08mdfe.f90)

### 10.2  Program Data

Program Data (f08mdfe.d)

### 10.3  Program Results

Program Results (f08mdfe.r)

F08MDF (DBDSDC) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual