NAG CL Interfacef08mdc (dbdsdc)

Settings help

CL Name Style:

1Purpose

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

2Specification

 #include
 void f08mdc (Nag_OrderType order, Nag_UploType uplo, Nag_ComputeSingularVecsType compq, Integer n, double d[], double e[], double u[], Integer pdu, double vt[], Integer pdvt, double q[], Integer iq[], NagError *fail)
The function may be called by the names: f08mdc, nag_lapackeig_dbdsdc or nag_dbdsdc.

3Description

f08mdc 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 function 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 function is available to apply $U$ or $V$ when stored in compact form.

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
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

5Arguments

1: $\mathbf{order}$Nag_OrderType Input
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{uplo}$Nag_UploType Input
On entry: indicates whether $B$ is upper or lower bidiagonal.
${\mathbf{uplo}}=\mathrm{Nag_Upper}$
$B$ is upper bidiagonal.
${\mathbf{uplo}}=\mathrm{Nag_Lower}$
$B$ is lower bidiagonal.
Constraint: ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$.
3: $\mathbf{compq}$Nag_ComputeSingularVecsType Input
On entry: specifies whether singular vectors are to be computed.
${\mathbf{compq}}=\mathrm{Nag_NotSingularVecs}$
Compute singular values only.
${\mathbf{compq}}=\mathrm{Nag_PackedSingularVecs}$
Compute singular values and compute singular vectors in compact form.
${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$
Compute singular values and singular vectors.
Constraint: ${\mathbf{compq}}=\mathrm{Nag_NotSingularVecs}$, $\mathrm{Nag_PackedSingularVecs}$ or $\mathrm{Nag_SingularVecs}$.
4: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $B$.
Constraint: ${\mathbf{n}}\ge 0$.
5: $\mathbf{d}\left[\mathit{dim}\right]$double Input/Output
Note: the dimension, dim, 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{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, the singular values of $B$.
6: $\mathbf{e}\left[\mathit{dim}\right]$double Input/Output
Note: the dimension, dim, 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.
7: $\mathbf{u}\left[\mathit{dim}\right]$double Output
Note: the dimension, dim, of the array u must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdu}}×{\mathbf{n}}\right)$ when ${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$;
• $1$ otherwise.
The $\left(i,j\right)$th element of the matrix $U$ is stored in
• ${\mathbf{u}}\left[\left(j-1\right)×{\mathbf{pdu}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{u}}\left[\left(i-1\right)×{\mathbf{pdu}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: if ${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$, then if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, u contains the left singular vectors of the bidiagonal matrix $B$.
If ${\mathbf{compq}}\ne \mathrm{Nag_SingularVecs}$, u is not referenced.
8: $\mathbf{pdu}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array u.
Constraints:
• if ${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$, ${\mathbf{pdu}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ${\mathbf{pdu}}\ge 1$.
9: $\mathbf{vt}\left[\mathit{dim}\right]$double Output
Note: the dimension, dim, of the array vt must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdvt}}×{\mathbf{n}}\right)$ when ${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$;
• $1$ otherwise.
The $\left(i,j\right)$th element of the matrix is stored in
• ${\mathbf{vt}}\left[\left(j-1\right)×{\mathbf{pdvt}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{vt}}\left[\left(i-1\right)×{\mathbf{pdvt}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: if ${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$, then if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, the rows of vt contain the right singular vectors of the bidiagonal matrix $B$.
If ${\mathbf{compq}}\ne \mathrm{Nag_SingularVecs}$, vt is not referenced.
10: $\mathbf{pdvt}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array vt.
Constraints:
• if ${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$, ${\mathbf{pdvt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ${\mathbf{pdvt}}\ge 1$.
11: $\mathbf{q}\left[\mathit{dim}\right]$double Output
Note: the dimension, dim, 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}}=\mathrm{Nag_PackedSingularVecs}$, then if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, 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 \mathrm{Nag_PackedSingularVecs}$, q is not referenced.
12: $\mathbf{iq}\left[\mathit{dim}\right]$Integer Output
Note: the dimension, dim, 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}}=\mathrm{Nag_PackedSingularVecs}$, then if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, 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 \mathrm{Nag_PackedSingularVecs}$, iq is not referenced.
13: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_ENUM_INT_2
On entry, ${\mathbf{compq}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdu}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$, ${\mathbf{pdu}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
otherwise ${\mathbf{pdu}}\ge 1$.
On entry, ${\mathbf{compq}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdvt}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{compq}}=\mathrm{Nag_SingularVecs}$, ${\mathbf{pdvt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
otherwise ${\mathbf{pdvt}}\ge 1$.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pdu}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdu}}>0$.
On entry, ${\mathbf{pdvt}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdvt}}>0$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_SINGULAR
The algorithm failed to compute a singular value. The update process of divide-and-conquer failed.

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 values, see Section 4.9.1 of Anderson et al. (1999). See also f08flc.

8Parallelism and Performance

f08mdc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f08mdc 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 function. 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 f08mec, but for large matrices f08mdc is usually much faster.
There is no complex analogue of f08mdc.

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 (f08mdce.c)

10.2Program Data

Program Data (f08mdce.d)

10.3Program Results

Program Results (f08mdce.r)