|
From: Ioan F. <if...@ny...> - 2014-06-05 21:16:09
|
Hi Luigi,
Pretty sad state of affairs with my SWIG code, but I guess you're right,
it's better to start from somewhere rather than from scratch.
The code below should be placed within interpolation.i interface file.
Regards,
Ioan
*%{
// safe versions which copy their arguments
template <class I1, class I2>
class SafeInterpolationConvex {
public:
SafeInterpolationConvex(const Array& x, const Array& y, Real
quadraticity,
Real monotonicity, bool forcePositive, bool flatFinalPeriod,
const helper_map& preExistingHelpers)
: x_(x), y_(y),
quadraticity_(quadraticity), monotonicity_(monotonicity),
forcePositive_(forcePositive),
flatFinalPeriod_(flatFinalPeriod),
helper_map_(helper_map()),
f_(x_.begin(), x_.end(), y_.begin(), quadraticity_,
monotonicity_, forcePositive_,
flatFinalPeriod_, helper_map_()) {}
Real operator()(Real x, bool allowExtrapolation=false) {
return f_(x, allowExtrapolation);
}
protected:
Array x_, y_;
Real quadraticity_,
Real monotonicity_,
bool forcePositive_,
bool flatFinalPeriod_,
const &preExistingHelpers helper_map_,
I1 f_;
};
%}
%define make_safe_interpolationConvex(T1,T2,Alias)
%{
typedef SafeInterpolationConvex<QuantLib::T1, QuantLib::T2> Safe##T;
%}
%rename(Alias) Safe##T;
class Safe##T {
#if defined(SWIGMZSCHEME) || defined(SWIGGUILE) \
|| defined(SWIGCSHARP) || defined(SWIGPERL)
%rename(call) operator();
#endif
public:
Safe##T(const T1& x, const T2& y);
Real operator()(Real x, bool allowExtrapolation=false);
};
%enddef
make_safe_interpolationConvex(ConvexMonotoneInterpolation,ConvexMonotoneInterpolation,ConvexMonotoneInterpolation);
%{
using QuantLib::ConvexMonotone;
%}
struct ConvexMonotone{};*
--
View this message in context: http://quantlib.10058.n7.nabble.com/Convex-Monotone-Interpolation-SWIG-exposed-to-Python-tp15327p15400.html
Sent from the quantlib-dev mailing list archive at Nabble.com.
|