[Rcpp-devel] Rcpp bug with rgamma

Dirk Eddelbuettel edd at debian.org
Sun Oct 3 18:11:44 CEST 2010


Colin,

The problem goes away as soon as you set the seeds to the RNGs:

   edd at max:/tmp$ cat colin.r
   library(Rcpp)
   library(inline)
   
   set.seed(42)  # this makes all the difference
   foo <- "return(Rcpp::wrap(rgamma(3,1,1)));"
   fun <- cxxfunction(signature(), foo, plugin = "Rcpp")
   
   print(fun())
   cat("Bye\n");
   edd at max:/tmp$ r colin.r
   Loading required package: methods
   [1] 1.93930 0.18042 0.53443
   Bye
   edd at max:/tmp$ 

I am not quite sure why that is needed for rgamma() when it isn't for all the
other distributions. We'll take a look -- but your code should now be fine.

Cheers, Dirk
   
-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list