RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
Random.hpp File Reference
#include <cstddef>
#include <random>
#include <type_traits>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  RST
 Root namespace of RSTools.
 
namespace  RST::Maths
 Math helpers: constants, interpolation, random numbers, 2D and 3D vectors and matrices.
 

Functions

Random numbers
std::mt19937 & RST::Maths::randomEngine ()
 Per-thread engine behind random() and randomChoice(); call seed() on it for reproducible results.
 
template<typename T >
T RST::Maths::random (const T &min, const T &max)
 Uniform random number in [min, max] for integers, or [min, max) for floating-point types.
 
template<typename T >
T RST::Maths::randomChoice (const std::vector< T > &list)
 Random element of list, or T{} if it is empty.