Aerobus v1.2
Loading...
Searching...
No Matches
examples/polynomials_over_finite_field.cpp

How to build a known polynomial (here aerobus::known_polynomials::allone) with coefficients in a finite field (here aerobus::zpz<2>) and get its value when evaluated at a value in this field (here 1).

#include <iostream>
#include "../src/aerobus.h"
using GF2 = aerobus::zpz<2>;
using P = aerobus::known_polynomials::allone<8, GF2>;
int main() {
// at this point, value_at_1 is an instanciation of zpz<2>::val
using value_at_1 = P::template value_at_t<GF2::template inject_constant_t<1>>;
// here we get its value in an arithmetic type, here int32_t
constexpr int32_t x = value_at_1::template get<int32_t>();
// ensure that 1+1+1+1+1+1+1+1 in Z/2Z is equal to one
std::cout << "expected = " << 1 << std::endl;
std::cout << "computed = " << x << std::endl;
return 0;
}
congruence classes of integers modulo p (32 bits)
Definition aerobus.h:1607