svd_truncated, a Fortran77 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
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.
The computer code and data files described and made available on this web page are distributed under the MIT license
svd_truncated is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.
fingerprints, a dataset directory which contains a few images of fingerprints.
lapack_examples, a Fortran77 program which demonstrates the use of the LAPACK linear algebra library.
LINPACK_D, a Fortran77 library which solves linear systems using double precision real arithmetic;
SVD_BASIS, a Fortran90 program which computes a reduced basis for a collection of data vectors using the SVD.
SVD_DEMO, a Fortran77 program which demonstrates the singular value decomposition (SVD) for a simple example.
SVD_SNOWFALL, a Fortran77 program which reads a file containing historical snowfall data and analyzes the data with the Singular Value Decomposition (SVD), and plots created by GNUPLOT.
TOMS358, a Fortran77 routine which computes the singular value decomposition for a complex matrix.