Group: | Linear Algebra |
See also: | eigsm eiggn |
Function: | svd | |
Description: | computes the singular value decomposition of an n x p matrix x (n >= p). The singular value decomposition finds matrices u, l, v such that x = u*l*v', where u and v are orthogonal matrices and l is a diagonal matrix. |
Usage: | y = svd(x) | |
Input: | ||
x | n x p matrix to be decomposed | |
Output: | ||
y.u | n x p matrix, the left matrix u | |
y.l | p x 1 vector, elements of the diagonal of matrix l | |
y.v | p x p matrix, the right matrix v |
x = #(1:5)~#(6:10)~#(11:15) y = svd(x) y.u y.l y.v r = x - y.u *(y.l .* y.v') r
Contents of u [1,] -0.35456 -0.68869 0.61103 [2,] -0.3987 -0.37555 -0.53304 [3,] -0.44284 -0.062422 -0.32161 [4,] -0.48697 0.25071 -0.20176 [5,] -0.53111 0.56384 0.44539 Contents of l [1,] 35.127 [2,] 2.4654 [3,] 2.0468e-15 Contents of v [1,] -0.20166 0.89032 -0.40825 [2,] -0.51683 0.25733 0.8165 [3,] -0.832 -0.37565 -0.40825 Contents of r [1,] -8.8818e-16 -2.6645e-15 0 [2,] -8.8818e-16 -1.7764e-15 -3.5527e-15 [3,] -1.3323e-15 -1.7764e-15 -3.5527e-15 [4,] -8.8818e-16 -3.5527e-15 -5.3291e-15 [5,] -1.7764e-15 -7.1054e-15 -1.0658e-14