inline calls to volatility bridges?

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

inline calls to volatility bridges?

japari
Hi all,
Maybe I am missing something but should not these methods be inlined?
In file: swaptionconstantvol.cpp

    Volatility ConstantSwaptionVolatility::volatilityImpl(const Date&,
                                                          const Period&,
                                                          Rate) const {
        return volatility_->value();
    }

    Volatility ConstantSwaptionVolatility::volatilityImpl(Time,
                                                          Time,
                                                          Rate) const {
        return volatility_->value();
    }

the same goes for the equivalent methods in spreadedswaptionvol.cpp

Regards
pp

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: inline calls to volatility bridges?

Ferdinando Ametrano-4
Hi Jose

On Wed, Jan 28, 2009 at 8:12 AM, Jose Aparicio-Navarro <[hidden email]> wrote:
> Hi all,
> Maybe I am missing something but should not these methods be inlined?
> In file: swaptionconstantvol.cpp
>
>    Volatility ConstantSwaptionVolatility::volatilityImpl(const Date&,
>                                                          const Period&,
>                                                          Rate) const {
>        return volatility_->value();
>    }

volatility_ is a Quote, and in swaptionconstantvol.hpp there is only a
forward declaration of the Quote class, while the relevanty header is
only included in the cpp file. So the quote interface cannot be
accessed in the hpp file.

It's coded this way to reduce file dependencies: any change to Quote
would require swaptionconstantvol.cpp to be recompiled, but would not
trigger the recompilation of all files including
swaptionconstantvol.hpp. While it might seem a minor benefit this
approach leads to huge benefits in very large projects where changing
a base class could trigger a very time-consuming rebuild-all

Besides I'm not an expert here, but chances are a good compiler could
inline anyway...

ciao -- Nando

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: inline calls to volatility bridges?

Luigi Ballabio
On Wed, 2009-01-28 at 10:40 +0100, Ferdinando Ametrano wrote:
> It's coded this way to reduce file dependencies: [...]
>
> Besides I'm not an expert here, but chances are a good compiler could
> inline anyway...

Nope, it's a virtual method. In most cases a compiler would not inline
it, even if it was defined as inline.

Luigi


--

When I was a boy of fourteen, my father was so ignorant I could hardly
stand to have the old man around. But when I got to be twenty-one, I
was astonished at how much the old man had learned in seven years.
-- Mark Twain



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: inline calls to volatility bridges?

Ferdinando Ametrano-4
On Wed, Jan 28, 2009 at 11:13 AM, Luigi Ballabio
<[hidden email]> wrote:
> Nope, it's a virtual method. In most cases a compiler would not inline
> it, even if it was defined as inline.

Amen

ciao -- Nando

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: inline calls to volatility bridges?

japari
Quoting Ferdinando Ametrano <[hidden email]>:

> On Wed, Jan 28, 2009 at 11:13 AM, Luigi Ballabio
> <[hidden email]> wrote:
> > Nope, it's a virtual method. In most cases a compiler would not inline
> > it, even if it was defined as inline.
>
> Amen
>
> ciao -- Nando
>

Thank you both for the answers,
fair enough, it is a trade off; anyway this is not the method I will be calling
at every time step of a MC simulation.

I was curious though and I have checked the assembler code VC++ generates with
an inlined virtual member. On the default compilation it ignores me and does not
inline but it does with -Ob1 and -Ob2. Naively though the vt ptrs might
dissapear but of course they are there for their local stacks.

Regards
pepe

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev