On 16 May 2013 at 19:14, Jonathan Olmsted wrote: | Matteo, | | | | The other obvious of course is that you are not forced to control a loop | over | 10^6 elements from R either: pass N=10^6 down to C++ code, and run your N | loops there. You will also get a considerable speed boost. | | | | ^ I could have been more explicit. This is what I meant. You might may or may | not be able to do this in the sourceCpp() framework, though. How you do this is | much more obvious if you go the route of making an Rcpp package. For as much as | the convenience functions are a blessing, I've always found it hard to think | about how I'd do more complex things with them. It could be possible, I just | don't see it. I find the package approach to be a nice balance between | abstracting away from some details but keeping some in the forefront of your | mind. If you email me off the list and I can send you a very small package that | using Rcpp. Multiple C++ functions are created, only some are exposed to R.
Another great post, but note that Rcpp.package.skeleton() already does most of that. Plus existing CRAN packages as eg wordcloud (one R function rewritten as one C++ function). Dirk | It seems like you'd probably do something similar. | | -Jonathan | | | | | | | On Thu, May 16, 2013 at 8:11 PM, Dirk Eddelbuettel <[email protected]> | wrote: | | | | | | On 16 May 2013 at 14:49, Jonathan Olmsted wrote: | | | Several things. | | | | | | Xiao, Dirk's code gives me a segfault immediately and reliably. | | | | | | All, when I do this whole song and dance using the "old" Rcpp/ | inline/ | | | cxxfunction approach, I don't have any issues. One obvious | difference you | | can | | | see (like was mentioned) in the generated code (visibile using | verbose= | | TRUE) is | | | the declaration of an RNGScope object. | | | | | | But, if the memory issue crops up when you call a C++ function | (syncing | | with | | | R's RNG state) 1e6 times AND you are already writing C++ maybe | this is | | an | | | opportunity to just put one more layer of the code into C++ and | create | | only one | | | such RNGScope object? | | | | Beautiful. So we get to blame R Core after all? ;-) | | | | Dirk | | | | -- | | Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com | | _______________________________________________ | | Rcpp-devel mailing list | | [email protected] | | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/ | rcpp-devel | | | | | | -- | Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com | | -- Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
