From: Billy N. <mai...@gm...> - 2012-04-18 11:27:30
|
Hi, As an exercise, I am trying to convert the SwapValuation example into Java. Any example in how to convert new classes with SWIG, e.g. PieceWiseYieldCurve? Billy -----Original Message----- From: Zhi Xuan Fang [mailto:zhi...@gm...] Sent: Tuesday, April 17, 2012 6:12 AM To: qua...@li... Subject: [Quantlib-users] Adding functions to QuantLib SWIG Hi, I am currently working on QuantLib SWIG 1.0 with SWIG version 1.3.29. I am having troubles adding functions to a class. For example adding the function int addlfunc(){ return 1;} to class Quote. From the marketelements.i file, I tried %{ using QuantLib::Quote; %} %ignore Quote; class Quote { public: Real value() const; %extend{ int addlfunc(){ return 1; } } }; however it doesn't build. I am new to SWIG but when I was looking at their documentation, %extend seems to be the answer. In addition, does quantlib swig not allow reference to vectors as a function argument? I am trying to open up marketmodels to QuantLib SWIG. the nextStep function of BrownianGenerators takes in a reference to vectors as a function argument and I am unable to get it working like the other simpler functions of numberOfSteps, numberOfFactors, etc. Thanks for any help provided. Regards, Zhi Xuan |