[Rcpp-devel] Persistent C++ objects within R/Rcpp?
lawyer at mpi-inf.mpg.de
Tue Jun 26 09:52:16 CEST 2012
On 06/26/2012 02:00 AM, Dirk Eddelbuettel wrote:
> it seems you simply want a creator function in C++ which creates a
> simulation object, which you then modify and alter in R, possibly give back
> to C++ etc. Is that correct?
> In the case, Rcpp can help easily.
I second Dirk's answer, with the following addition. My
"simulation object" (SO) was a bit big, and I was loosing a lot of
time to copy operations (not sure if this is Rcpp's fault or my
lack of coding skill). My solution was to use classes. I code, in
C++, my SO as a class. I use the Rcpp class interface to write R
wrappers to the functions which manipulate the state of the SO.
To run a simulation, I load the module into R, create an instance
of the class, then run the simulation via the R functions which
are linked to the SO functions.
I am sure there is a more elegant way, but this approach works.
It is difficult to find a black cat in a dark room,
especially if there is no cat.
-- Chinese proverb
Dr. Glenn Lawyer
+352 661 967 244
Max-Planck-Institut für Informatik
Computational Biology and Applied Algorithmics
Campus E1 4
66123 Saarbrücken, Germany
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rcpp-devel