#include #include #include #include "dpf.hpp" /// `buffered_prg` is a forward cursor, one stream per value type. /// `at(index)` reads by absolute index and does not move the cursor. /// `lane_table` is the seekable form: value and mask streams per role. int main() { //! [buffered-prg] dpf::randomness::aes_buffered_prg prg( /*per stream*/ 64); std::uint64_t first = prg.get<0>(); std::uint64_t second = prg.get<0>(); // Absolute index 0 is `first` again. The cursor stays at 2. std::uint64_t replay = prg.at<0>(0); std::uint32_t other_stream = prg.get<1>(); std::uint64_t batch[4]; prg.fill<0>(batch, 4); //! [buffered-prg] if (std::memcmp(&replay, &first, sizeof(first)) != 0) { std::cerr << "buffered_prg at(0)\n"; return 1; } if (prg.sampled<0>() != 6) { std::cerr << "buffered_prg cursor\n"; return 1; } // Stream 1 has its own cursor. if (prg.sampled<1>() != 1) { std::cerr << "buffered_prg stream 1\n"; return 1; } (void)second; (void)other_stream; (void)batch; //! [lane-table] dpf::randomness::lane_table lanes(/*window*/ 32); // Order does not matter. Masks are a separate stream from values. auto v_late = lanes.value_at(/*role*/ 3, /*index*/ 10); auto v_early = lanes.value_at(3, 10); auto mask = lanes.mask_at(3, 10); //! [lane-table] if (std::memcmp(&v_late, &v_early, sizeof(v_late)) != 0) { std::cerr << "lane_table replay\n"; return 1; } (void)mask; std::cout << "ok\n"; return 0; }