@@ -397,6 +397,60 @@ cdef class fmpz_poly(flint_poly):
397397 fmpz_poly_gcd(res.val, self .val, (< fmpz_poly> other).val)
398398 return res
399399
400+ def resultant (self , other ):
401+ """
402+ Returns the resultant of *self* and *other*.
403+
404+ >>> A = fmpz_poly([1, 0, -1]); B = fmpz_poly([1, -1])
405+ >>> A.resultant(B)
406+ 0
407+ >>> C = fmpz_poly([1, 0, 0, 0, 0, -1, 1])
408+ >>> D = fmpz_poly([1, 0, 0, -1, 0, 0, 1])
409+ >>> C.resultant(D)
410+ 3
411+ >>> f = fmpz_poly([1, -1] + [0] * 98 + [1])
412+ >>> g = fmpz_poly([1] + [0] * 50 + [-1] + [0] * 48 + [1])
413+ >>> f.resultant(g)
414+ 1125899906842623
415+
416+ """
417+ cdef fmpz res
418+ other = any_as_fmpz_poly(other)
419+ if other is NotImplemented :
420+ raise TypeError (" cannot convert input to fmpz_poly" )
421+
422+ res = fmpz.__new__ (fmpz)
423+ fmpz_poly_resultant(res.val, self .val, (< fmpz_poly> other).val)
424+ return res
425+
426+ def resultant_modular (self , other ):
427+ """
428+ Returns the resultant of *self* and *other* using Collins' 1971 modular
429+ algorithm.
430+
431+ >>> A = fmpz_poly([1, 0, -1]); B = fmpz_poly([1, -1])
432+ >>> A.resultant_modular(B)
433+ 0
434+ >>> C = fmpz_poly([1, 0, 0, 0, 0, -1, 1])
435+ >>> D = fmpz_poly([1, 0, 0, -1, 0, 0, 1])
436+ >>> C.resultant_modular(D)
437+ 3
438+ >>> f = fmpz_poly([1, -1] + [0] * 98 + [1])
439+ >>> g = fmpz_poly([1] + [0] * 50 + [-1] + [0] * 48 + [1])
440+ >>> f.resultant_modular(g)
441+ 1125899906842623
442+
443+ """
444+ cdef fmpz res
445+ other = any_as_fmpz_poly(other)
446+ if other is NotImplemented :
447+ raise TypeError (" cannot convert input to fmpz_poly" )
448+
449+ res = fmpz.__new__ (fmpz)
450+ fmpz_poly_resultant_modular(res.val, self .val, (< fmpz_poly> other).val)
451+ return res
452+
453+
400454 def factor (self ):
401455 """
402456 Factors self into irreducible factors, returning a tuple
0 commit comments