Collaboration diagram for DSPF_dp_svd:
int | DSPF_dp_svd (const int Nrows, const int Ncols, double *restrict A, double *restrict U, double *restrict V, double *restrict U1, double *restrict diag, double *restrict superdiag) |
int DSPF_dp_svd | ( | const int | Nrows, | |
const int | Ncols, | |||
double *restrict | A, | |||
double *restrict | U, | |||
double *restrict | V, | |||
double *restrict | U1, | |||
double *restrict | diag, | |||
double *restrict | superdiag | |||
) |
This routine decomposes an Nrows x Ncols matrix A into a product of three matrices: A = U * D * V' where U and V are orthogonal matrices, V' is the transpose of V, and D is a diagonal matrix. If the define constant ENABLE_REDUCED_FORM is defined then the reduced form is generated else the full form is generated as shown below for the case Nrows>=Ncols.
full form
U [Nrows x Nrows]
D [Nrows x Ncols]
V'[Ncols x Ncols]
reduced form
U [Nrows x Ncols]
D [Ncols x Ncols]
V'[Ncols x Ncols]
The singular values are the diagonal elements of D and correspond to the positive square roots of the eigenvalues of the matrix A' * A. This code is suitable for dense matrices. No optimizations are made for sparse matrices. This routine calls the following routines.
1. DSPF_dp_convert_to_bidiag: converts A to bidiagonal matrix using Householder transformations.
2. DSPF_dp_bidiag_to_diag: converts bidiagonal matrix to diagonal using Givens transformations (works only for Nrows>=Ncols).
3. DSPF_dp_sort_singular_values: sorts singular values in descending order and modifies U and V matrices accordingly.
If Nrows<Ncols then the transpose of the input is generated A'=V*D'*U' and input to steps 1,2, and 3. Then the U and V matrices are switched and the D matrix is generated based on the list on singular values. The table shown below illustrates the processing for the case Nrows<Ncols.
full form V [Ncols x Ncols] D'[Ncols x Nrows] U'[Nrows x Nrows] reduced form V [Ncols x Nrows] D'[Nrows x Nrows] U'[Nrows x Nrows]
Nrows | = Number of rows in A matrix | |
Ncols | = Number of columns in A matrix | |
A | = Pointer of matrix A | |
U | = Pointer to matrix U | |
V | = Pointer to matrix V | |
U1 | = Pointer to scratch pad matrix U1[max(Nrows,Ncols)^2] | |
diag | = Pointer to vector of diagonal elements diag[max(Nrows,Ncols)] | |
superdiag | = Pointer to vector of superdiagonal elements superdiag[max(Nrows,Ncols)] |