MT19937¶
Scalar¶
namespace pxart {
struct mt19937;
}
Include Scheme¶
#include <pxart/mt19937.hpp>
Member Types¶
using uint_type = uint32_t;
using result_type = uint_type;
struct default_seeder;
Member Functions¶
Construction and Seeding¶
constexpr mt19937();
pxart::mt19937::default_seeder
. template <typename RNG>
constexpr explicit mt19937(RNG&& rng);
Generation¶
constexpr result_type operator()() noexcept;
Characteristics¶
constexpr result_type min() noexcept;
constexpr result_type max() noexcept;
Notes¶
pxart::mt19937
used with pxart::mt19937::default_seeder
produces exactly the same results as std::mt19937
from the C++ STL.
Example¶
#include <iomanip>
#include <iostream>
#include <random>
//
#include <pxart/mt19937.hpp>
#include <pxart/uniform.hpp>
using namespace std;
int main() {
// Properly initialize pxart PRNG.
pxart::mt19937 rng{std::random_device{}};
// Print some uniformly distributed random numbers.
for (size_t i = 0; i < 10; ++i)
cout << setw(20) << pxart::uniform<float>(rng) << '\n';
}
Last update: January 18, 2021