Fixed RAND_A_B macro. Added macros for generating random numbers using xorwow, passing the state to the macro.
This commit is contained in:
parent
bbf7a18b66
commit
747d8bbaf2
1 changed files with 9 additions and 1 deletions
10
utils.hpp
10
utils.hpp
|
|
@ -41,8 +41,9 @@
|
|||
std::cout << (x)[i_print_vec] << "\t"; \
|
||||
std::cout << "\n";}
|
||||
#define PRINT_STR(x) std::cout << (x) << "\n"
|
||||
#define PRINT_LINE() std::cout << __FILE__ << ':' << __LINE__ << "\n"
|
||||
|
||||
#define RAND_A_B(a, b) ((double(rand())/RAND_MAX)*(b-a) + a)
|
||||
#define RAND_A_B(a, b) ((double(rand())/RAND_MAX)*((b)-(a)) + (a))
|
||||
#define RAND_0_1() (double(rand())/RAND_MAX)
|
||||
|
||||
#define MIN(a, b) ((a) < (b)) ? (a) : (b)
|
||||
|
|
@ -114,6 +115,13 @@ std::ostream& operator<<(std::ostream& os, const C<T,Args...>& objs)
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#define RAND_MAX_XORWOW ((unsigned int)(4294967295))
|
||||
#define RAND_MAX_XORWOW_F (4294967295.0f)
|
||||
#define RAND_MAX_XORWOW_D (4294967295.0)
|
||||
|
||||
#define RAND_XORWOW_A_B(state, a, b) ((double(rand_xorwow(state))/RAND_MAX_XORWOW_D)*((b)-(a)) + (a))
|
||||
#define RAND_XORWOW_0_1(state) (double(rand_xorwow(state))/RAND_MAX_XORWOW_D)
|
||||
|
||||
/// Pseudo-random number generator algorithm "xorwow" from p. 5 of Marsaglia, "Xorshift RNGs".
|
||||
///
|
||||
/// The period is 2^160-2^32 ~= 10^48 numbers.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue