7#ifndef _MINISKETCH_FIELDS_GENERIC_COMMON_IMPL_H_
8#define _MINISKETCH_FIELDS_GENERIC_COMMON_IMPL_H_ 1
18template<
typename I,
int B, u
int32_t MOD,
typename F,
typename T, const F* SQR, const F* QRT>
class Field
20 typedef BitsInt<I, B> O;
21 typedef LFSR<O, MOD> L;
25 constexpr int Bits()
const {
return B; }
27 constexpr inline Elem Mul2(Elem val)
const {
return L::Call(val); }
33 explicit Multiplier(
const Field&, Elem a) { table.template Build<L::Call>(a); }
34 constexpr inline Elem operator()(Elem a)
const {
return table.template Map<O>(a); }
40 inline constexpr Elem
Sqr(Elem a)
const {
return SQR->template Map<O>(a); }
43 inline constexpr Elem Qrt(Elem a)
const {
return QRT->template Map<O>(a); }
49 Elem FromSeed(uint64_t seed)
const {
50 uint64_t k0 = 0x496e744669656c64ull;
52 uint64_t
count = ((uint64_t)
B) << 32;
60 Elem Deserialize(BitReader& in)
const {
return in.template Read<B, I>(); }
62 void Serialize(BitWriter& out, Elem val)
const {
out.template Write<B, I>(val); }
64 constexpr Elem FromUint64(uint64_t x)
const {
return O::Mask(I(x)); }
65 constexpr uint64_t ToUint64(Elem val)
const {
return uint64_t(val); }
static constexpr I Mask(I val)
#define T(expected, seed, data)
I InvExtGCD(I x)
Compute the inverse of x using an extgcd algorithm.
constexpr I GFMul(const I &a, const I &b)
Compute the carry-less multiplication of a and b, with N bits, using L as LFSR type.
uint64_t SipHash(uint64_t k0, uint64_t k1, uint64_t data)
void Serialize(Stream &, V)=delete
void Sqr(std::vector< typename F::Elem > &poly, const F &field)
Square a polynomial.
static constexpr I Call(const I &a)