Performs a singular value decomposition on a matrix.
u (optional) The m-by-n column matrix of the decomposition of a.
v (optional) The n-by-n orthogonal matrix of the decomposition of a.
The SVD procedure function transforms an m-by-n matrix a to the product of an m-by-n column orthogonal matrix u, an n-by-n diagonal matrix w, and the transpose of an n-by-n orthogonal matrix v. In other words, u, w, and v are matrices that are calculated by SVD.
By definition, the product of these three matrices (u, w, v) is equal to a:
In a linear system of equations,
x
, given A
and b
is:
Function SVD_SOLVE, A, b
x
, the solution of the system of equations Ax = b.
SVD, A, w, u, v
A
.
n = N_ELEMENTS(w)
wp = FLTARR(n,n) FOR i=0, n-1 DO IF w(i) NE 0 THEN wp(i,i) = 1./w(i) RETURN, v # wp # (TRANSPOSE(u) # b)
x
from equation and return.
END
The SVD function is based on the subroutine SVDCMP in Numerical Recipes in C: The Art of Scientific Computing, by Flannery, Press, Teukolsky, and Vetterling, Cambridge University Press, Cambridge, MA, 1988, and is used by permission.