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

Arguments to fmpz_CRT and fmpz_CRT_ui #1549

Merged
merged 3 commits into from
Oct 21, 2023
Merged

Conversation

fagu
Copy link
Contributor

@fagu fagu commented Oct 21, 2023

  1. The documentation of fmpz_CRT requires that the arguments m1 and m2 are greater than 1. If you pass m2=1, it currently prints the confusing message Exception (fmpz_CRT). m1 not invertible modulo m2..
    I propose removing the requirement since it's not really used in the implementation anyways.
    I haven't added any serious test with m1=1 or m2=1. (As far as I see, only the case where m2 is prime is currently tested, really...)

  2. Maybe also make the parameters r2 and m2 const?

fmpz_invmod(c, c, m2);

if (fmpz_is_zero(c))
if (!fmpz_invmod(c, c, m2))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fmpz_invmod(f,g,h) returns 0 if g is not invertible modulo h. It doesn't necessarily set f=0.

@@ -61,12 +61,6 @@ void fmpz_CRT_ui(fmpz_t out, const fmpz_t r1, const fmpz_t m1,
c = fmpz_fdiv_ui(m1, m2);
c = n_invmod(c, m2);

if (c == 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

n_invmod(x,y) throws an exception if x is not invertible modulo y.

@fredrik-johansson
Copy link
Collaborator

This looks good.

@fredrik-johansson fredrik-johansson merged commit 84db7d0 into flintlib:trunk Oct 21, 2023
15 of 16 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.

2 participants