Hello,
I would like to expose the ConvexMonotoneInterpolation QuantLib class to Python via SWIG, without much success, due primarily to the template reference issue. Of all the derived classes of the 1-D interpolation base class, I need the one with the template Unfortunately, I cannot post any of my attempts to add to the interpolation.i interface file, as none of them seem to work. Any help / suggestions would be highly appreciated. Thank you, Ioan |
Hi Ioan,
please post your attempts anyway. They'll give a useful starting point, and it will take significantly less to tell you where to modify them than to start from scratch. Luigi On Wed, May 28, 2014 at 9:33 PM, Ioan F. <[hidden email]> wrote: > Hello, > > I would like to expose the ConvexMonotoneInterpolation QuantLib class to > Python via SWIG, without much success, due primarily to the template > reference issue. Of all the derived classes of the 1-D interpolation base > class, I need the one with the template > Unfortunately, I cannot post any of my attempts to add to the > interpolation.i interface file, as none of them seem to work. > Any help / suggestions would be highly appreciated. > > Thank you, > Ioan > > > > -- > View this message in context: http://quantlib.10058.n7.nabble.com/Convex-Monotone-Interpolation-SWIG-exposed-to-Python-tp15327.html > Sent from the quantlib-dev mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Time is money. Stop wasting it! Get your web API in 5 minutes. > www.restlet.com/download > http://p.sf.net/sfu/restlet > _______________________________________________ > QuantLib-dev mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-dev -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
This post was updated on .
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) : x_(x), y_(y), quadraticity_(quadraticity), monotonicity_(monotonicity), forcePositive_(forcePositive), f_(x_.begin(), x_.end(), y_.begin(), quadraticity_, monotonicity_, forcePositive_) {} Real operator()(Real x, bool allowExtrapolation=false) { return f_(x, allowExtrapolation); } protected: Array x_, y_; Real quadraticity_; Real monotonicity_; bool forcePositive_; I1 f_; }; %} %define make_safe_interpolationConvex(T, Alias) %{ typedef SafeInterpolationConvex(QuantLib::T) 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 Array& x, const Array& y, Real quadraticity, Real monotonicity, bool forcePositive); Real operator()(Real x, bool allowExtrapolation=false); }; %enddef //make_safe_interpolationConvex(ConvexMonotoneInterpolation,ConvexMonotoneInterpolation); %{ using QuantLib::ConvexMonotone; %} struct ConvexMonotone{}; |
Free forum by Nabble | Edit this page |