#include <Rand.h>
|
| | Random () |
| | Construct and seed from std::random_device.
|
| | Random (uint32_t seed) |
| | Construct with a deterministic seed.
|
| float | rand005 () |
| | Draw a random float in [0, 0.5).
|
| float | rand051 () |
| | Draw a random float in [0.5, 1).
|
| float | rand01 () |
| | Draw a random float in [0, 1).
|
| float | rand11 () |
| | Draw a random float in [-1, 1).
|
| float | rand0Pi () |
| | Draw a random float in [0, ).
|
| template<typename T> |
| T | rand (T a, T b) |
| | Draw a value uniformly in the half-open interval [a, b).
|
| template<typename T> |
| void | shuffle (std::vector< T > &a) |
| | Shuffle a container in-place using Fisher–Yates.
|
◆ Random() [1/2]
Construct and seed from std::random_device.
◆ Random() [2/2]
| Random::Random |
( |
uint32_t | seed | ) |
|
Construct with a deterministic seed.
- Parameters
-
| seed | Seed value for the underlying PRNG. |
◆ rand()
template<typename T>
| T Random::rand |
( |
T | a, |
|
|
T | b ) |
|
inline |
Draw a value uniformly in the half-open interval [a, b).
- Template Parameters
-
| T | Arithmetic type (typically float/double/int). For integral types, the result is produced by scaling a [0,1) float and casting. |
- Parameters
-
| a | Lower bound (inclusive). |
| b | Upper bound (exclusive conceptually; for integers, distribution is effectively over the discrete set starting at a). |
- Returns
- A value in the range [a, b).
- Warning
- For integral
T the mapping is via cast from float and thus not perfectly uniform over the integers.
◆ rand005()
| float Random::rand005 |
( |
| ) |
|
Draw a random float in [0, 0.5).
- Returns
- Value
.
◆ rand01()
Draw a random float in [0, 1).
- Returns
- Value
.
◆ rand051()
| float Random::rand051 |
( |
| ) |
|
Draw a random float in [0.5, 1).
- Returns
- Value
.
◆ rand0Pi()
| float Random::rand0Pi |
( |
| ) |
|
Draw a random float in [0,
).
- Returns
- Value
(radians).
◆ rand11()
Draw a random float in [-1, 1).
- Returns
- Value
.
◆ shuffle()
template<typename T>
| void Random::shuffle |
( |
std::vector< T > & | a | ) |
|
|
inline |
Shuffle a container in-place using Fisher–Yates.
- Template Parameters
-
| T | Element type contained in the vector. |
- Parameters
-
- Note
- Uses this instance's PRNG via
rand<size_t>().
The documentation for this class was generated from the following files: