LAPACK++  2022.05.00
LAPACK C++ API
Standard, A = U Sigma V^H, bidiagonal

Functions

int64_t lapack::bdsdc (lapack::Uplo uplo, lapack::Job compq, int64_t n, double *D, double *E, double *U, int64_t ldu, double *VT, int64_t ldvt, double *Q, int64_t *IQ)
 Computes the singular value decomposition (SVD) of a real n-by-n (upper or lower) bidiagonal matrix B: \(B = U S V^T\), using a divide and conquer method, where S is a diagonal matrix with non-negative diagonal elements (the singular values of B), and U and VT \(= V^T\) are orthogonal matrices of left and right singular vectors, respectively. More...
 
int64_t lapack::bdsdc (lapack::Uplo uplo, lapack::Job compq, int64_t n, float *D, float *E, float *U, int64_t ldu, float *VT, int64_t ldvt, float *Q, int64_t *IQ)
 
int64_t lapack::bdsqr (lapack::Uplo uplo, int64_t n, int64_t ncvt, int64_t nru, int64_t ncc, double *D, double *E, double *VT, int64_t ldvt, double *U, int64_t ldu, double *C, int64_t ldc)
 
int64_t lapack::bdsqr (lapack::Uplo uplo, int64_t n, int64_t ncvt, int64_t nru, int64_t ncc, double *D, double *E, std::complex< double > *VT, int64_t ldvt, std::complex< double > *U, int64_t ldu, std::complex< double > *C, int64_t ldc)
 Computes the singular values and, optionally, the right and/or left singular vectors from the singular value decomposition (SVD) of a real n-by-n (upper or lower) bidiagonal matrix B using the implicit zero-shift QR algorithm. More...
 
int64_t lapack::bdsqr (lapack::Uplo uplo, int64_t n, int64_t ncvt, int64_t nru, int64_t ncc, float *D, float *E, float *VT, int64_t ldvt, float *U, int64_t ldu, float *C, int64_t ldc)
 
int64_t lapack::bdsqr (lapack::Uplo uplo, int64_t n, int64_t ncvt, int64_t nru, int64_t ncc, float *D, float *E, std::complex< float > *VT, int64_t ldvt, std::complex< float > *U, int64_t ldu, std::complex< float > *C, int64_t ldc)
 
int64_t lapack::bdsvdx (lapack::Uplo uplo, lapack::Job jobz, lapack::Range range, int64_t n, double const *D, double const *E, double vl, double vu, int64_t il, int64_t iu, int64_t *nfound, double *S, double *Z, int64_t ldz)
 Computes the singular value decomposition (SVD) of a real n-by-n (upper or lower) bidiagonal matrix B, \(B = U S VT\), where S is a diagonal matrix with non-negative diagonal elements (the singular values of B), and U and VT are orthogonal matrices of left and right singular vectors, respectively. More...
 
int64_t lapack::bdsvdx (lapack::Uplo uplo, lapack::Job jobz, lapack::Range range, int64_t n, float const *D, float const *E, float vl, float vu, int64_t il, int64_t iu, int64_t *nfound, float *S, float *Z, int64_t ldz)
 

Detailed Description

Function Documentation

◆ bdsdc()

int64_t lapack::bdsdc ( lapack::Uplo  uplo,
lapack::Job  compq,
int64_t  n,
double *  D,
double *  E,
double *  U,
int64_t  ldu,
double *  VT,
int64_t  ldvt,
double *  Q,
int64_t *  IQ 
)

Computes the singular value decomposition (SVD) of a real n-by-n (upper or lower) bidiagonal matrix B: \(B = U S V^T\), using a divide and conquer method, where S is a diagonal matrix with non-negative diagonal elements (the singular values of B), and U and VT \(= V^T\) are orthogonal matrices of left and right singular vectors, respectively.

bdsdc can be used to compute all singular values, and optionally, singular vectors or singular vectors in compact form.

This code makes very mild assumptions about floating point arithmetic. It will work on machines with a guard digit in add/subtract, or on those binary machines without guard digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. It could conceivably fail on hexadecimal or decimal machines without guard digits, but we know of none. See lapack::lasd3 for details.

The code currently calls lapack::lasdq if singular values only are desired. However, it can be slightly modified to compute singular values using the divide and conquer method.

Overloaded versions are available for float, double.

Parameters
[in]uplo
  • lapack::Uplo::Upper: B is upper bidiagonal.
  • lapack::Uplo::Lower: B is lower bidiagonal.
[in]compqWhether singular vectors are to be computed:
  • lapack::Job::NoVec: Compute singular values only;
  • lapack::Job::CompactVec: Compute singular values and compute singular vectors in compact form [this option not yet implemented in LAPACK++.];
  • lapack::Job::Vec: Compute singular values and singular vectors.
