From 7c40cd7bd4f5a42684c223c6b6289f392a4dec01 Mon Sep 17 00:00:00 2001 From: lkcl Date: Sat, 19 Mar 2022 06:49:11 +0000 Subject: [PATCH] --- gfpinv.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gfpinv.py b/gfpinv.py index e75773a..45b6dbb 100644 --- a/gfpinv.py +++ b/gfpinv.py @@ -16,12 +16,16 @@ def gfpinv(a): r = 0 s = 1 while v > 0: + # implementations could use count-zeros on + # both u and r to save cycles if u & 1 == 0: u >>= 1 if r & 1 == 0: r >>= 1 else: r = (r + p) >> 1 + # implementations could use count-zeros on + # both v and s to save cycles elif v & 1 == 0: v >>= 1 if s & 1 == 0: -- 2.30.2