Last active
February 13, 2021 19:08
-
-
Save naphipps/9784df722d45c8e1bbe7108d182c466a to your computer and use it in GitHub Desktop.
Here's how I merged imneme's randutils with her pcg-random generators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
imneme's randutils.hpp gist: | |
https://gist.github.com/imneme/540829265469e673d045 | |
imneme's pcg-cpp random generator I use: | |
https://github.com/imneme/pcg-cpp | |
Here's imneme's blog post describing why randutils.hpp is useful: | |
https://www.pcg-random.org/posts/developing-a-seed_seq-alternative.html | |
*/ | |
/* | |
imneme's original randutils does not support pcg32 out of the box, | |
but you can add this to easily support pcg32 | |
*/ | |
namespace randutils | |
{ | |
typedef randutils::seed_seq_fe<2, ui32> seed_seq_fe64; | |
typedef randutils::auto_seeded<seed_seq_fe64> auto_seed_64; | |
} | |
//how to merge randutils with her pcg-cpp | |
typedef randutils::random_generator<pcg32, randutils::auto_seed_64> pcg32_fe; | |
typedef randutils::random_generator<pcg64, randutils::auto_seed_128> pcg64_fe; | |
/* | |
Here's the simplest way how I use the above: | |
But I personally recommend creating a class that inherits from pcg32 so you can hide this in a constructor or something. | |
*/ | |
pcg32 myPcg32 = pcg32_fe().engine(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment