48 typedef unsigned long long int myuint;
114 #define M61 2305843009213693951ULL 120 #define MERSBASE M61 //xSUFF(M61) 121 #define MOD_PAYNE(k) ((((k)) & MERSBASE) + (((k)) >> BITS) ) // slightly faster than my old way, ok for addition 122 #define MOD_REM(k) ((k) % MERSBASE ) // latest Intel CPU is supposed to do this in one CPU cycle, but on my machines it seems to be 20% slower than the best tricks 123 #define MOD_MERSENNE(k) MOD_PAYNE(k) 126 #define INV_MERSBASE (0.4336808689942017736029811203479766845703E-18) 133 #ifdef USE_MIXMAX_256_NEW 135 #define SPECIAL 487013230256099064 // s=487013230256099064, m=1 -- good old MIXMAX 136 #define MOD_MULSPEC(k) fmodmulM61( 0, SPECIAL , (k) ) 140 #define MOD_MULSPEC(k) (MERSBASE - (k)); 144 #define SPECIALMUL 53 // m=2^53+1 148 #define SPECIALMUL 36 // m=2^36+1, other valid possibilities are m=2^13+1, m=2^19+1, m=2^24+1 152 #define SPECIALMUL 42 // m=2^42+1 156 #define SPECIALMUL 52 // m=2^52+1 160 #define SPECIALMUL 55 // m=2^55+1 164 #define SPECIALMUL 51 // m=2^51+1 and a SPECIAL=+1 (!!!) 166 #define MOD_MULSPEC(k) (k) 169 #define SPECIALMUL 51 // m=2^51+1 and a SPECIAL=487013230256099140 170 #define SPECIAL 487013230256099140ULL 171 #define MOD_MULSPEC(k) fmodmulM61( 0, SPECIAL , (k) ) 176 #define MOD_MULSPEC(k) MOD_MERSENNE(3*(MERSBASE-(k))) 180 #warning Not a verified N, you are on your own! 181 #define SPECIALMUL 58 184 #endif // list of interesting N for modulus M61 ends here 187 #ifndef __MIXMAX_C // c++ can put code into header files, why cant we? (with the inline declaration, should be safe from duplicate-symbol error) 189 #define get_next(X) GET_BY_MACRO(X) 190 #define get_next_float(X) get_next_float_BY_MACRO(X) 213 #if defined(__GNUC__) && (__GNUC__ < 5) && (!defined(__ICC)) && defined(__x86_64__) && defined(__SSE2_MATH__) && defined(USE_INLINE_ASM) 218 __asm__ __volatile__(
"pxor %0, %0; " 228 #define ARRAY_INDEX_OUT_OF_BOUNDS 0xFF01 229 #define SEED_WAS_ZERO 0xFF02 230 #define ERROR_READING_STATE_FILE 0xFF03 231 #define ERROR_READING_STATE_COUNTER 0xFF04 232 #define ERROR_READING_STATE_CHECKSUM 0xFF05 240 #ifdef HOOKUP_GSL // if you need to use mixmax through GSL, pass -DHOOKUP_GSL=1 to the compiler 243 #include <gsl/gsl_rng.h> 244 unsigned long gsl_get_next(
void *vstate);
245 double gsl_get_next_float(
void *vstate);
246 void seed_for_gsl(
void *vstate,
unsigned long seed);
258 unsigned long gsl_get_next(
void *vstate) {
263 double gsl_get_next_float(
void *vstate) {
268 void seed_for_gsl(
void *vstate,
unsigned long seed){
277 #endif // not inside __MIXMAX_C 278 #endif // closing MIXMAX_H_ int rng_free(rng_state_t *X)
myuint apply_bigskip(myuint *Vout, myuint *Vin, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
int iterate(rng_state_t *X)
myuint precalc(rng_state_t *X)
void fill_array(rng_state_t *X, unsigned int n, double *array)
void iterate_and_fill_array(rng_state_t *X, double *array)
myuint iterate_raw_vec(myuint *Y, myuint sumtotOld)
void seed_uniquestream(rng_state_t *X, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
rng_state_t * rng_alloc()
#define get_next_float(X)
myuint fmodmulM61(myuint cum, myuint s, myuint a)
void seed_vielbein(rng_state_t *X, unsigned int i)
void read_state(rng_state_t *X, const char filename[])
static const gsl_rng_type mixmax_type
myuint modadd(myuint foo, myuint bar)
void seed_spbox(rng_state_t *X, myuint seed)
myuint GET_BY_MACRO(rng_state_t *X)
void print_state(rng_state_t *X)
struct rng_state_st rng_state_t
rng_state_t * rng_copy(myuint *Y)
void branch_inplace(rng_state_t *Xin, myID_t *ID)
double get_next_float_BY_MACRO(rng_state_t *X)
const gsl_rng_type * gsl_rng_mixmax