Commit 45c515f
committed
Add 64-bit implementation of MersenneTwisterEngine
With the required tempering parameter `d` introduced by the previous
patch, we can now introduce the standard 64-bit implementation of the
Mersenne Twister. See https://en.wikipedia.org/wiki/Mersenne_Twister
for an explanation of the chosen constants.
Some minimal unittests have been added similar to those already present
for the 32-bit `Mt19937`. These can be verified by comparison to C++11
by compiling and running the following C++ program:
/****************************************************************/
int main ()
{
static_assert(std::mt19937_64::default_seed == 5489,
"Default seed does not match Phobos!");
std::mt19937_64 gen(std::mt19937_64::default_seed);
std::cout << gen() << std::endl;
for (int i = 0; i < 9998; ++i) {
gen();
}
std::cout << gen() << std::endl;
}
/****************************************************************/
Note that the `for` loop in this example advances the generator 9998
times compared to the D unittest's `popFrontN(9999)` because the first
`gen()` call already advances the generator once.
Fixes Issue #10900 <https://issues.dlang.org/show_bug.cgi?id=10900>.1 parent dcd83ac commit 45c515f
1 file changed
+44
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
863 | 906 | | |
864 | 907 | | |
865 | 908 | | |
| |||
895 | 938 | | |
896 | 939 | | |
897 | 940 | | |
898 | | - | |
| 941 | + | |
899 | 942 | | |
900 | 943 | | |
901 | 944 | | |
| |||
0 commit comments