passagemath-flint 10.5.43__cp310-cp310-macosx_14_0_arm64.whl → 10.6.1rc1__cp310-cp310-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 (102) hide show
  1. {passagemath_flint-10.5.43.dist-info → passagemath_flint-10.6.1rc1.dist-info}/METADATA +5 -6
  2. {passagemath_flint-10.5.43.dist-info → passagemath_flint-10.6.1rc1.dist-info}/RECORD +102 -102
  3. passagemath_flint.dylibs/{libflint.19.0.dylib → libflint.20.0.dylib} +0 -0
  4. passagemath_flint.dylibs/libgf2x.3.dylib +0 -0
  5. passagemath_flint.dylibs/libmpfi.0.dylib +0 -0
  6. sage/combinat/posets/hasse_cython_flint.cpython-310-darwin.so +0 -0
  7. sage/data_structures/bounded_integer_sequences.cpython-310-darwin.so +0 -0
  8. sage/data_structures/bounded_integer_sequences.pyx +22 -20
  9. sage/graphs/chrompoly.cpython-310-darwin.so +0 -0
  10. sage/graphs/chrompoly.pyx +4 -3
  11. sage/graphs/matchpoly.cpython-310-darwin.so +0 -0
  12. sage/libs/arb/arith.cpython-310-darwin.so +0 -0
  13. sage/libs/flint/arith.cpython-310-darwin.so +0 -0
  14. sage/libs/flint/arith_sage.cpython-310-darwin.so +0 -0
  15. sage/libs/flint/flint.pxd +2 -2
  16. sage/libs/flint/flint_sage.cpython-310-darwin.so +0 -0
  17. sage/libs/flint/flint_wrap.h +4 -0
  18. sage/libs/flint/fmpq_poly_sage.cpython-310-darwin.so +0 -0
  19. sage/libs/flint/fmpz_factor_sage.cpython-310-darwin.so +0 -0
  20. sage/libs/flint/fmpz_poly.cpython-310-darwin.so +0 -0
  21. sage/libs/flint/fmpz_poly_sage.cpython-310-darwin.so +0 -0
  22. sage/libs/flint/nmod_poly_linkage.pxi +5 -4
  23. sage/libs/flint/qsieve.cpython-310-darwin.so +0 -0
  24. sage/libs/flint/qsieve_sage.cpython-310-darwin.so +0 -0
  25. sage/libs/flint/types.pxd +2 -2
  26. sage/libs/flint/ulong_extras.cpython-310-darwin.so +0 -0
  27. sage/libs/flint/ulong_extras_sage.cpython-310-darwin.so +0 -0
  28. sage/matrix/change_ring.cpython-310-darwin.so +0 -0
  29. sage/matrix/matrix_complex_ball_dense.cpython-310-darwin.so +0 -0
  30. sage/matrix/matrix_cyclo_dense.cpython-310-darwin.so +0 -0
  31. sage/matrix/matrix_cyclo_dense.pyx +3 -3
  32. sage/matrix/matrix_integer_dense.cpython-310-darwin.so +0 -0
  33. sage/matrix/matrix_integer_dense.pyx +50 -33
  34. sage/matrix/matrix_integer_sparse.cpython-310-darwin.so +0 -0
  35. sage/matrix/matrix_integer_sparse.pyx +1 -1
  36. sage/matrix/matrix_rational_dense.cpython-310-darwin.so +0 -0
  37. sage/matrix/matrix_rational_dense.pyx +64 -28
  38. sage/matrix/matrix_rational_sparse.cpython-310-darwin.so +0 -0
  39. sage/matrix/matrix_rational_sparse.pyx +3 -3
  40. sage/matrix/misc_flint.cpython-310-darwin.so +0 -0
  41. sage/modular/modform/eis_series_cython.cpython-310-darwin.so +0 -0
  42. sage/modular/modsym/apply.cpython-310-darwin.so +0 -0
  43. sage/modular/modsym/heilbronn.cpython-310-darwin.so +0 -0
  44. sage/modular/pollack_stevens/dist.cpython-310-darwin.so +0 -0
  45. sage/modular/pollack_stevens/dist.pyx +2 -2
  46. sage/quivers/algebra.py +2 -1
  47. sage/quivers/algebra_elements.cpython-310-darwin.so +0 -0
  48. sage/quivers/algebra_elements.pyx +5 -5
  49. sage/quivers/ar_quiver.py +21 -21
  50. sage/quivers/homspace.py +2 -1
  51. sage/quivers/morphism.py +31 -29
  52. sage/quivers/path_semigroup.py +14 -11
  53. sage/quivers/paths.cpython-310-darwin.so +0 -0
  54. sage/quivers/paths.pyx +2 -2
  55. sage/quivers/representation.py +22 -24
  56. sage/rings/complex_arb.cpython-310-darwin.so +0 -0
  57. sage/rings/complex_arb.pyx +37 -36
  58. sage/rings/complex_interval.cpython-310-darwin.so +0 -0
  59. sage/rings/convert/mpfi.cpython-310-darwin.so +0 -0
  60. sage/rings/factorint_flint.cpython-310-darwin.so +0 -0
  61. sage/rings/fraction_field_FpT.cpython-310-darwin.so +0 -0
  62. sage/rings/fraction_field_FpT.pyx +29 -0
  63. sage/rings/number_field/S_unit_solver.py +1 -1
  64. sage/rings/number_field/galois_group.py +1 -1
  65. sage/rings/number_field/morphism.py +3 -4
  66. sage/rings/number_field/number_field.py +97 -75
  67. sage/rings/number_field/number_field_element.cpython-310-darwin.so +0 -0
  68. sage/rings/number_field/number_field_element.pyx +72 -0
  69. sage/rings/number_field/number_field_element_quadratic.cpython-310-darwin.so +0 -0
  70. sage/rings/number_field/number_field_element_quadratic.pyx +35 -17
  71. sage/rings/number_field/number_field_morphisms.cpython-310-darwin.so +0 -0
  72. sage/rings/number_field/number_field_morphisms.pyx +2 -2
  73. sage/rings/number_field/number_field_rel.py +1 -1
  74. sage/rings/number_field/order.py +44 -47
  75. sage/rings/number_field/order_ideal.py +2 -5
  76. sage/rings/polynomial/evaluation_flint.cpython-310-darwin.so +0 -0
  77. sage/rings/polynomial/hilbert.cpython-310-darwin.so +0 -0
  78. sage/rings/polynomial/hilbert.pyx +3 -6
  79. sage/rings/polynomial/polynomial_complex_arb.cpython-310-darwin.so +0 -0
  80. sage/rings/polynomial/polynomial_integer_dense_flint.cpython-310-darwin.so +0 -0
  81. sage/rings/polynomial/polynomial_integer_dense_flint.pyx +3 -5
  82. sage/rings/polynomial/polynomial_number_field.cpython-310-darwin.so +0 -0
  83. sage/rings/polynomial/polynomial_rational_flint.cpython-310-darwin.so +0 -0
  84. sage/rings/polynomial/polynomial_rational_flint.pxd +3 -3
  85. sage/rings/polynomial/polynomial_rational_flint.pyx +24 -11
  86. sage/rings/polynomial/polynomial_zmod_flint.cpython-310-darwin.so +0 -0
  87. sage/rings/polynomial/polynomial_zmod_flint.pyx +3 -4
  88. sage/rings/polynomial/real_roots.cpython-310-darwin.so +0 -0
  89. sage/rings/polynomial/real_roots.pyx +1 -1
  90. sage/rings/polynomial/refine_root.cpython-310-darwin.so +0 -0
  91. sage/rings/polynomial/weil/weil_polynomials.cpython-310-darwin.so +0 -0
  92. sage/rings/polynomial/weil/weil_polynomials.pyx +1 -1
  93. sage/rings/qqbar.py +1 -1
  94. sage/rings/real_arb.cpython-310-darwin.so +0 -0
  95. sage/rings/real_arb.pyx +21 -10
  96. sage/rings/real_interval_absolute.cpython-310-darwin.so +0 -0
  97. sage/rings/real_mpfi.cpython-310-darwin.so +0 -0
  98. sage/rings/real_mpfi.pyx +14 -11
  99. sage/schemes/elliptic_curves/descent_two_isogeny.cpython-310-darwin.so +0 -0
  100. sage/schemes/elliptic_curves/descent_two_isogeny.pyx +11 -0
  101. {passagemath_flint-10.5.43.dist-info → passagemath_flint-10.6.1rc1.dist-info}/WHEEL +0 -0
  102. {passagemath_flint-10.5.43.dist-info → passagemath_flint-10.6.1rc1.dist-info}/top_level.txt +0 -0
