Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Simon Zehnder
Hi Darren, I haven't known about this book. I own the R cookbook from O'Reilly and this is quite well written. I will give it a closer view soon! Thanks for this info! Best Simon On Feb 15, 2013, at 1:58 AM, Darren Cook wrote: >> It runs in parallel does not mean it works correctly. > > BTW

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Simon Zehnder
Hi Dirk, that is good to know. At this point I would like to know: Functions like R::qbinom or R::qnorm from R's C library can still be used right? They are not called, but the code is read and worked through in compilation? Best Simon P.S.: How is it with code using RcppArmadillo: Is there a

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Simon Zehnder
Hi Yan, thank you very much for your comment. I read now the section 6 of the parallel package documentation. It's better to give programming a little more time than to get at the end undefined behavior. At this point only a short question: I use the nlopt library, constructing in every threa

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Darren Cook
> It runs in parallel does not mean it works correctly. BTW, the O'Reilly Parallel R book mentions random number generation in quite a few places. Reading it, you really feel nostalgic for the simple life of good 'ole single-threaded random number generators :-) Darren __

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Dirk Eddelbuettel
On 14 February 2013 at 22:24, Yan Zhou wrote: | It runs in parallel does not mean it works correctly. Well put :) | Simply increase seed certainly not avoid overlapping. The best algorithm that | use MT19937 in parallel environment without overlapping has a complexity O(log | n) AFAIK. | | Seco

[Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Yan Zhou
It runs in parallel does not mean it works correctly.Simply increase seed certainly not avoid overlapping. The best algorithm that use MT19937 in parallel environment without overlapping has a complexity O(log n) AFAIK.Second, R's RNG has a single instance within the whole program, which means your

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Simon Zehnder
Well, in OpenMP it seems to work, if I use inside the #pragma parallel for: Rcpp::Environment base("package:base"); Rcpp::Function SetSeed = base["set.seed"]; SetSeed(1 + i * nobs_intern * 3); I used OMP_NUMTHREADS = 4 and 8 iterations. Best Simon On Feb 14, 2013, at 10:10 PM, Simon Zehnder

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Simon Zehnder
I made all my simple tests now by using Rcpp::Environment and then Rcpp::Function for "set.seed" when calling R::rnorm. The next step would be to parallelize the iterations via OpenMP. The suggestion of Yan makes quite sense to produce a RNG via std::mt19937. This is also the way I did it when I

Re: [Rcpp-devel] parallelization in Rcpp

2013-02-14 Thread Tim Triche, Jr.
there is an example of using OpenMP for this: http://dirk.eddelbuettel.com/code/rcpp/html/OpenMP_2OpenMPandInline_8r-example.html thanks Dirk :-) On Thu, Feb 14, 2013 at 3:43 AM, Zhao Yang wrote: > Hello, > > Firstly, I would like to thank the develops of Rcpp for this tool. > > Then, here is

[Rcpp-devel] parallelization in Rcpp

2013-02-14 Thread Zhao Yang
Hello, Firstly, I would like to thank the develops of Rcpp for this tool. Then, here is the function: - code<-' NumericVector my_id(id); NumericMatrix my_link(link); NumericVector lst(1000); for (int i=0;i<1000;i++){ for (int j=0;j<1000;j++){ if (my_link(my_id[i],my_i

Re: [Rcpp-devel] R very basic compilation error

2013-02-14 Thread Bharath Govindarajan
Hi Kevin, Great! . Problem fixed now. Thanks a lot. Regards Bharath On Thu, Feb 14, 2013 at 2:33 AM, Kevin Ushey wrote: > Could it be because the file extension is .c rather than the expected > .cpp? Compiling the code runs fine for me when the file extension is .cpp, > but I get the same err