Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sage/calculus/test_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<class 'sage.symbolic.expression.Expression'>
sage: t1, t2
(omega + x, omega + x)
sage: e = sympy.sin(var("y"))+sage.all.cos(sympy.Symbol("x"))
sage: e = sympy.sin(var("y")) + sage.functions.trig.cos(sympy.Symbol("x"))
sage: type(e)
<class 'sympy.core.add.Add'>
sage: e
Expand All @@ -166,7 +166,7 @@
<class 'sage.symbolic.expression.Expression'>
sage: e
cos(x) + sin(y)
sage: e = sage.all.cos(var("y")**3)**4+var("x")**2
sage: e = sage.functions.trig.cos(var("y")**3)**4+var("x")**2
sage: e = e._sympy_()
sage: e
x**2 + cos(y**3)**4
Expand Down
3 changes: 2 additions & 1 deletion src/sage/ext/fast_callable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ def function_name(fn):
Given a function, return a string giving a name for the function.

For functions we recognize, we use our standard opcode name for the
function (so operator.add becomes 'add', and sage.all.sin becomes 'sin').
function (so :func:`operator.add` becomes ``'add'``, and :func:`sage.functions.trig.sin`
becomes ``'sin'``).

For functions we don't recognize, we try to come up with a name,
but the name will be wrapped in braces; this is a signal that
Expand Down
9 changes: 5 additions & 4 deletions src/sage/groups/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@

from copy import copy

from sage.arith.misc import integer_ceil, integer_floor, xlcm
from sage.arith.srange import xsrange
from sage.misc.functional import log
from sage.misc.misc_c import prod
import sage.rings.integer_ring as integer_ring
import sage.rings.integer
from sage.arith.srange import xsrange