@@ -6,8 +6,9 @@ This file provides the backend for \class{Polynomial_zmod_flint} via
6
6
  templating.
7
7
 
8
8
  AUTHOR:
9
- -- Martin Albrecht (2009-01) another initial implementation
10
- -- Burcin Erocal (2008-11) initial implementation
9
+
10
+ - Martin Albrecht (2009-01) another initial implementation
11
+ - Burcin Erocal (2008-11) initial implementation
11
12
  """
12
13
  #*****************************************************************************
13
14
  # Copyright (C) 2008-2009 Burcin Erocal <burcin@erocal.org>
@@ -15,7 +16,7 @@ AUTHOR:
15
16
  #
16
17
  # Distributed under the terms of the GNU General Public License (GPL),
17
18
  # version 2 or any later version. The full text of the GPL is available at:
18
- # http://www.gnu.org/licenses/
19
+ # https://www.gnu.org/licenses/
19
20
  #*****************************************************************************
20
21
 
21
22
  from cysignals.signals cimport sig_on, sig_off
@@ -338,7 +339,7 @@ cdef inline int celement_mul_scalar(nmod_poly_t res, nmod_poly_t p,
338
339
  sage: (p*9836).coefficients() == [x*9836 for x in p.coefficients()]
339
340
  True
340
341
  """
341
- nmod_poly_scalar_mul_nmod(res, p, (<unsigned long>c)%n)
342
+ nmod_poly_scalar_mul_nmod(res, p, (<unsigned long>c) % n)
342
343
 
