Skip to content

PCG32

Scalar

namespace pxart {

struct pcg32;

}

Include Scheme

#include <pxart/pcg32.hpp>

Member Types

using uint_type = uint64_t;
using result_type = uint32_t;

Member Functions

Construction and Seeding

constexpr pcg32();
Default constructor.


template <typename RNG>
constexpr explicit pcg32(RNG&& rng);
Initialize the PRNG by any other seeder or RNG.

Generation

constexpr result_type operator()() noexcept;
Return pseudorandom numbers and advance the state of the generator.

Example

#include <iomanip>
#include <iostream>
#include <random>
//
#include <pxart/pcg32.hpp>
#include <pxart/uniform.hpp>

using namespace std;

int main() {
  // Properly initialize pxart PRNG.
  pxart::pcg32 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