Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap fmpq_reconstruct_fmpz_2.. #1760

Merged
merged 2 commits into from
Jun 3, 2024
Merged

Wrap fmpq_reconstruct_fmpz_2.. #1760

merged 2 commits into from
Jun 3, 2024

Conversation

sumiya11
Copy link
Contributor

..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).


Returns a tuple (`success`, `n/d`), where `success` signals the success of reconstruction.
"""
function reconstruct2(a::ZZRingElem, m::ZZRingElem, N::ZZRingElem, D::ZZRingElem)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why reconstruct2 and not reconstruct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason other than the name of the wrapped function, fmpq_reconstruct_fmpz_2

@thofma
Copy link
Member

thofma commented May 31, 2024

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
Copy link
Contributor Author

sumiya11 commented Jun 3, 2024

Sure; done; thanks.

Copy link

codecov bot commented Jun 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thofma thofma merged commit 1cca47a into Nemocas:master Jun 3, 2024
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants