passagemath-flint 10.5.42__cp311-cp311-macosx_14_0_arm64.whl → 10.6.1rc1__cp311-cp311-macosx_14_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. {passagemath_flint-10.5.42.dist-info → passagemath_flint-10.6.1rc1.dist-info}/METADATA +5 -6
  2. {passagemath_flint-10.5.42.dist-info → passagemath_flint-10.6.1rc1.dist-info}/RECORD +106 -106
  3. passagemath_flint.dylibs/{libflint.19.0.dylib → libflint.20.0.dylib} +0 -0
  4. passagemath_flint.dylibs/libgcc_s.1.1.dylib +0 -0
  5. passagemath_flint.dylibs/libgf2x.3.dylib +0 -0
  6. passagemath_flint.dylibs/libgfortran.5.dylib +0 -0
  7. passagemath_flint.dylibs/libmpfi.0.dylib +0 -0
  8. passagemath_flint.dylibs/libopenblas_armv8p-r0.3.29.dylib +0 -0
  9. passagemath_flint.dylibs/libquadmath.0.dylib +0 -0
  10. sage/combinat/posets/hasse_cython_flint.cpython-311-darwin.so +0 -0
  11. sage/data_structures/bounded_integer_sequences.cpython-311-darwin.so +0 -0
  12. sage/data_structures/bounded_integer_sequences.pyx +22 -20
  13. sage/graphs/chrompoly.cpython-311-darwin.so +0 -0
  14. sage/graphs/chrompoly.pyx +4 -3
  15. sage/graphs/matchpoly.cpython-311-darwin.so +0 -0
  16. sage/libs/arb/arith.cpython-311-darwin.so +0 -0
  17. sage/libs/flint/arith.cpython-311-darwin.so +0 -0
  18. sage/libs/flint/arith_sage.cpython-311-darwin.so +0 -0
  19. sage/libs/flint/flint.pxd +2 -2
  20. sage/libs/flint/flint_sage.cpython-311-darwin.so +0 -0
  21. sage/libs/flint/flint_wrap.h +4 -0
  22. sage/libs/flint/fmpq_poly_sage.cpython-311-darwin.so +0 -0
  23. sage/libs/flint/fmpz_factor_sage.cpython-311-darwin.so +0 -0
  24. sage/libs/flint/fmpz_poly.cpython-311-darwin.so +0 -0
  25. sage/libs/flint/fmpz_poly_sage.cpython-311-darwin.so +0 -0
  26. sage/libs/flint/nmod_poly_linkage.pxi +5 -4
  27. sage/libs/flint/qsieve.cpython-311-darwin.so +0 -0
  28. sage/libs/flint/qsieve_sage.cpython-311-darwin.so +0 -0
  29. sage/libs/flint/types.pxd +2 -2
  30. sage/libs/flint/ulong_extras.cpython-311-darwin.so +0 -0
  31. sage/libs/flint/ulong_extras_sage.cpython-311-darwin.so +0 -0
  32. sage/matrix/change_ring.cpython-311-darwin.so +0 -0
  33. sage/matrix/matrix_complex_ball_dense.cpython-311-darwin.so +0 -0
  34. sage/matrix/matrix_cyclo_dense.cpython-311-darwin.so +0 -0
  35. sage/matrix/matrix_cyclo_dense.pyx +3 -3
  36. sage/matrix/matrix_integer_dense.cpython-311-darwin.so +0 -0
  37. sage/matrix/matrix_integer_dense.pyx +50 -33
  38. sage/matrix/matrix_integer_sparse.cpython-311-darwin.so +0 -0
  39. sage/matrix/matrix_integer_sparse.pyx +1 -1
  40. sage/matrix/matrix_rational_dense.cpython-311-darwin.so +0 -0
  41. sage/matrix/matrix_rational_dense.pyx +64 -28
  42. sage/matrix/matrix_rational_sparse.cpython-311-darwin.so +0 -0
  43. sage/matrix/matrix_rational_sparse.pyx +3 -3
  44. sage/matrix/misc_flint.cpython-311-darwin.so +0 -0
  45. sage/modular/modform/eis_series_cython.cpython-311-darwin.so +0 -0
  46. sage/modular/modsym/apply.cpython-311-darwin.so +0 -0
  47. sage/modular/modsym/heilbronn.cpython-311-darwin.so +0 -0
  48. sage/modular/pollack_stevens/dist.cpython-311-darwin.so +0 -0
  49. sage/modular/pollack_stevens/dist.pyx +2 -2
  50. sage/quivers/algebra.py +2 -1
  51. sage/quivers/algebra_elements.cpython-311-darwin.so +0 -0
  52. sage/quivers/algebra_elements.pyx +5 -5
  53. sage/quivers/ar_quiver.py +21 -21
  54. sage/quivers/homspace.py +2 -1
  55. sage/quivers/morphism.py +31 -29
  56. sage/quivers/path_semigroup.py +14 -11
  57. sage/quivers/paths.cpython-311-darwin.so +0 -0
  58. sage/quivers/paths.pyx +2 -2
  59. sage/quivers/representation.py +22 -24
  60. sage/rings/complex_arb.cpython-311-darwin.so +0 -0
  61. sage/rings/complex_arb.pyx +37 -36
  62. sage/rings/complex_interval.cpython-311-darwin.so +0 -0
  63. sage/rings/convert/mpfi.cpython-311-darwin.so +0 -0
  64. sage/rings/factorint_flint.cpython-311-darwin.so +0 -0
  65. sage/rings/fraction_field_FpT.cpython-311-darwin.so +0 -0
  66. sage/rings/fraction_field_FpT.pyx +29 -0
  67. sage/rings/number_field/S_unit_solver.py +1 -1
  68. sage/rings/number_field/galois_group.py +1 -1
  69. sage/rings/number_field/morphism.py +3 -4
  70. sage/rings/number_field/number_field.py +98 -76
  71. sage/rings/number_field/number_field_element.cpython-311-darwin.so +0 -0
  72. sage/rings/number_field/number_field_element.pyx +72 -0
  73. sage/rings/number_field/number_field_element_quadratic.cpython-311-darwin.so +0 -0
  74. sage/rings/number_field/number_field_element_quadratic.pyx +35 -17
  75. sage/rings/number_field/number_field_morphisms.cpython-311-darwin.so +0 -0
  76. sage/rings/number_field/number_field_morphisms.pyx +2 -2
  77. sage/rings/number_field/number_field_rel.py +1 -1
  78. sage/rings/number_field/order.py +44 -47
  79. sage/rings/number_field/order_ideal.py +2 -5
  80. sage/rings/polynomial/evaluation_flint.cpython-311-darwin.so +0 -0
  81. sage/rings/polynomial/hilbert.cpython-311-darwin.so +0 -0
  82. sage/rings/polynomial/hilbert.pyx +3 -6
  83. sage/rings/polynomial/polynomial_complex_arb.cpython-311-darwin.so +0 -0
  84. sage/rings/polynomial/polynomial_integer_dense_flint.cpython-311-darwin.so +0 -0
  85. sage/rings/polynomial/polynomial_integer_dense_flint.pyx +3 -5
  86. sage/rings/polynomial/polynomial_number_field.cpython-311-darwin.so +0 -0
  87. sage/rings/polynomial/polynomial_rational_flint.cpython-311-darwin.so +0 -0
  88. sage/rings/polynomial/polynomial_rational_flint.pxd +3 -3
  89. sage/rings/polynomial/polynomial_rational_flint.pyx +24 -11
  90. sage/rings/polynomial/polynomial_zmod_flint.cpython-311-darwin.so +0 -0
  91. sage/rings/polynomial/polynomial_zmod_flint.pyx +3 -4
  92. sage/rings/polynomial/real_roots.cpython-311-darwin.so +0 -0
  93. sage/rings/polynomial/real_roots.pyx +1 -1
  94. sage/rings/polynomial/refine_root.cpython-311-darwin.so +0 -0
  95. sage/rings/polynomial/weil/weil_polynomials.cpython-311-darwin.so +0 -0
  96. sage/rings/polynomial/weil/weil_polynomials.pyx +1 -1
  97. sage/rings/qqbar.py +1 -1
  98. sage/rings/real_arb.cpython-311-darwin.so +0 -0
  99. sage/rings/real_arb.pyx +21 -10
  100. sage/rings/real_interval_absolute.cpython-311-darwin.so +0 -0
  101. sage/rings/real_mpfi.cpython-311-darwin.so +0 -0
  102. sage/rings/real_mpfi.pyx +14 -11
  103. sage/schemes/elliptic_curves/descent_two_isogeny.cpython-311-darwin.so +0 -0
  104. sage/schemes/elliptic_curves/descent_two_isogeny.pyx +11 -0
  105. {passagemath_flint-10.5.42.dist-info → passagemath_flint-10.6.1rc1.dist-info}/WHEEL +0 -0
  106. {passagemath_flint-10.5.42.dist-info → passagemath_flint-10.6.1rc1.dist-info}/top_level.txt +0 -0
