The Truncated Singular Value Decomposition
is a C program 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
A(mxn) = U(mxm) * S(mxn) * V'(nxn)
Note that the transpose of V is used in the decomposition, and that the
diagonal matrix S is typically stored as a vector.
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;
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 LINPACK routine DSVDC can compute the "truncated U" version of the SVD.
In order to compute the "truncated V" version with DSVDC, it's actually necessary
to transpose the matrix, compute the truncated U version, and then transpose
everything back...very carefully.
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
SVD_TRUNCATED is available in
a C version and
a C++ version and
a FORTRAN77 version and
a FORTRAN90 version and
a MATLAB version.
Related Data and Programs:
a C library which
solves linear systems using double precision real arithmetic;
a C++ program which
computes a reduced basis for a collection of data vectors using the SVD.
a C program which
demonstrates the singular value decomposition (SVD) for a simple example.
a C library which
reads a file containing historical snowfall data and
analyzes the data with the Singular Value Decomposition (SVD),
and plots created by GNUPLOT.
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,
Gene Golub, Charles VanLoan,
Johns Hopkins, 1996,
David Kahaner, Cleve Moler, Steven Nash,
Numerical Methods and Software,
Prentice Hall, 1989,
Lloyd Trefethen, David Bau,
Numerical Linear Algebra,
List of Routines:
MAIN is the main program for SVD_TRUNCATED.
DAXPY computes constant times a vector plus a vector.
DDOT forms the dot product of two vectors.
DNRM2 returns the euclidean norm of a vector.
DROT applies a plane rotation.
DROTG constructs a Givens plane rotation.
DSCAL scales a vector by a constant.
DSVDC computes the singular value decomposition of a real rectangular matrix.
DSWAP interchanges two vectors.
I4_MAX returns the maximum of two I4's.
I4_MIN returns the minimum of two I4's.
R8_ABS returns the absolute value of a R8.
R8_MAX returns the maximum of two R8's.
R8_SIGN returns the sign of a R8.
R8MAT_PRINT prints an R8MAT.
R8MAT_PRINT_SOME prints some of an R8MAT.
R8MAT_TRANSPOSE_NEW returns the transpose of an R8MAT.
R8MAT_UNIFORM_01_NEW returns a unit pseudorandom R8MAT.
SVD_TRUNCATED_U gets the truncated SVD when N <= M
SVD_TRUNCATED_U_TEST tests SVD_TRUNCATED_U.
SVD_TRUNCATED_V gets the truncated SVD when M <= N.
SVD_TRUNCATED_V_TEST tests SVD_TRUNCATED_V.
TIMESTAMP prints the current YMDHMS date as a time stamp.
You can go up one level to
the C source codes.
Last revised on 05 July 2013.