[Rcpp-devel] Mersenne Twister in RcppArmadillo?

c s conradsand.arma at gmail.com
Mon Feb 11 11:23:23 CET 2013


On Sun, Feb 10, 2013 at 12:32 AM, Yan Zhou <zhouyan at me.com> wrote:
> To have Armadillo randn use MT19937 is not easy.
> Since it use srand() for seed, I guess it also use C rand(),
> whose quality is quite questionable.

The quality of the rand() function from C depends on the
implementation in libc, which varies from system to system.

While I'd like to incorporate a Mersenne-Twister random number
generator directly in Armadillo, it would either add a dependency on
Boost, or on C++11.  Boost might not be available on a user's system,
and the degree of support for C++11 features varies from compiler to
compiler.  We also have to bear in mind that R folks currently
disallow CRAN packages that use C++11.

As a possible interim solution, I'll look into extending the .fill()
function to accept a functor, so that a matrix could be filled with
random numbers with the aid of a user-defined class, without
explicitly declaring a loop.


More information about the Rcpp-devel mailing list