@@ -889,6 +889,43 @@ cdef class NumberFieldElement(NumberFieldElement_base):
889
889
 
890
890
  EXAMPLES::
891
891
 
892
+ sage: x = polygen(ZZ, 'x')
893
+ sage: K.<a> = NumberField(x^3 - 2)
894
+ sage: a._random_element() # random
895
+ -1/2*a^2 - 4
896
+ sage: K.<a> = NumberField(x^2 - 5)
897
+ sage: a._random_element() # random
898
+ -1/48*a - 1/2
899
+
900
+ With denominator bound one, we always get integral elements::
901
+
902
+ sage: K = QuadraticField(2)
903
+ sage: uu = [K.random_element(den_bound=1) for _ in range(5)]
904
+ sage: uu # random
905
+ [0, a + 2, -12*a - 2, -a + 1, -a - 2]
906
+ sage: all(u.is_integral() for u in uu)
907
+ True
908
+
909
+ Without this constraint, we do not always get them::
910
+
911
+ sage: K = QuadraticField(2)
912
+ sage: uu = [K.random_element() for _ in range(100)]
913
+ sage: all(u.is_integral() for u in uu)
914
+ False
915
+
916
+ Random integral elements can also be picked using the random_element
917
+ method of the number field's "ring of integers" or "maximal order" ::
918
+
919
+ sage: K = QuadraticField(2)
920
+ sage: O = K.maximal_order()
921
+ sage: O.random_element() # random
922
+ 5*a - 6
923
+ sage: O = K.ring_of_integers()
924
+ sage: O.random_element() # random
925
+ -4*a + 1
926
+
927
+ TESTS::
928
+
892
929
  sage: x = polygen(ZZ, 'x')
893
930
  sage: K.<a> = NumberField(x^3 - 2)
894
931
  sage: a._random_element().parent() is K
@@ -5311,6 +5348,23 @@ cdef class OrderElement_absolute(NumberFieldElement_absolute):
5311
5348
  """
5312
5349
  return self._parent.number_field()(NumberFieldElement_absolute.__invert__(self))
5313
5350
 
5351
+ def canonical_associate(self):
5352
+ """
5353
+ Return a canonical associate.
5354
+
5355
+ Only implemented here because order elements inherit from field elements,
5356
+ but the canonical associate implemented there does not apply here.
5357
+
5358
+ EXAMPLES::
5359
+
5360
+ sage: x = polygen(ZZ, 'x')
5361
+ sage: K = NumberField(x^3 - x + 2, 'a')
5362
+ sage: OK = K.ring_of_integers()
5363
+ sage: (OK.1).canonical_associate()
5364
+ NotImplemented
5365
+ """
5366
+ return NotImplemented
5367
+
5314
5368
 
5315
5369
  cdef class OrderElement_relative(NumberFieldElement_relative):
5316
5370
  """
@@ -5524,6 +5578,24 @@ cdef class OrderElement_relative(NumberFieldElement_relative):
5524
5578
  R = ZZ[var]
5525
5579
  return R(K(self).absolute_minpoly(var))
5526
5580
 
5581
+ def canonical_associate(self):
5582
+ """
5583
+ Return a canonical associate.
5584
+
5585
+ Only implemented here because order elements inherit from
5586
+ field elements, but the canonical associate implemented there
5587
+ does not apply here.
5588
+
5589
+ EXAMPLES::
5590
+
5591
+ sage: x = ZZ['x'].0
5592
+ sage: K.<a,b> = NumberField([x^2 + 1, x^2 - 3])
5593
+ sage: OK = K.maximal_order()
5594
+ sage: (OK.1).canonical_associate()
5595
+ NotImplemented
5596
+ """
5597
+ return NotImplemented
5598
+
5527
5599
 
5528
5600
  class CoordinateFunction():
5529
5601
  r"""
@@ -420,7 +420,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
420
420
  """
421
421
  Used for pickling.
422
422
 
423
- TESTS:
423
+ TESTS::
424
424
 
425
425
  sage: x = polygen(ZZ, 'x')
426
426
  sage: K.<a> = NumberField(x^2 - 13)
@@ -438,6 +438,23 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
438
438
  return __make_NumberFieldElement_quadratic1, (self._parent, type(self), a, b, denom)
439
439
 
440
440
  cdef int _randomize(self, num_bound, den_bound, distribution) except -1:
441
+ """
442
+ TESTS::
443
+
444
+ sage: a = ZZ.random_element(-100, 100)
445
+ sage: while a.is_square():
446
+ ....: a = ZZ.random_element(-100, 100)
447
+ sage: K = QuadraticField(a)
448
+ sage: K.random_element().parent() is K # indirect doctest
449
+ True
450
+ sage: len(set(K.random_element() for _ in range(100))) >= 40
451
+ True
452
+
453
+ Verify that :issue:`30017` is fixed::
454
+
455
+ sage: all(K.random_element().is_integral() for s in range(100))
456
+ False
457
+ """
441
458
  cdef Integer temp, denom1, denom2
442
459
 
443
460
  # in theory, we could just generate two random numerators and
@@ -448,17 +465,20 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
448
465
  # of the random element code, it's worth doing slightly more
449
466
  # work to make this possible.
450
467
 
451
- # normalize denominator bound
452
- if den_bound is None or den_bound < 1:
453
- den_bound = 1
454
-
455
468
  # generate denominators
