Re: Adding functions to QuantLib SWIG

Posted by Billy Ng-5 on
URL: http://quantlib.414.s1.nabble.com/Adding-functions-to-QuantLib-SWIG-tp6140p6141.html

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:[hidden email]]
Sent: Tuesday, April 17, 2012 6:12 AM
To: [hidden email]
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

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users