Skip to content

Commit ae31437

Browse files
committed
powmod to pow_mod
1 parent 9589530 commit ae31437

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/flint/test/test_all.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,17 +2095,17 @@ def test_fmpz_mod_poly():
20952095
assert f*f == f**2
20962096
assert f*f == f**fmpz(2)
20972097

2098-
# powmod
2098+
# pow_mod
20992099
# assert ui and fmpz exp agree for polynomials and generators
21002100
R_gen = R_test.gen()
21012101
assert pow(f, 2**60, g) == pow(pow(f, 2**30, g), 2**30, g)
21022102
assert pow(R_gen, 2**60, g) == pow(pow(R_gen, 2**30, g), 2**30, g)
21032103

2104-
# Check other typechecks for powmod
2104+
# Check other typechecks for pow_mod
21052105
assert raises(lambda: pow(f, -2, g), ValueError)
21062106
assert raises(lambda: pow(f, 1, "A"), TypeError)
21072107
assert raises(lambda: pow(f, "A", g), TypeError)
2108-
assert raises(lambda: f.powmod(2**32, g, mod_rev_inv="A"), TypeError)
2108+
assert raises(lambda: f.pow_mod(2**32, g, mod_rev_inv="A"), TypeError)
21092109

21102110
# Shifts
21112111
assert raises(lambda: R_test([1,2,3]).left_shift(-1), ValueError)
@@ -2162,9 +2162,9 @@ def test_fmpz_mod_poly():
21622162
assert raises(lambda: f.mulmod(f, "AAA"), TypeError)
21632163
assert raises(lambda: f.mulmod("AAA", g), TypeError)
21642164

2165-
# powmod
2166-
assert f.powmod(2, g) == (f*f) % g
2167-
assert raises(lambda: f.powmod(2, "AAA"), TypeError)
2165+
# pow_mod
2166+
assert f.pow_mod(2, g) == (f*f) % g
2167+
assert raises(lambda: f.pow_mod(2, "AAA"), TypeError)
21682168

21692169
# divmod
21702170
S, T = f.divmod(g)

src/flint/types/fmpz_mod_poly.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ cdef class fmpz_mod_poly(flint_poly):
536536

537537
def __pow__(self, e, mod=None):
538538
if mod is not None:
539-
return self.powmod(e, mod)
539+
return self.pow_mod(e, mod)
540540

541541
cdef fmpz_mod_poly res
542542
if e < 0:
@@ -1137,13 +1137,13 @@ cdef class fmpz_mod_poly(flint_poly):
11371137
)
11381138
return res
11391139

1140-
def powmod(self, e, modulus, mod_rev_inv=None):
1140+
def pow_mod(self, e, modulus, mod_rev_inv=None):
11411141
"""
11421142
Returns ``self`` raised to the power ``e`` modulo ``modulus``:
11431143
:math:`f^e \mod g`/
11441144
11451145
``mod_rev_inv`` is the inverse of the reverse of the modulus,
1146-
precomputing it and passing it to ``powmod()`` can optimise
1146+
precomputing it and passing it to ``pow_mod()`` can optimise
11471147
powering of polynomials with large exponents.
11481148
11491149
>>> R = fmpz_mod_poly_ctx(163)
@@ -1152,12 +1152,12 @@ cdef class fmpz_mod_poly(flint_poly):
11521152
>>> g = 43*x**6 + 91*x**5 + 77*x**4 + 113*x**3 + 71*x**2 + 132*x + 60
11531153
>>> mod = x**4 + 93*x**3 + 78*x**2 + 72*x + 149
11541154
>>>
1155-
>>> f.powmod(123, mod)
1155+
>>> f.pow_mod(123, mod)
11561156
3*x^3 + 25*x^2 + 115*x + 161
1157-
>>> f.powmod(2**64, mod)
1157+
>>> f.pow_mod(2**64, mod)
11581158
52*x^3 + 96*x^2 + 136*x + 9
11591159
>>> mod_rev_inv = mod.reverse().inverse_series_trunc(4)
1160-
>>> f.powmod(2**64, mod, mod_rev_inv)
1160+
>>> f.pow_mod(2**64, mod, mod_rev_inv)
11611161
52*x^3 + 96*x^2 + 136*x + 9
11621162
"""
11631163
cdef fmpz_mod_poly res

src/flint/types/nmod_poly.pyx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,34 +474,34 @@ cdef class nmod_poly(flint_poly):
474474
def __pow__(nmod_poly self, exp, mod=None):
475475
cdef nmod_poly res
476476
if mod is not None:
477-
return self.powmod(exp, mod)
477+
return self.pow_mod(exp, mod)
478478
if exp < 0:
479479
raise ValueError("negative exponent")
480480
res = nmod_poly.__new__(nmod_poly)
481481
nmod_poly_init_preinv(res.val, (<nmod_poly>self).val.mod.n, (<nmod_poly>self).val.mod.ninv)
482482
nmod_poly_pow(res.val, self.val, <ulong>exp)
483483
return res
484484

485-
def powmod(self, e, modulus, mod_rev_inv=None):
485+
def pow_mod(self, e, modulus, mod_rev_inv=None):
486486
"""
487487
Returns ``self`` raised to the power ``e`` modulo ``modulus``:
488488
:math:`f^e \mod g`/
489489
490490
``mod_rev_inv`` is the inverse of the reverse of the modulus,
491-
precomputing it and passing it to ``powmod()`` can optimise
491+
precomputing it and passing it to ``pow_mod()`` can optimise
492492
powering of polynomials with large exponents.
493493
494494
>>> x = nmod_poly([0,1], 163)
495495
>>> f = 30*x**6 + 104*x**5 + 76*x**4 + 33*x**3 + 70*x**2 + 44*x + 65
496496
>>> g = 43*x**6 + 91*x**5 + 77*x**4 + 113*x**3 + 71*x**2 + 132*x + 60
497497
>>> mod = x**4 + 93*x**3 + 78*x**2 + 72*x + 149
498498
>>>
499-
>>> f.powmod(123, mod)
499+
>>> f.pow_mod(123, mod)
500500
3*x^3 + 25*x^2 + 115*x + 161
501-
>>> f.powmod(2**64, mod)
501+
>>> f.pow_mod(2**64, mod)
502502
52*x^3 + 96*x^2 + 136*x + 9
503503
>>> mod_rev_inv = mod.reverse().inverse_series_trunc(4)
504-
>>> f.powmod(2**64, mod, mod_rev_inv)
504+
>>> f.pow_mod(2**64, mod, mod_rev_inv)
505505
52*x^3 + 96*x^2 + 136*x + 9
506506
"""
507507
cdef nmod_poly res

0 commit comments

Comments
 (0)