456
- denom1 = <Integer>(ZZ.random_element(x=1,
457
- y=den_bound+1,
458
- distribution=distribution))
459
- denom2 = <Integer>(ZZ.random_element(x=1,
460
- y=den_bound+1,
461
- distribution=distribution))
469
+ if den_bound is None:
470
+ denom1 = <Integer>(1 + abs(ZZ.random_element(distribution=distribution)))
471
+ denom2 = <Integer>(1 + abs(ZZ.random_element(distribution=distribution)))
472
+ else:
473
+ # normalize denominator bound
474
+ if den_bound < 1:
475
+ den_bound = 1
476
+ denom1 = <Integer>(ZZ.random_element(x=1,
477
+ y=den_bound+1,
478
+ distribution=distribution))
479
+ denom2 = <Integer>(ZZ.random_element(x=1,
480
+ y=den_bound+1,
481
+ distribution=distribution))
462
482
 
463
483
  # set a, b
464
484
  temp = <Integer>(ZZ.random_element(x=num_bound, distribution=distribution))
@@ -2383,8 +2403,6 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
2383
2403
 
2384
2404
  TESTS::
2385
2405
 
2386
- sage: import warnings
2387
- sage: warnings.filterwarnings("ignore", category=DeprecationWarning)
2388
2406
  sage: K2.<sqrt2> = QuadraticField(2)
2389
2407
  sage: K3.<sqrt3> = QuadraticField(3)
2390
2408
  sage: K5.<sqrt5> = QuadraticField(5)
@@ -2399,15 +2417,15 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
2399
2417
  ....: assert round(a+b*sqrt(5.)) == round(a+b*sqrt5), (a, b)
2400
2418
  """
2401
2419
  n = self.floor()
2402
- test = 2 * (self - n).abs()
2420
+ test = 2 * (self - n)
2403
2421
  if test < 1:
2404
2422
  return n
2405
2423
  elif test > 1:
2406
2424
  return n + 1
2407
- elif self > 0:
2408
- return n + 1
2409
- else:
2425
+ elif n % 2 == 0:
2410
2426
  return n
2427
+ else:
2428
+ return n + 1
2411
2429
 
2412
2430
 
2413
2431
  cdef class NumberFieldElement_quadratic_sqrt(NumberFieldElement_quadratic):
@@ -238,12 +238,12 @@ cdef class EmbeddedNumberFieldMorphism(NumberFieldEmbedding):
238
238
  """
239
239
  if ambient_field is None:
240
240
  if K.coerce_embedding() is None:
241
- raise TypeError("No embedding available for %s"%K)
241
+ raise TypeError("No embedding available for %s" % K)
242
242
  Kemb = K
243
243
  while Kemb.coerce_embedding() is not None:
244
244
  Kemb = Kemb.coerce_embedding().codomain()
245
245
  if L.coerce_embedding() is None:
246
- raise TypeError("No embedding available for %s"%L)
246
+ raise TypeError("No embedding available for %s" % L)
247
247
  Lemb = L
248
248
  while Lemb.coerce_embedding() is not None:
249
249
  Lemb = Lemb.coerce_embedding().codomain()
@@ -40,7 +40,7 @@ We do some arithmetic in a tower of relative number fields::
40
40
  sage: a.parent()
41
41
  Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field
42
42
 
43
- .. WARNING:
43
+ .. WARNING::
44
44
 
45
45
  Doing arithmetic in towers of relative fields that depends on canonical
46
46
  coercions is currently VERY SLOW. It is much better to explicitly coerce
@@ -79,6 +79,7 @@ AUTHORS:
79
79
  # ****************************************************************************
80
80
 
81
81
  from sage.categories.integral_domains import IntegralDomains
82
+ from sage.categories.noetherian_rings import NoetherianRings
82
83
  from sage.misc.cachefunc import cached_method
83
84
  from sage.structure.parent import Parent
84
85
  from sage.structure.sequence import Sequence
@@ -458,6 +459,16 @@ class Order(Parent, sage.rings.abc.Order):
458
459
  Traceback (most recent call last):
459
460
  ...
460
461
  ValueError: the rank of the span of gens is wrong
462
+
463
+ Orders are always Noetherian::
464
+
465
+ sage: x = polygen(ZZ, 'x')
466
+ sage: L.<alpha> = NumberField(x**4 - x**2 + 7)
467
+ sage: O = L.maximal_order() ; O.is_noetherian()
468
+ True
469
+ sage: E.<w> = NumberField(x^2 - x + 2)
470
+ sage: OE = E.ring_of_integers(); OE.is_noetherian()
471
+ True
461
472
  """
462
473
 
463
474
  def __init__(self, K):
@@ -480,8 +491,9 @@ class Order(Parent, sage.rings.abc.Order):
480
491
  0.0535229072603327 + 1.20934552493846*I
481
492
  """