[in]nThe order of the matrix B. n >= 0.
[in,out]DThe vector D of length n. On entry, the n diagonal elements of the bidiagonal matrix B. On successful exit, the singular values of B.
[in,out]EThe vector E of length n-1. On entry, the elements of E contain the offdiagonal elements of the bidiagonal matrix whose SVD is desired. On exit, E has been destroyed.
[out]UThe n-by-n matrix U, stored in an ldu-by-n array. If compq = Vec, then: on successful exit, U contains the left singular vectors of the bidiagonal matrix. For other values of compq, U is not referenced.
[in]lduThe leading dimension of the array U. ldu >= 1. If singular vectors are desired, then ldu >= max( 1, n ).
[out]VTThe n-by-n matrix VT, stored in an ldvt-by-n array. If compq = Vec, then: on successful exit, VT^T contains the right singular vectors of the bidiagonal matrix. For other values of compq, VT is not referenced.
[in]ldvtThe leading dimension of the array VT. ldvt >= 1. If singular vectors are desired, then ldvt >= max( 1, n ).
[out]Q[This option not yet implemented in LAPACK++.] If compq = CompactVec, then: The vector Q of length ldq. For other values of compq, Q is not referenced.
[out]IQ[This option not yet implemented in LAPACK++.] If compq = CompactVec, then: The vector IQ of length ldiq. For other values of compq, IQ is not referenced.
Returns
= 0: successful exit.
> 0: The algorithm failed to compute a singular value. The update process of divide and conquer failed.

◆ bdsqr()

int64_t lapack::bdsqr ( lapack::Uplo  uplo,
int64_t  n,
int64_t  ncvt,
int64_t  nru,
int64_t  ncc,
double *  D,
double *  E,
std::complex< double > *  VT,
int64_t  ldvt,
std::complex< double > *  U,
int64_t  ldu,
std::complex< double > *  C,
int64_t  ldc 
)

Computes the singular values and, optionally, the right and/or left singular vectors from the singular value decomposition (SVD) of a real n-by-n (upper or lower) bidiagonal matrix B using the implicit zero-shift QR algorithm.

The SVD of B has the form

\[ B = Q S P^H \]

where S is the diagonal matrix of singular values, Q is an orthogonal matrix of left singular vectors, and P is an orthogonal matrix of right singular vectors. If left singular vectors are requested, this subroutine actually returns \(U Q\) instead of Q, and, if right singular vectors are requested, this subroutine returns \(P^H V^H\) instead of \(P^H\), for given input matrices U and VT \(= V^H\). When U and VT are the unitary matrices that reduce a general matrix A to bidiagonal form: \(A = U B V^H\), as computed by lapack::gebrd, then

\[ A = (U Q) S (P^H V^H) \]

is the SVD of A. Optionally, the subroutine may also compute \(Q^H C\) for a given input matrix C.

See "Computing Small Singular Values of Bidiagonal Matrices With Guaranteed High Relative Accuracy," by J. Demmel and W. Kahan, LAPACK Working Note #3 (or SIAM J. Sci. Statist. Comput. vol. 11, no. 5, pp. 873-912, Sept 1990) and "Accurate singular values and differential qd algorithms," by B. Parlett and V. Fernando, Technical Report CPAM-554, Mathematics Department, University of California at Berkeley, July 1992 for a detailed description of the algorithm.

Overloaded versions are available for float, double, std::complex<float>, and std::complex<double>.

Parameters
[in]uplo
  • lapack::Uplo::Upper: B is upper bidiagonal;
  • lapack::Uplo::Lower: B is lower bidiagonal.
[in]nThe order of the matrix B. n >= 0.
[in]ncvtThe number of columns of the matrix VT. ncvt >= 0.
[in]nruThe number of rows of the matrix U. nru >= 0.
[in]nccThe number of columns of the matrix C. ncc >= 0.
[in,out]DThe vector D of length n. On entry, the n diagonal elements of the bidiagonal matrix B. On successful exit, the singular values of B in decreasing order.
[in,out]EThe vector E of length n-1. On entry, the n-1 offdiagonal elements of the bidiagonal matrix B. On successful exit, E is destroyed; if return value > 0, D and E will contain the diagonal and superdiagonal elements of a bidiagonal matrix orthogonally equivalent to the one given as input.
[in,out]VTThe n-by-ncvt matrix VT, stored in an ldvt-by-ncvt array. On entry, an n-by-ncvt matrix VT. On exit, VT is overwritten by \(P^H V^H\). Not referenced if ncvt = 0.
[in]ldvtThe leading dimension of the array VT. ldvt >= max(1,n) if ncvt > 0; ldvt >= 1 if ncvt = 0.
[in,out]UThe nru-by-n matrix U, stored in an ldu-by-n array. On entry, an nru-by-n matrix U. On exit, U is overwritten by \(U Q\). Not referenced if nru = 0.
[in]lduThe leading dimension of the array U. ldu >= max(1,nru).
[in,out]CThe n-by-ncc matrix C, stored in an ldc-by-ncc array. On entry, an n-by-ncc matrix C. On exit, C is overwritten by \(Q^H C\). Not referenced if ncc = 0.
[in]ldcThe leading dimension of the array C. ldc >= max(1,n) if ncc > 0; ldc >=1 if ncc = 0.
Returns
= 0: successful exit
> 0: the algorithm did not converge; D and E contain the elements of a bidiagonal matrix which is orthogonally similar to the input matrix B; if return value = i, i elements of E have not converged to zero.

