Skip to content

Commit 703e0dc

Browse files
author
Jake Moss
committed
Split _truediv_scalar_ into two functions
1 parent 5fc1d74 commit 703e0dc

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/flint/flint_base/flint_base.pxd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ cdef class flint_mpoly(flint_elem):
2323
cdef _mul_mpoly_(self, other)
2424

2525
cdef _divmod_mpoly_(self, other)
26-
cdef _truediv_scalar_(self, other, assume_exact: bool)
26+
cdef _truediv_scalar_(self, other)
27+
cdef _divexact_scalar_(self, other)
2728
cdef _floordiv_mpoly_(self, other)
2829
cdef _truediv_mpoly_(self, other)
2930
cdef _mod_mpoly_(self, other)

src/flint/flint_base/flint_base.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,10 @@ cdef class flint_mpoly(flint_elem):
449449
cdef _floordiv_mpoly_(self, other):
450450
return NotImplemented
451451

452-
cdef _truediv_scalar_(self, other, assume_exact: bool):
452+
cdef _truediv_scalar_(self, other):
453+
return NotImplemented
454+
455+
cdef _divexact_scalar_(self, other):
453456
return NotImplemented
454457

455458
cdef _truediv_mpoly_(self, other):
@@ -611,7 +614,7 @@ cdef class flint_mpoly(flint_elem):
611614
return NotImplemented
612615

613616
self._division_check(other)
614-
res = self._truediv_scalar_(other, False)
617+
res = self._truediv_scalar_(other)
615618
if res is not NotImplemented:
616619
return res
617620

src/flint/types/fmpq_mpoly.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,16 @@ cdef class fmpq_mpoly(flint_mpoly):
420420
fmpq_mpoly_div(quotient.val, self.val, other.val, self.ctx.val)
421421
return quotient
422422

423-
cdef _truediv_scalar_(self, arg, _: bool):
423+
cdef _truediv_scalar_(self, arg):
424424
cdef fmpq_mpoly quotient
425425
cdef fmpq other = <fmpq>arg
426426
quotient = create_fmpq_mpoly(self.ctx)
427427
fmpq_mpoly_scalar_div_fmpq(quotient.val, self.val, other.val, self.ctx.val)
428428
return quotient
429429

430+
cdef _divexact_scalar_(self, arg):
431+
return self._truediv_scalar_(arg)
432+
430433
cdef _truediv_mpoly_(self, arg):
431434
cdef fmpq_mpoly quotient, other = <fmpq_mpoly>arg
432435
quotient = create_fmpq_mpoly(self.ctx)

src/flint/types/fmpz_mpoly.pyx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,19 +405,22 @@ cdef class fmpz_mpoly(flint_mpoly):
405405
fmpz_mpoly_div(quotient.val, self.val, other.val, self.ctx.val)
406406
return quotient
407407

408-
cdef _truediv_scalar_(self, arg, assume_exact: bool):
408+
cdef _truediv_scalar_(self, arg):
409409
cdef fmpz_mpoly quotient,
410410
cdef fmpz other = <fmpz>arg
411411
quotient = create_fmpz_mpoly(self.ctx)
412-
if assume_exact:
413-
fmpz_mpoly_scalar_divexact_fmpz(quotient.val, self.val, other.val, self.ctx.val)
414-
return quotient
415-
416412
if fmpz_mpoly_scalar_divides_fmpz(quotient.val, self.val, other.val, self.ctx.val):
417413
return quotient
418414
else:
419415
raise DomainError("fmpz_mpoly division is not exact")
420416

417+
cdef _divexact_scalar_(self, arg):
418+
cdef fmpz_mpoly quotient,
419+
cdef fmpz other = <fmpz>arg
420+
quotient = create_fmpz_mpoly(self.ctx)
421+
fmpz_mpoly_scalar_divexact_fmpz(quotient.val, self.val, other.val, self.ctx.val)
422+
return quotient
423+
421424
cdef _truediv_mpoly_(self, arg):
422425
cdef fmpz_mpoly quotient, other = <fmpz_mpoly>arg
423426
quotient = create_fmpz_mpoly(self.ctx)
@@ -865,7 +868,7 @@ cdef class fmpz_mpoly(flint_mpoly):
865868
(2, x0*x1 + 2*x0)
866869
"""
867870
cdef fmpz content = self.content()
868-
return content, self._truediv_scalar_(content, True)
871+
return content, self._divexact_scalar_(content)
869872

870873
def sqrt(self, assume_perfect_square: bool = False):
871874
"""

0 commit comments

Comments
 (0)