From 79498fcd93b71a60e3dbf10d41b11193f17d89c4 Mon Sep 17 00:00:00 2001 From: Martin Rubey Date: Mon, 7 Jan 2019 08:26:26 +0100 Subject: [PATCH] add missing colon to EXAMPLES: if followed by a code block --- src/sage/algebras/quantum_groups/q_numbers.py | 2 +- src/sage/categories/category_with_axiom.py | 2 +- .../covariant_functorial_construction.py | 2 +- src/sage/categories/division_rings.py | 2 +- .../categories/filtered_modules_with_basis.py | 2 +- .../finite_complex_reflection_groups.py | 4 +- src/sage/categories/functor.pyx | 2 +- src/sage/categories/magmas.py | 6 +- src/sage/coding/binary_code.pyx | 12 +- src/sage/coding/grs.py | 2 +- src/sage/combinat/chas/wqsym.py | 2 +- src/sage/combinat/debruijn_sequence.pyx | 2 +- src/sage/combinat/parallelogram_polyomino.py | 2 +- src/sage/combinat/tableau.py | 2 +- src/sage/combinat/words/morphism.py | 2 +- src/sage/combinat/words/words.py | 2 +- src/sage/ext/fast_callable.pyx | 13 +- .../finance/markov_multifractal_cython.pyx | 10 +- src/sage/functions/generalized.py | 4 +- src/sage/functions/log.py | 2 +- src/sage/functions/orthogonal_polys.py | 2 +- src/sage/geometry/lattice_polytope.py | 2 +- src/sage/geometry/newton_polygon.py | 24 +- src/sage/graphs/base/sparse_graph.pyx | 2 +- src/sage/graphs/generic_graph.py | 2 +- src/sage/graphs/orientations.py | 2 +- src/sage/graphs/strongly_regular_db.pyx | 2 +- .../additive_abelian_wrapper.py | 2 +- src/sage/groups/group.pyx | 2 +- src/sage/groups/libgap_wrapper.pyx | 2 +- .../groups/lie_gps/nilpotent_lie_group.py | 2 +- .../perm_gps/partn_ref/refinement_binary.pyx | 12 +- src/sage/homology/simplicial_complex.py | 2 +- .../homology/simplicial_set_constructions.py | 6 +- src/sage/interfaces/gap.py | 4 +- src/sage/libs/coxeter3/coxeter.pyx | 2 +- src/sage/libs/ecl.pyx | 2 +- src/sage/libs/gap/operations.py | 2 +- src/sage/libs/ntl/ntl_GF2.pyx | 18 +- src/sage/libs/ntl/ntl_GF2E.pyx | 48 +- src/sage/libs/ntl/ntl_GF2EContext.pyx | 25 +- src/sage/libs/ntl/ntl_GF2EX.pyx | 24 +- src/sage/libs/ntl/ntl_GF2X_linkage.pxi | 75 +- src/sage/libs/ntl/ntl_ZZ.pyx | 15 +- src/sage/libs/ntl/ntl_ZZX.pyx | 145 ++-- src/sage/libs/ntl/ntl_ZZ_p.pyx | 48 +- src/sage/libs/ntl/ntl_ZZ_pContext.pyx | 24 +- src/sage/libs/ntl/ntl_ZZ_pE.pyx | 19 +- src/sage/libs/ntl/ntl_ZZ_pEContext.pyx | 54 +- src/sage/libs/ntl/ntl_ZZ_pEX.pyx | 790 +++++++++--------- src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi | 63 +- src/sage/libs/ntl/ntl_lzz_p.pyx | 33 +- src/sage/libs/ntl/ntl_lzz_pContext.pyx | 15 +- src/sage/libs/ntl/ntl_lzz_pX.pyx | 102 ++- src/sage/libs/ntl/ntl_mat_ZZ.pyx | 84 +- src/sage/libs/pynac/constant.pyx | 2 +- src/sage/libs/symmetrica/sb.pxi | 21 +- src/sage/libs/symmetrica/schur.pxi | 21 +- src/sage/matrix/change_ring.pyx | 3 +- src/sage/matrix/matrix1.pyx | 4 +- src/sage/matrix/matrix2.pyx | 2 +- src/sage/matrix/matrix_generic_dense.pyx | 6 +- src/sage/matrix/matrix_modn_sparse.pyx | 6 +- src/sage/matrix/misc.pyx | 6 +- src/sage/misc/fpickle.pyx | 2 +- src/sage/misc/inline_fortran.py | 2 +- src/sage/misc/latex.py | 4 +- src/sage/misc/sage_ostools.pyx | 2 +- src/sage/modular/btquotients/btquotient.py | 4 +- .../modular/btquotients/pautomorphicform.py | 2 +- src/sage/modular/hecke/submodule.py | 2 +- src/sage/modular/modsym/space.py | 2 +- .../modules/vector_complex_double_dense.pyx | 12 +- src/sage/modules/vector_modn_dense.pyx | 3 +- src/sage/modules/vector_real_double_dense.pyx | 18 +- .../quadratic_form__local_field_invariants.py | 4 +- src/sage/quadratic_forms/ternary.pyx | 2 +- src/sage/quivers/algebra.py | 4 +- src/sage/quivers/representation.py | 2 +- .../rings/finite_rings/finite_field_base.pyx | 2 +- src/sage/rings/finite_rings/integer_mod.pyx | 15 +- src/sage/rings/integer.pyx | 6 +- .../rings/number_field/number_field_ideal.py | 2 +- src/sage/rings/padics/generic_nodes.py | 2 +- src/sage/rings/padics/lattice_precision.py | 2 +- src/sage/rings/padics/padic_generic.py | 2 +- .../rings/padics/padic_lattice_element.py | 2 +- .../multi_polynomial_libsingular.pyx | 3 +- src/sage/rings/polynomial/pbori.pyx | 5 +- .../rings/polynomial/polynomial_element.pyx | 5 +- .../polynomial_quotient_ring_element.py | 2 +- .../polynomial/skew_polynomial_element.pyx | 2 +- .../rings/polynomial/skew_polynomial_ring.py | 4 +- src/sage/rings/real_lazy.pyx | 3 +- src/sage/rings/tate_algebra.py | 2 +- src/sage/rings/tate_algebra_element.pyx | 2 +- src/sage/sandpiles/sandpile.py | 2 +- src/sage/schemes/plane_conics/con_field.py | 2 +- .../riemann_surfaces/riemann_surface.py | 2 +- src/sage/schemes/toric/divisor.py | 2 +- src/sage/schemes/toric/points.py | 3 +- src/sage/schemes/toric/weierstrass.py | 4 +- src/sage/schemes/toric/weierstrass_higher.py | 2 +- 103 files changed, 1141 insertions(+), 806 deletions(-) diff --git a/src/sage/algebras/quantum_groups/q_numbers.py b/src/sage/algebras/quantum_groups/q_numbers.py index d1b9926337e..00642a44589 100644 --- a/src/sage/algebras/quantum_groups/q_numbers.py +++ b/src/sage/algebras/quantum_groups/q_numbers.py @@ -165,7 +165,7 @@ def q_binomial(n, k, q=None): division is not implemented in the ring containing `q`, then it will not work. - EXAMPLES: + EXAMPLES:: sage: from sage.algebras.quantum_groups.q_numbers import q_binomial sage: q_binomial(2, 1) diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py index 7fce1513037..28a74890900 100644 --- a/src/sage/categories/category_with_axiom.py +++ b/src/sage/categories/category_with_axiom.py @@ -2189,7 +2189,7 @@ def additional_structure(self): .. SEEALSO:: :meth:`Category.additional_structure`. - EXAMPLES: + EXAMPLES:: sage: Sets().Finite().additional_structure() sage: Monoids().additional_structure() diff --git a/src/sage/categories/covariant_functorial_construction.py b/src/sage/categories/covariant_functorial_construction.py index ff195d2266a..0e4da5929f9 100644 --- a/src/sage/categories/covariant_functorial_construction.py +++ b/src/sage/categories/covariant_functorial_construction.py @@ -629,7 +629,7 @@ def additional_structure(self): - :meth:`Category.additional_structure`. - :meth:`is_construction_defined_by_base`. - EXAMPLES: + EXAMPLES:: sage: Modules(ZZ).Graded().additional_structure() Category of graded modules over Integer Ring diff --git a/src/sage/categories/division_rings.py b/src/sage/categories/division_rings.py index d1fd34ea057..cd26f46acae 100644 --- a/src/sage/categories/division_rings.py +++ b/src/sage/categories/division_rings.py @@ -50,7 +50,7 @@ def extra_super_categories(self): The :ref:`axioms-deduction-rules` section in the documentation of axioms - EXAMPLES: + EXAMPLES:: sage: DivisionRings().extra_super_categories() (Category of domains,) diff --git a/src/sage/categories/filtered_modules_with_basis.py b/src/sage/categories/filtered_modules_with_basis.py index 349df9ab554..a4b6cbe036e 100644 --- a/src/sage/categories/filtered_modules_with_basis.py +++ b/src/sage/categories/filtered_modules_with_basis.py @@ -789,7 +789,7 @@ def maximal_degree(self): .. SEEALSO:: :meth:`homogeneous_degree` - EXAMPLES: + EXAMPLES:: sage: A = ModulesWithBasis(ZZ).Filtered().example() sage: x = A(Partition((3,2,1))) diff --git a/src/sage/categories/finite_complex_reflection_groups.py b/src/sage/categories/finite_complex_reflection_groups.py index 2b56b1ddd33..330960fa70f 100644 --- a/src/sage/categories/finite_complex_reflection_groups.py +++ b/src/sage/categories/finite_complex_reflection_groups.py @@ -191,7 +191,7 @@ def _test_degrees(self, **options): - ``options`` -- any keyword arguments accepted by :meth:`_tester` - EXAMPLES: + EXAMPLES:: sage: from sage.categories.complex_reflection_groups import ComplexReflectionGroups sage: W = ComplexReflectionGroups().Finite().example(); W # optional - gap3 @@ -246,7 +246,7 @@ def _test_codegrees(self, **options): - ``options`` -- any keyword arguments accepted by :meth:`_tester` - EXAMPLES: + EXAMPLES:: sage: from sage.categories.complex_reflection_groups import ComplexReflectionGroups sage: W = ComplexReflectionGroups().Finite().example(); W # optional - gap3 diff --git a/src/sage/categories/functor.pyx b/src/sage/categories/functor.pyx index cf6314e47e5..ad77488eb9e 100644 --- a/src/sage/categories/functor.pyx +++ b/src/sage/categories/functor.pyx @@ -524,7 +524,7 @@ class ForgetfulFunctor_generic(Functor): """ Return whether ``self`` is not equal to ``other``. - EXAMPLES: + EXAMPLES:: sage: F1 = ForgetfulFunctor(FiniteFields(),Fields()) sage: F1 != F1 diff --git a/src/sage/categories/magmas.py b/src/sage/categories/magmas.py index b3cd846b076..ed71a2c1e9d 100644 --- a/src/sage/categories/magmas.py +++ b/src/sage/categories/magmas.py @@ -347,7 +347,7 @@ class Algebras(AlgebrasCategory): def extra_super_categories(self): """ - EXAMPLES: + EXAMPLES:: sage: Magmas().Commutative().Algebras(QQ).extra_super_categories() [Category of commutative magmas] @@ -407,7 +407,7 @@ class Algebras(AlgebrasCategory): def extra_super_categories(self): """ - EXAMPLES: + EXAMPLES:: sage: Magmas().Commutative().Algebras(QQ).extra_super_categories() [Category of commutative magmas] @@ -722,7 +722,7 @@ class Algebras(AlgebrasCategory): def extra_super_categories(self): """ - EXAMPLES: + EXAMPLES:: sage: Magmas().Commutative().Algebras(QQ).extra_super_categories() [Category of commutative magmas] diff --git a/src/sage/coding/binary_code.pyx b/src/sage/coding/binary_code.pyx index 642f8950ed6..ede70b82377 100644 --- a/src/sage/coding/binary_code.pyx +++ b/src/sage/coding/binary_code.pyx @@ -1982,7 +1982,8 @@ cdef class PartitionStack: # Returns an integer whose bits represent which columns are minimal cell # representatives. # -# EXAMPLES: +# EXAMPLES:: +# # sage: import sage.coding.binary_code # sage: from sage.coding.binary_code import * # sage: P = PartitionStack(2, 6) @@ -2041,7 +2042,8 @@ cdef class PartitionStack: # Returns an integer whose bits represent which columns are fixed. For # efficiency, mcrs is the output of min_cell_reps. # -# EXAMPLES: +# EXAMPLES:: +# # sage: import sage.coding.binary_code # sage: from sage.coding.binary_code import * # sage: P = PartitionStack(2, 6) @@ -2100,7 +2102,8 @@ cdef class PartitionStack: # """ # Returns an integer representing the first, smallest nontrivial cell of columns. # -# EXAMPLES: +# EXAMPLES:: +# # sage: import sage.coding.binary_code # sage: from sage.coding.binary_code import * # sage: P = PartitionStack(2, 6) @@ -2309,7 +2312,8 @@ cdef class PartitionStack: # Split column v out, placing it before the rest of the cell it was in. # Returns the location of the split column. # -# EXAMPLES: +# EXAMPLES:: +# # sage: import sage.coding.binary_code # sage: from sage.coding.binary_code import * # sage: P = PartitionStack(2, 6) diff --git a/src/sage/coding/grs.py b/src/sage/coding/grs.py index ae10d82d93b..c27534a6274 100644 --- a/src/sage/coding/grs.py +++ b/src/sage/coding/grs.py @@ -611,7 +611,7 @@ def ReedSolomonCode(base_field, length, dimension, primitive_root=None): one will be computed and can be recovered as ``C.evaluation_points()[1]`` where `C` is the code returned by this method. - EXAMPLES: + EXAMPLES:: sage: C = codes.ReedSolomonCode(GF(7), 6, 3); C [6, 3, 4] Reed-Solomon Code over GF(7) diff --git a/src/sage/combinat/chas/wqsym.py b/src/sage/combinat/chas/wqsym.py index ecbedb9fcd5..21dfe98afdb 100644 --- a/src/sage/combinat/chas/wqsym.py +++ b/src/sage/combinat/chas/wqsym.py @@ -803,7 +803,7 @@ def star_involution(self): :meth:`algebraic_complement`, :meth:`coalgebraic_complement` - EXAMPLES: + EXAMPLES:: sage: WQSym = algebras.WQSym(ZZ) sage: X = WQSym.X() diff --git a/src/sage/combinat/debruijn_sequence.pyx b/src/sage/combinat/debruijn_sequence.pyx index 0c08d5e4a26..db8fda9e5c0 100644 --- a/src/sage/combinat/debruijn_sequence.pyx +++ b/src/sage/combinat/debruijn_sequence.pyx @@ -330,7 +330,7 @@ class DeBruijnSequences(UniqueRepresentation, Parent): - ``seq`` -- A sequence of integers. - EXAMPLES: + EXAMPLES:: sage: Sequences = DeBruijnSequences(2, 3) sage: Sequences.an_element() in Sequences diff --git a/src/sage/combinat/parallelogram_polyomino.py b/src/sage/combinat/parallelogram_polyomino.py index 2601162d214..5b8886903fe 100644 --- a/src/sage/combinat/parallelogram_polyomino.py +++ b/src/sage/combinat/parallelogram_polyomino.py @@ -1338,7 +1338,7 @@ def _to_ordered_tree_via_dyck(self): See :meth:`_to_dyck_delest_viennot` for the exact references. See also :meth:`to_ordered_tree()`. - EXAMPLES: + EXAMPLES:: sage: pp = ParallelogramPolyomino([[0, 1], [1, 0]]) sage: pp._to_ordered_tree_via_dyck() diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index cae3a7148df..2484a468c55 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -1908,7 +1908,7 @@ def leq(self, secondtab): - ``secondtab`` -- a tableau of the same shape as ``self`` - EXAMPLES: + EXAMPLES:: sage: T = Tableau([[1, 2], [3]]) sage: S = Tableau([[1, 3], [3]]) diff --git a/src/sage/combinat/words/morphism.py b/src/sage/combinat/words/morphism.py index c0f71defbd6..280506a35fa 100644 --- a/src/sage/combinat/words/morphism.py +++ b/src/sage/combinat/words/morphism.py @@ -1809,7 +1809,7 @@ def fixed_point(self, letter): - ``word`` - the fixed point of ``self`` beginning with ``letter``. - EXAMPLES: + EXAMPLES:: sage: W = FiniteWords('abc') diff --git a/src/sage/combinat/words/words.py b/src/sage/combinat/words/words.py index 046a0474b3e..44bd3cc1d4c 100644 --- a/src/sage/combinat/words/words.py +++ b/src/sage/combinat/words/words.py @@ -593,7 +593,7 @@ def __call__(self, data=None, length=None, datatype=None, caching=True, check=Tr when reloading. Also, most iterators do not support copying and should not support pickling by extension. - EXAMPLES: + EXAMPLES:: sage: W = FiniteWords() diff --git a/src/sage/ext/fast_callable.pyx b/src/sage/ext/fast_callable.pyx index 2a32e093f33..c9c78dab7b9 100644 --- a/src/sage/ext/fast_callable.pyx +++ b/src/sage/ext/fast_callable.pyx @@ -1125,7 +1125,8 @@ cdef class ExpressionConstant(Expression): r""" An Expression that represents an arbitrary constant. - EXAMPLES: + EXAMPLES:: + sage: from sage.ext.fast_callable import ExpressionTreeBuilder sage: etb = ExpressionTreeBuilder(vars=(x,)) sage: type(etb(3)) @@ -1192,7 +1193,8 @@ cdef class ExpressionVariable(Expression): r""" An Expression that represents a variable. - EXAMPLES: + EXAMPLES:: + sage: from sage.ext.fast_callable import ExpressionTreeBuilder sage: etb = ExpressionTreeBuilder(vars=(x,)) sage: type(etb.var(x)) @@ -1258,7 +1260,8 @@ cdef class ExpressionCall(Expression): r""" An Expression that represents a function call. - EXAMPLES: + EXAMPLES:: + sage: from sage.ext.fast_callable import ExpressionTreeBuilder sage: etb = ExpressionTreeBuilder(vars=(x,)) sage: type(etb.call(sin, x)) @@ -1346,7 +1349,8 @@ cdef class ExpressionIPow(Expression): r""" A power Expression with an integer exponent. - EXAMPLES: + EXAMPLES:: + sage: from sage.ext.fast_callable import ExpressionTreeBuilder sage: etb = ExpressionTreeBuilder(vars=(x,)) sage: type(etb.var('x')^17) @@ -2500,4 +2504,3 @@ cdef class Wrapper: if isinstance(op, tuple) and op[0] == 'py_call': py_calls.append(op[1]) return py_calls - diff --git a/src/sage/finance/markov_multifractal_cython.pyx b/src/sage/finance/markov_multifractal_cython.pyx index 7dc3a263642..59adc8ecf7d 100644 --- a/src/sage/finance/markov_multifractal_cython.pyx +++ b/src/sage/finance/markov_multifractal_cython.pyx @@ -28,7 +28,8 @@ def simulations(Py_ssize_t n, Py_ssize_t k, OUTPUT: list of lists - EXAMPLES: + EXAMPLES:: + sage: set_random_seed(0) sage: msm = finance.MarkovSwitchingMultifractal(8,1.4,1.0,0.95,3) sage: import sage.finance.markov_multifractal_cython @@ -71,10 +72,3 @@ def simulations(Py_ssize_t n, Py_ssize_t k, S.append(t) return S - - - - - - - diff --git a/src/sage/functions/generalized.py b/src/sage/functions/generalized.py index 62e4bce15aa..ffc9e078097 100644 --- a/src/sage/functions/generalized.py +++ b/src/sage/functions/generalized.py @@ -316,7 +316,7 @@ def __init__(self): - ``x`` - a real number or a symbolic expression - EXAMPLES: + EXAMPLES:: sage: unit_step(-1) 0 @@ -405,7 +405,7 @@ def __init__(self): r""" The sgn function, ``sgn(x)``. - EXAMPLES: + EXAMPLES:: sage: sgn(-1) -1 diff --git a/src/sage/functions/log.py b/src/sage/functions/log.py index 0f817a74b4c..f70c710bda9 100644 --- a/src/sage/functions/log.py +++ b/src/sage/functions/log.py @@ -1278,7 +1278,7 @@ def _evalf_(self, z, m, parent=None, algorithm=None): def _maxima_init_evaled_(self, n, z): """ - EXAMPLES: + EXAMPLES:: sage: maxima_calculus(harmonic_number(x,2)) gen_harmonic_number(2,_SAGE_VAR_x) diff --git a/src/sage/functions/orthogonal_polys.py b/src/sage/functions/orthogonal_polys.py index 386ba4df02e..263f51191d1 100644 --- a/src/sage/functions/orthogonal_polys.py +++ b/src/sage/functions/orthogonal_polys.py @@ -602,7 +602,7 @@ def _eval_special_values_(self, n, x): Values known for special values of x. For details see [AS1964]_ 22.4 (p. 777) - EXAMPLES: + EXAMPLES:: sage: var('n') n diff --git a/src/sage/geometry/lattice_polytope.py b/src/sage/geometry/lattice_polytope.py index 5a6bd2062f4..f781abb33c8 100644 --- a/src/sage/geometry/lattice_polytope.py +++ b/src/sage/geometry/lattice_polytope.py @@ -3922,7 +3922,7 @@ def traverse_boundary(self): Needed for plot3d function of polytopes. - EXAMPLES: + EXAMPLES:: sage: p = lattice_polytope.cross_polytope(2).polar() sage: p.traverse_boundary() diff --git a/src/sage/geometry/newton_polygon.py b/src/sage/geometry/newton_polygon.py index f9cc867b7a7..ff0a5f2afe2 100644 --- a/src/sage/geometry/newton_polygon.py +++ b/src/sage/geometry/newton_polygon.py @@ -59,7 +59,7 @@ def _repr_(self): """ Return a string representation of this Newton polygon. - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (2,5) ]); NP @@ -96,7 +96,7 @@ def vertices(self, copy=True): The list of vertices of this Newton polygon (or a copy of it if ``copy`` is set to True) - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (2,5) ]); NP @@ -127,7 +127,7 @@ def last_slope(self): Returns the last (infinite) slope of this Newton polygon if it is infinite and ``+Infinity`` otherwise. - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP1 = NewtonPolygon([ (0,0), (1,1), (2,8), (3,5) ], last_slope=3) @@ -168,7 +168,7 @@ def slopes(self, repetition=True): If ``repetition`` is True, each slope is repeated a number of times equal to its length. Otherwise, it appears only one time. - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (3,6) ]); NP @@ -204,7 +204,7 @@ def _add_(self, other): The Newton polygon, which is the convex hull of this Newton polygon and ``other`` - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP1 = NewtonPolygon([ (0,0), (1,1), (2,6) ]); NP1 @@ -235,7 +235,7 @@ def _mul_(self, other): If ``self`` and ``other`` are respective Newton polygons of some polynomials `f` and `g` the self*other is the Newton polygon of the product `fg` - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP1 = NewtonPolygon([ (0,0), (1,1), (2,6) ]); NP1 @@ -276,7 +276,7 @@ def __pow__(self, exp, ignored=None): If ``self`` is the Newton polygon of a polynomial `f`, then ``self^exp`` is the Newton polygon of `f^{exp}`. - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (2,6) ]); NP @@ -300,7 +300,7 @@ def __lshift__(self, i): This Newton polygon shifted by the vector `(0,i)` - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (2,6) ]); NP @@ -324,7 +324,7 @@ def __rshift__(self, i): This Newton polygon shifted by the vector `(0,-i)` - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (2,6) ]); NP @@ -348,7 +348,7 @@ def __call__(self, x): The value of this Newton polygon at abscissa `x` - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (3,6) ]); NP @@ -460,7 +460,7 @@ def plot(self, **kwargs): All usual rendering options (color, thickness, etc.) are available. - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (2,6) ]) @@ -497,7 +497,7 @@ def reverse(self, degree=None): The image this Newton polygon under the symmetry '(x,y) \mapsto (degree-x, y)` - EXAMPLES: + EXAMPLES:: sage: from sage.geometry.newton_polygon import NewtonPolygon sage: NP = NewtonPolygon([ (0,0), (1,1), (2,5) ]) diff --git a/src/sage/graphs/base/sparse_graph.pyx b/src/sage/graphs/base/sparse_graph.pyx index 49e48d6e706..1752193413c 100644 --- a/src/sage/graphs/base/sparse_graph.pyx +++ b/src/sage/graphs/base/sparse_graph.pyx @@ -1403,7 +1403,7 @@ cdef class SparseGraphBackend(CGraphBackend): """ Initialize a sparse graph with n vertices. - EXAMPLES: + EXAMPLES:: sage: D = sage.graphs.base.sparse_graph.SparseGraphBackend(9) sage: D.add_edge(0,1,None,False) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 6ea39a801ab..b04a11762da 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -1205,7 +1205,7 @@ def __copy__(self): A new graph instance that is as close as possible to the original graph. The output is always mutable. - EXAMPLES: + EXAMPLES:: sage: g = Graph({0: [1, 2, 3], 2: [4]}, immutable=True) sage: g.weighted(list(range(5))) diff --git a/src/sage/graphs/orientations.py b/src/sage/graphs/orientations.py index e96eba12752..3e81af1fb66 100644 --- a/src/sage/graphs/orientations.py +++ b/src/sage/graphs/orientations.py @@ -191,7 +191,7 @@ def _strong_orientations_of_a_mixed_graph(Dg, V, E): - an iterator which will produce all strong orientations of the input partially directed graph. - EXAMPLES: + EXAMPLES:: sage: from sage.graphs.orientations import _strong_orientations_of_a_mixed_graph sage: g = graphs.CycleGraph(5) diff --git a/src/sage/graphs/strongly_regular_db.pyx b/src/sage/graphs/strongly_regular_db.pyx index 55a14287563..3a76f893d70 100644 --- a/src/sage/graphs/strongly_regular_db.pyx +++ b/src/sage/graphs/strongly_regular_db.pyx @@ -3096,7 +3096,7 @@ def _build_small_srg_database(): parameters of the graph of words of `C`. Another relevant reference is Sect.9.8.3 of [BH12]_. - EXAMPLES: + EXAMPLES:: sage: from sage.graphs.strongly_regular_db import _build_small_srg_database sage: _build_small_srg_database() diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index f07e778884b..58b8189d2ef 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -101,7 +101,7 @@ class AdditiveAbelianGroupWrapperElement(addgp.AdditiveAbelianGroupElement): def __init__(self, parent, vector, element=None, check=False): r""" - EXAMPLES: + EXAMPLES:: sage: from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) diff --git a/src/sage/groups/group.pyx b/src/sage/groups/group.pyx index 61a1728ec57..7e70a3de136 100644 --- a/src/sage/groups/group.pyx +++ b/src/sage/groups/group.pyx @@ -213,7 +213,7 @@ cdef class Group(Parent): An element of the group. - EXAMPLES: + EXAMPLES:: sage: G = AbelianGroup([2,3,4,5]) sage: G.an_element() diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx index 0cc181cb684..908f88d04e8 100644 --- a/src/sage/groups/libgap_wrapper.pyx +++ b/src/sage/groups/libgap_wrapper.pyx @@ -292,7 +292,7 @@ class ParentLibGAP(SageObject): A :class:`~sage.libs.gap.element.GapElement` - EXAMPLES: + EXAMPLES:: sage: G = FreeGroup(2) sage: G._gap_gens() diff --git a/src/sage/groups/lie_gps/nilpotent_lie_group.py b/src/sage/groups/lie_gps/nilpotent_lie_group.py index e334c2875ef..78001d2e9be 100644 --- a/src/sage/groups/lie_gps/nilpotent_lie_group.py +++ b/src/sage/groups/lie_gps/nilpotent_lie_group.py @@ -911,7 +911,7 @@ def _repr_(self): Supports printing in exponential coordinates of the first and second kinds, depending on the default coordinate system. - EXAMPLES: + EXAMPLES:: sage: L = LieAlgebra(QQ, 2, step=2) sage: G = L.lie_group('H') diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx index 31938b8944e..b4aa2bcbcf8 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx @@ -115,7 +115,8 @@ cdef class LinearBinaryCodeStruct(BinaryCodeStruct): partition -- an optional list of lists partition of the columns. default is the unit partition. - EXAMPLES: + EXAMPLES:: + sage: from sage.groups.perm_gps.partn_ref.refinement_binary import LinearBinaryCodeStruct sage: B = LinearBinaryCodeStruct(matrix(GF(2),[[1,0,1],[0,1,1]])) @@ -301,7 +302,8 @@ cdef class LinearBinaryCodeStruct(BinaryCodeStruct): """ Calculate whether self is isomorphic to other. - EXAMPLES: + EXAMPLES:: + sage: from sage.groups.perm_gps.partn_ref.refinement_binary import LinearBinaryCodeStruct sage: B = LinearBinaryCodeStruct(Matrix(GF(2), [[1,1,1,1,0,0],[0,0,1,1,1,1]])) @@ -463,7 +465,8 @@ cdef class NonlinearBinaryCodeStruct(BinaryCodeStruct): partition -- an optional list of lists partition of the columns. default is the unit partition. - EXAMPLES: + EXAMPLES:: + sage: from sage.groups.perm_gps.partn_ref.refinement_binary import NonlinearBinaryCodeStruct sage: B = NonlinearBinaryCodeStruct(Matrix(GF(2), [[1,0,0,0],[0,0,1,0]])) @@ -562,7 +565,8 @@ cdef class NonlinearBinaryCodeStruct(BinaryCodeStruct): """ Calculate whether self is isomorphic to other. - EXAMPLES: + EXAMPLES:: + sage: from sage.groups.perm_gps.partn_ref.refinement_binary import NonlinearBinaryCodeStruct sage: B = NonlinearBinaryCodeStruct(Matrix(GF(2), [[1,1,1,1,0,0],[0,0,1,1,1,1]])) diff --git a/src/sage/homology/simplicial_complex.py b/src/sage/homology/simplicial_complex.py index 946eda090a4..1c9797f6c61 100644 --- a/src/sage/homology/simplicial_complex.py +++ b/src/sage/homology/simplicial_complex.py @@ -4586,7 +4586,7 @@ def intersection(self,other): r""" Calculate the intersection of two simplicial complexes. - EXAMPLES: + EXAMPLES:: sage: X = SimplicialComplex([[1,2,3],[1,2,4]]) sage: Y = SimplicialComplex([[1,2,3],[1,4,5]]) diff --git a/src/sage/homology/simplicial_set_constructions.py b/src/sage/homology/simplicial_set_constructions.py index 46be7d06bea..69edf35459b 100644 --- a/src/sage/homology/simplicial_set_constructions.py +++ b/src/sage/homology/simplicial_set_constructions.py @@ -2783,7 +2783,7 @@ def __repr_or_latex__(self, output_type=None): We use `S` to denote unreduced suspension, `\Sigma` for reduced suspension. - EXAMPLES: + EXAMPLES:: sage: T = simplicial_sets.Torus() sage: K = T.suspension(10) @@ -2824,7 +2824,7 @@ def _repr_(self): We use `S` to denote unreduced suspension, `\Sigma` for reduced suspension. - EXAMPLES: + EXAMPLES:: sage: S2 = simplicial_sets.Sphere(2) sage: S2.suspension(3) @@ -2844,7 +2844,7 @@ def _latex_(self): We use `S` to denote unreduced suspension, `\Sigma` for reduced suspension. - EXAMPLES: + EXAMPLES:: sage: S2 = simplicial_sets.Sphere(2) sage: latex(S2.suspension(3)) diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py index aa7bc198a03..b201707f0f4 100644 --- a/src/sage/interfaces/gap.py +++ b/src/sage/interfaces/gap.py @@ -1,4 +1,4 @@ -# -*- coding: UTF-8 -*- +# -*- coding: utf-8 -*- r""" Interface to GAP @@ -295,7 +295,7 @@ def _get_gap_memory_pool_size_MB(): String. - EXAMPLES: + EXAMPLES:: sage: from sage.interfaces.gap import \ ....: _get_gap_memory_pool_size_MB diff --git a/src/sage/libs/coxeter3/coxeter.pyx b/src/sage/libs/coxeter3/coxeter.pyx index 694239fd555..98d6287f12f 100644 --- a/src/sage/libs/coxeter3/coxeter.pyx +++ b/src/sage/libs/coxeter3/coxeter.pyx @@ -797,7 +797,7 @@ cdef class CoxGroupElement: def __richcmp__(CoxGroupElement self, other, int op): """ - EXAMPLES: + EXAMPLES:: sage: from sage.libs.coxeter3.coxeter import * # optional - coxeter3 sage: W = CoxGroup(['A', 5]) # optional - coxeter3 diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx index e4088660b27..ee5cc783550 100644 --- a/src/sage/libs/ecl.pyx +++ b/src/sage/libs/ecl.pyx @@ -1145,7 +1145,7 @@ cdef class EclObject: Strings are not characters - EXAMPLES: + EXAMPLES:: sage: from sage.libs.ecl import * sage: EclObject('"a"').characterp() diff --git a/src/sage/libs/gap/operations.py b/src/sage/libs/gap/operations.py index f28b4ab48bb..28c38ee1fea 100644 --- a/src/sage/libs/gap/operations.py +++ b/src/sage/libs/gap/operations.py @@ -54,7 +54,7 @@ def _repr_(self): String - EXAMPLES: + EXAMPLES:: sage: from sage.libs.gap.operations import OperationInspector sage: opr = OperationInspector(libgap(123)) diff --git a/src/sage/libs/ntl/ntl_GF2.pyx b/src/sage/libs/ntl/ntl_GF2.pyx index a86990e5f77..c7083501620 100644 --- a/src/sage/libs/ntl/ntl_GF2.pyx +++ b/src/sage/libs/ntl/ntl_GF2.pyx @@ -40,7 +40,8 @@ cdef class ntl_GF2(object): r""" Initializes a NTL bit. - EXAMPLES: + EXAMPLES:: + sage: ntl.GF2(1) 1 sage: ntl.GF2(int(2)) @@ -59,7 +60,8 @@ cdef class ntl_GF2(object): """ Return the string representation of self. - EXAMPLES: + EXAMPLES:: + sage: str(ntl.GF2(1)) # indirect doctest '1' """ @@ -69,7 +71,8 @@ cdef class ntl_GF2(object): """ Serializes self. - EXAMPLES: + EXAMPLES:: + sage: a = ntl.GF2(1) sage: loads(dumps(a)) 1 @@ -224,7 +227,8 @@ cdef class ntl_GF2(object): """ Return self as an int. - EXAMPLES: + EXAMPLES:: + sage: o = ntl.GF2(1) sage: z = ntl.GF2(0) sage: int(z) @@ -239,7 +243,8 @@ def unpickle_class_value(cls, x): """ Here for unpickling. - EXAMPLES: + EXAMPLES:: + sage: sage.libs.ntl.ntl_GF2.unpickle_class_value(ntl.GF2,1) 1 sage: type(sage.libs.ntl.ntl_GF2.unpickle_class_value(ntl.GF2,1)) @@ -251,7 +256,8 @@ def unpickle_class_args(cls, x): """ Here for unpickling. - EXAMPLES: + EXAMPLES:: + sage: sage.libs.ntl.ntl_GF2.unpickle_class_args(ntl.GF2,[1]) 1 sage: type(sage.libs.ntl.ntl_GF2.unpickle_class_args(ntl.GF2,[1])) diff --git a/src/sage/libs/ntl/ntl_GF2E.pyx b/src/sage/libs/ntl/ntl_GF2E.pyx index ab15f89c692..8c0f5583d18 100644 --- a/src/sage/libs/ntl/ntl_GF2E.pyx +++ b/src/sage/libs/ntl/ntl_GF2E.pyx @@ -92,7 +92,8 @@ cdef class ntl_GF2E(object): OUTPUT: a new ntl.GF2E element - EXAMPLES: + EXAMPLES:: + sage: k. = GF(2^8) sage: e = ntl.GF2E(a,k); e [0 1] @@ -169,7 +170,8 @@ cdef class ntl_GF2E(object): """ Returns the structure that holds the underlying NTL GF2E modulus. - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext( ntl.GF2X([1,1,0,1,1,0,0,0,1]) ) sage: a = ntl.GF2E(ntl.ZZ_pX([1,1,3],2), ctx) sage: cty = a.modulus_context(); cty @@ -183,7 +185,8 @@ cdef class ntl_GF2E(object): """ Return the string representation of self. - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: ntl.GF2E([1,1,0,1], ctx) # indirect doctest [1 1 0 1] @@ -195,7 +198,8 @@ cdef class ntl_GF2E(object): """ Return a copy of self. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.GF2E([0,1,1],GF(2^4,'a')) sage: y = copy(x) sage: x == y @@ -209,7 +213,8 @@ cdef class ntl_GF2E(object): def __mul__(ntl_GF2E self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) ; y = ntl.GF2E([1,1,0,1,1], ctx) sage: x*y ## indirect doctest @@ -226,7 +231,8 @@ cdef class ntl_GF2E(object): def __sub__(ntl_GF2E self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) ; y = ntl.GF2E([1,1,0,1,1], ctx) sage: x - y ## indirect doctest @@ -243,7 +249,8 @@ cdef class ntl_GF2E(object): def __add__(ntl_GF2E self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) ; y = ntl.GF2E([1,1,0,1,1], ctx) sage: x+y ## indirect doctest @@ -260,7 +267,8 @@ cdef class ntl_GF2E(object): def __truediv__(ntl_GF2E self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) ; y = ntl.GF2E([1,1,0,1,1], ctx) sage: x/y ## indirect doctest @@ -280,7 +288,8 @@ cdef class ntl_GF2E(object): def __neg__(ntl_GF2E self): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) sage: -x ## indirect doctest @@ -292,7 +301,8 @@ cdef class ntl_GF2E(object): def __pow__(ntl_GF2E self, long e, ignored): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) sage: x**2 ## indirect doctest @@ -337,7 +347,8 @@ cdef class ntl_GF2E(object): """ Returns True if this element equals zero, False otherwise. - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) ; y = ntl.GF2E([1,1,0,1,1,0,0,0,1], ctx) sage: x.IsZero() @@ -351,7 +362,8 @@ cdef class ntl_GF2E(object): """ Returns True if this element equals one, False otherwise. - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) ; y = ntl.GF2E([0,1,0,1,1,0,0,0,1], ctx) sage: x.IsOne() @@ -365,7 +377,8 @@ cdef class ntl_GF2E(object): """ Returns the trace of this element. - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: x = ntl.GF2E([1,0,1,0,1], ctx) ; y = ntl.GF2E([0,1,1,0,1,1], ctx) sage: x.trace() @@ -381,7 +394,8 @@ cdef class ntl_GF2E(object): """ Returns a ntl.GF2X copy of this element. - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,0,0,1])) sage: a = ntl.GF2E('0x1c', ctx) sage: a.rep() @@ -397,7 +411,8 @@ cdef class ntl_GF2E(object): """ Represents this element as a list of binary digits. - EXAMPLES: + EXAMPLES:: + sage: e=ntl.GF2E([0,1,1],GF(2^4,'a')) sage: e.list() [0, 1, 1] @@ -434,7 +449,8 @@ cdef class ntl_GF2E(object): OUTPUT: FiniteFieldElement over k - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext([1,1,0,1,1,0,0,0,1]) sage: e = ntl.GF2E([0,1], ctx) sage: a = e._sage_(); a diff --git a/src/sage/libs/ntl/ntl_GF2EContext.pyx b/src/sage/libs/ntl/ntl_GF2EContext.pyx index 3728a2fe69e..68f911fa121 100644 --- a/src/sage/libs/ntl/ntl_GF2EContext.pyx +++ b/src/sage/libs/ntl/ntl_GF2EContext.pyx @@ -24,7 +24,8 @@ GF2EContextDict = {} cdef class ntl_GF2EContext_class(object): def __init__(self, ntl_GF2X v): """ - EXAMPLES: + EXAMPLES:: + # You can construct contexts manually. sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1])) sage: n1 = ntl.GF2E([1,1],ctx) @@ -51,7 +52,8 @@ cdef class ntl_GF2EContext_class(object): def __reduce__(self): """ - EXAMPLES: + EXAMPLES:: + sage: c = ntl.GF2EContext(GF(2^5,'b')) sage: loads(dumps(c)) is c True @@ -62,10 +64,11 @@ cdef class ntl_GF2EContext_class(object): """ Returns a print representation of self. - EXAMPLES: - sage: c = ntl.GF2EContext(GF(2^16,'a')) - sage: c - NTL modulus [1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1] + EXAMPLES:: + + sage: c = ntl.GF2EContext(GF(2^16,'a')) + sage: c + NTL modulus [1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1] """ return "NTL modulus %s"%(self.m) @@ -74,7 +77,8 @@ cdef class ntl_GF2EContext_class(object): Return the current modulus associated to this context. - EXAMPLES: + EXAMPLES:: + sage: c = ntl.GF2EContext(GF(2^7,'foo')) sage: c.modulus() [1 1 0 0 0 0 0 1] @@ -84,7 +88,8 @@ cdef class ntl_GF2EContext_class(object): def restore(self): """ - EXAMPLES: + EXAMPLES:: + sage: c1 = ntl.GF2E([0,1],GF(2^4,'a')) ; c2 = ntl.GF2E([1,0,1],GF(2^4,'a')) sage: c1+c2 [1 1 1] @@ -100,7 +105,9 @@ cdef class ntl_GF2EContext_class(object): def ntl_GF2EContext( v ): """ Create a new GF2EContext. - EXAMPLES: + + EXAMPLES:: + sage: c = ntl.GF2EContext(GF(2^2,'a')) sage: n1 = ntl.GF2E([0,1],c) sage: n1 diff --git a/src/sage/libs/ntl/ntl_GF2EX.pyx b/src/sage/libs/ntl/ntl_GF2EX.pyx index b902ca3f117..3b17d720388 100644 --- a/src/sage/libs/ntl/ntl_GF2EX.pyx +++ b/src/sage/libs/ntl/ntl_GF2EX.pyx @@ -43,7 +43,8 @@ cdef class ntl_GF2EX(object): """ Minimal wrapper of NTL's GF2EX class. - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: ntl.GF2EX(ctx, '[[1 0] [2 1]]') [[1] [0 1]] @@ -99,7 +100,8 @@ cdef class ntl_GF2EX(object): def __reduce__(self): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0 1] [1 0 0 1] [1]]') sage: f == loads(dumps(f)) @@ -140,7 +142,8 @@ cdef class ntl_GF2EX(object): """ Return the string representation of self. - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: ntl.GF2EX(ctx, '[[1 0] [2 1]]').__repr__() '[[1] [0 1]]' @@ -149,7 +152,8 @@ cdef class ntl_GF2EX(object): def __mul__(ntl_GF2EX self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: g = ntl.GF2EX(ctx, '[[1 0 1 1] [0 1 1 0 1] [1 0 1]]') @@ -168,7 +172,8 @@ cdef class ntl_GF2EX(object): def __sub__(ntl_GF2EX self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: g = ntl.GF2EX(ctx, '[[1 0 1 1] [0 1 1 0 1] [1 0 1]]') @@ -187,7 +192,8 @@ cdef class ntl_GF2EX(object): def __add__(ntl_GF2EX self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: g = ntl.GF2EX(ctx, '[[1 0 1 1] [0 1 1 0 1] [1 0 1]]') @@ -206,7 +212,8 @@ cdef class ntl_GF2EX(object): def __neg__(ntl_GF2EX self): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: -f ## indirect doctest @@ -220,7 +227,8 @@ cdef class ntl_GF2EX(object): def __pow__(ntl_GF2EX self, long e, ignored): """ - EXAMPLES: + EXAMPLES:: + sage: ctx = ntl.GF2EContext(ntl.GF2X([1,1,0,1,1,0,1])) sage: f = ntl.GF2EX(ctx, '[[1 0] [2 1]]') sage: f**2 ## indirect doctest diff --git a/src/sage/libs/ntl/ntl_GF2X_linkage.pxi b/src/sage/libs/ntl/ntl_GF2X_linkage.pxi index 77d66c16983..fd5a276eecc 100644 --- a/src/sage/libs/ntl/ntl_GF2X_linkage.pxi +++ b/src/sage/libs/ntl/ntl_GF2X_linkage.pxi @@ -26,14 +26,16 @@ from sage.libs.ntl.GF2X cimport * cdef GF2X_c *celement_new(long parent): """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] """ return new GF2X_c() cdef int celement_delete(GF2X_c *e, long parent): """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: del x """ @@ -41,14 +43,16 @@ cdef int celement_delete(GF2X_c *e, long parent): cdef int celement_construct(GF2X_c *e, long parent): """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] """ pass cdef int celement_destruct(GF2X_c *e, long parent): """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: del x """ @@ -56,7 +60,8 @@ cdef int celement_destruct(GF2X_c *e, long parent): cdef int celement_gen(GF2X_c *e, long i, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] """ cdef unsigned char g = 2 @@ -66,7 +71,8 @@ cdef object celement_repr(GF2X_c *e, long parent): """ We ignore NTL's printing. - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x x @@ -75,7 +81,8 @@ cdef object celement_repr(GF2X_c *e, long parent): cdef inline int celement_set(GF2X_c* res, GF2X_c* a, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: y = x; y x @@ -84,7 +91,8 @@ cdef inline int celement_set(GF2X_c* res, GF2X_c* a, long parent) except -2: cdef inline int celement_set_si(GF2X_c* res, long i, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: P(0) 0 @@ -100,7 +108,8 @@ cdef inline long celement_get_si(GF2X_c* res, long parent) except -2: cdef inline bint celement_is_zero(GF2X_c* a, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: bool(x), x.is_zero() (True, False) @@ -111,7 +120,8 @@ cdef inline bint celement_is_zero(GF2X_c* a, long parent) except -2: cdef inline bint celement_is_one(GF2X_c *a, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x.is_one() False @@ -122,7 +132,8 @@ cdef inline bint celement_is_one(GF2X_c *a, long parent) except -2: cdef inline bint celement_equal(GF2X_c *a, GF2X_c *b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x == x True @@ -135,7 +146,8 @@ cdef inline bint celement_equal(GF2X_c *a, GF2X_c *b, long parent) except -2: cdef inline int celement_cmp(GF2X_c *a, GF2X_c *b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x != 1 True @@ -179,7 +191,8 @@ cdef inline int celement_cmp(GF2X_c *a, GF2X_c *b, long parent) except -2: cdef long celement_len(GF2X_c *a, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x.degree() 1 @@ -190,7 +203,8 @@ cdef long celement_len(GF2X_c *a, long parent) except -2: cdef inline int celement_add(GF2X_c *res, GF2X_c *a, GF2X_c *b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x + 1 x + 1 @@ -199,7 +213,8 @@ cdef inline int celement_add(GF2X_c *res, GF2X_c *a, GF2X_c *b, long parent) exc cdef inline int celement_sub(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x - 1 x + 1 @@ -208,7 +223,8 @@ cdef inline int celement_sub(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent) exc cdef inline int celement_neg(GF2X_c* res, GF2X_c* a, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: -x x @@ -236,7 +252,8 @@ cdef inline int celement_mul_scalar(GF2X_c* res, GF2X_c* p, object c, cdef inline int celement_mul(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x*(x+1) x^2 + x @@ -245,14 +262,16 @@ cdef inline int celement_mul(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent) exc cdef inline int celement_div(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] """ return GF2X_divide(res[0], a[0], b[0]) cdef inline int celement_floordiv(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x//(x + 1) 1 @@ -263,7 +282,8 @@ cdef inline int celement_floordiv(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent cdef inline int celement_mod(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: (x^2 + 1) % x^2 1 @@ -272,7 +292,8 @@ cdef inline int celement_mod(GF2X_c* res, GF2X_c* a, GF2X_c* b, long parent) exc cdef inline int celement_quorem(GF2X_c* q, GF2X_c* r, GF2X_c* a, GF2X_c* b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: f = x^2 + x + 1 sage: f.quo_rem(x + 1) @@ -284,14 +305,16 @@ cdef inline int celement_inv(GF2X_c* res, GF2X_c* a, long parent) except -2: """ We ignore NTL here and use the fraction field constructor. - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] """ raise NotImplementedError cdef inline int celement_pow(GF2X_c* res, GF2X_c* x, long e, GF2X_c *modulus, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: x^1000 x^1000 @@ -326,7 +349,8 @@ cdef inline int celement_pow(GF2X_c* res, GF2X_c* x, long e, GF2X_c *modulus, lo cdef inline int celement_gcd(GF2X_c* res, GF2X_c* a, GF2X_c *b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: f = x*(x+1) sage: f.gcd(x+1) @@ -338,7 +362,8 @@ cdef inline int celement_gcd(GF2X_c* res, GF2X_c* a, GF2X_c *b, long parent) exc cdef inline int celement_xgcd(GF2X_c* res, GF2X_c* s, GF2X_c *t, GF2X_c* a, GF2X_c *b, long parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = GF(2)[] sage: f = x*(x+1) sage: f.xgcd(x+1) diff --git a/src/sage/libs/ntl/ntl_ZZ.pyx b/src/sage/libs/ntl/ntl_ZZ.pyx index a32b2cae80c..b504501ca8e 100644 --- a/src/sage/libs/ntl/ntl_ZZ.pyx +++ b/src/sage/libs/ntl/ntl_ZZ.pyx @@ -102,7 +102,8 @@ cdef class ntl_ZZ(object): """ Return the string representation of self. - EXAMPLES: + EXAMPLES:: + sage: ntl.ZZ(5).__repr__() '5' """ @@ -244,7 +245,8 @@ cdef class ntl_ZZ(object): """ Return self as an int. - EXAMPLES: + EXAMPLES:: + sage: ntl.ZZ(22).__int__() 22 sage: type(ntl.ZZ(22).__int__()) @@ -310,7 +312,8 @@ cdef class ntl_ZZ(object): r""" Sets the value from a sage int. - EXAMPLES: + EXAMPLES:: + sage: n=ntl.ZZ(2983) sage: n 2983 @@ -394,7 +397,8 @@ def unpickle_class_value(cls, x): """ Here for unpickling. - EXAMPLES: + EXAMPLES:: + sage: sage.libs.ntl.ntl_ZZ.unpickle_class_value(ntl.ZZ, 3) 3 sage: type(sage.libs.ntl.ntl_ZZ.unpickle_class_value(ntl.ZZ, 3)) @@ -406,7 +410,8 @@ def unpickle_class_args(cls, x): """ Here for unpickling. - EXAMPLES: + EXAMPLES:: + sage: sage.libs.ntl.ntl_ZZ.unpickle_class_args(ntl.ZZ, [3]) 3 sage: type(sage.libs.ntl.ntl_ZZ.unpickle_class_args(ntl.ZZ, [3])) diff --git a/src/sage/libs/ntl/ntl_ZZX.pyx b/src/sage/libs/ntl/ntl_ZZX.pyx index caf87d10554..1ee992279b3 100644 --- a/src/sage/libs/ntl/ntl_ZZX.pyx +++ b/src/sage/libs/ntl/ntl_ZZX.pyx @@ -107,7 +107,8 @@ cdef class ntl_ZZX(object): # See ntl_ZZX.pxd for definition of data members def __init__(self, v=None): """ - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,5,-9]) sage: f [1 2 5 -9] @@ -148,7 +149,8 @@ cdef class ntl_ZZX(object): """ Return the string representation of self. - EXAMPLES: + EXAMPLES:: + sage: ntl.ZZX([1,3,0,5]).__repr__() '[1 3 0 5]' """ @@ -162,7 +164,8 @@ cdef class ntl_ZZX(object): """ Return a copy of self. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZX([1,32]) sage: y = copy(x) sage: y == x @@ -263,7 +266,8 @@ cdef class ntl_ZZX(object): r""" Retrieves coefficients as a list of ntl.ZZ Integers. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZX([129381729371289371237128318293718237, 2, -3, 0, 4]) sage: L = x.list(); L [129381729371289371237128318293718237, 2, -3, 0, 4] @@ -278,7 +282,8 @@ cdef class ntl_ZZX(object): def __add__(ntl_ZZX self, ntl_ZZX other): """ - EXAMPLES: + EXAMPLES:: + sage: ntl.ZZX(list(range(5))) + ntl.ZZX(list(range(6))) [0 2 4 6 8 5] """ @@ -292,7 +297,8 @@ cdef class ntl_ZZX(object): def __sub__(ntl_ZZX self, ntl_ZZX other): """ - EXAMPLES: + EXAMPLES:: + sage: ntl.ZZX(list(range(5))) - ntl.ZZX(list(range(6))) [0 0 0 0 0 -5] """ @@ -306,7 +312,8 @@ cdef class ntl_ZZX(object): def __mul__(ntl_ZZX self, ntl_ZZX other): """ - EXAMPLES: + EXAMPLES:: + sage: ntl.ZZX(list(range(5))) * ntl.ZZX(list(range(6))) [0 0 1 4 10 20 30 34 31 20] """ @@ -325,7 +332,8 @@ cdef class ntl_ZZX(object): Compute quotient self / other, if the quotient is a polynomial. Otherwise an Exception is raised. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3]) * ntl.ZZX([4,5])**2 sage: g = ntl.ZZX([4,5]) sage: f/g @@ -360,7 +368,8 @@ cdef class ntl_ZZX(object): function returns q if q lies in ZZ[X], and otherwise raises an Exception. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([2,4,6]); g = ntl.ZZX([2]) sage: f % g # 0 [] @@ -384,7 +393,8 @@ cdef class ntl_ZZX(object): Returns the unique integral q and r such that self = q*other + r, if they exist. Otherwise raises an Exception. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX(list(range(10))); g = ntl.ZZX([-1,0,1]) sage: q, r = f.quo_rem(g) sage: q, r @@ -405,7 +415,8 @@ cdef class ntl_ZZX(object): """ Return f*f. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([-1,0,1]) sage: f*f [1 0 -2 0 1] @@ -469,7 +480,8 @@ cdef class ntl_ZZX(object): """ Return True exactly if this polynomial is 0. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([0,0,0,0]) sage: f.is_zero() True @@ -485,7 +497,8 @@ cdef class ntl_ZZX(object): """ Return True exactly if this polynomial is 1. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,1]) sage: f.is_one() False @@ -499,7 +512,8 @@ cdef class ntl_ZZX(object): """ Return True exactly if this polynomial is monic. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([2,0,0,1]) sage: f.is_monic() True @@ -520,7 +534,9 @@ cdef class ntl_ZZX(object): def __neg__(self): """ Return the negative of self. - EXAMPLES: + + EXAMPLES:: + sage: f = ntl.ZZX([2,0,0,1]) sage: -f [-2 0 0 -1] @@ -532,7 +548,8 @@ cdef class ntl_ZZX(object): Return the polynomial obtained by shifting all coefficients of this polynomial to the left n positions. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([2,0,0,1]) sage: f [2 0 0 1] @@ -552,7 +569,8 @@ cdef class ntl_ZZX(object): Return the polynomial obtained by shifting all coefficients of this polynomial to the right n positions. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([2,0,0,1]) sage: f [2 0 0 1] @@ -571,7 +589,8 @@ cdef class ntl_ZZX(object): leading coefficient of f. Also, our convention is that the content of 0 is 0. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([2,0,0,2]) sage: f.content() 2 @@ -595,7 +614,8 @@ cdef class ntl_ZZX(object): coefficient of the primitive part is nonnegative, and the primitive part of 0 is 0. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([6,12,3,9]) sage: f.primitive_part() [2 4 1 3] @@ -618,7 +638,8 @@ cdef class ntl_ZZX(object): deg(b), and \code{LeadCoeff(b)\^(deg(a)-deg(b)+1) a = b q + r}. Only the classical algorithm is used. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([0,1]) sage: g = ntl.ZZX([1,2,3]) sage: g.pseudo_quo_rem(f) @@ -641,7 +662,8 @@ cdef class ntl_ZZX(object): Return the gcd d = gcd(a, b), where by convention the leading coefficient of d is >= 0. We use a multi-modular algorithm. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3]) * ntl.ZZX([4,5])**2 sage: g = ntl.ZZX([1,1,1])**3 * ntl.ZZX([1,2,3]) sage: f.gcd(g) @@ -656,7 +678,8 @@ cdef class ntl_ZZX(object): """ Return the least common multiple of self and other. - EXAMPLES: + EXAMPLES:: + sage: x1 = ntl.ZZX([-1,0,0,1]) sage: x2 = ntl.ZZX([-1,0,0,0,0,0,1]) sage: x1.lcm(x2) @@ -684,7 +707,8 @@ cdef class ntl_ZZX(object): $2^{-80}$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3]) * ntl.ZZX([4,5])**2 sage: g = ntl.ZZX([1,1,1])**3 * ntl.ZZX([1,2,3]) sage: f.xgcd(g) # nothing since they are not coprime @@ -713,7 +737,8 @@ cdef class ntl_ZZX(object): Return the degree of this polynomial. The degree of the 0 polynomial is -1. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([5,0,1]) sage: f.degree() 2 @@ -733,7 +758,8 @@ cdef class ntl_ZZX(object): """ Return the leading coefficient of this polynomial. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([3,6,9]) sage: f.leading_coefficient() 9 @@ -749,7 +775,8 @@ cdef class ntl_ZZX(object): """ Return the constant coefficient of this polynomial. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([3,6,9]) sage: f.constant_term() 3 @@ -765,7 +792,8 @@ cdef class ntl_ZZX(object): """ Set this polynomial to the monomial "x". - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX() sage: f.set_x() sage: f @@ -784,7 +812,8 @@ cdef class ntl_ZZX(object): """ True if this is the polynomial "x". - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX() sage: f.set_x() sage: f.is_x() @@ -802,7 +831,8 @@ cdef class ntl_ZZX(object): """ Return the derivative of this polynomial. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,7,0,13]) sage: f.derivative() [7 0 39] @@ -815,7 +845,8 @@ cdef class ntl_ZZX(object): of this polynomial. If hi is set then this function behaves as if this polynomial has degree hi. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3,4,5]) sage: f.reverse() [5 4 3 2 1] @@ -836,7 +867,8 @@ cdef class ntl_ZZX(object): Return the truncation of this polynomial obtained by removing all terms of degree >= m. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3,4,5]) sage: f.truncate(3) [1 2 3] @@ -861,7 +893,8 @@ cdef class ntl_ZZX(object): """ Return self*other but with terms of degree >= m removed. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3,4,5]) sage: g = ntl.ZZX([10]) sage: f.multiply_and_truncate(g, 2) @@ -878,7 +911,8 @@ cdef class ntl_ZZX(object): """ Return self*self but with terms of degree >= m removed. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3,4,5]) sage: f.square_and_truncate(4) [1 4 10 20] @@ -895,7 +929,8 @@ cdef class ntl_ZZX(object): Compute and return the inverse of self modulo $x^m$. The constant term of self must be 1 or -1. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3,4,5,6,7]) sage: f.invert_and_truncate(20) [1 -2 1 0 0 0 0 8 -23 22 -7 0 0 0 64 -240 337 -210 49] @@ -916,7 +951,8 @@ cdef class ntl_ZZX(object): Return self*other % modulus. The modulus must be monic with deg(modulus) > 0, and self and other must have smaller degree. - EXAMPLES: + EXAMPLES:: + sage: modulus = ntl.ZZX([1,2,0,1]) # must be monic sage: g = ntl.ZZX([-1,0,1]) sage: h = ntl.ZZX([3,7,13]) @@ -932,7 +968,8 @@ cdef class ntl_ZZX(object): The modulus must be monic, and of positive degree degree bigger than the degree of self. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,0,3]) sage: mod = ntl.ZZX([5,3,-1,1,1]) sage: f.trace_mod(mod) @@ -947,12 +984,14 @@ cdef class ntl_ZZX(object): monomial x modulo this polynomial for i = 0, ..., deg(f)-1. This polynomial must be monic. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,0,3,0,1]) sage: f.trace_list() [5, 0, -6, 0, 10] - The input polynomial must be monic or a ValueError is raised: + The input polynomial must be monic or a ValueError is raised:: + sage: f = ntl.ZZX([1,2,0,3,0,2]) sage: f.trace_list() Traceback (most recent call last): @@ -976,7 +1015,8 @@ cdef class ntl_ZZX(object): randomized strategy that errors with probability no more than $2^{-80}$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([17,0,1,1]) sage: g = ntl.ZZX([34,-17,18,2]) sage: f.resultant(g) @@ -1000,13 +1040,15 @@ cdef class ntl_ZZX(object): randomized strategy that errors with probability no more than $2^{-80}$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,0,3]) sage: mod = ntl.ZZX([-5,2,0,0,1]) sage: f.norm_mod(mod) -8846 - The norm is the constant term of the characteristic polynomial. + The norm is the constant term of the characteristic polynomial:: + sage: f.charpoly_mod(mod) [-8846 -594 -60 14 1] """ @@ -1027,7 +1069,8 @@ cdef class ntl_ZZX(object): randomized strategy that errors with probability no more than $2^{-80}$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,0,3]) sage: f.discriminant() -339 @@ -1052,7 +1095,8 @@ cdef class ntl_ZZX(object): randomized strategy that errors with probability no more than $2^{-80}$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,0,3]) sage: mod = ntl.ZZX([-5,2,0,0,1]) sage: f.charpoly_mod(mod) @@ -1070,14 +1114,16 @@ cdef class ntl_ZZX(object): self. In all cases, this function may use a randomized strategy that errors with probability no more than $2^{-80}$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([0,0,1]) sage: g = f*f sage: f.charpoly_mod(g) [0 0 0 0 1] However, since $f^2 = 0$ modulo $g$, its minimal polynomial - is of degree $2$. + is of degree $2$:: + sage: f.minpoly_mod_noproof(g) [0 0 1] """ @@ -1088,7 +1134,8 @@ cdef class ntl_ZZX(object): """ Reset this polynomial to 0. Changes this polynomial in place. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3]) sage: f [1 2 3] @@ -1106,7 +1153,8 @@ cdef class ntl_ZZX(object): the polynomial grows. (You might save a millisecond with this function.) - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([1,2,3]) sage: f.preallocate_space(20) sage: f @@ -1127,7 +1175,8 @@ cdef class ntl_ZZX(object): is a factor, and the second is its exponent. Assumes that self is primitive. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.ZZX([0, 1, 2, 1]) sage: f.squarefree_decomposition() [([0 1], 1), ([1 1], 2)] diff --git a/src/sage/libs/ntl/ntl_ZZ_p.pyx b/src/sage/libs/ntl/ntl_ZZ_p.pyx index 0ed38a1f736..50ea48dace6 100644 --- a/src/sage/libs/ntl/ntl_ZZ_p.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_p.pyx @@ -85,7 +85,8 @@ cdef class ntl_ZZ_p(object): r""" Initializes an NTL integer mod p. - EXAMPLES: + EXAMPLES:: + sage: c = ntl.ZZ_pContext(11) sage: ntl.ZZ_p(12r, c) 1 @@ -165,7 +166,8 @@ cdef class ntl_ZZ_p(object): """ Return the modulus for self. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(5,17) sage: c = x.modulus_context() sage: y = ntl.ZZ_p(3,c) @@ -182,7 +184,8 @@ cdef class ntl_ZZ_p(object): """ Return the string representation of self. - EXAMPLES: + EXAMPLES:: + sage: ntl.ZZ_p(7,192).__repr__() '7' """ @@ -220,7 +223,8 @@ cdef class ntl_ZZ_p(object): def __invert__(ntl_ZZ_p self): r""" - EXAMPLES: + EXAMPLES:: + sage: c=ntl.ZZ_pContext(11) sage: ~ntl.ZZ_p(2r,modulus=c) 6 @@ -234,7 +238,8 @@ cdef class ntl_ZZ_p(object): def __mul__(ntl_ZZ_p self, other): """ - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(5,31) ; y = ntl.ZZ_p(8,31) sage: x*y ## indirect doctest 9 @@ -252,7 +257,8 @@ cdef class ntl_ZZ_p(object): def __sub__(ntl_ZZ_p self, other): """ - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(5,31) ; y = ntl.ZZ_p(8,31) sage: x-y ## indirect doctest 28 @@ -270,7 +276,8 @@ cdef class ntl_ZZ_p(object): def __add__(ntl_ZZ_p self, other): """ - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(5,31) ; y = ntl.ZZ_p(8,31) sage: x+y ## indirect doctest 13 @@ -290,7 +297,8 @@ cdef class ntl_ZZ_p(object): def __neg__(ntl_ZZ_p self): """ - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(5,31) sage: -x ## indirect doctest 26 @@ -304,7 +312,8 @@ cdef class ntl_ZZ_p(object): def __pow__(ntl_ZZ_p self, long e, ignored): """ - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(5,31) sage: x**3 ## indirect doctest 1 @@ -320,7 +329,8 @@ cdef class ntl_ZZ_p(object): """ Return self as an int. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(3,8) sage: x.__int__() 3 @@ -343,7 +353,8 @@ cdef class ntl_ZZ_p(object): r""" This method exists solely for automated testing of get_as_int(). - EXAMPLES: + EXAMPLES:: + sage: c = ntl.ZZ_pContext(20) sage: x = ntl.ZZ_p(42,modulus=c) sage: i = x._get_as_int_doctest() @@ -368,7 +379,8 @@ cdef class ntl_ZZ_p(object): r""" This method exists solely for automated testing of set_from_int(). - EXAMPLES: + EXAMPLES:: + sage: c=ntl.ZZ_pContext(ntl.ZZ(20)) sage: x = ntl.ZZ_p(modulus=c) sage: x._set_from_int_doctest(42) @@ -386,7 +398,8 @@ cdef class ntl_ZZ_p(object): """ Return a lift of self as an ntl.ZZ object. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(8,18) sage: x.lift() 8 @@ -402,7 +415,8 @@ cdef class ntl_ZZ_p(object): r""" Returns the modulus as an NTL ZZ. - EXAMPLES: + EXAMPLES:: + sage: c = ntl.ZZ_pContext(ntl.ZZ(20)) sage: n = ntl.ZZ_p(2983,c) sage: n.modulus() @@ -445,7 +459,8 @@ cdef class ntl_ZZ_p(object): """ Return a lift of self as a Sage integer. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.ZZ_p(8,188) sage: x._integer_() 8 @@ -461,7 +476,8 @@ cdef class ntl_ZZ_p(object): r""" Returns the value as a sage IntegerModRing. - EXAMPLES: + EXAMPLES:: + sage: c = ntl.ZZ_pContext(20) sage: n = ntl.ZZ_p(2983, c) sage: type(n._sage_()) diff --git a/src/sage/libs/ntl/ntl_ZZ_pContext.pyx b/src/sage/libs/ntl/ntl_ZZ_pContext.pyx index 40d0c430ba2..09abc82949c 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pContext.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pContext.pyx @@ -25,7 +25,8 @@ from sage.rings.integer cimport Integer cdef class ntl_ZZ_pContext_class(object): def __init__(self, ntl_ZZ v): """ - EXAMPLES: + EXAMPLES:: + # You can construct contexts manually. sage: c = ntl.ZZ_pContext(11) sage: n1 = ntl.ZZ_p(12,c) @@ -52,7 +53,8 @@ cdef class ntl_ZZ_pContext_class(object): def __reduce__(self): """ - EXAMPLES: + EXAMPLES:: + sage: c = ntl.ZZ_pContext(13) sage: loads(dumps(c)) is c True @@ -63,10 +65,11 @@ cdef class ntl_ZZ_pContext_class(object): """ Returns a print representation of self. - EXAMPLES: - sage: c = ntl.ZZ_pContext(7) - sage: c - NTL modulus 7 + EXAMPLES:: + + sage: c = ntl.ZZ_pContext(7) + sage: c + NTL modulus 7 """ return "NTL modulus %s"%(self.p) @@ -78,7 +81,8 @@ cdef class ntl_ZZ_pContext_class(object): Return the current modulus associated to this context. - EXAMPLES: + EXAMPLES:: + sage: c = ntl.ZZ_pContext(7) sage: c.modulus() 7 @@ -94,7 +98,8 @@ cdef class ntl_ZZ_pContext_class(object): def restore(self): """ - EXAMPLES: + EXAMPLES:: + sage: c1 = ntl.ZZ_p(5,92) ; c2 = ntl.ZZ_p(7,92) sage: c1+c2 12 @@ -132,7 +137,8 @@ ZZ_pContext_factory = ntl_ZZ_pContext_factory() def ntl_ZZ_pContext( v ): """ Create a new ZZ_pContext. - EXAMPLES: + EXAMPLES:: + sage: c = ntl.ZZ_pContext(178) sage: n1 = ntl.ZZ_p(212,c) sage: n1 diff --git a/src/sage/libs/ntl/ntl_ZZ_pE.pyx b/src/sage/libs/ntl/ntl_ZZ_pE.pyx index d2ba7059ef6..bbb9ef8c8d3 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pE.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pE.pyx @@ -70,7 +70,8 @@ cdef class ntl_ZZ_pE(object): r""" Initializes an ntl ZZ_pE. - EXAMPLES: + EXAMPLES:: + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1],11)) sage: c.ZZ_pE([13,4,1]) [1 3] @@ -203,7 +204,8 @@ cdef class ntl_ZZ_pE(object): def __invert__(ntl_ZZ_pE self): r""" - EXAMPLES: + EXAMPLES:: + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([2,7,1],11)) sage: ~ntl.ZZ_pE([1,1],modulus=c) [7 3] @@ -337,11 +339,12 @@ def make_ZZ_pE(x, c): """ Here for unpickling. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5,0,1],25)) - sage: sage.libs.ntl.ntl_ZZ_pE.make_ZZ_pE([4,3], c) - [4 3] - sage: type(sage.libs.ntl.ntl_ZZ_pE.make_ZZ_pE([4,3], c)) - + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5,0,1],25)) + sage: sage.libs.ntl.ntl_ZZ_pE.make_ZZ_pE([4,3], c) + [4 3] + sage: type(sage.libs.ntl.ntl_ZZ_pE.make_ZZ_pE([4,3], c)) + """ return ntl_ZZ_pE(x, c) diff --git a/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx b/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx index 5e025302fe0..bfa408be73f 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pEContext.pyx @@ -26,6 +26,7 @@ cdef class ntl_ZZ_pEContext_class(object): def __init__(self, ntl_ZZ_pX f): """ EXAMPLES: + # You can construct contexts manually. sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([4,1,6],25)) sage: n1=c.ZZ_pE([10,17,12]) @@ -64,9 +65,10 @@ cdef class ntl_ZZ_pEContext_class(object): """ Returns a string representation of self. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)); c - NTL modulus [1 1 1] (mod 7) + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)); c + NTL modulus [1 1 1] (mod 7) """ return "NTL modulus %s (mod %s)"%(self.f, self.pc.p) @@ -74,11 +76,12 @@ cdef class ntl_ZZ_pEContext_class(object): """ Returns the ZZ_pContext contained within self. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)); c - NTL modulus [1 1 1] (mod 7) - sage: c.get_pc() - NTL modulus 7 + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)); c + NTL modulus [1 1 1] (mod 7) + sage: c.get_pc() + NTL modulus 7 """ return self.pc @@ -86,10 +89,11 @@ cdef class ntl_ZZ_pEContext_class(object): """ Returns the ZZ_pX polynomial defining self. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: c.polynomial() - [1 1 1] + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: c.polynomial() + [1 1 1] """ return self.f @@ -126,10 +130,11 @@ cdef class ntl_ZZ_pEContext_class(object): """ Returns a ZZ_pE object with modulus self out of the data v. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: c.ZZ_pE([4,3]) - [4 3] + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: c.ZZ_pE([4,3]) + [4 3] """ from .ntl_ZZ_pE import ntl_ZZ_pE return ntl_ZZ_pE(v,modulus=self) @@ -138,10 +143,11 @@ cdef class ntl_ZZ_pEContext_class(object): """ Returns a ZZ_pE object with modulus self out of the data v. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: c.ZZ_pEX([4,3]) - [[4] [3]] + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: c.ZZ_pEX([4,3]) + [[4] [3]] """ from .ntl_ZZ_pEX import ntl_ZZ_pEX return ntl_ZZ_pEX(v, modulus=self) @@ -153,9 +159,11 @@ def ntl_ZZ_pEContext( ntl_ZZ_pX f): Such an object must be created before any ZZ_pE or ZZ_pEX objects can be used. The context handling should be taken care of by the wrapper classes. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)); c - NTL modulus [1 1 1] (mod 7) + + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)); c + NTL modulus [1 1 1] (mod 7) """ try: return ZZ_pEContextDict[repr(f), repr(f.c.p)] diff --git a/src/sage/libs/ntl/ntl_ZZ_pEX.pyx b/src/sage/libs/ntl/ntl_ZZ_pEX.pyx index 382a4514933..cca5c3613f8 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pEX.pyx @@ -56,7 +56,8 @@ cdef class ntl_ZZ_pEX(object): # See ntl_ZZ_pEX.pxd for definition of data members def __init__(self, v=None, modulus=None): """ - EXAMPLES: + EXAMPLES:: + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) sage: a = ntl.ZZ_pE([3,2], c) sage: b = ntl.ZZ_pE([1,2], c) @@ -191,7 +192,8 @@ cdef class ntl_ZZ_pEX(object): """ Returns the structure that holds the underlying NTL modulus. - EXAMPLES: + EXAMPLES:: + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) sage: a = ntl.ZZ_pE([3,2], c) sage: b = ntl.ZZ_pE([1,2], c) @@ -205,13 +207,14 @@ cdef class ntl_ZZ_pEX(object): r""" Sets the ith coefficient of self to be a. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f[1] = 4; f - [[3 2] [4] [1 2]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f[1] = 4; f + [[3 2] [4] [1 2]] """ if i < 0: raise IndexError("index (i=%s) must be >= 0" % i) @@ -227,15 +230,16 @@ cdef class ntl_ZZ_pEX(object): r""" Returns the ith coefficient of self. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f[0] - [3 2] - sage: f[5] - [] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f[0] + [3 2] + sage: f[5] + [] """ if i < 0: raise IndexError("index (=%s) must be >= 0" % i) @@ -252,13 +256,14 @@ cdef class ntl_ZZ_pEX(object): """ Return list of entries as a list of ntl_ZZ_pEs. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.list() - [[3 2], [1 2], [1 2]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.list() + [[3 2], [1 2], [1 2]] """ # This function could be sped up by using the list API and not restoring the context each time. # Or by using self.x.rep directly. @@ -270,14 +275,15 @@ cdef class ntl_ZZ_pEX(object): """ Adds self and other. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = ntl.ZZ_pEX([-b, a]) - sage: f + g - [[2] [4 4] [1 2]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = ntl.ZZ_pEX([-b, a]) + sage: f + g + [[2] [4 4] [1 2]] """ if self.c is not other.c: raise ValueError("You can not perform arithmetic with elements of different moduli.") @@ -292,14 +298,15 @@ cdef class ntl_ZZ_pEX(object): """ Subtracts other from self. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = ntl.ZZ_pEX([-b, a]) - sage: f - g - [[4 4] [5] [1 2]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = ntl.ZZ_pEX([-b, a]) + sage: f - g + [[4 4] [5] [1 2]] """ if self.c is not other.c: raise ValueError("You can not perform arithmetic with elements of different moduli.") @@ -314,20 +321,21 @@ cdef class ntl_ZZ_pEX(object): """ Returns the product self * other. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = ntl.ZZ_pEX([-b, a]) - sage: f * g - [[1 3] [1 1] [2 4] [6 4]] - sage: c2 = ntl.ZZ_pEContext(ntl.ZZ_pX([4,1,1], 5)) # we can mix up the moduli - sage: x = c2.ZZ_pEX([2,4]) - sage: x^2 - [[4] [1] [1]] - sage: f * g # back to the first one and the ntl modulus gets reset correctly - [[1 3] [1 1] [2 4] [6 4]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = ntl.ZZ_pEX([-b, a]) + sage: f * g + [[1 3] [1 1] [2 4] [6 4]] + sage: c2 = ntl.ZZ_pEContext(ntl.ZZ_pX([4,1,1], 5)) # we can mix up the moduli + sage: x = c2.ZZ_pEX([2,4]) + sage: x^2 + [[4] [1] [1]] + sage: f * g # back to the first one and the ntl modulus gets reset correctly + [[1 3] [1 1] [2 4] [6 4]] """ if self.c is not other.c: raise ValueError("You can not perform arithmetic with elements of different moduli.") @@ -343,18 +351,19 @@ cdef class ntl_ZZ_pEX(object): Compute quotient self / other, if the quotient is a polynomial. Otherwise an Exception is raised. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a^2, -a*b-a*b, b^2]) - sage: g = ntl.ZZ_pEX([-a, b]) - sage: f / g - [[4 5] [1 2]] - sage: g / f - Traceback (most recent call last): - ... - ArithmeticError: self (=[[4 5] [1 2]]) is not divisible by other (=[[5 1] [2 6] [4]]) + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a^2, -a*b-a*b, b^2]) + sage: g = ntl.ZZ_pEX([-a, b]) + sage: f / g + [[4 5] [1 2]] + sage: g / f + Traceback (most recent call last): + ... + ArithmeticError: self (=[[4 5] [1 2]]) is not divisible by other (=[[5 1] [2 6] [4]]) """ if self.c is not other.c: raise ValueError("You can not perform arithmetic with elements of different moduli.") @@ -380,16 +389,17 @@ cdef class ntl_ZZ_pEX(object): If p is not prime or the modulus is not irreducible, this function may raise a RuntimeError due to division by a noninvertible element of ZZ_p. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5, 0, 1], 5^10)) - sage: a = c.ZZ_pE([5, 1]) - sage: b = c.ZZ_pE([4, 99]) - sage: f = c.ZZ_pEX([a, b]) - sage: g = c.ZZ_pEX([a^2, -b, a + b]) - sage: g % f - [[1864280 2123186]] - sage: f % g - [[5 1] [4 99]] + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5, 0, 1], 5^10)) + sage: a = c.ZZ_pE([5, 1]) + sage: b = c.ZZ_pE([4, 99]) + sage: f = c.ZZ_pEX([a, b]) + sage: g = c.ZZ_pEX([a^2, -b, a + b]) + sage: g % f + [[1864280 2123186]] + sage: f % g + [[5 1] [4 99]] """ if self.c is not other.c: raise ValueError("You can not perform arithmetic with elements of different moduli.") @@ -409,16 +419,17 @@ cdef class ntl_ZZ_pEX(object): If p is not prime or the modulus is not irreducible, this function may raise a RuntimeError due to division by a noninvertible element of ZZ_p. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5, 0, 1], 5^10)) - sage: a = c.ZZ_pE([5, 1]) - sage: b = c.ZZ_pE([4, 99]) - sage: f = c.ZZ_pEX([a, b]) - sage: g = c.ZZ_pEX([a^2, -b, a + b]) - sage: g.quo_rem(f) - ([[4947544 2492106] [4469276 6572944]], [[1864280 2123186]]) - sage: f.quo_rem(g) - ([], [[5 1] [4 99]]) + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5, 0, 1], 5^10)) + sage: a = c.ZZ_pE([5, 1]) + sage: b = c.ZZ_pE([4, 99]) + sage: f = c.ZZ_pEX([a, b]) + sage: g = c.ZZ_pEX([a^2, -b, a + b]) + sage: g.quo_rem(f) + ([[4947544 2492106] [4469276 6572944]], [[1864280 2123186]]) + sage: f.quo_rem(g) + ([], [[5 1] [4 99]]) """ if self.c is not other.c: raise ValueError("You can not perform arithmetic with elements of different moduli.") @@ -434,13 +445,14 @@ cdef class ntl_ZZ_pEX(object): """ Return $f^2$. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.square() - [[5 1] [5 1] [2 1] [1] [4]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.square() + [[5 1] [5 1] [2 1] [1] [4]] """ # self.c.restore_c() # _new() restores the context cdef ntl_ZZ_pEX r = self._new() @@ -513,16 +525,17 @@ cdef class ntl_ZZ_pEX(object): """ Return True exactly if this polynomial is 0. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.is_zero() - False - sage: f = ntl.ZZ_pEX([0,0,7], c) - sage: f.is_zero() - True + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.is_zero() + False + sage: f = ntl.ZZ_pEX([0,0,7], c) + sage: f.is_zero() + True """ self.c.restore_c() return bool(ZZ_pEX_IsZero(self.x)) @@ -531,16 +544,17 @@ cdef class ntl_ZZ_pEX(object): """ Return True exactly if this polynomial is 1. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.is_one() - False - sage: f = ntl.ZZ_pEX([1, 0, 0], c) - sage: f.is_one() - True + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.is_one() + False + sage: f = ntl.ZZ_pEX([1, 0, 0], c) + sage: f.is_one() + True """ self.c.restore_c() return bool(ZZ_pEX_IsOne(self.x)) @@ -549,16 +563,17 @@ cdef class ntl_ZZ_pEX(object): """ Return True exactly if this polynomial is monic. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.is_monic() - False - sage: f = ntl.ZZ_pEX([a, b, 1], c) - sage: f.is_monic() - True + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.is_monic() + False + sage: f = ntl.ZZ_pEX([a, b, 1], c) + sage: f.is_monic() + True """ self.c.restore_c() # The following line is what we should have. However, strangely this is *broken* @@ -575,13 +590,14 @@ cdef class ntl_ZZ_pEX(object): """ Return the negative of self. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: -f - [[4 5] [6 5] [6 5]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: -f + [[4 5] [6 5] [6 5]] """ cdef ntl_ZZ_pEX r = self._new() # self.c.restore_c() # _new() calls restore @@ -596,20 +612,21 @@ cdef class ntl_ZZ_pEX(object): (in which case self is reduced modulo c.p) or self.c.p should divide c.p (in which case self is lifted to something modulo c.p congruent to self modulo self.c.p) - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5, 0, 1], 5^20)) - sage: a = ntl.ZZ_pE([192870, 1928189], c) - sage: b = ntl.ZZ_pE([18275,293872987], c) - sage: f = ntl.ZZ_pEX([a, b]) - sage: g = f.convert_to_modulus(ntl.ZZ_pContext(ntl.ZZ(5^5))) - sage: g - [[2245 64] [2650 1112]] - sage: g.get_modulus_context() - NTL modulus [3120 0 1] (mod 3125) - sage: g^2 - [[1130 2985] [805 830] [2095 2975]] - sage: (f^2).convert_to_modulus(ntl.ZZ_pContext(ntl.ZZ(5^5))) - [[1130 2985] [805 830] [2095 2975]] + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5, 0, 1], 5^20)) + sage: a = ntl.ZZ_pE([192870, 1928189], c) + sage: b = ntl.ZZ_pE([18275,293872987], c) + sage: f = ntl.ZZ_pEX([a, b]) + sage: g = f.convert_to_modulus(ntl.ZZ_pContext(ntl.ZZ(5^5))) + sage: g + [[2245 64] [2650 1112]] + sage: g.get_modulus_context() + NTL modulus [3120 0 1] (mod 3125) + sage: g^2 + [[1130 2985] [805 830] [2095 2975]] + sage: (f^2).convert_to_modulus(ntl.ZZ_pContext(ntl.ZZ(5^5))) + [[1130 2985] [805 830] [2095 2975]] """ cdef ntl_ZZ_pEContext_class cE = ntl_ZZ_pEContext(self.c.f.convert_to_modulus(c)) cE.restore_c() @@ -625,20 +642,21 @@ cdef class ntl_ZZ_pEX(object): Return the polynomial obtained by shifting all coefficients of this polynomial to the left n positions. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]); f - [[3 2] [1 2] [1 2]] - sage: f.left_shift(2) - [[] [] [3 2] [1 2] [1 2]] - sage: f.left_shift(5) - [[] [] [] [] [] [3 2] [1 2] [1 2]] + EXAMPLES:: - A negative left shift is a right shift. - sage: f.left_shift(-2) - [[1 2]] + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]); f + [[3 2] [1 2] [1 2]] + sage: f.left_shift(2) + [[] [] [3 2] [1 2] [1 2]] + sage: f.left_shift(5) + [[] [] [] [] [] [3 2] [1 2] [1 2]] + + A negative left shift is a right shift. + sage: f.left_shift(-2) + [[1 2]] """ # self.c.restore_c() # _new() calls restore cdef ntl_ZZ_pEX r = self._new() @@ -652,20 +670,21 @@ cdef class ntl_ZZ_pEX(object): Return the polynomial obtained by shifting all coefficients of this polynomial to the right n positions. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]); f - [[3 2] [1 2] [1 2]] - sage: f.right_shift(2) - [[1 2]] - sage: f.right_shift(5) - [] + EXAMPLES:: - A negative right shift is a left shift. - sage: f.right_shift(-5) - [[] [] [] [] [] [3 2] [1 2] [1 2]] + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]); f + [[3 2] [1 2] [1 2]] + sage: f.right_shift(2) + [[1 2]] + sage: f.right_shift(5) + [] + + A negative right shift is a left shift. + sage: f.right_shift(-5) + [[] [] [] [] [] [3 2] [1 2] [1 2]] """ # self.c.restore_c() # _new() calls restore cdef ntl_ZZ_pEX r = self._new() @@ -680,20 +699,21 @@ cdef class ntl_ZZ_pEX(object): NOTE: Does not work if p is not prime or if the modulus is not irreducible. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = f^2 - sage: h = f^3 - sage: g.gcd(h) - [[2 1] [8 1] [9 1] [2] [1]] - sage: f^2 - [[5 8] [9 8] [6 8] [5] [8]] - sage: eight = ntl.ZZ_pEX([[8]], c) - sage: f^2 / eight - [[2 1] [8 1] [9 1] [2] [1]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = f^2 + sage: h = f^3 + sage: g.gcd(h) + [[2 1] [8 1] [9 1] [2] [1]] + sage: f^2 + [[5 8] [9 8] [6 8] [5] [8]] + sage: eight = ntl.ZZ_pEX([[8]], c) + sage: f^2 / eight + [[2 1] [8 1] [9 1] [2] [1]] """ #If check = True, need to check that ZZ_pE is a field. self.c.restore_c() @@ -709,20 +729,21 @@ cdef class ntl_ZZ_pEX(object): Here r is the gcd of self and other. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = ntl.ZZ_pEX([a-b, b^2, a]) - sage: h = ntl.ZZ_pEX([a^2-b, b^4, b,a]) - sage: r,s,t = (g*f).xgcd(h*f) - sage: r - [[4 6] [1] [1]] - sage: f / ntl.ZZ_pEX([b]) - [[4 6] [1] [1]] - sage: s*f*g+t*f*h - [[4 6] [1] [1]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = ntl.ZZ_pEX([a-b, b^2, a]) + sage: h = ntl.ZZ_pEX([a^2-b, b^4, b,a]) + sage: r,s,t = (g*f).xgcd(h*f) + sage: r + [[4 6] [1] [1]] + sage: f / ntl.ZZ_pEX([b]) + [[4 6] [1] [1]] + sage: s*f*g+t*f*h + [[4 6] [1] [1]] """ self.c.restore_c() cdef ntl_ZZ_pEX s = self._new() @@ -738,15 +759,16 @@ cdef class ntl_ZZ_pEX(object): Return the degree of this polynomial. The degree of the 0 polynomial is -1. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.degree() - 2 - sage: ntl.ZZ_pEX([], c).degree() - -1 + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.degree() + 2 + sage: ntl.ZZ_pEX([], c).degree() + -1 """ self.c.restore_c() return ZZ_pEX_deg(self.x) @@ -755,13 +777,14 @@ cdef class ntl_ZZ_pEX(object): """ Return the leading coefficient of this polynomial. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.leading_coefficient() - [1 2] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.leading_coefficient() + [1 2] """ self.c.restore_c() cdef long i @@ -772,13 +795,14 @@ cdef class ntl_ZZ_pEX(object): """ Return the constant coefficient of this polynomial. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.constant_term() - [3 2] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.constant_term() + [3 2] """ self.c.restore_c() return self[0] @@ -787,15 +811,16 @@ cdef class ntl_ZZ_pEX(object): """ Set this polynomial to the monomial "x". - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f - [[3 2] [1 2] [1 2]] - sage: f.set_x(); f - [[] [1]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f + [[3 2] [1 2] [1 2]] + sage: f.set_x(); f + [[] [1]] """ self.c.restore_c() ZZ_pEX_SetX(self.x) @@ -804,15 +829,16 @@ cdef class ntl_ZZ_pEX(object): """ True if this is the polynomial "x". - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.is_x() - False - sage: f.set_x(); f.is_x() - True + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.is_x() + False + sage: f.set_x(); f.is_x() + True """ return bool(ZZ_pEX_IsX(self.x)) @@ -820,13 +846,14 @@ cdef class ntl_ZZ_pEX(object): """ Return the derivative of this polynomial. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.derivative() - [[1 2] [2 4]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.derivative() + [[1 2] [2 4]] """ cdef ntl_ZZ_pEX r = self._new() sig_on() @@ -870,19 +897,20 @@ cdef class ntl_ZZ_pEX(object): of this polynomial. If hi is set then this function behaves as if this polynomial has degree hi. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.reverse() - [[1 2] [1 2] [3 2]] - sage: f.reverse(hi=5) - [[] [] [] [1 2] [1 2] [3 2]] - sage: f.reverse(hi=1) - [[1 2] [3 2]] - sage: f.reverse(hi=-2) - [] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.reverse() + [[1 2] [1 2] [3 2]] + sage: f.reverse(hi=5) + [[] [] [] [1 2] [1 2] [3 2]] + sage: f.reverse(hi=1) + [[1 2] [3 2]] + sage: f.reverse(hi=-2) + [] """ cdef ntl_ZZ_pEX r = self._new() if not (hi is None): @@ -896,15 +924,16 @@ cdef class ntl_ZZ_pEX(object): Return the truncation of this polynomial obtained by removing all terms of degree >= m. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.truncate(3) - [[3 2] [1 2] [1 2]] - sage: f.truncate(1) - [[3 2]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.truncate(3) + [[3 2] [1 2] [1 2]] + sage: f.truncate(1) + [[3 2]] """ cdef ntl_ZZ_pEX r = self._new() if m > 0: @@ -917,16 +946,17 @@ cdef class ntl_ZZ_pEX(object): """ Return self*other but with terms of degree >= m removed. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = ntl.ZZ_pEX([a - b, b^2, a, a*b]) - sage: f*g - [[6 4] [4 9] [4 6] [7] [1 9] [2 5]] - sage: f.multiply_and_truncate(g, 3) - [[6 4] [4 9] [4 6]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = ntl.ZZ_pEX([a - b, b^2, a, a*b]) + sage: f*g + [[6 4] [4 9] [4 6] [7] [1 9] [2 5]] + sage: f.multiply_and_truncate(g, 3) + [[6 4] [4 9] [4 6]] """ cdef ntl_ZZ_pEX r = self._new() if m > 0: @@ -939,15 +969,16 @@ cdef class ntl_ZZ_pEX(object): """ Return self*self but with terms of degree >= m removed. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f^2 - [[5 8] [9 8] [6 8] [5] [8]] - sage: f.square_and_truncate(3) - [[5 8] [9 8] [6 8]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f^2 + [[5 8] [9 8] [6 8] [5] [8]] + sage: f.square_and_truncate(3) + [[5 8] [9 8] [6 8]] """ cdef ntl_ZZ_pEX r = self._new() if m > 0: @@ -961,16 +992,17 @@ cdef class ntl_ZZ_pEX(object): Compute and return the inverse of self modulo $x^m$. The constant term of self must be invertible. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = f.invert_and_truncate(5) - sage: g - [[8 6] [4 4] [5 9] [1 4] [0 1]] - sage: f * g - [[1] [] [] [] [] [2 8] [9 10]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = f.invert_and_truncate(5) + sage: g + [[8 6] [4 4] [5 9] [1 4] [0 1]] + sage: f * g + [[1] [] [] [] [] [2 8] [9 10]] """ if m < 0: raise ArithmeticError("m (=%s) must be positive" % m) @@ -987,15 +1019,16 @@ cdef class ntl_ZZ_pEX(object): Return self*other % modulus. The modulus must be monic with deg(modulus) > 0, and self and other must have smaller degree. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = ntl.ZZ_pEX([b^4, a*b^2, a - b]) - sage: m = ntl.ZZ_pEX([a - b, b^2, a, a*b]) - sage: f.multiply_mod(g, m) - [[10 10] [4 4] [10 3]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = ntl.ZZ_pEX([b^4, a*b^2, a - b]) + sage: m = ntl.ZZ_pEX([a - b, b^2, a, a*b]) + sage: f.multiply_mod(g, m) + [[10 10] [4 4] [10 3]] """ self.c.restore_c() cdef ntl_ZZ_pEX r = self._new() @@ -1010,14 +1043,15 @@ cdef class ntl_ZZ_pEX(object): The modulus must be monic, and of positive degree degree bigger than the degree of self. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: m = ntl.ZZ_pEX([a - b, b^2, a, a*b]) - sage: f.trace_mod(m) - [8 1] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: m = ntl.ZZ_pEX([a - b, b^2, a, a*b]) + sage: f.trace_mod(m) + [8 1] """ self.c.restore_c() cdef ntl_ZZ_pE r = ntl_ZZ_pE(modulus = self.c) @@ -1032,7 +1066,8 @@ cdef class ntl_ZZ_pEX(object): # monomial x modulo this polynomial for i = 0, ..., deg(f)-1. # This polynomial must be monic. # - # EXAMPLES: + # EXAMPLES:: + # # sage: c=ntl.ZZ_pContext(ntl.ZZ(20)) # sage: f = c.ZZ_pX([1,2,0,3,0,1]) # sage: f.trace_list() @@ -1060,16 +1095,17 @@ cdef class ntl_ZZ_pEX(object): """ Return the resultant of self and other. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: g = ntl.ZZ_pEX([a - b, b^2, a, a*b]) - sage: f.resultant(g) - [1] - sage: (f*g).resultant(f^2) - [] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: g = ntl.ZZ_pEX([a - b, b^2, a, a*b]) + sage: f.resultant(g) + [1] + sage: (f*g).resultant(f^2) + [] """ self.c.restore_c() cdef ntl_ZZ_pE r = ntl_ZZ_pE(modulus = self.c) @@ -1084,14 +1120,15 @@ cdef class ntl_ZZ_pEX(object): modulus must be monic, and of positive degree strictly greater than the degree of self. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: m = ntl.ZZ_pEX([a - b, b^2, a, a*b]) - sage: f.norm_mod(m) - [9 2] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: m = ntl.ZZ_pEX([a - b, b^2, a, a*b]) + sage: f.norm_mod(m) + [9 2] """ self.c.restore_c() cdef ntl_ZZ_pE r = ntl_ZZ_pE(modulus = self.c) @@ -1108,13 +1145,14 @@ cdef class ntl_ZZ_pEX(object): $$ where m = deg(a), and lc(a) is the leading coefficient of a. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f.discriminant() - [1 6] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f.discriminant() + [1 6] """ self.c.restore_c() cdef long m @@ -1131,14 +1169,15 @@ cdef class ntl_ZZ_pEX(object): modulus. The modulus must be monic of degree bigger than self. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: m = ntl.ZZ_pEX([a - b, b^2, a, a*b]) - sage: f.minpoly_mod(m) - [[2 9] [8 2] [3 10] [1]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: m = ntl.ZZ_pEX([a - b, b^2, a, a*b]) + sage: f.minpoly_mod(m) + [[2 9] [8 2] [3 10] [1]] """ self.c.restore_c() cdef ntl_ZZ_pEX r = self._new() @@ -1151,15 +1190,16 @@ cdef class ntl_ZZ_pEX(object): """ Reset this polynomial to 0. Changes this polynomial in place. - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f - [[3 2] [1 2] [1 2]] - sage: f.clear(); f - [] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f + [[3 2] [1 2] [1 2]] + sage: f.clear(); f + [] """ self.c.restore_c() sig_on() @@ -1174,14 +1214,15 @@ cdef class ntl_ZZ_pEX(object): the polynomial grows. (You might save a millisecond with this function.) - EXAMPLES: - sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: f = ntl.ZZ_pEX([a, b, b]) - sage: f[10]=ntl.ZZ_pE([1,8],c) # no new memory is allocated - sage: f - [[3 2] [1 2] [1 2] [] [] [] [] [] [] [] [1 8]] + EXAMPLES:: + + sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 11)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: f = ntl.ZZ_pEX([a, b, b]) + sage: f[10]=ntl.ZZ_pE([1,8],c) # no new memory is allocated + sage: f + [[3 2] [1 2] [1 2] [] [] [] [] [] [] [] [1 8]] """ self.c.restore_c() sig_on() @@ -1193,13 +1234,14 @@ def make_ZZ_pEX(v, modulus): """ Here for unpickling. - EXAMPLES: - sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5,0,1],25)) - sage: a = ntl.ZZ_pE([3,2], c) - sage: b = ntl.ZZ_pE([1,2], c) - sage: sage.libs.ntl.ntl_ZZ_pEX.make_ZZ_pEX([a,b,b], c) - [[3 2] [1 2] [1 2]] - sage: type(sage.libs.ntl.ntl_ZZ_pEX.make_ZZ_pEX([a,b,b], c)) - + EXAMPLES:: + + sage: c = ntl.ZZ_pEContext(ntl.ZZ_pX([-5,0,1],25)) + sage: a = ntl.ZZ_pE([3,2], c) + sage: b = ntl.ZZ_pE([1,2], c) + sage: sage.libs.ntl.ntl_ZZ_pEX.make_ZZ_pEX([a,b,b], c) + [[3 2] [1 2] [1 2]] + sage: type(sage.libs.ntl.ntl_ZZ_pEX.make_ZZ_pEX([a,b,b], c)) + """ return ntl_ZZ_pEX(v, modulus) diff --git a/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi b/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi index ae325adc330..a5de653c2e8 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi +++ b/src/sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi @@ -27,7 +27,8 @@ from sage.libs.ntl.types cimport ZZ_pX_c, ZZ_pEX_c cdef ZZ_pEX_c *celement_new(cparent parent): """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') """ if parent != NULL: @@ -37,7 +38,8 @@ cdef ZZ_pEX_c *celement_new(cparent parent): cdef int celement_delete(ZZ_pEX_c *e, cparent parent): """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: del x """ @@ -48,7 +50,8 @@ cdef int celement_delete(ZZ_pEX_c *e, cparent parent): cdef int celement_construct(ZZ_pEX_c *e, cparent parent): """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') """ if parent != NULL: @@ -57,7 +60,8 @@ cdef int celement_construct(ZZ_pEX_c *e, cparent parent): cdef int celement_destruct(ZZ_pEX_c *e, cparent parent): """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: del x """ @@ -67,7 +71,8 @@ cdef int celement_destruct(ZZ_pEX_c *e, cparent parent): cdef int celement_gen(ZZ_pEX_c *e, long i, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') """ if parent != NULL: @@ -79,7 +84,8 @@ cdef object celement_repr(ZZ_pEX_c *e, cparent parent): """ We ignore NTL's printing. - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: x x @@ -88,7 +94,8 @@ cdef object celement_repr(ZZ_pEX_c *e, cparent parent): cdef inline int celement_set(ZZ_pEX_c* res, ZZ_pEX_c* a, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: y = x sage: y @@ -98,7 +105,8 @@ cdef inline int celement_set(ZZ_pEX_c* res, ZZ_pEX_c* a, cparent parent) except cdef inline int celement_set_si(ZZ_pEX_c* res, long i, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: P(0) 0 @@ -117,7 +125,8 @@ cdef inline long celement_get_si(ZZ_pEX_c* res, cparent parent) except -2: cdef inline bint celement_is_zero(ZZ_pEX_c* a, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: bool(x), x.is_zero() (True, False) @@ -131,7 +140,8 @@ cdef inline bint celement_is_zero(ZZ_pEX_c* a, cparent parent) except -2: cdef inline bint celement_is_one(ZZ_pEX_c *a, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: x.is_one() False @@ -145,7 +155,8 @@ cdef inline bint celement_is_one(ZZ_pEX_c *a, cparent parent) except -2: cdef inline bint celement_equal(ZZ_pEX_c *a, ZZ_pEX_c *b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: x == x True @@ -170,7 +181,8 @@ cdef inline int celement_cmp(ZZ_pEX_c *a, ZZ_pEX_c *b, cparent parent) except -2 cdef long celement_len(ZZ_pEX_c *a, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(GF(next_prime(2**60)**3,'a'),implementation='NTL') sage: x.degree() 1 @@ -184,7 +196,8 @@ cdef long celement_len(ZZ_pEX_c *a, cparent parent) except -2: cdef inline int celement_add(ZZ_pEX_c *res, ZZ_pEX_c *a, ZZ_pEX_c *b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: (1+a+a^2)*x + (1+x+x^2) @@ -197,7 +210,8 @@ cdef inline int celement_add(ZZ_pEX_c *res, ZZ_pEX_c *a, ZZ_pEX_c *b, cparent pa cdef inline int celement_sub(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: (1+a+a^2)*x - (1+x+x^2) @@ -210,7 +224,8 @@ cdef inline int celement_sub(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent pa cdef inline int celement_neg(ZZ_pEX_c* res, ZZ_pEX_c* a, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: -x @@ -226,7 +241,8 @@ cdef inline int celement_mul_scalar(ZZ_pEX_c* res, ZZ_pEX_c* p, object c, cparen cdef inline int celement_mul(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: (1+a+a^2)*x * (1+x+x^2) @@ -245,7 +261,8 @@ cdef inline int celement_div(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent pa cdef inline int celement_floordiv(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: (x^2+2*a*x+a^2)//(x+a) @@ -264,7 +281,8 @@ cdef inline int celement_floordiv(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cpare cdef inline int celement_mod(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: (x^2-2*a*x) % (x+a) @@ -277,7 +295,8 @@ cdef inline int celement_mod(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent pa cdef inline int celement_quorem(ZZ_pEX_c* q, ZZ_pEX_c* r, ZZ_pEX_c* a, ZZ_pEX_c* b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: (x^2+2*a*x).quo_rem(x-a) @@ -357,7 +376,8 @@ cdef inline int celement_pow(ZZ_pEX_c* res, ZZ_pEX_c* x, long e, ZZ_pEX_c *modul cdef inline int celement_gcd(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c *b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: f = (x+3)*(x^7+a*x^5+1) @@ -373,7 +393,8 @@ cdef inline int celement_gcd(ZZ_pEX_c* res, ZZ_pEX_c* a, ZZ_pEX_c *b, cparent pa cdef inline int celement_xgcd(ZZ_pEX_c* res, ZZ_pEX_c* s, ZZ_pEX_c *t, ZZ_pEX_c* a, ZZ_pEX_c *b, cparent parent) except -2: """ - EXAMPLES: + EXAMPLES:: + sage: K. = GF(next_prime(2**60)**3) sage: P. = PolynomialRing(K,implementation='NTL') sage: f = (x+3)*(x^7+a*x^5+1) diff --git a/src/sage/libs/ntl/ntl_lzz_p.pyx b/src/sage/libs/ntl/ntl_lzz_p.pyx index 36850937558..b5cd62502c4 100644 --- a/src/sage/libs/ntl/ntl_lzz_p.pyx +++ b/src/sage/libs/ntl/ntl_lzz_p.pyx @@ -149,7 +149,8 @@ cdef class ntl_zz_p(object): """ Quick and dirty zz_p object creation. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.zz_p(23,75) sage: y = x*x ## indirect doctest """ @@ -183,7 +184,8 @@ cdef class ntl_zz_p(object): def __add__(ntl_zz_p self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ntl.zz_p(5,23) + ntl.zz_p(6,23) 11 """ @@ -199,7 +201,8 @@ cdef class ntl_zz_p(object): def __sub__(ntl_zz_p self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ntl.zz_p(5,23) - ntl.zz_p(6,23) 22 """ @@ -215,7 +218,8 @@ cdef class ntl_zz_p(object): def __mul__(ntl_zz_p self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ntl.zz_p(5,23) * ntl.zz_p(6,23) 7 """ @@ -231,7 +235,8 @@ cdef class ntl_zz_p(object): def __truediv__(ntl_zz_p self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ntl.zz_p(5,23) / ntl.zz_p(2,23) 14 """ @@ -297,7 +302,8 @@ cdef class ntl_zz_p(object): """ Return the negative of self. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_p(5,234) sage: -f ## indirect doctest 229 @@ -343,7 +349,8 @@ cdef class ntl_zz_p(object): """ Return self as an int. - EXAMPLES: + EXAMPLES:: + sage: ntl.zz_p(3,next_prime(100)).__int__() 3 sage: int(ntl.zz_p(3,next_prime(100))) @@ -357,7 +364,8 @@ cdef class ntl_zz_p(object): """ Return f*f. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_p(15,23) sage: f*f 18 @@ -372,7 +380,8 @@ cdef class ntl_zz_p(object): """ Return True exactly if this element is 0. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_p(0,20) sage: f.is_zero() True @@ -387,7 +396,8 @@ cdef class ntl_zz_p(object): """ Return True exactly if this element is 1. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_p(1,11) sage: f.is_one() True @@ -402,7 +412,8 @@ cdef class ntl_zz_p(object): """ Reset this element to 0. - EXAMPLES: + EXAMPLES:: + sage: x = ntl.zz_p(5,102) ; x 5 sage: x.clear() ; x diff --git a/src/sage/libs/ntl/ntl_lzz_pContext.pyx b/src/sage/libs/ntl/ntl_lzz_pContext.pyx index 284f31304c1..c38d7e8ed67 100644 --- a/src/sage/libs/ntl/ntl_lzz_pContext.pyx +++ b/src/sage/libs/ntl/ntl_lzz_pContext.pyx @@ -19,7 +19,8 @@ zz_pContextDict = {} cdef class ntl_zz_pContext_class(object): def __init__(self, long v): """ - EXAMPLES: + EXAMPLES:: + # You can construct contexts manually. sage: c = ntl.zz_pContext(11) sage: n1 = ntl.zz_p(12,c) @@ -58,7 +59,8 @@ cdef class ntl_zz_pContext_class(object): """ Print the modulus for self. - EXAMPLES: + EXAMPLES:: + sage: c1 = ntl.zz_pContext(36) sage: c1.modulus() 36 @@ -69,7 +71,8 @@ cdef class ntl_zz_pContext_class(object): """ Restore a zz_pContext. - EXAMPLES: + EXAMPLES:: + sage: c = ntl.zz_pContext(5) sage: m = ntl.zz_p(4,7) sage: c.restore() @@ -80,7 +83,8 @@ cdef class ntl_zz_pContext_class(object): """ Actual code for the above. - EXAMPLES: + EXAMPLES:: + sage: n = ntl.zz_p(3,5) sage: m = ntl.zz_p(4,7) sage: n*n ## indirect doctest @@ -93,7 +97,8 @@ def ntl_zz_pContext( v ): """ Creation function for a zz_p context. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pContext(26) sage: f = ntl.zz_pContext(10^100) Traceback (most recent call last): diff --git a/src/sage/libs/ntl/ntl_lzz_pX.pyx b/src/sage/libs/ntl/ntl_lzz_pX.pyx index 4df255c26d9..8a36824282c 100644 --- a/src/sage/libs/ntl/ntl_lzz_pX.pyx +++ b/src/sage/libs/ntl/ntl_lzz_pX.pyx @@ -63,7 +63,8 @@ cdef class ntl_zz_pX(object): # See ntl_zz_pX.pxd for definition of data members def __init__(self, ls=[], modulus=None): """ - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,5,-9],20) sage: f [1, 2, 5, 11] @@ -174,7 +175,8 @@ cdef class ntl_zz_pX(object): """ Return the string representation of self. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([3,5], 17) sage: f.__repr__() '[3, 5]' @@ -185,7 +187,8 @@ cdef class ntl_zz_pX(object): """ Return the ith coefficient of f. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX(range(7), 71) sage: f[3] ## indirect doctest 3 @@ -210,7 +213,8 @@ cdef class ntl_zz_pX(object): Set the ith coefficient of self to val. If i is out of range, raise an exception. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([], 7) sage: f[3] = 2 ; f [0, 0, 0, 2] @@ -235,7 +239,8 @@ cdef class ntl_zz_pX(object): Quick and dirty method for creating a new object with the same zz_pContext as self. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1], 20) sage: f.square() ## indirect doctest [1] @@ -249,7 +254,8 @@ cdef class ntl_zz_pX(object): """ Return self + other. - EXAMPLES: + EXAMPLES:: + sage: ntl.zz_pX(range(5),20) + ntl.zz_pX(range(6),20) ## indirect doctest [0, 2, 4, 6, 8, 5] sage: ntl.zz_pX(range(5),20) + ntl.zz_pX(range(6),50) @@ -271,7 +277,8 @@ cdef class ntl_zz_pX(object): """ Return self - other. - EXAMPLES: + EXAMPLES:: + sage: ntl.zz_pX(range(5),32) - ntl.zz_pX(range(6),32) [0, 0, 0, 0, 0, 27] sage: ntl.zz_pX(range(5),20) - ntl.zz_pX(range(6),50) ## indirect doctest @@ -291,7 +298,8 @@ cdef class ntl_zz_pX(object): def __mul__(ntl_zz_pX self, other): """ - EXAMPLES: + EXAMPLES:: + sage: ntl.zz_pX(range(5),20) * ntl.zz_pX(range(6),20) ## indirect doctest [0, 0, 1, 4, 10, 0, 10, 14, 11] sage: ntl.zz_pX(range(5),20) * ntl.zz_pX(range(6),50) @@ -316,7 +324,8 @@ cdef class ntl_zz_pX(object): Compute quotient self / other, if the quotient is a polynomial. Otherwise an Exception is raised. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,3],17) * ntl.zz_pX([4,5],17)**2 sage: g = ntl.zz_pX([4,5],17) sage: f/g ## indirect doctest @@ -359,7 +368,8 @@ cdef class ntl_zz_pX(object): function returns q if q lies in ZZ[X], and otherwise raises an Exception. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([2,4,6],17); g = ntl.zz_pX([2],17) sage: f % g ## indirect doctest [] @@ -384,7 +394,8 @@ cdef class ntl_zz_pX(object): """ Return the n-th nonnegative power of self. - EXAMPLES: + EXAMPLES:: + sage: g = ntl.zz_pX([-1,0,1],20) sage: g**10 ## indirect doctest [1, 0, 10, 0, 5, 0, 0, 0, 10, 0, 8, 0, 10, 0, 0, 0, 5, 0, 10, 0, 1] @@ -404,7 +415,8 @@ cdef class ntl_zz_pX(object): Specifically, this return r, q such that $self = q * right + r$ - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX(range(7), 19) sage: g = ntl.zz_pX([2,4,6], 19) sage: f // g @@ -428,7 +440,8 @@ cdef class ntl_zz_pX(object): """ Returns the whole part of $self / right$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX(range(10), 19); g = ntl.zz_pX([1]*5, 19) sage: f // g ## indirect doctest [8, 18, 18, 18, 18, 9] @@ -445,7 +458,8 @@ cdef class ntl_zz_pX(object): """ Shifts this polynomial to the left, which is multiplication by $x^n$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([2,4,6], 17) sage: f << 2 ## indirect doctest [0, 0, 2, 4, 6] @@ -459,7 +473,8 @@ cdef class ntl_zz_pX(object): """ Shifts this polynomial to the right, which is division by $x^n$ (and truncation). - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,3], 17) sage: f >> 2 ## indirect doctest [3] @@ -473,7 +488,8 @@ cdef class ntl_zz_pX(object): """ The formal derivative of self. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX(range(10), 17) sage: f.diff() [1, 4, 9, 16, 8, 2, 15, 13, 13] @@ -487,7 +503,8 @@ cdef class ntl_zz_pX(object): """ Returns self with coefficients reversed, i.e. $x^n self(x^{-n})$. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([2,4,6], 17) sage: f.reverse() [6, 4, 2] @@ -500,7 +517,8 @@ cdef class ntl_zz_pX(object): def __neg__(self): """ Return the negative of self. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([2,0,0,1],20) sage: -f [18, 0, 0, 19] @@ -546,7 +564,8 @@ cdef class ntl_zz_pX(object): """ Return list of entries as a list of python ints. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([23, 5,0,1], 10) sage: f.list() [3, 5, 0, 1] @@ -562,7 +581,8 @@ cdef class ntl_zz_pX(object): Return the degree of this polynomial. The degree of the 0 polynomial is -1. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([5,0,1],50) sage: f.degree() 2 @@ -583,7 +603,8 @@ cdef class ntl_zz_pX(object): """ Return the leading coefficient of this polynomial. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([3,6,9],19) sage: f.leading_coefficient() 9 @@ -598,7 +619,8 @@ cdef class ntl_zz_pX(object): """ Return the constant coefficient of this polynomial. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([3,6,9],127) sage: f.constant_term() 3 @@ -613,7 +635,8 @@ cdef class ntl_zz_pX(object): """ Return f*f. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([-1,0,1],17) sage: f*f [1, 0, 15, 0, 1] @@ -630,7 +653,8 @@ cdef class ntl_zz_pX(object): Return the truncation of this polynomial obtained by removing all terms of degree >= m. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,3,4,5],70) sage: f.truncate(3) [1, 2, 3] @@ -659,7 +683,8 @@ cdef class ntl_zz_pX(object): """ Return self*other but with terms of degree >= m removed. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,3,4,5],20) sage: g = ntl.zz_pX([10],20) sage: f.multiply_and_truncate(g, 2) @@ -681,7 +706,8 @@ cdef class ntl_zz_pX(object): """ Return self*self but with terms of degree >= m removed. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,3,4,5],20) sage: f.square_and_truncate(4) [1, 4, 10] @@ -703,7 +729,8 @@ cdef class ntl_zz_pX(object): Compute and return the inverse of self modulo $x^m$. The constant term of self must be 1 or -1. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,3,4,5,6,7],20) sage: f.invert_and_truncate(20) [1, 18, 1, 0, 0, 0, 0, 8, 17, 2, 13, 0, 0, 0, 4, 0, 17, 10, 9] @@ -733,7 +760,8 @@ cdef class ntl_zz_pX(object): """ Return True exactly if this polynomial is 0. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([0,0,0,20],5) sage: f.is_zero() True @@ -750,7 +778,8 @@ cdef class ntl_zz_pX(object): """ Return True exactly if this polynomial is 1. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,1],101) sage: f.is_one() False @@ -765,7 +794,8 @@ cdef class ntl_zz_pX(object): """ Return True exactly if this polynomial is monic. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([2,0,0,1],17) sage: f.is_monic() True @@ -787,7 +817,8 @@ cdef class ntl_zz_pX(object): """ Set this polynomial to the monomial "x". - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([],177) sage: f.set_x() sage: f @@ -808,7 +839,8 @@ cdef class ntl_zz_pX(object): """ True if this is the polynomial "x". - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([],100) sage: f.set_x() sage: f.is_x() @@ -827,7 +859,8 @@ cdef class ntl_zz_pX(object): """ Reset this polynomial to 0. Changes this polynomial in place. - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,3],17) sage: f [1, 2, 3] @@ -846,7 +879,8 @@ cdef class ntl_zz_pX(object): the polynomial grows. (You might save a millisecond with this function.) - EXAMPLES: + EXAMPLES:: + sage: f = ntl.zz_pX([1,2,3],17) sage: f.preallocate_space(20) sage: f diff --git a/src/sage/libs/ntl/ntl_mat_ZZ.pyx b/src/sage/libs/ntl/ntl_mat_ZZ.pyx index 60d3b467c59..2fa8e3e7487 100644 --- a/src/sage/libs/ntl/ntl_mat_ZZ.pyx +++ b/src/sage/libs/ntl/ntl_mat_ZZ.pyx @@ -69,7 +69,8 @@ cdef class ntl_mat_ZZ(object): """ The \class{mat_ZZ} class implements arithmetic with matrices over $\Z$. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(3,3) ; M [ [0 0 0] @@ -101,7 +102,8 @@ cdef class ntl_mat_ZZ(object): def __reduce__(self): """ - EXAMPLES: + EXAMPLES:: + sage: m = ntl.mat_ZZ(3, 2, range(6)); m [ [0 1] @@ -123,7 +125,8 @@ cdef class ntl_mat_ZZ(object): """ Return the string representation of self. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(2,3,[5..10]) ; M.__repr__() '[\n[5 6 7]\n[8 9 10]\n]' """ @@ -133,7 +136,8 @@ cdef class ntl_mat_ZZ(object): """ Multiply two matrices. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(2,2,[8..11]) ; N = ntl.mat_ZZ(2,2,[-1..2]) sage: M*N [ @@ -155,7 +159,8 @@ cdef class ntl_mat_ZZ(object): """ Return self - other. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(2,2,[8..11]) ; N = ntl.mat_ZZ(2,2,[-1..2]) sage: M-N [ @@ -177,7 +182,8 @@ cdef class ntl_mat_ZZ(object): """ Return self + other. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(2,2,[8..11]) ; N = ntl.mat_ZZ(2,2,[-1..2]) sage: M+N [ @@ -227,7 +233,8 @@ cdef class ntl_mat_ZZ(object): """ Return self to the e power. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(2,2,[8..11]) sage: M**4 [ @@ -258,7 +265,8 @@ cdef class ntl_mat_ZZ(object): """ Return the number of rows in self. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(5,5,range(25)) sage: M.nrows() 5 @@ -269,7 +277,8 @@ cdef class ntl_mat_ZZ(object): """ Return the number of columns in self. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(5,8,range(40)) sage: M.ncols() 8 @@ -280,7 +289,8 @@ cdef class ntl_mat_ZZ(object): """ Given a tuple (i, j), return self[i,j]. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(2,9,[3..20]) sage: M[1,7] ## indirect doctest 19 @@ -323,7 +333,8 @@ cdef class ntl_mat_ZZ(object): def list(self): """ - EXAMPLES: + EXAMPLES:: + sage: m = ntl.mat_ZZ(3, 4, range(12)); m [ [0 1 2 3] @@ -345,7 +356,8 @@ cdef class ntl_mat_ZZ(object): """ Return the determinant of self. - EXAMPLES: + EXAMPLES:: + sage: ntl.mat_ZZ(8,8,[3..66]).determinant() 0 sage: ntl.mat_ZZ(2,5,range(10)).determinant() @@ -428,7 +440,8 @@ cdef class ntl_mat_ZZ(object): Find the characteristic polynomial of self, and return it as an NTL ZZX. - EXAMPLES: + EXAMPLES:: + sage: M = ntl.mat_ZZ(2,2,[1,2,3,4]) sage: M.charpoly() [-2 -5 1] @@ -476,7 +489,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.BKZ_FP(); a @@ -545,7 +559,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.BKZ_QP(); a @@ -614,7 +629,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.BKZ_QP1(); a @@ -683,7 +699,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.BKZ_XD(); a @@ -752,7 +769,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.BKZ_RR(); a @@ -821,7 +839,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.G_BKZ_FP(); a @@ -890,7 +909,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.G_BKZ_QP(); a @@ -959,7 +979,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.G_BKZ_QP1(); a @@ -1028,7 +1049,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.G_BKZ_XD(); a @@ -1097,7 +1119,8 @@ cdef class ntl_mat_ZZ(object): prune -- see above (default: 0) verbose -- print verbose output (default: False) - EXAMPLES: + EXAMPLES:: + sage: A = Matrix(ZZ,5,5,range(25)) sage: a = A._ntl_() sage: a.G_BKZ_RR(); a @@ -1185,7 +1208,8 @@ cdef class ntl_mat_ZZ(object): above and U is an optional return value if return_U is True. - EXAMPLES: + EXAMPLES:: + sage: M=ntl.mat_ZZ(3,3,[1,2,3,4,5,6,7,8,9]) sage: M.LLL() (2, 54) @@ -1270,7 +1294,8 @@ cdef class ntl_mat_ZZ(object): (rank,[U]) where rank and U are as described above and U is an optional return value if return_U is True. - EXAMPLES: + EXAMPLES:: + sage: M=ntl.mat_ZZ(3,3,[1,2,3,4,5,6,7,8,9]) sage: M.LLL_FP() 2 @@ -1318,7 +1343,8 @@ cdef class ntl_mat_ZZ(object): Performs the same reduction as \code{self.LLL_FP} using the same calling conventions but with quad float precision. - EXAMPLES: + EXAMPLES:: + sage: M=ntl.mat_ZZ(3,3,[1,2,3,4,5,6,7,8,9]) sage: M.LLL_QP(delta=0.75) 2 @@ -1342,7 +1368,8 @@ cdef class ntl_mat_ZZ(object): same calling conventions but with extended exponent double precision. - EXAMPLES: + EXAMPLES:: + sage: M=ntl.mat_ZZ(3,3,[1,2,3,4,5,6,7,8,9]) sage: M.LLL_XD(delta=0.75) 2 @@ -1366,7 +1393,8 @@ cdef class ntl_mat_ZZ(object): same calling conventions but with arbitrary precision floating point numbers. - EXAMPLES: + EXAMPLES:: + sage: M=ntl.mat_ZZ(3,3,[1,2,3,4,5,6,7,8,9]) sage: M.LLL_RR(delta=0.75) 2 diff --git a/src/sage/libs/pynac/constant.pyx b/src/sage/libs/pynac/constant.pyx index f05941e6f08..48ce02fc594 100644 --- a/src/sage/libs/pynac/constant.pyx +++ b/src/sage/libs/pynac/constant.pyx @@ -27,7 +27,7 @@ cdef class PynacConstant: """ Creates a constant in Pynac. - EXAMPLES: + EXAMPLES:: sage: from sage.libs.pynac.constant import PynacConstant sage: f = PynacConstant('foo', 'foo', 'real') diff --git a/src/sage/libs/symmetrica/sb.pxi b/src/sage/libs/symmetrica/sb.pxi index 46c0bc56d97..2a7b7ed6a5c 100644 --- a/src/sage/libs/symmetrica/sb.pxi +++ b/src/sage/libs/symmetrica/sb.pxi @@ -35,7 +35,8 @@ def mult_schubert_schubert_symmetrica(a, b): """ Multiplies the Schubert polynomials a and b. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.mult_schubert_schubert([3,2,1], [3,2,1]) X[5, 3, 1, 2, 4] """ @@ -68,7 +69,8 @@ def t_SCHUBERT_POLYNOM_symmetrica(a): Converts a Schubert polynomial to a 'regular' multivariate polynomial. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.t_SCHUBERT_POLYNOM([3,2,1]) x0^2*x1 """ @@ -97,7 +99,8 @@ def t_POLYNOM_SCHUBERT_symmetrica(a): """ Converts a multivariate polynomial a to a Schubert polynomial. - EXAMPLES: + EXAMPLES:: + sage: R. = QQ[] sage: w0 = x1^2*x2 sage: symmetrica.t_POLYNOM_SCHUBERT(w0) @@ -134,7 +137,8 @@ def mult_schubert_variable_symmetrica(a, i): Returns the product of a and x_i. Note that indexing with i starts at 1. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.mult_schubert_variable([3,2,1], 2) X[3, 2, 4, 1] sage: symmetrica.mult_schubert_variable([3,2,1], 4) @@ -169,7 +173,8 @@ def divdiff_perm_schubert_symmetrica(perm, a): $\delta_i$ to $a$ where $a$ is either a permutation or a Schubert polynomial over QQ. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.divdiff_perm_schubert([2,3,1], [3,2,1]) X[2, 1] sage: symmetrica.divdiff_perm_schubert([3,1,2], [3,2,1]) @@ -215,7 +220,8 @@ def divdiff_perm_schubert_symmetrica(perm, a): def scalarproduct_schubert_symmetrica(a, b): """ - EXAMPLES: + EXAMPLES:: + sage: symmetrica.scalarproduct_schubert([3,2,1], [3,2,1]) X[1, 3, 5, 2, 4] sage: symmetrica.scalarproduct_schubert([3,2,1], [2,1,3]) @@ -251,7 +257,8 @@ def divdiff_schubert_symmetrica(i, a): $\delta_i$ to $a$ where $a$ is either a permutation or a Schubert polynomial over QQ. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.divdiff_schubert(1, [3,2,1]) X[2, 3, 1] sage: symmetrica.divdiff_schubert(2, [3,2,1]) diff --git a/src/sage/libs/symmetrica/schur.pxi b/src/sage/libs/symmetrica/schur.pxi index 4f4f495547a..71edb10b02d 100644 --- a/src/sage/libs/symmetrica/schur.pxi +++ b/src/sage/libs/symmetrica/schur.pxi @@ -63,7 +63,8 @@ def outerproduct_schur_symmetrica(parta, partb): outer tensor product of two irreducibe representations of the symmetric group. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.outerproduct_schur([2],[2]) s[2, 2] + s[3, 1] + s[4] """ @@ -140,7 +141,8 @@ def compute_schur_with_alphabet_symmetrica(part, length, alphabet='x'): partition PART as a POLYNOM erg. The INTEGER length specifies the length of the alphabet. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.compute_schur_with_alphabet(2,2) x0^2 + x0*x1 + x1^2 sage: symmetrica.compute_schur_with_alphabet([2],2) @@ -185,7 +187,8 @@ def compute_homsym_with_alphabet_symmetrica(n, length, alphabet='x'): The INTEGER laenge specifies the length of the alphabet. Both routines are the same. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.compute_homsym_with_alphabet(3,1,'x') x^3 sage: symmetrica.compute_homsym_with_alphabet([2,1],1,'x') @@ -231,7 +234,8 @@ def compute_elmsym_with_alphabet_symmetrica(n, length, alphabet='x'): The INTEGER length specifies the length of the alphabet. Both routines are the same. - EXAMPLES: + EXAMPLES:: + sage: a = symmetrica.compute_elmsym_with_alphabet(2,2); a x0*x1 sage: a.parent() @@ -279,7 +283,8 @@ def compute_monomial_with_alphabet_symmetrica(n, length, alphabet='x'): function labeled by a PARTITION number as a POLYNOM erg. The INTEGER laenge specifies the length of the alphabet. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.compute_monomial_with_alphabet([2,1],2,'x') x0^2*x1 + x0*x1^2 sage: symmetrica.compute_monomial_with_alphabet([1,1,1],2,'x') @@ -325,7 +330,8 @@ def compute_powsym_with_alphabet_symmetrica(n, length, alphabet='x'): or a POW_SYM label as a POLYNOM erg. The INTEGER laenge specifies the length of the alphabet. - EXAMPLES: + EXAMPLES:: + sage: symmetrica.compute_powsym_with_alphabet(2,2,'x') x0^2 + x1^2 sage: symmetrica.compute_powsym_with_alphabet(2,2,'x').parent() @@ -365,7 +371,8 @@ def compute_powsym_with_alphabet_symmetrica(n, length, alphabet='x'): def compute_schur_with_alphabet_det_symmetrica(part, length, alphabet='x'): """ - EXAMPLES: + EXAMPLES:: + sage: symmetrica.compute_schur_with_alphabet_det(2,2) x0^2 + x0*x1 + x1^2 sage: symmetrica.compute_schur_with_alphabet_det([2],2) diff --git a/src/sage/matrix/change_ring.pyx b/src/sage/matrix/change_ring.pyx index 7d8ad3fe133..76e7275d5ec 100644 --- a/src/sage/matrix/change_ring.pyx +++ b/src/sage/matrix/change_ring.pyx @@ -21,7 +21,8 @@ def integer_to_real_double_dense(Matrix_integer_dense A): OUTPUT: -- a dense real double matrix - EXAMPLES: + EXAMPLES:: + sage: a = matrix(ZZ,2,3,[-2,-5,3,4,8,1030339830489349908]) sage: a.change_ring(RDF) [ -2.0 -5.0 3.0] diff --git a/src/sage/matrix/matrix1.pyx b/src/sage/matrix/matrix1.pyx index 6e9d1244b74..6561684872d 100644 --- a/src/sage/matrix/matrix1.pyx +++ b/src/sage/matrix/matrix1.pyx @@ -442,7 +442,7 @@ cdef class Matrix(Matrix0): """ Returns a string defining a Scilab representation of self. - EXAMPLES: + EXAMPLES:: sage: a = matrix([[1,2,3],[4,5,6],[7,8,9]]); a [1 2 3] @@ -471,7 +471,7 @@ cdef class Matrix(Matrix0): """ Creates a ScilabElement object based on self and returns it. - EXAMPLES: + EXAMPLES:: sage: a = matrix([[1,2,3],[4,5,6],[7,8,9]]); a [1 2 3] diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index e0e12eb16ee..637524d5211 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -13947,7 +13947,7 @@ cdef class Matrix(Matrix1): [Sto1998]_, where the former is more representative of the code here. - EXAMPLES: + EXAMPLES:: sage: A = matrix(QQ, [[-68, 69, -27, -11, -65, 9, -181, -32], ....: [-52, 52, -27, -8, -52, -16, -133, -14], diff --git a/src/sage/matrix/matrix_generic_dense.pyx b/src/sage/matrix/matrix_generic_dense.pyx index a8cc42ca55e..41ff970ff51 100644 --- a/src/sage/matrix/matrix_generic_dense.pyx +++ b/src/sage/matrix/matrix_generic_dense.pyx @@ -117,7 +117,8 @@ cdef class Matrix_generic_dense(matrix_dense.Matrix_dense): def _pickle(self): """ - EXAMPLES: + EXAMPLES:: + sage: R. = Integers(25)['x']; A = matrix(R, [1,x,x^3+1,2*x]) sage: A._pickle() ([1, x, x^3 + 1, 2*x], 0) @@ -126,7 +127,8 @@ cdef class Matrix_generic_dense(matrix_dense.Matrix_dense): def _unpickle(self, data, int version): """ - EXAMPLES: + EXAMPLES:: + sage: R. = Integers(25)['x']; A = matrix(R, [1,x,x^3+1,2*x]); B = A.parent()(0) sage: v = A._pickle() sage: B._unpickle(v[0], v[1]) diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index a848ad7581d..241167ace4f 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -253,7 +253,8 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): This code is implicitly called for multiplying self by another sparse matrix. - EXAMPLES: + EXAMPLES:: + sage: a = matrix(GF(43), 3, 3, range(9), sparse=True) sage: b = matrix(GF(43), 3, 3, range(10,19), sparse=True) sage: a*b @@ -326,7 +327,8 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): Multiply self by the sparse matrix _right, and return the result as a dense matrix. - EXAMPLES: + EXAMPLES:: + sage: a = matrix(GF(10007), 2, [1,2,3,4], sparse=True) sage: b = matrix(GF(10007), 2, 3, [1..6], sparse=True) sage: a * b diff --git a/src/sage/matrix/misc.pyx b/src/sage/matrix/misc.pyx index 55d80be5941..0d4fefb289d 100644 --- a/src/sage/matrix/misc.pyx +++ b/src/sage/matrix/misc.pyx @@ -59,7 +59,7 @@ def matrix_integer_dense_rational_reconstruction(Matrix_integer_dense A, Integer A -- matrix N -- an integer - EXAMPLES: + EXAMPLES:: sage: B = ((matrix(ZZ, 3,4, [1,2,3,-4,7,2,18,3,4,3,4,5])/3)%500).change_ring(ZZ) sage: sage.matrix.misc.matrix_integer_dense_rational_reconstruction(B, 500) @@ -146,7 +146,7 @@ def matrix_integer_sparse_rational_reconstruction(Matrix_integer_sparse A, Integ rational reconstruction on all entries of the matrix, viewed as numbers mod N. - EXAMPLES: + EXAMPLES:: sage: A = matrix(ZZ, 3, 4, [(1/3)%500, 2, 3, (-4)%500, 7, 2, 2, 3, 4, 3, 4, (5/7)%500], sparse=True) sage: sage.matrix.misc.matrix_integer_sparse_rational_reconstruction(A, 500) @@ -290,7 +290,7 @@ def matrix_rational_echelon_form_multimodular(Matrix self, height_guess=None, pr where H denotes the height. If this fails, do step 4 with a few more primes. - EXAMPLES: + EXAMPLES:: sage: A = matrix(QQ, 3, 7, [1..21]) sage: from sage.matrix.misc import matrix_rational_echelon_form_multimodular diff --git a/src/sage/misc/fpickle.pyx b/src/sage/misc/fpickle.pyx index 44efb2385c3..2f4fed80caf 100644 --- a/src/sage/misc/fpickle.pyx +++ b/src/sage/misc/fpickle.pyx @@ -86,7 +86,7 @@ def unpickle_function(pickled): """ Unpickle a pickled function. - EXAMPLES: + EXAMPLES:: sage: def f(N,M): return N*M ... diff --git a/src/sage/misc/inline_fortran.py b/src/sage/misc/inline_fortran.py index e44724bc018..508bc7defe8 100644 --- a/src/sage/misc/inline_fortran.py +++ b/src/sage/misc/inline_fortran.py @@ -22,7 +22,7 @@ def _import_module_from_path(name, path=None): Returns a fully executed module object without inserting that module into `sys.modules`. - EXAMPLES: + EXAMPLES:: sage: from sage.misc.inline_fortran import _import_module_from_path sage: modname = '___test__import_module_from_path' diff --git a/src/sage/misc/latex.py b/src/sage/misc/latex.py index 7f09a049164..b94f7971406 100644 --- a/src/sage/misc/latex.py +++ b/src/sage/misc/latex.py @@ -2821,7 +2821,7 @@ def _repr_(self): """ String representation - EXAMPLES: + EXAMPLES:: sage: from sage.misc.latex import latex_examples sage: len(latex_examples.knot()._repr_()) > 300 @@ -2873,7 +2873,7 @@ def _repr_(self): """ String representation - EXAMPLES: + EXAMPLES:: sage: from sage.misc.latex import latex_examples sage: len(latex_examples.diagram()._repr_()) > 300 diff --git a/src/sage/misc/sage_ostools.pyx b/src/sage/misc/sage_ostools.pyx index f3512ac3846..a272097876f 100644 --- a/src/sage/misc/sage_ostools.pyx +++ b/src/sage/misc/sage_ostools.pyx @@ -58,7 +58,7 @@ def restore_cwd(chdir=None): - ``chdir`` -- optionally change directories to the given directory upon entering the context manager - EXAMPLES: + EXAMPLES:: sage: import os sage: from sage.misc.sage_ostools import restore_cwd diff --git a/src/sage/modular/btquotients/btquotient.py b/src/sage/modular/btquotients/btquotient.py index 07cd03c0b9d..9c221622418 100644 --- a/src/sage/modular/btquotients/btquotient.py +++ b/src/sage/modular/btquotients/btquotient.py @@ -1428,7 +1428,7 @@ def __classcall__(cls, p, Nminus, Nplus=1, character=None, """ Ensure that a canonical BruhatTitsQuotient is created. - EXAMPLES: + EXAMPLES:: sage: BruhatTitsQuotient(3,17) is BruhatTitsQuotient(3,17,1) True @@ -2427,7 +2427,7 @@ def _increase_precision(self, amount=1): - ``amount`` Integer (default: 1). The amount by which to increase the precision. - EXAMPLES: + EXAMPLES:: sage: X = BruhatTitsQuotient(3,101) sage: X.get_embedding_matrix() diff --git a/src/sage/modular/btquotients/pautomorphicform.py b/src/sage/modular/btquotients/pautomorphicform.py index 344a93720b2..25e884037da 100644 --- a/src/sage/modular/btquotients/pautomorphicform.py +++ b/src/sage/modular/btquotients/pautomorphicform.py @@ -954,7 +954,7 @@ def _an_element_(self): A harmonic cocycle in self. - EXAMPLES: + EXAMPLES:: sage: X = BruhatTitsQuotient(5,23) sage: H = X.harmonic_cocycles(2,prec=10) diff --git a/src/sage/modular/hecke/submodule.py b/src/sage/modular/hecke/submodule.py index 99e4b7b1a7a..b51a64c58e5 100644 --- a/src/sage/modular/hecke/submodule.py +++ b/src/sage/modular/hecke/submodule.py @@ -242,7 +242,7 @@ def _compute_hecke_matrix(self, n): def _compute_diamond_matrix(self, d): r""" - EXAMPLES: + EXAMPLES:: sage: f = ModularSymbols(Gamma1(13),2,sign=1).cuspidal_subspace().decomposition()[0] sage: a = f.diamond_bracket_operator(2).matrix() # indirect doctest diff --git a/src/sage/modular/modsym/space.py b/src/sage/modular/modsym/space.py index 75ff364fb38..281c4572228 100644 --- a/src/sage/modular/modsym/space.py +++ b/src/sage/modular/modsym/space.py @@ -1126,7 +1126,7 @@ def congruence_number(self, other, prec=None): If prec is not given it is set equal to the max of the ``hecke_bound`` function called on each space. - EXAMPLES: + EXAMPLES:: sage: A, B = ModularSymbols(48, 2).cuspidal_submodule().decomposition() sage: A.congruence_number(B) diff --git a/src/sage/modules/vector_complex_double_dense.pyx b/src/sage/modules/vector_complex_double_dense.pyx index fbdbcda2040..95da06bd693 100644 --- a/src/sage/modules/vector_complex_double_dense.pyx +++ b/src/sage/modules/vector_complex_double_dense.pyx @@ -53,7 +53,8 @@ cdef class Vector_complex_double_dense(Vector_double_dense): implemented using numpy which will call the underlying BLAS, if needed, on the system. - EXAMPLES: + EXAMPLES:: + sage: v = vector(CDF,[(1,-1), (2,pi), (3,5)]) sage: v (1.0 - 1.0*I, 2.0 + 3.141592653589793*I, 3.0 + 5.0*I) @@ -73,7 +74,8 @@ cdef class Vector_complex_double_dense(Vector_double_dense): """ Pickling - EXAMPLES: + EXAMPLES:: + sage: a = vector(CDF, range(9)) sage: loads(dumps(a)) == a True @@ -86,7 +88,8 @@ def unpickle_v0(parent, entries, degree): """ Create a complex double vector containing the entries. - EXAMPLES: + EXAMPLES:: + sage: v = vector(CDF, [1,2,3]) sage: w = sage.modules.vector_complex_double_dense.unpickle_v0(v.parent(), list(v), v.degree()) sage: v == w @@ -99,7 +102,8 @@ def unpickle_v1(parent, entries, degree, is_mutable=None): Create a complex double vector with the given parent, entries, degree, and mutability. - EXAMPLES: + EXAMPLES:: + sage: v = vector(CDF, [1,2,3]) sage: w = sage.modules.vector_complex_double_dense.unpickle_v1(v.parent(), list(v), v.degree(), v.is_mutable()) sage: v == w diff --git a/src/sage/modules/vector_modn_dense.pyx b/src/sage/modules/vector_modn_dense.pyx index d0184ad2939..afa49902dcb 100644 --- a/src/sage/modules/vector_modn_dense.pyx +++ b/src/sage/modules/vector_modn_dense.pyx @@ -293,7 +293,8 @@ cdef class Vector_modn_dense(free_module_element.FreeModuleElement): cpdef _pairwise_product_(self, Vector right): """ - EXAMPLES: + EXAMPLES:: + sage: v = vector(Integers(8), [2,3]); w = vector(Integers(8), [2,5]) sage: v * w 3 diff --git a/src/sage/modules/vector_real_double_dense.pyx b/src/sage/modules/vector_real_double_dense.pyx index bc01c96d6f6..9f96f23af38 100644 --- a/src/sage/modules/vector_real_double_dense.pyx +++ b/src/sage/modules/vector_real_double_dense.pyx @@ -1,7 +1,8 @@ r""" Dense real double vectors using a NumPy backend. -EXAMPLES: +EXAMPLES:: + sage: v = vector(RDF,[1, pi, sqrt(2)]) sage: v (1.0, 3.141592653589793, 1.414213562373095) @@ -43,7 +44,8 @@ cdef class Vector_real_double_dense(Vector_double_dense): using numpy which will call the underlying BLAS, if needed, on the system. - EXAMPLES: + EXAMPLES:: + sage: v = vector(RDF, [1,2,3,4]); v (1.0, 2.0, 3.0, 4.0) sage: v*v @@ -67,7 +69,8 @@ cdef class Vector_real_double_dense(Vector_double_dense): left tail of the distribution. (Paragraph from the scipy.stats docstring.) - EXAMPLES: + EXAMPLES:: + sage: v = vector(RDF, range(9)) sage: v.stats_skew() 0.0 @@ -80,7 +83,8 @@ cdef class Vector_real_double_dense(Vector_double_dense): """ Pickling - EXAMPLES: + EXAMPLES:: + sage: a = vector(RDF, range(9)) sage: loads(dumps(a)) == a True @@ -93,7 +97,8 @@ def unpickle_v0(parent, entries, degree): """ Create a real double vector containing the entries. - EXAMPLES: + EXAMPLES:: + sage: v = vector(RDF, [1,2,3]) sage: w = sage.modules.vector_real_double_dense.unpickle_v0(v.parent(), list(v), v.degree()) sage: v == w @@ -106,7 +111,8 @@ def unpickle_v1(parent, entries, degree, is_mutable=None): Create a real double vector with the given parent, entries, degree, and mutability. - EXAMPLES: + EXAMPLES:: + sage: v = vector(RDF, [1,2,3]) sage: w = sage.modules.vector_real_double_dense.unpickle_v1(v.parent(), list(v), v.degree(), v.is_mutable()) sage: v == w diff --git a/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py b/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py index b52b9e915d6..977126e99de 100644 --- a/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py +++ b/src/sage/quadratic_forms/quadratic_form__local_field_invariants.py @@ -360,7 +360,7 @@ def signature(self): an integer - EXAMPLES: + EXAMPLES:: sage: Q = DiagonalQuadraticForm(ZZ, [1,0,0,-4,3,11,3]) sage: Q.signature() @@ -873,7 +873,7 @@ def compute_definiteness_string_by_determinants(self): string describing the definiteness - EXAMPLES: + EXAMPLES:: sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1,1]) sage: Q.compute_definiteness_string_by_determinants() diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx index 9d756315739..f5095198f0f 100644 --- a/src/sage/quadratic_forms/ternary.pyx +++ b/src/sage/quadratic_forms/ternary.pyx @@ -967,7 +967,7 @@ def _find_p_neighbor_from_vec(a, b, c, r, s, t, p, v, mat = False): Reference: Gonzalo Tornaria's Thesis, Thrm 3.5, p34. - EXAMPLES: + EXAMPLES:: sage: from sage.quadratic_forms.ternary import _find_p_neighbor_from_vec sage: Q = TernaryQF([1, 3, 3, -2, 0, -1]) diff --git a/src/sage/quivers/algebra.py b/src/sage/quivers/algebra.py index 6cf7075345d..5fe6affaaea 100644 --- a/src/sage/quivers/algebra.py +++ b/src/sage/quivers/algebra.py @@ -500,7 +500,7 @@ def quiver(self): - :class:`DiGraph`, the quiver of the algebra - EXAMPLES: + EXAMPLES:: sage: P = DiGraph({1:{2:['a', 'b']}}).path_semigroup() sage: A = P.algebra(GF(3)) @@ -526,7 +526,7 @@ def semigroup(self): - the path semigroup from which ``self`` was formed (a partial semigroup) - EXAMPLES: + EXAMPLES:: sage: P = DiGraph({1:{2:['a', 'b']}}).path_semigroup() sage: A = P.algebra(GF(3)) diff --git a/src/sage/quivers/representation.py b/src/sage/quivers/representation.py index 7c0ed7837b8..60a6b680ee3 100644 --- a/src/sage/quivers/representation.py +++ b/src/sage/quivers/representation.py @@ -2196,7 +2196,7 @@ def quotient(self, sub, check=True): projection map from ``self`` to ``quot`` can be obtained by calling ``quot.coerce_map_from(self)``. - EXAMPLES: + EXAMPLES:: sage: Q = DiGraph({1:{2:['a','b']}, 2:{3:['c']}}).path_semigroup() sage: M = Q.I(GF(3), 3) diff --git a/src/sage/rings/finite_rings/finite_field_base.pyx b/src/sage/rings/finite_rings/finite_field_base.pyx index af90c0b323c..e0ee4e21299 100644 --- a/src/sage/rings/finite_rings/finite_field_base.pyx +++ b/src/sage/rings/finite_rings/finite_field_base.pyx @@ -1606,7 +1606,7 @@ cdef class FiniteField(Field): """ Return ``True`` if self is defined by a Conway polynomial. - EXAMPLES: + EXAMPLES:: sage: GF(5^3, 'a').is_conway() True diff --git a/src/sage/rings/finite_rings/integer_mod.pyx b/src/sage/rings/finite_rings/integer_mod.pyx index 56041a26766..ee518853ba5 100644 --- a/src/sage/rings/finite_rings/integer_mod.pyx +++ b/src/sage/rings/finite_rings/integer_mod.pyx @@ -813,7 +813,8 @@ cdef class IntegerMod_abstract(FiniteRingElement): """ Returns the minimal polynomial of this element. - EXAMPLES: + EXAMPLES:: + sage: GF(241, 'a')(1).minpoly() x + 240 """ @@ -823,7 +824,8 @@ cdef class IntegerMod_abstract(FiniteRingElement): """ Returns the minimal polynomial of this element. - EXAMPLES: + EXAMPLES:: + sage: GF(241, 'a')(1).minimal_polynomial(var = 'z') z + 240 """ @@ -2161,7 +2163,8 @@ cdef class IntegerMod_gmp(IntegerMod_abstract): def __pow__(IntegerMod_gmp self, exp, m): # NOTE: m ignored, always use modulus of parent ring """ - EXAMPLES: + EXAMPLES:: + sage: R = Integers(10^10) sage: R(2)^1000 5668069376 @@ -2630,7 +2633,8 @@ cdef class IntegerMod_int(IntegerMod_abstract): def __pow__(IntegerMod_int self, exp, m): # NOTE: m ignored, always use modulus of parent ring """ - EXAMPLES: + EXAMPLES:: + sage: R = Integers(10) sage: R(2)^10 4 @@ -3421,7 +3425,8 @@ cdef class IntegerMod_int64(IntegerMod_abstract): def __pow__(IntegerMod_int64 self, exp, m): # NOTE: m ignored, always use modulus of parent ring """ - EXAMPLES: + EXAMPLES:: + sage: R = Integers(10) sage: R(2)^10 4 diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 17e62f3932b..5e4e391f13d 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -5934,7 +5934,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): for a large list of small integers the overhead of calling StringToInteger can be a killer. - EXAMPLES: + EXAMPLES:: + sage: (117)._magma_init_(magma) # optional - magma '117' @@ -6731,7 +6732,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Return the complex conjugate of this integer, which is the integer itself. - EXAMPLES: + EXAMPLES:: + sage: n = 205 sage: n.conjugate() 205 diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py index a90c12665a3..3edd42b2b36 100644 --- a/src/sage/rings/number_field/number_field_ideal.py +++ b/src/sage/rings/number_field/number_field_ideal.py @@ -1099,7 +1099,7 @@ def is_principal(self, proof=None): ``proof=True`` (this is the default setting) to prove the correctness of the output. - EXAMPLES: + EXAMPLES:: sage: K = QuadraticField(-119,'a') sage: P = K.factor(2)[1][0] diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py index c726e7aa720..d862ccced0f 100644 --- a/src/sage/rings/padics/generic_nodes.py +++ b/src/sage/rings/padics/generic_nodes.py @@ -508,7 +508,7 @@ def label(self): Elements of a parent with some label do not coerce to a parent with a different label. However conversions are allowed. - EXAMPLES: + EXAMPLES:: sage: R = ZpLC(5) sage: R.label() # no label by default diff --git a/src/sage/rings/padics/lattice_precision.py b/src/sage/rings/padics/lattice_precision.py index 22c09f80710..e69ef472e78 100644 --- a/src/sage/rings/padics/lattice_precision.py +++ b/src/sage/rings/padics/lattice_precision.py @@ -780,7 +780,7 @@ def ambient_dimension(self): Return the dimension of the vector space in which the precision module/lattice lives. - EXAMPLES: + EXAMPLES:: sage: R = ZpLC(2, label='ambient_dim') sage: prec = R.precision() diff --git a/src/sage/rings/padics/padic_generic.py b/src/sage/rings/padics/padic_generic.py index 7f482f9194e..8518daab69d 100644 --- a/src/sage/rings/padics/padic_generic.py +++ b/src/sage/rings/padics/padic_generic.py @@ -1128,7 +1128,7 @@ def _test_elements_eq_transitive(self, **options): The operator ``==`` is not transitive for `p`-adic numbers. We disable the check of the category framework by overriding this method. - EXAMPLES: + EXAMPLES:: sage: R = Zp(3) sage: R(3) == R(0,1) diff --git a/src/sage/rings/padics/padic_lattice_element.py b/src/sage/rings/padics/padic_lattice_element.py index 51f672f1c5c..f3760cb9ac6 100644 --- a/src/sage/rings/padics/padic_lattice_element.py +++ b/src/sage/rings/padics/padic_lattice_element.py @@ -909,7 +909,7 @@ def lift(self): its absolute precision. If a rational is returned, its denominator will be a power of `p`. - EXAMPLES: + EXAMPLES:: sage: R = ZpLC(7) sage: a = R(8); a.lift() diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx index 148eb91f7db..fe8487ff63c 100644 --- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx +++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx @@ -1544,7 +1544,8 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base): """ Serializes self. - EXAMPLES: + EXAMPLES:: + sage: P. = PolynomialRing(QQ, order='degrevlex') sage: P == loads(dumps(P)) True diff --git a/src/sage/rings/polynomial/pbori.pyx b/src/sage/rings/polynomial/pbori.pyx index e62cf0eaa44..ecde06908ac 100644 --- a/src/sage/rings/polynomial/pbori.pyx +++ b/src/sage/rings/polynomial/pbori.pyx @@ -5125,7 +5125,7 @@ class BooleanPolynomialIdeal(MPolynomialIdeal): EXAMPLES: - A Simple example:: + A simple example:: sage: from sage.doctest.fixtures import reproducible_repr sage: R. = BooleanPolynomialRing() @@ -7066,7 +7066,8 @@ cdef class GroebnerStrategy: cdef class BooleanMulAction(Action): cpdef _act_(self, g, x): """ - EXAMPLES: + EXAMPLES:: + sage: from brial import BooleanMonomialMonoid sage: P. = BooleanPolynomialRing(3) sage: M = BooleanMonomialMonoid(P) diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index a711e94cb80..820895505be 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -6087,7 +6087,7 @@ cdef class Polynomial(CommutativeAlgebraElement): For internal use only. - EXAMPLES: + EXAMPLES:: sage: R. = PolynomialRing(ZZ) sage: (2*a^2 + a)._pari_with_name() @@ -10904,7 +10904,8 @@ cdef class Polynomial_generic_dense(Polynomial): OUTPUT: element of base ring - EXAMPLES: + EXAMPLES:: + sage: R. = QQ[] sage: S. = R[] sage: f = x*t + x + t diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py index c94b7fc8d33..c1de1b91d4c 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py @@ -283,7 +283,7 @@ def _richcmp_(self, other, op): Compare this element with something else, where equality testing coerces the object on the right, if possible (and necessary). - EXAMPLES: + EXAMPLES:: sage: R. = PolynomialRing(QQ) sage: S. = R.quotient(x^3-2) diff --git a/src/sage/rings/polynomial/skew_polynomial_element.pyx b/src/sage/rings/polynomial/skew_polynomial_element.pyx index 6f22c02c8f5..0f75b12901b 100644 --- a/src/sage/rings/polynomial/skew_polynomial_element.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_element.pyx @@ -2251,7 +2251,7 @@ cdef class SkewPolynomial_generic_dense(SkewPolynomial): Return the generic dense skew polynomial corresponding to the current parameters provided ``self``. - EXAMPLES: + EXAMPLES:: sage: R. = QQ[] sage: sigma = R.hom([t+1]) diff --git a/src/sage/rings/polynomial/skew_polynomial_ring.py b/src/sage/rings/polynomial/skew_polynomial_ring.py index 9dfeb17182b..9aa25f80da0 100644 --- a/src/sage/rings/polynomial/skew_polynomial_ring.py +++ b/src/sage/rings/polynomial/skew_polynomial_ring.py @@ -105,7 +105,7 @@ def _minimal_vanishing_polynomial(R, eval_pts): The minimal vanishing polynomial. - EXAMPLES: + EXAMPLES:: sage: from sage.rings.polynomial.skew_polynomial_ring import _minimal_vanishing_polynomial sage: k. = GF(5^3) @@ -738,7 +738,7 @@ def is_sparse(self): Since sparse skew polynomials are not yet implemented, this function always returns ``False``. - EXAMPLES: + EXAMPLES:: sage: R. = RR[] sage: sigma = R.hom([t+1]) diff --git a/src/sage/rings/real_lazy.pyx b/src/sage/rings/real_lazy.pyx index 6c13be234e1..938831a9918 100644 --- a/src/sage/rings/real_lazy.pyx +++ b/src/sage/rings/real_lazy.pyx @@ -397,7 +397,8 @@ class ComplexLazyField_class(LazyField): This lazy field doesn't evaluate its elements until they are cast into a field of fixed precision. - EXAMPLES: + EXAMPLES:: + sage: a = RLF(1/3); a 0.3333333333333334? sage: Reals(200)(a) diff --git a/src/sage/rings/tate_algebra.py b/src/sage/rings/tate_algebra.py index cd6af342ba8..461d648b6d2 100644 --- a/src/sage/rings/tate_algebra.py +++ b/src/sage/rings/tate_algebra.py @@ -494,7 +494,7 @@ def prime(self): """ Return the prime, that is the characteristic of the residue field. - EXAMPLES: + EXAMPLES:: sage: R = Zp(3) sage: A. = TateAlgebra(R) diff --git a/src/sage/rings/tate_algebra_element.pyx b/src/sage/rings/tate_algebra_element.pyx index 1d60ca757a9..c0a8e07c5c5 100644 --- a/src/sage/rings/tate_algebra_element.pyx +++ b/src/sage/rings/tate_algebra_element.pyx @@ -51,7 +51,7 @@ def _pushout_family(elements, initial=ZZ): - ``initial`` -- a parent - EXAMPLES: + EXAMPLES:: sage: from sage.rings.tate_algebra_element import _pushout_family diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py index a5d0c8eff1b..dfd3841f638 100644 --- a/src/sage/sandpiles/sandpile.py +++ b/src/sage/sandpiles/sandpile.py @@ -2004,7 +2004,7 @@ def _set_jacobian_representatives(self): r""" Find representatives for the elements of the Jacobian group. - EXAMPLES: + EXAMPLES:: sage: s = sandpiles.Complete(3) sage: s._set_jacobian_representatives() diff --git a/src/sage/schemes/plane_conics/con_field.py b/src/sage/schemes/plane_conics/con_field.py index 1a294126b05..b4714f86dc5 100644 --- a/src/sage/schemes/plane_conics/con_field.py +++ b/src/sage/schemes/plane_conics/con_field.py @@ -411,7 +411,7 @@ def has_rational_point(self, point = False, delegates the task to the Magma computer algebra system. - EXAMPLES: + EXAMPLES:: sage: Conic(RR, [1, 1, 1]).has_rational_point() False diff --git a/src/sage/schemes/riemann_surfaces/riemann_surface.py b/src/sage/schemes/riemann_surfaces/riemann_surface.py index 8ee7c2407f8..6ab80f88e4b 100644 --- a/src/sage/schemes/riemann_surfaces/riemann_surface.py +++ b/src/sage/schemes/riemann_surfaces/riemann_surface.py @@ -1416,7 +1416,7 @@ def cohomology_basis(self, option=1): differentials `g/(df/dw) dz`, where `f(z,w)=0` is the equation specifying the Riemann surface. - EXAMPLES: + EXAMPLES:: sage: from sage.schemes.riemann_surfaces.riemann_surface import RiemannSurface sage: R. = QQ[] diff --git a/src/sage/schemes/toric/divisor.py b/src/sage/schemes/toric/divisor.py index ed6dfe6c317..13d7b4b88b9 100644 --- a/src/sage/schemes/toric/divisor.py +++ b/src/sage/schemes/toric/divisor.py @@ -1110,7 +1110,7 @@ def Chow_cycle(self, ring=ZZ): The :class:`~sage.schemes.toric.chow_group.ChowCycle` represented by the divisor. - EXAMPLES: + EXAMPLES:: sage: dP6 = toric_varieties.dP6() sage: cone = dP6.fan(1)[0] diff --git a/src/sage/schemes/toric/points.py b/src/sage/schemes/toric/points.py index 117c4b74278..71e496603e4 100644 --- a/src/sage/schemes/toric/points.py +++ b/src/sage/schemes/toric/points.py @@ -437,7 +437,7 @@ def multiplicative_generator(self): A finite field element. - EXAMPLES: + EXAMPLES:: sage: point_set = toric_varieties.P2(base_ring=GF(5^2, 'a')).point_set() sage: ffe = point_set._finite_field_enumerator() @@ -1031,4 +1031,3 @@ def cardinality(self): for log_t in self.solutions(inhomogeneous, log_range): n += 1 return n - diff --git a/src/sage/schemes/toric/weierstrass.py b/src/sage/schemes/toric/weierstrass.py index 2025db421ac..eaebb84c9fd 100644 --- a/src/sage/schemes/toric/weierstrass.py +++ b/src/sage/schemes/toric/weierstrass.py @@ -649,7 +649,7 @@ def _check_polynomial_P2(cubic, variables): polynomial ring. A ``ValueError`` is raised if the polynomial is not homogeneous. - EXAMPLES: + EXAMPLES:: sage: from sage.schemes.toric.weierstrass import _check_polynomial_P2 sage: R. = QQ[] @@ -990,7 +990,7 @@ def _check_polynomial_P2_112(polynomial, variables): polynomial ring. A ``ValueError`` is raised if the polynomial is not homogeneous. - EXAMPLES: + EXAMPLES:: sage: from sage.schemes.toric.weierstrass import _check_polynomial_P2_112 sage: R. = QQ[] diff --git a/src/sage/schemes/toric/weierstrass_higher.py b/src/sage/schemes/toric/weierstrass_higher.py index 23042d5a6d8..7c0e1beb0c2 100644 --- a/src/sage/schemes/toric/weierstrass_higher.py +++ b/src/sage/schemes/toric/weierstrass_higher.py @@ -83,7 +83,7 @@ def _check_polynomials_P3(quadratic1, quadratic2, variables): polynomial ring. A ``ValueError`` is raised if the polynomial is not homogeneous. - EXAMPLES: + EXAMPLES:: sage: from sage.schemes.toric.weierstrass_higher import _check_polynomials_P3 sage: R. = QQ[]