Saturday, April 05, 2008

SVD for the Vertically Challenged

If you haven't noticed, this blog can be a bit random, and I never know what will garner interest on the Net. One surprisingly popular offering has been the little SVD calculator I created by porting the JAMA SVD code from Java to JavaScript.

Today, I found an obvious bug in my applet and fixed it. In the process, I discovered a number of people querying the Net about the issue leading to the bug. The problem was that the JAMA code only calculated the SVD in cases where m >= n; i.e., it could only calculate the SVD on matrices with more rows (m) than columns (n).

This is easily fixed, if you consider the matrix transpose and corresponding transpose of its SVD.

AT = (U*S*VT)T

The basic rule of matrix algebra to consider: The transpose of a matrix product is equal to the reverse product of the individual matrix transposes (cf. The Matrix Cookbook).

In other words:


Bottom line: If you can only calculate the SVD of A where m >= n, all you need to do is calculate the SVD of AT and swap the resulting U and V matrices.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home