Dear Rcpp-List: I have been working on speeding my R code. A while ago, I realized that no further vectorization would help and interacting R with C/C++/.. was absolutely necessary. I don't program in C/C++ extensively, so the transition was a difficult process. I tried to use the R API but the error messages were intimidating. A few weeks ago I saw Professor Chambers presentation (pdf from David Smith's website) about R in Stanford. I saw him mentioning Rcpp which motivated me to try Rcpp (I confess, I am lazy to try new stuff). And I haven't been dissapointed. Thank you very much Dirk and Romain (and other developers, including Professor Chambers and Professor Bates).
Rcpp reduced the length of my code considerably (like: I didn't need to bother about PROTECT .. ) and the informative syntax (like: Rcpp::IntegerMatrix ..) made my code more readable. These are great advantages, but the best part was testing and compiling with the Inline package. I am a statistician; writing a C program and then using dyn.load was the way I learned to do it in grad school. Rcpp + inline makes this process way easier. Thank you for the great documentation on your webpage Dirk. It helped me a lot. I am still a beginner in using Rcpp and friends (2 weeks old) and have a few miscellaneous questions. The answer to these questions may be very basic or obvious, so please bear with me. (Dirk showed me a simple way to test things using Rcpp + inline here -- http://stats.stackexchange.com/questions/6690/what-is-the-difference-between-rf-dpois-in-rmath-h-and-the-dpois-that-i-use-direc ) 1. I have been using Rcpp + inline to test if the faster implementation gives the right results (which is obtained from R code). I was wondering if there are other strategies which people use to test their Rcpp code? (sorry, if this doesn't make sense.) 2. I have a MCMC simulation (say: foo) which uses several functions (say: fun1, fun2). These functions (fun1, fun2) are themselves computation intensive and I used Rcpp to speed them. Until now I do something like this: In R file: foo <- function (...){ src1 <- paste(readLines("fun1-rcpp.cpp"), collapse="\n") RcppFun1 <- cxxfunction( .., plugin="Rcpp",body=src1) ## similar cpp code for fun2 for (i in 1:10000){ ## use RcppFun1, RcppFun2 here } } I was wondering if this is OK (it already speeds up my code by zillion times) or is there a more elegant way of doing this. I am thinking about using Rcpp to increase the speed of foo (for more speed) but I am not too sure on how to do this. Towards this end, I checked a few packages mentioned on Dirk's website namely, pcaMethods. I am thinking RcppExport and .Call is the way to do this? Thank you for your answers or pointers. S.
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel