summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-12-28 18:18:48 +0100
committerTyge Løvset <[email protected]>2020-12-28 18:18:48 +0100
commit74a75b3a8d155ea155358674d3bf8251658183a5 (patch)
tree19886986b9ce6943b826311cda40f67ebc8dd7b1 /docs
parent83b7be31a1d0fc0be4e013dbfc97bb6cdc3600db (diff)
downloadSTC-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 'docs')
-rw-r--r--docs/cpque_api.md6
-rw-r--r--docs/crand_api.md49
2 files changed, 27 insertions, 28 deletions
diff --git a/docs/cpque_api.md b/docs/cpque_api.md
index cd6b8a9e..7e0021d3 100644
--- a/docs/cpque_api.md
+++ b/docs/cpque_api.md
@@ -63,13 +63,13 @@ using_cpque(i, cvec_i, >); // adaptor type, '>' = min-heap
int main()
{
size_t N = 10000000;
- crand_t rng = crand_init(1234);
- crand_uniform_t dist = crand_uniform_init(0, N * 10);
+ stc64_t rng = stc64_init(1234);
+ stc64_uniform_t dist = stc64_uniform_init(0, N * 10);
cpque_i heap = cpque_i_init();
// Push ten million random numbers to priority queue, plus some negative ones.
c_forrange (N)
- cpque_i_push(&heap, crand_uniform(&rng, &dist));
+ cpque_i_push(&heap, stc64_uniform(&rng, &dist));
c_push_items(&heap, cpque_i, {-231, -32, -873, -4, -343});
// Extract and display the fifty smallest.
diff --git a/docs/crand_api.md b/docs/crand_api.md
index ddab9b23..3299b046 100644
--- a/docs/crand_api.md
+++ b/docs/crand_api.md
@@ -1,30 +1,29 @@
# Module [crand](../stc/crand.h): Pseudo Random Number Generators
-This describes the API of module **crand**. It contains a *64-bit PRNG*, and can generate
+This describes the API of module **crand**. It contains **stc64**, a *64-bit PRNG*, and can generate
bounded uniform and normal distributed random numbers.
-**crand** is an extremely fast PRNG by Tyge Løvset, suited for parallel usage. It features a
-Weyl-sequence as part of the state. It is faster than *sfc64*, *wyhash64*, *pcg64*, and almost
-50% faster than *xoshiro256\*\** on common platforms. It does not require fast multiplication or
-128-bit integer operations. It has a 256 bit state, but updates only 192 bit per generated
-number.
+**stc64** is an extremely fast PRNG by Tyge Løvset, suited for parallel usage. It features a
+Weyl-sequence as part of the state. It is faster than *sfc64*, *wyhash64*, *pcg64*, and *xoshiro256\*\**
+on common platforms. It does not require fast multiplication or 128-bit integer operations. It has a
+256 bit state, but updates only 192 bit per generated number.
-There is no *jump function*, but by incrementing the Weyl-increment by 2, it starts a new
+There is no *jump function*, but by incrementing the Weyl-increment by 2, it starts a new
unique 2^64 *minimum* length period. Note that for each Weyl-increment (state[3]), the period
length is about 2^126 with a high probability. For a single thread, a minimum period of 2^127
is generated when the Weyl-increment is incremented by 2 every 2^64 output.
-**crand** passes *PractRand*, tested up to 8TB output, Vigna's Hamming weight test, and simple
+**stc64** passes *PractRand*, tested up to 8TB output, Vigna's Hamming weight test, and simple
correlation tests, i.e. *n* interleaved streams with only one-bit differences in initial state.
## Types
| Name | Type definition | Used to represent... |
|:-------------------|:------------------------------------------|:-----------------------------|
-| `crand_t` | `struct {uint64_t state[4];}` | The PRNG engine type |
-| `crand_uniform_t` | `struct {int64_t lower; uint64_t range;}` | Integer uniform distribution |
-| `crand_uniformf_t` | `struct {double lower, range;}` | Real number uniform distr. |
-| `crand_normalf_t` | `struct {double mean, stddev;}` | Normal distribution type |
+| `stc64_t` | `struct {uint64_t state[4];}` | The PRNG engine type |
+| `stc64_uniform_t` | `struct {int64_t lower; uint64_t range;}` | Integer uniform distribution |
+| `stc64_uniformf_t` | `struct {double lower, range;}` | Real number uniform distr. |
+| `stc64_normalf_t` | `struct {double mean, stddev;}` | Normal distribution type |
## Header file
@@ -36,16 +35,16 @@ All cstr definitions and prototypes may be included in your C source file by inc
## Methods
```c
- 1) crand_t crand_init(uint64_t seed);
- 2) crand_t crand_with_seq(uint64_t seed, uint64_t seq);
- 3) uint64_t crand_next(crand_t* rng);
- 4) double crand_nextf(crand_t* rng);
- 5) crand_uniform_t crand_uniform_init(int64_t low, int64_t high);
- 6) int64_t crand_uniform(crand_t* rng, crand_uniform_t* dist);
- 7) crand_uniformf_t crand_uniformf_init(double low, double high);
- 8) double crand_uniformf(crand_t* rng, crand_uniformf_t* dist);
- 9) crand_normalf_t crand_normalf_init(double mean, double stddev);
-10) double crand_normalf(crand_t* rng, crand_normalf_t* dist);
+ 1) stc64_t stc64_init(uint64_t seed);
+ 2) stc64_t stc64_with_seq(uint64_t seed, uint64_t seq);
+ 3) uint64_t stc64_rand(stc64_t* rng);
+ 4) double stc64_randf(stc64_t* rng);
+ 5) stc64_uniform_t stc64_uniform_init(int64_t low, int64_t high);
+ 6) int64_t stc64_uniform(stc64_t* rng, stc64_uniform_t* dist);
+ 7) stc64_uniformf_t stc64_uniformf_init(double low, double high);
+ 8) double stc64_uniformf(stc64_t* rng, stc64_uniformf_t* dist);
+ 9) stc64_normalf_t stc64_normalf_init(double mean, double stddev);
+10) double stc64_normalf(stc64_t* rng, stc64_normalf_t* dist);
```
`1-2)` PRNG 64-bit engine initializers. `3)` Integer generator, range \[0, 2^64).
`4)` Double RNG with range \[0, 1). `5-6)` Uniform integer RNG with range \[*low*, *high*].
@@ -82,13 +81,13 @@ int main()
// Setup random engine with normal distribution.
uint64_t seed = time(NULL);
- crand_t rng = crand_init(seed);
- crand_normalf_t dist = crand_normalf_init(Mean, StdDev);
+ stc64_t rng = stc64_init(seed);
+ stc64_normalf_t dist = stc64_normalf_init(Mean, StdDev);
// Create histogram map
cmap_i mhist = cmap_i_init();
for (size_t i = 0; i < N; ++i) {
- int index = (int) round( crand_normalf(&rng, &dist) );
+ int index = (int) round( stc64_normalf(&rng, &dist) );
cmap_i_emplace(&mhist, index, 0).first->second += 1;
}