482
493
  self._K = K
494
+ cat = IntegralDomains() & NoetherianRings()
483
495
  Parent.__init__(self, base=ZZ, names=K.variable_names(),
484
- normalize=False, category=IntegralDomains())
496
+ normalize=False, category=cat)
485
497
  self._populate_coercion_lists_(embedding=self.number_field())
486
498
  if self.absolute_degree() == 2:
487
499
  self.is_maximal() # cache
@@ -616,22 +628,6 @@ class Order(Parent, sage.rings.abc.Order):
616
628
  """
617
629
  return False
618
630
 
619
- def is_noetherian(self):
620
- r"""
621
- Return ``True`` (because orders are always Noetherian).
622
-
623
- EXAMPLES::
624
-
625
- sage: x = polygen(ZZ, 'x')
626
- sage: L.<alpha> = NumberField(x**4 - x**2 + 7)
627
- sage: O = L.maximal_order() ; O.is_noetherian()
628
- True
629
- sage: E.<w> = NumberField(x^2 - x + 2)
630
- sage: OE = E.ring_of_integers(); OE.is_noetherian()
631
- True
632
- """
633
- return True
634
-
635
631
  def is_integrally_closed(self) -> bool:
636
632
  r"""
637
633
  Return whether this ring is integrally closed.
@@ -823,7 +819,7 @@ class Order(Parent, sage.rings.abc.Order):
823
819
  from sage.matrix.constructor import Matrix
824
820
  self.__basis_matrix_inverse = Matrix([to_V(b) for b in self.basis()]).inverse()
825
821
  M = self.__basis_matrix_inverse
826
- return to_V(K(x))*M
822
+ return to_V(K(x)) * M
827
823
 
828
824
  def free_module(self):
829
825
  r"""
@@ -1376,7 +1372,8 @@ class Order(Parent, sage.rings.abc.Order):
1376
1372
  sage: A.random_element().parent() is A
1377
1373
  True
1378
1374
  """
1379
- return sum([ZZ.random_element(*args, **kwds)*a for a in self.basis()])
1375
+ return sum([ZZ.random_element(*args, **kwds) * a
1376
+ for a in self.basis()])
1380
1377
 
1381
1378
  def absolute_degree(self):
1382
1379
  r"""
@@ -1494,41 +1491,41 @@ class Order(Parent, sage.rings.abc.Order):
1494
1491
  elements.append(self(a))
1495
1492
  return elements
1496
1493
 
1497
- ## def absolute_polynomial(self):
1498
- ## """
1499
- ## Return the absolute polynomial of this order, which is just the absolute polynomial of the number field.
1494
+ # def absolute_polynomial(self):
1495
+ # """
1496
+ # Return the absolute polynomial of this order, which is just the absolute polynomial of the number field.
1500
1497
 
1501
- ## EXAMPLES::
1498
+ # EXAMPLES::
1502
1499
 
1503
- ## sage: K.<a, b> = NumberField([x^2 + 1, x^3 + x + 1]); OK = K.maximal_order()
1504
- ## Traceback (most recent call last):
1505
- ## ...
1506
- ## NotImplementedError
1500
+ # sage: K.<a, b> = NumberField([x^2 + 1, x^3 + x + 1]); OK = K.maximal_order()
1501
+ # Traceback (most recent call last):
1502
+ # ...
1503
+ # NotImplementedError
1507
1504
 
1508
- ## #sage: OK.absolute_polynomial()
1509
- ## #x^6 + 5*x^4 - 2*x^3 + 4*x^2 + 4*x + 1
1510
- ## """
1511
- ## return self.number_field().absolute_polynomial()
1505
+ # #sage: OK.absolute_polynomial()
1506
+ # #x^6 + 5*x^4 - 2*x^3 + 4*x^2 + 4*x + 1
1507
+ # """
1508
+ # return self.number_field().absolute_polynomial()
1512
1509
 
1513
- ## def polynomial(self):
1514
- ## """
1515
- ## Return the polynomial defining the number field that contains self.
1516
- ## """
1517
- ## return self.number_field().polynomial()
1510
+ # def polynomial(self):
1511
+ # """
1512
+ # Return the polynomial defining the number field that contains self.
1513
+ # """
1514
+ # return self.number_field().polynomial()
1518
1515
 
1519
- ## def polynomial_ntl(self):
1520
- ## """
1521
- ## Return defining polynomial of the parent number field as a
1522
- ## pair, an ntl polynomial and a denominator.
1516
+ # def polynomial_ntl(self):
1517
+ # """
1518
+ # Return defining polynomial of the parent number field as a
1519
+ # pair, an ntl polynomial and a denominator.
1523
1520
 
1524
- ## This is used mainly to implement some internal arithmetic.
1521
+ # This is used mainly to implement some internal arithmetic.
1525
1522
 
