class to create a fast xorshift-based pseudo-random number generator More...
#include <taskflow/utility/math.hpp>
Public Member Functions | |
| Xorshift ()=default | |
| constructs an uninitialized xor-shift generator | |
| Xorshift (T value) | |
| constructs a xor-shift generator with the given seed | |
| void | seed (T value) |
| seeds the generator with a new value | |
| T | operator() () |
| generates the next pseudo-random value | |
class to create a fast xorshift-based pseudo-random number generator
| T | unsigned integral type used as the internal state (supported uint32_t and uint64_t) |
This class implements a lightweight xorshift pseudo-random number generator suitable for performance-critical paths such as schedulers, work-stealing victim selection, and randomized backoff. The implementation is branchless on the hot path and has a very small state footprint (one machine word). All operations are integer-only.
|
default |
constructs an uninitialized xor-shift generator
The internal state is not initialized. The user must call seed() with a non-zero value before generating numbers.
|
inline |
constructs a xor-shift generator with the given seed
| value | the new seed value to use |
The seed value must be non-zero.
|
inline |
generates the next pseudo-random value
TFor 32-bit state, this function implements the Xorshift32 algorithm. For 64-bit state, this function implements the Xorshift64 algorithm with a multiplicative output transformation to improve distribution.
|
inline |
seeds the generator with a new value
| value | the new seed value |
The seed value must be non-zero. A zero seed results in a degenerated generator that always returns zero.