#
# Lists of names (as strings) which the user may use to identify one
Expand Down Expand Up @@ -1396,8 +1398,7 @@ def order_from_bounds(P, bounds, d=None, operation='+',
if d > 1:
Q = multiple(P, d, operation=operation)
lb, ub = bounds
bounds = (sage.arith.all.integer_ceil(lb / d),
sage.arith.all.integer_floor(ub / d))
bounds = (integer_ceil(lb / d), integer_floor(ub / d))

# Use generic bsgs to find n=d*m with lb<=n<=ub and n*P=0

Expand Down Expand Up @@ -1486,7 +1487,7 @@ def merge_points(P1, P2, operation='+',
if n2.divides(n1):
return (g1, n1)

m, k1, k2 = sage.arith.all.xlcm(n1, n2)
m, k1, k2 = xlcm(n1, n2)
m1 = n1 // k1
m2 = n2 // k2
g1 = multiple(g1, m1, operation=operation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def __init__(self, parent, M, check=True, **kwargs):

EXAMPLES::

sage:
sage: from sage.modular.modform_hecketriangle.hecke_triangle_groups import HeckeTriangleGroup, HeckeTriangleGroupElement
sage: lam = PolynomialRing(ZZ, 'lam').gen()
sage: M = matrix([[-1, 0], [-lam^4 + 5*lam^2 + lam - 5, -1]])
Expand Down
8 changes: 5 additions & 3 deletions src/sage/rings/bernoulli_mod_p.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ AUTHOR:
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.arith.misc import is_prime, primitive_root

cimport sage.rings.fast_arith
import sage.rings.fast_arith
cdef sage.rings.fast_arith.arith_int arith_int
Expand Down Expand Up @@ -135,12 +137,12 @@ def bernoulli_mod_p(int p):
if p <= 2:
raise ValueError("p (=%s) must be a prime >= 3" % p)

if not sage.arith.all.is_prime(p):
if not is_prime(p):
raise ValueError("p (=%s) must be a prime" % p)

cdef int g, gSqr, gInv, gInvSqr, isOdd

g = sage.arith.all.primitive_root(p)
g = primitive_root(p)
gInv = arith_int.c_inverse_mod_int(g, p)
gSqr = ((<llong> g) * g) % p
gInvSqr = ((<llong> gInv) * gInv) % p
Expand Down Expand Up @@ -303,7 +305,7 @@ def bernoulli_mod_p_single(long p, long k):
if p <= 2:
raise ValueError("p (=%s) must be a prime >= 3" % p)

if not sage.arith.all.is_prime(p):
if not is_prime(p):
raise ValueError("p (=%s) must be a prime" % p)

cdef long x = bernmm_bern_modp(p, k)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ cdef class ComplexIntervalFieldElement(FieldElement):

Exact and nearly exact points are still visible::

sage: # needs sage.plot
sage: # needs sage.plot sage.symbolic
sage: plot(CIF(pi, 1), color='red') + plot(CIF(1, e), color='purple') + plot(CIF(-1, -1))
Graphics object consisting of 6 graphics primitives

Expand Down
16 changes: 12 additions & 4 deletions src/sage/rings/continued_fraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,20 @@
import numbers

import sage.rings.abc

from sage.misc.lazy_import import lazy_import
from sage.rings.infinity import Infinity
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.structure.richcmp import rich_to_bool, richcmp_method
from sage.structure.sage_object import SageObject

lazy_import('sage.combinat.words.abstract_word', 'Word_class')
lazy_import('sage.combinat.words.finite_word', 'FiniteWord_class')
lazy_import('sage.combinat.words.infinite_word', 'InfiniteWord_class')
lazy_import('sage.combinat.words.word', 'Word')


ZZ_0 = Integer(0)
ZZ_1 = Integer(1)
ZZ_m1 = Integer(-1)
Expand Down Expand Up @@ -2490,7 +2498,10 @@ def continued_fraction_list(x, type="std", partial_convergents=False,

cf = None

from sage.rings.real_mpfr import RealLiteral
try:
from sage.rings.real_mpfr import RealLiteral
except ImportError:
RealLiteral = ()
if isinstance(x, RealLiteral):
from sage.rings.real_mpfi import RealIntervalField
x = RealIntervalField(x.prec())(x)
Expand Down Expand Up @@ -2661,7 +2672,6 @@ def continued_fraction(x, value=None):
pass

# input for finite or ultimately periodic partial quotient expansion
from sage.combinat.words.finite_word import FiniteWord_class
if isinstance(x, FiniteWord_class):
x = list(x)

Expand All @@ -2675,12 +2685,10 @@ def continued_fraction(x, value=None):
return ContinuedFraction_periodic(x1, x2)

# input for infinite partial quotient expansion
from sage.combinat.words.infinite_word import InfiniteWord_class
from sage.misc.lazy_list import lazy_list_generic
if isinstance(x, (lazy_list_generic, InfiniteWord_class)):
return ContinuedFraction_infinite(x, value)

from sage.combinat.words.abstract_word import Word_class
if isinstance(x, Word_class):
raise ValueError("word with unknown length cannot be converted "
"to continued fractions")
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/finite_rings/element_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ cdef class FinitePolyExtElement(FiniteRingElement):
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") # needs sage.modules
sage: q == p # needs sage.modules
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
Expand Down
15 changes: 10 additions & 5 deletions src/sage/rings/finite_rings/element_givaro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ from cysignals.signals cimport sig_on, sig_off

from cypari2.paridecl cimport *

import sage.arith.misc

from sage.misc.randstate cimport current_randstate
from sage.rings.finite_rings.element_pari_ffelt cimport FiniteFieldElement_pari_ffelt
from sage.structure.richcmp cimport richcmp
import sage.arith.all

from cypari2.gen cimport Gen
from cypari2.stack cimport clear_stack
Expand Down Expand Up @@ -414,9 +415,6 @@ cdef class Cache_givaro(Cache_base):
# Reduce to pari
e = e.__pari__()

elif isinstance(e, sage.libs.gap.element.GapElement_FiniteField):
return e.sage(ring=self.parent)

elif isinstance(e, GapElement):
from sage.libs.gap.libgap import libgap
return libgap(e).sage(ring=self.parent)
Expand All @@ -434,6 +432,13 @@ cdef class Cache_givaro(Cache_base):
return ret

else:
try:
from sage.libs.gap.element import GapElement_FiniteField
except ImportError:
pass
else:
if isinstance(e, GapElement_FiniteField):
return e.sage(ring=self.parent)
raise TypeError("unable to coerce %r" % type(e))

cdef GEN t
Expand Down Expand Up @@ -1568,7 +1573,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement):
raise ArithmeticError("Multiplicative order of 0 not defined.")
n = (self._cache).order_c() - 1
order = Integer(1)
for p, e in sage.arith.all.factor(n):
for p, e in sage.arith.misc.factor(n):
# Determine the power of p that divides the order.
a = self**(n / (p**e))
while a != 1:
Expand Down
11 changes: 7 additions & 4 deletions src/sage/rings/finite_rings/element_ntl_gf2e.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ cdef class Cache_ntl_gf2e(Cache_base):
cdef FiniteField_ntl_gf2eElement x
cdef FiniteField_ntl_gf2eElement g
cdef Py_ssize_t i
from sage.libs.gap.element import GapElement_FiniteField

if is_IntegerMod(e):
e = e.lift()
Expand Down Expand Up @@ -334,14 +333,18 @@ cdef class Cache_ntl_gf2e(Cache_base):
# Reduce to pari
e = e.__pari__()

elif isinstance(e, GapElement_FiniteField):
return e.sage(ring=self._parent)

elif isinstance(e, GapElement):
from sage.libs.gap.libgap import libgap
return libgap(e).sage(ring=self._parent)

else:
try:
from sage.libs.gap.element import GapElement_FiniteField
except ImportError:
pass
else:
if isinstance(e, GapElement_FiniteField):
return e.sage(ring=self._parent)
raise TypeError("unable to coerce %r" % type(e))

cdef GEN t
Expand Down
1 change: 1 addition & 0 deletions src/sage/rings/finite_rings/element_pari_ffelt.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):

EXAMPLES::

sage: # needs sage.modules
sage: k.<a> = GF(2^20, impl='pari_ffelt')
sage: e = k.random_element()
sage: f = loads(dumps(e))
Expand Down
3 changes: 2 additions & 1 deletion src/sage/rings/finite_rings/galois_group.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# sage.doctest: needs sage.modules sage.rings.finite_rings
r"""
Galois groups of Finite Fields
"""
Expand Down Expand Up @@ -109,7 +110,7 @@ def _element_constructor_(self, x, check=True):
Frob^2
sage: G(G.gens()[0])
Frob
sage: G([(1,3,2)])
sage: G([(1,3,2)]) # needs sage.libs.gap
Frob^2
sage: G(k.hom(k.gen()^3, k))
Frob
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/finite_rings/residue_field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ First over a small non-prime field::
Residue field in ubar of Fractional ideal
(47, 517/55860*u^5 + 235/3724*u^4 + 9829/13965*u^3
+ 54106/13965*u^2 + 64517/27930*u + 755696/13965)
sage: I.groebner_basis()
sage: I.groebner_basis() # needs sage.libs.singular
[X + (-19*ubar^2 - 5*ubar - 17)*Y]

And now over a large prime field::
Expand All @@ -144,11 +144,11 @@ And now over a large prime field::
4398046511119
sage: S.<X, Y, Z> = PolynomialRing(Rf, order='lex')
sage: I = ideal([2*X - Y^2, Y + Z])
sage: I.groebner_basis()
sage: I.groebner_basis() # needs sage.libs.singular
[X + 2199023255559*Z^2, Y + Z]
sage: S.<X, Y, Z> = PolynomialRing(Rf, order='deglex')
sage: I = ideal([2*X - Y^2, Y + Z])
sage: I.groebner_basis()
sage: I.groebner_basis() # needs sage.libs.singular
[Z^2 + 4398046511117*X, Y + Z]
"""

Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/residue_field_pari_ffelt.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ResidueFiniteField_pari_ffelt(ResidueField_generic, FiniteField_pari_ffelt

sage: R.<t> = 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.<a> = 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 # needs sage.modules
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:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/function_field/function_field_rational.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __init__(self, constant_field, names, category=None):

sage: K.<t> = FunctionField(CC); K # needs sage.rings.real_mpfr
Rational function field in t over Complex Field with 53 bits of precision
sage: TestSuite(K).run() # long time (5s) # needs sage.rings.real_mpfr
sage: TestSuite(K).run() # long time (5s) # needs sage.rings.real_mpfr

sage: FunctionField(QQ[I], 'alpha') # needs sage.rings.number_field
Rational function field in alpha over
Expand Down
9 changes: 6 additions & 3 deletions src/sage/rings/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ProductTree:
(the famous *Fast* Fourier Transform) can be implemented as follows
using the :meth:`remainders` method of this class::

sage: # needs sage.rings.finite_rings
sage: from sage.rings.generic import ProductTree
sage: F = GF(65537)
sage: a = F(1111)
Expand Down Expand Up @@ -62,6 +63,7 @@ class ProductTree:

::

sage: # needs sage.libs.pari
sage: vs = prime_range(100)
sage: tree = ProductTree(vs)
sage: tree.root().factor()
Expand All @@ -71,7 +73,7 @@ class ProductTree:

We can access the individual layers of the tree::

sage: tree.layers
sage: tree.layers # needs sage.libs.pari
[(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97),
(6, 35, 143, 323, 667, 1147, 1763, 2491, 3599, 4757, 5767, 7387, 97),
(210, 46189, 765049, 4391633, 17120443, 42600829, 97),
Expand All @@ -87,8 +89,8 @@ def __init__(self, leaves):
EXAMPLES::

sage: from sage.rings.generic import ProductTree
sage: vs = prime_range(100)
sage: tree = ProductTree(vs)
sage: vs = prime_range(100) # needs sage.libs.pari
sage: tree = ProductTree(vs) # needs sage.libs.pari
"""
V = tuple(leaves)
self.layers = [V]
Expand Down Expand Up @@ -182,6 +184,7 @@ def remainders(self, x):

EXAMPLES::

sage: # needs sage.libs.pari
sage: from sage.rings.generic import ProductTree
sage: vs = prime_range(100)
sage: tree = ProductTree(vs)
Expand Down
4 changes: 3 additions & 1 deletion src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4076,7 +4076,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
"""
if self.is_zero():
raise ArithmeticError("support of 0 not defined")
return sage.arith.all.prime_factors(self)
from sage.arith.misc import prime_factors

return prime_factors(self)

def coprime_integers(self, m):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ cdef class RingHomomorphism(RingMap):
Ideals in quotient rings over ``QQbar`` do not support reduction yet,
so the graph is constructed in the ambient ring instead::

sage: # needs sage.rings.number_field
sage: # needs sage.libs.singular sage.rings.number_field
sage: A.<z,w> = QQbar['z,w'].quotient('z*w - 1')
sage: B.<x,y> = QQbar['x,y'].quotient('2*x^2 + y^2 - 1')
sage: f = A.hom([QQbar(2).sqrt()*x + QQbar(I)*y,
Expand Down Expand Up @@ -1447,7 +1447,7 @@ cdef class RingHomomorphism(RingMap):
An isomorphism between the algebraic torus and the circle over a number
field::

sage: # needs sage.rings.number_field
sage: # needs sage.libs.singular sage.rings.number_field
sage: K.<i> = QuadraticField(-1)
sage: A.<z,w> = K['z,w'].quotient('z*w - 1')
sage: B.<x,y> = K['x,y'].quotient('x^2 + y^2 - 1')
Expand Down
Loading