LAPACK++
2022.07.00
LAPACK C++ API
|
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) |
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
.
[in] | uplo |
|
[in] | compq | Whether singular vectors are to be computed:
|
[in] | n | The order of the matrix B. n >= 0. |
[in,out] | D | The 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] | E | The 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] | U | The 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] | ldu | The leading dimension of the array U. ldu >= 1. If singular vectors are desired, then ldu >= max( 1, n ). |
[out] | VT | The 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] | ldvt | The 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. |
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>
.
[in] | uplo |
|
[in] | n | The order of the matrix B. n >= 0. |
[in] | ncvt | The number of columns of the matrix VT. ncvt >= 0. |
[in] | nru | The number of rows of the matrix U. nru >= 0. |
[in] | ncc | The number of columns of the matrix C. ncc >= 0. |
[in,out] | D | The 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] | E | The 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] | VT | The 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] | ldvt | The leading dimension of the array VT. ldvt >= max(1,n) if ncvt > 0; ldvt >= 1 if ncvt = 0. |
[in,out] | U | The 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] | ldu | The leading dimension of the array U. ldu >= max(1,nru). |
[in,out] | C | The 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] | ldc | The leading dimension of the array C. ldc >= max(1,n) if ncc > 0; ldc >=1 if ncc = 0. |
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
.
[in] | uplo |
|
[in] | jobz |
|
[in] | range |
|
[in] | n | The order of the bidiagonal matrix. n >= 0. |
[in] | D | The vector D of length n. The n diagonal elements of the bidiagonal matrix B. |
[in] | E | The 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] | vl | If range=Value, the lower bound of the interval to be searched for singular values. vu > vl. Not referenced if range = All or Index. |
[in] | vu | If range=Value, the upper bound of the interval to be searched for singular values. vu > vl. Not referenced if range = All or Index. |
[in] | il | If 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] | iu | If 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] | nfound | The total number of singular values found. 0 <= nfound <= n.
|
[out] | S | The vector S of length n. The first nfound elements contain the selected singular values in ascending order. |
[out] | Z | The (2*n)-by-zcol matrix Z, stored in an (2*n)-by-zcol array.
|
[in] | ldz | The leading dimension of the array Z. ldz >= 1, and if jobz = Vec, ldz >= max(2,2*n). |
lapack::stevx
. The indices of the eigenvectors (as returned by lapack::stevx
) are stored in the array iwork.