#include #include #include #include "grotto.hpp" /// Two piecewise LUTs, one comparison, one prefix walk of the union. int main() { //! [lut-union] grotto::piecewise_lut low{{0, 10}, {{1, 0}, {0, 2}}}; grotto::piecewise_lut high{{0, 4, 12}, {{3, 0}, {1, 1}, {9, 4}}}; const std::uint8_t center = 12; const std::uint8_t eta = 3; auto plan = grotto::make_lut_union_plan({low, high}, eta); auto mat = grotto::make_offset_poly_keys(center, plan.degree); auto s0 = grotto::lut_union_eval<0>(mat, plan); auto s1 = grotto::lut_union_eval<1>(mat, plan); dpf::protocol::composer composer(0); grotto::schedule_lut_union(composer, plan); //! [lut-union] if (plan.comparisons != 1 || plan.prefix_walks != 1) { std::cerr << "plan shape\n"; return 1; } if (composer.default_plan().rounds() != plan.depth) { std::cerr << "geneval rounds\n"; return 1; } const std::uint64_t opened[2] = {s0[0] + s1[0], s0[1] + s1[1]}; if (opened[0] != grotto::offset_poly_clear(center, low.knots, low.coeff, eta) || opened[1] != grotto::offset_poly_clear(center, high.knots, high.coeff, eta)) { std::cerr << "opened value\n"; return 1; } return 0; }