# NAG FL Interfacef08mbf (dbdsvdx)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f08mbf computes all or selected singular values and, optionally, the corresponding left and right singular vectors of a real $n×n$ (upper or lower) bidiagonal matrix $B$.

## 2Specification

Fortran Interface
 Subroutine f08mbf ( uplo, jobz, n, d, e, vl, vu, il, iu, ns, s, z, ldz, work, info)
 Integer, Intent (In) :: n, il, iu, ldz Integer, Intent (Out) :: ns, iwork(12*n), info Real (Kind=nag_wp), Intent (In) :: d(n), e(n-1), vl, vu Real (Kind=nag_wp), Intent (Inout) :: z(ldz,*) Real (Kind=nag_wp), Intent (Out) :: s(n), work(14*n) Character (1), Intent (In) :: uplo, jobz, range
#include <nag.h>
 void f08mbf_ (const char *uplo, const char *jobz, const char *range, const Integer *n, const double d[], const double e[], const double *vl, const double *vu, const Integer *il, const Integer *iu, Integer *ns, double s[], double z[], const Integer *ldz, double work[], Integer iwork[], Integer *info, const Charlen length_uplo, const Charlen length_jobz, const Charlen length_range)
The routine may be called by the names f08mbf, nagf_lapackeig_dbdsvdx or its LAPACK name dbdsvdx.

## 3Description

f08mbf computes the singular value decomposition (SVD) of a real $n×n$ (upper or lower) bidiagonal matrix $B$ as
 $B = USVT ,$
where $S$ is a diagonal matrix with non-negative diagonal elements (the singular values of $B$), and $U$ and ${V}^{\mathrm{T}}$ are orthogonal matrices. The columns of $U$ and $V$ are the left and right singular vectors of $B$, respectively.
Given an upper bidiagonal matrix $B$ with diagonal $\mathbit{d}=\left(\begin{array}{cccc}{d}_{1}& {d}_{2}& \dots & {d}_{n}\end{array}\right)$ and superdiagonal $\mathbit{e}=\left(\begin{array}{cccc}{e}_{1}& {e}_{2}& \dots & {e}_{N-1}\end{array}\right)$, f08mbf computes the singular value decomposition of $B$ through the eigenvalues and eigenvectors of the $\left(n×2\right)×\left(n×2\right)$ tridiagonal matrix
 $TGK= ( 0 d1 d1 0 e1 e1 0 d2 d2 . . . . ) .$
