diff options
| author | Tyge Løvset <[email protected]> | 2020-12-28 18:18:48 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-12-28 18:18:48 +0100 |
| commit | 74a75b3a8d155ea155358674d3bf8251658183a5 (patch) | |
| tree | 19886986b9ce6943b826311cda40f67ebc8dd7b1 /examples/random.c | |
| parent | 83b7be31a1d0fc0be4e013dbfc97bb6cdc3600db (diff) | |
| download | STC-modified-74a75b3a8d155ea155358674d3bf8251658183a5.tar.gz STC-modified-74a75b3a8d155ea155358674d3bf8251658183a5.zip | |
Reverted crand.h API back to rename crand_* to stc64_*, and crand_next() -> stc64_rand().
Diffstat (limited to 'examples/random.c')
| -rw-r--r-- | examples/random.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/random.c b/examples/random.c index 94a68607..7325e023 100644 --- a/examples/random.c +++ b/examples/random.c @@ -9,16 +9,16 @@ int main() enum {R = 30};
const size_t N = 1000000000;
uint64_t seed = 1234; // time(NULL);
- crand_t rng = crand_init(seed);
+ stc64_t rng = stc64_init(seed);
uint64_t sum = 0;
- crand_normalf_t dist2 = crand_normalf_init(R / 2.0, R / 6.0);
+ stc64_normalf_t dist2 = stc64_normalf_init(R / 2.0, R / 6.0);
size_t N2 = 10000000;
int hist[R] = {0};
sum = 0;
c_forrange (N2) {
- int n = round((crand_normalf(&rng, &dist2) + 0.5));
+ int n = round((stc64_normalf(&rng, &dist2) + 0.5));
sum += n;
if (n >= 0 && n < R) ++hist[n];
}
@@ -33,16 +33,16 @@ int main() sum = 0;
before = clock();
c_forrange (N) {
- sum += crand_next(&rng);
+ sum += stc64_rand(&rng);
}
diff = clock() - before;
printf("random : %f secs, %zu %f\n", (float) diff / CLOCKS_PER_SEC, N, (double) sum / N);
- crand_uniform_t dist1 = crand_uniform_init(0, 1000);
+ stc64_uniform_t dist1 = stc64_uniform_init(0, 1000);
sum = 0;
before = clock();
c_forrange (N) {
- sum += crand_uniform(&rng, &dist1);
+ sum += stc64_uniform(&rng, &dist1);
}
diff = clock() - before;
printf("uniform: %f secs, %zu %f\n", (float) diff / CLOCKS_PER_SEC, N, (double) sum / N);
|
