Skip to content

Commit 5445684

Browse files
Merge pull request #185 from GiacomoPope/double_name
Remove doubled `mul_mod` functions from `fmpz_mod_poly`
2 parents f5b07e9 + 6f9ee53 commit 5445684

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

src/flint/test/test_all.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -2158,9 +2158,9 @@ def test_fmpz_mod_poly():
21582158
assert f*f == f**2 == f.square()
21592159

21602160
# mulmod
2161-
assert f.mulmod(f, g) == (f*f) % g
2162-
assert raises(lambda: f.mulmod(f, "AAA"), TypeError)
2163-
assert raises(lambda: f.mulmod("AAA", g), TypeError)
2161+
assert f.mul_mod(f, g) == (f*f) % g
2162+
assert raises(lambda: f.mul_mod(f, "AAA"), TypeError)
2163+
assert raises(lambda: f.mul_mod("AAA", g), TypeError)
21642164

21652165
# pow_mod
21662166
assert f.pow_mod(2, g) == (f*f) % g
@@ -2272,10 +2272,6 @@ def test_fmpz_mod_poly():
22722272
assert raises(lambda: f.mul_low(g, "A"), TypeError)
22732273
assert f.mul_low(g, 3) == (f * g) % x**3
22742274

2275-
assert raises(lambda: f.mul_mod(f_cmp, h), ValueError)
2276-
assert raises(lambda: f.mul_mod(g, f_cmp), ValueError)
2277-
assert f.mul_mod(g, h) == (f * g) % h
2278-
22792275
assert raises(lambda: f.pow_trunc(-1, 5), ValueError)
22802276

22812277

src/flint/types/fmpz_mod_poly.pyx

+3-35
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ cdef class fmpz_mod_poly(flint_poly):
11061106
)
11071107
return res
11081108

1109-
def mulmod(self, other, modulus):
1109+
def mul_mod(self, other, modulus):
11101110
"""
11111111
Computes the multiplication of ``self`` with ``other``
11121112
modulo the polynomial ``modulus``
@@ -1117,7 +1117,7 @@ cdef class fmpz_mod_poly(flint_poly):
11171117
>>> g = 43*x**6 + 91*x**5 + 77*x**4 + 113*x**3 + 71*x**2 + 132*x + 60
11181118
>>> mod = x**4 + 93*x**3 + 78*x**2 + 72*x + 149
11191119
>>>
1120-
>>> f.mulmod(g, mod)
1120+
>>> f.mul_mod(g, mod)
11211121
106*x^3 + 44*x^2 + 53*x + 77
11221122
"""
11231123
cdef fmpz_mod_poly res
@@ -1504,7 +1504,7 @@ cdef class fmpz_mod_poly(flint_poly):
15041504
>>> h = f.sqrt_trunc(5)
15051505
>>> h
15061506
82*x^4 + 162*x^3 + x^2 + x + 1
1507-
>>> h.mulmod(h, x**5) == f
1507+
>>> h.mul_mod(h, x**5) == f
15081508
True
15091509
15101510
"""
@@ -1647,38 +1647,6 @@ cdef class fmpz_mod_poly(flint_poly):
16471647
)
16481648
return res
16491649

1650-
def mul_mod(self, other, modulus):
1651-
r"""
1652-
Returns remainder of the product of ``self`` with ``other`` after reduction by ``modulus``
1653-
1654-
Equivalent to computing `f(x) \cdot g(x) \mod x^n`
1655-
1656-
>>> R = fmpz_mod_poly_ctx(163)
1657-
>>> f = R([2,3,5,7,11])
1658-
>>> g = R([1,2,4,8,16])
1659-
>>> h = R([1,0,1])
1660-
>>> f.mul_mod(g, h) == (f * g) % h
1661-
True
1662-
>>> f.mul_mod(g, h)
1663-
63*x + 80
1664-
"""
1665-
# Only allow multiplication and reduction with other fmpz_mod_poly
1666-
if not typecheck(other, fmpz_mod_poly) or not typecheck(modulus, fmpz_mod_poly):
1667-
raise TypeError("input polynomials must be of type fmpz_mod_poly")
1668-
1669-
# Ensure the contexts match
1670-
other_c = <fmpz_mod_poly>other
1671-
modulus_c = <fmpz_mod_poly>modulus
1672-
if (self.ctx != other_c.ctx) or (self.ctx != modulus_c.ctx):
1673-
raise ValueError("other polynomial's context does not match")
1674-
1675-
cdef fmpz_mod_poly res
1676-
res = self.ctx.new_ctype_poly()
1677-
fmpz_mod_poly_mulmod(
1678-
res.val, self.val, other_c.val, modulus_c.val, res.ctx.mod.val
1679-
)
1680-
return res
1681-
16821650
def pow_trunc(self, slong e, slong n):
16831651
"""
16841652
Returns ``self`` raised to the power ``e`` modulo `x^n`:

0 commit comments

Comments
 (0)