Nemocas / Nemo.jl

Julia bindings for various mathematical libraries (including flint2)
http://nemocas.github.io/Nemo.jl/
Other
187 stars 58 forks source link

Wrap fmpq_reconstruct_fmpz_2.. #1760

Closed sumiya11 closed 4 months ago

sumiya11 commented 4 months ago

..because it can be faster when the bound is precomputed.

using Nemo, BenchmarkTools, Primes
m = ZZRingElem(prod(nextprimes(BigInt(2)^30, 1_000)));
n, d = ZZRingElem(1), ZZRingElem(100)
N = D = isqrt((m >> 1) - 1);
a = mod(n * invmod(d, m), m);

@btime reconstruct($a,$m)
#  17.160 μs (17 allocations: 29.23 KiB)

@btime reconstruct2($a,$m,$N,$N)
#  4.656 μs (15 allocations: 25.58 KiB)

BTW, perhaps Nemo.reconstruct can be changed to do the same as Nemo.unsafe_reconstruct (and Nemo.unsafe_reconstruct be removed).

thofma commented 4 months ago

Can you rename it to reconstruct? The method names are not translated 1:1 from flint and it it just another method for reconstruct. Once renamed, I'll merge and tag a new release.

sumiya11 commented 4 months ago

Sure; done; thanks.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.59%. Comparing base (b04719f) to head (bb189c0). Report is 4 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1760 +/- ## ========================================== + Coverage 85.48% 85.59% +0.11% ========================================== Files 95 95 Lines 36923 36921 -2 ========================================== + Hits 31565 31604 +39 + Misses 5358 5317 -41 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.