mirror of
https://github.com/aicodix/code.git
synced 2026-04-28 09:43:11 +00:00
use much faster __builtin_clz
This commit is contained in:
parent
9f07a27eaf
commit
41fa2c7f40
1 changed files with 4 additions and 0 deletions
|
|
@ -398,10 +398,14 @@ GaloisFieldReference<M, POLY, TYPE> rcp(GaloisFieldReference<M, POLY, TYPE> a)
|
||||||
TYPE newr = a.P, r = a.v;
|
TYPE newr = a.P, r = a.v;
|
||||||
TYPE newt = 0, t = 1;
|
TYPE newt = 0, t = 1;
|
||||||
auto degree = [](TYPE a) {
|
auto degree = [](TYPE a) {
|
||||||
|
#if 1
|
||||||
|
return 31 - __builtin_clz(a);
|
||||||
|
#else
|
||||||
int d = 0;
|
int d = 0;
|
||||||
while (a >>= 1)
|
while (a >>= 1)
|
||||||
++d;
|
++d;
|
||||||
return d;
|
return d;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
int k = degree(r);
|
int k = degree(r);
|
||||||
int j = M - k;
|
int j = M - k;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue