# DSPF_sp_svd [Matrix]

Collaboration diagram for DSPF_sp_svd:

## Detailed Description

 int DSPF_sp_svd (const int Nrows, const int Ncols, float *restrict A, float *restrict U, float *restrict V, float *restrict U1, float *restrict diag, float *restrict superdiag)

## Function Documentation

 int DSPF_sp_svd ( const int Nrows, const int Ncols, float *restrict A, float *restrict U, float *restrict V, float *restrict U1, float *restrict diag, float *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]

Parameters:
 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)]
Algorithm:
DSPF_sp_svd_cn.c is the natural C equivalent of the optimized intrinsic C code without restrictions. Note that the intrinsic C code is optimized and restrictions may apply.
Assumptions:
The arrays A,U,D,V,U1,diag,and superdiag are stored in distinct arrays. In-place processing of A is not allowed.
Implementation Notes:
Interruptibility : The code is interruptible.
Endian support : supports both Little and Big endian modes.