If $\left(s,u,v\right)$ is a singular triplet of $B$ with $‖u‖=‖v‖=1$, then $\left(s,{q}_{1}\right)$ and $\left(-s,{q}_{2}\right)$, $‖{q}_{1}‖=‖{q}_{2}‖=1$, are eigenpairs of $\mathit{TGK}$, with ${q}_{1}=\left({v}_{1},{u}_{1},{v}_{2},{u}_{2},\dots ,{v}_{n},{u}_{n}\right)/\sqrt{2}$, and ${q}_{2}=\left({-v}_{1},{u}_{1},{-v}_{2},{u}_{2},\dots ,{-v}_{n},{u}_{n}\right)/\sqrt{2}$.
Given a $\mathit{TGK}$ matrix, you can either
1. (i)compute $-s,-v$ and change signs so that the singular values (and corresponding vectors) are already in descending order (as in f08kbf) or
2. (ii)compute $s,v$ and reorder the values (and corresponding vectors).
f08mbf implements (i) by calling f08jbf (bisection plus inverse iteration, to be replaced with a version of the Multiple Relative Robust Representation algorithm. (See Williams and Lang (2013).)
Alternative to computing all singular values of $B$, a selected set can be computed. The set is either those singular values lying in a given interval, $\sigma \in \left({v}_{l},{v}_{u}\right]$, or those whose index (counting from largest to smallest in magnitude) lies in a given range $1\le {i}_{l},\dots ,{i}_{u}\le n$. In these cases, the corresponding left and right singular vectors can optionally be computed.

## 4References

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 https://www.netlib.org/lapack/lug
Williams P and Lang B (2013) A framework for the $M{R}^{3}$ Algorithm: theory and implementation SIAM J. Sci. Comput. 35 740–766

## 5Arguments

1: $\mathbf{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: $\mathbf{jobz}$Character(1) Input
On entry: indicates whether singular vectors are computed.
${\mathbf{jobz}}=\text{'N'}$
Only singular values are computed.
${\mathbf{jobz}}=\text{'V'}$
Singular values and singular vectors are computed.
Constraint: ${\mathbf{jobz}}=\text{'N'}$ or $\text{'V'}$.
3: $\mathbf{range}$Character(1) Input
On entry: indicates which singular values should be returned.
${\mathbf{range}}=\text{'A'}$
All singular values will be found.
${\mathbf{range}}=\text{'V'}$
All singular values in the half-open interval $\left({\mathbf{vl}},{\mathbf{vu}}\right]$ will be found.
${\mathbf{range}}=\text{'I'}$
The ilth through iuth singular values will be found.
Constraint: ${\mathbf{range}}=\text{'A'}$, $\text{'V'}$ or $\text{'I'}$.
4: $\mathbf{n}$Integer Input
On entry: $n$, the order of the bidiagonal matrix $B$.
Constraint: ${\mathbf{n}}\ge 0$.
5: $\mathbf{d}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
On entry: the diagonal elements $\mathbit{d}$ of the bidiagonal matrix $B$.
6: $\mathbf{e}\left({\mathbf{n}}-1\right)$Real (Kind=nag_wp) array Input
On entry: the $\left(n-1\right)$ off-diagonal elements $\mathbit{e}$ of the bidiagonal matrix $B$.
7: $\mathbf{vl}$Real (Kind=nag_wp) Input
On entry: if ${\mathbf{range}}=\text{'V'}$, the lower bound of the interval to be searched for singular values.
If ${\mathbf{range}}=\text{'A'}$ or $\text{'I'}$, vl is not referenced.
Constraint: if ${\mathbf{range}}=\text{'V'}$, $0.0\le {\mathbf{vl}}$.
8: $\mathbf{vu}$Real (Kind=nag_wp) Input
On entry: if ${\mathbf{range}}=\text{'V'}$, the upper bound of the interval to be searched for singular values.
If ${\mathbf{range}}=\text{'A'}$ or $\text{'I'}$, vu is not referenced.
Constraint: if ${\mathbf{range}}=\text{'V'}$, ${\mathbf{vl}}<{\mathbf{vu}}$.
9: $\mathbf{il}$Integer Input
10: $\mathbf{iu}$Integer Input
On entry: if ${\mathbf{range}}=\text{'I'}$, il and iu specify the indices (in ascending order) of the smallest and largest singular values to be returned, respectively.
If ${\mathbf{range}}=\text{'A'}$ or $\text{'V'}$, il and iu are not referenced.
Constraints:
• if ${\mathbf{range}}=\text{'I'}$ and ${\mathbf{n}}=0$, ${\mathbf{il}}=1$ and ${\mathbf{iu}}=0$;
• if ${\mathbf{range}}=\text{'I'}$ and ${\mathbf{n}}>0$, $1\le {\mathbf{il}}\le {\mathbf{iu}}\le {\mathbf{n}}$.
11: $\mathbf{ns}$Integer Output
On exit: the total number of singular values found. $0\le {\mathbf{ns}}\le {\mathbf{n}}$.
If ${\mathbf{range}}=\text{'A'}$, ${\mathbf{ns}}={\mathbf{n}}$.
If ${\mathbf{range}}=\text{'I'}$, ${\mathbf{ns}}={\mathbf{iu}}-{\mathbf{il}}+1$.
12: $\mathbf{s}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
On exit: the first ns elements contain the selected singular values in ascending order.
13: $\mathbf{z}\left({\mathbf{ldz}},*\right)$Real (Kind=nag_wp) array Output
Note: the second dimension of the array z must be at least $\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{ns}}\right)+1$ if ${\mathbf{jobz}}=\text{'V'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{jobz}}=\text{'V'}$, then if ${\mathbf{info}}=0$ the first ns columns of z contain the singular vectors of the matrix $B$ corresponding to the selected singular values, with $U$ in rows $1$ to $n$ and $V$ in rows $n+1$ to $n×2$, i.e.,
 $Z= ( U V ) .$
If ${\mathbf{jobz}}=\text{'N'}$, then z is not referenced.
Note: the user must ensure that at least $K=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{ns}}\right)+1$ columns are supplied in the array $Z$. If ${\mathbf{range}}=\text{'V'}$, the exact value of ns is not known in advance and an upper bound of at least n must be used.
14: $\mathbf{ldz}$Integer Input
On entry: the first dimension of the array z as declared in the (sub)program from which f08mbf is called.
Constraints:
• if ${\mathbf{jobz}}=\text{'V'}$, ${\mathbf{ldz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2,{\mathbf{n}}×2\right)$;
• otherwise ${\mathbf{ldz}}\ge 1$.
15: $\mathbf{work}\left(14×{\mathbf{n}}\right)$Real (Kind=nag_wp) array Workspace
16: $\mathbf{iwork}\left(12×{\mathbf{n}}\right)$Integer array Workspace
On exit: if ${\mathbf{jobz}}=\text{'V'}$, then
• if ${\mathbf{info}}={\mathbf{0}}$, the first ns elements of iwork are zero;
• if ${\mathbf{info}}>{\mathbf{0}}$, iwork contains the indices of the eigenvectors that failed to converge in f08jbf.
If ${\mathbf{jobz}}=\text{'N'}$, iwork is not referenced.
17: $\mathbf{info}$Integer Output
On exit: ${\mathbf{info}}=0$ unless the routine detects an error (see Section 6).

## 6Error 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 converge; $⟨\mathit{\text{value}}⟩$ eigenvectors of the associated eigenproblem did not converge. Their indices are stored in array iwork.

## 7Accuracy

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| ≤ p(n)εsi$
where $\epsilon$ is the machine precision and $p\left(n\right)$ is a modest function of $n$.
For bounds on the computed singular vectors, see Section 4.9.1 of Anderson et al. (1999). See also f08flf.

## 8Parallelism and Performance

f08mbf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f08mbf 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.

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, but for large matrices f08mbf is usually much faster.
There is no complex analogue of f08mbf.

## 10Example

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.1Program Text

Program Text (f08mbfe.f90)

### 10.2Program Data

Program Data (f08mbfe.d)

### 10.3Program Results

Program Results (f08mbfe.r)