@@ -17,7 +17,7 @@ from flint.types.fmpz_vec cimport fmpz_vec
1717from flint.types.fmpq_vec cimport fmpq_vec
1818
1919from 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
2222from flint.flintlib.functions.fmpq cimport fmpq_set, fmpq_one
2323from flint.flintlib.functions.fmpq_mpoly cimport (
@@ -785,6 +785,36 @@ 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+ >>> ctx = fmpq_mpoly_ctx.get(("x","y"))
795+ >>> x, y = ctx.gens()
796+ >>> (fmpq(2,3)*x + fmpq(2,5)*y).zpoly()
797+ 5*x + 3*y
798+ """
799+ cdef fmpz_mpoly_ctx zctx = fmpz_mpoly_ctx.from_context(self .ctx)
800+ cdef fmpz_mpoly res = create_fmpz_mpoly(zctx)
801+ fmpz_mpoly_set(res.val, self .val.zpoly, zctx.val)
802+ return res
803+
804+ def zcontent (self ):
805+ """
806+ Return the content of ``self``. The product of this and
807+ ``self.zpoly()``, represents the whole polynomial.
808+
809+ >>> ctx = fmpq_mpoly_ctx.get(("x","y"))
810+ >>> x, y = ctx.gens()
811+ >>> (fmpq(2,3)*x + fmpq(2,5)*y).zcontent()
812+ 2/15
813+ """
814+ cdef fmpq res = fmpq.__new__ (fmpq)
815+ fmpq_set(res.val, self .val.content)
816+ return res
817+
788818 def resultant (self , other , var ):
789819 """
790820 Return the resultant of ``self`` and ``other`` with respect to variable ``var``.
0 commit comments