diff options
author | Aina Niemetz <aina.niemetz@gmail.com> | 2018-10-09 10:36:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-09 10:36:40 -0700 |
commit | 90ffa8b4eb26af9060e57be7fe5d6008717d3ce6 (patch) | |
tree | 0442e608d7cf01131cd98293a3a20b0906348c71 /src/util/random.cpp | |
parent | 12246d53ac1dd4bbd464dee9dea61b8ac05b4b49 (diff) |
Random: support URNG interface (#2595)
Use std::shuffle (with Random as the unified random generator) instead
of std::random_shuffle for deterministic, reproducable random shuffling.
Diffstat (limited to 'src/util/random.cpp')
-rw-r--r-- | src/util/random.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/random.cpp b/src/util/random.cpp index 86c569a4a..7c6abd33e 100644 --- a/src/util/random.cpp +++ b/src/util/random.cpp @@ -23,6 +23,16 @@ namespace CVC4 { +Random::Random(uint64_t seed) { setSeed(seed); } + +void Random::setSeed(uint64_t seed) +{ + d_seed = seed == 0 ? ~seed : seed; + d_state = d_seed; +} + +uint64_t Random::operator()() { return rand(); } + uint64_t Random::rand() { /* xorshift* generator (see S. Vigna, An experimental exploration of |