Hi
I am also trying to convert the fittedbondcurve class from C++ to java using SWIG. I use a swig file from the mail. http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 I call if from: NelsonSiegelFitting ns = new NelsonSiegelFitting(); FittedBondDiscountCurve ss = new FittedBondDiscountCurve( settlementDays, calendar, depoSwapInstruments, bondDayCount, ns); } but i get the next complie error: change type 'ns' to 'SWIGTYPE_p_FittingMethod' I guess the parent class FittingMethod have not correctly convert to java. any clues? thanks wangjingtao 12/18 the i file is: ============================================ #ifndef quantlib_fitted_bond_i #define quantlib_fitted_bond_i %include termstructures.i %include interpolation.i %include ratehelpers.i %{ using QuantLib::InterpolatedDiscountCurve; using QuantLib::FittedBondDiscountCurve; using QuantLib::RateHelper; using QuantLib::YieldTermStructure; typedef boost::shared_ptr<YieldTermStructure> FittedBondDiscountCurvePtr; typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; %} %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; class FittedBondDiscountCurvePtr : public boost::shared_ptr<YieldTermStructure> { public: %extend { FittedBondDiscountCurvePtr(Natural settlementDays, const Calendar& calendar, const std::vector<boost::shared_ptr<BondHelper> >& instruments, const DayCounter& dayCounter, const FittingMethod& fittingMethod, Real accuracy = 1.0e-10, Size maxEvaluations = 10000, const Array& guess = Array(), Real simplexLambda = 1.0) { return new FittedBondDiscountCurvePtr( new FittedBondDiscountCurve( settlementDays, calendar, instruments, dayCounter, fittingMethod, accuracy, maxEvaluations, guess, simplexLambda) ); } FittedBondDiscountCurvePtr(const Date &referenceDate, const std::vector<boost::shared_ptr<BondHelper> >& instruments, const DayCounter& dayCounter, const FittingMethod& fittingMethod, Real accuracy = 1.0e-10, Size maxEvaluations = 10000, const Array &guess = Array(), Real simplexLambda = 1.0) { return new FittedBondDiscountCurvePtr( new FittedBondDiscountCurve( referenceDate, instruments, dayCounter, fittingMethod, accuracy, maxEvaluations, guess, simplexLambda) ); } } }; %{ using QuantLib::ExponentialSplinesFitting; using QuantLib::NelsonSiegelFitting; using QuantLib::CubicBSplinesFitting; typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; %} %ignore FittingMethod; class FittingMethod {}; %template(FittingMethod) boost::shared_ptr<FittingMethod>; class ExponentialSplinesFitting : public FittingMethod { public: %extend { ExponentialSplinesFitting(bool constrainAtZero = true) { return new ExponentialSplinesFitting(constrainAtZero); } } }; class NelsonSiegelFitting : public FittingMethod { public: %extend { NelsonSiegelFitting() { return new NelsonSiegelFitting(); } } }; class CubicBSplinesFitting : public FittingMethod { public: %extend { CubicBSplinesFitting(const std::vector<Time>& knotVector, bool constrainAtZero = true) { return new CubicBSplinesFitting(knotVector, constrainAtZero); } } }; #endif ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hello,
the constructor expects a reference to a FittingMethod instance, but you're exporting it as a shared_ptr. Try removing the line %template(FittingMethod) boost::shared_ptr<FittingMethod>; from your SWIG interface. Luigi On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> wrote: > Hi > > I am also trying to convert the fittedbondcurve class from C++ to java > using SWIG. I use a swig file from the mail. > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 > > I call if from: > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > FittedBondDiscountCurve ss = > new FittedBondDiscountCurve( > settlementDays, > calendar, > depoSwapInstruments, > bondDayCount, > ns); > } > > but i get the next complie error: > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > > I guess the parent class FittingMethod have not correctly convert to java. > > any clues? > thanks > > wangjingtao > 12/18 > > > the i file is: > ============================================ > > #ifndef quantlib_fitted_bond_i > #define quantlib_fitted_bond_i > %include termstructures.i > %include interpolation.i > %include ratehelpers.i > %{ > using QuantLib::InterpolatedDiscountCurve; > using QuantLib::FittedBondDiscountCurve; > using QuantLib::RateHelper; > using QuantLib::YieldTermStructure; > typedef boost::shared_ptr<YieldTermStructure> FittedBondDiscountCurvePtr; > typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; > %} > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; > class FittedBondDiscountCurvePtr : public > boost::shared_ptr<YieldTermStructure> { > public: > %extend { > FittedBondDiscountCurvePtr(Natural settlementDays, > const Calendar& calendar, > const std::vector<boost::shared_ptr<BondHelper> >& > instruments, > const DayCounter& dayCounter, > const FittingMethod& fittingMethod, > Real accuracy = 1.0e-10, > Size maxEvaluations = 10000, > const Array& guess = Array(), > Real simplexLambda = 1.0) > { > return new FittedBondDiscountCurvePtr( > new FittedBondDiscountCurve( > settlementDays, > calendar, > instruments, > dayCounter, > fittingMethod, > accuracy, > maxEvaluations, > guess, > simplexLambda) > ); > } > FittedBondDiscountCurvePtr(const Date &referenceDate, > const > std::vector<boost::shared_ptr<BondHelper> >& instruments, > const DayCounter& dayCounter, > const FittingMethod& fittingMethod, > Real accuracy = 1.0e-10, > Size maxEvaluations = 10000, > const Array &guess = Array(), > Real simplexLambda = 1.0) > { > return new FittedBondDiscountCurvePtr( > new FittedBondDiscountCurve( > referenceDate, > instruments, > dayCounter, > fittingMethod, > accuracy, > maxEvaluations, > guess, > simplexLambda) > ); > } > } > }; > %{ > using QuantLib::ExponentialSplinesFitting; > using QuantLib::NelsonSiegelFitting; > using QuantLib::CubicBSplinesFitting; > typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; > %} > %ignore FittingMethod; > class FittingMethod {}; > %template(FittingMethod) boost::shared_ptr<FittingMethod>; > class ExponentialSplinesFitting : public FittingMethod > { > public: > %extend > { > ExponentialSplinesFitting(bool constrainAtZero = true) > { > return new ExponentialSplinesFitting(constrainAtZero); > } > } > }; > class NelsonSiegelFitting : public FittingMethod > { > public: > %extend > { > NelsonSiegelFitting() > { > return new NelsonSiegelFitting(); > } > } > }; > class CubicBSplinesFitting : public FittingMethod > { > public: > %extend > { > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool > constrainAtZero = true) > { > return new CubicBSplinesFitting(knotVector, constrainAtZero); > } > } > }; > > #endif > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
luigi
see the attachments. I removed the line. but in java the error is as the same. the java source is: NelsonSiegelFitting ns = new NelsonSiegelFitting(); FittedBondDiscountCurve ss = new FittedBondDiscountCurve( settlementDays, calendar, depoSwapInstruments, bondDayCount, ns); and has the next compile error: >>The constructor FittedBondDiscountCurve(int, Calendar, BondHelperVector, DayCounter, NelsonSiegelFitting) is undefined. and has the next quick fix available: > > change type 'ns' to 'SWIGTYPE_p_FittingMethod' any other clues? thks. > Date: Tue, 24 Dec 2013 12:04:25 +0100 > Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG > From: [hidden email] > To: [hidden email] > CC: [hidden email] > > Hello, > the constructor expects a reference to a FittingMethod instance, > but you're exporting it as a shared_ptr. Try removing the line > > %template(FittingMethod) boost::shared_ptr<FittingMethod>; > > from your SWIG interface. > > Luigi > > > On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> wrote: > > Hi > > > > I am also trying to convert the fittedbondcurve class from C++ to java > > using SWIG. I use a swig file from the mail. > > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 > > > > I call if from: > > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > > FittedBondDiscountCurve ss = > > new FittedBondDiscountCurve( > > settlementDays, > > calendar, > > depoSwapInstruments, > > bondDayCount, > > ns); > > } > > > > but i get the next complie error: > > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > > > > I guess the parent class FittingMethod have not correctly convert to java. > > > > any clues? > > thanks > > > > wangjingtao > > 12/18 > > > > > > the i file is: > > ============================================ > > > > #ifndef quantlib_fitted_bond_i > > #define quantlib_fitted_bond_i > > %include termstructures.i > > %include interpolation.i > > %include ratehelpers.i > > %{ > > using QuantLib::InterpolatedDiscountCurve; > > using QuantLib::FittedBondDiscountCurve; > > using QuantLib::RateHelper; > > using QuantLib::YieldTermStructure; > > typedef boost::shared_ptr<YieldTermStructure> FittedBondDiscountCurvePtr; > > typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; > > %} > > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; > > class FittedBondDiscountCurvePtr : public > > boost::shared_ptr<YieldTermStructure> { > > public: > > %extend { > > FittedBondDiscountCurvePtr(Natural settlementDays, > > const Calendar& calendar, > > const std::vector<boost::shared_ptr<BondHelper> >& > > instruments, > > const DayCounter& dayCounter, > > const FittingMethod& fittingMethod, > > Real accuracy = 1.0e-10, > > Size maxEvaluations = 10000, > > const Array& guess = Array(), > > Real simplexLambda = 1.0) > > { > > return new FittedBondDiscountCurvePtr( > > new FittedBondDiscountCurve( > > settlementDays, > > calendar, > > instruments, > > dayCounter, > > fittingMethod, > > accuracy, > > maxEvaluations, > > guess, > > simplexLambda) > > ); > > } > > FittedBondDiscountCurvePtr(const Date &referenceDate, > > const > > std::vector<boost::shared_ptr<BondHelper> >& instruments, > > const DayCounter& dayCounter, > > const FittingMethod& fittingMethod, > > Real accuracy = 1.0e-10, > > Size maxEvaluations = 10000, > > const Array &guess = Array(), > > Real simplexLambda = 1.0) > > { > > return new FittedBondDiscountCurvePtr( > > new FittedBondDiscountCurve( > > referenceDate, > > instruments, > > dayCounter, > > fittingMethod, > > accuracy, > > maxEvaluations, > > guess, > > simplexLambda) > > ); > > } > > } > > }; > > %{ > > using QuantLib::ExponentialSplinesFitting; > > using QuantLib::NelsonSiegelFitting; > > using QuantLib::CubicBSplinesFitting; > > typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; > > %} > > %ignore FittingMethod; > > class FittingMethod {}; > > %template(FittingMethod) boost::shared_ptr<FittingMethod>; > > class ExponentialSplinesFitting : public FittingMethod > > { > > public: > > %extend > > { > > ExponentialSplinesFitting(bool constrainAtZero = true) > > { > > return new ExponentialSplinesFitting(constrainAtZero); > > } > > } > > }; > > class NelsonSiegelFitting : public FittingMethod > > { > > public: > > %extend > > { > > NelsonSiegelFitting() > > { > > return new NelsonSiegelFitting(); > > } > > } > > }; > > class CubicBSplinesFitting : public FittingMethod > > { > > public: > > %extend > > { > > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool > > constrainAtZero = true) > > { > > return new CubicBSplinesFitting(knotVector, constrainAtZero); > > } > > } > > }; > > > > #endif > > > > ------------------------------------------------------------------------------ > > Rapidly troubleshoot problems before they affect your business. Most IT > > organizations don't have a clear picture of how application performance > > affects their revenue. With AppDynamics, you get 100% visibility into your > > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > > Pro! > > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > > _______________________________________________ > > QuantLib-users mailing list > > [hidden email] > > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > > > > -- > <https://implementingquantlib.blogspot.com> > <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users quantlib_fitted_bond_i.i (4K) Download Attachment |
Hello,
your wrappers won't compile, so I'm not sure what you're calling from your Java code. Anyway: - you're using BondHelper, which is not defined in the wrappers; - you're passing a vector of RateHelpers, which can't be implicitly converted to a vector of BondHelpers; - you're declaring pure virtual methods in NelsonSiegelFitting and not declaring them in the derived class, so SWIG thinks it can't instantiate it. The file I'm attaching should fix the problems (look at the differences with your file to see what I've done). I haven't tried it from Java, but at least it compiles. Let me know what happens. Luigi On Fri, Dec 27, 2013 at 1:30 AM, 静涛 王 <[hidden email]> wrote: > luigi > > see the attachments. > I removed the line. but in java the error is as the same. > > the java source is: > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > > FittedBondDiscountCurve ss = new FittedBondDiscountCurve( > settlementDays, > calendar, > depoSwapInstruments, > bondDayCount, > ns); > > and has the next compile error: >>>The constructor FittedBondDiscountCurve(int, Calendar, BondHelperVector, >>> DayCounter, NelsonSiegelFitting) is undefined. > > and has the next quick fix available: >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > > any other clues? > > thks. > > > >> Date: Tue, 24 Dec 2013 12:04:25 +0100 >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG >> From: [hidden email] >> To: [hidden email] >> CC: [hidden email] >> >> Hello, >> the constructor expects a reference to a FittingMethod instance, >> but you're exporting it as a shared_ptr. Try removing the line >> >> %template(FittingMethod) boost::shared_ptr<FittingMethod>; >> >> from your SWIG interface. >> >> Luigi >> >> >> On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> wrote: >> > Hi >> > >> > I am also trying to convert the fittedbondcurve class from C++ to java >> > using SWIG. I use a swig file from the mail. >> > >> > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 >> > >> > I call if from: >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); >> > FittedBondDiscountCurve ss = >> > new FittedBondDiscountCurve( >> > settlementDays, >> > calendar, >> > depoSwapInstruments, >> > bondDayCount, >> > ns); >> > } >> > >> > but i get the next complie error: >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' >> > >> > I guess the parent class FittingMethod have not correctly convert to >> > java. >> > >> > any clues? >> > thanks >> > >> > wangjingtao >> > 12/18 >> > >> > >> > the i file is: >> > ============================================ >> > >> > #ifndef quantlib_fitted_bond_i >> > #define quantlib_fitted_bond_i >> > %include termstructures.i >> > %include interpolation.i >> > %include ratehelpers.i >> > %{ >> > using QuantLib::InterpolatedDiscountCurve; >> > using QuantLib::FittedBondDiscountCurve; >> > using QuantLib::RateHelper; >> > using QuantLib::YieldTermStructure; >> > typedef boost::shared_ptr<YieldTermStructure> >> > FittedBondDiscountCurvePtr; >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; >> > %} >> > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; >> > class FittedBondDiscountCurvePtr : public >> > boost::shared_ptr<YieldTermStructure> { >> > public: >> > %extend { >> > FittedBondDiscountCurvePtr(Natural settlementDays, >> > const Calendar& calendar, >> > const std::vector<boost::shared_ptr<BondHelper> >& >> > instruments, >> > const DayCounter& dayCounter, >> > const FittingMethod& fittingMethod, >> > Real accuracy = 1.0e-10, >> > Size maxEvaluations = 10000, >> > const Array& guess = Array(), >> > Real simplexLambda = 1.0) >> > { >> > return new FittedBondDiscountCurvePtr( >> > new FittedBondDiscountCurve( >> > settlementDays, >> > calendar, >> > instruments, >> > dayCounter, >> > fittingMethod, >> > accuracy, >> > maxEvaluations, >> > guess, >> > simplexLambda) >> > ); >> > } >> > FittedBondDiscountCurvePtr(const Date &referenceDate, >> > const >> > std::vector<boost::shared_ptr<BondHelper> >& instruments, >> > const DayCounter& dayCounter, >> > const FittingMethod& fittingMethod, >> > Real accuracy = 1.0e-10, >> > Size maxEvaluations = 10000, >> > const Array &guess = Array(), >> > Real simplexLambda = 1.0) >> > { >> > return new FittedBondDiscountCurvePtr( >> > new FittedBondDiscountCurve( >> > referenceDate, >> > instruments, >> > dayCounter, >> > fittingMethod, >> > accuracy, >> > maxEvaluations, >> > guess, >> > simplexLambda) >> > ); >> > } >> > } >> > }; >> > %{ >> > using QuantLib::ExponentialSplinesFitting; >> > using QuantLib::NelsonSiegelFitting; >> > using QuantLib::CubicBSplinesFitting; >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; >> > %} >> > %ignore FittingMethod; >> > class FittingMethod {}; >> > %template(FittingMethod) boost::shared_ptr<FittingMethod>; >> > class ExponentialSplinesFitting : public FittingMethod >> > { >> > public: >> > %extend >> > { >> > ExponentialSplinesFitting(bool constrainAtZero = true) >> > { >> > return new ExponentialSplinesFitting(constrainAtZero); >> > } >> > } >> > }; >> > class NelsonSiegelFitting : public FittingMethod >> > { >> > public: >> > %extend >> > { >> > NelsonSiegelFitting() >> > { >> > return new NelsonSiegelFitting(); >> > } >> > } >> > }; >> > class CubicBSplinesFitting : public FittingMethod >> > { >> > public: >> > %extend >> > { >> > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool >> > constrainAtZero = true) >> > { >> > return new CubicBSplinesFitting(knotVector, constrainAtZero); >> > } >> > } >> > }; >> > >> > #endif >> > >> > >> > ------------------------------------------------------------------------------ >> > Rapidly troubleshoot problems before they affect your business. Most IT >> > organizations don't have a clear picture of how application performance >> > affects their revenue. With AppDynamics, you get 100% visibility into >> > your >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of >> > AppDynamics >> > Pro! >> > >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk >> > _______________________________________________ >> > QuantLib-users mailing list >> > [hidden email] >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > >> >> >> >> -- >> <https://implementingquantlib.blogspot.com> >> <https://twitter.com/lballabio> -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users fittedbondcurve.i (4K) Download Attachment |
I'm sorry for that canot complied. Because i changed ratehelper.i.
I complied the attached file and find the FittedBondDiscountCurve.class has the next source: ================================================================================== public FittedBondDiscountCurve(long paramLong1, Calendar paramCalendar, BondHelperVector paramBondHelperVector, DayCounter paramDayCounter, SWIGTYPE_p_FittingMethod paramSWIGTYPE_p_FittingMethod, double paramDouble1, long paramLong2, Array paramArray, double paramDouble2) { this(QuantLibJNI.new_FittedBondDiscountCurve__SWIG_0(paramLong1, Calendar.getCPtr(paramCalendar), paramCalendar, BondHelperVector.getCPtr(paramBondHelperVector), paramBondHelperVector, DayCounter.getCPtr(paramDayCounter), paramDayCounter, SWIGTYPE_p_FittingMethod.getCPtr(paramSWIGTYPE_p_FittingMethod), paramDouble1, paramLong2, Array.getCPtr(paramArray), paramArray, paramDouble2), true); } ================================================================================== please attention that the FittingMethod is converted into SWIGTYPE_p_FittingMethod. So when complied in java has the error like: "The constructor FittedBondDiscountCurve(int, Calendar, BondHelperVector,DayCounter, NelsonSiegelFitting) is undefined.". best reagrds. wang > Date: Fri, 27 Dec 2013 11:18:55 +0100 > Subject: Re: FW: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG > From: [hidden email] > To: [hidden email] > CC: [hidden email] > > Hello, > your wrappers won't compile, so I'm not sure what you're calling > from your Java code. Anyway: > - you're using BondHelper, which is not defined in the wrappers; > - you're passing a vector of RateHelpers, which can't be implicitly > converted to a vector of BondHelpers; > - you're declaring pure virtual methods in NelsonSiegelFitting and not > declaring them in the derived class, so SWIG thinks it can't > instantiate it. > > The file I'm attaching should fix the problems (look at the > differences with your file to see what I've done). I haven't tried it > from Java, but at least it compiles. Let me know what happens. > > Luigi > > > On Fri, Dec 27, 2013 at 1:30 AM, 静涛 王 <[hidden email]> wrote: > > luigi > > > > see the attachments. > > I removed the line. but in java the error is as the same. > > > > the java source is: > > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > > > > FittedBondDiscountCurve ss = new FittedBondDiscountCurve( > > settlementDays, > > calendar, > > depoSwapInstruments, > > bondDayCount, > > ns); > > > > and has the next compile error: > >>>The constructor FittedBondDiscountCurve(int, Calendar, BondHelperVector, > >>> DayCounter, NelsonSiegelFitting) is undefined. > > > > and has the next quick fix available: > >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > > > > any other clues? > > > > thks. > > > > > > > >> Date: Tue, 24 Dec 2013 12:04:25 +0100 > >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG > >> From: [hidden email] > >> To: [hidden email] > >> CC: [hidden email] > >> > >> Hello, > >> the constructor expects a reference to a FittingMethod instance, > >> but you're exporting it as a shared_ptr. Try removing the line > >> > >> %template(FittingMethod) boost::shared_ptr<FittingMethod>; > >> > >> from your SWIG interface. > >> > >> Luigi > >> > >> > >> On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> wrote: > >> > Hi > >> > > >> > I am also trying to convert the fittedbondcurve class from C++ to java > >> > using SWIG. I use a swig file from the mail. > >> > > >> > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 > >> > > >> > I call if from: > >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > >> > FittedBondDiscountCurve ss = > >> > new FittedBondDiscountCurve( > >> > settlementDays, > >> > calendar, > >> > depoSwapInstruments, > >> > bondDayCount, > >> > ns); > >> > } > >> > > >> > but i get the next complie error: > >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > >> > > >> > I guess the parent class FittingMethod have not correctly convert to > >> > java. > >> > > >> > any clues? > >> > thanks > >> > > >> > wangjingtao > >> > 12/18 > >> > > >> > > >> > the i file is: > >> > ============================================ > >> > > >> > #ifndef quantlib_fitted_bond_i > >> > #define quantlib_fitted_bond_i > >> > %include termstructures.i > >> > %include interpolation.i > >> > %include ratehelpers.i > >> > %{ > >> > using QuantLib::InterpolatedDiscountCurve; > >> > using QuantLib::FittedBondDiscountCurve; > >> > using QuantLib::RateHelper; > >> > using QuantLib::YieldTermStructure; > >> > typedef boost::shared_ptr<YieldTermStructure> > >> > FittedBondDiscountCurvePtr; > >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; > >> > %} > >> > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; > >> > class FittedBondDiscountCurvePtr : public > >> > boost::shared_ptr<YieldTermStructure> { > >> > public: > >> > %extend { > >> > FittedBondDiscountCurvePtr(Natural settlementDays, > >> > const Calendar& calendar, > >> > const std::vector<boost::shared_ptr<BondHelper> >& > >> > instruments, > >> > const DayCounter& dayCounter, > >> > const FittingMethod& fittingMethod, > >> > Real accuracy = 1.0e-10, > >> > Size maxEvaluations = 10000, > >> > const Array& guess = Array(), > >> > Real simplexLambda = 1.0) > >> > { > >> > return new FittedBondDiscountCurvePtr( > >> > new FittedBondDiscountCurve( > >> > settlementDays, > >> > calendar, > >> > instruments, > >> > dayCounter, > >> > fittingMethod, > >> > accuracy, > >> > maxEvaluations, > >> > guess, > >> > simplexLambda) > >> > ); > >> > } > >> > FittedBondDiscountCurvePtr(const Date &referenceDate, > >> > const > >> > std::vector<boost::shared_ptr<BondHelper> >& instruments, > >> > const DayCounter& dayCounter, > >> > const FittingMethod& fittingMethod, > >> > Real accuracy = 1.0e-10, > >> > Size maxEvaluations = 10000, > >> > const Array &guess = Array(), > >> > Real simplexLambda = 1.0) > >> > { > >> > return new FittedBondDiscountCurvePtr( > >> > new FittedBondDiscountCurve( > >> > referenceDate, > >> > instruments, > >> > dayCounter, > >> > fittingMethod, > >> > accuracy, > >> > maxEvaluations, > >> > guess, > >> > simplexLambda) > >> > ); > >> > } > >> > } > >> > }; > >> > %{ > >> > using QuantLib::ExponentialSplinesFitting; > >> > using QuantLib::NelsonSiegelFitting; > >> > using QuantLib::CubicBSplinesFitting; > >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod FittingMethod; > >> > %} > >> > %ignore FittingMethod; > >> > class FittingMethod {}; > >> > %template(FittingMethod) boost::shared_ptr<FittingMethod>; > >> > class ExponentialSplinesFitting : public FittingMethod > >> > { > >> > public: > >> > %extend > >> > { > >> > ExponentialSplinesFitting(bool constrainAtZero = true) > >> > { > >> > return new ExponentialSplinesFitting(constrainAtZero); > >> > } > >> > } > >> > }; > >> > class NelsonSiegelFitting : public FittingMethod > >> > { > >> > public: > >> > %extend > >> > { > >> > NelsonSiegelFitting() > >> > { > >> > return new NelsonSiegelFitting(); > >> > } > >> > } > >> > }; > >> > class CubicBSplinesFitting : public FittingMethod > >> > { > >> > public: > >> > %extend > >> > { > >> > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool > >> > constrainAtZero = true) > >> > { > >> > return new CubicBSplinesFitting(knotVector, constrainAtZero); > >> > } > >> > } > >> > }; > >> > > >> > #endif > >> > > >> > > >> > ------------------------------------------------------------------------------ > >> > Rapidly troubleshoot problems before they affect your business. Most IT > >> > organizations don't have a clear picture of how application performance > >> > affects their revenue. With AppDynamics, you get 100% visibility into > >> > your > >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of > >> > AppDynamics > >> > Pro! > >> > > >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > >> > _______________________________________________ > >> > QuantLib-users mailing list > >> > [hidden email] > >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users > >> > > >> > >> > >> > >> -- > >> <https://implementingquantlib.blogspot.com> > >> <https://twitter.com/lballabio> > > > > -- > <https://implementingquantlib.blogspot.com> > <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
That's strange. What SWIG version are you using? And how are you
calling SWIG exactly? Luigi On Mon, Dec 30, 2013 at 6:32 AM, 静涛 王 <[hidden email]> wrote: > I'm sorry for that canot complied. Because i changed ratehelper.i. > > I complied the attached file and find the > FittedBondDiscountCurve.class has the next source: > ================================================================================== > public FittedBondDiscountCurve(long paramLong1, Calendar paramCalendar, > BondHelperVector paramBondHelperVector, DayCounter paramDayCounter, > SWIGTYPE_p_FittingMethod paramSWIGTYPE_p_FittingMethod, double paramDouble1, > long paramLong2, Array paramArray, double paramDouble2) { > this(QuantLibJNI.new_FittedBondDiscountCurve__SWIG_0(paramLong1, > Calendar.getCPtr(paramCalendar), paramCalendar, > BondHelperVector.getCPtr(paramBondHelperVector), paramBondHelperVector, > DayCounter.getCPtr(paramDayCounter), paramDayCounter, > SWIGTYPE_p_FittingMethod.getCPtr(paramSWIGTYPE_p_FittingMethod), > paramDouble1, paramLong2, Array.getCPtr(paramArray), paramArray, > paramDouble2), true); > } > ================================================================================== > > please attention that the FittingMethod is converted into > SWIGTYPE_p_FittingMethod. > > So when complied in java has the error like: > "The constructor FittedBondDiscountCurve(int, Calendar, > BondHelperVector,DayCounter, NelsonSiegelFitting) is undefined.". > > best reagrds. > wang > > > > >> Date: Fri, 27 Dec 2013 11:18:55 +0100 >> Subject: Re: FW: [Quantlib-users] Converting FittedBondDiscountCurve to >> SWIG > >> From: [hidden email] >> To: [hidden email] >> CC: [hidden email] >> >> Hello, >> your wrappers won't compile, so I'm not sure what you're calling >> from your Java code. Anyway: >> - you're using BondHelper, which is not defined in the wrappers; >> - you're passing a vector of RateHelpers, which can't be implicitly >> converted to a vector of BondHelpers; >> - you're declaring pure virtual methods in NelsonSiegelFitting and not >> declaring them in the derived class, so SWIG thinks it can't >> instantiate it. >> >> The file I'm attaching should fix the problems (look at the >> differences with your file to see what I've done). I haven't tried it >> from Java, but at least it compiles. Let me know what happens. >> >> Luigi >> >> >> On Fri, Dec 27, 2013 at 1:30 AM, 静涛 王 <[hidden email]> wrote: >> > luigi >> > >> > see the attachments. >> > I removed the line. but in java the error is as the same. >> > >> > the java source is: >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); >> > >> > FittedBondDiscountCurve ss = new FittedBondDiscountCurve( >> > settlementDays, >> > calendar, >> > depoSwapInstruments, >> > bondDayCount, >> > ns); >> > >> > and has the next compile error: >> >>>The constructor FittedBondDiscountCurve(int, Calendar, >> >>> BondHelperVector, >> >>> DayCounter, NelsonSiegelFitting) is undefined. >> > >> > and has the next quick fix available: >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' >> > >> > any other clues? >> > >> > thks. >> > >> > >> > >> >> Date: Tue, 24 Dec 2013 12:04:25 +0100 >> >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to >> >> SWIG >> >> From: [hidden email] >> >> To: [hidden email] >> >> CC: [hidden email] >> >> >> >> Hello, >> >> the constructor expects a reference to a FittingMethod instance, >> >> but you're exporting it as a shared_ptr. Try removing the line >> >> >> >> %template(FittingMethod) boost::shared_ptr<FittingMethod>; >> >> >> >> from your SWIG interface. >> >> >> >> Luigi >> >> >> >> >> >> On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> wrote: >> >> > Hi >> >> > >> >> > I am also trying to convert the fittedbondcurve class from C++ to >> >> > java >> >> > using SWIG. I use a swig file from the mail. >> >> > >> >> > >> >> > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 >> >> > >> >> > I call if from: >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); >> >> > FittedBondDiscountCurve ss = >> >> > new FittedBondDiscountCurve( >> >> > settlementDays, >> >> > calendar, >> >> > depoSwapInstruments, >> >> > bondDayCount, >> >> > ns); >> >> > } >> >> > >> >> > but i get the next complie error: >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' >> >> > >> >> > I guess the parent class FittingMethod have not correctly convert to >> >> > java. >> >> > >> >> > any clues? >> >> > thanks >> >> > >> >> > wangjingtao >> >> > 12/18 >> >> > >> >> > >> >> > the i file is: >> >> > ============================================ >> >> > >> >> > #ifndef quantlib_fitted_bond_i >> >> > #define quantlib_fitted_bond_i >> >> > %include termstructures.i >> >> > %include interpolation.i >> >> > %include ratehelpers.i >> >> > %{ >> >> > using QuantLib::InterpolatedDiscountCurve; >> >> > using QuantLib::FittedBondDiscountCurve; >> >> > using QuantLib::RateHelper; >> >> > using QuantLib::YieldTermStructure; >> >> > typedef boost::shared_ptr<YieldTermStructure> >> >> > FittedBondDiscountCurvePtr; >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod >> >> > FittingMethod; >> >> > %} >> >> > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; >> >> > class FittedBondDiscountCurvePtr : public >> >> > boost::shared_ptr<YieldTermStructure> { >> >> > public: >> >> > %extend { >> >> > FittedBondDiscountCurvePtr(Natural settlementDays, >> >> > const Calendar& calendar, >> >> > const std::vector<boost::shared_ptr<BondHelper> >& >> >> > instruments, >> >> > const DayCounter& dayCounter, >> >> > const FittingMethod& fittingMethod, >> >> > Real accuracy = 1.0e-10, >> >> > Size maxEvaluations = 10000, >> >> > const Array& guess = Array(), >> >> > Real simplexLambda = 1.0) >> >> > { >> >> > return new FittedBondDiscountCurvePtr( >> >> > new FittedBondDiscountCurve( >> >> > settlementDays, >> >> > calendar, >> >> > instruments, >> >> > dayCounter, >> >> > fittingMethod, >> >> > accuracy, >> >> > maxEvaluations, >> >> > guess, >> >> > simplexLambda) >> >> > ); >> >> > } >> >> > FittedBondDiscountCurvePtr(const Date &referenceDate, >> >> > const >> >> > std::vector<boost::shared_ptr<BondHelper> >& instruments, >> >> > const DayCounter& dayCounter, >> >> > const FittingMethod& fittingMethod, >> >> > Real accuracy = 1.0e-10, >> >> > Size maxEvaluations = 10000, >> >> > const Array &guess = Array(), >> >> > Real simplexLambda = 1.0) >> >> > { >> >> > return new FittedBondDiscountCurvePtr( >> >> > new FittedBondDiscountCurve( >> >> > referenceDate, >> >> > instruments, >> >> > dayCounter, >> >> > fittingMethod, >> >> > accuracy, >> >> > maxEvaluations, >> >> > guess, >> >> > simplexLambda) >> >> > ); >> >> > } >> >> > } >> >> > }; >> >> > %{ >> >> > using QuantLib::ExponentialSplinesFitting; >> >> > using QuantLib::NelsonSiegelFitting; >> >> > using QuantLib::CubicBSplinesFitting; >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod >> >> > FittingMethod; >> >> > %} >> >> > %ignore FittingMethod; >> >> > class FittingMethod {}; >> >> > %template(FittingMethod) boost::shared_ptr<FittingMethod>; >> >> > class ExponentialSplinesFitting : public FittingMethod >> >> > { >> >> > public: >> >> > %extend >> >> > { >> >> > ExponentialSplinesFitting(bool constrainAtZero = true) >> >> > { >> >> > return new ExponentialSplinesFitting(constrainAtZero); >> >> > } >> >> > } >> >> > }; >> >> > class NelsonSiegelFitting : public FittingMethod >> >> > { >> >> > public: >> >> > %extend >> >> > { >> >> > NelsonSiegelFitting() >> >> > { >> >> > return new NelsonSiegelFitting(); >> >> > } >> >> > } >> >> > }; >> >> > class CubicBSplinesFitting : public FittingMethod >> >> > { >> >> > public: >> >> > %extend >> >> > { >> >> > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool >> >> > constrainAtZero = true) >> >> > { >> >> > return new CubicBSplinesFitting(knotVector, constrainAtZero); >> >> > } >> >> > } >> >> > }; >> >> > >> >> > #endif >> >> > >> >> > >> >> > >> >> > ------------------------------------------------------------------------------ >> >> > Rapidly troubleshoot problems before they affect your business. Most >> >> > IT >> >> > organizations don't have a clear picture of how application >> >> > performance >> >> > affects their revenue. With AppDynamics, you get 100% visibility into >> >> > your >> >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of >> >> > AppDynamics >> >> > Pro! >> >> > >> >> > >> >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk >> >> > _______________________________________________ >> >> > QuantLib-users mailing list >> >> > [hidden email] >> >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users >> >> > >> >> >> >> >> >> >> >> -- >> >> <https://implementingquantlib.blogspot.com> >> >> <https://twitter.com/lballabio> >> >> >> >> -- >> <https://implementingquantlib.blogspot.com> >> <https://twitter.com/lballabio> -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
The SWIG Version is : Version: 2.0.9 (16 December 2012) and the command I execute is: D:\programe\swigwin\swig -java -c++ -outdir D:\trywrap\QuantLibJava\quantlib_wrap\swig\Java\org\quantlib -package org.quantlib -o quantlib_wrap.cpp D:\trywrap\QuantLibJava\quantlib_wrap\SWIGfilter\quantlib.i thank you wang > Date: Mon, 30 Dec 2013 17:04:45 +0100
> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG > From: [hidden email] > To: [hidden email] > CC: [hidden email] > > That's strange. What SWIG version are you using? And how are you > calling SWIG exactly? > > Luigi > > On Mon, Dec 30, 2013 at 6:32 AM, 静涛 王 <[hidden email]> wrote: > > I'm sorry for that canot complied. Because i changed ratehelper.i. > > > > I complied the attached file and find the > > FittedBondDiscountCurve.class has the next source: > > ================================================================================== > > public FittedBondDiscountCurve(long paramLong1, Calendar paramCalendar, > > BondHelperVector paramBondHelperVector, DayCounter paramDayCounter, > > SWIGTYPE_p_FittingMethod paramSWIGTYPE_p_FittingMethod, double paramDouble1, > > long paramLong2, Array paramArray, double paramDouble2) { > > this(QuantLibJNI.new_FittedBondDiscountCurve__SWIG_0(paramLong1, > > Calendar.getCPtr(paramCalendar), paramCalendar, > > BondHelperVector.getCPtr(paramBondHelperVector), paramBondHelperVector, > > DayCounter.getCPtr(paramDayCounter), paramDayCounter, > > SWIGTYPE_p_FittingMethod.getCPtr(paramSWIGTYPE_p_FittingMethod), > > paramDouble1, paramLong2, Array.getCPtr(paramArray), paramArray, > > paramDouble2), true); > > } > > ================================================================================== > > > > please attention that the FittingMethod is converted into > > SWIGTYPE_p_FittingMethod. > > > > So when complied in java has the error like: > > "The constructor FittedBondDiscountCurve(int, Calendar, > > BondHelperVector,DayCounter, NelsonSiegelFitting) is undefined.". > > > > best reagrds. > > wang > > > > > > > > > >> Date: Fri, 27 Dec 2013 11:18:55 +0100 > >> Subject: Re: FW: [Quantlib-users] Converting FittedBondDiscountCurve to > >> SWIG > > > >> From: [hidden email] > >> To: [hidden email] > >> CC: [hidden email] > >> > >> Hello, > >> your wrappers won't compile, so I'm not sure what you're calling > >> from your Java code. Anyway: > >> - you're using BondHelper, which is not defined in the wrappers; > >> - you're passing a vector of RateHelpers, which can't be implicitly > >> converted to a vector of BondHelpers; > >> - you're declaring pure virtual methods in NelsonSiegelFitting and not > >> declaring them in the derived class, so SWIG thinks it can't > >> instantiate it. > >> > >> The file I'm attaching should fix the problems (look at the > >> differences with your file to see what I've done). I haven't tried it > >> from Java, but at least it compiles. Let me know what happens. > >> > >> Luigi > >> > >> > >> On Fri, Dec 27, 2013 at 1:30 AM, 静涛 王 <[hidden email]> wrote: > >> > luigi > >> > > >> > see the attachments. > >> > I removed the line. but in java the error is as the same. > >> > > >> > the java source is: > >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > >> > > >> > FittedBondDiscountCurve ss = new FittedBondDiscountCurve( > >> > settlementDays, > >> > calendar, > >> > depoSwapInstruments, > >> > bondDayCount, > >> > ns); > >> > > >> > and has the next compile error: > >> >>>The constructor FittedBondDiscountCurve(int, Calendar, > >> >>> BondHelperVector, > >> >>> DayCounter, NelsonSiegelFitting) is undefined. > >> > > >> > and has the next quick fix available: > >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > >> > > >> > any other clues? > >> > > >> > thks. > >> > > >> > > >> > > >> >> Date: Tue, 24 Dec 2013 12:04:25 +0100 > >> >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to > >> >> SWIG > >> >> From: [hidden email] > >> >> To: [hidden email] > >> >> CC: [hidden email] > >> >> > >> >> Hello, > >> >> the constructor expects a reference to a FittingMethod instance, > >> >> but you're exporting it as a shared_ptr. Try removing the line > >> >> > >> >> %template(FittingMethod) boost::shared_ptr<FittingMethod>; > >> >> > >> >> from your SWIG interface. > >> >> > >> >> Luigi > >> >> > >> >> > >> >> On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> wrote: > >> >> > Hi > >> >> > > >> >> > I am also trying to convert the fittedbondcurve class from C++ to > >> >> > java > >> >> > using SWIG. I use a swig file from the mail. > >> >> > > >> >> > > >> >> > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 > >> >> > > >> >> > I call if from: > >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > >> >> > FittedBondDiscountCurve ss = > >> >> > new FittedBondDiscountCurve( > >> >> > settlementDays, > >> >> > calendar, > >> >> > depoSwapInstruments, > >> >> > bondDayCount, > >> >> > ns); > >> >> > } > >> >> > > >> >> > but i get the next complie error: > >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > >> >> > > >> >> > I guess the parent class FittingMethod have not correctly convert to > >> >> > java. > >> >> > > >> >> > any clues? > >> >> > thanks > >> >> > > >> >> > wangjingtao > >> >> > 12/18 > >> >> > > >> >> > > >> >> > the i file is: > >> >> > ============================================ > >> >> > > >> >> > #ifndef quantlib_fitted_bond_i > >> >> > #define quantlib_fitted_bond_i > >> >> > %include termstructures.i > >> >> > %include interpolation.i > >> >> > %include ratehelpers.i > >> >> > %{ > >> >> > using QuantLib::InterpolatedDiscountCurve; > >> >> > using QuantLib::FittedBondDiscountCurve; > >> >> > using QuantLib::RateHelper; > >> >> > using QuantLib::YieldTermStructure; > >> >> > typedef boost::shared_ptr<YieldTermStructure> > >> >> > FittedBondDiscountCurvePtr; > >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod > >> >> > FittingMethod; > >> >> > %} > >> >> > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; > >> >> > class FittedBondDiscountCurvePtr : public > >> >> > boost::shared_ptr<YieldTermStructure> { > >> >> > public: > >> >> > %extend { > >> >> > FittedBondDiscountCurvePtr(Natural settlementDays, > >> >> > const Calendar& calendar, > >> >> > const std::vector<boost::shared_ptr<BondHelper> >& > >> >> > instruments, > >> >> > const DayCounter& dayCounter, > >> >> > const FittingMethod& fittingMethod, > >> >> > Real accuracy = 1.0e-10, > >> >> > Size maxEvaluations = 10000, > >> >> > const Array& guess = Array(), > >> >> > Real simplexLambda = 1.0) > >> >> > { > >> >> > return new FittedBondDiscountCurvePtr( > >> >> > new FittedBondDiscountCurve( > >> >> > settlementDays, > >> >> > calendar, > >> >> > instruments, > >> >> > dayCounter, > >> >> > fittingMethod, > >> >> > accuracy, > >> >> > maxEvaluations, > >> >> > guess, > >> >> > simplexLambda) > >> >> > ); > >> >> > } > >> >> > FittedBondDiscountCurvePtr(const Date &referenceDate, > >> >> > const > >> >> > std::vector<boost::shared_ptr<BondHelper> >& instruments, > >> >> > const DayCounter& dayCounter, > >> >> > const FittingMethod& fittingMethod, > >> >> > Real accuracy = 1.0e-10, > >> >> > Size maxEvaluations = 10000, > >> >> > const Array &guess = Array(), > >> >> > Real simplexLambda = 1.0) > >> >> > { > >> >> > return new FittedBondDiscountCurvePtr( > >> >> > new FittedBondDiscountCurve( > >> >> > referenceDate, > >> >> > instruments, > >> >> > dayCounter, > >> >> > fittingMethod, > >> >> > accuracy, > >> >> > maxEvaluations, > >> >> > guess, > >> >> > simplexLambda) > >> >> > ); > >> >> > } > >> >> > } > >> >> > }; > >> >> > %{ > >> >> > using QuantLib::ExponentialSplinesFitting; > >> >> > using QuantLib::NelsonSiegelFitting; > >> >> > using QuantLib::CubicBSplinesFitting; > >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod > >> >> > FittingMethod; > >> >> > %} > >> >> > %ignore FittingMethod; > >> >> > class FittingMethod {}; > >> >> > %template(FittingMethod) boost::shared_ptr<FittingMethod>; > >> >> > class ExponentialSplinesFitting : public FittingMethod > >> >> > { > >> >> > public: > >> >> > %extend > >> >> > { > >> >> > ExponentialSplinesFitting(bool constrainAtZero = true) > >> >> > { > >> >> > return new ExponentialSplinesFitting(constrainAtZero); > >> >> > } > >> >> > } > >> >> > }; > >> >> > class NelsonSiegelFitting : public FittingMethod > >> >> > { > >> >> > public: > >> >> > %extend > >> >> > { > >> >> > NelsonSiegelFitting() > >> >> > { > >> >> > return new NelsonSiegelFitting(); > >> >> > } > >> >> > } > >> >> > }; > >> >> > class CubicBSplinesFitting : public FittingMethod > >> >> > { > >> >> > public: > >> >> > %extend > >> >> > { > >> >> > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool > >> >> > constrainAtZero = true) > >> >> > { > >> >> > return new CubicBSplinesFitting(knotVector, constrainAtZero); > >> >> > } > >> >> > } > >> >> > }; > >> >> > > >> >> > #endif > >> >> > > >> >> > > >> >> > > >> >> > ------------------------------------------------------------------------------ > >> >> > Rapidly troubleshoot problems before they affect your business. Most > >> >> > IT > >> >> > organizations don't have a clear picture of how application > >> >> > performance > >> >> > affects their revenue. With AppDynamics, you get 100% visibility into > >> >> > your > >> >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of > >> >> > AppDynamics > >> >> > Pro! > >> >> > > >> >> > > >> >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > >> >> > _______________________________________________ > >> >> > QuantLib-users mailing list > >> >> > [hidden email] > >> >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> <https://implementingquantlib.blogspot.com> > >> >> <https://twitter.com/lballabio> > >> > >> > >> > >> -- > >> <https://implementingquantlib.blogspot.com> > >> <https://twitter.com/lballabio> > > > > -- > <https://implementingquantlib.blogspot.com> > <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I'm using 2.0.11, but it shouldn't make a difference.
Are you sure you're using the same file I sent you? The fact that a) your files live in a folder called SWIGfilter and b) the names of your parameters are all changed (paramLong1, paramCalendar etc instead of settlementDays, calendar...) makes me suspect that there's some preprocessing going on. Luigi On Tue, Dec 31, 2013 at 2:51 AM, 静涛 王 <[hidden email]> wrote: > The SWIG Version is : > Version: 2.0.9 (16 December 2012) > > and the command I execute is: > > D:\programe\swigwin\swig -java -c++ -outdir > D:\trywrap\QuantLibJava\quantlib_wrap\swig\Java\org\quantlib -package > org.quantlib -o quantlib_wrap.cpp > D:\trywrap\QuantLibJava\quantlib_wrap\SWIGfilter\quantlib.i > > thank you > wang > >> Date: Mon, 30 Dec 2013 17:04:45 +0100 > >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG >> From: [hidden email] >> To: [hidden email] >> CC: [hidden email] >> >> That's strange. What SWIG version are you using? And how are you >> calling SWIG exactly? >> >> Luigi >> >> On Mon, Dec 30, 2013 at 6:32 AM, 静涛 王 <[hidden email]> wrote: >> > I'm sorry for that canot complied. Because i changed ratehelper.i. >> > >> > I complied the attached file and find the >> > FittedBondDiscountCurve.class has the next source: >> > >> > ================================================================================== >> > public FittedBondDiscountCurve(long paramLong1, Calendar paramCalendar, >> > BondHelperVector paramBondHelperVector, DayCounter paramDayCounter, >> > SWIGTYPE_p_FittingMethod paramSWIGTYPE_p_FittingMethod, double >> > paramDouble1, >> > long paramLong2, Array paramArray, double paramDouble2) { >> > this(QuantLibJNI.new_FittedBondDiscountCurve__SWIG_0(paramLong1, >> > Calendar.getCPtr(paramCalendar), paramCalendar, >> > BondHelperVector.getCPtr(paramBondHelperVector), paramBondHelperVector, >> > DayCounter.getCPtr(paramDayCounter), paramDayCounter, >> > SWIGTYPE_p_FittingMethod.getCPtr(paramSWIGTYPE_p_FittingMethod), >> > paramDouble1, paramLong2, Array.getCPtr(paramArray), paramArray, >> > paramDouble2), true); >> > } >> > >> > ================================================================================== >> > >> > please attention that the FittingMethod is converted into >> > SWIGTYPE_p_FittingMethod. >> > >> > So when complied in java has the error like: >> > "The constructor FittedBondDiscountCurve(int, Calendar, >> > BondHelperVector,DayCounter, NelsonSiegelFitting) is undefined.". >> > >> > best reagrds. >> > wang >> > >> > >> > >> > >> >> Date: Fri, 27 Dec 2013 11:18:55 +0100 >> >> Subject: Re: FW: [Quantlib-users] Converting FittedBondDiscountCurve to >> >> SWIG >> > >> >> From: [hidden email] >> >> To: [hidden email] >> >> CC: [hidden email] >> >> >> >> Hello, >> >> your wrappers won't compile, so I'm not sure what you're calling >> >> from your Java code. Anyway: >> >> - you're using BondHelper, which is not defined in the wrappers; >> >> - you're passing a vector of RateHelpers, which can't be implicitly >> >> converted to a vector of BondHelpers; >> >> - you're declaring pure virtual methods in NelsonSiegelFitting and not >> >> declaring them in the derived class, so SWIG thinks it can't >> >> instantiate it. >> >> >> >> The file I'm attaching should fix the problems (look at the >> >> differences with your file to see what I've done). I haven't tried it >> >> from Java, but at least it compiles. Let me know what happens. >> >> >> >> Luigi >> >> >> >> >> >> On Fri, Dec 27, 2013 at 1:30 AM, 静涛 王 <[hidden email]> wrote: >> >> > luigi >> >> > >> >> > see the attachments. >> >> > I removed the line. but in java the error is as the same. >> >> > >> >> > the java source is: >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); >> >> > >> >> > FittedBondDiscountCurve ss = new FittedBondDiscountCurve( >> >> > settlementDays, >> >> > calendar, >> >> > depoSwapInstruments, >> >> > bondDayCount, >> >> > ns); >> >> > >> >> > and has the next compile error: >> >> >>>The constructor FittedBondDiscountCurve(int, Calendar, >> >> >>> BondHelperVector, >> >> >>> DayCounter, NelsonSiegelFitting) is undefined. >> >> > >> >> > and has the next quick fix available: >> >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' >> >> > >> >> > any other clues? >> >> > >> >> > thks. >> >> > >> >> > >> >> > >> >> >> Date: Tue, 24 Dec 2013 12:04:25 +0100 >> >> >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to >> >> >> SWIG >> >> >> From: [hidden email] >> >> >> To: [hidden email] >> >> >> CC: [hidden email] >> >> >> >> >> >> Hello, >> >> >> the constructor expects a reference to a FittingMethod instance, >> >> >> but you're exporting it as a shared_ptr. Try removing the line >> >> >> >> >> >> %template(FittingMethod) boost::shared_ptr<FittingMethod>; >> >> >> >> >> >> from your SWIG interface. >> >> >> >> >> >> Luigi >> >> >> >> >> >> >> >> >> On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> wrote: >> >> >> > Hi >> >> >> > >> >> >> > I am also trying to convert the fittedbondcurve class from C++ to >> >> >> > java >> >> >> > using SWIG. I use a swig file from the mail. >> >> >> > >> >> >> > >> >> >> > >> >> >> > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 >> >> >> > >> >> >> > I call if from: >> >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); >> >> >> > FittedBondDiscountCurve ss = >> >> >> > new FittedBondDiscountCurve( >> >> >> > settlementDays, >> >> >> > calendar, >> >> >> > depoSwapInstruments, >> >> >> > bondDayCount, >> >> >> > ns); >> >> >> > } >> >> >> > >> >> >> > but i get the next complie error: >> >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' >> >> >> > >> >> >> > I guess the parent class FittingMethod have not correctly convert >> >> >> > to >> >> >> > java. >> >> >> > >> >> >> > any clues? >> >> >> > thanks >> >> >> > >> >> >> > wangjingtao >> >> >> > 12/18 >> >> >> > >> >> >> > >> >> >> > the i file is: >> >> >> > ============================================ >> >> >> > >> >> >> > #ifndef quantlib_fitted_bond_i >> >> >> > #define quantlib_fitted_bond_i >> >> >> > %include termstructures.i >> >> >> > %include interpolation.i >> >> >> > %include ratehelpers.i >> >> >> > %{ >> >> >> > using QuantLib::InterpolatedDiscountCurve; >> >> >> > using QuantLib::FittedBondDiscountCurve; >> >> >> > using QuantLib::RateHelper; >> >> >> > using QuantLib::YieldTermStructure; >> >> >> > typedef boost::shared_ptr<YieldTermStructure> >> >> >> > FittedBondDiscountCurvePtr; >> >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod >> >> >> > FittingMethod; >> >> >> > %} >> >> >> > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; >> >> >> > class FittedBondDiscountCurvePtr : public >> >> >> > boost::shared_ptr<YieldTermStructure> { >> >> >> > public: >> >> >> > %extend { >> >> >> > FittedBondDiscountCurvePtr(Natural settlementDays, >> >> >> > const Calendar& calendar, >> >> >> > const std::vector<boost::shared_ptr<BondHelper> >& >> >> >> > instruments, >> >> >> > const DayCounter& dayCounter, >> >> >> > const FittingMethod& fittingMethod, >> >> >> > Real accuracy = 1.0e-10, >> >> >> > Size maxEvaluations = 10000, >> >> >> > const Array& guess = Array(), >> >> >> > Real simplexLambda = 1.0) >> >> >> > { >> >> >> > return new FittedBondDiscountCurvePtr( >> >> >> > new FittedBondDiscountCurve( >> >> >> > settlementDays, >> >> >> > calendar, >> >> >> > instruments, >> >> >> > dayCounter, >> >> >> > fittingMethod, >> >> >> > accuracy, >> >> >> > maxEvaluations, >> >> >> > guess, >> >> >> > simplexLambda) >> >> >> > ); >> >> >> > } >> >> >> > FittedBondDiscountCurvePtr(const Date &referenceDate, >> >> >> > const >> >> >> > std::vector<boost::shared_ptr<BondHelper> >& instruments, >> >> >> > const DayCounter& dayCounter, >> >> >> > const FittingMethod& fittingMethod, >> >> >> > Real accuracy = 1.0e-10, >> >> >> > Size maxEvaluations = 10000, >> >> >> > const Array &guess = Array(), >> >> >> > Real simplexLambda = 1.0) >> >> >> > { >> >> >> > return new FittedBondDiscountCurvePtr( >> >> >> > new FittedBondDiscountCurve( >> >> >> > referenceDate, >> >> >> > instruments, >> >> >> > dayCounter, >> >> >> > fittingMethod, >> >> >> > accuracy, >> >> >> > maxEvaluations, >> >> >> > guess, >> >> >> > simplexLambda) >> >> >> > ); >> >> >> > } >> >> >> > } >> >> >> > }; >> >> >> > %{ >> >> >> > using QuantLib::ExponentialSplinesFitting; >> >> >> > using QuantLib::NelsonSiegelFitting; >> >> >> > using QuantLib::CubicBSplinesFitting; >> >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod >> >> >> > FittingMethod; >> >> >> > %} >> >> >> > %ignore FittingMethod; >> >> >> > class FittingMethod {}; >> >> >> > %template(FittingMethod) boost::shared_ptr<FittingMethod>; >> >> >> > class ExponentialSplinesFitting : public FittingMethod >> >> >> > { >> >> >> > public: >> >> >> > %extend >> >> >> > { >> >> >> > ExponentialSplinesFitting(bool constrainAtZero = true) >> >> >> > { >> >> >> > return new ExponentialSplinesFitting(constrainAtZero); >> >> >> > } >> >> >> > } >> >> >> > }; >> >> >> > class NelsonSiegelFitting : public FittingMethod >> >> >> > { >> >> >> > public: >> >> >> > %extend >> >> >> > { >> >> >> > NelsonSiegelFitting() >> >> >> > { >> >> >> > return new NelsonSiegelFitting(); >> >> >> > } >> >> >> > } >> >> >> > }; >> >> >> > class CubicBSplinesFitting : public FittingMethod >> >> >> > { >> >> >> > public: >> >> >> > %extend >> >> >> > { >> >> >> > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool >> >> >> > constrainAtZero = true) >> >> >> > { >> >> >> > return new CubicBSplinesFitting(knotVector, constrainAtZero); >> >> >> > } >> >> >> > } >> >> >> > }; >> >> >> > >> >> >> > #endif >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > ------------------------------------------------------------------------------ >> >> >> > Rapidly troubleshoot problems before they affect your business. >> >> >> > Most >> >> >> > IT >> >> >> > organizations don't have a clear picture of how application >> >> >> > performance >> >> >> > affects their revenue. With AppDynamics, you get 100% visibility >> >> >> > into >> >> >> > your >> >> >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of >> >> >> > AppDynamics >> >> >> > Pro! >> >> >> > >> >> >> > >> >> >> > >> >> >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk >> >> >> > _______________________________________________ >> >> >> > QuantLib-users mailing list >> >> >> > [hidden email] >> >> >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> <https://implementingquantlib.blogspot.com> >> >> >> <https://twitter.com/lballabio> >> >> >> >> >> >> >> >> -- >> >> <https://implementingquantlib.blogspot.com> >> >> <https://twitter.com/lballabio> >> >> >> >> -- >> <https://implementingquantlib.blogspot.com> >> <https://twitter.com/lballabio> -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I'm sure that the .i file is the same.
and I put all the .i file in the SWIGfilter folder. " paramLong1" is the parameter so i think it's no problem. what's the param name in your java file? Now I set the FittingMethod's declaration in the .i file to avoid this problem. wang tks > Date: Thu, 2 Jan 2014 18:12:53 +0100 > Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG > From: [hidden email] > To: [hidden email] > CC: [hidden email] > > I'm using 2.0.11, but it shouldn't make a difference. > > Are you sure you're using the same file I sent you? The fact that a) > your files live in a folder called SWIGfilter and b) the names of your > parameters are all changed (paramLong1, paramCalendar etc instead of > settlementDays, calendar...) makes me suspect that there's some > preprocessing going on. > > Luigi > > > On Tue, Dec 31, 2013 at 2:51 AM, 静涛 王 <[hidden email]> wrote: > > The SWIG Version is : > > Version: 2.0.9 (16 December 2012) > > > > and the command I execute is: > > > > D:\programe\swigwin\swig -java -c++ -outdir > > D:\trywrap\QuantLibJava\quantlib_wrap\swig\Java\org\quantlib -package > > org.quantlib -o quantlib_wrap.cpp > > D:\trywrap\QuantLibJava\quantlib_wrap\SWIGfilter\quantlib.i > > > > thank you > > wang > > > >> Date: Mon, 30 Dec 2013 17:04:45 +0100 > > > >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG > >> From: [hidden email] > >> To: [hidden email] > >> CC: [hidden email] > >> > >> That's strange. What SWIG version are you using? And how are you > >> calling SWIG exactly? > >> > >> Luigi > >> > >> On Mon, Dec 30, 2013 at 6:32 AM, 静涛 王 <[hidden email]> wrote: > >> > I'm sorry for that canot complied. Because i changed ratehelper.i. > >> > > >> > I complied the attached file and find the > >> > FittedBondDiscountCurve.class has the next source: > >> > > >> > ================================================================================== > >> > public FittedBondDiscountCurve(long paramLong1, Calendar paramCalendar, > >> > BondHelperVector paramBondHelperVector, DayCounter paramDayCounter, > >> > SWIGTYPE_p_FittingMethod paramSWIGTYPE_p_FittingMethod, double > >> > paramDouble1, > >> > long paramLong2, Array paramArray, double paramDouble2) { > >> > this(QuantLibJNI.new_FittedBondDiscountCurve__SWIG_0(paramLong1, > >> > Calendar.getCPtr(paramCalendar), paramCalendar, > >> > BondHelperVector.getCPtr(paramBondHelperVector), paramBondHelperVector, > >> > DayCounter.getCPtr(paramDayCounter), paramDayCounter, > >> > SWIGTYPE_p_FittingMethod.getCPtr(paramSWIGTYPE_p_FittingMethod), > >> > paramDouble1, paramLong2, Array.getCPtr(paramArray), paramArray, > >> > paramDouble2), true); > >> > } > >> > > >> > ================================================================================== > >> > > >> > please attention that the FittingMethod is converted into > >> > SWIGTYPE_p_FittingMethod. > >> > > >> > So when complied in java has the error like: > >> > "The constructor FittedBondDiscountCurve(int, Calendar, > >> > BondHelperVector,DayCounter, NelsonSiegelFitting) is undefined.". > >> > > >> > best reagrds. > >> > wang > >> > > >> > > >> > > >> > > >> >> Date: Fri, 27 Dec 2013 11:18:55 +0100 > >> >> Subject: Re: FW: [Quantlib-users] Converting FittedBondDiscountCurve to > >> >> SWIG > >> > > >> >> From: [hidden email] > >> >> To: [hidden email] > >> >> CC: [hidden email] > >> >> > >> >> Hello, > >> >> your wrappers won't compile, so I'm not sure what you're calling > >> >> from your Java code. Anyway: > >> >> - you're using BondHelper, which is not defined in the wrappers; > >> >> - you're passing a vector of RateHelpers, which can't be implicitly > >> >> converted to a vector of BondHelpers; > >> >> - you're declaring pure virtual methods in NelsonSiegelFitting and not > >> >> declaring them in the derived class, so SWIG thinks it can't > >> >> instantiate it. > >> >> > >> >> The file I'm attaching should fix the problems (look at the > >> >> differences with your file to see what I've done). I haven't tried it > >> >> from Java, but at least it compiles. Let me know what happens. > >> >> > >> >> Luigi > >> >> > >> >> > >> >> On Fri, Dec 27, 2013 at 1:30 AM, 静涛 王 <[hidden email]> wrote: > >> >> > luigi > >> >> > > >> >> > see the attachments. > >> >> > I removed the line. but in java the error is as the same. > >> >> > > >> >> > the java source is: > >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > >> >> > > >> >> > FittedBondDiscountCurve ss = new FittedBondDiscountCurve( > >> >> > settlementDays, > >> >> > calendar, > >> >> > depoSwapInstruments, > >> >> > bondDayCount, > >> >> > ns); > >> >> > > >> >> > and has the next compile error: > >> >> >>>The constructor FittedBondDiscountCurve(int, Calendar, > >> >> >>> BondHelperVector, > >> >> >>> DayCounter, NelsonSiegelFitting) is undefined. > >> >> > > >> >> > and has the next quick fix available: > >> >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > >> >> > > >> >> > any other clues? > >> >> > > >> >> > thks. > >> >> > > >> >> > > >> >> > > >> >> >> Date: Tue, 24 Dec 2013 12:04:25 +0100 > >> >> >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to > >> >> >> SWIG > >> >> >> From: [hidden email] > >> >> >> To: [hidden email] > >> >> >> CC: [hidden email] > >> >> >> > >> >> >> Hello, > >> >> >> the constructor expects a reference to a FittingMethod instance, > >> >> >> but you're exporting it as a shared_ptr. Try removing the line > >> >> >> > >> >> >> %template(FittingMethod) boost::shared_ptr<FittingMethod>; > >> >> >> > >> >> >> from your SWIG interface. > >> >> >> > >> >> >> Luigi > >> >> >> > >> >> >> > >> >> >> On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> wrote: > >> >> >> > Hi > >> >> >> > > >> >> >> > I am also trying to convert the fittedbondcurve class from C++ to > >> >> >> > java > >> >> >> > using SWIG. I use a swig file from the mail. > >> >> >> > > >> >> >> > > >> >> >> > > >> >> >> > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 > >> >> >> > > >> >> >> > I call if from: > >> >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > >> >> >> > FittedBondDiscountCurve ss = > >> >> >> > new FittedBondDiscountCurve( > >> >> >> > settlementDays, > >> >> >> > calendar, > >> >> >> > depoSwapInstruments, > >> >> >> > bondDayCount, > >> >> >> > ns); > >> >> >> > } > >> >> >> > > >> >> >> > but i get the next complie error: > >> >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > >> >> >> > > >> >> >> > I guess the parent class FittingMethod have not correctly convert > >> >> >> > to > >> >> >> > java. > >> >> >> > > >> >> >> > any clues? > >> >> >> > thanks > >> >> >> > > >> >> >> > wangjingtao > >> >> >> > 12/18 > >> >> >> > > >> >> >> > > >> >> >> > the i file is: > >> >> >> > ============================================ > >> >> >> > > >> >> >> > #ifndef quantlib_fitted_bond_i > >> >> >> > #define quantlib_fitted_bond_i > >> >> >> > %include termstructures.i > >> >> >> > %include interpolation.i > >> >> >> > %include ratehelpers.i > >> >> >> > %{ > >> >> >> > using QuantLib::InterpolatedDiscountCurve; > >> >> >> > using QuantLib::FittedBondDiscountCurve; > >> >> >> > using QuantLib::RateHelper; > >> >> >> > using QuantLib::YieldTermStructure; > >> >> >> > typedef boost::shared_ptr<YieldTermStructure> > >> >> >> > FittedBondDiscountCurvePtr; > >> >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod > >> >> >> > FittingMethod; > >> >> >> > %} > >> >> >> > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; > >> >> >> > class FittedBondDiscountCurvePtr : public > >> >> >> > boost::shared_ptr<YieldTermStructure> { > >> >> >> > public: > >> >> >> > %extend { > >> >> >> > FittedBondDiscountCurvePtr(Natural settlementDays, > >> >> >> > const Calendar& calendar, > >> >> >> > const std::vector<boost::shared_ptr<BondHelper> >& > >> >> >> > instruments, > >> >> >> > const DayCounter& dayCounter, > >> >> >> > const FittingMethod& fittingMethod, > >> >> >> > Real accuracy = 1.0e-10, > >> >> >> > Size maxEvaluations = 10000, > >> >> >> > const Array& guess = Array(), > >> >> >> > Real simplexLambda = 1.0) > >> >> >> > { > >> >> >> > return new FittedBondDiscountCurvePtr( > >> >> >> > new FittedBondDiscountCurve( > >> >> >> > settlementDays, > >> >> >> > calendar, > >> >> >> > instruments, > >> >> >> > dayCounter, > >> >> >> > fittingMethod, > >> >> >> > accuracy, > >> >> >> > maxEvaluations, > >> >> >> > guess, > >> >> >> > simplexLambda) > >> >> >> > ); > >> >> >> > } > >> >> >> > FittedBondDiscountCurvePtr(const Date &referenceDate, > >> >> >> > const > >> >> >> > std::vector<boost::shared_ptr<BondHelper> >& instruments, > >> >> >> > const DayCounter& dayCounter, > >> >> >> > const FittingMethod& fittingMethod, > >> >> >> > Real accuracy = 1.0e-10, > >> >> >> > Size maxEvaluations = 10000, > >> >> >> > const Array &guess = Array(), > >> >> >> > Real simplexLambda = 1.0) > >> >> >> > { > >> >> >> > return new FittedBondDiscountCurvePtr( > >> >> >> > new FittedBondDiscountCurve( > >> >> >> > referenceDate, > >> >> >> > instruments, > >> >> >> > dayCounter, > >> >> >> > fittingMethod, > >> >> >> > accuracy, > >> >> >> > maxEvaluations, > >> >> >> > guess, > >> >> >> > simplexLambda) > >> >> >> > ); > >> >> >> > } > >> >> >> > } > >> >> >> > }; > >> >> >> > %{ > >> >> >> > using QuantLib::ExponentialSplinesFitting; > >> >> >> > using QuantLib::NelsonSiegelFitting; > >> >> >> > using QuantLib::CubicBSplinesFitting; > >> >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod > >> >> >> > FittingMethod; > >> >> >> > %} > >> >> >> > %ignore FittingMethod; > >> >> >> > class FittingMethod {}; > >> >> >> > %template(FittingMethod) boost::shared_ptr<FittingMethod>; > >> >> >> > class ExponentialSplinesFitting : public FittingMethod > >> >> >> > { > >> >> >> > public: > >> >> >> > %extend > >> >> >> > { > >> >> >> > ExponentialSplinesFitting(bool constrainAtZero = true) > >> >> >> > { > >> >> >> > return new ExponentialSplinesFitting(constrainAtZero); > >> >> >> > } > >> >> >> > } > >> >> >> > }; > >> >> >> > class NelsonSiegelFitting : public FittingMethod > >> >> >> > { > >> >> >> > public: > >> >> >> > %extend > >> >> >> > { > >> >> >> > NelsonSiegelFitting() > >> >> >> > { > >> >> >> > return new NelsonSiegelFitting(); > >> >> >> > } > >> >> >> > } > >> >> >> > }; > >> >> >> > class CubicBSplinesFitting : public FittingMethod > >> >> >> > { > >> >> >> > public: > >> >> >> > %extend > >> >> >> > { > >> >> >> > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool > >> >> >> > constrainAtZero = true) > >> >> >> > { > >> >> >> > return new CubicBSplinesFitting(knotVector, constrainAtZero); > >> >> >> > } > >> >> >> > } > >> >> >> > }; > >> >> >> > > >> >> >> > #endif > >> >> >> > > >> >> >> > > >> >> >> > > >> >> >> > > >> >> >> > ------------------------------------------------------------------------------ > >> >> >> > Rapidly troubleshoot problems before they affect your business. > >> >> >> > Most > >> >> >> > IT > >> >> >> > organizations don't have a clear picture of how application > >> >> >> > performance > >> >> >> > affects their revenue. With AppDynamics, you get 100% visibility > >> >> >> > into > >> >> >> > your > >> >> >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of > >> >> >> > AppDynamics > >> >> >> > Pro! > >> >> >> > > >> >> >> > > >> >> >> > > >> >> >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > >> >> >> > _______________________________________________ > >> >> >> > QuantLib-users mailing list > >> >> >> > [hidden email] > >> >> >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users > >> >> >> > > >> >> >> > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> <https://implementingquantlib.blogspot.com> > >> >> >> <https://twitter.com/lballabio> > >> >> > >> >> > >> >> > >> >> -- > >> >> <https://implementingquantlib.blogspot.com> > >> >> <https://twitter.com/lballabio> > >> > >> > >> > >> -- > >> <https://implementingquantlib.blogspot.com> > >> <https://twitter.com/lballabio> > > > > -- > <https://implementingquantlib.blogspot.com> > <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
The parameter in my Java file is called settlementDays, which is
exactly the same name that it's given in the .i file; SWIG doesn't modify it, which is why I'm suspecting that your build system is modifying the interface files somehow, or that SWIG is picking up the wrong file. Can you try modifying the .i file and seeing if SWIG picks up the change? (For instance, change the first parameter from "Natural settlementDays" to "int settlementDays".) Luigi On Tue, Jan 7, 2014 at 7:58 AM, 静涛 王 <[hidden email]> wrote: > I'm sure that the .i file is the same. > and I put all the .i file in the SWIGfilter folder. > " paramLong1" is the parameter so i think it's no problem. > what's the param name in your java file? > > Now I set the FittingMethod's declaration in the .i file to avoid this > problem. > > > wang > tks > >> Date: Thu, 2 Jan 2014 18:12:53 +0100 > >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG >> From: [hidden email] >> To: [hidden email] >> CC: [hidden email] >> >> I'm using 2.0.11, but it shouldn't make a difference. >> >> Are you sure you're using the same file I sent you? The fact that a) >> your files live in a folder called SWIGfilter and b) the names of your >> parameters are all changed (paramLong1, paramCalendar etc instead of >> settlementDays, calendar...) makes me suspect that there's some >> preprocessing going on. >> >> Luigi >> >> >> On Tue, Dec 31, 2013 at 2:51 AM, 静涛 王 <[hidden email]> wrote: >> > The SWIG Version is : >> > Version: 2.0.9 (16 December 2012) >> > >> > and the command I execute is: >> > >> > D:\programe\swigwin\swig -java -c++ -outdir >> > D:\trywrap\QuantLibJava\quantlib_wrap\swig\Java\org\quantlib -package >> > org.quantlib -o quantlib_wrap.cpp >> > D:\trywrap\QuantLibJava\quantlib_wrap\SWIGfilter\quantlib.i >> > >> > thank you >> > wang >> > >> >> Date: Mon, 30 Dec 2013 17:04:45 +0100 >> > >> >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to >> >> SWIG >> >> From: [hidden email] >> >> To: [hidden email] >> >> CC: [hidden email] >> >> >> >> That's strange. What SWIG version are you using? And how are you >> >> calling SWIG exactly? >> >> >> >> Luigi >> >> >> >> On Mon, Dec 30, 2013 at 6:32 AM, 静涛 王 <[hidden email]> wrote: >> >> > I'm sorry for that canot complied. Because i changed ratehelper.i. >> >> > >> >> > I complied the attached file and find the >> >> > FittedBondDiscountCurve.class has the next source: >> >> > >> >> > >> >> > ================================================================================== >> >> > public FittedBondDiscountCurve(long paramLong1, Calendar >> >> > paramCalendar, >> >> > BondHelperVector paramBondHelperVector, DayCounter paramDayCounter, >> >> > SWIGTYPE_p_FittingMethod paramSWIGTYPE_p_FittingMethod, double >> >> > paramDouble1, >> >> > long paramLong2, Array paramArray, double paramDouble2) { >> >> > this(QuantLibJNI.new_FittedBondDiscountCurve__SWIG_0(paramLong1, >> >> > Calendar.getCPtr(paramCalendar), paramCalendar, >> >> > BondHelperVector.getCPtr(paramBondHelperVector), >> >> > paramBondHelperVector, >> >> > DayCounter.getCPtr(paramDayCounter), paramDayCounter, >> >> > SWIGTYPE_p_FittingMethod.getCPtr(paramSWIGTYPE_p_FittingMethod), >> >> > paramDouble1, paramLong2, Array.getCPtr(paramArray), paramArray, >> >> > paramDouble2), true); >> >> > } >> >> > >> >> > >> >> > ================================================================================== >> >> > >> >> > please attention that the FittingMethod is converted into >> >> > SWIGTYPE_p_FittingMethod. >> >> > >> >> > So when complied in java has the error like: >> >> > "The constructor FittedBondDiscountCurve(int, Calendar, >> >> > BondHelperVector,DayCounter, NelsonSiegelFitting) is undefined.". >> >> > >> >> > best reagrds. >> >> > wang >> >> > >> >> > >> >> > >> >> > >> >> >> Date: Fri, 27 Dec 2013 11:18:55 +0100 >> >> >> Subject: Re: FW: [Quantlib-users] Converting FittedBondDiscountCurve >> >> >> to >> >> >> SWIG >> >> > >> >> >> From: [hidden email] >> >> >> To: [hidden email] >> >> >> CC: [hidden email] >> >> >> >> >> >> Hello, >> >> >> your wrappers won't compile, so I'm not sure what you're calling >> >> >> from your Java code. Anyway: >> >> >> - you're using BondHelper, which is not defined in the wrappers; >> >> >> - you're passing a vector of RateHelpers, which can't be implicitly >> >> >> converted to a vector of BondHelpers; >> >> >> - you're declaring pure virtual methods in NelsonSiegelFitting and >> >> >> not >> >> >> declaring them in the derived class, so SWIG thinks it can't >> >> >> instantiate it. >> >> >> >> >> >> The file I'm attaching should fix the problems (look at the >> >> >> differences with your file to see what I've done). I haven't tried >> >> >> it >> >> >> from Java, but at least it compiles. Let me know what happens. >> >> >> >> >> >> Luigi >> >> >> >> >> >> >> >> >> On Fri, Dec 27, 2013 at 1:30 AM, 静涛 王 <[hidden email]> wrote: >> >> >> > luigi >> >> >> > >> >> >> > see the attachments. >> >> >> > I removed the line. but in java the error is as the same. >> >> >> > >> >> >> > the java source is: >> >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); >> >> >> > >> >> >> > FittedBondDiscountCurve ss = new FittedBondDiscountCurve( >> >> >> > settlementDays, >> >> >> > calendar, >> >> >> > depoSwapInstruments, >> >> >> > bondDayCount, >> >> >> > ns); >> >> >> > >> >> >> > and has the next compile error: >> >> >> >>>The constructor FittedBondDiscountCurve(int, Calendar, >> >> >> >>> BondHelperVector, >> >> >> >>> DayCounter, NelsonSiegelFitting) is undefined. >> >> >> > >> >> >> > and has the next quick fix available: >> >> >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' >> >> >> > >> >> >> > any other clues? >> >> >> > >> >> >> > thks. >> >> >> > >> >> >> > >> >> >> > >> >> >> >> Date: Tue, 24 Dec 2013 12:04:25 +0100 >> >> >> >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve >> >> >> >> to >> >> >> >> SWIG >> >> >> >> From: [hidden email] >> >> >> >> To: [hidden email] >> >> >> >> CC: [hidden email] >> >> >> >> >> >> >> >> Hello, >> >> >> >> the constructor expects a reference to a FittingMethod instance, >> >> >> >> but you're exporting it as a shared_ptr. Try removing the line >> >> >> >> >> >> >> >> %template(FittingMethod) boost::shared_ptr<FittingMethod>; >> >> >> >> >> >> >> >> from your SWIG interface. >> >> >> >> >> >> >> >> Luigi >> >> >> >> >> >> >> >> >> >> >> >> On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> >> >> >> >> wrote: >> >> >> >> > Hi >> >> >> >> > >> >> >> >> > I am also trying to convert the fittedbondcurve class from C++ >> >> >> >> > to >> >> >> >> > java >> >> >> >> > using SWIG. I use a swig file from the mail. >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 >> >> >> >> > >> >> >> >> > I call if from: >> >> >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); >> >> >> >> > FittedBondDiscountCurve ss = >> >> >> >> > new FittedBondDiscountCurve( >> >> >> >> > settlementDays, >> >> >> >> > calendar, >> >> >> >> > depoSwapInstruments, >> >> >> >> > bondDayCount, >> >> >> >> > ns); >> >> >> >> > } >> >> >> >> > >> >> >> >> > but i get the next complie error: >> >> >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' >> >> >> >> > >> >> >> >> > I guess the parent class FittingMethod have not correctly >> >> >> >> > convert >> >> >> >> > to >> >> >> >> > java. >> >> >> >> > >> >> >> >> > any clues? >> >> >> >> > thanks >> >> >> >> > >> >> >> >> > wangjingtao >> >> >> >> > 12/18 >> >> >> >> > >> >> >> >> > >> >> >> >> > the i file is: >> >> >> >> > ============================================ >> >> >> >> > >> >> >> >> > #ifndef quantlib_fitted_bond_i >> >> >> >> > #define quantlib_fitted_bond_i >> >> >> >> > %include termstructures.i >> >> >> >> > %include interpolation.i >> >> >> >> > %include ratehelpers.i >> >> >> >> > %{ >> >> >> >> > using QuantLib::InterpolatedDiscountCurve; >> >> >> >> > using QuantLib::FittedBondDiscountCurve; >> >> >> >> > using QuantLib::RateHelper; >> >> >> >> > using QuantLib::YieldTermStructure; >> >> >> >> > typedef boost::shared_ptr<YieldTermStructure> >> >> >> >> > FittedBondDiscountCurvePtr; >> >> >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod >> >> >> >> > FittingMethod; >> >> >> >> > %} >> >> >> >> > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; >> >> >> >> > class FittedBondDiscountCurvePtr : public >> >> >> >> > boost::shared_ptr<YieldTermStructure> { >> >> >> >> > public: >> >> >> >> > %extend { >> >> >> >> > FittedBondDiscountCurvePtr(Natural settlementDays, >> >> >> >> > const Calendar& calendar, >> >> >> >> > const std::vector<boost::shared_ptr<BondHelper> >& >> >> >> >> > instruments, >> >> >> >> > const DayCounter& dayCounter, >> >> >> >> > const FittingMethod& fittingMethod, >> >> >> >> > Real accuracy = 1.0e-10, >> >> >> >> > Size maxEvaluations = 10000, >> >> >> >> > const Array& guess = Array(), >> >> >> >> > Real simplexLambda = 1.0) >> >> >> >> > { >> >> >> >> > return new FittedBondDiscountCurvePtr( >> >> >> >> > new FittedBondDiscountCurve( >> >> >> >> > settlementDays, >> >> >> >> > calendar, >> >> >> >> > instruments, >> >> >> >> > dayCounter, >> >> >> >> > fittingMethod, >> >> >> >> > accuracy, >> >> >> >> > maxEvaluations, >> >> >> >> > guess, >> >> >> >> > simplexLambda) >> >> >> >> > ); >> >> >> >> > } >> >> >> >> > FittedBondDiscountCurvePtr(const Date &referenceDate, >> >> >> >> > const >> >> >> >> > std::vector<boost::shared_ptr<BondHelper> >& instruments, >> >> >> >> > const DayCounter& dayCounter, >> >> >> >> > const FittingMethod& fittingMethod, >> >> >> >> > Real accuracy = 1.0e-10, >> >> >> >> > Size maxEvaluations = 10000, >> >> >> >> > const Array &guess = Array(), >> >> >> >> > Real simplexLambda = 1.0) >> >> >> >> > { >> >> >> >> > return new FittedBondDiscountCurvePtr( >> >> >> >> > new FittedBondDiscountCurve( >> >> >> >> > referenceDate, >> >> >> >> > instruments, >> >> >> >> > dayCounter, >> >> >> >> > fittingMethod, >> >> >> >> > accuracy, >> >> >> >> > maxEvaluations, >> >> >> >> > guess, >> >> >> >> > simplexLambda) >> >> >> >> > ); >> >> >> >> > } >> >> >> >> > } >> >> >> >> > }; >> >> >> >> > %{ >> >> >> >> > using QuantLib::ExponentialSplinesFitting; >> >> >> >> > using QuantLib::NelsonSiegelFitting; >> >> >> >> > using QuantLib::CubicBSplinesFitting; >> >> >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod >> >> >> >> > FittingMethod; >> >> >> >> > %} >> >> >> >> > %ignore FittingMethod; >> >> >> >> > class FittingMethod {}; >> >> >> >> > %template(FittingMethod) boost::shared_ptr<FittingMethod>; >> >> >> >> > class ExponentialSplinesFitting : public FittingMethod >> >> >> >> > { >> >> >> >> > public: >> >> >> >> > %extend >> >> >> >> > { >> >> >> >> > ExponentialSplinesFitting(bool constrainAtZero = true) >> >> >> >> > { >> >> >> >> > return new ExponentialSplinesFitting(constrainAtZero); >> >> >> >> > } >> >> >> >> > } >> >> >> >> > }; >> >> >> >> > class NelsonSiegelFitting : public FittingMethod >> >> >> >> > { >> >> >> >> > public: >> >> >> >> > %extend >> >> >> >> > { >> >> >> >> > NelsonSiegelFitting() >> >> >> >> > { >> >> >> >> > return new NelsonSiegelFitting(); >> >> >> >> > } >> >> >> >> > } >> >> >> >> > }; >> >> >> >> > class CubicBSplinesFitting : public FittingMethod >> >> >> >> > { >> >> >> >> > public: >> >> >> >> > %extend >> >> >> >> > { >> >> >> >> > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool >> >> >> >> > constrainAtZero = true) >> >> >> >> > { >> >> >> >> > return new CubicBSplinesFitting(knotVector, constrainAtZero); >> >> >> >> > } >> >> >> >> > } >> >> >> >> > }; >> >> >> >> > >> >> >> >> > #endif >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> > ------------------------------------------------------------------------------ >> >> >> >> > Rapidly troubleshoot problems before they affect your business. >> >> >> >> > Most >> >> >> >> > IT >> >> >> >> > organizations don't have a clear picture of how application >> >> >> >> > performance >> >> >> >> > affects their revenue. With AppDynamics, you get 100% >> >> >> >> > visibility >> >> >> >> > into >> >> >> >> > your >> >> >> >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of >> >> >> >> > AppDynamics >> >> >> >> > Pro! >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk >> >> >> >> > _______________________________________________ >> >> >> >> > QuantLib-users mailing list >> >> >> >> > [hidden email] >> >> >> >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> >> <https://implementingquantlib.blogspot.com> >> >> >> >> <https://twitter.com/lballabio> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> <https://implementingquantlib.blogspot.com> >> >> >> <https://twitter.com/lballabio> >> >> >> >> >> >> >> >> -- >> >> <https://implementingquantlib.blogspot.com> >> >> <https://twitter.com/lballabio> >> >> >> >> -- >> <https://implementingquantlib.blogspot.com> >> <https://twitter.com/lballabio> -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I'm sorry because in my FittedBondDiscountCurve.class file the param is "long paramLong1", and in my FittedBondDiscountCurve.java file the param is "long settlementDays". I set the FittingMethod's declaration in the .i file to avoid declar the FittingMethod in java. at last the programe is able to run. tks wang > Date: Tue, 7 Jan 2014 15:15:15 +0100
> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG > From: [hidden email] > To: [hidden email] > CC: [hidden email] > > The parameter in my Java file is called settlementDays, which is > exactly the same name that it's given in the .i file; SWIG doesn't > modify it, which is why I'm suspecting that your build system is > modifying the interface files somehow, or that SWIG is picking up the > wrong file. Can you try modifying the .i file and seeing if SWIG picks > up the change? (For instance, change the first parameter from "Natural > settlementDays" to "int settlementDays".) > > Luigi > > On Tue, Jan 7, 2014 at 7:58 AM, 静涛 王 <[hidden email]> wrote: > > I'm sure that the .i file is the same. > > and I put all the .i file in the SWIGfilter folder. > > " paramLong1" is the parameter so i think it's no problem. > > what's the param name in your java file? > > > > Now I set the FittingMethod's declaration in the .i file to avoid this > > problem. > > > > > > wang > > tks > > > >> Date: Thu, 2 Jan 2014 18:12:53 +0100 > > > >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG > >> From: [hidden email] > >> To: [hidden email] > >> CC: [hidden email] > >> > >> I'm using 2.0.11, but it shouldn't make a difference. > >> > >> Are you sure you're using the same file I sent you? The fact that a) > >> your files live in a folder called SWIGfilter and b) the names of your > >> parameters are all changed (paramLong1, paramCalendar etc instead of > >> settlementDays, calendar...) makes me suspect that there's some > >> preprocessing going on. > >> > >> Luigi > >> > >> > >> On Tue, Dec 31, 2013 at 2:51 AM, 静涛 王 <[hidden email]> wrote: > >> > The SWIG Version is : > >> > Version: 2.0.9 (16 December 2012) > >> > > >> > and the command I execute is: > >> > > >> > D:\programe\swigwin\swig -java -c++ -outdir > >> > D:\trywrap\QuantLibJava\quantlib_wrap\swig\Java\org\quantlib -package > >> > org.quantlib -o quantlib_wrap.cpp > >> > D:\trywrap\QuantLibJava\quantlib_wrap\SWIGfilter\quantlib.i > >> > > >> > thank you > >> > wang > >> > > >> >> Date: Mon, 30 Dec 2013 17:04:45 +0100 > >> > > >> >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to > >> >> SWIG > >> >> From: [hidden email] > >> >> To: [hidden email] > >> >> CC: [hidden email] > >> >> > >> >> That's strange. What SWIG version are you using? And how are you > >> >> calling SWIG exactly? > >> >> > >> >> Luigi > >> >> > >> >> On Mon, Dec 30, 2013 at 6:32 AM, 静涛 王 <[hidden email]> wrote: > >> >> > I'm sorry for that canot complied. Because i changed ratehelper.i. > >> >> > > >> >> > I complied the attached file and find the > >> >> > FittedBondDiscountCurve.class has the next source: > >> >> > > >> >> > > >> >> > ================================================================================== > >> >> > public FittedBondDiscountCurve(long paramLong1, Calendar > >> >> > paramCalendar, > >> >> > BondHelperVector paramBondHelperVector, DayCounter paramDayCounter, > >> >> > SWIGTYPE_p_FittingMethod paramSWIGTYPE_p_FittingMethod, double > >> >> > paramDouble1, > >> >> > long paramLong2, Array paramArray, double paramDouble2) { > >> >> > this(QuantLibJNI.new_FittedBondDiscountCurve__SWIG_0(paramLong1, > >> >> > Calendar.getCPtr(paramCalendar), paramCalendar, > >> >> > BondHelperVector.getCPtr(paramBondHelperVector), > >> >> > paramBondHelperVector, > >> >> > DayCounter.getCPtr(paramDayCounter), paramDayCounter, > >> >> > SWIGTYPE_p_FittingMethod.getCPtr(paramSWIGTYPE_p_FittingMethod), > >> >> > paramDouble1, paramLong2, Array.getCPtr(paramArray), paramArray, > >> >> > paramDouble2), true); > >> >> > } > >> >> > > >> >> > > >> >> > ================================================================================== > >> >> > > >> >> > please attention that the FittingMethod is converted into > >> >> > SWIGTYPE_p_FittingMethod. > >> >> > > >> >> > So when complied in java has the error like: > >> >> > "The constructor FittedBondDiscountCurve(int, Calendar, > >> >> > BondHelperVector,DayCounter, NelsonSiegelFitting) is undefined.". > >> >> > > >> >> > best reagrds. > >> >> > wang > >> >> > > >> >> > > >> >> > > >> >> > > >> >> >> Date: Fri, 27 Dec 2013 11:18:55 +0100 > >> >> >> Subject: Re: FW: [Quantlib-users] Converting FittedBondDiscountCurve > >> >> >> to > >> >> >> SWIG > >> >> > > >> >> >> From: [hidden email] > >> >> >> To: [hidden email] > >> >> >> CC: [hidden email] > >> >> >> > >> >> >> Hello, > >> >> >> your wrappers won't compile, so I'm not sure what you're calling > >> >> >> from your Java code. Anyway: > >> >> >> - you're using BondHelper, which is not defined in the wrappers; > >> >> >> - you're passing a vector of RateHelpers, which can't be implicitly > >> >> >> converted to a vector of BondHelpers; > >> >> >> - you're declaring pure virtual methods in NelsonSiegelFitting and > >> >> >> not > >> >> >> declaring them in the derived class, so SWIG thinks it can't > >> >> >> instantiate it. > >> >> >> > >> >> >> The file I'm attaching should fix the problems (look at the > >> >> >> differences with your file to see what I've done). I haven't tried > >> >> >> it > >> >> >> from Java, but at least it compiles. Let me know what happens. > >> >> >> > >> >> >> Luigi > >> >> >> > >> >> >> > >> >> >> On Fri, Dec 27, 2013 at 1:30 AM, 静涛 王 <[hidden email]> wrote: > >> >> >> > luigi > >> >> >> > > >> >> >> > see the attachments. > >> >> >> > I removed the line. but in java the error is as the same. > >> >> >> > > >> >> >> > the java source is: > >> >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > >> >> >> > > >> >> >> > FittedBondDiscountCurve ss = new FittedBondDiscountCurve( > >> >> >> > settlementDays, > >> >> >> > calendar, > >> >> >> > depoSwapInstruments, > >> >> >> > bondDayCount, > >> >> >> > ns); > >> >> >> > > >> >> >> > and has the next compile error: > >> >> >> >>>The constructor FittedBondDiscountCurve(int, Calendar, > >> >> >> >>> BondHelperVector, > >> >> >> >>> DayCounter, NelsonSiegelFitting) is undefined. > >> >> >> > > >> >> >> > and has the next quick fix available: > >> >> >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > >> >> >> > > >> >> >> > any other clues? > >> >> >> > > >> >> >> > thks. > >> >> >> > > >> >> >> > > >> >> >> > > >> >> >> >> Date: Tue, 24 Dec 2013 12:04:25 +0100 > >> >> >> >> Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve > >> >> >> >> to > >> >> >> >> SWIG > >> >> >> >> From: [hidden email] > >> >> >> >> To: [hidden email] > >> >> >> >> CC: [hidden email] > >> >> >> >> > >> >> >> >> Hello, > >> >> >> >> the constructor expects a reference to a FittingMethod instance, > >> >> >> >> but you're exporting it as a shared_ptr. Try removing the line > >> >> >> >> > >> >> >> >> %template(FittingMethod) boost::shared_ptr<FittingMethod>; > >> >> >> >> > >> >> >> >> from your SWIG interface. > >> >> >> >> > >> >> >> >> Luigi > >> >> >> >> > >> >> >> >> > >> >> >> >> On Wed, Dec 18, 2013 at 8:27 AM, 静涛 王 <[hidden email]> > >> >> >> >> wrote: > >> >> >> >> > Hi > >> >> >> >> > > >> >> >> >> > I am also trying to convert the fittedbondcurve class from C++ > >> >> >> >> > to > >> >> >> >> > java > >> >> >> >> > using SWIG. I use a swig file from the mail. > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > http://quantlib.10058.n7.nabble.com/Call-QL-from-SWIG-Python-FittedBondCurve-td12087.html#a12088 > >> >> >> >> > > >> >> >> >> > I call if from: > >> >> >> >> > NelsonSiegelFitting ns = new NelsonSiegelFitting(); > >> >> >> >> > FittedBondDiscountCurve ss = > >> >> >> >> > new FittedBondDiscountCurve( > >> >> >> >> > settlementDays, > >> >> >> >> > calendar, > >> >> >> >> > depoSwapInstruments, > >> >> >> >> > bondDayCount, > >> >> >> >> > ns); > >> >> >> >> > } > >> >> >> >> > > >> >> >> >> > but i get the next complie error: > >> >> >> >> > change type 'ns' to 'SWIGTYPE_p_FittingMethod' > >> >> >> >> > > >> >> >> >> > I guess the parent class FittingMethod have not correctly > >> >> >> >> > convert > >> >> >> >> > to > >> >> >> >> > java. > >> >> >> >> > > >> >> >> >> > any clues? > >> >> >> >> > thanks > >> >> >> >> > > >> >> >> >> > wangjingtao > >> >> >> >> > 12/18 > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > the i file is: > >> >> >> >> > ============================================ > >> >> >> >> > > >> >> >> >> > #ifndef quantlib_fitted_bond_i > >> >> >> >> > #define quantlib_fitted_bond_i > >> >> >> >> > %include termstructures.i > >> >> >> >> > %include interpolation.i > >> >> >> >> > %include ratehelpers.i > >> >> >> >> > %{ > >> >> >> >> > using QuantLib::InterpolatedDiscountCurve; > >> >> >> >> > using QuantLib::FittedBondDiscountCurve; > >> >> >> >> > using QuantLib::RateHelper; > >> >> >> >> > using QuantLib::YieldTermStructure; > >> >> >> >> > typedef boost::shared_ptr<YieldTermStructure> > >> >> >> >> > FittedBondDiscountCurvePtr; > >> >> >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod > >> >> >> >> > FittingMethod; > >> >> >> >> > %} > >> >> >> >> > %rename(FittedBondDiscountCurve) FittedBondDiscountCurvePtr; > >> >> >> >> > class FittedBondDiscountCurvePtr : public > >> >> >> >> > boost::shared_ptr<YieldTermStructure> { > >> >> >> >> > public: > >> >> >> >> > %extend { > >> >> >> >> > FittedBondDiscountCurvePtr(Natural settlementDays, > >> >> >> >> > const Calendar& calendar, > >> >> >> >> > const std::vector<boost::shared_ptr<BondHelper> >& > >> >> >> >> > instruments, > >> >> >> >> > const DayCounter& dayCounter, > >> >> >> >> > const FittingMethod& fittingMethod, > >> >> >> >> > Real accuracy = 1.0e-10, > >> >> >> >> > Size maxEvaluations = 10000, > >> >> >> >> > const Array& guess = Array(), > >> >> >> >> > Real simplexLambda = 1.0) > >> >> >> >> > { > >> >> >> >> > return new FittedBondDiscountCurvePtr( > >> >> >> >> > new FittedBondDiscountCurve( > >> >> >> >> > settlementDays, > >> >> >> >> > calendar, > >> >> >> >> > instruments, > >> >> >> >> > dayCounter, > >> >> >> >> > fittingMethod, > >> >> >> >> > accuracy, > >> >> >> >> > maxEvaluations, > >> >> >> >> > guess, > >> >> >> >> > simplexLambda) > >> >> >> >> > ); > >> >> >> >> > } > >> >> >> >> > FittedBondDiscountCurvePtr(const Date &referenceDate, > >> >> >> >> > const > >> >> >> >> > std::vector<boost::shared_ptr<BondHelper> >& instruments, > >> >> >> >> > const DayCounter& dayCounter, > >> >> >> >> > const FittingMethod& fittingMethod, > >> >> >> >> > Real accuracy = 1.0e-10, > >> >> >> >> > Size maxEvaluations = 10000, > >> >> >> >> > const Array &guess = Array(), > >> >> >> >> > Real simplexLambda = 1.0) > >> >> >> >> > { > >> >> >> >> > return new FittedBondDiscountCurvePtr( > >> >> >> >> > new FittedBondDiscountCurve( > >> >> >> >> > referenceDate, > >> >> >> >> > instruments, > >> >> >> >> > dayCounter, > >> >> >> >> > fittingMethod, > >> >> >> >> > accuracy, > >> >> >> >> > maxEvaluations, > >> >> >> >> > guess, > >> >> >> >> > simplexLambda) > >> >> >> >> > ); > >> >> >> >> > } > >> >> >> >> > } > >> >> >> >> > }; > >> >> >> >> > %{ > >> >> >> >> > using QuantLib::ExponentialSplinesFitting; > >> >> >> >> > using QuantLib::NelsonSiegelFitting; > >> >> >> >> > using QuantLib::CubicBSplinesFitting; > >> >> >> >> > typedef QuantLib::FittedBondDiscountCurve::FittingMethod > >> >> >> >> > FittingMethod; > >> >> >> >> > %} > >> >> >> >> > %ignore FittingMethod; > >> >> >> >> > class FittingMethod {}; > >> >> >> >> > %template(FittingMethod) boost::shared_ptr<FittingMethod>; > >> >> >> >> > class ExponentialSplinesFitting : public FittingMethod > >> >> >> >> > { > >> >> >> >> > public: > >> >> >> >> > %extend > >> >> >> >> > { > >> >> >> >> > ExponentialSplinesFitting(bool constrainAtZero = true) > >> >> >> >> > { > >> >> >> >> > return new ExponentialSplinesFitting(constrainAtZero); > >> >> >> >> > } > >> >> >> >> > } > >> >> >> >> > }; > >> >> >> >> > class NelsonSiegelFitting : public FittingMethod > >> >> >> >> > { > >> >> >> >> > public: > >> >> >> >> > %extend > >> >> >> >> > { > >> >> >> >> > NelsonSiegelFitting() > >> >> >> >> > { > >> >> >> >> > return new NelsonSiegelFitting(); > >> >> >> >> > } > >> >> >> >> > } > >> >> >> >> > }; > >> >> >> >> > class CubicBSplinesFitting : public FittingMethod > >> >> >> >> > { > >> >> >> >> > public: > >> >> >> >> > %extend > >> >> >> >> > { > >> >> >> >> > CubicBSplinesFitting(const std::vector<Time>& knotVector, bool > >> >> >> >> > constrainAtZero = true) > >> >> >> >> > { > >> >> >> >> > return new CubicBSplinesFitting(knotVector, constrainAtZero); > >> >> >> >> > } > >> >> >> >> > } > >> >> >> >> > }; > >> >> >> >> > > >> >> >> >> > #endif > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > ------------------------------------------------------------------------------ > >> >> >> >> > Rapidly troubleshoot problems before they affect your business. > >> >> >> >> > Most > >> >> >> >> > IT > >> >> >> >> > organizations don't have a clear picture of how application > >> >> >> >> > performance > >> >> >> >> > affects their revenue. With AppDynamics, you get 100% > >> >> >> >> > visibility > >> >> >> >> > into > >> >> >> >> > your > >> >> >> >> > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of > >> >> >> >> > AppDynamics > >> >> >> >> > Pro! > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > >> >> >> >> > _______________________________________________ > >> >> >> >> > QuantLib-users mailing list > >> >> >> >> > [hidden email] > >> >> >> >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users > >> >> >> >> > > >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> -- > >> >> >> >> <https://implementingquantlib.blogspot.com> > >> >> >> >> <https://twitter.com/lballabio> > >> >> >> > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> <https://implementingquantlib.blogspot.com> > >> >> >> <https://twitter.com/lballabio> > >> >> > >> >> > >> >> > >> >> -- > >> >> <https://implementingquantlib.blogspot.com> > >> >> <https://twitter.com/lballabio> > >> > >> > >> > >> -- > >> <https://implementingquantlib.blogspot.com> > >> <https://twitter.com/lballabio> > > > > -- > <https://implementingquantlib.blogspot.com> > <https://twitter.com/lballabio> ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi all, Has anyone successfully added SWIG bindings for the fitted bond curve? I am trying to added a C# example that replicates the one in C++, but got stuck. I am completely new to SWIG. Could someone point me to any good documentation, tutorials or examples? Thanks a lot!
George On Thu, Jan 9, 2014 at 6:09 AM, 静涛 王 <[hidden email]> wrote:
------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available. Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi George,
I'm sorry for the later. I have successfully for the fitted bond curve. But because my language is java. I couldn't help the trouble of C#. But as an example, see the documents of java's tutorials please. And for the interface of fitted bond curve, I have modified the ratehelpers.i and add a file fittedbondcurve.i. If you can correctly wrap the dll. I think this 2 file can make you correctly call the fitted bond curve class. jingtao Date: Wed, 30 Apr 2014 06:31:28 -0400 Subject: Re: [Quantlib-users] Converting FittedBondDiscountCurve to SWIG From: [hidden email] To: [hidden email] CC: [hidden email]; [hidden email] Hi all, Has anyone successfully added SWIG bindings for the fitted bond curve? I am trying to added a C# example that replicates the one in C++, but got stuck. I am completely new to SWIG. Could someone point me to any good documentation, tutorials or examples? Thanks a lot!
George On Thu, Jan 9, 2014 at 6:09 AM, 静涛 王 <[hidden email]> wrote:
------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users fittedbondcurve.i (4K) Download Attachment ratehelpers.i (14K) Download Attachment makequantlibJNL.txt (7K) Download Attachment |
Hi Jingtao, Thank you so much for your help! I'll take a look at this soon. I used to program in Java several years ago, and I am interested in getting QuantLib to work in Java/Scala as well. Regards, George
------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |