#include <random.hpp>
Definition at line 14 of file random.hpp.
◆ Random() [1/3]
| CaDiCaL::Random::Random |
( |
| ) |
|
Definition at line 219 of file cadical_random.cpp.
219 : state (1) {
220 add (hash_machine_identifier ());
221 add (hash_network_addresses ());
222 add (hash_clock_cycles ());
223 add (hash_process ());
224 add (hash_time ());
225#ifdef DO_PRINT_HASH
226 printf ("c PRINT_HASH %32s = %020" PRIu64 "\n", "combined", state);
227 fflush (stdout);
228#endif
229}
◆ Random() [2/3]
| CaDiCaL::Random::Random |
( |
uint64_t | seed | ) |
|
|
inline |
◆ Random() [3/3]
Definition at line 31 of file random.hpp.
31: state (other.seed ()) {}
◆ generate()
Definition at line 43 of file random.hpp.
43 {
45 return state >> 32;
46 }
◆ generate_bool()
| bool CaDiCaL::Random::generate_bool |
( |
| ) |
|
|
inline |
◆ generate_double()
| double CaDiCaL::Random::generate_double |
( |
| ) |
|
|
inline |
◆ generate_int()
| int CaDiCaL::Random::generate_int |
( |
| ) |
|
|
inline |
◆ next()
| uint64_t CaDiCaL::Random::next |
( |
| ) |
|
|
inline |
Definition at line 36 of file random.hpp.
36 {
37 state *= 6364136223846793005ul;
38 state += 1442695040888963407ul;
40 return state;
41 }
#define CADICAL_assert(ignore)
◆ operator+=()
| void CaDiCaL::Random::operator+= |
( |
uint64_t | a | ) |
|
|
inline |
◆ operator=()
| void CaDiCaL::Random::operator= |
( |
uint64_t | seed | ) |
|
|
inline |
◆ pick_double()
| double CaDiCaL::Random::pick_double |
( |
double | l, |
|
|
double | r ) |
|
inline |
Definition at line 90 of file random.hpp.
90 {
93 res += l;
96 return res;
97 }
◆ pick_int()
| int CaDiCaL::Random::pick_int |
( |
int | l, |
|
|
int | r ) |
|
inline |
Definition at line 56 of file random.hpp.
56 {
58 const unsigned delta = 1 + r - (unsigned) l;
60 if (delta) {
61 const double fraction = tmp / 4294967296.0;
62 scaled = delta * fraction;
63 } else
64 scaled = tmp;
65 const int res = scaled + l;
68 return res;
69 }
◆ pick_log()
| int CaDiCaL::Random::pick_log |
( |
int | l, |
|
|
int | r ) |
|
inline |
Definition at line 71 of file random.hpp.
71 {
73 const unsigned delta = 1 + r - (unsigned) l;
74 int log_delta = delta ? 0 : 32;
75 while (log_delta < 32 && (1u << log_delta) < delta)
76 log_delta++;
77 const int log_res =
pick_int (0, log_delta);
79 if (log_res < 32)
80 tmp &= (1u << log_res) - 1;
81 if (delta)
82 tmp %= delta;
83 const int res = l + tmp;
85 return res;
86 }
int pick_int(int l, int r)
◆ seed()
| uint64_t CaDiCaL::Random::seed |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: