Running into problem with R-Swig wrappers
Posted by Joseph Wang-2 on Jun 07, 2006; 3:01am
URL: http://quantlib.414.s1.nabble.com/Running-into-problem-with-R-Swig-wrappers-tp11141.html
The problem I'm running into is that an overloaded r function with large
numbers of arguments seem to be eating up huge amounts of memory, causing my
512 meg machine to run out of free memory before loading the wrapper.
The trouble is that the functions with large numbers of option arguments
generate r overloaded functions.
One way I've been able to get things to work is by defining
#if defined(SWIGR)
#define OPTIONAL(x, y) x
#else
#define OPTIONAL(x, y) x = y
#endif
and then
ParCouponPtr(Real nominal, const Date& paymentDate,
const XiborPtr& index,
const Date& startDate, const Date& endDate,
Integer fixingDays,
OPTIONAL(Spread spread, 0.0),
OPTIONAL(const Date& refPeriodStart, Date()),
OPTIONAL(const Date& refPeriodEnd, Date())
This forces R to remove the optional arguments, which means that R no longer
uses overloading to represent these long functions, which bypasses the memory
bloating.
I've e-mailed the r-help list for any suggestions to get around the memory
bloat.
I'm curious if anyone has any other ideas on how to handle this. One thing
that might be possible is to turn off operator overloading in R-SWIG if there
are more than six arguments, and then to use a herustic to figure out which
method to generate a wrapper for.
Thoughts?