18template <
typename Params>
21 static constexpr auto P = Params::P;
22 static constexpr size_t N = Params::N;
23 typedef typename Params::W W;
25 constexpr static std::array<W, N> one() {
26 std::array<W, N> one = {};
31 constexpr static std::array<W, N> redc(
const std::array<W, 2 * N>& z) {
32 constexpr W TOP_MASK =
static_cast<W
>(0x1FF);
34 std::array<W, N> hi = {};
35 copy_mem(hi, std::span{z}.template subspan<N - 1, N>());
38 std::array<W, N> lo = {};
39 copy_mem(lo, std::span{z}.template first<N>());
40 lo[N - 1] &= TOP_MASK;
43 std::array<W, N> s = {};
48 std::array<W, N> r = {};
54 constexpr static std::array<W, N> to_rep(
const std::array<W, N>& x) {
return x; }
56 constexpr static std::array<W, N> wide_to_rep(
const std::array<W, 2 * N>& x) {
return redc(x); }
58 constexpr static std::array<W, N> from_rep(
const std::array<W, N>& z) {
return z; }
62 "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
63 "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC",
64 "51953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00",
65 "1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409",
66 "C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66",
67 "11839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650",
constexpr auto bigint_add(std::span< W, N > z, std::span< const W, N > x, std::span< const W, N > y) -> W