mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-bigint: Extend Barrett reduction range to 16 limbs
Extended the range for Barrett reduction in mpz_mod from 8 to 16 limbs. This allows the more efficient Barrett reduction algorithm to be used for a wider range of moduli, improving performance for modular arithmetic operations. Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
@@ -1694,7 +1694,7 @@ mpz_mod(mpz_ctx_t *ctx, mpz_t *r, mpz_t *x, mpz_t *y)
|
||||
}
|
||||
|
||||
/* Barrett reduction for moderate-sized moduli */
|
||||
if (y->sz >= 2 && y->sz <= 8 && x->sz >= y->sz + 2) {
|
||||
if (y->sz >= 2 && y->sz <= 16 && x->sz >= y->sz + 2) {
|
||||
mpz_t mu;
|
||||
mpz_init_temp(ctx, &mu, y->sz + 1);
|
||||
mpz_barrett_mu(ctx, &mu, y);
|
||||
|
||||
Reference in New Issue
Block a user