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
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
|
|
@ -141,3 +142,54 @@ TEST(SignedPrefix, RejectsAKeyWithoutAComparison)
|
|||
EXPECT_THROW(grotto::signed_prefix_parities(k0, ends), std::invalid_argument);
|
||||
EXPECT_THROW(grotto::signed_segment_parities(k1, ends), std::invalid_argument);
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
void expect_ilogb_segments(const grotto::constant_lut<int8_t> & lut, int8_t alpha)
|
||||
{
|
||||
if (lut.bounds.size() != N)
|
||||
return;
|
||||
std::array<int8_t, N> ends{};
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
ends[i] = lut.bounds[i];
|
||||
auto [k0, k1] = dpf::make_dpf(alpha, dpf::gt(uint64_t{1}));
|
||||
const uint64_t mask = k0.cmp().mask;
|
||||
const auto s0 = grotto::signed_segment_parities(k0, ends);
|
||||
const auto s1 = grotto::signed_segment_parities(k1, ends);
|
||||
uint64_t acc = 0;
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
{
|
||||
const uint64_t bit = opened(s0[i], s1[i], mask);
|
||||
acc += bit * static_cast<uint64_t>(lut.values[i]);
|
||||
}
|
||||
EXPECT_EQ(acc, static_cast<uint64_t>(lut(alpha))) << int(alpha);
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
void dispatch_ilogb(const grotto::constant_lut<int8_t> & lut, int8_t alpha, bool & matched)
|
||||
{
|
||||
if (lut.bounds.size() == N)
|
||||
{
|
||||
expect_ilogb_segments<N>(lut, alpha);
|
||||
matched = true;
|
||||
return;
|
||||
}
|
||||
if constexpr (N > 1)
|
||||
dispatch_ilogb<N - 1>(lut, alpha, matched);
|
||||
}
|
||||
|
||||
TEST(SignedPrefix, SegmentsRecoverIlogbInt8)
|
||||
{
|
||||
for (unsigned frac : {0u, 4u})
|
||||
{
|
||||
const auto lut = grotto::make_exact_constant_lut<int8_t>(
|
||||
grotto::exact_constant::ilogb, frac);
|
||||
ASSERT_GE(lut.bounds.size(), 3u);
|
||||
ASSERT_LE(lut.bounds.size(), 40u);
|
||||
for (int v = -128; v <= 127; ++v)
|
||||
{
|
||||
bool matched = false;
|
||||
dispatch_ilogb<40>(lut, static_cast<int8_t>(v), matched);
|
||||
ASSERT_TRUE(matched) << lut.bounds.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue