From 38efc7d2df030d37e3f20efbce71fadad1294cef Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 14 Jan 2025 21:32:09 +0100 Subject: Added BigInt --- zmodn.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'zmodn.h') diff --git a/zmodn.h b/zmodn.h index fdb1ee6..a24f293 100644 --- a/zmodn.h +++ b/zmodn.h @@ -7,16 +7,31 @@ #include #include -template -requires std::is_integral_v -std::tuple extended_gcd(INT a, INT b) { +template +concept Integer = requires(T a, T b, int i, std::ostream& os) { + {T(i)}; + + {a + b} -> std::same_as; + {a - b} -> std::same_as; + {a * b} -> std::same_as; + {a / b} -> std::same_as; + {a % b} -> std::same_as; + + {a == b} -> std::same_as; + {a != b} -> std::same_as; + + {os << a} -> std::same_as; +}; + +template +std::tuple extended_gcd(T a, T b) { if (b == 0) return {a, 1, 0}; auto [g, x, y] = extended_gcd(b, a%b); return {g, y, x - y*(a/b)}; } -template -requires(N > 1) && std::is_integral_v +template +requires(N > 1) class Zmod { public: Zmod(decltype(N) z) : value{(z%N + N) % N} {} -- cgit v1.2.3