Colin,

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

   e...@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");
   e...@max:/tmp$ r colin.r
   Loading required package: methods
   [1] 1.93930 0.18042 0.53443
   Bye
   e...@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 | [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

Reply via email to