Singular value decomposition (economy) of matrix
Syntax: @svd(m1, v1, m2)
m1: matrix, sym
v1: vector
![](../content/images/functionref_s.118.36.01.jpg)
m2: matrix, sym
![](../content/images/functionref_s.118.36.02.jpg)
Return: matrix
![](../content/images/functionref_s.118.36.03.jpg)
Performs an “economy” or “thin” singular value decomposition of the matrix m1, generating truncated results when m1 is not square (exploiting the reduced maximum rank of a non-square matrix).
The matrix
![](../content/images/functionref_s.118.36.04.jpg)
is returned by the function, the vector
v1 will be filled (resized if necessary) with the singular values and the matrix
m2 will be assigned (resized if necessary) the other matrix,
![](../content/images/functionref_s.118.36.05.jpg)
, of the decomposition. The singular value decomposition satisfies:
where
![](../content/images/functionref_s.118.36.07.jpg)
is a diagonal matrix with the singular values along the diagonal. Singular values close to zero indicate that the matrix may not be of full rank. See the
@rank function for a related discussion.
Let r be the number of rows of m1 and s be the number of columns of m1 so that m1 has at most t = min(r, s) distinct singular values. Then
• m2 will be s-by-t
• v1 will be t-by-1
• ![](../content/images/functionref_s.118.36.08.jpg)
will have dimensions
r-by-
t Examples
matrix x = @mnrnd(5, 7)
vector w
matrix v
matrix u = @svd(x, w, v)
performs the thin SVD of the matrix X. U is
![](../content/images/functionref_s.118.36.09.jpg)
, W is a 5 element vector containing the singular values, and V is a
![](../content/images/functionref_s.118.36.10.jpg)
matrix.
Alternately, if the rank is less than the number of rows,
matrix x = @mnrnd(7, 5)
matrix u = @svd(x, w, v)
U is
![](../content/images/functionref_s.118.36.11.jpg)
, W is a 5 element vector containing the singular values, and V is a
![](../content/images/functionref_s.118.36.12.jpg)
matrix.
The following demonstrate the properties of the decomposition:
sym i1 = @inner(u)
sym i2 = @inner(v)
matrix x1 = u * @makediagonal(w) * v.@t
where I1 and I2 and the identity matrix, and X1 is equal to X.
Cross-references