Go to the documentation of this file.
11 #ifndef _GK_MKRANDOM_H
12 #define _GK_MKRANDOM_H
23 #define GK_MKRANDOM(FPRFX, RNGT, VALT)\
27 void FPRFX ## srand(RNGT seed) \
29 gk_randinit((uint64_t) seed);\
36 RNGT FPRFX ## rand() \
38 if (sizeof(RNGT) <= sizeof(int32_t)) \
39 return (RNGT)gk_randint32(); \
41 return (RNGT)gk_randint64(); \
48 RNGT FPRFX ## randInRange(RNGT max) \
50 return (RNGT)((FPRFX ## rand())%max); \
59 void FPRFX ## randArrayPermute(RNGT n, VALT *p, RNGT nshuffles, int flag)\
70 for (i=0; i<n; i++) {\
71 v = FPRFX ## randInRange(n);\
72 u = FPRFX ## randInRange(n);\
73 gk_SWAP(p[v], p[u], tmp);\
77 for (i=0; i<nshuffles; i++) {\
78 v = FPRFX ## randInRange(n-3);\
79 u = FPRFX ## randInRange(n-3);\
84 gk_SWAP(p[v+0], p[u+2], tmp);\
85 gk_SWAP(p[v+1], p[u+3], tmp);\
86 gk_SWAP(p[v+2], p[u+0], tmp);\
87 gk_SWAP(p[v+3], p[u+1], tmp);\
98 void FPRFX ## randArrayPermuteFine(RNGT n, VALT *p, int flag)\
108 for (i=0; i<n; i++) {\
109 v = FPRFX ## randInRange(n);\
110 gk_SWAP(p[i], p[v], tmp);\
115 #define GK_MKRANDOM_PROTO(FPRFX, RNGT, VALT)\
116 void FPRFX ## srand(RNGT seed); \
117 RNGT FPRFX ## rand(); \
118 RNGT FPRFX ## randInRange(RNGT max); \
119 void FPRFX ## randArrayPermute(RNGT n, VALT *p, RNGT nshuffles, int flag);\
120 void FPRFX ## randArrayPermuteFine(RNGT n, VALT *p, int flag);\
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:22