@@ -2835,31 +2835,13 @@ def setbad(obj, i, val):
2835
2835
assert raises (lambda : p .integral (), NotImplementedError )
2836
2836
2837
2837
# resultant checks.
2838
-
2839
- if is_field and characteristic == 0 :
2840
- # Check that the resultant of two cyclotomic polynomials is right.
2841
- # See Dresden's 2012 "Resultants of Cyclotomic Polynomials"
2842
- for m in range (1 , 50 ):
2843
- for n in range (m + 1 , 50 ):
2844
- a = flint .fmpz_poly .cyclotomic (m )
2845
- b = flint .fmpz_poly .cyclotomic (n )
2846
- q , r = divmod (flint .fmpz (n ), flint .fmpz (m ))
2847
- fs = q .factor ()
2848
- if r != 0 or len (fs ) > 1 :
2849
- assert a .resultant (b ) == 1
2850
- else :
2851
- prime = fs [0 ][0 ]
2852
- tot = flint .fmpz (m ).euler_phi ()
2853
- assert a .resultant (b ) == prime ** tot
2854
-
2855
2838
x = P ([0 , 1 ])
2856
2839
2857
- if composite_characteristic and type (x ) == flint .fmpz_mod_poly :
2858
- # Flint crashes in this case, even though the resultant could be
2859
- # computed.
2840
+ if composite_characteristic and type (x ) in [ flint .fmpz_mod_poly , flint . nmod_poly ] :
2841
+ # Flint sometimes crashes in this case, even though the resultant
2842
+ # could be computed.
2860
2843
divisor = characteristic .factor ()[0 ][0 ]
2861
- if type (x ) == flint .fmpz_mod_poly :
2862
- assert raises (lambda : x .resultant (x + divisor ), ValueError )
2844
+ assert raises (lambda : x .resultant (x + divisor ), ValueError )
2863
2845
elif type (x ) == flint .fq_default_poly :
2864
2846
# Flint does not implement resultants over GF(q) for nonprime q, so
2865
2847
# there's nothing for us to check.
@@ -2873,6 +2855,22 @@ def setbad(obj, i, val):
2873
2855
for k in range (- 10 , 10 ):
2874
2856
assert x .resultant (x + S (k )) == S (k )
2875
2857
2858
+ def test_poly_resultants ():
2859
+ # Check that the resultant of two cyclotomic polynomials is right.
2860
+ # See Dresden's 2012 "Resultants of Cyclotomic Polynomials"
2861
+ for m in range (1 , 50 ):
2862
+ for n in range (m + 1 , 50 ):
2863
+ a = flint .fmpz_poly .cyclotomic (m )
2864
+ b = flint .fmpz_poly .cyclotomic (n )
2865
+ q , r = divmod (flint .fmpz (n ), flint .fmpz (m ))
2866
+ fs = q .factor ()
2867
+ if r != 0 or len (fs ) > 1 :
2868
+ assert a .resultant (b ) == 1
2869
+ else :
2870
+ prime = fs [0 ][0 ]
2871
+ tot = flint .fmpz (m ).euler_phi ()
2872
+ assert a .resultant (b ) == prime ** tot
2873
+
2876
2874
def _all_mpolys ():
2877
2875
return [
2878
2876
(flint .fmpz_mpoly , flint .fmpz_mpoly_ctx .get , flint .fmpz , False , flint .fmpz (0 )),
@@ -4869,6 +4867,8 @@ def test_all_tests():
4869
4867
test_polys ,
4870
4868
test_mpolys ,
4871
4869
4870
+ test_poly_resultants ,
4871
+
4872
4872
test_fmpz_mpoly_vec ,
4873
4873
4874
4874
test_matrices_eq ,
0 commit comments