Login  Register

Re: SVD routine error?

Posted by Luigi Ballabio-2 on Feb 23, 2004; 3:51am
URL: http://quantlib.414.s1.nabble.com/SVD-routine-error-tp2794p2795.html

Hi Neil,

         some news:

>I've checked in a test to testsuite\matrices.cpp which looks at a couple
>of cases. The accuracy is good to about 1e-6, which isn't that great.
>Anyone having difficulty please contribute your Matrices as test cases.

Actually, there was an error in the definition of norm() in the test.
With the correct definition your routine seems to be good to 1e-12.

The bad news is that the error in norm() was hiding a bug in pseudoSqrt().
Apparently, the thing couldn't calculate a sqrt to save its life.
Nando, can you take a look at it?


>The algorithm is ported from the TNT / JAMA project, and should have m>=n
>(rows >= columns). I don't know why this is however. I was considering
>throwing an exception if n>m and forcing the user to transpose the matrix
>first.

No, I just extended the thing. You just decompose the transposed matrix,
and swap the results. The proof is in a comment in svd.cpp. You might want
to have a look and check that it's ok. But I transposed one of the matrices
in the test, and it still works.

Oh, and while I was at it, I quantlibified the code a bit more. I hope
you've no problems with this.


> > Ehm, I'm not exactly sure what you mean. "Extending", as in ...?
> >
>I mean that I want to make it easy to swap from using the current SVD
>class to a NAG SVD routine, or CLAPACK SVD routine, if they are available.
>Would 'pluggable' be a better word..

Encapsulating the NAG/CLAPACK routine in a class with the same interface as
the current one would go a long way towards your goal. Once it is done, one
can just pass the class to use as a template argument.

Later,
         Luigi