diff options
| author | Tyge Løvset <[email protected]> | 2022-04-18 23:00:13 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-04-18 23:00:13 +0200 |
| commit | 1eddea1da0125ddad2f8804fadafd1494c1bb11a (patch) | |
| tree | 2c38c69cd129edb88dc901a3e1197d177b1a6cf9 /include | |
| parent | c2ed81e1d1de503b9264e7c03bcc7087a270df94 (diff) | |
| download | STC-modified-1eddea1da0125ddad2f8804fadafd1494c1bb11a.tar.gz STC-modified-1eddea1da0125ddad2f8804fadafd1494c1bb11a.zip | |
Renamed stc64_random() => crandom(), stc64_srandom(seed) => csrandom(seed). Kept old names for backward comp.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/clist.h | 2 | ||||
| -rw-r--r-- | include/stc/crandom.h | 20 |
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);
}
|
