Skip to content

Conversation

@quaternic
Copy link
Contributor

@quaternic quaternic commented Aug 12, 2025

Builds on #1011, both were split from #1002

The computation is implemented in linear_mul_reduction.

@quaternic
Copy link
Contributor Author

I've now rebased and applied the previous feedback.

@tgross35

Could you add a module-level doc comment with some of the common names used here? E.g. R, RR (if that's not R*R) r, m, q, xq. I'm unfortunately a bit lost :) (but I don't need to understand it in detail)

To make the module easier to follow, I moved the public interface, fn linear_mul_reduction, to the start of the file and added more explanatory comments. That should be understandable on its own. The implementation is essentially unchanged from before, other than one minor tweak.

Comment on lines +54 to +57
// The partial remainder is in `[0, 2y)` ...
let r = m.partial_remainder();
// ... so check and correct, and compensate for the earlier shift.
r.checked_sub(y).unwrap_or(r) >> s
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That minor tweak:
Previously the right shift was done first, and then the checked_sub was with the original y. Now that's done first with the left-shifted y, and the shift is last.

@quaternic
Copy link
Contributor Author

I've gone through and rewritten the comments for the implementation of Reducer, which should actually be understandable now. (At least this time I didn't get too much of a headache from it.)

@rustbot

This comment has been minimized.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

The comments are super thorough and I was able to (to a reasonable level) understand what's going on, thank you for all the updates!

@tgross35 tgross35 merged commit e1d8a49 into rust-lang:main Dec 5, 2025
38 checks passed
@quaternic quaternic deleted the modular-reduction branch December 5, 2025 13:43
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.

3 participants