mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
degree of poly is always larger than of the element
This commit is contained in:
parent
9570346a59
commit
595cf80cc5
1 changed files with 7 additions and 2 deletions
|
|
@ -393,14 +393,19 @@ GaloisFieldReference<M, POLY, TYPE> rcp(GaloisFieldReference<M, POLY, TYPE> a)
|
|||
{
|
||||
assert(a.v);
|
||||
#if 1
|
||||
uint32_t r = POLY, newr = a.v;
|
||||
uint32_t t = 0, newt = 1;
|
||||
if (a.v == 1)
|
||||
return a;
|
||||
uint32_t newr = POLY, r = a.v;
|
||||
uint32_t newt = 0, t = 1;
|
||||
auto degree = [](uint32_t a) {
|
||||
int d = 0;
|
||||
while (a >>= 1)
|
||||
++d;
|
||||
return d;
|
||||
};
|
||||
int j = M - degree(r);
|
||||
newr ^= r << j;
|
||||
newt ^= t << j;
|
||||
while (newr != 1) {
|
||||
int j = degree(newr) - degree(r);
|
||||
if (j < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue