NAG FL Interface
f08msf (zbdsqr)
1
Purpose
f08msf computes the singular value decomposition of a complex general matrix which has been reduced to bidiagonal form.
2
Specification
Fortran Interface
Subroutine f08msf ( 
uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, work, info) 
Integer, Intent (In) 
:: 
n, ncvt, nru, ncc, ldvt, ldu, ldc 
Integer, Intent (Out) 
:: 
info 
Real (Kind=nag_wp), Intent (Inout) 
:: 
d(*), e(*), work(*) 
Complex (Kind=nag_wp), Intent (Inout) 
:: 
vt(ldvt,*), u(ldu,*), c(ldc,*) 
Character (1), Intent (In) 
:: 
uplo 

C Header Interface
#include <nag.h>
void 
f08msf_ (const char *uplo, const Integer *n, const Integer *ncvt, const Integer *nru, const Integer *ncc, double d[], double e[], Complex vt[], const Integer *ldvt, Complex u[], const Integer *ldu, Complex c[], const Integer *ldc, double work[], Integer *info, const Charlen length_uplo) 

C++ Header Interface
#include <nag.h> extern "C" {
void 
f08msf_ (const char *uplo, const Integer &n, const Integer &ncvt, const Integer &nru, const Integer &ncc, double d[], double e[], Complex vt[], const Integer &ldvt, Complex u[], const Integer &ldu, Complex c[], const Integer &ldc, double work[], Integer &info, const Charlen length_uplo) 
}

The routine may be called by the names f08msf, nagf_lapackeig_zbdsqr or its LAPACK name zbdsqr.
3
Description
f08msf computes the singular values and, optionally, the left or right singular vectors of a real upper or lower bidiagonal matrix
$B$. In other words, it can compute the singular value decomposition (SVD) of
$B$ as
Here
$\Sigma $ is a diagonal matrix with real diagonal elements
${\sigma}_{i}$ (the singular values of
$B$), such that
$U$ is an orthogonal matrix whose columns are the left singular vectors
${u}_{i}$;
$V$ is an orthogonal matrix whose rows are the right singular vectors
${v}_{i}$. Thus
To compute
$U$ and/or
${V}^{\mathrm{T}}$, the arrays
u and/or
vt must be initialized to the unit matrix before
f08msf is called.
The routine stores the real orthogonal matrices
$U$ and
${V}^{\mathrm{T}}$ in complex arrays
u and
vt, so that it may also be used to compute the SVD of a complex general matrix
$A$ which has been reduced to bidiagonal form by a unitary transformation:
$A=QB{P}^{\mathrm{H}}$. If
$A$ is
$m$ by
$n$ with
$m\ge n$, then
$Q$ is
$m$ by
$n$ and
${P}^{\mathrm{H}}$ is
$n$ by
$n$; if
$A$ is
$n$ by
$p$ with
$n<p$, then
$Q$ is
$n$ by
$n$ and
${P}^{\mathrm{H}}$ is
$n$ by
$p$. In this case, the matrices
$Q$ and/or
${P}^{\mathrm{H}}$ must be formed explicitly by
f08ktf and passed to
f08msf in the arrays
u and/or
vt respectively.
f08msf also has the capability of forming ${U}^{\mathrm{H}}C$, where $C$ is an arbitrary complex matrix; this is needed when using the SVD to solve linear least squares problems.
f08msf uses two different algorithms. If any singular vectors are required (i.e., if
${\mathbf{ncvt}}>0$ or
${\mathbf{nru}}>0$ or
${\mathbf{ncc}}>0$), the bidiagonal
$QR$ algorithm is used, switching between zeroshift and implicitly shifted forms to preserve the accuracy of small singular values, and switching between
$QR$ and
$QL$ variants in order to handle graded matrices effectively (see
Demmel and Kahan (1990)). If only singular values are required (i.e., if
${\mathbf{ncvt}}={\mathbf{nru}}={\mathbf{ncc}}=0$), they are computed by the differential qd algorithm (see
Fernando and Parlett (1994)), which is faster and can achieve even greater accuracy.
The singular vectors are normalized so that $\Vert {u}_{i}\Vert =\Vert {v}_{i}\Vert =1$, but are determined only to within a complex factor of absolute value $1$.
4
References
Demmel J W and Kahan W (1990) Accurate singular values of bidiagonal matrices SIAM J. Sci. Statist. Comput. 11 873–912
Fernando K V and Parlett B N (1994) Accurate singular values and differential qd algorithms Numer. Math. 67 191–229
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
5
Arguments

1:
$\mathbf{uplo}$ – Character(1)
Input

On entry: indicates whether
$B$ is an upper or lower bidiagonal matrix.
 ${\mathbf{uplo}}=\text{'U'}$
 $B$ is an upper bidiagonal matrix.
 ${\mathbf{uplo}}=\text{'L'}$
 $B$ is a lower bidiagonal matrix.
Constraint:
${\mathbf{uplo}}=\text{'U'}$ or $\text{'L'}$.

2:
$\mathbf{n}$ – Integer
Input

On entry: $n$, the order of the matrix $B$.
Constraint:
${\mathbf{n}}\ge 0$.

3:
$\mathbf{ncvt}$ – Integer
Input

On entry: $\mathit{ncvt}$, the number of columns of the matrix ${V}^{\mathrm{H}}$ of right singular vectors. Set ${\mathbf{ncvt}}=0$ if no right singular vectors are required.
Constraint:
${\mathbf{ncvt}}\ge 0$.

4:
$\mathbf{nru}$ – Integer
Input

On entry: $\mathit{nru}$, the number of rows of the matrix $U$ of left singular vectors. Set ${\mathbf{nru}}=0$ if no left singular vectors are required.
Constraint:
${\mathbf{nru}}\ge 0$.

5:
$\mathbf{ncc}$ – Integer
Input

On entry: $\mathit{ncc}$, the number of columns of the matrix $C$. Set ${\mathbf{ncc}}=0$ if no matrix $C$ is supplied.
Constraint:
${\mathbf{ncc}}\ge 0$.

6:
$\mathbf{d}\left(*\right)$ – Real (Kind=nag_wp) array
Input/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 diagonal elements of the bidiagonal matrix $B$.
On exit: the singular values in decreasing order of magnitude, unless
${\mathbf{info}}>{\mathbf{0}}$ (in which case see
Section 6).

7:
$\mathbf{e}\left(*\right)$ – Real (Kind=nag_wp) array
Input/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 offdiagonal elements of the bidiagonal matrix $B$.
On exit:
e is overwritten, but if
${\mathbf{info}}>{\mathbf{0}}$ see
Section 6.

8:
$\mathbf{vt}\left({\mathbf{ldvt}},*\right)$ – Complex (Kind=nag_wp) array
Input/Output

Note: the second dimension of the array
vt
must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ncvt}}\right)$.
On entry: if
${\mathbf{ncvt}}>0$,
vt must contain an
$n$ by
$\mathit{ncvt}$ matrix. If the right singular vectors of
$B$ are required,
$\mathit{ncvt}=n$ and
vt must contain the unit matrix; if the right singular vectors of
$A$ are required,
vt must contain the unitary matrix
${P}^{\mathrm{H}}$ returned by
f08ktf with
${\mathbf{vect}}=\text{'P'}$.
On exit: the
$n$ by
$\mathit{ncvt}$ matrix
${V}^{\mathrm{H}}$ or
${V}^{\mathrm{H}}{P}^{\mathrm{H}}$ of right singular vectors, stored by rows.
If
${\mathbf{ncvt}}=0$,
vt is not referenced.

9:
$\mathbf{ldvt}$ – Integer
Input

