Message408994
That computation of the shift can be simplified to require only one popcount operation. With F and Finv as before:
def comb_small(n, k):
assert 0 <= k <= n <= Nmax
return (F[n] * Finv[k] * Finv[n-k] % 2**64) << (k ^ n ^ (n-k)).bit_count() |
|
Date |
User |
Action |
Args |
2021-12-21 09:15:25 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, serhiy.storchaka, PedanticHacker, mcognetta, Stefan Pochmann, pablogsal |
2021-12-21 09:15:25 | mark.dickinson | set | messageid: <1640078125.64.0.95495357946.issue37295@roundup.psfhosted.org> |
2021-12-21 09:15:25 | mark.dickinson | link | issue37295 messages |
2021-12-21 09:15:25 | mark.dickinson | create | |
|