343
344
  cdef inline int celement_mul(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsigned long n) except -2:
344
345
  """
sage/libs/flint/types.pxd CHANGED
@@ -267,9 +267,9 @@ cdef extern from "flint_wrap.h":
267
267
 
268
268
 
269
269
  # flint/flint.h
270
- ctypedef struct flint_rand_s:
270
+ ctypedef struct flint_rand_struct:
271
271
  pass
272
- ctypedef flint_rand_s flint_rand_t[1]
272
+ ctypedef flint_rand_struct flint_rand_t[1]
273
273
 
274
274
  cdef long FLINT_BITS
275
275
  cdef long FLINT_D_BITS
@@ -1230,7 +1230,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
1230
1230
  sage: Matrix(CyclotomicField(10),0).charpoly()
1231
1231
  1
1232
1232
  """
1233
- key = 'charpoly-%s-%s'%(algorithm,proof)
1233
+ key = 'charpoly-%s-%s' % (algorithm, proof)
1234
1234
  f = self.fetch(key)
1235
1235
  if f is not None:
1236
1236
  return f.change_variable_name(var)
@@ -1525,7 +1525,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
1525
1525
  sage: a == b # long time (depends on previous)
1526
1526
  True
1527
1527
  """
1528
- key = 'echelon_form-%s'%algorithm
1528
+ key = 'echelon_form-%s' % algorithm
1529
1529
  E = self.fetch(key)
1530
1530
  if E is not None:
1531
1531
  return E
@@ -1631,7 +1631,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
1631
1631
  ...
1632
1632
  ValueError: echelon form mod 7 not defined
1633
1633
  """
1634
- cdef int i
1634
+ cdef Py_ssize_t i
1635
1635
 
1636
1636
  # Initialize variables
1637
1637
  ls, _ = self._reductions(p)
@@ -60,7 +60,7 @@ TESTS::
60
60
  from libc.stdint cimport int64_t
61
61
  from libc.string cimport strcpy, strlen
62
62
 
63
- from sage.cpython.string cimport char_to_str, str_to_bytes
63
+ from sage.cpython.string cimport char_to_str
64
64
  from sage.ext.stdsage cimport PY_NEW
65
65
  from cysignals.signals cimport sig_check, sig_on, sig_str, sig_off
66
66
  from cysignals.memory cimport sig_malloc, sig_free, check_allocarray
@@ -446,7 +446,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
446
446
  sage: matrix(ZZ,1,3,[1,193,15])._pickle() == (b'1 61 f', 0) # indirect doctest
447
447
  True
448
448
  """
449
- return str_to_bytes(self._export_as_string(32), 'ascii')
449
+ return self._export_as_string(32).encode('ascii')
450
450
 
451
451
  cpdef _export_as_string(self, int base=10):
452
452
  """
@@ -467,7 +467,8 @@ cdef class Matrix_integer_dense(Matrix_dense):
467
467
  """
468
468
  # TODO: *maybe* redo this to use mpz_import and mpz_export
469
469
  # from sec 5.14 of the GMP manual. ??
470
- cdef int i, j, len_so_far, m, n
470
+ cdef Py_ssize_t i, j, len_so_far
471
+ cdef int m, n
471
472
  cdef char *s
472
473
  cdef char *t
473
474
  cdef char *tmp
@@ -530,18 +531,18 @@ cdef class Matrix_integer_dense(Matrix_dense):
530
531
  self._unpickle_matrix_2x2_version0(data)
531
532
  else:
532
533
  raise RuntimeError("invalid pickle data")
534
+
533
535
  else:
534
- raise RuntimeError("unknown matrix version (=%s)"%version)
536
+ raise RuntimeError(f"unknown matrix version (={version})")
535
537
 
536
538
  cdef _unpickle_version0(self, data):
537
- cdef Py_ssize_t i, j, n, k
539
+ cdef Py_ssize_t i, j, k
538
540
  data = data.split()
539
- n = self._nrows * self._ncols
540
- if len(data) != n:
541
+ if len(data) != self._nrows * self._ncols:
541
542
  raise RuntimeError("invalid pickle data")
542
543
  k = 0
543
- for i from 0 <= i < self._nrows:
544
- for j from 0 <= j < self._ncols:
544
+ for i in range(self._nrows):
545
+ for j in range(self._ncols):
545
546
  s = data[k]
546
547
  k += 1
547
548
  if fmpz_set_str(fmpz_mat_entry(self._matrix, i, j), s, 32):
@@ -1321,7 +1322,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
1321
1322
  elif algorithm == 'generic':
1322
1323
  g = Matrix_dense.charpoly(self, var)
1323
1324
  else:
1324
- raise ValueError("no algorithm '%s'"%algorithm)
1325
+ raise ValueError("no algorithm '%s'" % algorithm)
1325
1326
 
1326
1327
  self.cache(cache_key, g)
1327
1328
  return g
@@ -1396,7 +1397,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
1396
1397
  else:
1397
1398
  algorithm = 'linbox'
1398
1399
 
1399
- key = 'minpoly_%s'%(algorithm)
1400
+ key = 'minpoly_%s' % (algorithm)
1400
1401
  g = self.fetch(key)
1401
1402
  if g is not None:
1402
1403
  return g.change_variable_name(var)
@@ -1407,7 +1408,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
1407
1408
  elif algorithm == 'generic':
1408
1409
  g = Matrix_dense.minpoly(self, var)
1409
1410
  else:
1410
- raise ValueError("no algorithm '%s'"%algorithm)
1411
+ raise ValueError("no algorithm '%s'" % algorithm)
1411
1412
 
1412
1413
  self.cache(key, g)
1413
1414
  return g
@@ -1561,7 +1562,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
1561
1562
  [ 1 -2 -45]
1562
1563
  """
