where are the implementations for <random>?
Sun Apr 9 18:24:00 GMT 2017
On Sun, 9 Apr 2017, Oliver Kullmann wrote:
> I thought that with the facilities from <random> we had good and
> well-defined ones -- but alas, only recently I realised that only say
> the Mersenne twister is well-defined in the standard, but roughly
> everything else is up to the implementer.
> Since reproducibility is crucial for us (as with most scientific
> applications), thus we need to implement ourselves the algorithms for
> 1. std::seed_seq
> 2. std::uniform_int_distribution
> 3. std::bernoulli_distribution (only for default p=0.5).
> Easiest would be to copy (and specialise) the gcc-implementations.
> I searched for it in the source-code, but couldn't find it:
> Where do I find the implementations for <random> ?
First you find the file called "random" (/usr/include/c++/6/random here),
then you notice that it contains
so you look for those files (and recursively if needed)
You compile a file that contains #include <random> using the -E flag, and
look for bernoulli_distribution or whatever in the output.
Get the sources for gcc.
grep -r bernoulli_distribution /the/sources
They all point to bits/random.h (with one function implemented in
bits/random.tcc), with older versions in tr1/.
More information about the Gcc-help