On entry: the first dimension of the array
vt as declared in the (sub)program from which
f08msf is called.
Constraints:
 if ${\mathbf{ncvt}}>0$, ${\mathbf{ldvt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
 otherwise ${\mathbf{ldvt}}\ge 1$.

10:
$\mathbf{u}\left({\mathbf{ldu}},*\right)$ – Complex (Kind=nag_wp) array
Input/Output

Note: the second dimension of the array
u
must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: if
${\mathbf{nru}}>0$,
u must contain an
$\mathit{nru}$ by
$n$ matrix. If the left singular vectors of
$B$ are required,
$\mathit{nru}=n$ and
u must contain the unit matrix; if the left singular vectors of
$A$ are required,
u must contain the unitary matrix
$Q$ returned by
f08ktf with
${\mathbf{vect}}=\text{'Q'}$.
On exit: the
$\mathit{nru}$ by
$n$ matrix
$U$ or
$QU$ of left singular vectors, stored as columns of the matrix.
If
${\mathbf{nru}}=0$,
u is not referenced.

11:
$\mathbf{ldu}$ – Integer
Input

On entry: the first dimension of the array
u as declared in the (sub)program from which
f08msf is called.
Constraint:
${\mathbf{ldu}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{nru}}\right)$.

12:
$\mathbf{c}\left({\mathbf{ldc}},*\right)$ – Complex (Kind=nag_wp) array
Input/Output

Note: the second dimension of the array
c
must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ncc}}\right)$.
On entry: the $n$ by $\mathit{ncc}$ matrix $C$ if ${\mathbf{ncc}}>0$.
On exit:
c is overwritten by the matrix
${U}^{\mathrm{H}}C$. If
${\mathbf{ncc}}=0$,
c is not referenced.

13:
$\mathbf{ldc}$ – Integer
Input

On entry: the first dimension of the array
c as declared in the (sub)program from which
f08msf is called.
Constraints:
 if ${\mathbf{ncc}}>0$, ${\mathbf{ldc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
 otherwise ${\mathbf{ldc}}\ge 1$.

14:
$\mathbf{work}\left(*\right)$ – Real (Kind=nag_wp) array
Workspace

Note: the dimension of the array
work
must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,4\times {\mathbf{n}}\right)$.

15:
$\mathbf{info}$ – Integer
Output
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$

$\u2329\mathit{\text{value}}\u232a$ offdiagonals did not converge. The arrays
d and
e contain the diagonal and offdiagonal elements, respectively, of a bidiagonal matrix orthogonally equivalent to
$B$.
7
Accuracy
Each singular value and singular vector is computed to high relative accuracy. However, the reduction to bidiagonal form (prior to calling the routine) may exclude the possibility of obtaining high relative accuracy in the small singular values of the original matrix if its singular values vary widely in magnitude.
If
${\sigma}_{i}$ is an exact singular value of
$B$ and
${\stackrel{~}{\sigma}}_{i}$ is the corresponding computed value, then
where
$p\left(m,n\right)$ is a modestly increasing function of
$m$ and
$n$, and
$\epsilon $ is the
machine precision. If only singular values are computed, they are computed more accurately (i.e., the function
$p\left(m,n\right)$ is smaller), than when some singular vectors are also computed.
If
${u}_{i}$ is an exact left singular vector of
$B$, and
${\stackrel{~}{u}}_{i}$ is the corresponding computed left singular vector, then the angle
$\theta \left({\stackrel{~}{u}}_{i},{u}_{i}\right)$ between them is bounded as follows:
where
${\mathit{relgap}}_{i}$ is the relative gap between
${\sigma}_{i}$ and the other singular values, defined by
A similar error bound holds for the right singular vectors.
8
Parallelism and Performance
f08msf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f08msf 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 implementationspecific information.
The total number of real floatingpoint operations is roughly proportional to ${n}^{2}$ if only the singular values are computed. About $12{n}^{2}\times \mathit{nru}$ additional operations are required to compute the left singular vectors and about $12{n}^{2}\times \mathit{ncvt}$ to compute the right singular vectors. The operations to compute the singular values must all be performed in scalar mode; the additional operations to compute the singular vectors can be vectorized and on some machines may be performed much faster.
The real analogue of this routine is
f08mef.
10
Example
See
Section 10 in
f08ktf, which illustrates the use of the routine to compute the singular value decomposition of a general matrix.