

Number of threads used to run it, as this will vary in different Generally speaking we want the answer to be independent of the.Up subject to a few constraints about using OpenMP together with R: Here we’ve made a number of decisions about how to split the problem There is no equivalent to PutRNGstate() because the pointerĬpp11 :: cpp_source ( "rng_pi_parallel.cpp" ) After that the listing proceeds as before proceeds as before, except.Numbers do not come from some global source Starting at 0) random number stream - this pair of lines is roughlyĮquivalent to GetRNGstate() except that that the random The second line extracts a reference to the first (C++ indexing.The first line of the function safely creates a pointer to the.We’ve added ] and included theĭust random interface ( dust/r/random.hpp).

This snippet looks much the same as above: #include #include ] ] double pi_dust ( int n, cpp11 ::sexp ptr ) Passing that state into a C++ function willĪllow use of the random functions within dust, and will update the stateĬorrectly (see the following section for details). (either package developer or user of the package) creates a “pointer” to The way we expose this for use within other packages is that the user So the act of calling the function should update the seed as a “side Times we would want the stream to pick up where it left off last time, If we were to use the simulation function multiple Source of random numbers, so we need to create a source that ourįunction can use. One of the design ideas in dust is that there is no single global Sure that it is fetched and set on entry and exit to the function. With the R version above we are looking after R’s global Way that we cope with the random number stream will look quiteĭifferent. The implementation in dust will look very similar to above, but the
