Login  Register

Re: Running into problem with R-Swig wrappers

Posted by Duncan Temple Lang on Jun 07, 2006; 4:48am
URL: http://quantlib.414.s1.nabble.com/Running-into-problem-with-R-Swig-wrappers-tp11141p11142.html

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Can you show us some of the overloaded functions, please?
I don't know what you mean by a "large" number of arguments
and why you are generating functions with a large number of
parameters so it would be helpful to see what you are generating.

 D.

Joseph Wang wrote:

> 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?

- --
Duncan Temple Lang                    [hidden email]
Department of Statistics              work:  (530) 752-4782
4210 Mathematical Sciences Building   fax:   (530) 752-7099
One Shields Ave.
University of California at Davis
Davis,
CA 95616,
USA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFEhkxg9p/Jzwa2QP4RAp8zAJ9fq4+xV3cjD4+uhB8SkCk18JPUuACdEMA0
Fp5feNGFE2CmiGJrrkJ6cv4=
=w/8W
-----END PGP SIGNATURE-----