Problems with svdcmp()


Gian
10-22-2003, 12:13 PM
Hi,
We had to implement in C++ a sort of library to be used with svdcmp routine: a load method for matrix to decompose and a save method to write a file with results.

We noticed that svdcmp() don't work, as said in the book at page 70, with any kind of matrix, but it returns meaningless values if m<n.

First I thought it maybe due to the bugs not fixed, but I was wrong: It's a little bit better but values aren't right.

Now our professors told us to introduce a control in the routine that pretends m>n and in case false it exchanges m with n and trasposes the output. Unfortunately that is out of our knowledge because of high level of code-optimization.
At this point we thought to modify the main and in case m<n traspose the matrix in input. Although it's less elegant, it's absolutely easier.

So I asked if you have any suggestions that made us done a better impression with our profs.

Thank You in advance. Bye.

geofizyk
04-13-2004, 11:40 AM
Hi Gian,

svdcmp works if the matrix is not square and also if m<n.
It gives the solution vector (although the unique solution does not exist) in terms of least squares.
The solutions is provided by the routine: svdbksb(a, w, v, m, n, b, x).
One thing to remeber is to zero out the eigenvalues (w) that are zero or numerically close to zero.

Regards
Pawel