summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/stc/clist.h2
-rw-r--r--include/stc/crandom.h20
2 files changed, 12 insertions, 10 deletions
diff --git a/include/stc/clist.h b/include/stc/clist.h
index 88f41f4e..c3c15900 100644
--- a/include/stc/clist.h
+++ b/include/stc/clist.h
@@ -38,7 +38,7 @@
{
int n;
for (int i = 0; i < 1000000; ++i) // one million
- clist_ix_push_back(&list, stc64_random() >> 32);
+ clist_ix_push_back(&list, crandom() >> 32);
n = 0;
c_foreach (i, clist_ix, list)
if (++n % 10000 == 0) printf("%8d: %10zu\n", n, *i.ref);
diff --git a/include/stc/crandom.h b/include/stc/crandom.h
index 97e0275d..e12b9bed 100644
--- a/include/stc/crandom.h
+++ b/include/stc/crandom.h
@@ -60,9 +60,12 @@ typedef struct stc64_normalf { double mean, stddev, next; unsigned has_next; } s
*/
/* Global STC64 PRNGs */
-STC_API void stc64_srandom(uint64_t seed);
-STC_API uint64_t stc64_random(void);
-STC_API double stc64_randomf(void);
+STC_API void csrandom(uint64_t seed);
+STC_API uint64_t crandom(void);
+STC_API double crandomf(void);
+
+STC_INLINE void stc64_srandom(uint64_t seed) { csrandom(seed); } // alias
+STC_INLINE uint64_t stc64_random() { return crandom(); } // alias
/* Init with sequence number */
STC_API stc64_t stc64_with_seq(uint64_t seed, uint64_t seq);
@@ -70,9 +73,8 @@ STC_API stc64_t stc64_with_seq(uint64_t seed, uint64_t seq);
/* Unbiased bounded uniform distribution. range [low, high] */
STC_API int64_t stc64_uniform(stc64_t* rng, stc64_uniform_t* dist);
-STC_INLINE stc64_t stc64_init(uint64_t seed) {
- return stc64_with_seq(seed, seed + 0x3504f333d3aa0b37);
-}
+STC_INLINE stc64_t stc64_init(uint64_t seed)
+ { return stc64_with_seq(seed, seed + 0x3504f333d3aa0b37); }
STC_INLINE uint64_t stc64_rand(stc64_t* rng) {
uint64_t *s = rng->state; enum {LR=24, RS=11, LS=3};
@@ -129,15 +131,15 @@ static stc64_t stc64_global = {{
0x6a09e667a754166b
}};
-STC_DEF void stc64_srandom(uint64_t seed) {
+STC_DEF void csrandom(uint64_t seed) {
stc64_global = stc64_init(seed);
}
-STC_DEF uint64_t stc64_random(void) {
+STC_DEF uint64_t crandom(void) {
return stc64_rand(&stc64_global);
}
-STC_DEF double stc64_randomf(void) {
+STC_DEF double crandomf(void) {
return stc64_randf(&stc64_global);
}