Annotate noexcept and constexpr with HEDLEY, and add interval containment, ChaCha, and the dyadic range tables.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
875f09fec1
commit
0d8a5a8131
97 changed files with 9212 additions and 1159 deletions
62
examples/evaluation/buffered_prg.cpp
Normal file
62
examples/evaluation/buffered_prg.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "dpf.hpp"
|
||||
|
||||
/// `buffered_prg` is a forward cursor, one stream per value type.
|
||||
/// `at<I>(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<std::uint64_t, std::uint32_t> 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<std::uint64_t> 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue