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
|
|
@ -1,31 +1,44 @@
|
|||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#include "dpf.hpp"
|
||||
|
||||
int main(int arc, char * argv[])
|
||||
/// Every input of the domain, from `numeric_limits<Input>::min()` through
|
||||
/// `max()`. Same shape as `eval_interval`.
|
||||
int main()
|
||||
{
|
||||
uint16_t x = 42; // Input value
|
||||
using prg = dpf::prg::counter_wrapper<dpf::prg::dummy>; // This is just to count the number of PRG invocations
|
||||
auto before = prg::count(); // In order to show how much this program cost
|
||||
auto [dpf0, dpf1] = dpf::make_dpf<prg>(x);
|
||||
auto after = prg::count();
|
||||
std::cout << "dpf::make_dpf used " << (after-before) << "\n";
|
||||
const std::uint8_t alpha = 42;
|
||||
const std::uint64_t beta = 7;
|
||||
auto [k0, k1] = dpf::make_dpf(alpha, beta);
|
||||
|
||||
before = prg::count();
|
||||
auto [buf0, iter0] = dpf::eval_full(dpf0);
|
||||
after = prg::count();
|
||||
std::cout << "dpf::eval_full(dpf0) used " << (after-before) << "\n";
|
||||
before = prg::count();
|
||||
auto [buf1, iter1] = dpf::eval_full(dpf1);
|
||||
after = prg::count();
|
||||
std::cout << "dpf::eval_full(dpf1) used " << (after-before) << "\n";
|
||||
// Retrieve the original input by iterating over the two buffers
|
||||
for (size_t i = 0; i < buf0.size(); ++i) {
|
||||
bool item1 = buf0[i];
|
||||
bool item2 = buf1[i];
|
||||
if (item1 ^ item2) std::cout << "The original input is: " << i << std::endl;
|
||||
//! [eval-full]
|
||||
auto [buf0, iter0] = dpf::eval_full(k0);
|
||||
auto [buf1, iter1] = dpf::eval_full(k1);
|
||||
|
||||
auto it0 = std::begin(iter0);
|
||||
auto it1 = std::begin(iter1);
|
||||
for (int x = std::numeric_limits<std::uint8_t>::min();
|
||||
x <= std::numeric_limits<std::uint8_t>::max();
|
||||
++x, ++it0, ++it1)
|
||||
{
|
||||
std::uint64_t got = dpf::reconstruct(*it0, *it1);
|
||||
std::uint64_t expect = (static_cast<std::uint8_t>(x) == alpha) ? beta : 0;
|
||||
if (got != expect)
|
||||
{
|
||||
std::cerr << "eval_full\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//! [eval-full]
|
||||
if (it0 != std::end(iter0) || it1 != std::end(iter1))
|
||||
{
|
||||
std::cerr << "eval_full length\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << "Total PRG invocation: " << prg::count() << "\n";
|
||||
std::cout << beta << "\n";
|
||||
(void)buf0;
|
||||
(void)buf1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue