From 03ac76c7d8b47958654d7d26ae316483bb4337eb Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sat, 15 Apr 2023 11:06:23 +0200 Subject: [PATCH] added reciprocal from index to index type --- galois_field.hh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/galois_field.hh b/galois_field.hh index f74c3db..1ab1f8b 100644 --- a/galois_field.hh +++ b/galois_field.hh @@ -188,12 +188,19 @@ Value operator * (Value a, Value b) return (!a.v || !b.v) ? a.zero() : value(index(a) * index(b)); } +template +Index rcp(Index a) +{ + assert(a.i < a.modulus()); + return Index(!a.i ? 0 : a.modulus() - a.i); +} + template Value rcp(Value a) { assert(a.v <= a.N); assert(a.v); - return value(Index(index(a).modulus() - index(a).i)); + return value(rcp(index(a))); } template