Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imneme/pcg-c-basic
PCG — Minimal C Implementation
https://github.com/imneme/pcg-c-basic
Last synced: 3 months ago
JSON representation
PCG — Minimal C Implementation
- Host: GitHub
- URL: https://github.com/imneme/pcg-c-basic
- Owner: imneme
- License: apache-2.0
- Created: 2014-10-17T18:46:23.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-11-25T11:44:58.000Z (12 months ago)
- Last Synced: 2024-06-24T01:02:58.793Z (5 months ago)
- Language: C
- Size: 197 KB
- Stars: 398
- Watchers: 22
- Forks: 51
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-embedded-software - pcg-c-basic - Code provides a minimal implementation of one member of the PCG family of random number generators, which are fast, statistically excellent, and offer a number of useful features. (Cryptography / Random Number Generation)
README
# PCG Random Number Generation, Minimal C Edition
[PCG-Random website]: http://www.pcg-random.org
This code provides a minimal implementation of one member of the PCG family
of random number generators, which are fast, statistically excellent,
and offer a number of useful features.Full details can be found at the [PCG-Random website]. This version
of the code provides a single family member and skips some useful features
(such as jump-ahead/jump-back) -- if you want a more full-featured library,
you may prefer the full version of the C library, or for all features,
the C++ library.## Documentation and Examples
Visit [PCG-Random website] for information on how to use this library, or look
at the sample code -- hopefully it should be fairly self explanatory.## Building
There is no library to build. Just use the code. You can however build the
three demo programs.The code is written in C89-style C with no significant platform dependencies.
On a Unix-style system (e.g., Linux, Mac OS X), or any system with `make`,
you should be able to just type typemake
Almost all the real code is in `pcg_basic.c`, with type and function
declarations in `pcg_basic.h`.On other systems, it should be straightforward to build. For example, you
even run the code directly using the tinycc compiler, usingcat pcg_basic.c pcg32-demo.c | tcc -run
## Testing
This command will build the three provided demo programs, `pcg32-global-demo`
(which uses the global rng), `pcg32-demo` (which uses a local generator), and
pcg32x2-demo (which gangs together two generators, showing the usefulness of
creating multiple generators).To run the demos using a fixed seed (same output every time), run
./pcg32-demo
To produce different output, run./pcg32-demo -r
You can also pass an integer count to specify how may rounds of output you
would like.