MCPcopy Create free account
hub / github.com/LancePutnam/Gamma / main

Function main

examples/function/random.cpp:15–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13using namespace gam;
14
15int main(int argc, char* argv[]){
16
17 const int iterations = 24;
18 #define LOOP for(int i=0; i<iterations; i++)
19
20 float floats[iterations];
21 int ints[iterations];
22
23 RNGLinCon lc;
24 RNGMulLinCon mlc;
25 RNGTaus tw;
26
27 printf("\n\nRNG LinCon float:\n");
28 LOOP printf("%4.2f ", rnd::uni_float(lc));
29
30 printf("\n\nRNG MulLinCon float:\n");
31 LOOP printf("%4.2f ", rnd::uni_float(mlc));
32
33 printf("\n\nRNG Tausworthe float:\n");
34 LOOP printf("%4.2f ", rnd::uni_float(tw));
35
36 printf("\n\nRNG shared float:\n");
37 LOOP printf("%4.2f ", rnd::uni(1.f));
38
39 printf("\n\npermute:\n");
40 for(int i=0; i<16; i++){
41 slice(ints,iterations) = gen::RAdd1<int>();
42 rnd::permute(ints, iterations);
43 LOOP printf("%2i ", ints[i]);
44 printf("\n");
45 }
46
47 printf("\n\ncond(0.2, 0.2):\n");
48 char v = '|';
49 for(int i=0; i<256; ++i) printf("%c", rnd::cond(v, '.', '|', 0.2, 0.2));
50
51 printf("\n\ncond(0.8, 0.8):\n");
52 for(int i=0; i<256; ++i) printf("%c", rnd::cond(v, '.', '|', 0.8, 0.8));
53
54 printf("\n\nprob(0.2):\n");
55 for(int i=0; i<256; ++i) printf("%c", rnd::prob(0.2) ? '|' : '.');
56
57 printf("\n\nprob(0.8):\n");
58 for(int i=0; i<256; ++i) printf("%c", rnd::prob(0.8) ? '|' : '.');
59
60 printf("\n\nthin(0.2):\n");
61 slice(floats, iterations) = gen::Val<>(1);
62 rnd::thin(floats, iterations, 0.2);
63 LOOP printf("%c", floats[i] != 0.f ? '|' : '.');
64
65 printf("\n\nthin(0.8):\n");
66 slice(floats, iterations) = gen::Val<>(1);
67 rnd::thin(floats, iterations, 0.8);
68 LOOP printf("%c", floats[i] != 0.f ? '|' : '.');
69
70 printf("\n\nuni [0.f, 1.f)\n");
71 rnd::uni(floats, iterations);
72 LOOP printf("%4.2f ", floats[i]);

Callers

nothing calls this directly

Calls 7

uni_floatFunction · 0.85
sliceFunction · 0.85
probFunction · 0.85
thinFunction · 0.85
pow3Function · 0.85
weightedFunction · 0.85
permuteFunction · 0.50

Tested by

no test coverage detected