From bbe11ba55eb272b53b644b10613c3731978fafdf Mon Sep 17 00:00:00 2001
From: Germain Poullot
- This is a tour of Sage that closely follows the tour of
- Mathematica that is at the beginning of the Mathematica
- Book.
+ A one page introduction to Sage as a handy calculator.
= PowerSeriesRing(GF(11), implementation='pari') sage: f = q - q^3 + O(q^10) sage: f.map_coefficients(lambda c: c - 2) @@ -1504,26 +1505,26 @@ cdef class PowerSeries(AlgebraElement): def sqrt(self, prec=None, extend=False, all=False, name=None): r""" - Return a square root of self. + Return a square root of ``self``. INPUT: - - ``prec`` - integer (default: None): if not None and the series + - ``prec`` -- integer (default: ``None``): if not ``None`` and the series has infinite precision, truncates series at precision - prec. + ``prec``. - - ``extend`` - bool (default: False); if True, return a square + - ``extend`` -- bool (default: ``False``); if ``True``, return a square root in an extension ring, if necessary. Otherwise, raise - a ValueError if the square root is not in the base power series - ring. For example, if ``extend`` is True the square root of a + a :class:`ValueError` if the square root is not in the base power series + ring. For example, if ``extend`` is ``True``, the square root of a power series with odd degree leading coefficient is defined as an element of a formal extension ring. - - ``name`` - string; if ``extend`` is True, you must also specify the print + - ``name`` -- string; if ``extend`` is True, you must also specify the print name of the formal square root. - - ``all`` - bool (default: False); if True, return all square - roots of self, instead of just one. + - ``all`` -- bool (default: ``False``); if ``True``, return all square + roots of ``self``, instead of just one. ALGORITHM: Newton's method @@ -1536,20 +1537,22 @@ cdef class PowerSeries(AlgebraElement): sage: K.= PowerSeriesRing(QQ, 't', 5) sage: sqrt(t^2) t - sage: sqrt(1+t) + sage: sqrt(1 + t) 1 + 1/2*t - 1/8*t^2 + 1/16*t^3 - 5/128*t^4 + O(t^5) - sage: sqrt(4+t) + sage: sqrt(4 + t) 2 + 1/4*t - 1/64*t^2 + 1/512*t^3 - 5/16384*t^4 + O(t^5) - sage: u = sqrt(2+t, prec=2, extend=True, name = 'alpha'); u + sage: u = sqrt(2 + t, prec=2, extend=True, name = 'alpha'); u alpha sage: u^2 2 + t sage: u.parent() - Univariate Quotient Polynomial Ring in alpha over Power Series Ring in t over Rational Field with modulus x^2 - 2 - t + Univariate Quotient Polynomial Ring in alpha + over Power Series Ring in t over Rational Field + with modulus x^2 - 2 - t sage: K. = PowerSeriesRing(QQ, 't', 50) - sage: sqrt(1+2*t+t^2) + sage: sqrt(1 + 2*t + t^2) 1 + t - sage: sqrt(t^2 +2*t^4 + t^6) + sage: sqrt(t^2 + 2*t^4 + t^6) t + t^3 sage: sqrt(1 + t + t^2 + 7*t^3)^2 1 + t + t^2 + 7*t^3 + O(t^50) @@ -1560,7 +1563,8 @@ cdef class PowerSeries(AlgebraElement): :: - sage: K. = PowerSeriesRing(CDF, 5) # needs sage.rings.complex_double + sage: # needs sage.rings.complex_double + sage: K. = PowerSeriesRing(CDF, 5) sage: v = sqrt(-1 + t + t^3, all=True); v [1.0*I - 0.5*I*t - 0.125*I*t^2 - 0.5625*I*t^3 - 0.2890625*I*t^4 + O(t^5), -1.0*I + 0.5*I*t + 0.125*I*t^2 + 0.5625*I*t^3 + 0.2890625*I*t^4 + O(t^5)] @@ -1576,7 +1580,9 @@ cdef class PowerSeries(AlgebraElement): sage: s^2 2*t + t^3 + O(t^4) sage: parent(s) - Univariate Quotient Polynomial Ring in sqrtf over Power Series Ring in t over Rational Field with modulus x^2 - 2*t - t^3 + O(t^4) + Univariate Quotient Polynomial Ring in sqrtf + over Power Series Ring in t over Rational Field + with modulus x^2 - 2*t - t^3 + O(t^4) TESTS:: @@ -1685,7 +1691,7 @@ cdef class PowerSeries(AlgebraElement): def square_root(self): """ - Return the square root of self in this ring. If this cannot be done + Return the square root of ``self`` in this ring. If this cannot be done, then an error will be raised. This function succeeds if and only if @@ -1694,14 +1700,15 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: sage: K. = PowerSeriesRing(QQ, 't', 5) - sage: (1+t).square_root() + sage: (1 + t).square_root() 1 + 1/2*t - 1/8*t^2 + 1/16*t^3 - 5/128*t^4 + O(t^5) - sage: (2+t).square_root() + sage: (2 + t).square_root() Traceback (most recent call last): ... ValueError: Square root does not live in this ring. - sage: (2+t.change_ring(RR)).square_root() - 1.41421356237309 + 0.353553390593274*t - 0.0441941738241592*t^2 + 0.0110485434560398*t^3 - 0.00345266983001244*t^4 + O(t^5) + sage: (2 + t.change_ring(RR)).square_root() # needs sage.rings.real_mpfr + 1.41421356237309 + 0.353553390593274*t - 0.0441941738241592*t^2 + + 0.0110485434560398*t^3 - 0.00345266983001244*t^4 + O(t^5) sage: t.square_root() Traceback (most recent call last): ... @@ -1710,7 +1717,7 @@ cdef class PowerSeries(AlgebraElement): sage: f = (1+t)^20 sage: f.square_root() 1 + 10*t + 45*t^2 + 120*t^3 + 210*t^4 + O(t^5) - sage: f = 1+t + sage: f = 1 + t sage: f.square_root() Traceback (most recent call last): ... @@ -2476,7 +2483,8 @@ cdef class PowerSeries(AlgebraElement): Check that `\exp(t)` is, well, `\exp(t)`:: sage: (t + O(t^10)).exp() - 1 + t + 1/2*t^2 + 1/6*t^3 + 1/24*t^4 + 1/120*t^5 + 1/720*t^6 + 1/5040*t^7 + 1/40320*t^8 + 1/362880*t^9 + O(t^10) + 1 + t + 1/2*t^2 + 1/6*t^3 + 1/24*t^4 + 1/120*t^5 + 1/720*t^6 + + 1/5040*t^7 + 1/40320*t^8 + 1/362880*t^9 + O(t^10) Check that `\exp(\log(1+t))` is `1+t`:: @@ -2486,7 +2494,8 @@ cdef class PowerSeries(AlgebraElement): Check that `\exp(2t + t^2 - t^5)` is whatever it is:: sage: (2*t + t^2 - t^5 + O(t^10)).exp() - 1 + 2*t + 3*t^2 + 10/3*t^3 + 19/6*t^4 + 8/5*t^5 - 7/90*t^6 - 538/315*t^7 - 425/168*t^8 - 30629/11340*t^9 + O(t^10) + 1 + 2*t + 3*t^2 + 10/3*t^3 + 19/6*t^4 + 8/5*t^5 - 7/90*t^6 + - 538/315*t^7 - 425/168*t^8 - 30629/11340*t^9 + O(t^10) Check requesting lower precision:: @@ -2507,6 +2516,7 @@ cdef class PowerSeries(AlgebraElement): Handle nonzero constant term (fixes :trac:`4477`):: + sage: # needs sage.rings.real_mpfr sage: R. = PowerSeriesRing(RR) sage: (1 + x + x^2 + O(x^3)).exp() 2.71828182845905 + 2.71828182845905*x + 4.07742274268857*x^2 + O(x^3) @@ -2517,7 +2527,8 @@ cdef class PowerSeries(AlgebraElement): sage: (1 + x + O(x^2)).exp() # needs sage.symbolic Traceback (most recent call last): ... - ArithmeticError: exponential of constant term does not belong to coefficient ring (consider working in a larger ring) + ArithmeticError: exponential of constant term does not belong + to coefficient ring (consider working in a larger ring) :: @@ -2567,7 +2578,8 @@ cdef class PowerSeries(AlgebraElement): sage: R. = PowerSeriesRing(QQ, default_prec=10) sage: (1 + t + O(t^10)).log() - t - 1/2*t^2 + 1/3*t^3 - 1/4*t^4 + 1/5*t^5 - 1/6*t^6 + 1/7*t^7 - 1/8*t^8 + 1/9*t^9 + O(t^10) + t - 1/2*t^2 + 1/3*t^3 - 1/4*t^4 + 1/5*t^5 - 1/6*t^6 + 1/7*t^7 + - 1/8*t^8 + 1/9*t^9 + O(t^10) sage: t.exp().log() t + O(t^10) @@ -2580,8 +2592,9 @@ cdef class PowerSeries(AlgebraElement): ... ArithmeticError: constant term of power series is not 1 + sage: # needs sage.rings.real_mpfr sage: R. = PowerSeriesRing(RR) - sage: (2+t).log().exp() + sage: (2 + t).log().exp() 2.00000000000000 + 1.00000000000000*t + O(t^20) """ if prec is None: From 36f7707773278c33c5619b9e6f514a5f95bcf99e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 14:50:46 -0700 Subject: [PATCH 046/494] src/sage/rings/polynomial/polynomial_element.pyx: Update # needs --- .../rings/polynomial/polynomial_element.pyx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index c0eb7e19f63..700f89267ee 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -8336,7 +8336,7 @@ cdef class Polynomial(CommutativePolynomial): Spurious crash with pari-2.5.5, see :trac:`16165`:: sage: f = (1+x+x^2)^3 - sage: f.roots(ring=CC) # needs sage.rings.real_mpfr + sage: f.roots(ring=CC) # needs sage.libs.pari sage.rings.real_mpfr [(-0.500000000000000 - 0.866025403784439*I, 3), (-0.500000000000000 + 0.866025403784439*I, 3)] @@ -8344,7 +8344,7 @@ cdef class Polynomial(CommutativePolynomial): sage: polRing. = PolynomialRing(ZZ) sage: j = (x+1)^2 * (x-1)^7 * (x^2-x+1)^5 - sage: j.roots(CC) # needs sage.rings.real_mpfr + sage: j.roots(CC) # needs sage.libs.pari sage.rings.real_mpfr [(-1.00000000000000, 2), (1.00000000000000, 7), (0.500000000000000 - 0.866025403784439*I, 5), @@ -8740,20 +8740,20 @@ cdef class Polynomial(CommutativePolynomial): EXAMPLES:: sage: x = polygen(ZZ) - sage: (x^2 - x - 1).real_roots() # needs sage.rings.real_mpfr + sage: (x^2 - x - 1).real_roots() # needs sage.libs.pari sage.rings.real_mpfr [-0.618033988749895, 1.61803398874989] TESTS:: - sage: x = polygen(RealField(100)) # needs sage.rings.real_mpfr - sage: (x^2 - x - 1).real_roots()[0].parent() # needs sage.rings.real_mpfr + sage: x = polygen(RealField(100)) # needs sage.libs.pari sage.rings.real_mpfr + sage: (x^2 - x - 1).real_roots()[0].parent() # needs sage.libs.pari sage.rings.real_mpfr Real Field with 100 bits of precision sage: x = polygen(RDF) sage: (x^2 - x - 1).real_roots()[0].parent() # needs numpy Real Double Field - sage: x = polygen(ZZ,'x'); v = (x^2 - x - 1).real_roots() # needs sage.rings.real_mpfr - sage: v[0].parent() is RR # needs sage.rings.real_mpfr + sage: x = polygen(ZZ,'x'); v = (x^2 - x - 1).real_roots() # needs sage.libs.pari sage.rings.real_mpfr + sage: v[0].parent() is RR # needs sage.libs.pari sage.rings.real_mpfr True """ K = self.base_ring() @@ -8775,15 +8775,16 @@ cdef class Polynomial(CommutativePolynomial): EXAMPLES:: + sage: # needs sage.libs.pari sage.rings.real_mpfr sage: x = polygen(ZZ) - sage: (x^3 - 1).complex_roots() # note: low order bits slightly different on ppc. # needs sage.rings.real_mpfr + sage: (x^3 - 1).complex_roots() # note: low order bits slightly different on ppc. [1.00000000000000, -0.500000000000000 - 0.86602540378443...*I, -0.500000000000000 + 0.86602540378443...*I] TESTS:: - sage: # needs sage.rings.real_mpfr + sage: # needs sage.libs.pari sage.rings.real_mpfr sage: x = polygen(RR) sage: (x^3 - 1).complex_roots()[0].parent() Complex Field with 53 bits of precision From 35c223227f6bf11f71d202685156f92cce1f0e0a Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 15:31:22 -0700 Subject: [PATCH 047/494] Fix # needs for sagemath-pari --- src/sage/rings/factorint_pari.pyx | 1 + src/sage/rings/finite_rings/residue_field.pyx | 11 +++++----- .../rings/function_field/element_rational.pyx | 2 +- .../rings/polynomial/laurent_polynomial.pyx | 6 +++--- .../polynomial/multi_polynomial_sequence.py | 8 +++---- .../rings/polynomial/polynomial_element.pyx | 21 ++++++++++--------- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/sage/rings/factorint_pari.pyx b/src/sage/rings/factorint_pari.pyx index 8e5ed7c619e..862b7baa5b8 100644 --- a/src/sage/rings/factorint_pari.pyx +++ b/src/sage/rings/factorint_pari.pyx @@ -1,3 +1,4 @@ +# sage_setup: distribution = sagemath-pari # sage.doctest: needs sage.libs.pari r""" Integer factorization using PARI diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx index b466ee5e2c1..c5973c6f1dc 100644 --- a/src/sage/rings/finite_rings/residue_field.pyx +++ b/src/sage/rings/finite_rings/residue_field.pyx @@ -1293,7 +1293,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism): sage: # needs sage.rings.finite_rings sage: R. = GF(2)[]; P = R.ideal(t^7 + t^6 + t^5 + t^4 + 1) sage: k = P.residue_field(); f = k.coerce_map_from(R) - sage: f(t^10) + sage: f(t^10) # needs sage.modules tbar^6 + tbar^3 + tbar^2 """ self._K = K @@ -1482,7 +1482,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism): sage: k. = P.residue_field(); f = k.coerce_map_from(R) sage: f.lift(a^2 + 5*a + 1) t^2 + 5*t + 1 - sage: f(f.lift(a^2 + 5*a + 1)) == a^2 + 5*a + 1 + sage: f(f.lift(a^2 + 5*a + 1)) == a^2 + 5*a + 1 # needs sage.modules True """ if self.domain() is ZZ: @@ -1780,12 +1780,11 @@ class ResidueFiniteField_prime_modn(ResidueField_generic, FiniteField_prime_modn EXAMPLES:: - sage: # needs sage.rings.number_field + sage: # needs sage.modules sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^3 - 7) sage: P = K.ideal(29).factor()[1][0] - sage: k = ResidueField(P) - sage: k + sage: k = ResidueField(P); k Residue field of Fractional ideal (-a^2 - 2*a - 2) sage: OK = K.maximal_order() sage: c = OK(a) @@ -1799,7 +1798,7 @@ class ResidueFiniteField_prime_modn(ResidueField_generic, FiniteField_prime_modn sage: k(v) # indirect doctest 3 - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: R. = GF(2)[]; P = R.ideal(t + 1); k. = P.residue_field() sage: V = k.vector_space(map=False); v = V([1]) sage: k(v) diff --git a/src/sage/rings/function_field/element_rational.pyx b/src/sage/rings/function_field/element_rational.pyx index 0d306d6826e..a23532dacd3 100644 --- a/src/sage/rings/function_field/element_rational.pyx +++ b/src/sage/rings/function_field/element_rational.pyx @@ -390,7 +390,7 @@ cdef class FunctionFieldElement_rational(FunctionFieldElement): sage: f = (x+1)/(x-1) sage: f.is_nth_power(1) True - sage: f.is_nth_power(3) + sage: f.is_nth_power(3) # needs sage.modules False sage: (f^3).is_nth_power(3) True diff --git a/src/sage/rings/polynomial/laurent_polynomial.pyx b/src/sage/rings/polynomial/laurent_polynomial.pyx index 6515cf17e1a..8285d3a37db 100644 --- a/src/sage/rings/polynomial/laurent_polynomial.pyx +++ b/src/sage/rings/polynomial/laurent_polynomial.pyx @@ -260,9 +260,9 @@ cdef class LaurentPolynomial(CommutativeAlgebraElement): sage: f = x*a + a sage: f.map_coefficients(lambda a: a + 1) (a + 1) + (a + 1)*x - sage: R. = LaurentPolynomialRing(k, 2) - sage: f = x*a + 2*x^3*y*a + a - sage: f.map_coefficients(lambda a: a + 1) + sage: R. = LaurentPolynomialRing(k, 2) # needs sage.modules + sage: f = x*a + 2*x^3*y*a + a # needs sage.modules + sage: f.map_coefficients(lambda a: a + 1) # needs sage.modules (2*a + 1)*x^3*y + (a + 1)*x + a + 1 Examples with different base ring:: diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py index 8088eb3349c..b52fb34f721 100644 --- a/src/sage/rings/polynomial/multi_polynomial_sequence.py +++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py @@ -394,22 +394,22 @@ def __init__(self, parts, ring, immutable=False, cr=False, cr_str=None): EXAMPLES:: sage: P. = PolynomialRing(GF(127), 4) - sage: I = sage.rings.ideal.Katsura(P) # needs sage.rings.finite_rings + sage: I = sage.rings.ideal.Katsura(P) # needs sage.libs.singular - sage: Sequence([I.gens()], I.ring()) # indirect doctest # needs sage.rings.finite_rings + sage: Sequence([I.gens()], I.ring()) # indirect doctest # needs sage.libs.singular [a + 2*b + 2*c + 2*d - 1, a^2 + 2*b^2 + 2*c^2 + 2*d^2 - a, 2*a*b + 2*b*c + 2*c*d - b, b^2 + 2*a*c + 2*b*d - c] If an ideal is provided, the generators are used.:: - sage: Sequence(I) # needs sage.rings.finite_rings + sage: Sequence(I) # needs sage.libs.singular [a + 2*b + 2*c + 2*d - 1, a^2 + 2*b^2 + 2*c^2 + 2*d^2 - a, 2*a*b + 2*b*c + 2*c*d - b, b^2 + 2*a*c + 2*b*d - c] If a list of polynomials is provided, the system has only one part.:: - sage: Sequence(I.gens(), I.ring()) # needs sage.rings.finite_rings + sage: Sequence(I.gens(), I.ring()) # needs sage.libs.singular [a + 2*b + 2*c + 2*d - 1, a^2 + 2*b^2 + 2*c^2 + 2*d^2 - a, 2*a*b + 2*b*c + 2*c*d - b, b^2 + 2*a*c + 2*b*d - c] """ diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 700f89267ee..5b85be6bc19 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -6881,9 +6881,9 @@ cdef class Polynomial(CommutativePolynomial): sage: R. = QQ[] sage: S. = R[] sage: f = x^2 + a; g = y^3 + a - sage: h = f.resultant(g); h # needs sage.libs.pari + sage: h = f.resultant(g); h # needs sage.libs.pari sage.modules y^3 - x^2 - sage: h.parent() is R # needs sage.libs.pari + sage: h.parent() is R # needs sage.libs.pari sage.modules True Check that :trac:`13672` is fixed:: @@ -7342,9 +7342,9 @@ cdef class Polynomial(CommutativePolynomial): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.libs.singular sage: f = cyclotomic_polynomial(30) - sage: f.adams_operator(7)==f + sage: f.adams_operator(7) == f True sage: f.adams_operator(6) == cyclotomic_polynomial(5)**2 True @@ -7505,7 +7505,7 @@ cdef class Polynomial(CommutativePolynomial): -31 sage: d.parent() is QQ # needs sage.libs.pari True - sage: EllipticCurve([1, 1]).discriminant()/16 # needs sage.libs.pari + sage: EllipticCurve([1, 1]).discriminant()/16 # needs sage.libs.pari sage.schemes -31 :: @@ -7733,7 +7733,7 @@ cdef class Polynomial(CommutativePolynomial): sage: f = x^3 - 1 sage: f.roots() [(1, 1)] - sage: f.roots(ring=CC) # ... - low order bits slightly different on ppc + sage: f.roots(ring=CC) # ... - low order bits slightly different on ppc # needs sage.rings.real_mpfr [(1.00000000000000, 1), (-0.500000000000000 - 0.86602540378443...*I, 1), (-0.500000000000000 + 0.86602540378443...*I, 1)] @@ -8274,9 +8274,10 @@ cdef class Polynomial(CommutativePolynomial): TESTS:: - sage: K. = CyclotomicField(2) # needs sage.rings.number_field - sage: R. = K[] # needs sage.rings.number_field - sage: factor(x^3 - 1) # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(2) + sage: R. = K[] + sage: factor(x^3 - 1) (x - 1) * (x^2 + x + 1) This shows that the issue from :trac:`6237` is fixed:: @@ -10834,7 +10835,7 @@ cdef class Polynomial(CommutativePolynomial): Some random tests:: - sage: for R in [QQ['x'], GF(4)['x']]: # needs sage.rings.finite_rings + sage: for R in [QQ['x'], GF(4)['x']]: # needs sage.modules sage.rings.finite_rings ....: for _ in range(30): ....: p = R.random_element(degree=randint(10,20)) ....: n = ZZ.random_element(2,20) From d7cf4a754982557a439b66ede881983f0fe86556 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 19:58:44 -0700 Subject: [PATCH 048/494] sage.rings: Update # needs --- src/sage/rings/factorint.pyx | 2 +- .../rings/finite_rings/element_pari_ffelt.pyx | 3 +++ src/sage/rings/finite_rings/integer_mod.pyx | 9 ++++---- .../rings/polynomial/multi_polynomial.pyx | 6 ++--- .../rings/polynomial/polynomial_element.pyx | 4 ++-- .../polynomial/polynomial_quotient_ring.py | 21 +++++++++--------- .../polynomial_quotient_ring_element.py | 22 +++++++++---------- src/sage/rings/polynomial/polynomial_ring.py | 7 +++--- src/sage/rings/power_series_pari.pyx | 8 ++++--- src/sage/rings/rational_field.py | 2 +- src/sage/rings/ring.pyx | 6 ++--- src/sage/rings/tests.py | 2 +- 12 files changed, 49 insertions(+), 43 deletions(-) diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index 95f91424164..32116f9de0a 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -135,7 +135,7 @@ cpdef factor_aurifeuillian(n, check=True): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.rings.real_interval_field sage: from sage.rings.factorint import factor_aurifeuillian as fa sage: fa(2^6 + 1) [5, 13] diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx index 30ad3075da6..845df74b840 100644 --- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx @@ -873,6 +873,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): TESTS:: + sage: # needs sage.modules sage: F. = GF(13^64, impl='pari_ffelt'); F Finite Field in a of size 13^64 sage: x = F.random_element() @@ -885,6 +886,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement): sage: x.pth_power(-1)**13 == x True + sage: # needs sage.modules sage: F. = GF(127^16, impl='pari_ffelt'); F Finite Field in a of size 127^16 sage: x = F.random_element() @@ -1386,6 +1388,7 @@ def unpickle_FiniteFieldElement_pari_ffelt(parent, elem): """ EXAMPLES:: + sage: # needs sage.modules sage: k. = GF(2^20, impl='pari_ffelt') sage: e = k.random_element() sage: f = loads(dumps(e)) # indirect doctest diff --git a/src/sage/rings/finite_rings/integer_mod.pyx b/src/sage/rings/finite_rings/integer_mod.pyx index 38dd4569c7f..be1d9ca5322 100644 --- a/src/sage/rings/finite_rings/integer_mod.pyx +++ b/src/sage/rings/finite_rings/integer_mod.pyx @@ -656,7 +656,7 @@ cdef class IntegerMod_abstract(FiniteRingElement): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.modules sage: r = Integers(125) sage: b = r.multiplicative_generator()^3 sage: a = b^17 @@ -825,10 +825,11 @@ cdef class IntegerMod_abstract(FiniteRingElement): EXAMPLES:: + sage: m = Mod(3, 1568) - sage: v = m.generalised_log(); v # needs sage.libs.pari + sage: v = m.generalised_log(); v # needs sage.libs.pari sage.modules [1, 3, 1] - sage: prod([Zmod(1568).unit_gens()[i] ** v[i] for i in [0..2]]) # needs sage.libs.pari + sage: prod([Zmod(1568).unit_gens()[i] ** v[i] for i in [0..2]]) # needs sage.libs.pari sage.modules 3 .. SEEALSO:: @@ -924,7 +925,7 @@ cdef class IntegerMod_abstract(FiniteRingElement): 1 sage: a.polynomial() 1 - sage: type(a.polynomial()) # needs sage.rings.finite_rings + sage: type(a.polynomial()) # needs sage.libs.flint """ R = self.parent()[var] diff --git a/src/sage/rings/polynomial/multi_polynomial.pyx b/src/sage/rings/polynomial/multi_polynomial.pyx index dee2a02e2c6..bee78170e99 100644 --- a/src/sage/rings/polynomial/multi_polynomial.pyx +++ b/src/sage/rings/polynomial/multi_polynomial.pyx @@ -1549,9 +1549,9 @@ cdef class MPolynomial(CommutativePolynomial): sage: f = x^5*y + 3*x^2*y^2 - 2*x + y - 1 sage: f.discriminant(y) # needs sage.libs.singular x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 - sage: f.polynomial(y).discriminant() # needs sage.libs.pari + sage: f.polynomial(y).discriminant() # needs sage.libs.pari sage.modules x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 - sage: f.discriminant(y).parent() == f.polynomial(y).discriminant().parent() # needs sage.libs.singular + sage: f.discriminant(y).parent() == f.polynomial(y).discriminant().parent() # needs sage.libs.singular sage.modules False TESTS: @@ -1561,7 +1561,7 @@ cdef class MPolynomial(CommutativePolynomial): sage: # needs sage.rings.number_field sage: R. = QQbar[] sage: f = x^5*y + 3*x^2*y^2 - 2*x + y - 1 - sage: f.discriminant(y) + sage: f.discriminant(y) # needs sage.libs.singular x^10 + 2*x^5 + 24*x^3 + 12*x^2 + 1 AUTHOR: Miguel Marco diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 5b85be6bc19..d5873f3971c 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -2980,8 +2980,8 @@ cdef class Polynomial(CommutativePolynomial): sage: D = d0 + d1*y + d2*y^2 + d3*y^3 + d4*y^4 + d5*y^5 + d6*y^6 + d7*y^7 sage: F = D.subs({y: B}) sage: G = A.subs({y: F}) + C - sage: g = G.mod(y^8 + y) - sage: g.degree(y) + sage: g = G.mod(y^8 + y) # needs sage.libs.singular + sage: g.degree(y) # needs sage.libs.singular 7 """ return self % other diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index e372be888ee..894336def89 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -1099,7 +1099,7 @@ def is_integral_domain(self, proof=True): sage: U.is_integral_domain() False sage: R2. = PolynomialRing(R) - sage: S2 = R2.quotient(z^2 - y^3) + sage: S2 = R2.quotient(z^2 - y^3) # needs sage.libs.singular sage: S2.is_integral_domain() # needs sage.libs.singular True sage: S3 = R2.quotient(z^2 - 2*y*z + y^2) @@ -1915,7 +1915,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): sage: K. = FunctionField(l) sage: R. = K[] sage: F = t * x - sage: F.factor(proof=False) + sage: F.factor(proof=False) # needs sage.modules (x) * t """ @@ -1945,9 +1945,9 @@ def _factor_univariate_polynomial(self, f): sage: R. = M[] sage: R(y).factor() # indirect doctest y - sage: (T^2 + T + x).factor() # indirect doctest + sage: (T^2 + T + x).factor() # indirect doctest # needs sage.modules (T + y) * (T + y + 1) - sage: (y*T^2 + y*T + y*x).factor() # indirect doctest + sage: (y*T^2 + y*T + y*x).factor() # indirect doctest # needs sage.modules (y) * (T + y) * (T + y + 1) """ @@ -1988,7 +1988,7 @@ def _isomorphic_ring(self): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: K. = GF(4) sage: R. = K[] sage: L. = K.extension(b^2 + b + a); L @@ -1996,14 +1996,13 @@ def _isomorphic_ring(self): over Finite Field in a of size 2^2 with modulus b^2 + b + a sage: from_M, to_M, M = L._isomorphic_ring(); M Finite Field in z4 of size 2^4 - - sage: R. = L[] # needs sage.rings.finite_rings - sage: M. = L.extension(c^2 + b*c + b); M # needs sage.rings.finite_rings + sage: R. = L[] + sage: M. = L.extension(c^2 + b*c + b); M Univariate Quotient Polynomial Ring in c over Univariate Quotient Polynomial Ring in b over Finite Field in a of size 2^2 with modulus b^2 + b + a with modulus c^2 + b*c + b - sage: from_N, to_N, N = M._isomorphic_ring(); N # needs sage.rings.finite_rings + sage: from_N, to_N, N = M._isomorphic_ring(); N Finite Field in z8 of size 2^8 sage: R. = QQ[] @@ -2135,7 +2134,7 @@ def _test_isomorphic_ring(self, **options): TESTS:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: K. = GF(4) sage: R. = K[] sage: L. = K.extension(b^2 + b + a) @@ -2367,7 +2366,7 @@ def field_extension(self, names): Over a finite field, the corresponding field extension is not a number field:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: R. = GF(25, 'a')['x'] sage: S. = R.quo(x^3 + 2*x + 1) sage: F, g, h = S.field_extension('b') diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py index 4185f0d1455..56f1522a19b 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py @@ -592,7 +592,7 @@ def charpoly(self, var): sage: R. = PolynomialRing(QQ) sage: S. = R.quo(x^3 -389*x^2 + 2*x - 5) - sage: a.charpoly('X') + sage: a.charpoly('X') # needs sage.modules X^3 - 389*X^2 + 2*X - 5 """ return self.matrix().charpoly(var) @@ -606,9 +606,9 @@ def fcp(self, var='x'): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 -389*x^2 + 2*x - 5) - sage: a.fcp('x') + sage: a.fcp('x') # needs sage.modules x^3 - 389*x^2 + 2*x - 5 - sage: S(1).fcp('y') + sage: S(1).fcp('y') # needs sage.modules (y - 1)^3 """ return self.charpoly(var).factor() @@ -621,7 +621,7 @@ def lift(self): EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: S. = R.quotient(x^3-2) + sage: S. = R.quotient(x^3 - 2) sage: b = a^2 - 3 sage: b a^2 - 3 @@ -661,7 +661,7 @@ def matrix(self): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 + 2*x - 5) - sage: a.matrix() + sage: a.matrix() # needs sage.modules [ 0 1 0] [ 0 0 1] [ 5 -2 0] @@ -699,9 +699,9 @@ def minpoly(self): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 + 2*x - 5) - sage: (a + 123).minpoly() + sage: (a + 123).minpoly() # needs sage.modules x^3 - 369*x^2 + 45389*x - 1861118 - sage: (a + 123).matrix().minpoly() + sage: (a + 123).matrix().minpoly() # needs sage.modules x^3 - 369*x^2 + 45389*x - 1861118 One useful application of this function is to compute a minimal @@ -711,10 +711,10 @@ def minpoly(self): sage: # needs sage.rings.finite_rings sage: F2. = GF((431,2), modulus=[1,0,1]) sage: F6. = F2.extension(3) - sage: (u + 1).minpoly() + sage: (u + 1).minpoly() # needs sage.modules x^6 + 425*x^5 + 19*x^4 + 125*x^3 + 189*x^2 + 239*x + 302 sage: ext = F6.over(F2) - sage: ext(u + 1).minpoly() # indirect doctest + sage: ext(u + 1).minpoly() # indirect doctest # needs sage.modules x^3 + (396*i + 428)*x^2 + (80*i + 39)*x + 9*i + 178 TESTS: @@ -750,7 +750,7 @@ def norm(self): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 - 389*x^2 + 2*x - 5) - sage: a.norm() + sage: a.norm() # needs sage.modules 5 """ return self.matrix().determinant() @@ -763,7 +763,7 @@ def trace(self): EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: S. = R.quotient(x^3 -389*x^2 + 2*x - 5) + sage: S. = R.quotient(x^3 - 389*x^2 + 2*x - 5) sage: a.trace() 389 """ diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index 2878ed7f648..123db470a62 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -1057,10 +1057,11 @@ def change_ring(self, R): EXAMPLES:: - sage: R. = RealIntervalField()[]; R # needs sage.rings.real_interval_field + sage: # needs sage.rings.finite_rings sage.rings.real_interval_field + sage: R. = RealIntervalField()[]; R Univariate Polynomial Ring in ZZZ over Real Interval Field with 53 bits of precision - sage: R.change_ring(GF(19^2, 'b')) # needs sage.rings.finite_rings + sage: R.change_ring(GF(19^2, 'b')) Univariate Polynomial Ring in ZZZ over Finite Field in b of size 19^2 """ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing @@ -2591,7 +2592,7 @@ def irreducible_element(self, n, algorithm=None): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage: f = GF(5^3, 'a')['x'].irreducible_element(2) sage: f.degree() 2 diff --git a/src/sage/rings/power_series_pari.pyx b/src/sage/rings/power_series_pari.pyx index 94a6d1baacb..dc84fdbc162 100644 --- a/src/sage/rings/power_series_pari.pyx +++ b/src/sage/rings/power_series_pari.pyx @@ -9,7 +9,7 @@ PARI by passing the keyword ``implementation='pari'`` to the sage: R. = PowerSeriesRing(ZZ, implementation='pari'); R Power Series Ring in q over Integer Ring - sage: S.= PowerSeriesRing(CC, implementation='pari'); S + sage: S. = PowerSeriesRing(CC, implementation='pari'); S # needs sage.rings.real_mpfr Power Series Ring in t over Complex Field with 53 bits of precision Note that only the type of the elements depends on the implementation, @@ -19,9 +19,9 @@ not the type of the parents:: sage: type(q) - sage: type(S) + sage: type(S) # needs sage.rings.real_mpfr - sage: type(t) + sage: type(t) # needs sage.rings.real_mpfr If `k` is a finite field implemented using PARI, this is the default @@ -137,6 +137,7 @@ cdef class PowerSeries_pari(PowerSeries): TESTS:: + sage: # needs sage.rings.real_mpfr sage: R. = PowerSeriesRing(CC, implementation='pari') sage: TestSuite(q).run() sage: f = q - q^3 + O(q^10) @@ -664,6 +665,7 @@ cdef class PowerSeries_pari(PowerSeries): sage: f.list() [1, 0, 0, -5, 0, 1] + sage: # needs sage.rings.padics sage: S. = PowerSeriesRing(pAdicRing(5), implementation='pari') sage: (2 + u).list() [2 + O(5^20), 1 + O(5^20)] diff --git a/src/sage/rings/rational_field.py b/src/sage/rings/rational_field.py index 104c5463bf5..2938796b655 100644 --- a/src/sage/rings/rational_field.py +++ b/src/sage/rings/rational_field.py @@ -1424,7 +1424,7 @@ def selmer_space(self, S, p, proof=None): sage: QS2gens # needs sage.rings.number_field [-1] - sage: all(QQ.selmer_space([], p)[0].dimension() == 0 # needs sage.libs.pari + sage: all(QQ.selmer_space([], p)[0].dimension() == 0 # needs sage.libs.pari sage.rings.number_field ....: for p in primes(3, 10)) True diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx index 4fe45ed2c59..cf75edd4099 100644 --- a/src/sage/rings/ring.pyx +++ b/src/sage/rings/ring.pyx @@ -533,10 +533,10 @@ cdef class Ring(ParentWithGens):sage: S._ideal_class_(2) - sage: T. = S[] # needs sage.rings.finite_rings - sage: T._ideal_class_(5) # needs sage.rings.finite_rings + sage: T. = S[] # needs sage.libs.singular + sage: T._ideal_class_(5) # needs sage.libs.singular - sage: T._ideal_class_(1) # needs sage.rings.finite_rings + sage: T._ideal_class_(1) # needs sage.libs.singular Since :trac:`7797`, non-commutative rings have ideals as well:: diff --git a/src/sage/rings/tests.py b/src/sage/rings/tests.py index 13a205195d5..3eed7e1aa31 100644 --- a/src/sage/rings/tests.py +++ b/src/sage/rings/tests.py @@ -445,7 +445,7 @@ def test_karatsuba_multiplication(base_ring, maxdeg1, maxdeg2, sage: rings += [ZZ[I], ZZ[I, sqrt(2)]] # needs sage.rings.number_field sage.symbolic sage: rings += [GF(49, 'a')] # needs sage.rings.finite_rings sage: rings += [MatrixSpace(GF(17), 3)] # needs sage.modules - sage: for C in rings: + sage: for C in rings: # needs sage.modules ....: test_karatsuba_multiplication(C, 10, 10) Zero-tests over ``QQbar`` are currently very slow, so we test only very small examples:: From 5ffeedfbc411f2342774895217bddc67f2d7b771 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Sep 2023 01:01:30 -0700 Subject: [PATCH 049/494] sage.rings: Update # needs --- src/sage/rings/factorint.pyx | 3 +- src/sage/rings/finite_rings/element_base.pyx | 28 +++++++++++-------- .../finite_rings/residue_field_pari_ffelt.pyx | 8 +++--- src/sage/rings/morphism.pyx | 10 +++---- src/sage/rings/polynomial/flatten.py | 2 +- .../rings/polynomial/polynomial_element.pyx | 5 ++-- 6 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index 32116f9de0a..7a441eabad6 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -154,7 +154,8 @@ cpdef factor_aurifeuillian(n, check=True): TESTS:: - sage: for n in [2,3,5,6,30,31,33]: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.rings.real_interval_field + sage: for n in [2,3,5,6,30,31,33]: ....: for m in [8,96,109201283]: ....: s = -1 if n % 4 == 1 else 1 ....: y = (m^2*n)^n + s diff --git a/src/sage/rings/finite_rings/element_base.pyx b/src/sage/rings/finite_rings/element_base.pyx index e9ab5b5d4ab..08f76c59927 100755 --- a/src/sage/rings/finite_rings/element_base.pyx +++ b/src/sage/rings/finite_rings/element_base.pyx @@ -268,6 +268,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): TESTS:: + sage: # needs sage.modules sage: F,t = GF(random_prime(99)^randrange(2,99), 't').objgen() sage: a = F.random_element() sage: all(a[i] == a.polynomial()[i] for i in range(F.degree())) @@ -290,7 +291,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): EXAMPLES:: sage: x = polygen(GF(71)) - sage: F. = GF(71^7, modulus=x^7+x+1) + sage: F. = GF(71^7, modulus=x^7 + x + 1) sage: a = 3 + u + 3*u^2 + 3*u^3 + 7*u^4 sage: a.list() [3, 1, 3, 3, 7, 0, 0] @@ -308,6 +309,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): TESTS:: + sage: # needs sage.modules sage: R. = GF(17)[] sage: F. = GF(17^60) sage: a = F.random_element() @@ -351,6 +353,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): TESTS:: + sage: # needs sage.modules sage: F = GF(random_prime(333)^randrange(111,999),'t') sage: a = F.random_element() sage: list(a) == a.list() # implicit doctest @@ -358,6 +361,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): :: + sage: # needs sage.modules sage: F. = GF(17^60) sage: a = F.random_element() sage: a == sum(c*t^i for i,c in enumerate(a)) # implicit doctest @@ -365,7 +369,8 @@ cdef class FinitePolyExtElement(FiniteRingElement): :: - sage: F. = GF((2^127-1)^10, 't') + sage: # needs sage.modules + sage: F. = GF((2^127 - 1)^10, 't') sage: a = F.random_element() sage: a == sum(c*t^i for i,c in enumerate(a)) # implicit doctest True @@ -431,6 +436,7 @@ cdef class FinitePolyExtElement(FiniteRingElement): EXAMPLES:: + sage: # needs sage.modules sage: k. = GF(2^4) sage: b = k.random_element() sage: vector(a*b) == a.matrix() * vector(b) @@ -557,18 +563,18 @@ cdef class FinitePolyExtElement(FiniteRingElement): def charpoly(self, var='x', algorithm='pari'): """ - Return the characteristic polynomial of self as a polynomial with given variable. + Return the characteristic polynomial of ``self`` as a polynomial with given variable. INPUT: - ``var`` -- string (default: 'x') - - ``algorithm`` -- string (default: 'pari') + - ``algorithm`` -- string (default: ``'pari'``) - - 'pari' -- use pari's charpoly + - ``'pari'`` -- use pari's charpoly - - 'matrix' -- return the charpoly computed from the matrix of - left multiplication by self + - ``'matrix'`` -- return the charpoly computed from the matrix of + left multiplication by ``self`` The result is not cached. @@ -578,10 +584,10 @@ cdef class FinitePolyExtElement(FiniteRingElement): sage: k. = FiniteField(19^2) sage: parent(a) Finite Field in a of size 19^2 - sage: b=a**20 - sage: p=FinitePolyExtElement.charpoly(b,"x", algorithm="pari") - sage: q=FinitePolyExtElement.charpoly(b,"x", algorithm="matrix") - sage: q == p + sage: b = a**20 + sage: p = FinitePolyExtElement.charpoly(b, "x", algorithm="pari") + sage: q = FinitePolyExtElement.charpoly(b, "x", algorithm="matrix") # needs sage.modules + sage: q == p # needs sage.modules True sage: p x^2 + 15*x + 4 diff --git a/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx b/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx index 375b3b4cdfc..f21a3b8d9bb 100644 --- a/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx +++ b/src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx @@ -110,15 +110,15 @@ class ResidueFiniteField_pari_ffelt(ResidueField_generic, FiniteField_pari_ffelt 7521*alpha + 4131 sage: ff(17/3) 6677 - sage: V = ff.vector_space(map=False); v = V([3,-2]) - sage: type(ff.convert_map_from(V)) + sage: V = ff.vector_space(map=False); v = V([3,-2]) # needs sage.modules + sage: type(ff.convert_map_from(V)) # needs sage.modules - sage: ff(v) # indirect doctest + sage: ff(v) # indirect doctest # needs sage.modules 10005*alpha + 3 sage: R. = GF(5)[]; P = R.ideal(4*t^12 + 3*t^11 + 4*t^10 + t^9 + t^8 + 3*t^7 + 2*t^6 + 3*t^4 + t^3 + 3*t^2 + 2) sage: k. = P.residue_field() - sage: V = k.vector_space(map=False); v = V([1,2,3,4,5,6,7,8,9,0,1,2]); k(v) # indirect doctest + sage: V = k.vector_space(map=False); v = V([1,2,3,4,5,6,7,8,9,0,1,2]); k(v) # indirect doctest # needs sage.modules 2*a^11 + a^10 + 4*a^8 + 3*a^7 + 2*a^6 + a^5 + 4*a^3 + 3*a^2 + 2*a + 1 """ try: diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index f6e88f8f180..17e63a269bc 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -81,9 +81,9 @@ From smaller to bigger doesn't make sense:: From bigger to small does:: sage: f = RR.hom(RealField(15)) # needs sage.rings.real_mpfr - sage: f(2.5) + sage: f(2.5) # needs sage.rings.real_mpfr 2.500 - sage: f(RR.pi()) + sage: f(RR.pi()) # needs sage.rings.real_mpfr 3.142 Inclusion map from the reals to the complexes:: @@ -1516,7 +1516,7 @@ cdef class RingHomomorphism(RingMap): sage: A. = GF(7^3) sage: R = A.polynomial_ring().quotient(A.polynomial()) sage: g = A.hom(R.gens(), R) - sage: (g.inverse() * g).is_identity() + sage: (g.inverse() * g).is_identity() # needs sage.libs.singular True sage: B. , f = A.extension(3, map=True) sage: f.inverse() @@ -2039,7 +2039,7 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): TESTS:: - sage: loads(dumps(f2)) == f2 # needs sage.rings.finite_rings + sage: loads(dumps(f2)) == f2 # needs sage.libs.pari True This was fixed in :trac:`24277`:: @@ -2946,7 +2946,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage.rings.finite_rings sage: R. = PolynomialRing(GF(19), 3) sage: S. = R.quo(x^3 + y^3 + z^3) sage: phi = S.hom([b, c, a]) diff --git a/src/sage/rings/polynomial/flatten.py b/src/sage/rings/polynomial/flatten.py index cfc5f96179c..74783285396 100644 --- a/src/sage/rings/polynomial/flatten.py +++ b/src/sage/rings/polynomial/flatten.py @@ -382,7 +382,7 @@ def _call_(self, p): sage: rings = [ZZ['x']['y']['a,b,c']] sage: rings += [GF(4)['x','y']['a','b']] # needs sage.rings.finite_rings sage: rings += [AA['x']['a','b']['y'], QQbar['a1','a2']['t']['X','Y']] # needs sage.rings.number_field - sage: for R in rings: + sage: for R in rings: # needs sage.modules ....: f = FlatteningMorphism(R) ....: g = f.section() ....: for _ in range(10): diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index d5873f3971c..9a80e062c22 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -6908,7 +6908,7 @@ cdef class Polynomial(CommutativePolynomial): sage: K. = FunctionField(QQ) sage: R. = K[] - sage: y.resultant(y + x) # needs sage.libs.pari + sage: y.resultant(y + x) # needs sage.libs.pari sage.modules x sage: # needs sage.libs.singular @@ -7793,7 +7793,8 @@ cdef class Polynomial(CommutativePolynomial): :: - sage: x = CC['x'].0 # needs sage.rings.real_mpfr + sage: # needs sage.rings.real_mpfr + sage: x = CC['x'].0 sage: f = x^3 - 2 sage: f.roots() # needs numpy [(1.25992104989487, 1), From e91b7c6852abda67480cc8013a6bbc3c99a44857 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Sep 2023 21:51:56 -0700 Subject: [PATCH 050/494] src/sage/rings/number_field/number_field.py: Use lazy_import --- src/sage/rings/number_field/number_field.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index abb58cadb8e..5ac37e3f23f 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -127,7 +127,7 @@ from sage.misc.fast_methods import WithEqualityById from sage.misc.functional import is_odd, lift - +from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod from sage.rings.infinity import Infinity from sage.categories.number_fields import NumberFields @@ -162,6 +162,10 @@ from sage.interfaces.abc import GapElement +lazy_import('sage.libs.gap.element', 'GapElement', as_='LibGapElement') +lazy_import('sage.rings.universal_cyclotomic_field', 'UniversalCyclotomicFieldElement') + + _NumberFields = NumberFields() @@ -11442,14 +11446,11 @@ def _element_constructor_(self, x, check=True): return NumberField_absolute._element_constructor_(self, x) elif isinstance(x, pari_gen): return NumberField_absolute._element_constructor_(self, x, check=check) - elif isinstance(x, (sage.libs.gap.element.GapElement, GapElement)): + elif isinstance(x, (LibGapElement, GapElement)): return self._coerce_from_gap(x) elif isinstance(x, str): return self._convert_from_str(x) - - # late import because of speed - from sage.rings.universal_cyclotomic_field import UniversalCyclotomicFieldElement - if isinstance(x, UniversalCyclotomicFieldElement): + elif isinstance(x, UniversalCyclotomicFieldElement): return x.to_cyclotomic_field(self) else: return self._convert_non_number_field_element(x) From ae8b9b2ba4a1084e75b2baf098fab8ac1baeebe6 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 4 Sep 2023 21:52:22 -0700 Subject: [PATCH 051/494] sage.rings: Update # needs --- .../polynomial/polynomial_quotient_ring.py | 9 ++++++--- .../polynomial_quotient_ring_element.py | 2 +- .../polynomial/polynomial_rational_flint.pyx | 17 ++++++++++++----- src/sage/rings/polynomial/toy_d_basis.py | 1 + 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 894336def89..98fd9a34fd5 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -1089,6 +1089,7 @@ def is_integral_domain(self, proof=True): EXAMPLES:: sage: R. = PolynomialRing(ZZ) + sage: S = R.quotient(z^2 - z) sage: S.is_integral_domain() False @@ -1098,12 +1099,14 @@ def is_integral_domain(self, proof=True): sage: U = R.quotient(-1) sage: U.is_integral_domain() False + + sage: # needs sage.libs.singular sage: R2. = PolynomialRing(R) - sage: S2 = R2.quotient(z^2 - y^3) # needs sage.libs.singular - sage: S2.is_integral_domain() # needs sage.libs.singular + sage: S2 = R2.quotient(z^2 - y^3) + sage: S2.is_integral_domain() True sage: S3 = R2.quotient(z^2 - 2*y*z + y^2) - sage: S3.is_integral_domain() # needs sage.libs.singular + sage: S3.is_integral_domain() False sage: R. = PolynomialRing(ZZ.quotient(4)) diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py index 56f1522a19b..5d4b9f1883b 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py @@ -764,7 +764,7 @@ def trace(self): sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3 - 389*x^2 + 2*x - 5) - sage: a.trace() + sage: a.trace() # needs sage.modules 389 """ return self.matrix().trace() diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index b888b31d214..f898eb701d6 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -344,7 +344,7 @@ cdef class Polynomial_rational_flint(Polynomial): sage: P. = PolynomialRing(QQ) sage: f = 3*x^2 + 2*x + 5 - sage: singular(f) + sage: singular(f) # needs sage.libs.singular 3*x^2+2*x+5 """ self._parent._singular_(singular).set_ring() # Expensive! @@ -486,7 +486,7 @@ cdef class Polynomial_rational_flint(Polynomial): True sage: (t/3)(RealBallField(100)(1)) [0.33333333333333333333333333333...] - sage: (t/3)(ComplexBallField(10)(1+i)) + sage: (t/3)(ComplexBallField(10)(1+i)) # needs sage.symbolic [0.33...] + [0.33...]*I """ cdef Polynomial_rational_flint f @@ -2097,6 +2097,7 @@ cdef class Polynomial_rational_flint(Polynomial): EXAMPLES:: + sage: # needs sage.libs.pari sage: R. = QQ[] sage: f = x^4 - 17*x^3 - 2*x + 1 sage: G = f.galois_group(); G @@ -2113,6 +2114,7 @@ cdef class Polynomial_rational_flint(Polynomial): :: + sage: # needs sage.libs.pari sage: f = x^4 - 17*x^3 - 2*x + 1 sage: G = f.galois_group(pari_group=True); G PARI group [24, -1, 5, "S4"] of degree 4 @@ -2130,6 +2132,7 @@ cdef class Polynomial_rational_flint(Polynomial): sage: f.galois_group(algorithm='kash') # optional - kash Transitive group number 5 of degree 4 + sage: # needs sage.libs.gap sage: f = x^4 - 17*x^3 - 2*x + 1 sage: f.galois_group(algorithm='gap') Transitive group number 5 of degree 4 @@ -2139,6 +2142,7 @@ cdef class Polynomial_rational_flint(Polynomial): sage: f = x^12 - 2*x^8 - x^7 + 2*x^6 + 4*x^4 - 2*x^3 - x^2 - x + 1 sage: f.galois_group(algorithm='gap') Transitive group number 183 of degree 12 + sage: f.galois_group(algorithm='magma') # optional - magma Transitive group number 5 of degree 4 @@ -2157,7 +2161,7 @@ cdef class Polynomial_rational_flint(Polynomial): are supported (see :trac:`20631`):: sage: R. = QQ[] - sage: (zeta^2 + zeta + 1).galois_group(pari_group=True) + sage: (zeta^2 + zeta + 1).galois_group(pari_group=True) # needs sage.libs.pari PARI group [2, -1, 1, "S2"] of degree 2 """ from sage.groups.pari_group import PariGroup @@ -2287,6 +2291,7 @@ cdef class Polynomial_rational_flint(Polynomial): EXAMPLES:: + sage: # needs sage.rings.padic sage: R. = QQ[] sage: f = x^3 - 2 sage: f.factor_padic(2) @@ -2307,6 +2312,7 @@ cdef class Polynomial_rational_flint(Polynomial): the same as first coercing to `\QQ_p` and then factoring (see also :trac:`15422`):: + sage: # needs sage.rings.padic sage: f = x^2 - 3^6 sage: f.factor_padic(3, 5) ((1 + O(3^5))*x + 3^3 + O(3^5)) * ((1 + O(3^5))*x + 2*3^3 + 2*3^4 + O(3^5)) @@ -2319,12 +2325,13 @@ cdef class Polynomial_rational_flint(Polynomial): A more difficult example:: sage: f = 100 * (5*x + 1)^2 * (x + 5)^2 - sage: f.factor_padic(5, 10) + sage: f.factor_padic(5, 10) # needs sage.rings.padic (4*5^4 + O(5^14)) * ((1 + O(5^9))*x + 5^-1 + O(5^9))^2 * ((1 + O(5^10))*x + 5 + O(5^10))^2 Try some bogus inputs:: + sage: # needs sage.rings.padic sage: f.factor_padic(3, -1) Traceback (most recent call last): ... @@ -2469,7 +2476,7 @@ cdef class Polynomial_rational_flint(Polynomial): -31 sage: d.parent() is QQ True - sage: EllipticCurve([1, 1]).discriminant() / 16 + sage: EllipticCurve([1, 1]).discriminant() / 16 # needs sage.schemes -31 :: diff --git a/src/sage/rings/polynomial/toy_d_basis.py b/src/sage/rings/polynomial/toy_d_basis.py index 3734449a666..89bab98dbae 100644 --- a/src/sage/rings/polynomial/toy_d_basis.py +++ b/src/sage/rings/polynomial/toy_d_basis.py @@ -51,6 +51,7 @@ Another example. This one is from the Magma Handbook:: + sage: # needs sage.libs.singular sage: P. = PolynomialRing(IntegerRing(), 3, order='lex') sage: I = ideal(x^2 - 1, y^2 - 1, 2*x*y - z) sage: I = Ideal(d_basis(I)) From c719121f07ac2910d31a140a3f314a38ab94d410 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 5 Sep 2023 09:39:58 -0700 Subject: [PATCH 052/494] src/sage/rings/real_arb.pyx: Update # needs --- src/sage/rings/real_arb.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx index 17859068273..7bc5eaed61a 100644 --- a/src/sage/rings/real_arb.pyx +++ b/src/sage/rings/real_arb.pyx @@ -3950,7 +3950,7 @@ cdef class RealBall(RingElement): [0.69314718055995 +/- ...e-15] sage: RBF(1/3).polylog(1/2) [0.44210883528067 +/- 6.7...e-15] - sage: RBF(1/3).polylog(RLF(pi)) + sage: RBF(1/3).polylog(RLF(pi)) # needs sage.symbolic [0.34728895057225 +/- ...e-15] TESTS:: From 7e08b6f4e9eabcd07160eb80f961c5202b185f98 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 6 Sep 2023 20:13:40 -0700 Subject: [PATCH 053/494] Add # needs --- src/sage/rings/derivation.py | 27 ++++++++++------------- src/sage/rings/polynomial/toy_d_basis.py | 1 + src/sage/rings/rational_field.py | 2 +- src/sage/rings/real_interval_absolute.pyx | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/sage/rings/derivation.py b/src/sage/rings/derivation.py index 26b6f2d5905..da55ada5432 100644 --- a/src/sage/rings/derivation.py +++ b/src/sage/rings/derivation.py @@ -1580,7 +1580,7 @@ def __init__(self, parent, arg=None): TESTS:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: from sage.rings.derivation import RingDerivationWithoutTwist_wrapper sage: R. = GF(5)[] sage: S = R.quo([x^5, y^5]) @@ -1588,8 +1588,7 @@ def __init__(self, parent, arg=None): sage: der = M.random_element() sage: isinstance(der, RingDerivationWithoutTwist_wrapper) True - - sage: TestSuite(der).run() # needs sage.rings.finite_rings + sage: TestSuite(der).run() """ if isinstance(arg, list) and len(arg) == 1 and isinstance(arg[0], RingDerivation): @@ -1620,7 +1619,7 @@ def _add_(self, other): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1637,7 +1636,7 @@ def _sub_(self, other): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1654,7 +1653,7 @@ def _neg_(self): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1670,7 +1669,7 @@ def _lmul_(self, factor): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1688,7 +1687,7 @@ def _rmul_(self, factor): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R. = GF(5)[] sage: S. = R.quo([X^5, Y^5]) sage: Dx = S.derivation(x) @@ -1707,21 +1706,19 @@ def list(self): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.libs.singular sage: R.