Skip to content

Commit 13d99ae

Browse files
committed
Add fmpq_mpoly.zpoly and fmpq_mpoly.zcontent
1 parent 36c5f92 commit 13d99ae

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/flint/types/fmpq_mpoly.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ class fmpq_mpoly(flint_mpoly[fmpq_mpoly_ctx, fmpq, ifmpq]):
102102
def xgcd(self, other: fmpq_mpoly, /) -> fmpq: ...
103103
def term_content(self) -> fmpq_mpoly: ...
104104

105+
def zpoly(self) -> fmpz_mpoly: ...
106+
def zcontent(self) -> fmpq: ...
107+
105108
def factor(self) -> tuple[fmpq, list[tuple[fmpq_mpoly, int]]]: ...
106109
def factor_squarefree(self) -> tuple[fmpq, list[tuple[fmpq_mpoly, int]]]: ...
107110

src/flint/types/fmpq_mpoly.pyx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ from flint.types.fmpz_vec cimport fmpz_vec
1717
from flint.types.fmpq_vec cimport fmpq_vec
1818

1919
from flint.types.fmpz cimport fmpz, any_as_fmpz
20-
from flint.types.fmpz_mpoly cimport fmpz_mpoly
20+
from flint.types.fmpz_mpoly cimport fmpz_mpoly, fmpz_mpoly_ctx, create_fmpz_mpoly
2121

2222
from flint.flintlib.functions.fmpq cimport fmpq_set, fmpq_one
2323
from flint.flintlib.functions.fmpq_mpoly cimport (
@@ -785,6 +785,26 @@ cdef class fmpq_mpoly(flint_mpoly):
785785
fmpq_mpoly_term_content(res.val, self.val, self.ctx.val)
786786
return res
787787

788+
def zpoly(self):
789+
"""
790+
Return the integer polynomial of ``self``. The product
791+
of this and ``self.zcontent()``, represents the whole
792+
polynomial.
793+
"""
794+
cdef fmpz_mpoly_ctx zctx = fmpz_mpoly_ctx.from_context(self.ctx)
795+
cdef fmpz_mpoly res = create_fmpz_mpoly(zctx)
796+
fmpz_mpoly_set(res.val, self.val.zpoly, zctx.val)
797+
return res
798+
799+
def zcontent(self):
800+
"""
801+
Return the content of ``self``. The product of this and
802+
``self.zpoly()``, represents the whole polynomial.
803+
"""
804+
cdef fmpq res = fmpq.__new__(fmpq)
805+
fmpq_set(res.val, self.val.content)
806+
return res
807+
788808
def resultant(self, other, var):
789809
"""
790810
Return the resultant of ``self`` and ``other`` with respect to variable ``var``.

0 commit comments

Comments
 (0)