projects
/
nmigen-gf.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
373204b
)
intriguing small tidyup on gfpinv making it more symmetrical
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Tue, 5 Apr 2022 15:04:57 +0000
(16:04 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Tue, 5 Apr 2022 15:04:57 +0000
(16:04 +0100)
gf_reference/gfpinv.py
patch
|
blob
|
history
diff --git
a/gf_reference/gfpinv.py
b/gf_reference/gfpinv.py
index 45b6dbbdd4cb19bdbfa0538fb9dfcb79981655fe..ba1494e28977ce4b66290d040a0028d7ae1d2bf2 100644
(file)
--- a/
gf_reference/gfpinv.py
+++ b/
gf_reference/gfpinv.py
@@
-19,19
+19,17
@@
def gfpinv(a):
# implementations could use count-zeros on
# both u and r to save cycles
if u & 1 == 0:
+ if r & 1 != 0:
+ r += p
u >>= 1
- if r & 1 == 0:
- r >>= 1
- else:
- r = (r + p) >> 1
+ r >>= 1
# implementations could use count-zeros on
# both v and s to save cycles
elif v & 1 == 0:
+ if s & 1 != 0:
+ s += p
v >>= 1
- if s & 1 == 0:
- s >>= 1
- else:
- s = (s + p) >> 1
+ s >>= 1
else:
x = u - v
if x > 0: