Pseudo-random numbers/Splitmix64: Difference between revisions
Content added Content deleted
(New post.) |
m (Added a new method to a class.) |
||
Line 327: | Line 327: | ||
Splitmix64() { state = 0; } |
Splitmix64() { state = 0; } |
||
Splitmix64(const uint64_t seed) : state(seed) { } |
Splitmix64(const uint64_t seed) : state(seed) { } |
||
void seed(uint64_t seed) { |
|||
state = seed; |
|||
} |
|||
uint64_t next_int() { |
uint64_t next_int() { |
||
Line 346: | Line 350: | ||
int main() { |
int main() { |
||
Splitmix64 random |
Splitmix64 random; |
||
random.seed(1234567); |
|||
for ( int i = 0; i < 5; ++i ) { |
for ( int i = 0; i < 5; ++i ) { |
||
std::cout << random.next_int() << std::endl; |
std::cout << random.next_int() << std::endl; |