# svd_truncated

svd_truncated, a FORTRAN90 code which demonstrates the computation of the reduced or truncated Singular Value Decomposition (SVD) of an M by N rectangular matrix, in cases where M < N or N < M.

The singular value decomposition of an M by N rectangular matrix A has the form

```        A(mxn) = U(mxm) * S(mxn) * V'(nxn)
```
where
• U is an orthogonal matrix, whose columns are the left singular vectors;
• S is a diagonal matrix, whose min(m,n) diagonal entries are the singular values;
• V is an orthogonal matrix, whose columns are the right singular vectors;
Note that the transpose of V is used in the decomposition, and that the diagonal matrix S is typically stored as a vector.

It is often the case that the matrix A has one dimension much bigger than the other. For instance, M = 3 and N = 10,000 might be such a case. For such examples, much of the computation and memory required for the standard SVD may not actually be needed. Instead, a truncated, or reduced version is appropriate. It will be computed faster, and require less memory to store the data.

If M < N, we have the "truncated V" SVD:

```        A(mxn) = U(mxm) * Sm(mxm) * Vm'(nxm)
```
Notice that, for our example, we will have to compute and store a Vm of size 30,000 instead of a V of size 1,000,000 entries.

If N < M, we have the "truncated U" SVD:

```        A(mxn) = Un(mxn) * Sn(nxn) * V'(nxn)
```
Similarly, in this case, the computation and storage of Un can be much reduced from that of U.

The LAPACK routines CGESVD, DGESVD, SGESVD and ZGESVD compute the SVD for a rectangular matrix in single or double precision, real or complex arithmetic. These routines include some options that allow you to request a reduced or truncated SVD computation, but the exact details of how to do this may be a little obscure. This program demonstrates how it is done.

In order to compile and load this program, you need to have access to a copy of LAPACK.

### Languages:

svd_truncated is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

SVD_BASIS, a FORTRAN90 code which computes a reduced basis for a collection of data vectors using the SVD.

svd_test, a FORTRAN90 code which demonstrates the singular value decomposition (SVD) for a simple example.

SVD_SNOWFALL, a FORTRAN90 code which reads a file containing historical snowfall data and analyzes the data with the Singular Value Decomposition (SVD), and plots created by GNUPLOT.

### Reference:

1. Edward Anderson, Zhaojun Bai, Christian Bischof, Susan Blackford, James Demmel, Jack Dongarra, Jeremy Du Croz, Anne Greenbaum, Sven Hammarling, Alan McKenney, Danny Sorensen,
LAPACK User's Guide,
Third Edition,
SIAM, 1999,
ISBN: 0898714478,
LC: QA76.73.F25L36
2. Gene Golub, Charles VanLoan,
Matrix Computations, Third Edition,
Johns Hopkins, 1996,
ISBN: 0-8018-4513-X,
LC: QA188.G65.
3. David Kahaner, Cleve Moler, Steven Nash,
Numerical Methods and Software,
Prentice Hall, 1989,
ISBN: 0-13-627258-4,
LC: TA345.K34.
4. Lloyd Trefethen, David Bau,
Numerical Linear Algebra,
SIAM, 1997,
ISBN: 0-89871-361-7,
LC: QA184.T74.

### Source Code:

Last revised on 31 August 2020.