Commit 78e9d2c0 authored by Marek Vavrusa's avatar Marek Vavrusa

Imported WELL1024a (however, it is not thread safe).

http://www.iro.umontreal.ca/~panneton/WELLRNG.html

refs #631
parent da331134
......@@ -101,6 +101,8 @@ src/common/ref.h
src/common/modified_tree.h
src/common/general-tree.h
src/common/general-tree.c
src/common/WELL1024a.c
src/common/WELL1024a.h
src/zcompile/parser-descriptor.h
src/zcompile/parser-descriptor.c
src/zcompile/parser-util.h
......
......@@ -41,7 +41,9 @@ libknot_common_SOURCES = \
common/ref.h \
common/ref.c \
common/errors.h \
common/errors.c
common/errors.c \
common/WELL1024a.h \
common/WELL1024a.c
libknot_la_SOURCES = \
$(libknot_common_SOURCES) \
......
......@@ -172,7 +172,9 @@ libknots_la_SOURCES = \
common/ref.h \
common/ref.c \
common/errors.h \
common/errors.c
common/errors.c \
common/WELL1024a.h \
common/WELL1024a.c
libknotd_la_SOURCES = \
knot/stat/gatherer.c \
......
/* ***************************************************************************** */
/* Copyright: Francois Panneton and Pierre L'Ecuyer, University of Montreal */
/* Makoto Matsumoto, Hiroshima University */
/* Notice: This code can be used freely for personal, academic, */
/* or non-commercial purposes. For commercial purposes, */
/* please contact P. L'Ecuyer at: lecuyer@iro.UMontreal.ca */
/* ***************************************************************************** */
#define W 32
#define R 32
#define M1 3
#define M2 24
#define M3 10
#define MAT0POS(t,v) (v^(v>>t))
#define MAT0NEG(t,v) (v^(v<<(-(t))))
#define Identity(v) (v)
#define V0 STATE[state_i ]
#define VM1 STATE[(state_i+M1) & 0x0000001fU]
#define VM2 STATE[(state_i+M2) & 0x0000001fU]
#define VM3 STATE[(state_i+M3) & 0x0000001fU]
#define VRm1 STATE[(state_i+31) & 0x0000001fU]
#define newV0 STATE[(state_i+31) & 0x0000001fU]
#define newV1 STATE[state_i ]
#define FACT 2.32830643653869628906e-10
static unsigned int state_i = 0;
static unsigned int STATE[R];
static unsigned int z0, z1, z2;
void InitWELLRNG1024a (unsigned int *init){
int j;
state_i = 0;
for (j = 0; j < R; j++)
STATE[j] = init[j];
}
double WELLRNG1024a (void){
z0 = VRm1;
z1 = Identity(V0) ^ MAT0POS (8, VM1);
z2 = MAT0NEG (-19, VM2) ^ MAT0NEG(-14,VM3);
newV1 = z1 ^ z2;
newV0 = MAT0NEG (-11,z0) ^ MAT0NEG(-7,z1) ^ MAT0NEG(-13,z2) ;
state_i = (state_i + 31) & 0x0000001fU;
return ((double) STATE[state_i] * FACT);
}
/* ***************************************************************************** */
/* Copyright: Francois Panneton and Pierre L'Ecuyer, University of Montreal */
/* Makoto Matsumoto, Hiroshima University */
/* Notice: This code can be used freely for personal, academic, */
/* or non-commercial purposes. For commercial purposes, */
/* please contact P. L'Ecuyer at: lecuyer@iro.UMontreal.ca */
/* ***************************************************************************** */
void InitWELLRNG1024a (unsigned int *init);
double WELLRNG1024a (void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment