Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
unconditionally get/put RNG state #825
Resolves #823. With this PR, we ensure that Rcpp functions called by other Rcpp functions synchronize the RNG state.
Although @wch's example showed this through the use of
That seems ... weird. The entire block is https://github.com/RcppCore/Rcpp/blob/master/src/api.cpp#L66-L83 and the counter is not part of the interface. We could simply make it
And FWIW the silversearcher agrees:
edd@rob:~/git/rcpp(master)$ ag RNGScopeCounter src/api.cpp 68: unsigned long RNGScopeCounter = 0; 73: if (RNGScopeCounter == 0) GetRNGstate(); 74: RNGScopeCounter++; 75: return RNGScopeCounter; 80: RNGScopeCounter--; 81: if (RNGScopeCounter == 0) PutRNGstate(); 82: return RNGScopeCounter; edd@rob:~/git/rcpp(master)$