1526
- ## EXAMPLES::
1523
+ # EXAMPLES::
1527
1524
 
1528
- ## sage: NumberField(x^2 + 1,'a').maximal_order().polynomial_ntl()
1529
- ## ([1 0 1], 1)
1530
- ## """
1531
- ## return self.number_field().polynomial_ntl()
1525
+ # sage: NumberField(x^2 + 1,'a').maximal_order().polynomial_ntl()
1526
+ # ([1 0 1], 1)
1527
+ # """
1528
+ # return self.number_field().polynomial_ntl()
1532
1529
 
1533
1530
 
1534
1531
  class Order_absolute(Order):
@@ -1605,7 +1602,7 @@ class Order_absolute(Order):
1605
1602
  3*a^2 + 2*a + 1
1606
1603
  """
1607
1604
  if isinstance(x, (tuple, list)):
1608
- x = sum(xi*gi for xi, gi in zip(x, self.gens()))
1605
+ x = sum(xi * gi for xi, gi in zip(x, self.gens()))
1609
1606
  if not isinstance(x, Element) or x.parent() is not self._K:
1610
1607
  x = self._K(x)
1611
1608
  V, _, embedding = self._K.vector_space()
@@ -65,15 +65,13 @@ from sage.structure.richcmp import richcmp
65
65
  from sage.structure.sequence import Sequence
66
66
  from sage.rings.integer_ring import ZZ
67
67
  from sage.rings.rational_field import QQ
68
- from sage.arith.misc import gcd
69
- from sage.matrix.constructor import matrix
70
68
  from sage.modules.free_module_element import vector
71
69
  from sage.rings.polynomial.polynomial_ring import polygens
72
70
  from sage.rings.ideal import Ideal_generic
73
71
 
74
72
  import sage.rings.number_field.order
75
73
 
76
- #TODO I*u works when u lies in I.ring().number_field(), but u*I doesn't
74
+ # TODO I*u works when u lies in I.ring().number_field(), but u*I doesn't
77
75
 
78
76
 
79
77
  def NumberFieldOrderIdeal(O, *args, **kwds):
@@ -779,9 +777,8 @@ def _random_for_testing():
779
777
  from sage.rings.number_field.number_field import QuadraticField
780
778
  from sage.arith.misc import primes
781
779
  from sage.rings.finite_rings.integer_mod_ring import Zmod
782
- from sage.misc.misc_c import prod
783
780
  while True:
784
- d = ZZ(choice((-1,+1)) * randrange(1,10**5))
781
+ d = ZZ(choice((-1, +1)) * randrange(1, 10**5))
785
782
  if not d.is_square():
786
783
  break
787
784
  K,t = QuadraticField(d).objgen()
@@ -132,7 +132,6 @@ cdef list quotient_by_var(list L, size_t index):
132
132
  Return the quotient of the ideal represented by ``L`` and the
133
133
  variable number ``index``.
134
134
  """
135
- cdef ETuple m_j
136
135
  cdef list result = L[:len(L)] # creates a copy
137
136
  cdef size_t i
138
137
  for i in range(len(L)):
@@ -167,7 +166,6 @@ cdef bint HilbertBaseCase(Polynomial_integer_dense_flint fhs, Node D, tuple w) n
167
166
  Otherwiese, ``False`` is returned.
168
167
  """
169
168
  cdef size_t i, j, exp
170
- cdef int e
171
169
  # First, the easiest cases:
172
170
  if not D.Id: # The zero ideal
173
171
  fmpz_poly_set_coeff_si(fhs._poly, 0, 1) # = PR(1)
@@ -228,7 +226,6 @@ cdef bint HilbertBaseCase(Polynomial_integer_dense_flint fhs, Node D, tuple w) n
228
226
 
229
227
  easy = True
230
228
  cdef ETuple m2
231
- cdef list v
232
229
  for j in range(i+1, len(D.Id)):
233
230
  if (<ETuple>PyList_GET_ITEM(D.Id,j))._nonzero > 1:
234
231
  # i.e., another generator contains more than a single var
@@ -297,7 +294,7 @@ cdef make_children(Node D, tuple w):
297
294
  if ``D.Right`` is not ``None``.
298
295
  """
299
296
  cdef size_t j, m
300
- cdef int i, ii
297
+ cdef int i
301
298
  # Determine the variable that appears most often in the monomials.
302
299
  # If "most often" means "only once", then instead we choose a variable that is
303
300
  # guaranteed to appear in a composed monomial.
@@ -491,9 +488,9 @@ def first_hilbert_series(I, grading=None, return_grading=False):
491
488
  br = S('basering')
492
489
  if S.eval('isQuotientRing(basering)')=='1':
493
490
  L = S('ringlist(basering)')
494
- R = S('ring(list(%s[1..3],ideal(0)))'%L.name())
491
+ R = S('ring(list(%s[1..3],ideal(0)))' % L.name())
495
492
  R.set_ring()
