Login  Register

Re: SVD routine error?

Posted by Neil P Firth on Feb 22, 2004; 2:47pm
URL: http://quantlib.414.s1.nabble.com/SVD-routine-error-tp2794p2808.html

Hi,

Sorry about the trouble this class is causing ;)

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.

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.

Are there any design thoughts on extending the linear algebra. For
instance, I'd like to be able to swap the TNT SVD class for a NAG or
CLAPACK routine to utilise the BLAS and the shared memory processors on
the Oxford computational finance cluster.

As for the macro problem:

>
> ,  There are some more problems with SVD
> In the line
>
> T scale = QL_MAX(QL_MAX(QL_MAX(QL_MAX(
>                QL_FABS(s[p-1]),QL_FABS(s[p-2])),QL_FABS(e[p-2])),
>                QL_FABS(s[k])),QL_FABS(e[k]));
>
> The Microsoft compiler VC6 doesn't like the macro expansion. Won't work
> in release mode. I think its the recursion.
> Try something like
>    double scale = max_funct(max_funct(max_funct(max_funct(
>                        abs_func(s[p-1]),abs_func(s[p-2])),abs_func(e[p-2])),
>                        abs_func(s[k])),abs_func(e[k]));

I think it would be best to do half the work in
double temp_scale =....
then do the rest in
double scale =...
as we want to use the QL_MAX macros everywhere for maintainability.

Neil