ZEDA  1.6.18
zeda_rand.h
Go to the documentation of this file.
1 /* ZEDA - Elementary Data and Algorithms
2  * Copyright (C) 1998 Tomomichi Sugihara (Zhidao)
3  */
15 #include <zeda/zeda_misc.h>
16 
17 #ifndef __ZEDA_RAND_H__
18 #define __ZEDA_RAND_H__
19 
21 
23 #ifndef __KERNEL__
24 
25 /* ********************************************************** *//* ************************************************** */
31 
33 #define Z_RAND_MT_HISTORY 623
34 
36 /* ********************************************************** *//********************************************************* */
39 typedef struct{
40  ulong x[Z_RAND_MT_HISTORY+1];
41  int index;
42  bool nd_sw;
43  double nd_last;
44 } zRandMT;
45 
53 __EXPORT void zRandInitMT(zRandMT *mt);
54 
56 __EXPORT int zRandMTI(zRandMT *mt, int min, int max);
57 
60 __EXPORT double zRandMTF(zRandMT *mt, double min, double max);
61 
64 __EXPORT double zRandMTN(zRandMT *mt);
65 
67 __EXPORT double zRandMTNU(zRandMT *mt);
68 
71 
72 #define zRandInit() zRandInitMT( NULL )
73 #define zRandI(min,max) zRandMTI( NULL, min, max )
74 #define zRandF(min,max) zRandMTF( NULL, min, max )
75 #define zRandN() zRandMTN( NULL )
76 #define zRandNU() zRandMTNU( NULL )
77 
80 #endif /* __KERNEL__ */
81 
83 
84 #endif /* __ZEDA_RAND_H__ */
double zRandMTN(zRandMT *mt)
a pseudo-random double-precision floating-point value in the range of [0,1].
double zRandMTNU(zRandMT *mt)
a pseudo-random value in the range of [0,1).
double nd_last
Definition: zeda_rand.h:43
#define __END_DECLS
Definition: zeda_defs.h:30
void zRandInitMT(zRandMT *mt)
initialize a random number generator based on Mersenne twister.
bool nd_sw
Definition: zeda_rand.h:42
random number generator based on Mersenne twister.
Definition: zeda_rand.h:39
miscellanies.
int index
Definition: zeda_rand.h:41
int zRandMTI(zRandMT *mt, int min, int max)
a pseudo-random integer between min and max.
#define __BEGIN_DECLS
Definition: zeda_defs.h:26
unsigned long ulong
Definition: zeda_defs.h:105
#define __EXPORT
Definition: zeda_compat.h:32
zRandMT * zRandMTDefault(void)
return a pointer to the default random number generator.
double zRandMTF(zRandMT *mt, double min, double max)
a pseudo-random double-precision floating-point value between min and max.