◆ bdsvdx()

int64_t lapack::bdsvdx ( lapack::Uplo  uplo,
lapack::Job  jobz,
lapack::Range  range,
int64_t  n,
double const *  D,
double const *  E,
double  vl,
double  vu,
int64_t  il,
int64_t  iu,
int64_t *  nfound,
double *  S,
double *  Z,
int64_t  ldz 
)

Computes the singular value decomposition (SVD) of a real n-by-n (upper or lower) bidiagonal matrix B, \(B = U S VT\), where S is a diagonal matrix with non-negative diagonal elements (the singular values of B), and U and VT are orthogonal matrices of left and right singular vectors, respectively.

Given an upper bidiagonal B with diagonal \(D = [ d_1 d_2 ... d_n ]\) and superdiagonal \(E = [ e_1 e_2 ... e_{n-1} ]\), bdsvdx computes the singular value decompositon of B through the eigenvalues and eigenvectors of the 2n-by-2n tridiagonal matrix

\[ TGK = \begin{bmatrix} 0 & d_1 \\ d_1 & 0 & e_1 \\ & e_1 & 0 & d_2 \\ & & d_2 & . & . \\ & & & . & . & . \end{bmatrix} \]

If (s,u,v) is a singular triplet of B with ||u|| = ||v|| = 1, then (+/-s,q), ||q|| = 1, are eigenpairs of TGK, with q = P * (u' +/- v') / sqrt(2) = ( v_1 u_1 v_2 u_2 ... v_n u_n ) / sqrt(2), and P = [ e_{n+1} e_{1} e_{n+2} e_{2} ... ].

Given a TGK matrix, one can either a) compute -s,-v and change signs so that the singular values (and corresponding vectors) are already in descending order (as in lapack::gesvd/lapack::gesdd) or b) compute s,v and reorder the values (and corresponding vectors). bdsvdx implements a) by calling lapack::stevx (bisection plus inverse iteration, to be replaced with a version of the Multiple Relative Robust Representation algorithm. (See P. Willems and B. Lang, A framework for the MR^3 algorithm: theory and implementation, SIAM J. Sci. Comput., 35:740-766, 2013.)

Overloaded versions are available for float, double.

Parameters
[in]uplo
  • lapack::Uplo::Upper: B is upper bidiagonal;
  • lapack::Uplo::Lower: B is lower bidiagonal.
[in]jobz
  • lapack::Job::NoVec: Compute singular values only;
  • lapack::Job::Vec: Compute singular values and singular vectors.
[in]range
  • lapack::Range::All: all singular values will be found.
  • lapack::Range::Value: all singular values in the half-open interval [vl,vu) will be found.
  • lapack::Range::Index: the il-th through iu-th singular values will be found.
[in]nThe order of the bidiagonal matrix. n >= 0.
[in]DThe vector D of length n. The n diagonal elements of the bidiagonal matrix B.
[in]EThe vector E of length max(1,n-1). The (n-1) superdiagonal elements of the bidiagonal matrix B in elements 1 to n-1.
[in]vlIf range=Value, the lower bound of the interval to be searched for singular values. vu > vl. Not referenced if range = All or Index.
[in]vuIf range=Value, the upper bound of the interval to be searched for singular values. vu > vl. Not referenced if range = All or Index.
[in]ilIf range=Index, the index of the smallest singular value to be returned. 1 <= il <= iu <= min(M,n), if min(M,n) > 0. Not referenced if range = All or Value.
[in]iuIf range=Index, the index of the largest singular value to be returned. 1 <= il <= iu <= min(M,n), if min(M,n) > 0. Not referenced if range = All or Value.
[out]nfoundThe total number of singular values found. 0 <= nfound <= n.
  • If range = All, nfound = n;
  • if range = Index, nfound = iu-il+1.
[out]SThe vector S of length n. The first nfound elements contain the selected singular values in ascending order.
[out]ZThe (2*n)-by-zcol matrix Z, stored in an (2*n)-by-zcol array.
  • If jobz = Vec, then if successful the first nfound 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 2*n, i.e.

    \[ Z = \begin{bmatrix} U \\ V \end{bmatrix} \]

  • If jobz = NoVec, then Z is not referenced.
    Note: The user must ensure that zcol >= nfound+1 columns are supplied in the array Z; if range = Value, the exact value of nfound is not known in advance and an upper bound must be used.
[in]ldzThe leading dimension of the array Z. ldz >= 1, and if jobz = Vec, ldz >= max(2,2*n).
Returns
= 0: successful exit
> 0: if return value = i, then i eigenvectors failed to converge in lapack::stevx. The indices of the eigenvectors (as returned by lapack::stevx) are stored in the array iwork.
> n: if return value = 2*n + 1, an internal error occurred.