svdappend
Updates an existing SVD after columns or rows are appended to the matrix.
Category: Mathematics > Linear Algebra
Syntax
S1 = svdappend(U, S, V, D)
Returns the singular values of [U*S*V' D].
[U1, S1, V1] = svdappend(U, S, V, D)
Returns the economy-size factors of the enlarged matrix.
___ = svdappend(U, S, V, D, 'Shape', 'rows')
Appends the rows of D below the matrix instead of columns beside it.
Description
When data arrives in batches, it is wasteful to decompose the whole matrix again each time. svdappend starts from the factors you already have and returns the economy SVD of the matrix with the new data attached, as a convenient shortcut for the usual update pattern.
The result is the same, up to signs, as calling svd on [U*S*V' D] directly.
Input arguments
U, S, V- Factors of an existing SVD;
Smay be a matrix or a vector of singular values. D- New columns (or rows) to append. It needs as many rows as
U(or as many columns asVhas rows, with the rows option). 'Shape''columns'(default) or'rows'.
Output arguments
S1- With one output, the vector of singular values of the enlarged matrix.
U1, V1- Singular vectors of the enlarged matrix.
Example
Append a column
A = magic(3);
[U, S, V] = svd(A, 'econ');
d = [1; 2; 3];
s1 = svdappend(U, S, V, d)'
s2 = svd([A d])'
Output
s1 = 1×3
15.3990 7.0620 3.4641
s2 = 1×3
15.3990 7.0620 3.4641
Notes
In MatLivre, with several outputs S1 comes back as a column vector of singular values, not a diagonal matrix.