Using quantlib with MS VC++ version 7.1 for eigenvector calcs

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Using quantlib with MS VC++ version 7.1 for eigenvector calcs

Elliffe, Eoin
Using quantlib with MS VC++ version 7.1 for eigenvector calcs

Hello Folks,

I am using some algorithms from numerical recipes in C, namely tqli() and tridiag(), to calculate the eigenvectors/values of a corr matrix.

I found that certain eigenvectors had elements with the correct magnitude but with opposite sign as those found using octave which uses hessenberg and schur decomposition.

I decided to take a look at Quantlib to see if I could remedy this.

I have managed to download boost and bjam and install and copied all the *.lib and *.dll files to C:\ProgramFiles\Microsoft Visual Studio .NET 2003\Vc7\platformSDK\Lib and bin respectively.

I changed the PATH in environment variables to C:\ProgramFiles\Microsoft Visual Studio .NET 2003\Vc7\platformSDK\bin
And changed VC++ directories to include C:\Boost\lib or include.

Now I downloaded quantlib-0.3-12 and put the boost folder (C:\Boost\include\boost-1_33_1\boost) in the quantlib-0.3-12 folder.

I opened the quantlib project and compiled almost everything, that is the 8 projects with rebuild all.  
I got one error:

c:\QuantLib-0.3.12\test-suite\hestonmodel.cpp(296): fatal error in "HestonModelTest::testAnalyticVsBlack": failed to reproduce Black price

    calculated: 0.80067
    expected:   0.80067
    error:      6.186290e-008

Ok so I thought this must be some kind of rounding error as the acceptable error is 5e-008
So I did a simple build and everything seemed to build successfully.


Now I went to my own project in a different directory and did the following
a) Property Pages -> C/C++ -> Code Generation -> Runtime Library: please select the appropriate
run-time library. Here I selected "Multi-threaded Debug (/MTd)"
b) Property Pages -> C/C++ -> Code Generation -> Basic Runtime Checks: please select "Both
(/RTC1, equiv. to /RTCsu)".

Now I simply included in my own code
#include <ql/Math/all.hpp>
When I did this I got the following error:

d:\data\858679046\Desktop\All Code, Working Version March-23-2006\CFPModel\CFPModel.cpp(17): fatal error C1083: Cannot open include file: 'ql/Math/all.hpp': No such file or directory

Sorry I know I have done something silly, any adivce would be well received.
Thank you
Eoin


_______________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
Reply | Threaded
Open this post in threaded view
|

Re: Using quantlib with MS VC++ version 7.1 for eigenvector calcs

Luigi Ballabio
On 04/07/2006 04:05:32 PM, Elliffe, Eoin wrote:
> Now I simply included in my own code
> #include <ql/Math/all.hpp>
> When I did this I got the following error:
>
> d:\data\858679046\Desktop\All Code, Working Version
> March-23-2006\CFPModel\CFPModel.cpp(17): fatal error C1083: Cannot
> open
> include file: 'ql/Math/all.hpp': No such file or directory

You have to tell the compiler where the header files are. You'll also  
have to tell it where the library is. Namely, select from the menubar

Tools -> Options -> Projects -> VC++ Directories

a) Select "Include files" from the pull-down menu on the top right and  
add c:\QuantLib-0.3.12 (or wherever QuantLib is);
b) in the same pull-down, select "Library files" and add
c:\QuantLib-0.3.12\lib (mind the lib at the end)


> Now I went to my own project in a different directory and did the
> following
> a) Property Pages -> C/C++ -> Code Generation -> Runtime Library:
> please
> select the appropriate
> run-time library. Here I selected "Multi-threaded Debug (/MTd)"

This might be right or wrong, depending on how you compiled QuantLib.  
Open the QuantLib project again and check what setting is used in the  
configuration you compiled. Use the same setting. If you compiled  
QuantLib in Debug configuration, you might want to use Release instead  
as it yields much faster code; you can choose the active configuration  
from the menubar in Build -> Configuration manager.

Later,
        Luigi


----------------------------------------

All generalizations are dangerous, even this one.
-- Alexandre Dumas


Reply | Threaded
Open this post in threaded view
|

Re: Using quantlib with MS VC++ version 7.1 for eigenvector calcs

Ferdinando M. Ametrano-3
In reply to this post by Elliffe, Eoin
On 4/7/06, Elliffe, Eoin <[hidden email]> wrote:
> I am using some algorithms from numerical recipes in C, namely tqli() and
> tridiag(), to calculate the eigenvectors/values of a corr matrix.
>
> I found that certain eigenvectors had elements with the correct magnitude
> but with opposite sign as those found using octave which uses hessenberg and
> schur decomposition.

why you consider this a problem?
Eigenvalues must be the same, eigenvector are defined with no regards
to their sign. If A is a matrix and k is one of its eigenvalue, there
is an eigenvector v of unit norm for which
A v = k v
holds.
The same equation holds also for  -v, which is of unit norm too. So v
and -v are completely equivalent.

btw 4v, 7v, 2.3v are eigenvector too, even if their norm != 1

> I decided to take a look at Quantlib to see if I could remedy this.
glad you trust QuantLib... but it's not going to remedy a non-issue

hope it helps

ciao -- Nando


Reply | Threaded
Open this post in threaded view
|

RE: Using quantlib with MS VC++ version 7.1 for eigenvector calcs

Elliffe, Eoin
In reply to this post by Elliffe, Eoin
What you say is certainly true, that is where V is the norm corr matrix.
V = W*diag(lambda)*W' even if the elements of W the eigenvector matrix
are negative.
I meant to say the eigenvalues are small and negative.
This is a problem....
 

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Ferdinando Ametrano
Sent: 07 April 2006 22:55
To: Elliffe, Eoin
Cc: [hidden email]
Subject: Re: [Quantlib-users] Using quantlib with MS VC++ version 7.1
for eigenvector calcs

On 4/7/06, Elliffe, Eoin <[hidden email]> wrote:
> I am using some algorithms from numerical recipes in C, namely tqli()
> and tridiag(), to calculate the eigenvectors/values of a corr matrix.
>
> I found that certain eigenvectors had elements with the correct
> magnitude but with opposite sign as those found using octave which
> uses hessenberg and schur decomposition.

why you consider this a problem?
Eigenvalues must be the same, eigenvector are defined with no regards to
their sign. If A is a matrix and k is one of its eigenvalue, there is an
eigenvector v of unit norm for which A v = k v holds.
The same equation holds also for  -v, which is of unit norm too. So v
and -v are completely equivalent.

btw 4v, 7v, 2.3v are eigenvector too, even if their norm != 1

> I decided to take a look at Quantlib to see if I could remedy this.
glad you trust QuantLib... but it's not going to remedy a non-issue

hope it helps

ciao -- Nando
_______________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.