diff --git a/utils.hpp b/utils.hpp index 73bbe90..0fb5444 100644 --- a/utils.hpp +++ b/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& objs) #include +#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.