13 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
14 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
15 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
16 127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
17 179, 181, 191, 193, 197, 199, 211, 223, 227, 229
38 for (
const auto&
c : poly.
coeffs) {
39 BigInt den =
c.get_denominator();
40 BigInt g = BigInt::gcd(lcm_den, den);
41 lcm_den = lcm_den * (den / g);
44 BigInt big_p(
static_cast<std::int64_t
>(p));
46 std::vector<int64_t> mod_coeffs;
47 mod_coeffs.reserve(poly.
coeffs.size());
49 for (
const auto&
c : poly.
coeffs) {
50 BigInt
num =
c.get_numerator();
51 BigInt den =
c.get_denominator();
52 BigInt integer_coeff =
num * (lcm_den / den);
54 BigInt rem = integer_coeff % big_p;
55 int64_t rem_val = rem.try_to_int64().value();
56 if (rem_val < 0) rem_val += p;
58 mod_coeffs.push_back(rem_val);
61 while (!mod_coeffs.empty() && mod_coeffs.back() == 0) {
62 mod_coeffs.pop_back();
77 const std::vector<int64_t>& f,
84 std::vector<int64_t> deriv;
85 deriv.reserve(f.size() - 1);
87 for (
size_t i = 1; i < f.size(); ++i) {
88 const auto index_residue =
static_cast<std::int64_t
>(
89 i %
static_cast<std::uint64_t
>(p));
90 int64_t coeff = (f[i] * index_residue) % p;
91 deriv.push_back(coeff);
94 while (!deriv.empty() && deriv.back() == 0) {