Skip to content

Commit

Permalink
Massive surgery on randmtzig. Faster now.
Browse files Browse the repository at this point in the history
  • Loading branch information
ViralBShah committed Oct 13, 2011
1 parent 6ec4ad2 commit 7ff80c9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 959 deletions.
36 changes: 3 additions & 33 deletions external/random/jl_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

static double randn_bm_next = RANDN_RESET;

void dsfmt_randn_bm_reset(void);
double dsfmt_randn_bm(void);

void dsfmt_randn_bm_reset(void)
{
randn_bm_next = RANDN_RESET;
Expand All @@ -36,36 +39,3 @@ double dsfmt_randn_bm(void)
randn_bm_next = s * vre;
return s * vim;
}

// Ziggurat

uint32_t *ZT_STATE;
uint64_t *KI;
uint64_t *KE;
double *WI;
double *FI;
double *WE;
double *FE;

void randn_zig_init(uint32_t seed) {
ZT_STATE = (uint32_t *) malloc ((MT_N+4) * sizeof(uint32_t));
KI = (uint64_t *) malloc(ZIGGURAT_TABLE_SIZE * sizeof(uint64_t));
KE = (uint64_t *) malloc(ZIGGURAT_TABLE_SIZE * sizeof(uint64_t));
WI = (double *) malloc(ZIGGURAT_TABLE_SIZE * sizeof(double));
FI = (double *) malloc(ZIGGURAT_TABLE_SIZE * sizeof(double));
WE = (double *) malloc(ZIGGURAT_TABLE_SIZE * sizeof(double));
FE = (double *) malloc(ZIGGURAT_TABLE_SIZE * sizeof(double));

randmtzig_init_by_int(seed, ZT_STATE);

return;
}

double randn_zig(void) {
return randmtzig_randn(ZT_STATE, KI, KE, WI, FI, WE, FE);
}

double *randn_zig_fill_array(double *a, uint32_t n) {
randmtzig_fill_drandn(n, a, ZT_STATE, KI, KE, WI, FI, WE, FE);
return a;
}
6 changes: 0 additions & 6 deletions external/random/jl_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@ void randomize();
uint32_t genrand_int32();
void randomseed32(uint32_t s);
void randomseed64(uint64_t s);
double dsfmt_randn();
uint32_t dsfmt_gv_genrand_uint32(void);

void randn_zig_init(uint32_t seed);
double randn_zig(void);
double *randn_zig_fill_array(double *a, uint32_t n);

#endif
Loading

0 comments on commit 7ff80c9

Please sign in to comment.