bug in europeanoption.cpp euroepanoption.hpp with Unix

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

bug in europeanoption.cpp euroepanoption.hpp with Unix

Xavier.Abulker
Hello,
I already sent this problem and this is a fix proposal:
The problem:

On Unix the example EuropeanOption gives the wrong result

Method          Value   EstimatedError  Discrepancy     Rel. Discr.
Black Scholes   3.2422  0.0000          0.000000        0.000000
Call-Put parity 3.2422  N/A             0       0.000000

It comes from the fact that in europeanoption.hpp" the following const
static member is declared:
static const Math::CumulativeNormalDistribution f_ but This variable "f_"
is never explicitly initialized.

To fix this problem we changed the following:

In europeanoption.cpp
we remove the row

 //   const Math::CumulativeNormalDistribution EuropeanOption::f_;

in europeanoption.hpp we add

#ifdef quantlib_global_define
     const Math::CumulativeNormalDistribution EuropeanOption::f_ =
Math::CumulativeNormalDistribution();
#endif

in EuropeanOption.cpp we add:

#define quantlib_global_define

this gives the correct result under Unix with gcc and c++ sun compiler.

Could you please integrate this fix in Quantlib?
Thanks


(See attached file: europeanoption.hpp)(See attached file:
europeanoption.cpp.ql)(See attached file: europeanoption.cpp)


*************************************************************************
Ce message et toutes les pieces jointes (ci-apres le "message") sont
confidentiels et etablis a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration.
La Fimat et ses filiales declinent toute responsabilite au
titre de ce message s'il a ete altere, deforme ou falsifie.
                    ********
This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
E-mails are susceptible to alteration.
Neither Fimat nor any of its subsidiaries or affiliates shall
be liable for the message if altered, changed or falsified.
*************************************************************************

europeanoption.hpp (8K) Download Attachment
europeanoption.cpp.ql (4K) Download Attachment
europeanoption.cpp (13K) Download Attachment