PetaVision  Alpha
cl_random.h
1 /*
2  * cl_random.h
3  *
4  * Created on: Dec 30, 2010
5  * Author: Craig Rasmussen
6  */
7 
8 #ifndef CL_RANDOM_H_
9 #define CL_RANDOM_H_
10 
11 #include "../include/pv_types.h"
12 #include <limits.h>
13 #include <math.h>
14 #include <stdlib.h>
15 
16 #define CL_RANDOM_MAX UINT_MAX
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
23  taus_uint4 *state;
24  int use_last;
25  float last_value;
26 };
27 
28 int cl_random_init(taus_uint4 *state, size_t count, unsigned int seed);
29 taus_uint4 cl_random_get(taus_uint4 state);
30 static inline double cl_random_max() { return (double)CL_RANDOM_MAX; }
31 float cl_box_muller(float m, float s, struct box_muller_state *bm_state);
32 static inline float cl_random_prob(taus_uint4 state) {
33  return (float)((float)state.s0 / (float)4294967296.0);
34 }
35 
36 #ifdef __cplusplus
37 }
38 #endif
39 
40 #endif /* CL_RANDOM_H_ */