496
- I = S('fetch(%s,%s)+ideal(%s)'%(br.name(),I.name(),br.name()))
493
+ I = S('fetch(%s,%s)+ideal(%s)' % (br.name(), I.name(), br.name()))
497
494
 
498
495
  I = [ETuple([int(x) for x in S.eval('string(leadexp({}[{}]))'.format(I.name(), i)).split(',')])
499
496
  for i in range(1,int(S.eval('size({})'.format(I.name())))+1)]
@@ -408,7 +408,6 @@ cdef class Polynomial_integer_dense_flint(Polynomial):
408
408
  cdef RealBall arb_a, arb_z
409
409
  cdef ComplexBall acb_a, acb_z
410
410
 
411
- cdef unsigned long limbs
412
411
  cdef fmpz_t a_fmpz
413
412
  cdef fmpz_t z_fmpz
414
413
 
@@ -1648,16 +1647,15 @@ cdef class Polynomial_integer_dense_flint(Polynomial):
1648
1647
  sage: f = -30*x; f.factor()
1649
1648
  (-1) * 2 * 3 * 5 * x
1650
1649
  """
1651
- cdef int i
1652
1650
  cdef long deg = fmpz_poly_degree(self._poly)
1653
1651
  # it appears that pari has a window from about degrees 30 and 300
1654
1652
  # in which it beats NTL.
1655
1653
  c = self.content()
1656
- g = self//c
1654
+ g = self // c
1657
1655
  if deg < 30 or deg > 300:
1658
- return c.factor()*g._factor_ntl()
1656
+ return c.factor() * g._factor_ntl()
1659
1657
  else:
1660
- return c.factor()*g._factor_pari()
1658
+ return c.factor() * g._factor_pari()
1661
1659
 
1662
1660
  def factor_mod(self, p):
1663
1661
  """
@@ -1,11 +1,11 @@
1
1
  # sage_setup: distribution = sagemath-flint
2
- ###############################################################################
2
+ # ############################################################################
3
3
  # Copyright (C) 2010 Sebastian Pancratz <sfp@pancratz.org> #
4
4
  # #
5
5
  # Distributed under the terms of the GNU General Public License (GPL) #
6
6
  # #
7
- # http://www.gnu.org/licenses/ #
8
- ###############################################################################
7
+ # https://www.gnu.org/licenses/ #
8
+ # ############################################################################
9
9
 
10
10
  from sage.libs.flint.types cimport fmpq_poly_t
11
11
 
@@ -25,6 +25,7 @@ AUTHOR:
25
25
 
26
26
  from cysignals.signals cimport sig_on, sig_str, sig_off
27
27
 
28
+ from libc.limits cimport LONG_MIN
28
29
  from cpython.long cimport PyLong_AsLong
29
30
  from sage.arith.long cimport pyobject_to_long
30
31
 
@@ -784,7 +785,7 @@ cdef class Polynomial_rational_flint(Polynomial):
784
785
  # Shifting #
785
786
  ###########################################################################
786
787
 
787
- def __lshift__(self, n):
788
+ def __lshift__(self, long n):
788
789
  """
789
790
  Notationally multiply ``self`` by `t^n`.
790
791
 
@@ -797,27 +798,34 @@ cdef class Polynomial_rational_flint(Polynomial):
797
798
  TESTS::
798
799
 
799
800
  sage: R.<t> = QQ[]
801
+ sage: t << (-1)
802
+ 1
803
+ sage: t << (-10)
804
+ 0
800
805
  sage: f = R.random_element(1000)
801
806
  sage: (f << 23) >> 23 == f # indirect doctest
802
807
  True
803
808
  """
804
- cdef unsigned long k = <unsigned long> n
809
+ if n < 0:
810
+ assert n != LONG_MIN
811
+ return self >> (-n)
812
+
805
813
  cdef Polynomial_rational_flint f = <Polynomial_rational_flint> self
806
814
  cdef Polynomial_rational_flint res
807
815
  cdef bint do_sig
808
816
 
809
- if k == 0 or fmpq_poly_is_zero(f._poly):
817
+ if n == 0 or fmpq_poly_is_zero(f._poly):
810
818
  return self
811
819
  else:
812
820
  res = f._new()
813
821
  do_sig = fmpq_poly_length(f._poly) > 5000 or n > 5000
814
822
 
815
823
  if do_sig: sig_str("FLINT exception")
816
- fmpq_poly_shift_left(res._poly, f._poly, k)
824
+ fmpq_poly_shift_left(res._poly, f._poly, n)
817
825
  if do_sig: sig_off()
818
826
  return res
819
827
 
820
- def __rshift__(self, n):
828
+ def __rshift__(self, long n):
821
829
  """
822
830
  Notationally return the quotient of Euclidean division of ``self``
823
831
  by `t^n`.
@@ -828,20 +836,25 @@ cdef class Polynomial_rational_flint(Polynomial):
828
836
  sage: f = 1 + t + t^2/2 + t^3/3 + t^4/4
829
837
  sage: f >> 2
830
838
  1/4*t^2 + 1/3*t + 1/2
839
+ sage: f >> (-2)
840
+ 1/4*t^6 + 1/3*t^5 + 1/2*t^4 + t^3 + t^2
831
841
  """
832
- cdef unsigned long k = <unsigned long> n
842
+ if n < 0:
843
+ assert n != LONG_MIN
844
+ return self << (-n)
845
+
833
846
  cdef Polynomial_rational_flint f = <Polynomial_rational_flint> self
834
847
  cdef Polynomial_rational_flint res
835
848
  cdef bint do_sig
836
849
 
837
- if k == 0 or fmpq_poly_is_zero(f._poly):
850
+ if n == 0 or fmpq_poly_is_zero(f._poly):
838
851
  return self
839
852
  else:
840
853
  res = f._new()
841
854
  do_sig = _do_sig(f._poly)
842
855
 
843
856
  if do_sig: sig_str("FLINT exception")
844
- fmpq_poly_shift_right(res._poly, f._poly, k)
857
+ fmpq_poly_shift_right(res._poly, f._poly, n)
845
858
  if do_sig: sig_off()
846
859
  return res
847
860
 
@@ -2218,9 +2231,9 @@ cdef class Polynomial_rational_flint(Polynomial):
2218
2231
  from sage.groups.perm_gps.permgroup_named import TransitiveGroup
2219
2232
  kash.eval('X := PolynomialRing(RationalField()).1')
2220
2233
  s = self._repr(name='X')
2221
- G = kash('Galois(%s)'%s)
2222
- d = int(kash.eval('%s.ext1'%G.name()))
2223
- n = int(kash.eval('%s.ext2'%G.name()))
2234
+ G = kash('Galois(%s)' % s)
2235
+ d = int(kash.eval('%s.ext1' % G.name()))
2236
+ n = int(kash.eval('%s.ext2' % G.name()))
2224
2237
  return TransitiveGroup(d, n)
2225
2238
  except RuntimeError as msg:
2226
2239
  raise NotImplementedError(str(msg) + "\nSorry, " +
@@ -191,7 +191,6 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
191
191
  """
192
192
  cdef list l_in = x
193
193
  cdef unsigned long length = len(l_in)
194
- cdef unsigned long modulus = nmod_poly_modulus(&self.x)
195
194
  cdef int i
196
195
  if length == 0:
197
196
  nmod_poly_zero(&self.x)
@@ -409,9 +408,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
409
408
  n = int(n)
410
409
  value = self.base_ring()(value)
411
410
  if n >= 0:
412
- nmod_poly_set_coeff_ui(&self.x, n, int(value)%nmod_poly_modulus(&self.x))
411
+ nmod_poly_set_coeff_ui(&self.x, n, int(value) % nmod_poly_modulus(&self.x))
413
412
  else:
414
- raise IndexError("Polynomial coefficient index must be nonnegative.")
413
+ raise IndexError("polynomial coefficient index must be nonnegative")
415
414
 
416
415
  cpdef Polynomial _mul_trunc_(self, Polynomial right, long n):
417
416
  """
@@ -645,7 +644,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
645
644
  cdef Polynomial_zmod_flint s0 = self._new()
646
645
  cdef Polynomial_zmod_flint t0 = P.one()
647
646
  cdef Polynomial_zmod_flint s1 = m
648
- cdef Polynomial_zmod_flint t1 = self%m
647
+ cdef Polynomial_zmod_flint t1 = self % m
649
648
 
650
649
  cdef Polynomial_zmod_flint q
651
650
  cdef Polynomial_zmod_flint r0
@@ -3751,7 +3751,7 @@ cdef class island:
3751
3751
 
3752
3752
  return self.known_done
3753
3753
 
3754
- def has_root(self):
3754
+ def has_root(self) -> bool:
3755
3755
  """
3756
3756
  Assuming that the island is done (has either 0 or 1 roots),
3757
3757
  reports whether the island has a root.
@@ -299,7 +299,7 @@ class WeilPolynomials_iter():
299
299
  k = Integer(k)
300
300
  if len(modlist) == 0 and k != 0:
301
301
  raise ValueError("Leading coefficient must be specified exactly")
302
- if len(modlist) > 0 and ((k != 0 and modlist[-1]%k != 0) or (k == 0 and modlist[-1] != 0)):
302
+ if modlist and ((k != 0 and modlist[-1] % k != 0) or (k == 0 and modlist[-1] != 0)):
303
303
  raise ValueError("Invalid moduli")
304
304
  coefflist.append(j)
305
305
  modlist.append(k)