|
From: Tom A. <tw...@ur...> - 2022-09-22 17:12:22
|
On Wed, 14 Sep 2022, Alix Lassauzet wrote:
> While I was investigating the cause of this kink, I tried to play with
> the 2 extra parameters, quadraticity and monotonicity, and noticed that
> if I set abnormal values to these parameters (both negative for
> example), my code does not throw any exception (while the implementation
> of the class convexmonotoneinterpolation.hpp suggests the code should
> fail around L201).
>
> I can't figure out what is happening:
> - is my code correct given that no exception is thrown?
> - Has anyone already experienced this behavior and how do they fix it?
When you create a PiecewiseYieldCurve, you specify the interpolator in two
ways: as a constructor parameter, but also as a type parameter. Somewhere
in the guts of the bootstrap process - i can't find it right now, but i'm
positive there is such a place - the code creates fresh instances of the
interpolator directly from the type parameter, using its no-argument
constructor. For ConvexMonotone, that means it uses the default values for
the icities and forcePositive, and so ignores the ones you specified when
you created the instance.
In my code, i have dealt with this by creating a subclass of the
interpolator which sets these to the values i want, eg:
class PureConvexMonotone : public ConvexMonotone {
public:
PureConvexMonotone(Real quadraticity = 0.0, Real monotonicity = 1.0, bool forcePositive = false)
: ConvexMonotone(quadraticity, monotonicity, forcePositive) {}
};
Then using that as the template parameter.
If you can run your code under a debugger, try putting a breakpoint on the
constructor, and see where you hit it.
tom
--
Whatever you do, do the best you can, because the film lives forever. --
Jackie Chan
|