1563
1564
  w = self._export_as_string(base=10)
1564
- return 'Matrix(IntegerRing(),%s,%s,StringToIntegerSequence("%s"))'%(
1565
+ return 'Matrix(IntegerRing(),%s,%s,StringToIntegerSequence("%s"))' % (
1565
1566
  self.nrows(), self.ncols(), w)
1566
1567
 
1567
1568
  def symplectic_form(self):
@@ -1864,7 +1865,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
1864
1865
  sage: H == U*m
1865
1866
  True
1866
1867
  """
1867
- key = 'hnf-%s-%s'%(include_zero_rows,transformation)
1868
+ key = 'hnf-%s-%s' % (include_zero_rows, transformation)
1868
1869
  ans = self.fetch(key)
1869
1870
  if ans is not None:
1870
1871
  return ans
@@ -2261,7 +2262,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
2261
2262
  if i > 0:
2262
2263
  d = d[i:] + [d[0]]*i
2263
2264
  else:
2264
- raise ValueError("algorithm (='%s') unknown"%algorithm)
2265
+ raise ValueError("algorithm (='%s') unknown" % algorithm)
2265
2266
 
2266
2267
  self.cache('elementary_divisors', d)
2267
2268
  return d[:]
@@ -2615,7 +2616,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
2615
2616
  K = _rational_kernel_iml(self).transpose().saturation(proof=proof)
2616
2617
  format = 'computed-iml-int'
2617
2618
  else:
2618
- raise ValueError('unknown algorithm: %s'%algorithm)
2619
+ raise ValueError('unknown algorithm: %s' % algorithm)
2619
2620
  tm = verbose("done computing right kernel matrix over the integers for %sx%s matrix" % (self.nrows(), self.ncols()),level=1, t=tm)
2620
2621
  return (format, K)
2621
2622
 
@@ -3093,7 +3094,9 @@ cdef class Matrix_integer_dense(Matrix_dense):
3093
3094
  cdef Matrix_integer_dense R = None # LLL-reduced matrix
3094
3095
  cdef Matrix_integer_dense U = None # transformation matrix
3095
3096
 
3096
- tm = verbose("LLL of %sx%s matrix (algorithm %s)"%(self.nrows(), self.ncols(), algorithm))
3097
+ tm = verbose("LLL of %sx%s matrix (algorithm %s)" % (self.nrows(),
3098
+ self.ncols(),
3099
+ algorithm))
3097
3100
  import sage.libs.ntl.all
3098
3101
  ntl_ZZ = sage.libs.ntl.all.ZZ
3099
3102
 
@@ -3171,7 +3174,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
3171
3174
  else:
3172
3175
  r = A.LLL_XD(delta, verbose=verb, return_U=transformation)
3173
3176
  else:
3174
- raise TypeError("algorithm %s not supported"%algorithm)
3177
+ raise TypeError("algorithm %s not supported" % algorithm)
3175
3178
 
3176
3179
  if isinstance(r, tuple):
3177
3180
  r, UNTL = r
@@ -3209,7 +3212,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
3209
3212
  from .matrix_integer_pari import _lll_pari
3210
3213
  R, U, r = _lll_pari(self)
3211
3214
  else:
3212
- raise TypeError("algorithm %s not supported"%algorithm)
3215
+ raise TypeError("algorithm %s not supported" % algorithm)
3213
3216
 
3214
3217
  verbose("LLL finished", tm)
3215
3218
  if r is not None:
@@ -3455,7 +3458,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
3455
3458
  num_per_row = int(density * nc)
3456
3459
  for i from 0 <= i < self._nrows:
3457
3460
  for j from 0 <= j < num_per_row:
3458
- k = rstate.c_random()%nc
3461
+ k = rstate.c_random() % nc
3459
3462
  the_integer_ring._randomize_mpz(tmp,
3460
3463
  x, y, distribution)
3461
3464
  self.set_unsafe_mpz(i,k,tmp)
@@ -3759,7 +3762,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
3759
3762
  elif algorithm == 'ntl':
3760
3763
  d = self._det_ntl()
3761
3764
  else:
3762
- raise TypeError("algorithm '%s' not known"%(algorithm))
3765
+ raise TypeError("algorithm '%s' not known" % (algorithm))
3763
3766
 
3764
3767
  self.cache('det', d)
3765
3768
  return d
@@ -3977,7 +3980,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
3977
3980
  cdef fmpz_t fden
3978
3981
  fmpz_init(fden)
3979
3982
  M = self._new(self._nrows,self._ncols)
3980
- verbose('computing inverse of %s x %s matrix using FLINT'%(self._nrows, self._ncols))
3983
+ verbose('computing inverse of %s x %s matrix using FLINT' % (self._nrows, self._ncols))
3981
3984
  sig_on()
3982
3985
  res = fmpz_mat_inv(M._matrix,fden,self._matrix)
3983
3986
  fmpz_get_mpz(den.value,fden)
@@ -4190,13 +4193,13 @@ cdef class Matrix_integer_dense(Matrix_dense):
4190
4193
  from .matrix_integer_iml import _solve_iml
4191
4194
  X, d = _solve_iml(self, C, right=True)
4192
4195
  else:
4193
- raise ValueError("Unknown algorithm '%s'"%algorithm)
4196
+ raise ValueError("Unknown algorithm '%s'" % algorithm)
4194
4197
  if d != 1:
4195
4198
  X = (1/d) * X
4196
4199
  if not matrix:
4197
4200
  # Convert back to a vector
4198
4201
  X = (X.base_ring() ** X.nrows())(X.list())
4199
- verbose('finished solve_right via %s'%algorithm, t)
4202
+ verbose('finished solve_right via %s' % algorithm, t)
4200
4203
  return X
4201
4204
 
4202
4205
  def _solve_iml(self, Matrix_integer_dense B, right=True):
@@ -4560,13 +4563,15 @@ cdef class Matrix_integer_dense(Matrix_dense):
4560
4563
  pivots_ = set(pivots)
4561
4564
  non_pivots = [i for i in range(B.ncols()) if i not in pivots_]
4562
4565
  D = B.matrix_from_columns(non_pivots)
4563
- t = verbose('calling %s solver'%solver, level=2, caller_name='p-adic echelon')
4566
+ t = verbose('calling %s solver' % solver,
4567
+ level=2, caller_name='p-adic echelon')
4564
4568
  if solver == 'iml':
4565
4569
  from .matrix_integer_iml import _solve_iml
4566
4570
  X, d = _solve_iml(C, D, right=True)
4567
4571
  else:
4568
4572
  X, d = C._solve_flint(D, right=True)
4569
- t = verbose('finished %s solver'%solver, level=2, caller_name='p-adic echelon', t=t)
4573
+ t = verbose('finished %s solver' % solver,
4574
+ level=2, caller_name='p-adic echelon', t=t)
4570
4575
 
4571
4576
  # Step 6: Verify that we had chosen the correct pivot columns.
4572
4577
  pivots_are_right = True
@@ -4786,7 +4791,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
4786
4791
  new_pivots = list(pivots)
4787
4792
  if v != 0:
4788
4793
  i = v.nonzero_positions()[0]
4789
- assert not (i in pivots), 'WARNING: bug in add_row -- i (=%s) should not be a pivot'%i
4794
+ assert not (i in pivots), 'WARNING: bug in add_row -- i (=%s) should not be a pivot' % i
4790
4795
 
4791
4796
  # If pivot entry is negative negate this row.
4792
4797
  if v[i] < 0:
@@ -4929,7 +4934,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
4929
4934
  for k from 0 <= k < i:
4930
4935
  res_rows[i][k] = 0
4931
4936
  for k from i <= k < ncols:
4932
- t = ((<int64_t>u)*T_rows[i][k])%R
4937
+ t = ((<int64_t>u)*T_rows[i][k]) % R
4933
4938
  if t < 0:
4934
4939
  t += R
4935
4940
  res_rows[i][k] = t
@@ -4939,7 +4944,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
4939
4944
  for j from 0 <= j < i:
4940
4945
  q = res_rows[j][i]/d
4941
4946
  for k from i <= k < ncols:
4942
- u = (res_rows[j][k] - (<int64_t>q)*res_rows[i][k])%R
4947
+ u = (res_rows[j][k] - (<int64_t>q)*res_rows[i][k]) % R
4943
4948
  if u < 0:
4944
4949
  u += R
4945
4950
  res_rows[j][k] = u
@@ -4962,11 +4967,11 @@ cdef class Matrix_integer_dense(Matrix_dense):
4962
4967
  d = ai.c_xgcd_int(T_i_i, T_j_i, &u, &v)
4963
4968
  if d != T_i_i:
4964
4969
  for k from i <= k < ncols:
4965
- B[k] = ((<int64_t>u)*T_rows[i][k] + (<int64_t>v)*T_rows[j][k])%R
4970
+ B[k] = ((<int64_t>u)*T_rows[i][k] + (<int64_t>v)*T_rows[j][k]) % R
4966
4971
  c1 = T_i_i/d
4967
4972
  c2 = -T_j_i/d
4968
4973
  for k from i <= k < ncols:
4969
- T_rows[j][k] = ((<int64_t>c1)*T_rows[j][k] + (<int64_t>c2)*T_rows[i][k])%R
4974
+ T_rows[j][k] = ((<int64_t>c1)*T_rows[j][k] + (<int64_t>c2)*T_rows[i][k]) % R
4970
4975
  if d != T_i_i:
4971
4976
  for k from i <= k < ncols:
4972
4977
  T_rows[i][k] = B[k]
@@ -5239,6 +5244,16 @@ cdef class Matrix_integer_dense(Matrix_dense):
5239
5244
  [ 3 4 5]
5240
5245
  [ 6 7 8]
5241
5246
  [ 1 5 -10]
5247
+
5248
+ TESTS:
5249
+
5250
+ Ensure that :issue:`11328` is fixed::
5251
+
5252
+ sage: m = matrix([[int(1),int(1)],[int(1),int(1)]])
5253
+ sage: m.insert_row(1,[int(2),int(3)])
5254
+ [1 1]
5255
+ [2 3]
5256
+ [1 1]
5242
5257
  """
5243
5258
  cdef Matrix_integer_dense res = self._new(self._nrows + 1, self._ncols)
5244
5259
  cdef Py_ssize_t j
@@ -5254,7 +5269,8 @@ cdef class Matrix_integer_dense(Matrix_dense):
5254
5269
  for i from 0 <= i < index:
5255
5270
  fmpz_init_set(fmpz_mat_entry(res._matrix,i,j), fmpz_mat_entry(self._matrix,i,j))
5256
5271
 
5257
- z = row[j]
5272
+ z = ZZ(row[j])
5273
+
5258
5274
  fmpz_set_mpz(zflint,z.value)
5259
5275
  fmpz_init_set(fmpz_mat_entry(res._matrix,index,j), zflint)
5260
5276
 
@@ -5437,7 +5453,8 @@ cdef class Matrix_integer_dense(Matrix_dense):
5437
5453
 
5438
5454
  name = singular._next_var_name()
5439
5455
  values = str(self.list())[1:-1]
5440
- singular.eval("intmat %s[%d][%d] = %s"%(name, self.nrows(), self.ncols(), values))
5456
+ singular.eval("intmat %s[%d][%d] = %s" % (name, self.nrows(),
5457
+ self.ncols(), values))
5441
5458
 
5442
5459
  from sage.interfaces.singular import SingularElement
5443
5460
  return SingularElement(singular, 'foobar', name, True)
@@ -660,7 +660,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
660
660
  r = Matrix_sparse.rank(self)
661
661
  self.cache("rank", r)
662
662
  else:
663
- raise ValueError("no algorithm '%s'"%algorithm)
663
+ raise ValueError("no algorithm '%s'" % algorithm)
664
664
 
665
665
  return r
666
666
 
@@ -68,7 +68,7 @@ Test hashing::
68
68
  from libc.string cimport strcpy, strlen
69
69
 
70
70
  from sage.categories.rings import Rings
71
- from sage.cpython.string cimport char_to_str, str_to_bytes
71
+ from sage.cpython.string cimport char_to_str
72
72
 
73
73
  from sage.modules.vector_rational_dense cimport Vector_rational_dense
74
74
  from sage.ext.stdsage cimport PY_NEW
@@ -357,13 +357,13 @@ cdef class Matrix_rational_dense(Matrix_dense):
357
357
  s = data[k]
358
358
  k += 1
359
359
  if '/' in s:
360
- num, den = [str_to_bytes(n) for n in s.split('/')]
360
+ num, den = (n.encode() for n in s.split('/'))
361
361
  if fmpz_set_str(fmpq_mat_entry_num(self._matrix, i, j), num, 32) or \
362
362
  fmpz_set_str(fmpq_mat_entry_den(self._matrix, i, j), den, 32):
363
363
  raise RuntimeError("invalid pickle data")
364
364
  else:
365
- s = str_to_bytes(s)
366
- if fmpz_set_str(fmpq_mat_entry_num(self._matrix, i, j), s, 32):
365
+ num = s.encode()
366
+ if fmpz_set_str(fmpq_mat_entry_num(self._matrix, i, j), num, 32):
367
367
  raise RuntimeError("invalid pickle data")
368
368
  fmpz_one(fmpq_mat_entry_den(self._matrix, i, j))
369
369
 
@@ -1261,7 +1261,7 @@ cdef class Matrix_rational_dense(Matrix_dense):
1261
1261
 
1262
1262
  cdef int fmpz_height(self, fmpz_t h) except -1:
1263
1263
  cdef fmpz_t x
1264
- cdef int i, j
1264
+ cdef Py_ssize_t i, j
1265
1265
  sig_on()
1266
1266
  fmpz_init(x)
1267
1267
  fmpz_zero(h)
@@ -1503,24 +1503,33 @@ cdef class Matrix_rational_dense(Matrix_dense):
1503
1503
 
1504
1504
  - ``algorithm`` -- an optional specification of an algorithm. One of
1505
1505
 
1506
- - ``None``: (default) uses flint for small dimension and multimodular otherwise
1506
+ - ``None``: (default) try to pick the best choice,
1507
+
1508
+ - ``'flint'``: use flint library
1509
+ `function <https://flintlib.org/doc/fmpq_mat.html#c.fmpq_mat_rref>`_,
1510
+ which automatically chooses between
1511
+ `classical algorithm <https://flintlib.org/doc/fmpq_mat.html#c.fmpq_mat_rref_classical>`_
1512
+ (Gaussian elimination),
1513
+ `fraction-free multimodular <https://flintlib.org/doc/fmpz_mat.html#c.fmpz_mat_rref_mul>`_,
1514
+ and `fraction-free LU decomposition <https://flintlib.org/doc/fmpz_mat.html#c.fmpz_mat_rref_fflu>`_,
1507
1515
 
1508
- - ``'flint'``: use the flint library,
1516
+ - ``'flint:classical'``, ``'flint:multimodular'``, ``'flint:fflu'``: use the
1517
+ flint library as above, but select an algorithm explicitly,
1509
1518
 
1510
1519
  - ``'padic'``: an algorithm based on the IML `p`-adic solver,
1511
1520
 
1512
- - ``'multimodular'``: uses a multimodular algorithm the uses
1513
- linbox modulo many primes (likely to be faster when coefficients
1514
- are huge),
1521
+ - ``'multimodular'``: uses a multimodular algorithm implemented in Cython
1522
+ that uses linbox modulo many primes,
1523
+ see :func:`~sage.matrix.misc.matrix_rational_echelon_form_multimodular`,
1515
1524
 
1516
1525
  - ``'classical'``: just clear each column using Gauss elimination.
1517
1526
 
1518
1527
  - ``height_guess``, ``**kwds`` -- all passed to the
1519
- multimodular algorithm; ignored by other algorithms
1528
+ ``'multimodular'`` algorithm; ignored by other algorithms
1520
1529
 
1521
1530
  - ``proof`` -- boolean or ``None`` (default: None, see
1522
1531
  proof.linear_algebra or sage.structure.proof). Passed to the
1523
- multimodular algorithm. Note that the Sage global default is
1532
+ ``'multimodular'`` algorithm. Note that the Sage global default is
1524
1533
  ``proof=True``.
1525
1534
 
1526
1535
  EXAMPLES::
@@ -1553,7 +1562,8 @@ cdef class Matrix_rational_dense(Matrix_dense):
1553
1562
  Echelonizing a matrix in place throws away the cache of
1554
1563
  the old matrix (:issue:`14506`)::
1555
1564
 
1556
- sage: for algo in ["flint", "padic", "multimodular", "classical"]: # needs sage.libs.linbox
1565
+ sage: for algo in ["flint", "padic", "multimodular", "classical", # needs sage.libs.linbox
1566
+ ....: "flint:classical", "flint:multimodular", "flint:fflu"]:
1557
1567
  ....: a = Matrix(QQ, [[1,2],[3,4]])
1558
1568
  ....: _ = a.det() # fills the cache
1559
1569
  ....: _ = a._clear_denom() # fills the cache
@@ -1565,18 +1575,10 @@ cdef class Matrix_rational_dense(Matrix_dense):
1565
1575
  self.check_mutability()
1566
1576
 
1567
1577
  if algorithm is None:
1568
- if self._nrows <= 25 or self._ncols <= 25:
1569
- algorithm = 'flint'
1570
- else:
1571
- try:
1572
- from sage.matrix.misc import matrix_rational_echelon_form_multimodular
1573
- except ImportError:
1574
- algorithm = 'flint'
1575
- else:
1576
- algorithm = 'multimodular'
1578
+ algorithm = 'flint:multimodular'
1577
1579
 
1578
- if algorithm == 'flint':
1579
- pivots = self._echelonize_flint()
1580
+ if algorithm in ('flint', 'flint:classical', 'flint:multimodular', 'flint:fflu'):
1581
+ pivots = self._echelonize_flint(algorithm)
1580
1582
  elif algorithm == 'multimodular':
1581
1583
  pivots = self._echelonize_multimodular(height_guess, proof, **kwds)
1582
1584
  elif algorithm == 'classical':
@@ -1666,12 +1668,16 @@ cdef class Matrix_rational_dense(Matrix_dense):
1666
1668
  self.cache('rank', len(E.pivots()))
1667
1669
  return E
1668
1670
 
1669
- def _echelonize_flint(self):
1671
+ def _echelonize_flint(self, algorithm: str):
1670
1672
  r"""
1673
+ INPUT: See :meth:`echelonize` for the options.
1674
+ Only options that use flint are allowed, passing other algorithms may
1675
+ trigger undefined behavior.
1676
+
1671
1677
  EXAMPLES::
1672
1678
 
1673
1679
  sage: m = matrix(QQ, 4, range(16))
1674
- sage: m._echelonize_flint()
1680
+ sage: m._echelonize_flint("flint")
1675
1681
  (0, 1)
1676
1682
  sage: m
1677
1683
  [ 1 0 -1 -2]
@@ -1679,7 +1685,7 @@ cdef class Matrix_rational_dense(Matrix_dense):
1679
1685
  [ 0 0 0 0]
1680
1686
  [ 0 0 0 0]
1681
1687
  sage: m = matrix(QQ, 4, 6, [-1,0,0,-2,-1,-2,-1,0,0,-2,-1,0,3,3,-2,0,0,3,-2,-3,1,1,-2,3])
1682
- sage: m._echelonize_flint()
1688
+ sage: m._echelonize_flint("flint")
1683
1689
  (0, 1, 2, 5)
1684
1690
  sage: m
1685
1691
  [ 1 0 0 2 1 0]
@@ -1688,10 +1694,40 @@ cdef class Matrix_rational_dense(Matrix_dense):
1688
1694
  [ 0 0 0 0 0 1]
1689
1695
  """
1690
1696
  self.clear_cache()
1697
+
1698
+ if fmpq_mat_is_empty(self._matrix):
1699
+ return ()
1700
+
1691
1701
  cdef long r
1702
+ cdef fmpz_mat_t Aclear
1703
+ cdef fmpz_t den
1692
1704
 
1693
1705
  sig_on()
1694
- r = fmpq_mat_rref(self._matrix, self._matrix)
1706
+
1707
+ if algorithm == 'flint':
1708
+ r = fmpq_mat_rref(self._matrix, self._matrix)
1709
+ elif algorithm == 'flint:classical':
1710
+ r = fmpq_mat_rref_classical(self._matrix, self._matrix)
1711
+ else:
1712
+ # copied from fmpq_mat_rref_fraction_free
1713
+ fmpz_mat_init(Aclear, self._nrows, self._ncols)
1714
+ fmpq_mat_get_fmpz_mat_rowwise(Aclear, NULL, self._matrix)
1715
+ fmpz_init(den)
1716
+
1717
+ if algorithm == 'flint:fflu':
1718
+ r = fmpz_mat_rref_fflu(Aclear, den, Aclear)
1719
+ else:
1720
+ assert algorithm == 'flint:multimodular'
1721
+ r = fmpz_mat_rref_mul(Aclear, den, Aclear)
1722
+
1723
+ if r == 0:
1724
+ fmpq_mat_zero(self._matrix)
1725
+ else:
1726
+ fmpq_mat_set_fmpz_mat_div_fmpz(self._matrix, Aclear, den)
1727
+
1728
+ fmpz_mat_clear(Aclear)
1729
+ fmpz_clear(den)
1730
+
1695
1731
  sig_off()
1696
1732
 
1697
1733
  # compute pivots
@@ -237,7 +237,7 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
237
237
  cdef mpq_vector* v
238
238
 
239
239
  # Build a table that gives the nonzero positions in each column of right
240
- nonzero_positions_in_columns = [set([]) for _ in range(right._ncols)]
240
+ nonzero_positions_in_columns = [set() for _ in range(right._ncols)]
241
241
  cdef Py_ssize_t i, j, k
242
242
  for i in range(right._nrows):
243
243
  v = &(right._matrix[i])
@@ -375,7 +375,7 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
375
375
  cdef mpz_t x, h
376
376
  mpz_init(x)
377
377
  mpz_init_set_si(h, 0)
378
- cdef int i, j
378
+ cdef Py_ssize_t i, j
379
379
  sig_on()
380
380
  for i from 0 <= i < self._nrows:
381
381
  for j from 0 <= j < self._matrix[i].num_nonzero:
@@ -539,7 +539,7 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
539
539
  [ 0 0 1 238/157]
540
540
  [ 0 0 0 0]
541
541
  """
542
- label = 'echelon_form_%s'%algorithm
542
+ label = 'echelon_form_%s' % algorithm
543
543
  x = self.fetch(label)
544
544
  if x is not None:
545
545
  return x
@@ -213,7 +213,7 @@ cdef class Dist(ModuleElement):
213
213
  scalar = new_base(left)
214
214
  return V([scalar * new_base(self.moment(i)) for i in range(self.precision_absolute())])
215
215
 
216
- def is_zero(self, p=None, M=None):
216
+ def is_zero(self, p=None, M=None) -> bool:
217
217
  r"""
218
218
  Return ``True`` if the `i`-th moment is zero for all `i` (case ``M`` is
219
219
  ``None``) or zero modulo `p^{M-i}` for all `i` (when ``M`` is not
@@ -387,7 +387,7 @@ cdef class Dist(ModuleElement):
387
387
  raise ValueError("not a scalar multiple")
388
388
  v = a.valuation(p)
389
389
  if n - i - v > relprec:
390
- verbose("Reseting alpha: relprec=%s, n-i=%s, v=%s" % (relprec, n - i, v), level = 2)
390
+ verbose("Resetting alpha: relprec=%s, n-i=%s, v=%s" % (relprec, n - i, v), level = 2)
391
391
  relprec = n - i - v
392
392
  if padic:
393
393
  alpha = (other._unscaled_moment(i) / a).add_bigoh(n - i)
sage/quivers/algebra.py CHANGED
@@ -21,8 +21,9 @@ Path Algebras
21
21
  # https://www.gnu.org/licenses/
22
22
  # ****************************************************************************
23
23
 
24
- from sage.misc.cachefunc import cached_method
25
24
  from sage.combinat.free_module import CombinatorialFreeModule
25
+ from sage.misc.cachefunc import cached_method
26
+
26
27
  from .algebra_elements import PathAlgebraElement
27
28
 
28
29