diff --git a/src/sage/algebras/affine_nil_temperley_lieb.py b/src/sage/algebras/affine_nil_temperley_lieb.py index 720c5f481cd..1fa213bd4bc 100644 --- a/src/sage/algebras/affine_nil_temperley_lieb.py +++ b/src/sage/algebras/affine_nil_temperley_lieb.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Affine nilTemperley Lieb Algebra of type A """ diff --git a/src/sage/algebras/algebra.py b/src/sage/algebras/algebra.py index 5aac6f22b9a..e69ea7da530 100644 --- a/src/sage/algebras/algebra.py +++ b/src/sage/algebras/algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Abstract base class for algebras """ diff --git a/src/sage/algebras/askey_wilson.py b/src/sage/algebras/askey_wilson.py index 37303e030c3..4943c73b36d 100644 --- a/src/sage/algebras/askey_wilson.py +++ b/src/sage/algebras/askey_wilson.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Askey-Wilson Algebras diff --git a/src/sage/algebras/associated_graded.py b/src/sage/algebras/associated_graded.py index 5e9d7b1f6b9..5dd01321114 100644 --- a/src/sage/algebras/associated_graded.py +++ b/src/sage/algebras/associated_graded.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Associated Graded Algebras To Filtered Algebras diff --git a/src/sage/algebras/catalog.py b/src/sage/algebras/catalog.py index efda74ed00e..ec48a6debed 100644 --- a/src/sage/algebras/catalog.py +++ b/src/sage/algebras/catalog.py @@ -84,17 +84,18 @@ ` """ -from sage.algebras.free_algebra import FreeAlgebra as Free -from sage.algebras.quatalg.quaternion_algebra import QuaternionAlgebra as Quaternion -from sage.algebras.steenrod.steenrod_algebra import SteenrodAlgebra as Steenrod -from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra import FiniteDimensionalAlgebra as FiniteDimensional -from sage.algebras.group_algebra import GroupAlgebra as Group -from sage.algebras.clifford_algebra import CliffordAlgebra as Clifford -from sage.algebras.clifford_algebra import ExteriorAlgebra as Exterior -from sage.algebras.weyl_algebra import DifferentialWeylAlgebra as DifferentialWeyl -from sage.algebras.lie_algebras.lie_algebra import LieAlgebra as Lie - from sage.misc.lazy_import import lazy_import +lazy_import('sage.algebras.free_algebra', 'FreeAlgebra', as_='Free') +lazy_import('sage.algebras.quatalg.quaternion_algebra', 'QuaternionAlgebra', as_='Quaternion') +lazy_import('sage.algebras.steenrod.steenrod_algebra', 'SteenrodAlgebra', as_='Steenrod') +lazy_import('sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra', + 'FiniteDimensionalAlgebra', as_='FiniteDimensional') +lazy_import('sage.algebras.group_algebra', 'GroupAlgebra', as_='Group') +lazy_import('sage.algebras.clifford_algebra', 'CliffordAlgebra', as_='Clifford') +lazy_import('sage.algebras.clifford_algebra', 'ExteriorAlgebra', as_='Exterior') +lazy_import('sage.algebras.weyl_algebra', 'DifferentialWeylAlgebra', as_='DifferentialWeyl') +lazy_import('sage.algebras.lie_algebras.lie_algebra', 'LieAlgebra', as_='Lie') + lazy_import('sage.algebras.iwahori_hecke_algebra', 'IwahoriHeckeAlgebra', 'IwahoriHecke') lazy_import('sage.algebras.nil_coxeter_algebra', 'NilCoxeterAlgebra', 'NilCoxeter') lazy_import('sage.algebras.free_zinbiel_algebra', 'FreeZinbielAlgebra', 'FreeZinbiel') diff --git a/src/sage/algebras/cellular_basis.py b/src/sage/algebras/cellular_basis.py index 873bd899b3e..e6e7487cba9 100644 --- a/src/sage/algebras/cellular_basis.py +++ b/src/sage/algebras/cellular_basis.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Cellular Basis ============== diff --git a/src/sage/algebras/clifford_algebra.py b/src/sage/algebras/clifford_algebra.py index 220a2eb27a5..ad8bd314c25 100644 --- a/src/sage/algebras/clifford_algebra.py +++ b/src/sage/algebras/clifford_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Clifford Algebras @@ -1770,6 +1771,7 @@ def interior_product_on_basis(self, a, b): Check :trac:`34694`:: + sage: # needs sage.symbolic sage: E = ExteriorAlgebra(SR,'e',3) sage: E.inject_variables() Defining e0, e1, e2 diff --git a/src/sage/algebras/clifford_algebra_element.pyx b/src/sage/algebras/clifford_algebra_element.pyx index 0a1a4adb681..2e6ad0a8547 100644 --- a/src/sage/algebras/clifford_algebra_element.pyx +++ b/src/sage/algebras/clifford_algebra_element.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules """ Clifford algebra elements @@ -944,6 +945,7 @@ cdef class CohomologyRAAGElement(CliffordAlgebraElement): EXAMPLES:: + sage: # needs sage.graphs sage.groups sage: C4 = graphs.CycleGraph(4) sage: A = groups.misc.RightAngledArtin(C4) sage: H = A.cohomology() diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py index 880814feba7..6324bc235be 100644 --- a/src/sage/algebras/cluster_algebra.py +++ b/src/sage/algebras/cluster_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.graphs sage.modules r""" Cluster algebras @@ -361,12 +362,11 @@ from sage.categories.rings import Rings from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver from sage.combinat.permutation import Permutation -from sage.geometry.cone import Cone -from sage.geometry.fan import Fan from sage.graphs.digraph import DiGraph from sage.matrix.constructor import identity_matrix, matrix from sage.matrix.special import block_matrix from sage.misc.cachefunc import cached_method +from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod from sage.modules.free_module_element import vector from sage.rings.infinity import infinity @@ -381,6 +381,8 @@ from sage.structure.sage_object import SageObject from sage.structure.unique_representation import UniqueRepresentation +lazy_import('sage.geometry.cone', 'Cone') +lazy_import('sage.geometry.fan', 'Fan') ############################################################################## # Elements of a cluster algebra @@ -2373,7 +2375,7 @@ def cluster_fan(self, depth=infinity): EXAMPLES:: sage: A = ClusterAlgebra(['A', 2]) - sage: A.cluster_fan() + sage: A.cluster_fan() # needs sage.geometry.polyhedron Rational polyhedral fan in 2-d lattice N """ seeds = self.seeds(depth=depth, mutating_F=False) diff --git a/src/sage/algebras/commutative_dga.py b/src/sage/algebras/commutative_dga.py index 953364d6813..35facfa7866 100644 --- a/src/sage/algebras/commutative_dga.py +++ b/src/sage/algebras/commutative_dga.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Commutative Differential Graded Algebras @@ -42,7 +43,8 @@ sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1,1,2)) sage: B = A.cdg_algebra({x: x*y, y: -x*y}) sage: B - Commutative Differential Graded Algebra with generators ('x', 'y', 'z') in degrees (1, 1, 2) over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('x', 'y', 'z') + in degrees (1, 1, 2) over Rational Field with differential: x --> x*y y --> -x*y z --> 0 @@ -116,7 +118,7 @@ def sorting_keys(element): OUTPUT: - Its coordinates in the corresponding cohomology_raw quotient vector space + Its coordinates in the corresponding ``cohomology_raw`` quotient vector space EXAMPLES:: @@ -155,7 +157,8 @@ class Differential(UniqueRepresentation, Morphism, sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 2, 3)) sage: B = A.cdg_algebra({x: x*y, y: -x*y , z: t}) sage: B - Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') in degrees (1, 1, 2, 3) over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') + in degrees (1, 1, 2, 3) over Rational Field with differential: x --> x*y y --> -x*y z --> t @@ -181,7 +184,9 @@ def __classcall__(cls, A, im_gens): sage: A. = GradedCommutativeAlgebra(QQ,degrees=(2,2,3,3)) sage: A = A.quotient(A.ideal([a*u,b*u,x*u])) sage: A.cdg_algebra({x:a*b,a:u}) - Commutative Differential Graded Algebra with generators ('a', 'b', 'x', 'u') in degrees (2, 2, 3, 3) with relations [a*u, b*u, x*u] over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('a', 'b', 'x', 'u') + in degrees (2, 2, 3, 3) with relations [a*u, b*u, x*u] over Rational Field + with differential: a --> u b --> 0 x --> a*b @@ -910,7 +915,8 @@ class GCAlgebra(UniqueRepresentation, QuotientRing_nc): 2 sage: B = A.quotient(A.ideal(a**2*b)) sage: B - Graded Commutative Algebra with generators ('a', 'b') in degrees (2, 3) with relations [a^2*b] over Rational Field + Graded Commutative Algebra with generators ('a', 'b') in degrees (2, 3) + with relations [a^2*b] over Rational Field sage: A.basis(7) [a^2*b] sage: B.basis(7) @@ -1203,9 +1209,10 @@ def quotient(self, I, check=True): sage: A. = GradedCommutativeAlgebra(GF(5), degrees=(2, 2, 3, 4)) sage: I = A.ideal([x*t+z^2, x*y - t]) - sage: B = A.quotient(I) - sage: B - Graded Commutative Algebra with generators ('x', 'y', 'z', 't') in degrees (2, 2, 3, 4) with relations [x*t, x*y - t] over Finite Field of size 5 + sage: B = A.quotient(I); B + Graded Commutative Algebra with generators ('x', 'y', 'z', 't') + in degrees (2, 2, 3, 4) with relations [x*t, x*y - t] + over Finite Field of size 5 sage: B(x*t) 0 sage: B(x*y) @@ -1304,13 +1311,22 @@ def _Hom_(self, B, category): sage: B. = GradedCommutativeAlgebra(QQ, degrees=(1,2,3)) sage: C. = GradedCommutativeAlgebra(GF(17)) sage: Hom(A,A) - Set of Homomorphisms from Graded Commutative Algebra with generators ('x', 'y') in degrees (1, 1) over Rational Field to Graded Commutative Algebra with generators ('x', 'y') in degrees (1, 1) over Rational Field + Set of Homomorphisms + from Graded Commutative Algebra with generators ('x', 'y') + in degrees (1, 1) over Rational Field + to Graded Commutative Algebra with generators ('x', 'y') + in degrees (1, 1) over Rational Field sage: Hom(A,B) - Set of Homomorphisms from Graded Commutative Algebra with generators ('x', 'y') in degrees (1, 1) over Rational Field to Graded Commutative Algebra with generators ('a', 'b', 'c') in degrees (1, 2, 3) over Rational Field + Set of Homomorphisms + from Graded Commutative Algebra with generators ('x', 'y') + in degrees (1, 1) over Rational Field + to Graded Commutative Algebra with generators ('a', 'b', 'c') + in degrees (1, 2, 3) over Rational Field sage: Hom(A,C) Traceback (most recent call last): ... - NotImplementedError: homomorphisms of graded commutative algebras have only been implemented when the base rings are the same + NotImplementedError: homomorphisms of graded commutative algebras + have only been implemented when the base rings are the same """ R = self.base_ring() # The base rings need to be checked before the categories, or @@ -1345,7 +1361,8 @@ def differential(self, diff): sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 2)) sage: A.differential({y:x*y, x: x*y}) - Differential of Graded Commutative Algebra with generators ('x', 'y', 'z') in degrees (1, 1, 2) over Rational Field + Differential of Graded Commutative Algebra with generators ('x', 'y', 'z') + in degrees (1, 1, 2) over Rational Field Defn: x --> x*y y --> x*y z --> 0 @@ -1382,7 +1399,8 @@ def cdg_algebra(self, differential): sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 1)) sage: B = A.cdg_algebra({a: b*c, b: a*c}) sage: B - Commutative Differential Graded Algebra with generators ('a', 'b', 'c') in degrees (1, 1, 1) over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('a', 'b', 'c') + in degrees (1, 1, 1) over Rational Field with differential: a --> b*c b --> a*c c --> 0 @@ -1391,7 +1409,8 @@ def cdg_algebra(self, differential): sage: d = A.differential({a: b*c, b: a*c}) sage: d - Differential of Graded Commutative Algebra with generators ('a', 'b', 'c') in degrees (1, 1, 1) over Rational Field + Differential of Graded Commutative Algebra with generators ('a', 'b', 'c') + in degrees (1, 1, 1) over Rational Field Defn: a --> b*c b --> a*c c --> 0 @@ -1646,7 +1665,8 @@ class GCAlgebra_multigraded(GCAlgebra): sage: A. = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0,1), (1,1))) sage: A - Graded Commutative Algebra with generators ('a', 'b', 'c') in degrees ((1, 0), (0, 1), (1, 1)) over Rational Field + Graded Commutative Algebra with generators ('a', 'b', 'c') + in degrees ((1, 0), (0, 1), (1, 1)) over Rational Field sage: a**2 0 sage: c.degree(total=True) @@ -1727,7 +1747,9 @@ def quotient(self, I, check=True): sage: I = A.ideal([x*t+z^2, x*y - t]) sage: B = A.quotient(I) sage: B - Graded Commutative Algebra with generators ('x', 'y', 'z', 't') in degrees (2, 2, 3, 4) with relations [x*t, x*y - t] over Finite Field of size 5 + Graded Commutative Algebra with generators ('x', 'y', 'z', 't') + in degrees (2, 2, 3, 4) with relations [x*t, x*y - t] + over Finite Field of size 5 sage: B(x*t) 0 sage: B(x*y) @@ -1823,7 +1845,8 @@ def differential(self, diff): sage: A. = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2))) sage: A.differential({a: c}) - Differential of Graded Commutative Algebra with generators ('a', 'b', 'c') in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field + Differential of Graded Commutative Algebra with generators ('a', 'b', 'c') + in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field Defn: a --> c b --> 0 c --> 0 @@ -1855,13 +1878,15 @@ def cdg_algebra(self, differential): sage: A. = GradedCommutativeAlgebra(QQ, degrees=((1,0), (0, 1), (0,2))) sage: A.cdg_algebra({a: c}) - Commutative Differential Graded Algebra with generators ('a', 'b', 'c') in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('a', 'b', 'c') + in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field with differential: a --> c b --> 0 c --> 0 sage: d = A.differential({a: c}) sage: A.cdg_algebra(d) - Commutative Differential Graded Algebra with generators ('a', 'b', 'c') in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('a', 'b', 'c') + in degrees ((1, 0), (0, 1), (0, 2)) over Rational Field with differential: a --> c b --> 0 c --> 0 @@ -1884,7 +1909,8 @@ def degree(self, total=False): EXAMPLES:: - sage: A. = GradedCommutativeAlgebra(GF(2), degrees=((1,0), (0,1), (1,1))) + sage: A. = GradedCommutativeAlgebra(GF(2), + ....: degrees=((1,0), (0,1), (1,1))) sage: (a**2*b).degree() (2, 1) sage: (a**2*b).degree(total=True) @@ -1944,7 +1970,8 @@ class DifferentialGCAlgebra(GCAlgebra): sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3, 3)) sage: A.cdg_algebra({z: x*y}) - Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') in degrees (2, 2, 3, 3) over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') + in degrees (2, 2, 3, 3) over Rational Field with differential: x --> 0 y --> 0 z --> x*y @@ -1954,7 +1981,8 @@ class DifferentialGCAlgebra(GCAlgebra): sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3, 3)) sage: A.cdg_algebra(differential={z: x*y}) - Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') in degrees (2, 2, 3, 3) over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') + in degrees (2, 2, 3, 3) over Rational Field with differential: x --> 0 y --> 0 z --> x*y @@ -2052,13 +2080,17 @@ def cdg_algebra(self, differential): sage: B = A.quotient(A.ideal(x^3-z*t)) sage: C = B.cdg_algebra({y:t}) sage: C - Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') in degrees (2, 3, 2, 4) with relations [x^3 - z*t] over Finite Field of size 5 with differential: + Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') + in degrees (2, 3, 2, 4) with relations [x^3 - z*t] + over Finite Field of size 5 with differential: x --> 0 y --> t z --> 0 t --> 0 sage: C.cdg_algebra({}) - Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') in degrees (2, 3, 2, 4) with relations [x^3 - z*t] over Finite Field of size 5 with differential: + Commutative Differential Graded Algebra with generators ('x', 'y', 'z', 't') + in degrees (2, 3, 2, 4) with relations [x^3 - z*t] + over Finite Field of size 5 with differential: x --> 0 y --> 0 z --> 0 @@ -2168,7 +2200,8 @@ def differential(self, x=None): sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1,1,2)) sage: B = A.cdg_algebra({y:x*y, x: y*x}) sage: d = B.differential(); d - Differential of Commutative Differential Graded Algebra with generators ('x', 'y', 'z') in degrees (1, 1, 2) over Rational Field + Differential of Commutative Differential Graded Algebra + with generators ('x', 'y', 'z') in degrees (1, 1, 2) over Rational Field Defn: x --> -x*y y --> x*y z --> 0 @@ -2281,7 +2314,8 @@ def cohomology(self, n): sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1,1,1,1,1)) sage: B = A.cdg_algebra({d: a*b, e: b*c}) sage: B.cohomology(2) - Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]} over Rational Field + Free module generated by {[a*c], [a*d], [b*d], [c*d - a*e], [b*e], [c*e]} + over Rational Field Compare to :meth:`cohomology_raw`:: @@ -2366,7 +2400,9 @@ def cohomology_generators(self, max_degree): sage: Ds.cohomology_generators(10) {2: [a^2], 4: [b^2]} - sage: Cm. = GradedCommutativeAlgebra(GF(2), degrees=((1,0), (1,1), (0,2), (0,3))) + sage: Cm. = GradedCommutativeAlgebra(GF(2), + ....: degrees=((1,0), (1,1), + ....: (0,2), (0,3))) sage: Dm = Cm.cdg_algebra({a:c, b:d}) sage: Dm.cohomology_generators(10) {2: [a^2], 4: [b^2]} @@ -2459,13 +2495,17 @@ def minimal_model(self, i=3, max_iterations=3, partial_result=False): sage: T = p.domain() sage: p Commutative Differential Graded Algebra morphism: - From: Commutative Differential Graded Algebra with generators ('x1_0', 'x2_0') in degrees (1, 2) over Rational Field with differential: - x1_0 --> 0 - x2_0 --> 0 - To: Commutative Differential Graded Algebra with generators ('x', 'y', 'z') in degrees (1, 1, 2) over Rational Field with differential: - x --> x*y - y --> x*y - z --> 0 + From: Commutative Differential Graded Algebra + with generators ('x1_0', 'x2_0') in degrees (1, 2) + over Rational Field with differential: + x1_0 --> 0 + x2_0 --> 0 + To: Commutative Differential Graded Algebra + with generators ('x', 'y', 'z') in degrees (1, 1, 2) + over Rational Field with differential: + x --> x*y + y --> x*y + z --> 0 Defn: (x1_0, x2_0) --> (x - y, z) sage: R.cohomology(1) Free module generated by {[x - y]} over Rational Field @@ -2488,7 +2528,11 @@ def minimal_model(self, i=3, max_iterations=3, partial_result=False): sage: phi = B.minimal_model(i=3) sage: M = phi.domain() sage: M - Commutative Differential Graded Algebra with generators ('x1_0', 'x1_1', 'x1_2', 'x2_0', 'x2_1', 'x2_2', 'x2_3', 'y3_0', 'y3_1', 'y3_2', 'y3_3', 'y3_4', 'y3_5', 'y3_6', 'y3_7', 'y3_8') in degrees (1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3) over Rational Field with differential: + Commutative Differential Graded Algebra with generators + ('x1_0', 'x1_1', 'x1_2', 'x2_0', 'x2_1', 'x2_2', 'x2_3', + 'y3_0', 'y3_1', 'y3_2', 'y3_3', 'y3_4', 'y3_5', 'y3_6', 'y3_7', 'y3_8') + in degrees (1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3) + over Rational Field with differential: x1_0 --> 0 x1_1 --> 0 x1_2 --> 0 @@ -2508,32 +2552,40 @@ def minimal_model(self, i=3, max_iterations=3, partial_result=False): sage: phi Commutative Differential Graded Algebra morphism: - From: Commutative Differential Graded Algebra with generators ('x1_0', 'x1_1', 'x1_2', 'x2_0', 'x2_1', 'x2_2', 'x2_3', 'y3_0', 'y3_1', 'y3_2', 'y3_3', 'y3_4', 'y3_5', 'y3_6', 'y3_7', 'y3_8') in degrees (1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3) over Rational Field with differential: - x1_0 --> 0 - x1_1 --> 0 - x1_2 --> 0 - x2_0 --> 0 - x2_1 --> 0 - x2_2 --> 0 - x2_3 --> 0 - y3_0 --> x2_0^2 - y3_1 --> x2_0*x2_1 - y3_2 --> x2_1^2 - y3_3 --> x2_0*x2_2 - y3_4 --> x2_1*x2_2 + x2_0*x2_3 - y3_5 --> x2_2^2 - y3_6 --> x2_1*x2_3 - y3_7 --> x2_2*x2_3 - y3_8 --> x2_3^2 - To: Commutative Differential Graded Algebra with generators ('e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7') in degrees (1, 1, 1, 1, 1, 1, 1) over Rational Field with differential: - e1 --> e1*e7 - e2 --> e2*e7 - e3 --> -e3*e7 - e4 --> -e4*e7 - e5 --> 0 - e6 --> 0 - e7 --> 0 - Defn: (x1_0, x1_1, x1_2, x2_0, x2_1, x2_2, x2_3, y3_0, y3_1, y3_2, y3_3, y3_4, y3_5, y3_6, y3_7, y3_8) --> (e5, e6, e7, e1*e3, e2*e3, e1*e4, e2*e4, 0, 0, 0, 0, 0, 0, 0, 0, 0) + From: Commutative Differential Graded Algebra with generators + ('x1_0', 'x1_1', 'x1_2', 'x2_0', 'x2_1', 'x2_2', 'x2_3', + 'y3_0', 'y3_1', 'y3_2', 'y3_3', 'y3_4', 'y3_5', 'y3_6', 'y3_7', 'y3_8') + in degrees (1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3) + over Rational Field with differential: + x1_0 --> 0 + x1_1 --> 0 + x1_2 --> 0 + x2_0 --> 0 + x2_1 --> 0 + x2_2 --> 0 + x2_3 --> 0 + y3_0 --> x2_0^2 + y3_1 --> x2_0*x2_1 + y3_2 --> x2_1^2 + y3_3 --> x2_0*x2_2 + y3_4 --> x2_1*x2_2 + x2_0*x2_3 + y3_5 --> x2_2^2 + y3_6 --> x2_1*x2_3 + y3_7 --> x2_2*x2_3 + y3_8 --> x2_3^2 + To: Commutative Differential Graded Algebra with generators + ('e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7') + in degrees (1, 1, 1, 1, 1, 1, 1) over Rational Field with differential: + e1 --> e1*e7 + e2 --> e2*e7 + e3 --> -e3*e7 + e4 --> -e4*e7 + e5 --> 0 + e6 --> 0 + e7 --> 0 + Defn: (x1_0, x1_1, x1_2, x2_0, x2_1, x2_2, x2_3, + y3_0, y3_1, y3_2, y3_3, y3_4, y3_5, y3_6, y3_7, y3_8) + --> (e5, e6, e7, e1*e3, e2*e3, e1*e4, e2*e4, 0, 0, 0, 0, 0, 0, 0, 0, 0) sage: [B.cohomology(i).dimension() for i in [1..3]] [3, 7, 13] sage: [M.cohomology(i).dimension() for i in [1..3]] @@ -2772,7 +2824,8 @@ def cohomology_algebra(self, max_degree=3): sage: B = A.cdg_algebra(d) sage: M = B.cohomology_algebra() sage: M - Commutative Differential Graded Algebra with generators ('x0', 'x1', 'x2') in degrees (1, 1, 2) over Rational Field with differential: + Commutative Differential Graded Algebra with generators ('x0', 'x1', 'x2') + in degrees (1, 1, 2) over Rational Field with differential: x0 --> 0 x1 --> 0 x2 --> 0 @@ -2843,14 +2896,18 @@ def numerical_invariants(self, max_degree=3, max_iterations=3): sage: B = A.cdg_algebra({e3 : e1*e2}) sage: B.minimal_model(4) Commutative Differential Graded Algebra morphism: - From: Commutative Differential Graded Algebra with generators ('x1_0', 'x1_1', 'y1_0') in degrees (1, 1, 1) over Rational Field with differential: - x1_0 --> 0 - x1_1 --> 0 - y1_0 --> x1_0*x1_1 - To: Commutative Differential Graded Algebra with generators ('e1', 'e2', 'e3') in degrees (1, 1, 1) over Rational Field with differential: - e1 --> 0 - e2 --> 0 - e3 --> e1*e2 + From: Commutative Differential Graded Algebra with + generators ('x1_0', 'x1_1', 'y1_0') in degrees (1, 1, 1) + over Rational Field with differential: + x1_0 --> 0 + x1_1 --> 0 + y1_0 --> x1_0*x1_1 + To: Commutative Differential Graded Algebra with + generators ('e1', 'e2', 'e3') in degrees (1, 1, 1) + over Rational Field with differential: + e1 --> 0 + e2 --> 0 + e3 --> e1*e2 Defn: (x1_0, x1_1, y1_0) --> (e1, e2, e3) sage: B.numerical_invariants(2) {1: [2, 1, 0], 2: [0, 0]} @@ -2908,7 +2965,7 @@ def is_formal(self, i, max_iterations=3): EXAMPLES:: sage: A. = GradedCommutativeAlgebra(QQ) - sage: B = A.cdg_algebra({e5 : e1*e2 + e3*e4}) + sage: B = A.cdg_algebra({e5: e1*e2 + e3*e4}) sage: B.is_formal(1) True sage: B.is_formal(2) @@ -2946,7 +3003,7 @@ def differential(self): EXAMPLES:: - sage: A. = GradedCommutativeAlgebra(QQ, degrees = (2, 2, 3, 4)) + sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3, 4)) sage: B = A.cdg_algebra({t: x*z, x: z, y: z}) sage: B.inject_variables() Defining x, y, z, t @@ -2973,9 +3030,9 @@ def is_coboundary(self): False sage: (x*z).is_coboundary() True - sage: (x*z+x*y).is_coboundary() + sage: (x*z + x*y).is_coboundary() False - sage: (x*z+y**2).is_coboundary() + sage: (x*z + y**2).is_coboundary() Traceback (most recent call last): ... ValueError: this element is not homogeneous @@ -3000,7 +3057,7 @@ def is_cohomologous_to(self, other): EXAMPLES:: sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1,1,1,1)) - sage: B = A.cdg_algebra(differential={a:b*c-c*d}) + sage: B = A.cdg_algebra(differential={a: b*c-c*d}) sage: w, x, y, z = B.gens() sage: (x*y).is_cohomologous_to(y*z) True @@ -3016,7 +3073,7 @@ def is_cohomologous_to(self, other): False sage: (x*y-y*z).is_cohomologous_to(x*y*z) True - sage: (x*y*z).is_cohomologous_to(0) # make sure 0 works + sage: (x*y*z).is_cohomologous_to(0) # make sure 0 works True """ if other.is_zero(): @@ -3036,17 +3093,17 @@ def cohomology_class(self): EXAMPLES:: sage: A. = GradedCommutativeAlgebra(QQ) - sage: B = A.cdg_algebra({e5:e1*e2+e3*e4}) + sage: B = A.cdg_algebra({e5: e1*e2+e3*e4}) sage: B.inject_variables() Defining e1, e2, e3, e4, e5 - sage: a = e1*e3*e5-3*e2*e3*e5 + sage: a = e1*e3*e5 - 3*e2*e3*e5 sage: a.cohomology_class() B[[e1*e3*e5]] - 3*B[[e2*e3*e5]] TESTS:: sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1, 2, 3)) - sage: B = A.cdg_algebra({a:b}) + sage: B = A.cdg_algebra({a: b}) sage: B.inject_variables() Defining a, b, c sage: b.cohomology_class() @@ -3057,10 +3114,10 @@ def cohomology_class(self): Check that the issue detected in :trac:`28155` is solved:: sage: A. = GradedCommutativeAlgebra(QQ) - sage: B = A.cdg_algebra({e5:e1*e2+e3*e4}) + sage: B = A.cdg_algebra({e5: e1*e2+e3*e4}) sage: B.inject_variables() Defining e1, e2, e3, e4, e5 - sage: a = e1*e3*e5-3*e2*e3*e5 + sage: a = e1*e3*e5 - 3*e2*e3*e5 sage: ca = a.cohomology_class() sage: C = B.cohomology(3) sage: ca in C @@ -3087,7 +3144,7 @@ def _cohomology_class_dict(self): EXAMPLES:: sage: A. = GradedCommutativeAlgebra(QQ) - sage: B = A.cdg_algebra({e5:e1*e2+e3*e4}) + sage: B = A.cdg_algebra({e5: e1*e2+e3*e4}) sage: a = B(e1*e3*e5-3*e2*e3*e5) sage: a._cohomology_class_dict() {(0, 0, 0, 0, 0, 0, 1, 0, 0): -3, (0, 0, 0, 0, 0, 1, 0, 0, 0): 1} @@ -3096,7 +3153,7 @@ def _cohomology_class_dict(self): x5 - 3*x6 sage: B.cohomology_generators(3) {1: [e1, e2, e3, e4], - 3: [e1*e2*e5 - e3*e4*e5, e1*e3*e5, e2*e3*e5, e1*e4*e5, e2*e4*e5]} + 3: [e1*e2*e5 - e3*e4*e5, e1*e3*e5, e2*e3*e5, e1*e4*e5, e2*e4*e5]} sage: [H(g._cohomology_class_dict()) for g in flatten(B.cohomology_generators(3).values())] [x0, x1, x2, x3, x4, x5, x6, x7, x8] """ @@ -3380,9 +3437,11 @@ def GradedCommutativeAlgebra(ring, names=None, degrees=None, max_degree=None, Defining a graded commutative algebra:: sage: GradedCommutativeAlgebra(QQ, 'x, y, z') - Graded Commutative Algebra with generators ('x', 'y', 'z') in degrees (1, 1, 1) over Rational Field + Graded Commutative Algebra with generators ('x', 'y', 'z') + in degrees (1, 1, 1) over Rational Field sage: GradedCommutativeAlgebra(QQ, degrees=(2, 3, 4)) - Graded Commutative Algebra with generators ('x0', 'x1', 'x2') in degrees (2, 3, 4) over Rational Field + Graded Commutative Algebra with generators ('x0', 'x1', 'x2') + in degrees (2, 3, 4) over Rational Field As usual in Sage, the ``A.<...>`` notation defines both the algebra and the generator names:: @@ -3390,21 +3449,21 @@ def GradedCommutativeAlgebra(ring, names=None, degrees=None, max_degree=None, sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1, 1, 2)) sage: x^2 0 - sage: y*x # Odd classes anticommute. + sage: y*x # Odd classes anticommute. -x*y - sage: z*y # z is central since it is in degree 2. + sage: z*y # z is central since it is in degree 2. y*z sage: (x*y*z**3).degree() 8 - sage: A.basis(3) # basis of homogeneous degree 3 elements + sage: A.basis(3) # basis of homogeneous degree 3 elements [x*z, y*z] Defining a quotient:: sage: I = A.ideal(x*z) - sage: AQ = A.quotient(I) - sage: AQ - Graded Commutative Algebra with generators ('x', 'y', 'z') in degrees (1, 1, 2) with relations [x*z] over Rational Field + sage: AQ = A.quotient(I); AQ + Graded Commutative Algebra with generators ('x', 'y', 'z') + in degrees (1, 1, 2) with relations [x*z] over Rational Field sage: AQ.basis(3) [y*z] @@ -3421,14 +3480,15 @@ def GradedCommutativeAlgebra(ring, names=None, degrees=None, max_degree=None, Now we add a differential to ``AQ``:: - sage: B = AQ.cdg_algebra({z:y*z}) - sage: B - Commutative Differential Graded Algebra with generators ('x', 'y', 'z') in degrees (1, 1, 2) with relations [x*z] over Rational Field with differential: + sage: B = AQ.cdg_algebra({z: y*z}); B + Commutative Differential Graded Algebra with generators ('x', 'y', 'z') + in degrees (1, 1, 2) with relations [x*z] over Rational Field with differential: x --> 0 y --> 0 z --> y*z sage: B.differential() - Differential of Commutative Differential Graded Algebra with generators ('x', 'y', 'z') in degrees (1, 1, 2) with relations [x*z] over Rational Field + Differential of Commutative Differential Graded Algebra with generators + ('x', 'y', 'z') in degrees (1, 1, 2) with relations [x*z] over Rational Field Defn: x --> 0 y --> 0 z --> y*z @@ -3447,10 +3507,12 @@ def GradedCommutativeAlgebra(ring, names=None, degrees=None, max_degree=None, We can construct multi-graded rings as well. We work in characteristic 2 for a change, so the algebras here are honestly commutative:: - sage: C. = GradedCommutativeAlgebra(GF(2), degrees=((1,0), (1,1), (0,2), (0,3))) - sage: D = C.cdg_algebra(differential={a:c, b:d}) - sage: D - Commutative Differential Graded Algebra with generators ('a', 'b', 'c', 'd') in degrees ((1, 0), (1, 1), (0, 2), (0, 3)) over Finite Field of size 2 with differential: + sage: C. = GradedCommutativeAlgebra(GF(2), + ....: degrees=((1,0), (1,1), (0,2), (0,3))) + sage: D = C.cdg_algebra(differential={a: c, b: d}); D + Commutative Differential Graded Algebra with generators ('a', 'b', 'c', 'd') + in degrees ((1, 0), (1, 1), (0, 2), (0, 3)) over Finite Field of size 2 + with differential: a --> c b --> d c --> 0 @@ -3460,9 +3522,9 @@ def GradedCommutativeAlgebra(ring, names=None, degrees=None, max_degree=None, Use tuples, lists, vectors, or elements of additive abelian groups to specify degrees:: - sage: D.basis(3) # basis in total degree 3 + sage: D.basis(3) # basis in total degree 3 [a^3, a*b, a*c, d] - sage: D.basis((1,2)) # basis in degree (1,2) + sage: D.basis((1,2)) # basis in degree (1,2) [a*c] sage: D.basis([1,2]) [a*c] @@ -3504,8 +3566,7 @@ def GradedCommutativeAlgebra(ring, names=None, degrees=None, max_degree=None, Graded algebra with maximal degree:: - sage: A. = GradedCommutativeAlgebra(QQ, degrees=(4,2), max_degree=6) - sage: A + sage: A. = GradedCommutativeAlgebra(QQ, degrees=(4,2), max_degree=6); A Graded commutative algebra with generators ('p', 'e') in degrees (4, 2) with maximal degree 6 sage: p^2 @@ -3563,7 +3624,8 @@ class GCAlgebraMorphism(RingHomomorphism_im_gens): sage: H = Hom(A,A) sage: f = H([y,x]) sage: f - Graded Commutative Algebra endomorphism of Graded Commutative Algebra with generators ('x', 'y') in degrees (1, 1) over Rational Field + Graded Commutative Algebra endomorphism of Graded Commutative Algebra + with generators ('x', 'y') in degrees (1, 1) over Rational Field Defn: (x, y) --> (y, x) sage: f(x*y) -x*y @@ -3590,7 +3652,8 @@ def __init__(self, parent, im_gens, check=True): sage: H = Hom(A,A) sage: f = H([x,x]) sage: f - Graded Commutative Algebra endomorphism of Graded Commutative Algebra with generators ('x', 'y') in degrees (1, 2) over Rational Field + Graded Commutative Algebra endomorphism of Graded Commutative Algebra + with generators ('x', 'y') in degrees (1, 2) over Rational Field Defn: (x, y) --> (x, x) sage: f.is_graded() False @@ -3608,7 +3671,8 @@ def __init__(self, parent, im_gens, check=True): sage: A2. = GradedCommutativeAlgebra(GF(2), degrees=(1,2)) sage: H2 = Hom(A2,A2) sage: H2([y,y]) - Graded Commutative Algebra endomorphism of Graded Commutative Algebra with generators ('x', 'y') in degrees (1, 2) over Finite Field of size 2 + Graded Commutative Algebra endomorphism of Graded Commutative Algebra + with generators ('x', 'y') in degrees (1, 2) over Finite Field of size 2 Defn: (x, y) --> (y, y) The "nc-relations" `a*b = -b*a`, for `a` and `b` in odd @@ -3652,7 +3716,8 @@ def __init__(self, parent, im_gens, check=True): sage: A.cover_ring() Multivariate Polynomial Ring in e1 over Rational Field sage: A.hom([2*e1]) - Graded Commutative Algebra endomorphism of Graded Commutative Algebra with generators ('e1',) in degrees (1,) over Rational Field + Graded Commutative Algebra endomorphism of Graded Commutative Algebra + with generators ('e1',) in degrees (1,) over Rational Field Defn: (e1,) --> (2*e1,) """ @@ -3834,13 +3899,17 @@ class GCAlgebraHomset(RingHomset_generic): sage: H = Hom(A,B) sage: H([y,0]) Graded Commutative Algebra morphism: - From: Graded Commutative Algebra with generators ('w', 'x') in degrees (1, 2) over Rational Field - To: Graded Commutative Algebra with generators ('y', 'z') in degrees (1, 1) over Rational Field + From: Graded Commutative Algebra with generators ('w', 'x') + in degrees (1, 2) over Rational Field + To: Graded Commutative Algebra with generators ('y', 'z') + in degrees (1, 1) over Rational Field Defn: (w, x) --> (y, 0) sage: H([y,y*z]) Graded Commutative Algebra morphism: - From: Graded Commutative Algebra with generators ('w', 'x') in degrees (1, 2) over Rational Field - To: Graded Commutative Algebra with generators ('y', 'z') in degrees (1, 1) over Rational Field + From: Graded Commutative Algebra with generators ('w', 'x') + in degrees (1, 2) over Rational Field + To: Graded Commutative Algebra with generators ('y', 'z') + in degrees (1, 1) over Rational Field Defn: (w, x) --> (y, y*z) """ @@ -3925,8 +3994,8 @@ class CohomologyClass(SageObject, CachedRepresentation): sage: from sage.algebras.commutative_dga import CohomologyClass sage: CohomologyClass(3) [3] - sage: A. = GradedCommutativeAlgebra(QQ, degrees = (2,2,3,3)) - sage: CohomologyClass(x^2+2*y*z, A) + sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2,2,3,3)) + sage: CohomologyClass(x^2 + 2*y*z, A) [2*y*z + x^2] TESTS: @@ -3978,7 +4047,7 @@ def __init__(self, x, cdga=None): EXAMPLES:: sage: from sage.algebras.commutative_dga import CohomologyClass - sage: CohomologyClass(x-2) + sage: CohomologyClass(x - 2) # needs sage.symbolic [x - 2] """ self._x = x @@ -3989,7 +4058,7 @@ def __hash__(self): TESTS:: sage: from sage.algebras.commutative_dga import CohomologyClass - sage: hash(CohomologyClass(sin)) == hash(sin) + sage: hash(CohomologyClass(sin)) == hash(sin) # needs sage.symbolic True """ return hash(self._x) @@ -3999,7 +4068,7 @@ def _repr_(self): EXAMPLES:: sage: from sage.algebras.commutative_dga import CohomologyClass - sage: CohomologyClass(sin) + sage: CohomologyClass(sin) # needs sage.symbolic [sin] """ return '[{}]'.format(self._x) @@ -4009,9 +4078,9 @@ def _latex_(self): EXAMPLES:: sage: from sage.algebras.commutative_dga import CohomologyClass - sage: latex(CohomologyClass(sin)) + sage: latex(CohomologyClass(sin)) # needs sage.symbolic \left[ \sin \right] - sage: latex(CohomologyClass(x^2)) + sage: latex(CohomologyClass(x^2)) # needs sage.symbolic \left[ x^{2} \right] """ from sage.misc.latex import latex @@ -4024,8 +4093,8 @@ def representative(self): EXAMPLES:: sage: from sage.algebras.commutative_dga import CohomologyClass - sage: x = CohomologyClass(sin) - sage: x.representative() == sin + sage: x = CohomologyClass(sin) # needs sage.symbolic + sage: x.representative() == sin # needs sage.symbolic True """ return self._x @@ -4085,7 +4154,7 @@ def total_degree(deg): INPUT: - - ``deg`` - an element of a free abelian group. + - ``deg`` -- an element of a free abelian group. In fact, ``deg`` could be an integer, a Python int, a list, a tuple, a vector, etc. This function returns the sum of the diff --git a/src/sage/algebras/down_up_algebra.py b/src/sage/algebras/down_up_algebra.py index 3ee1bcea25f..088e7ac30ad 100644 --- a/src/sage/algebras/down_up_algebra.py +++ b/src/sage/algebras/down_up_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Down-Up Algebras @@ -539,12 +540,13 @@ class VermaModule(CombinatorialFreeModule): construction of the irreducible representation `V(5)` (but they are different as `\mathfrak{gl}_2` weights):: - sage: B = crystals.Tableaux(['A',1], shape=[5]) - sage: [b.weight() for b in B] + sage: B = crystals.Tableaux(['A',1], shape=[5]) # needs sage.graphs + sage: [b.weight() for b in B] # needs sage.graphs [(5, 0), (4, 1), (3, 2), (2, 3), (1, 4), (0, 5)] An example with periodic weights (see Theorem 2.13 of [BR1998]_):: + sage: # needs sage.rings.number_field sage: k. = CyclotomicField(6) sage: al = z6 + 1 sage: (al - 1)^6 == 1 diff --git a/src/sage/algebras/exterior_algebra_groebner.pyx b/src/sage/algebras/exterior_algebra_groebner.pyx index 376eb454082..265e9323536 100644 --- a/src/sage/algebras/exterior_algebra_groebner.pyx +++ b/src/sage/algebras/exterior_algebra_groebner.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Exterior algebras Gröbner bases diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py index af2b5e7dd3c..a3b8742b4e0 100644 --- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py +++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py @@ -57,22 +57,28 @@ class FiniteDimensionalAlgebra(UniqueRepresentation, Algebra): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) - sage: A + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]); A Finite-dimensional algebra of degree 2 over Finite Field of size 3 sage: TestSuite(A).run() - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: B Finite-dimensional algebra of degree 3 over Rational Field TESTS:: sage: A.category() - Category of finite dimensional magmatic algebras with basis over Finite Field of size 3 - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])], assume_associative=True) + Category of finite dimensional magmatic algebras with basis + over Finite Field of size 3 + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])], + ....: assume_associative=True) sage: A.category() - Category of finite dimensional associative algebras with basis over Finite Field of size 3 + Category of finite dimensional associative algebras with basis + over Finite Field of size 3 """ @staticmethod def __classcall_private__(cls, k, table, names='e', assume_associative=False, @@ -93,7 +99,8 @@ def __classcall_private__(cls, k, table, names='e', assume_associative=False, sage: from sage.categories.magmatic_algebras import MagmaticAlgebras sage: cat = MagmaticAlgebras(GF(3)).FiniteDimensional().WithBasis() - sage: A1 = FiniteDimensionalAlgebra(GF(3), table, category=cat.Associative()) + sage: A1 = FiniteDimensionalAlgebra(GF(3), table, + ....: category=cat.Associative()) sage: A2 = FiniteDimensionalAlgebra(GF(3), table, assume_associative=True) sage: A1 is A2 True @@ -197,7 +204,8 @@ def _coerce_map_from_(self, S): """ TESTS:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: A.has_coerce_map_from(ZZ) True sage: A.has_coerce_map_from(GF(3)) @@ -224,7 +232,9 @@ def _element_constructor_(self, x): ... TypeError: algebra is not unitary - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: B(17) 17*e0 + 17*e2 """ @@ -243,7 +253,9 @@ def _Hom_(self, B, category): sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) sage: A._Hom_(B, A.category()) - Set of Homomorphisms from Finite-dimensional algebra of degree 1 over Rational Field to Finite-dimensional algebra of degree 2 over Rational Field + Set of Homomorphisms + from Finite-dimensional algebra of degree 1 over Rational Field + to Finite-dimensional algebra of degree 2 over Rational Field """ cat = MagmaticAlgebras(self.base_ring()).FiniteDimensional().WithBasis() if category.is_subcategory(cat): @@ -258,7 +270,8 @@ def ngens(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: A.ngens() 2 """ @@ -273,7 +286,8 @@ def gen(self, i): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: A.gen(0) e0 """ @@ -286,7 +300,8 @@ def basis(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: A.basis() Family (e0, e1) """ @@ -299,7 +314,8 @@ def __iter__(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: list(A) [0, e0, 2*e0, e1, e0 + e1, 2*e0 + e1, 2*e1, e0 + 2*e1, 2*e0 + 2*e1] @@ -319,7 +335,8 @@ def _ideal_class_(self, n=0): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: A._ideal_class_() """ @@ -332,7 +349,8 @@ def table(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: A.table() ( [1 0] [0 1] @@ -349,7 +367,8 @@ def left_table(self): EXAMPLES:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1],[-1,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: T = B.left_table(); T ( [1 0] [ 0 1] @@ -382,8 +401,8 @@ def base_extend(self, F): EXAMPLES:: sage: C = FiniteDimensionalAlgebra(GF(2), [Matrix([1])]) - sage: k. = GF(4) - sage: C.base_extend(k) + sage: k. = GF(4) # needs sage.rings.finite_rings + sage: C.base_extend(k) # needs sage.rings.finite_rings Finite-dimensional algebra of degree 1 over Finite Field in y of size 2^2 """ # Base extension of the multiplication table is done by __classcall_private__. @@ -395,11 +414,13 @@ def cardinality(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(7), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [2, 3]])]) + sage: A = FiniteDimensionalAlgebra(GF(7), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [2, 3]])]) sage: A.cardinality() 49 - sage: B = FiniteDimensionalAlgebra(RR, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [2, 3]])]) + sage: B = FiniteDimensionalAlgebra(RR, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [2, 3]])]) sage: B.cardinality() +Infinity @@ -431,9 +452,11 @@ def ideal(self, gens=None, given_by_matrix=False, side=None): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: A.ideal(A([1,1])) - Ideal (e0 + e1) of Finite-dimensional algebra of degree 2 over Finite Field of size 3 + Ideal (e0 + e1) of + Finite-dimensional algebra of degree 2 over Finite Field of size 3 """ return self._ideal_class_()(self, gens=gens, given_by_matrix=given_by_matrix) @@ -445,11 +468,14 @@ def is_associative(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1],[-1,0]])]) + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: A.is_associative() True - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,1], [0,0,0], [1,0,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,1], [0,0,0], [1,0,0]])]) sage: B.is_associative() False @@ -473,11 +499,15 @@ def is_commutative(self): EXAMPLES:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: B.is_commutative() True - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,1,0], [0,0,1]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,1,0], [0,0,1]])]) sage: C.is_commutative() False """ @@ -495,11 +525,13 @@ def is_finite(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(7), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [2, 3]])]) + sage: A = FiniteDimensionalAlgebra(GF(7), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [2, 3]])]) sage: A.is_finite() True - sage: B = FiniteDimensionalAlgebra(RR, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [2, 3]])]) + sage: B = FiniteDimensionalAlgebra(RR, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [2, 3]])]) sage: B.is_finite() False @@ -526,27 +558,35 @@ def is_unitary(self): sage: A.is_unitary() True - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [-1,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: B.is_unitary() True - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[0,0], [0,0]]), Matrix([[0,0], [0,0]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[0,0], [0,0]]), + ....: Matrix([[0,0], [0,0]])]) sage: C.is_unitary() False - sage: D = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[1,0], [0,1]])]) + sage: D = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[1,0], [0,1]])]) sage: D.is_unitary() False - sage: E = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0],[1,0]]), Matrix([[0,1],[0,1]])]) + sage: E = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0],[1,0]]), + ....: Matrix([[0,1],[0,1]])]) sage: E.is_unitary() False - sage: F = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,1], [0,0,0], [1,0,0]])]) + sage: F = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,1], [0,0,0], [1,0,0]])]) sage: F.is_unitary() True - sage: G = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [1,0,0]])]) + sage: G = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [1,0,0]])]) sage: G.is_unitary() # Unique right identity, but no left identity. False """ @@ -600,21 +640,27 @@ def one(self): sage: A.one() 0 - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [-1,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: B.one() e0 - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[0,0], [0,0]]), Matrix([[0,0], [0,0]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[0,0], [0,0]]), + ....: Matrix([[0,0], [0,0]])]) sage: C.one() Traceback (most recent call last): ... TypeError: algebra is not unitary - sage: D = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,1], [0,0,0], [1,0,0]])]) + sage: D = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,1], [0,0,0], [1,0,0]])]) sage: D.one() e0 - sage: E = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [1,0,0]])]) + sage: E = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,1]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [1,0,0]])]) sage: E.one() Traceback (most recent call last): ... @@ -634,11 +680,14 @@ def random_element(self, *args, **kwargs): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: A.random_element() # random e0 + 2*e1 - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: B.random_element(num_bound=1000) # random 215/981*e0 + 709/953*e1 + 931/264*e2 """ @@ -648,32 +697,39 @@ def _is_valid_homomorphism_(self, other, im_gens, base_map=None): """ TESTS:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) sage: Hom(A, B)(Matrix([[1], [0]])) - Morphism from Finite-dimensional algebra of degree 2 over Rational Field to Finite-dimensional algebra of degree 1 over Rational Field given by matrix + Morphism from Finite-dimensional algebra of degree 2 over Rational Field + to Finite-dimensional algebra of degree 1 over Rational Field given by matrix [1] [0] sage: Hom(B, A)(Matrix([[1, 0]])) - Morphism from Finite-dimensional algebra of degree 1 over Rational Field to Finite-dimensional algebra of degree 2 over Rational Field given by matrix + Morphism from Finite-dimensional algebra of degree 1 over Rational Field + to Finite-dimensional algebra of degree 2 over Rational Field given by matrix [1 0] sage: H = Hom(A, A) sage: H(Matrix.identity(QQ, 2)) - Morphism from Finite-dimensional algebra of degree 2 over Rational Field to Finite-dimensional algebra of degree 2 over Rational Field given by matrix + Morphism from Finite-dimensional algebra of degree 2 over Rational Field + to Finite-dimensional algebra of degree 2 over Rational Field given by matrix [1 0] [0 1] sage: H(Matrix([[1, 0], [0, 0]])) - Morphism from Finite-dimensional algebra of degree 2 over Rational Field to Finite-dimensional algebra of degree 2 over Rational Field given by matrix + Morphism from Finite-dimensional algebra of degree 2 over Rational Field + to Finite-dimensional algebra of degree 2 over Rational Field given by matrix [1 0] [0 0] sage: H(Matrix([[1, 0], [1, 1]])) Traceback (most recent call last): ... - ValueError: relations do not all (canonically) map to 0 under map determined by images of generators + ValueError: relations do not all (canonically) map to 0 + under map determined by images of generators sage: Hom(B, B)(Matrix([[2]])) Traceback (most recent call last): ... - ValueError: relations do not all (canonically) map to 0 under map determined by images of generators + ValueError: relations do not all (canonically) map to 0 + under map determined by images of generators """ assert len(im_gens) == self.degree() @@ -694,7 +750,7 @@ def quotient_map(self, ideal): INPUT: - - ``ideal`` -- a ``FiniteDimensionalAlgebraIdeal`` + - ``ideal`` -- a :class:`FiniteDimensionalAlgebraIdeal` OUTPUT: @@ -703,17 +759,22 @@ def quotient_map(self, ideal): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) - sage: q0 = A.quotient_map(A.zero_ideal()) - sage: q0 - Morphism from Finite-dimensional algebra of degree 2 over Finite Field of size 3 to Finite-dimensional algebra of degree 2 over Finite Field of size 3 given by matrix - [1 0] - [0 1] - sage: q1 = A.quotient_map(A.ideal(A.gen(1))) - sage: q1 - Morphism from Finite-dimensional algebra of degree 2 over Finite Field of size 3 to Finite-dimensional algebra of degree 1 over Finite Field of size 3 given by matrix - [1] - [0] + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) + sage: q0 = A.quotient_map(A.zero_ideal()); q0 + Morphism + from Finite-dimensional algebra of degree 2 over Finite Field of size 3 + to Finite-dimensional algebra of degree 2 over Finite Field of size 3 + given by matrix + [1 0] + [0 1] + sage: q1 = A.quotient_map(A.ideal(A.gen(1))); q1 + Morphism + from Finite-dimensional algebra of degree 2 over Finite Field of size 3 + to Finite-dimensional algebra of degree 1 over Finite Field of size 3 + given by matrix + [1] + [0] """ k = self.base_ring() f = ideal.basis_matrix().transpose().kernel().basis_matrix().echelon_form().transpose() @@ -744,12 +805,16 @@ def maximal_ideal(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) - sage: A.maximal_ideal() - Ideal (0, e1) of Finite-dimensional algebra of degree 2 over Finite Field of size 3 + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) + sage: A.maximal_ideal() # needs sage.rings.finite_rings + Ideal (0, e1) of + Finite-dimensional algebra of degree 2 over Finite Field of size 3 - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) - sage: B.maximal_ideal() + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B.maximal_ideal() # needs sage.libs.pari Traceback (most recent call last): ... ValueError: algebra is not local @@ -783,18 +848,31 @@ def primary_decomposition(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) - sage: A.primary_decomposition() - [Morphism from Finite-dimensional algebra of degree 2 over Finite Field of size 3 to Finite-dimensional algebra of degree 2 over Finite Field of size 3 given by matrix [1 0] - [0 1]] - - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) - sage: B.primary_decomposition() - [Morphism from Finite-dimensional algebra of degree 3 over Rational Field to Finite-dimensional algebra of degree 1 over Rational Field given by matrix [0] - [0] - [1], Morphism from Finite-dimensional algebra of degree 3 over Rational Field to Finite-dimensional algebra of degree 2 over Rational Field given by matrix [1 0] - [0 1] - [0 0]] + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) + sage: A.primary_decomposition() # needs sage.rings.finite_rings + [Morphism + from Finite-dimensional algebra of degree 2 over Finite Field of size 3 + to Finite-dimensional algebra of degree 2 over Finite Field of size 3 + given by matrix [1 0] + [0 1]] + + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B.primary_decomposition() # needs sage.libs.pari + [Morphism + from Finite-dimensional algebra of degree 3 over Rational Field + to Finite-dimensional algebra of degree 1 over Rational Field + given by matrix [0] + [0] + [1], + Morphism + from Finite-dimensional algebra of degree 3 over Rational Field + to Finite-dimensional algebra of degree 2 over Rational Field + given by matrix [1 0] + [0 1] + [0 0]] """ k = self.base_ring() n = self.degree() @@ -838,8 +916,9 @@ def maximal_ideals(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) - sage: A.maximal_ideals() + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) + sage: A.maximal_ideals() # needs sage.rings.finite_rings [Ideal (e1) of Finite-dimensional algebra of degree 2 over Finite Field of size 3] sage: B = FiniteDimensionalAlgebra(QQ, []) diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx index e4901439e19..d58e1ac8647 100644 --- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx +++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx @@ -26,7 +26,9 @@ cpdef FiniteDimensionalAlgebraElement unpickle_FiniteDimensionalAlgebraElement(A TESTS:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[1,1,0], [0,1,1], [0,1,1]]), Matrix([[0,0,1], [0,1,0], [1,0,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[1,1,0], [0,1,1], [0,1,1]]), + ....: Matrix([[0,0,1], [0,1,0], [1,0,0]])]) sage: x = B([1,2,3]) sage: loads(dumps(x)) == x # indirect doctest True @@ -59,7 +61,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: A(17) 2*e0 sage: A([1,1]) @@ -69,13 +72,15 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ TESTS:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: A(QQ(4)) Traceback (most recent call last): ... TypeError: elt should be a vector, a matrix, or an element of the base field - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [-1,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: elt = B(Matrix([[1,1], [-1,1]])); elt e0 + e1 sage: TestSuite(elt).run() @@ -133,7 +138,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ TESTS:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[1,1,0], [0,1,1], [0,1,1]]), Matrix([[0,0,1], [0,1,0], [1,0,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[1,1,0], [0,1,1], [0,1,1]]), + ....: Matrix([[0,0,1], [0,1,0], [1,0,0]])]) sage: x = B([1,2,3]) sage: loads(dumps(x)) == x # indirect doctest True @@ -149,7 +156,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): TESTS:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: x = A.element_class.__new__(A.element_class) sage: x.__setstate__((A, {'_vector':vector([1,1,1]), '_matrix':matrix(QQ,3,[1,1,0, 0,1,0, 0,0,1])})) sage: x @@ -183,7 +192,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ TESTS:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[1,1,0], [0,1,1], [0,1,1]]), Matrix([[0,0,1], [0,1,0], [1,0,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[1,1,0], [0,1,1], [0,1,1]]), + ....: Matrix([[0,0,1], [0,1,0], [1,0,0]])]) sage: x = B([1,2,3]) sage: x._matrix [3 2 3] @@ -205,7 +216,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: B(5).vector() (5, 0, 5) """ @@ -220,7 +233,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: B(5).matrix() [5 0 0] [0 5 0] @@ -240,7 +255,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [-1,0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: elt = B(Matrix([[1,1], [-1,1]])) sage: elt.monomial_coefficients() {0: 1, 1: 1} @@ -254,7 +270,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,1,0], [0,0,1]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,1,0], [0,0,1]])]) sage: C([1,2,0]).left_matrix() [1 0 0] [0 1 0] @@ -272,7 +290,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: A(1) e0 """ @@ -308,7 +327,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: latex(A(1)) # indirect doctest \left(\begin{array}{rr} 1 & 0 \\ @@ -324,7 +344,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: A([2,1/4,3])[2] 3 """ @@ -334,7 +356,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: len(A([2,1/4,3])) 3 """ @@ -345,7 +369,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: A(2) == 2 True sage: A(2) == 3 @@ -353,7 +378,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): sage: A(2) == GF(5)(2) False - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: B(1) != 0 True @@ -377,7 +404,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: A.basis()[0] + A.basis()[1] e0 + e1 """ @@ -387,7 +415,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: A.basis()[0] - A.basis()[1] e0 + 2*e1 """ @@ -397,7 +426,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ EXAMPLES:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,1,0], [0,0,1]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,1,0], [0,0,1]])]) sage: C.basis()[1] * C.basis()[2] e1 """ @@ -407,7 +438,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ TESTS:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,1,0], [0,0,1]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,1,0], [0,0,1]])]) sage: c = C.random_element() sage: c * 2 == c + c True @@ -421,7 +454,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ TESTS:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,1,0], [0,0,1]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,1,0], [0,0,1]])]) sage: c = C.random_element() sage: 2 * c == c + c True @@ -438,7 +473,9 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) sage: b = B([2,3,4]) sage: b^6 64*e0 + 576*e1 + 4096*e2 @@ -459,7 +496,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): """ TESTS:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [-1,0]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: x = C([1,2]) sage: y = ~x; y # indirect doctest 1/5*e0 - 2/5*e1 @@ -486,7 +524,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [-1,0]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: C([1,2]).is_invertible() True sage: C(0).is_invertible() @@ -505,7 +544,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [-1,0]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: C([1,2])._inverse 1/5*e0 - 2/5*e1 sage: C(0)._inverse is None @@ -543,7 +583,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [-1,0]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [-1,0]])]) sage: C([1,2]).inverse() 1/5*e0 - 2/5*e1 """ @@ -561,7 +602,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: C([1,0]).is_zerodivisor() False sage: C([0,1]).is_zerodivisor() @@ -575,7 +617,8 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), Matrix([[0,1], [0,0]])]) + sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0], [0,1]]), + ....: Matrix([[0,1], [0,0]])]) sage: C([1,0]).is_nilpotent() False sage: C([0,1]).is_nilpotent() @@ -596,13 +639,15 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) - sage: B(0).minimal_polynomial() + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B(0).minimal_polynomial() # needs sage.libs.pari x sage: b = B.random_element() - sage: f = b.minimal_polynomial(); f # random + sage: f = b.minimal_polynomial(); f # random # needs sage.libs.pari x^3 + 1/2*x^2 - 7/16*x + 1/16 - sage: f(b) == 0 + sage: f(b) == 0 # needs sage.libs.pari True """ A = self.parent() @@ -625,13 +670,15 @@ cdef class FiniteDimensionalAlgebraElement(AlgebraElement): EXAMPLES:: - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])]) - sage: B(0).characteristic_polynomial() + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), + ....: Matrix([[0,1,0], [0,0,0], [0,0,0]]), + ....: Matrix([[0,0,0], [0,0,0], [0,0,1]])]) + sage: B(0).characteristic_polynomial() # needs sage.libs.pari x^3 sage: b = B.random_element() - sage: f = b.characteristic_polynomial(); f # random + sage: f = b.characteristic_polynomial(); f # random # needs sage.libs.pari x^3 - 8*x^2 + 16*x - sage: f(b) == 0 + sage: f(b) == 0 # needs sage.libs.pari True """ return self.matrix().characteristic_polynomial() diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_ideal.py b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_ideal.py index 54f137e1966..15f0881bb8b 100644 --- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_ideal.py +++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_ideal.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings (because all doctests use GF) """ Ideals of Finite Algebras """ diff --git a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py index 22f12ce6bb5..d2114511ae6 100644 --- a/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py +++ b/src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py @@ -41,7 +41,8 @@ class FiniteDimensionalAlgebraMorphism(RingHomomorphism_im_gens): EXAMPLES:: sage: from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphism import FiniteDimensionalAlgebraMorphism - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) sage: H = Hom(A, B) sage: f = H(Matrix([[1], [0]])) @@ -62,7 +63,8 @@ def __init__(self, parent, f, check=True, unitary=True): sage: from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphism import FiniteDimensionalAlgebraMorphism sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: H = Hom(A, B) sage: phi = FiniteDimensionalAlgebraMorphism(H, Matrix([[1, 0]])) sage: TestSuite(phi).run(skip="_test_category") @@ -82,10 +84,11 @@ def _repr_(self): r""" TESTS:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) - sage: I = A.maximal_ideal() - sage: q = A.quotient_map(I) - sage: q._repr_() + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) + sage: I = A.maximal_ideal() # needs sage.libs.pari + sage: q = A.quotient_map(I) # needs sage.libs.pari + sage: q._repr_() # needs sage.libs.pari 'Morphism from Finite-dimensional algebra of degree 2 over Rational Field to Finite-dimensional algebra of degree 1 over Rational Field given by matrix\n[1]\n[0]' """ return "Morphism from {} to {} given by matrix\n{}".format( @@ -95,10 +98,11 @@ def __call__(self, x): """ TESTS:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) - sage: I = A.maximal_ideal() - sage: q = A.quotient_map(I) - sage: q(0) == 0 and q(1) == 1 + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) + sage: I = A.maximal_ideal() # needs sage.libs.pari + sage: q = A.quotient_map(I) # needs sage.libs.pari + sage: q(0) == 0 and q(1) == 1 # needs sage.libs.pari True """ x = self.domain()(x) @@ -112,7 +116,8 @@ def __eq__(self, other): TESTS:: sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: H = Hom(A, B) sage: phi = H(Matrix([[1, 0]])) sage: psi = H(Matrix([[1, 0]])) @@ -132,7 +137,8 @@ def __ne__(self, other): TESTS:: sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: H = Hom(A, B) sage: phi = H(Matrix([[1, 0]])) sage: psi = H(Matrix([[1, 0]])) @@ -149,7 +155,8 @@ def matrix(self): EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) sage: M = Matrix([[1], [0]]) sage: H = Hom(A, B) @@ -169,15 +176,16 @@ def inverse_image(self, I): OUTPUT: - -- ``FiniteDimensionalAlgebraIdeal``, the inverse image of `I` under ``self``. + :class:`FiniteDimensionalAlgebraIdeal`, the inverse image of `I` under ``self``. EXAMPLES:: - sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) - sage: I = A.maximal_ideal() - sage: q = A.quotient_map(I) - sage: B = q.codomain() - sage: q.inverse_image(B.zero_ideal()) == I + sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) + sage: I = A.maximal_ideal() # needs sage.libs.pari + sage: q = A.quotient_map(I) # needs sage.libs.pari + sage: B = q.codomain() # needs sage.libs.pari + sage: q.inverse_image(B.zero_ideal()) == I # needs sage.libs.pari True """ coker_I = I.basis_matrix().transpose().kernel().basis_matrix().transpose() @@ -195,7 +203,8 @@ def zero(self): EXAMPLES:: sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: H = Hom(A, B) sage: H.zero() Morphism from Finite-dimensional algebra of degree 1 over Rational Field to @@ -218,7 +227,8 @@ def __call__(self, f, check=True, unitary=True): EXAMPLES:: sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) - sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) + sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), + ....: Matrix([[0, 1], [0, 0]])]) sage: H = Hom(A, B) sage: H(Matrix([[1, 0]])) Morphism from Finite-dimensional algebra of degree 1 over Rational Field to diff --git a/src/sage/algebras/finite_gca.py b/src/sage/algebras/finite_gca.py index 5f21cdc8290..cb6c29e358d 100644 --- a/src/sage/algebras/finite_gca.py +++ b/src/sage/algebras/finite_gca.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Finite dimensional graded commutative algebras @@ -89,14 +90,15 @@ class FiniteGCAlgebra(CombinatorialFreeModule, Algebra): sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1,2,2,3), max_degree=6) sage: A - Graded commutative algebra with generators ('x', 'y', 'z', 't') in degrees (1, 2, 2, 3) with maximal degree 6 + Graded commutative algebra with generators ('x', 'y', 'z', 't') + in degrees (1, 2, 2, 3) with maximal degree 6 sage: t*x + x*t 0 sage: x^2 0 sage: x*t^2 0 - sage: x*y^2+z*t + sage: x*y^2 + z*t x*y^2 + z*t The generators can be returned with :meth:`algebra_generators`:: @@ -114,7 +116,9 @@ class FiniteGCAlgebra(CombinatorialFreeModule, Algebra): Depending on the context, the multiplication can be given a different symbol:: - sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1,2,6,6), max_degree=10, mul_symbol='⌣', mul_latex_symbol=r'\smile') + sage: A. = GradedCommutativeAlgebra(QQ, degrees=(1,2,6,6), max_degree=10, + ....: mul_symbol='⌣', + ....: mul_latex_symbol=r'\smile') sage: x*y^2 + x*t x⌣y^2 + x⌣t sage: latex(x*y^2 - z*x) diff --git a/src/sage/algebras/free_algebra.py b/src/sage/algebras/free_algebra.py index 50793075532..d375a68c0ae 100644 --- a/src/sage/algebras/free_algebra.py +++ b/src/sage/algebras/free_algebra.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat sage.modules """ Free algebras @@ -17,11 +17,12 @@ EXAMPLES:: - sage: F = FreeAlgebra(ZZ,3,'x,y,z') + sage: F = FreeAlgebra(ZZ, 3, 'x,y,z') sage: F.base_ring() Integer Ring sage: G = FreeAlgebra(F, 2, 'm,n'); G - Free Algebra on 2 generators (m, n) over Free Algebra on 3 generators (x, y, z) over Integer Ring + Free Algebra on 2 generators (m, n) over + Free Algebra on 3 generators (x, y, z) over Integer Ring sage: G.base_ring() Free Algebra on 3 generators (x, y, z) over Integer Ring @@ -34,8 +35,8 @@ Moreover, we can compute Groebner bases with degree bound for its two-sided ideals, and thus provide ideal containment tests:: - sage: F. = FreeAlgebra(QQ, implementation='letterplace') - sage: F + sage: # needs sage.libs.singular + sage: F. = FreeAlgebra(QQ, implementation='letterplace'); F Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F sage: I.groebner_basis(degbound=4) @@ -54,6 +55,7 @@ Positive integral degree weights for the letterplace implementation was introduced in :trac:`7797`:: + sage: # needs sage.libs.singular sage: F. = FreeAlgebra(QQ, implementation='letterplace', degrees=[2,1,3]) sage: x.degree() 2 @@ -73,6 +75,8 @@ sage: TestSuite(F).run() sage: F is loads(dumps(F)) True + + sage: # needs sage.libs.singular sage: F = FreeAlgebra(GF(5),3,'x', implementation='letterplace') sage: TestSuite(F).run() sage: F is loads(dumps(F)) @@ -84,6 +88,8 @@ sage: TestSuite(F).run() sage: F is loads(dumps(F)) True + + sage: # needs sage.libs.singular sage: F. = FreeAlgebra(GF(5),3, implementation='letterplace') sage: TestSuite(F).run() sage: F is loads(dumps(F)) @@ -95,6 +101,8 @@ sage: TestSuite(F).run() sage: F is loads(dumps(F)) True + + sage: # needs sage.libs.singular sage: F = FreeAlgebra(GF(5),3, ['xx', 'zba', 'Y'], implementation='letterplace') sage: TestSuite(F).run() sage: F is loads(dumps(F)) @@ -106,6 +114,8 @@ sage: TestSuite(F).run() sage: F is loads(dumps(F)) True + + sage: # needs sage.libs.singular sage: F = FreeAlgebra(GF(5),3, 'abc', implementation='letterplace') sage: TestSuite(F).run() sage: F is loads(dumps(F)) @@ -121,10 +131,11 @@ Note that the letterplace implementation can only be used if the corresponding (multivariate) polynomial ring has an implementation in Singular:: - sage: FreeAlgebra(FreeAlgebra(ZZ,2,'ab'), 2, 'x', implementation='letterplace') + sage: FreeAlgebra(FreeAlgebra(ZZ,2,'ab'), 2, 'x', implementation='letterplace') # needs sage.libs.singular Traceback (most recent call last): ... - NotImplementedError: polynomials over Free Algebra on 2 generators (a, b) over Integer Ring are not supported in Singular + NotImplementedError: polynomials over Free Algebra on 2 generators (a, b) + over Integer Ring are not supported in Singular """ # *************************************************************************** @@ -149,6 +160,7 @@ from sage.structure.factory import UniqueFactory from sage.misc.cachefunc import cached_method +from sage.misc.lazy_import import lazy_import from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.ring import Algebra from sage.categories.algebras_with_basis import AlgebrasWithBasis @@ -156,6 +168,8 @@ from sage.combinat.words.word import Word from sage.structure.category_object import normalize_names +lazy_import('sage.algebras.letterplace.free_algebra_letterplace', 'FreeAlgebra_letterplace') + class FreeAlgebraFactory(UniqueFactory): """ @@ -179,7 +193,8 @@ class FreeAlgebraFactory(UniqueFactory): sage: FreeAlgebra(GF(5),1, ['alpha']) Free Algebra on 1 generators (alpha,) over Finite Field of size 5 sage: FreeAlgebra(FreeAlgebra(ZZ,1,'a'), 2, 'x') - Free Algebra on 2 generators (x0, x1) over Free Algebra on 1 generators (a,) over Integer Ring + Free Algebra on 2 generators (x0, x1) over + Free Algebra on 1 generators (a,) over Integer Ring Free algebras are globally unique:: @@ -203,6 +218,7 @@ class FreeAlgebraFactory(UniqueFactory): elements are supported. Of course, isomorphic algebras in different implementations are not identical:: + sage: # needs sage.libs.singular sage: G = FreeAlgebra(GF(5),['x','y','z'], implementation='letterplace') sage: F == G False @@ -214,10 +230,13 @@ class FreeAlgebraFactory(UniqueFactory): :: - sage: H = FreeAlgebra(GF(5),['x','y','z'], implementation='letterplace', degrees=[1,2,3]) + sage: # needs sage.libs.singular + sage: H = FreeAlgebra(GF(5), ['x','y','z'], implementation='letterplace', + ....: degrees=[1,2,3]) sage: F != H != G True - sage: H is FreeAlgebra(GF(5),['x','y','z'], implementation='letterplace', degrees=[1,2,3]) + sage: H is FreeAlgebra(GF(5),['x','y','z'], implementation='letterplace', + ....: degrees=[1,2,3]) True sage: copy(H) is H is loads(dumps(H)) True @@ -235,7 +254,8 @@ class FreeAlgebraFactory(UniqueFactory): sage: s = a*b^2 * c^3; s a*b^2*c^3 sage: parent(s) - Free Algebra on 1 generators (c,) over Free Algebra on 2 generators (a, b) over Rational Field + Free Algebra on 1 generators (c,) over + Free Algebra on 2 generators (a, b) over Rational Field sage: c^3 * a * b^2 a*b^2*c^3 """ @@ -254,13 +274,19 @@ def create_key(self, base_ring, arg1=None, arg2=None, (Finite Field of size 5, ('x', 'y', 'z')) sage: FreeAlgebra.create_key(GF(5),3,'xyz') (Finite Field of size 5, ('x', 'y', 'z')) - sage: FreeAlgebra.create_key(GF(5),['x','y','z'], implementation='letterplace') + + sage: # needs sage.libs.singular + sage: FreeAlgebra.create_key(GF(5),['x','y','z'], + ....: implementation='letterplace') (Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,) - sage: FreeAlgebra.create_key(GF(5),['x','y','z'],3, implementation='letterplace') + sage: FreeAlgebra.create_key(GF(5),['x','y','z'],3, + ....: implementation='letterplace') (Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,) - sage: FreeAlgebra.create_key(GF(5),3,'xyz', implementation='letterplace') + sage: FreeAlgebra.create_key(GF(5),3,'xyz', + ....: implementation='letterplace') (Multivariate Polynomial Ring in x, y, z over Finite Field of size 5,) - sage: FreeAlgebra.create_key(GF(5),3,'xyz', implementation='letterplace', degrees=[1,2,3]) + sage: FreeAlgebra.create_key(GF(5),3,'xyz', + ....: implementation='letterplace', degrees=[1,2,3]) ((1, 2, 3), Multivariate Polynomial Ring in x, y, z, x_ over Finite Field of size 5) """ @@ -349,10 +375,10 @@ def is_FreeAlgebra(x) -> bool: True sage: is_FreeAlgebra(FreeAlgebra(ZZ,10,'x',implementation='letterplace')) True - sage: is_FreeAlgebra(FreeAlgebra(ZZ,10,'x',implementation='letterplace', degrees=list(range(1,11)))) + sage: is_FreeAlgebra(FreeAlgebra(ZZ,10,'x',implementation='letterplace', + ....: degrees=list(range(1,11)))) True """ - from sage.algebras.letterplace.free_algebra_letterplace import FreeAlgebra_letterplace return isinstance(x, (FreeAlgebra_generic, FreeAlgebra_letterplace)) @@ -542,6 +568,7 @@ def _element_constructor_(self, x): TESTS:: + sage: # needs sage.libs.singular sage: F. = FreeAlgebra(GF(5),3) sage: L. = FreeAlgebra(ZZ,3,implementation='letterplace') sage: F(x) # indirect doctest @@ -553,10 +580,11 @@ def _element_constructor_(self, x): :: + sage: # needs sage.libs.singular sage.rings.finite_rings sage: K. = GF(25) sage: F. = FreeAlgebra(K,3) sage: L. = FreeAlgebra(K,3, implementation='letterplace') - sage: F.1+(z+1)*L.2 + sage: F.1 + (z+1)*L.2 b + (z+1)*c Check that :trac:`15169` is fixed:: @@ -667,6 +695,7 @@ def _coerce_map_from_(self, R): sage: F.has_coerce_map_from(PolynomialRing(ZZ, 3, 'x,y,z')) False + sage: # needs sage.rings.finite_rings sage: K. = GF(25) sage: F. = FreeAlgebra(K,3) sage: F._coerce_map_from_(ZZ) @@ -682,8 +711,8 @@ def _coerce_map_from_(self, R): True sage: G._coerce_map_from_(F) False - sage: L. = FreeAlgebra(K,3, implementation='letterplace') - sage: F.1 + (z+1) * L.2 + sage: L. = FreeAlgebra(K,3, implementation='letterplace') # needs sage.libs.singular + sage: F.1 + (z+1) * L.2 # needs sage.libs.singular b + (z+1)*c """ if self._indices.has_coerce_map_from(R): @@ -780,9 +809,12 @@ def quotient(self, mons, mats=None, names=None, **args): sage: i, j, k = F.gens() sage: mons = [ F(1), i, j, k ] sage: M = MatrixSpace(QQ,4) - sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]), M([0,0,0,1, 0,0,-1,0, 0,1,0,0, -1,0,0,0]) ] + sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), + ....: M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]), + ....: M([0,0,0,1, 0,0,-1,0, 0,1,0,0, -1,0,0,0]) ] sage: H. = A.quotient(mons, mats); H - Free algebra quotient on 3 generators ('i', 'j', 'k') and dimension 4 over Rational Field + Free algebra quotient on 3 generators ('i', 'j', 'k') and dimension 4 + over Rational Field """ if mats is None: return super().quotient(mons, names) @@ -830,6 +862,7 @@ def g_algebra(self, relations, names=None, order='degrevlex', check=True): EXAMPLES:: + sage: # needs sage.libs.singular sage: A. = FreeAlgebra(QQ,3) sage: G = A.g_algebra({y*x: -x*y}) sage: (x,y,z) = G.gens() @@ -840,12 +873,12 @@ def g_algebra(self, relations, names=None, order='degrevlex', check=True): sage: z*x x*z sage: (x,y,z) = A.gens() - sage: G = A.g_algebra({y*x: -x*y+1}) + sage: G = A.g_algebra({y*x: -x*y + 1}) sage: (x,y,z) = G.gens() sage: y*x -x*y + 1 sage: (x,y,z) = A.gens() - sage: G = A.g_algebra({y*x: -x*y+z}) + sage: G = A.g_algebra({y*x: -x*y + z}) sage: (x,y,z) = G.gens() sage: y*x -x*y + z diff --git a/src/sage/algebras/free_algebra_element.py b/src/sage/algebras/free_algebra_element.py index 559df673fbf..1854414e2d0 100644 --- a/src/sage/algebras/free_algebra_element.py +++ b/src/sage/algebras/free_algebra_element.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat sage.modules """ Free algebra elements diff --git a/src/sage/algebras/free_algebra_quotient.py b/src/sage/algebras/free_algebra_quotient.py index b19884335c4..e41e9c877c5 100644 --- a/src/sage/algebras/free_algebra_quotient.py +++ b/src/sage/algebras/free_algebra_quotient.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Finite dimensional free algebra quotients @@ -21,11 +22,12 @@ sage: A = FreeAlgebra(QQ,n,'x') sage: F = A.monoid() sage: i, j = F.gens() - sage: mons = [ F(1), i, j, i*j ] + sage: mons = [F(1), i, j, i*j] sage: r = len(mons) sage: M = MatrixSpace(QQ,r) - sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]) ] - sage: H2. = A.quotient(mons,mats) + sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), + ....: M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]) ] + sage: H2. = A.quotient(mons, mats) sage: H2 == loads(dumps(H2)) True sage: i == loads(dumps(i)) @@ -106,15 +108,20 @@ def __init__(self, A, mons, mats, names): sage: A = FreeAlgebra(QQ,n,'i') sage: F = A.monoid() sage: i, j, k = F.gens() - sage: mons = [ F(1), i, j, k ] + sage: mons = [F(1), i, j, k] sage: M = MatrixSpace(QQ,4) - sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]), M([0,0,0,1, 0,0,-1,0, 0,1,0,0, -1,0,0,0]) ] + sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), + ....: M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]), + ....: M([0,0,0,1, 0,0,-1,0, 0,1,0,0, -1,0,0,0]) ] sage: H3. = FreeAlgebraQuotient(A,mons,mats) sage: x = 1 + i + j + k sage: x 1 + i + j + k sage: x**128 - -170141183460469231731687303715884105728 + 170141183460469231731687303715884105728*i + 170141183460469231731687303715884105728*j + 170141183460469231731687303715884105728*k + -170141183460469231731687303715884105728 + + 170141183460469231731687303715884105728*i + + 170141183460469231731687303715884105728*j + + 170141183460469231731687303715884105728*k Same algebra defined in terms of two generators, with some penalty on already slow arithmetic. @@ -128,14 +135,18 @@ def __init__(self, A, mons, mats, names): sage: mons = [ F(1), i, j, i*j ] sage: r = len(mons) sage: M = MatrixSpace(QQ,r) - sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]) ] + sage: mats = [M([0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0]), + ....: M([0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]) ] sage: H2. = A.quotient(mons,mats) sage: k = i*j sage: x = 1 + i + j + k sage: x 1 + i + j + i*j sage: x**128 - -170141183460469231731687303715884105728 + 170141183460469231731687303715884105728*i + 170141183460469231731687303715884105728*j + 170141183460469231731687303715884105728*i*j + -170141183460469231731687303715884105728 + + 170141183460469231731687303715884105728*i + + 170141183460469231731687303715884105728*j + + 170141183460469231731687303715884105728*i*j TESTS:: @@ -345,7 +356,8 @@ def hamilton_quatalg(R): sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(ZZ) sage: H - Free algebra quotient on 3 generators ('i', 'j', 'k') and dimension 4 over Integer Ring + Free algebra quotient on 3 generators ('i', 'j', 'k') and dimension 4 + over Integer Ring sage: i^2 -1 sage: i in H diff --git a/src/sage/algebras/free_algebra_quotient_element.py b/src/sage/algebras/free_algebra_quotient_element.py index c841a9210cf..559d4246ac0 100644 --- a/src/sage/algebras/free_algebra_quotient_element.py +++ b/src/sage/algebras/free_algebra_quotient_element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Free algebra quotient elements diff --git a/src/sage/algebras/free_zinbiel_algebra.py b/src/sage/algebras/free_zinbiel_algebra.py index 39ac9091618..d421b2d7aee 100644 --- a/src/sage/algebras/free_zinbiel_algebra.py +++ b/src/sage/algebras/free_zinbiel_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Free Zinbiel Algebras diff --git a/src/sage/algebras/group_algebra.py b/src/sage/algebras/group_algebra.py index e16b0c08a21..eaffe7538b7 100644 --- a/src/sage/algebras/group_algebra.py +++ b/src/sage/algebras/group_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.groups sage.modules r""" Group algebras diff --git a/src/sage/algebras/hall_algebra.py b/src/sage/algebras/hall_algebra.py index 3492ba5e073..83442eabc94 100644 --- a/src/sage/algebras/hall_algebra.py +++ b/src/sage/algebras/hall_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Hall Algebras diff --git a/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py b/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py index cf1c7a04c39..f34beb5a1f8 100644 --- a/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py +++ b/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat sage.modules r""" Ariki-Koike Algebras @@ -234,6 +234,7 @@ class ArikiKoikeAlgebra(Parent, UniqueRepresentation): We construct an Ariki-Koike algebra with `u = (1, \zeta_3, \zeta_3^2)`, where `\zeta_3` is a primitive third root of unity:: + sage: # needs sage.rings.number_field sage: F = CyclotomicField(3) sage: zeta3 = F.gen() sage: R. = LaurentPolynomialRing(F) @@ -248,6 +249,7 @@ class ArikiKoikeAlgebra(Parent, UniqueRepresentation): Next, we additionally take `q = 1` to obtain the group algebra of `G(r, 1, n)`:: + sage: # needs sage.rings.number_field sage: F = CyclotomicField(3) sage: zeta3 = F.gen() sage: H = algebras.ArikiKoike(3, 4, q=1, u=[1, zeta3, zeta3^2], R=F) diff --git a/src/sage/algebras/hecke_algebras/cubic_hecke_algebra.py b/src/sage/algebras/hecke_algebras/cubic_hecke_algebra.py index fdc94b13907..6a336d9932c 100644 --- a/src/sage/algebras/hecke_algebras/cubic_hecke_algebra.py +++ b/src/sage/algebras/hecke_algebras/cubic_hecke_algebra.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat sage.groups sage.modules r""" Cubic Hecke Algebras @@ -93,14 +93,15 @@ initializing. However, you can do calculations inside the infinite algebra as well:: - sage: CHA6 = algebras.CubicHecke(6) # optional - database_cubic_hecke - sage: CHA6.inject_variables() # optional - database_cubic_hecke + sage: # optional - database_cubic_hecke + sage: CHA6 = algebras.CubicHecke(6) + sage: CHA6.inject_variables() Defining c0, c1, c2, c3, c4 - sage: s = c0*c1*c2*c3*c4; s # optional - database_cubic_hecke + sage: s = c0*c1*c2*c3*c4; s c0*c1*c2*c3*c4 - sage: s^2 # optional - database_cubic_hecke + sage: s^2 (c0*c1*c2*c3*c4)^2 - sage: t = CHA6.an_element() * c4; t # optional - database_cubic_hecke + sage: t = CHA6.an_element() * c4; t (-w)*c0*c1^-1*c4 + v*c0*c2^-1*c4 + u*c2*c1*c4 + ((-v*w+u)/w)*c4 REFERENCES: @@ -1833,18 +1834,19 @@ def _init_basis_extension(self): EXAMPLES:: - sage: CHA5 = algebras.CubicHecke(5) # optional - database_cubic_hecke # indirect doctest - sage: fc = CHA5._filecache # optional - database_cubic_hecke - sage: be = fc.section.basis_extensions # optional - database_cubic_hecke - sage: CHA5.reset_filecache(be) # optional - database_cubic_hecke - sage: fc.read(be) # optional - database_cubic_hecke + sage: # optional - database_cubic_hecke + sage: CHA5 = algebras.CubicHecke(5) + sage: fc = CHA5._filecache + sage: be = fc.section.basis_extensions + sage: CHA5.reset_filecache(be) + sage: fc.read(be) [[4], [-4]] - sage: ele = CHA5.an_element() # optional - database_cubic_hecke - sage: CHA5.inject_variables() # optional - database_cubic_hecke + sage: ele = CHA5.an_element() + sage: CHA5.inject_variables() Defining c0, c1, c2, c3 - sage: ele2 = ele * c3 # optional - database_cubic_hecke - sage: bex = fc.read(be) # optional - database_cubic_hecke - sage: bex.sort(); bex # optional - database_cubic_hecke + sage: ele2 = ele * c3 + sage: bex = fc.read(be) + sage: bex.sort(); bex [[-4], [1, -3, 4], [1, -2, 4], [3, 2, 4], [4]] """ self._basis_extension = [] @@ -2220,14 +2222,15 @@ def _braid_image_by_basis_extension(self, braid_tietze): EXAMPLES:: - sage: CHA5 = algebras.CubicHecke(5) # optional - database_cubic_hecke - sage: be = CHA5.filecache_section().basis_extensions # optional - database_cubic_hecke - sage: CHA5.reset_filecache(be) # optional - database_cubic_hecke - sage: CHA5._basis_extension # optional - database_cubic_hecke + sage: # optional - database_cubic_hecke + sage: CHA5 = algebras.CubicHecke(5) + sage: be = CHA5.filecache_section().basis_extensions + sage: CHA5.reset_filecache(be) + sage: CHA5._basis_extension [[4], [-4]] - sage: CHA5._braid_image_by_basis_extension((4,1)) # optional - database_cubic_hecke + sage: CHA5._braid_image_by_basis_extension((4,1)) c3*c0 - sage: CHA5._basis_extension # optional - database_cubic_hecke + sage: CHA5._basis_extension [[4], [-4], [4, 1]] case where the braid already has an corresponding basis element:: @@ -2524,15 +2527,16 @@ def _cubic_braid_append_to_basis(self, cubic_braid): EXAMPLES:: - sage: CHA5 = algebras.CubicHecke(5) # optional - database_cubic_hecke - sage: be = CHA5.filecache_section().basis_extensions # optional - database_cubic_hecke - sage: CHA5.reset_filecache(be) # optional - database_cubic_hecke - sage: CHA5._basis_extension # optional - database_cubic_hecke + sage: # optional - database_cubic_hecke + sage: CHA5 = algebras.CubicHecke(5) + sage: be = CHA5.filecache_section().basis_extensions + sage: CHA5.reset_filecache(be) + sage: CHA5._basis_extension [[4], [-4]] - sage: CBG = CHA5.cubic_braid_group() # optional - database_cubic_hecke - sage: CHA5._cubic_braid_append_to_basis(CBG((4,1))) # optional - database_cubic_hecke + sage: CBG = CHA5.cubic_braid_group() + sage: CHA5._cubic_braid_append_to_basis(CBG((4,1))) c3*c0 - sage: CHA5._basis_extension # optional - database_cubic_hecke + sage: CHA5._basis_extension [[4], [-4], [4, 1]] """ @@ -2807,12 +2811,13 @@ def reset_filecache(self, section=None, commit=True): EXAMPLES:: - sage: CHA5 = algebras.CubicHecke(5) # optional - database_cubic_hecke - sage: be = CHA5.filecache_section().basis_extensions # optional - database_cubic_hecke - sage: CHA5.is_filecache_empty(be) # optional - database_cubic_hecke + sage: # optional - database_cubic_hecke + sage: CHA5 = algebras.CubicHecke(5) + sage: be = CHA5.filecache_section().basis_extensions + sage: CHA5.is_filecache_empty(be) False - sage: CHA5.reset_filecache(be) # optional - database_cubic_hecke - sage: CHA5.is_filecache_empty(be) # optional - database_cubic_hecke + sage: CHA5.reset_filecache(be) + sage: CHA5.is_filecache_empty(be) True """ fc = self._filecache diff --git a/src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py b/src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py index 7c2fe4a2210..90d6657d309 100644 --- a/src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py +++ b/src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari (for factorization) r""" Cubic Hecke Base Rings @@ -297,14 +298,15 @@ def _element_constructor_(self, x, mon=None): EXAMPLES:: - sage: CHA3 = algebras.CubicHecke(3) # optional gap3 - sage: GER = CHA3.extension_ring(generic=True) # optional gap3 - sage: sch7 = CHA3.chevie().SchurElements()[7] # optional gap3 - sage: GER(sch7) # optional gap3 + sage: # optional - gap3 + sage: CHA3 = algebras.CubicHecke(3) + sage: GER = CHA3.extension_ring(generic=True) + sage: sch7 = CHA3.chevie().SchurElements()[7] + sage: GER(sch7) a*b*c^-2 + a^2*b^-1*c^-1 + a^-1*b^2*c^-1 + 2 + a*b^-2*c + a^-2*b*c + a^-1*b^-1*c^2 - sage: rep4_gap3 = CHA3.chevie().Representations(4) # optional gap3 - sage: matrix(GER, rep4_gap3[1]) # optional gap3 + sage: rep4_gap3 = CHA3.chevie().Representations(4) + sage: matrix(GER, rep4_gap3[1]) [ b 0] [-b c] """ diff --git a/src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py b/src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py index 1e8cd3ae0c4..02689e2b11c 100644 --- a/src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py +++ b/src/sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.modules r""" Cubic Hecke matrix representations diff --git a/src/sage/algebras/iwahori_hecke_algebra.py b/src/sage/algebras/iwahori_hecke_algebra.py index 0b6696af043..a599c28a488 100644 --- a/src/sage/algebras/iwahori_hecke_algebra.py +++ b/src/sage/algebras/iwahori_hecke_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs sage.modules r""" Iwahori-Hecke Algebras @@ -51,15 +52,15 @@ def normalized_laurent_polynomial(R, p): the base ring. This function is a hack to recover from this. This occurs somewhat haphazardly with Laurent polynomial rings:: - sage: R.=LaurentPolynomialRing(ZZ) + sage: R. = LaurentPolynomialRing(ZZ) sage: [type(c) for c in (q**-1).coefficients()] [] It also happens in any ring when dividing by units:: - sage: type ( 3/1 ) + sage: type(3/1) - sage: type ( -1/-1 ) + sage: type(-1/-1) This function is a variation on a suggested workaround of Nils Bruin. @@ -67,19 +68,19 @@ def normalized_laurent_polynomial(R, p): EXAMPLES:: sage: from sage.algebras.iwahori_hecke_algebra import normalized_laurent_polynomial - sage: type ( normalized_laurent_polynomial(ZZ, 3/1) ) + sage: type(normalized_laurent_polynomial(ZZ, 3/1)) - sage: R.=LaurentPolynomialRing(ZZ) + sage: R. = LaurentPolynomialRing(ZZ) sage: [type(c) for c in normalized_laurent_polynomial(R, q**-1).coefficients()] [] - sage: R.=LaurentPolynomialRing(ZZ,2) - sage: p=normalized_laurent_polynomial(R, 2*u**-1*v**-1+u*v) - sage: ui=normalized_laurent_polynomial(R, u^-1) - sage: vi=normalized_laurent_polynomial(R, v^-1) - sage: p(ui,vi) + sage: R. = LaurentPolynomialRing(ZZ,2) + sage: p = normalized_laurent_polynomial(R, 2*u**-1*v**-1 + u*v) + sage: ui = normalized_laurent_polynomial(R, u^-1) + sage: vi = normalized_laurent_polynomial(R, v^-1) + sage: p(ui, vi) 2*u*v + u^-1*v^-1 - sage: q= u+v+ui - sage: q(ui,vi) + sage: q = u+v+ui + sage: q(ui, vi) u + v^-1 + u^-1 """ try: @@ -207,8 +208,8 @@ class IwahoriHeckeAlgebra(Parent, UniqueRepresentation): The Kazhdan-Lusztig bases are implemented inside `H` whenever `-q_1 q_2` has a square root:: - sage: H = IwahoriHeckeAlgebra('A3', u^2,-v^2) - sage: T=H.T(); Cp= H.Cp(); C=H.C() + sage: H = IwahoriHeckeAlgebra('A3', u^2, -v^2) + sage: T = H.T(); Cp = H.Cp(); C = H.C() sage: T(Cp[1]) (u^-1*v^-1)*T[1] + (u^-1*v) sage: T(C[1]) @@ -1954,12 +1955,13 @@ class Cp(_KLHeckeBasis): implemented with ``coxeter3`` to avoid unnecessary conversions, as in the following example with the same product computed in the last one:: - sage: R = LaurentPolynomialRing(QQ, 'v') # optional - coxeter3 - sage: v = R.gen(0) # optional - coxeter3 - sage: W = CoxeterGroup('A9', implementation='coxeter3') # optional - coxeter3 - sage: H = IwahoriHeckeAlgebra(W, v**2) # optional - coxeter3 - sage: Cp = H.Cp() # optional - coxeter3 - sage: Cp[1,2,1,8,9,8]*Cp[1,2,3,7,8,9] # optional - coxeter3 + sage: # optional - coxeter3 + sage: R = LaurentPolynomialRing(QQ, 'v') + sage: v = R.gen(0) + sage: W = CoxeterGroup('A9', implementation='coxeter3') + sage: H = IwahoriHeckeAlgebra(W, v**2) + sage: Cp = H.Cp() + sage: Cp[1,2,1,8,9,8]*Cp[1,2,3,7,8,9] (v^-2+2+v^2)*Cp[1,2,1,3,7,8,7,9,8,7] + (v^-2+2+v^2)*Cp[1,2,1,3,8,9,8,7] + (v^-3+3*v^-1+3*v+v^3)*Cp[1,2,1,3,8,9,8] @@ -1983,17 +1985,18 @@ def __init__(self, IHAlgebra, prefix=None): r""" TESTS:: - sage: R. = LaurentPolynomialRing(QQ) # optional - coxeter3 - sage: W = CoxeterGroup('A3', implementation='coxeter3') # optional - coxeter3 - sage: H = IwahoriHeckeAlgebra(W, v**2) # optional - coxeter3 - sage: Cp = H.Cp() # optional - coxeter3 - sage: Cp._delta == v + ~v # optional - coxeter3 + sage: # optional - coxeter3 + sage: R. = LaurentPolynomialRing(QQ) + sage: W = CoxeterGroup('A3', implementation='coxeter3') + sage: H = IwahoriHeckeAlgebra(W, v**2) + sage: Cp = H.Cp() + sage: Cp._delta == v + ~v True - sage: Cp._W_Coxeter3 == H._W # optional - coxeter3 + sage: Cp._W_Coxeter3 == H._W True - sage: H = IwahoriHeckeAlgebra(W, QQ(1)) # optional - coxeter3 - sage: Cp = H.Cp() # optional - coxeter3 - sage: Cp._W_Coxeter3 is None # optional - coxeter3 + sage: H = IwahoriHeckeAlgebra(W, QQ(1)) + sage: Cp = H.Cp() + sage: Cp._W_Coxeter3 is None True """ super().__init__(IHAlgebra, prefix) @@ -2127,12 +2130,13 @@ def product_on_basis(self, w1, w2): EXAMPLES:: - sage: R. = LaurentPolynomialRing(ZZ, 'v') # optional - coxeter3 - sage: W = CoxeterGroup('A3', implementation='coxeter3') # optional - coxeter3 - sage: H = IwahoriHeckeAlgebra(W, v**2); Cp=H.Cp() # optional - coxeter3 - sage: Cp.product_on_basis(W([1,2,1]), W([3,1])) # optional - coxeter3 + sage: # optional - coxeter3 + sage: R. = LaurentPolynomialRing(ZZ, 'v') + sage: W = CoxeterGroup('A3', implementation='coxeter3') + sage: H = IwahoriHeckeAlgebra(W, v**2); Cp=H.Cp() + sage: Cp.product_on_basis(W([1,2,1]), W([3,1])) (v^-1+v)*Cp[1,2,1,3] - sage: Cp.product_on_basis(W([1,2,1]), W([3,1,2])) # optional - coxeter3 + sage: Cp.product_on_basis(W([1,2,1]), W([3,1,2])) (v^-1+v)*Cp[1,2,1,3,2] + (v^-1+v)*Cp[1,2,1] """ if self._W_Coxeter3 is None: @@ -2194,14 +2198,15 @@ def _product_with_generator_on_basis(self, s, w, side='left'): EXAMPLES:: - sage: R. = LaurentPolynomialRing(ZZ, 'v') # optional - coxeter3 - sage: W = CoxeterGroup('A3', implementation='coxeter3') # optional - coxeter3 - sage: H = IwahoriHeckeAlgebra(W, v**2); Cp = H.Cp() # optional - coxeter3 - sage: Cp._product_with_generator_on_basis(1, W([2,1]), 'left') # optional - coxeter3 + sage: # optional - coxeter3 + sage: R. = LaurentPolynomialRing(ZZ, 'v') + sage: W = CoxeterGroup('A3', implementation='coxeter3') + sage: H = IwahoriHeckeAlgebra(W, v**2); Cp = H.Cp() + sage: Cp._product_with_generator_on_basis(1, W([2,1]), 'left') Cp[1,2,1] + Cp[1] - sage: Cp._product_with_generator_on_basis(1, W([2,1]), 'right') # optional - coxeter3 + sage: Cp._product_with_generator_on_basis(1, W([2,1]), 'right') (v^-1+v)*Cp[2,1] - sage: Cp._product_with_generator_on_basis(2, W([1,3,2,1,3]), 'right') # optional - coxeter3 + sage: Cp._product_with_generator_on_basis(2, W([1,3,2,1,3]), 'right') Cp[1,2,1,3,2,1] + Cp[1,2,3,2] + Cp[1,3,2,1] """ # use the product formula described in the class' documentation @@ -2236,12 +2241,13 @@ def _product_with_generator(self, s, x, side='left'): EXAMPLES:: - sage: R. = LaurentPolynomialRing(ZZ, 'v') # optional - coxeter3 - sage: W = CoxeterGroup('A3', implementation='coxeter3') # optional - coxeter3 - sage: H = IwahoriHeckeAlgebra(W, v**2); Cp = H.Cp() # optional - coxeter3 - sage: Cp._product_with_generator(1, Cp[1]+Cp[2], 'left') # optional - coxeter3 + sage: # optional - coxeter3 + sage: R. = LaurentPolynomialRing(ZZ, 'v') + sage: W = CoxeterGroup('A3', implementation='coxeter3') + sage: H = IwahoriHeckeAlgebra(W, v**2); Cp = H.Cp() + sage: Cp._product_with_generator(1, Cp[1]+Cp[2], 'left') Cp[1,2] + (v^-1+v)*Cp[1] - sage: Cp._product_with_generator(1, Cp[1]+Cp[2], 'right') # optional - coxeter3 + sage: Cp._product_with_generator(1, Cp[1]+Cp[2], 'right') Cp[2,1] + (v^-1+v)*Cp[1] """ return self.linear_combination((self._product_with_generator_on_basis(s, w, side), coeff) for (w, coeff) in x) diff --git a/src/sage/algebras/jordan_algebra.py b/src/sage/algebras/jordan_algebra.py index 81c40105f8a..f783dc890c8 100644 --- a/src/sage/algebras/jordan_algebra.py +++ b/src/sage/algebras/jordan_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Jordan Algebras diff --git a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx index ed9680a0af5..f221fe6ab55 100644 --- a/src/sage/algebras/lie_algebras/lie_algebra_element.pyx +++ b/src/sage/algebras/lie_algebras/lie_algebra_element.pyx @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat """ Lie Algebra Elements diff --git a/src/sage/algebras/lie_algebras/morphism.py b/src/sage/algebras/lie_algebras/morphism.py index f71001ce98f..3fa39f8ff78 100644 --- a/src/sage/algebras/lie_algebras/morphism.py +++ b/src/sage/algebras/lie_algebras/morphism.py @@ -461,8 +461,8 @@ class LieAlgebraMorphism_from_generators(LieAlgebraHomomorphism_im_gens): A quotient type Lie algebra morphism:: - sage: K. = LieAlgebra(SR, abelian=True) - sage: L.morphism({X: A, Y: B}) + sage: K. = LieAlgebra(SR, abelian=True) # needs sage.symbolic + sage: L.morphism({X: A, Y: B}) # needs sage.symbolic Lie algebra morphism: From: Lie algebra on 4 generators (X, Y, Z, W) over Rational Field To: Abelian Lie algebra on 2 generators (A, B) over Symbolic Ring @@ -623,17 +623,17 @@ def _call_(self, x): EXAMPLES:: sage: L. = LieAlgebra(QQ, {('X','Y'): {'Z':1}, ('X','Z'): {'W':1}}) - sage: K. = LieAlgebra(SR, abelian=True) - sage: phi = L.morphism({X: A, Y: B}) - sage: phi(X) + sage: K. = LieAlgebra(SR, abelian=True) # needs sage.symbolic + sage: phi = L.morphism({X: A, Y: B}) # needs sage.symbolic + sage: phi(X) # needs sage.symbolic A - sage: phi(Y) + sage: phi(Y) # needs sage.symbolic B - sage: phi(Z) + sage: phi(Z) # needs sage.symbolic 0 - sage: phi(W) + sage: phi(W) # needs sage.symbolic 0 - sage: phi(-X + 3*Y) + sage: phi(-X + 3*Y) # needs sage.symbolic -A + 3*B sage: K. = LieAlgebra(QQ, {('A','B'): {'C':2}}) diff --git a/src/sage/algebras/lie_algebras/quotient.py b/src/sage/algebras/lie_algebras/quotient.py index 7fe6b29677f..ed64e6ee279 100644 --- a/src/sage/algebras/lie_algebras/quotient.py +++ b/src/sage/algebras/lie_algebras/quotient.py @@ -242,6 +242,7 @@ def __init__(self, I, L, names, index_set, category=None): TESTS:: + sage: # needs sage.symbolic sage: L. = LieAlgebra(SR, {('x','y'): {'x':1}}) sage: K = L.quotient(y) sage: K.dimension() diff --git a/src/sage/algebras/lie_algebras/structure_coefficients.py b/src/sage/algebras/lie_algebras/structure_coefficients.py index 16c2cf51029..ed200875e32 100644 --- a/src/sage/algebras/lie_algebras/structure_coefficients.py +++ b/src/sage/algebras/lie_algebras/structure_coefficients.py @@ -411,8 +411,8 @@ def change_ring(self, R): sage: LQQ = L.change_ring(QQ) sage: LQQ.structure_coefficients() Finite family {('x', 'y'): z} - sage: LSR = LQQ.change_ring(SR) - sage: LSR.structure_coefficients() + sage: LSR = LQQ.change_ring(SR) # needs sage.symbolic + sage: LSR.structure_coefficients() # needs sage.symbolic Finite family {('x', 'y'): z} """ return LieAlgebraWithStructureCoefficients( diff --git a/src/sage/algebras/lie_algebras/subalgebra.py b/src/sage/algebras/lie_algebras/subalgebra.py index 90779eb91fc..7dc6e8ef37e 100644 --- a/src/sage/algebras/lie_algebras/subalgebra.py +++ b/src/sage/algebras/lie_algebras/subalgebra.py @@ -75,6 +75,7 @@ class LieSubalgebra_finite_dimensional_with_basis(Parent, UniqueRepresentation): Elements of the ambient Lie algebra can be reduced modulo an ideal or subalgebra:: + sage: # needs sage.symbolic sage: L. = LieAlgebra(SR, {('X','Y'): {'Z': 1}}) sage: I = L.ideal(Y) sage: I.reduce(X + 2*Y + 3*Z) @@ -87,6 +88,7 @@ class LieSubalgebra_finite_dimensional_with_basis(Parent, UniqueRepresentation): When the base ring is a field, the complementary subspace is spanned by those basis elements which are not leading supports of the basis:: + sage: # needs sage.symbolic sage: I = L.ideal(X + Y) sage: I.basis() Family (X + Y, Z) @@ -97,10 +99,10 @@ class LieSubalgebra_finite_dimensional_with_basis(Parent, UniqueRepresentation): Giving a different ``order`` may change the reduction of elements:: - sage: I = L.ideal(X + Y, order=lambda s: ['Z','Y','X'].index(s)) - sage: I.basis() + sage: I = L.ideal(X + Y, order=lambda s: ['Z','Y','X'].index(s)) # needs sage.symbolic + sage: I.basis() # needs sage.symbolic Family (Z, X + Y) - sage: I.reduce(el) + sage: I.reduce(el) # needs sage.symbolic (-x+y)*Y A subalgebra of a subalgebra is a subalgebra of the original:: diff --git a/src/sage/algebras/lie_conformal_algebras/abelian_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/abelian_lie_conformal_algebra.py index aa8b71901e1..80df46c57d3 100644 --- a/src/sage/algebras/lie_conformal_algebras/abelian_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/abelian_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Abelian Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py index 9fdf888fe39..f5d39cacbf2 100644 --- a/src/sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Affine Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/bosonic_ghosts_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/bosonic_ghosts_lie_conformal_algebra.py index 178493b13e8..0b0b61b4e25 100644 --- a/src/sage/algebras/lie_conformal_algebras/bosonic_ghosts_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/bosonic_ghosts_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Bosonic Ghosts Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/fermionic_ghosts_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/fermionic_ghosts_lie_conformal_algebra.py index e6bca4de671..098644908e6 100644 --- a/src/sage/algebras/lie_conformal_algebras/fermionic_ghosts_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/fermionic_ghosts_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Fermionic Ghosts Super Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py b/src/sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py index 9077ef8f6a2..8aefdd9d3a6 100644 --- a/src/sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py +++ b/src/sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Finitely and Freely Generated Lie Conformal Algebras. diff --git a/src/sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py index 53952f38c91..0787226252d 100644 --- a/src/sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Free Bosons Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py index 8cc6533b781..1e7525ae1d3 100644 --- a/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Free Fermions Super Lie Conformal Algebra. diff --git a/src/sage/algebras/lie_conformal_algebras/freely_generated_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/freely_generated_lie_conformal_algebra.py index 8fa5460d29a..b26d0bb4ca0 100644 --- a/src/sage/algebras/lie_conformal_algebras/freely_generated_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/freely_generated_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Freely Generated Lie Conformal Algebras diff --git a/src/sage/algebras/lie_conformal_algebras/graded_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/graded_lie_conformal_algebra.py index 35863aece41..c335daf98f7 100644 --- a/src/sage/algebras/lie_conformal_algebras/graded_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/graded_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Graded Lie Conformal Algebras diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py index 1007488e165..5ca0c8f6d07 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py index 723ae5c385a..09fb63a0a4c 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Lie Conformal Algebra Element diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_basis.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_basis.py index ae4882dbad0..4fef0fcf2e6 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_basis.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_basis.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Lie Conformal Algebras With Basis diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py index 7581daf0ddb..3c4252ce905 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Lie Conformal Algebras With Structure Coefficients diff --git a/src/sage/algebras/lie_conformal_algebras/n2_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/n2_lie_conformal_algebra.py index 045bfb6e57a..baf7a896144 100644 --- a/src/sage/algebras/lie_conformal_algebras/n2_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/n2_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules sage.rings.number_field r""" N=2 Super Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/neveu_schwarz_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/neveu_schwarz_lie_conformal_algebra.py index 8f5756f993f..5542b9fc097 100644 --- a/src/sage/algebras/lie_conformal_algebras/neveu_schwarz_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/neveu_schwarz_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Neveu-Schwarz Super Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/virasoro_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/virasoro_lie_conformal_algebra.py index cc11ec06a0a..0db2d545290 100644 --- a/src/sage/algebras/lie_conformal_algebras/virasoro_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/virasoro_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Virasoro Lie Conformal Algebra diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py index 343ee8a66f9..3c319db7ca3 100644 --- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Weyl Lie Conformal Algebra diff --git a/src/sage/algebras/nil_coxeter_algebra.py b/src/sage/algebras/nil_coxeter_algebra.py index 862fdc3b97e..b5dbd2d62c8 100644 --- a/src/sage/algebras/nil_coxeter_algebra.py +++ b/src/sage/algebras/nil_coxeter_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Nil-Coxeter Algebra """ diff --git a/src/sage/algebras/octonion_algebra.pyx b/src/sage/algebras/octonion_algebra.pyx index aef4f54aa9d..ee69aca6a7e 100644 --- a/src/sage/algebras/octonion_algebra.pyx +++ b/src/sage/algebras/octonion_algebra.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules """ Octonion Algebras @@ -415,7 +416,7 @@ cdef class Octonion_generic(AlgebraElement): sage: O = OctonionAlgebra(QQ, 1, 3, 7) sage: elt = sum(i * b for i, b in enumerate(O.basis(), start=2)) - sage: elt.norm() + sage: elt.norm() # needs sage.symbolic 2*sqrt(-61) sage: elt = sum(O.basis()) sage: elt.norm() @@ -438,7 +439,7 @@ cdef class Octonion_generic(AlgebraElement): sage: O = OctonionAlgebra(QQ, 1, 3, 7) sage: elt = sum(i * b for i, b in enumerate(O.basis(), start=2)) - sage: elt.abs() + sage: elt.abs() # needs sage.symbolic 2*sqrt(-61) sage: elt = sum(O.basis()) sage: elt.abs() @@ -576,10 +577,10 @@ cdef class Octonion(Octonion_generic): sage: O = OctonionAlgebra(QQ) sage: elt = sum(i * b for i, b in enumerate(O.basis(), start=2)) - sage: elt.norm() + sage: elt.norm() # needs sage.symbolic 2*sqrt(71) sage: elt = sum(O.basis()) - sage: elt.norm() + sage: elt.norm() # needs sage.symbolic 2*sqrt(2) """ return self.vec.norm() @@ -750,7 +751,7 @@ class OctonionAlgebra(UniqueRepresentation, Parent): EXAMPLES:: sage: O = OctonionAlgebra(QQ) - sage: TestSuite(O).run() + sage: TestSuite(O).run() # needs sage.symbolic sage: O = OctonionAlgebra(QQ, 1, 3, 7) sage: TestSuite(O).run() diff --git a/src/sage/algebras/orlik_solomon.py b/src/sage/algebras/orlik_solomon.py index 920056787c6..76ed00aa855 100644 --- a/src/sage/algebras/orlik_solomon.py +++ b/src/sage/algebras/orlik_solomon.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Orlik-Solomon Algebras """ @@ -114,9 +115,10 @@ def __init__(self, R, M, ordering=None): We check on the matroid associated to the graph with 3 vertices and 2 edges between each vertex:: + sage: # needs sage.graphs sage: G = Graph([[1,2],[1,2],[2,3],[2,3],[1,3],[1,3]], multiedges=True) - sage: M = Matroid(G) - sage: OS = M.orlik_solomon_algebra(QQ) + sage: MG = Matroid(G) + sage: OS = MG.orlik_solomon_algebra(QQ) sage: elts = OS.some_elements() + list(OS.algebra_generators()) sage: TestSuite(OS).run(elements=elts) """ @@ -253,10 +255,11 @@ def product_on_basis(self, a, b): Let us check that `e_{s_1} e_{s_2} \cdots e_{s_k} = e_S` for any subset `S = \{ s_1 < s_2 < \cdots < s_k \}` of the ground set:: + sage: # needs sage.graphs sage: G = Graph([[1,2],[1,2],[2,3],[3,4],[4,2]], multiedges=True) - sage: M = Matroid(G).regular_matroid() - sage: E = M.groundset_list() - sage: OS = M.orlik_solomon_algebra(ZZ) + sage: MG = Matroid(G).regular_matroid() + sage: E = MG.groundset_list() + sage: OS = MG.orlik_solomon_algebra(ZZ) sage: G = OS.algebra_generators() sage: import itertools sage: def test_prod(F): @@ -326,31 +329,33 @@ def subset_image(self, S): ([2, 5], -OS{0, 2} + OS{0, 5}) ([4, 5], -OS{3, 4} + OS{3, 5}) + sage: # needs sage.graphs sage: M4 = matroids.CompleteGraphic(4) - sage: OS = M4.orlik_solomon_algebra(QQ) - sage: OS.subset_image(frozenset({2,3,4})) + sage: OSM4 = M4.orlik_solomon_algebra(QQ) + sage: OSM4.subset_image(frozenset({2,3,4})) OS{0, 2, 3} + OS{0, 3, 4} An example of a custom ordering:: + sage: # needs sage.graphs sage: G = Graph([[3, 4], [4, 1], [1, 2], [2, 3], [3, 5], [5, 6], [6, 3]]) - sage: M = Matroid(G) + sage: MG = Matroid(G) sage: s = [(5, 6), (1, 2), (3, 5), (2, 3), (1, 4), (3, 6), (3, 4)] - sage: sorted([sorted(c) for c in M.circuits()]) + sage: sorted([sorted(c) for c in MG.circuits()]) [[(1, 2), (1, 4), (2, 3), (3, 4)], [(3, 5), (3, 6), (5, 6)]] - sage: OS = M.orlik_solomon_algebra(QQ, ordering=s) - sage: OS.subset_image(frozenset([])) + sage: OSMG = MG.orlik_solomon_algebra(QQ, ordering=s) + sage: OSMG.subset_image(frozenset([])) OS{} - sage: OS.subset_image(frozenset([(1,2),(3,4),(1,4),(2,3)])) + sage: OSMG.subset_image(frozenset([(1,2),(3,4),(1,4),(2,3)])) 0 - sage: OS.subset_image(frozenset([(2,3),(1,2),(3,4)])) + sage: OSMG.subset_image(frozenset([(2,3),(1,2),(3,4)])) OS{(1, 2), (2, 3), (3, 4)} - sage: OS.subset_image(frozenset([(1,4),(3,4),(2,3),(3,6),(5,6)])) + sage: OSMG.subset_image(frozenset([(1,4),(3,4),(2,3),(3,6),(5,6)])) -OS{(1, 2), (1, 4), (2, 3), (3, 6), (5, 6)} + OS{(1, 2), (1, 4), (3, 4), (3, 6), (5, 6)} - OS{(1, 2), (2, 3), (3, 4), (3, 6), (5, 6)} - sage: OS.subset_image(frozenset([(1,4),(3,4),(2,3),(3,6),(3,5)])) + sage: OSMG.subset_image(frozenset([(1,4),(3,4),(2,3),(3,6),(3,5)])) OS{(1, 2), (1, 4), (2, 3), (3, 5), (5, 6)} - OS{(1, 2), (1, 4), (2, 3), (3, 6), (5, 6)} + OS{(1, 2), (1, 4), (3, 4), (3, 5), (5, 6)} @@ -360,34 +365,36 @@ def subset_image(self, S): TESTS:: + sage: # needs sage.graphs sage: G = Graph([[1,2],[1,2],[2,3],[2,3],[1,3],[1,3]], multiedges=True) - sage: M = Matroid(G) - sage: sorted([sorted(c) for c in M.circuits()]) + sage: MG = Matroid(G) + sage: sorted([sorted(c) for c in MG.circuits()]) [[0, 1], [0, 2, 4], [0, 2, 5], [0, 3, 4], [0, 3, 5], [1, 2, 4], [1, 2, 5], [1, 3, 4], [1, 3, 5], [2, 3], [4, 5]] - sage: OS = M.orlik_solomon_algebra(QQ) - sage: OS.subset_image(frozenset([])) + sage: OSMG = MG.orlik_solomon_algebra(QQ) + sage: OSMG.subset_image(frozenset([])) OS{} - sage: OS.subset_image(frozenset([1, 2, 3])) + sage: OSMG.subset_image(frozenset([1, 2, 3])) 0 - sage: OS.subset_image(frozenset([1, 3, 5])) + sage: OSMG.subset_image(frozenset([1, 3, 5])) 0 - sage: OS.subset_image(frozenset([1, 2])) + sage: OSMG.subset_image(frozenset([1, 2])) OS{0, 2} - sage: OS.subset_image(frozenset([3, 4])) + sage: OSMG.subset_image(frozenset([3, 4])) -OS{0, 2} + OS{0, 4} - sage: OS.subset_image(frozenset([1, 5])) + sage: OSMG.subset_image(frozenset([1, 5])) OS{0, 4} + sage: # needs sage.graphs sage: G = Graph([[1,2],[1,2],[2,3],[3,4],[4,2]], multiedges=True) - sage: M = Matroid(G) - sage: sorted([sorted(c) for c in M.circuits()]) + sage: MG = Matroid(G) + sage: sorted([sorted(c) for c in MG.circuits()]) [[0, 1], [2, 3, 4]] - sage: OS = M.orlik_solomon_algebra(QQ) - sage: OS.subset_image(frozenset([])) + sage: OSMG = MG.orlik_solomon_algebra(QQ) + sage: OSMG.subset_image(frozenset([])) OS{} - sage: OS.subset_image(frozenset([1, 3, 4])) + sage: OSMG.subset_image(frozenset([1, 3, 4])) -OS{0, 2, 3} + OS{0, 2, 4} We check on a non-standard ordering:: @@ -452,6 +459,7 @@ def as_gca(self): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage.graphs sage: H = hyperplane_arrangements.braid(3) sage: O = H.orlik_solomon_algebra(QQ) sage: O.as_gca() @@ -462,7 +470,7 @@ def as_gca(self): sage: N = matroids.named_matroids.Fano() sage: O = N.orlik_solomon_algebra(QQ) - sage: O.as_gca() + sage: O.as_gca() # needs sage.libs.singular Graded Commutative Algebra with generators ('e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6') in degrees (1, 1, 1, 1, 1, 1, 1) with relations [e1*e2 - e1*e3 + e2*e3, e0*e1*e3 - e0*e1*e4 + e0*e3*e4 - e1*e3*e4, @@ -476,6 +484,7 @@ def as_gca(self): TESTS:: + sage: # needs sage.geometry.polyhedron sage: H = hyperplane_arrangements.Catalan(3,QQ).cone() sage: O = H.orlik_solomon_algebra(QQ) sage: A = O.as_gca() @@ -515,6 +524,7 @@ def as_cdga(self): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage.graphs sage: H = hyperplane_arrangements.braid(3) sage: O = H.orlik_solomon_algebra(QQ) sage: O.as_cdga() @@ -545,10 +555,11 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): Lets start with the action of `S_3` on the rank `2` braid matroid:: + sage: # needs sage.graphs sage: M = matroids.CompleteGraphic(3) sage: M.groundset() frozenset({0, 1, 2}) - sage: G = SymmetricGroup(3) + sage: G = SymmetricGroup(3) # needs sage.groups Calling elements ``g`` of ``G`` on an element `i` of `\{1, 2, 3\}` defines the action we want, but since the groundset is `\{0, 1, 2\}` @@ -560,6 +571,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): Now that we have defined an action we can create the invariant, and get its basis:: + sage: # needs sage.graphs sage.groups sage: OSG = M.orlik_solomon_algebra(QQ, invariant=(G, on_groundset)) sage: OSG.basis() Finite family {0: B[0], 1: B[1]} @@ -568,6 +580,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): Since it is invariant, the action of any ``g`` in ``G`` is trivial:: + sage: # needs sage.graphs sage.groups sage: x = OSG.an_element(); x 2*B[0] + 2*B[1] sage: g = G.an_element(); g @@ -575,6 +588,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): sage: g * x 2*B[0] + 2*B[1] + sage: # needs sage.graphs sage.groups sage: x = OSG.random_element() sage: g = G.random_element() sage: g * x == x @@ -583,7 +597,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): The underlying ambient module is the Orlik-Solomon algebra, which is accessible via :meth:`ambient()`:: - sage: M.orlik_solomon_algebra(QQ) is OSG.ambient() + sage: M.orlik_solomon_algebra(QQ) is OSG.ambient() # needs sage.graphs sage.groups True There is not much structure here, so lets look at a bigger example. @@ -591,6 +605,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): easier, we'll start the indexing at `1` so that the `S_6` action on the groundset is simply calling `g`:: + sage: # needs sage.graphs sage.groups sage: M = matroids.CompleteGraphic(4); M.groundset() frozenset({0, 1, 2, 3, 4, 5}) sage: new_bases = [frozenset(i+1 for i in j) for j in M.bases()] @@ -610,6 +625,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): Next, we look at the same matroid but with an `S_3 \times S_3` action (here realized as a Young subgroup of `S_6`):: + sage: # needs sage.graphs sage.groups sage: H = G.young_subgroup([3, 3]) sage: OSH = M.orlik_solomon_algebra(QQ, invariant=H) sage: OSH.basis() @@ -619,6 +635,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): We implement an `S_4` action on the vertices:: + sage: # needs sage.graphs sage.groups sage: M = matroids.CompleteGraphic(4) sage: G = SymmetricGroup(4) sage: edge_map = {i: M.groundset_to_edges([i])[0][:2] @@ -634,6 +651,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): We use this to describe the Young subgroup `S_2 \times S_2` action:: + sage: # needs sage.graphs sage.groups sage: H = G.young_subgroup([2,2]) sage: OSH = M.orlik_solomon_algebra(QQ, invariant=(H, vert_action)) sage: B = OSH.basis() @@ -645,7 +663,7 @@ class OrlikSolomonInvariantAlgebra(FiniteDimensionalInvariantModule): We demonstrate the algebra structure:: - sage: matrix([[b*bp for b in B] for bp in B]) + sage: matrix([[b*bp for b in B] for bp in B]) # needs sage.graphs sage.groups [ B[0] B[1] B[2] B[3] B[4] B[5] B[6] B[7]] [ B[1] 0 2*B[4] B[5] 0 0 2*B[7] 0] [ B[2] -2*B[4] 0 B[6] 0 -2*B[7] 0 0] @@ -668,6 +686,7 @@ def __init__(self, R, M, G, action_on_groundset=None, *args, **kwargs): EXAMPLES:: + sage: # needs sage.graphs sage.groups sage: M = matroids.CompleteGraphic(4) sage: new_bases = [frozenset(i+1 for i in j) for j in M.bases()] sage: M = Matroid(bases=new_bases) @@ -756,11 +775,12 @@ def _basis_action(self, g, f): EXAMPLES:: + sage: # needs sage.graphs sage.groups sage: M = matroids.CompleteGraphic(3) sage: M.groundset() frozenset({0, 1, 2}) sage: G = SymmetricGroup(3) - sage: def on_groundset(g,x): + sage: def on_groundset(g, x): ....: return g(x+1)-1 sage: OSG = M.orlik_solomon_algebra(QQ, invariant=(G,on_groundset)) sage: act = lambda g: (OSG._basis_action(g,frozenset({0,1})), @@ -775,6 +795,7 @@ def _basis_action(self, g, f): We also check that the ordering is respected:: + sage: # needs sage.graphs sage.groups sage: fset = frozenset({1,2}) sage: OS1 = M.orlik_solomon_algebra(QQ) sage: OS1.subset_image(fset) @@ -782,7 +803,6 @@ def _basis_action(self, g, f): sage: OS2 = M.orlik_solomon_algebra(QQ, range(2,-1,-1)) sage: OS2.subset_image(fset) OS{1, 2} - sage: OSG2 = M.orlik_solomon_algebra(QQ, ....: invariant=(G,on_groundset), ....: ordering=range(2,-1,-1)) @@ -792,9 +812,9 @@ def _basis_action(self, g, f): This choice of ``g`` acting on this choice of ``fset`` reverses the sign:: - sage: OSG._basis_action(g, fset) + sage: OSG._basis_action(g, fset) # needs sage.graphs sage.groups OS{0, 1} - OS{0, 2} - sage: OSG2._basis_action(g, fset) + sage: OSG2._basis_action(g, fset) # needs sage.graphs sage.groups -OS{1, 2} """ OS = self._ambient diff --git a/src/sage/algebras/orlik_terao.py b/src/sage/algebras/orlik_terao.py index 55fd2bdb641..81158f3e9b7 100644 --- a/src/sage/algebras/orlik_terao.py +++ b/src/sage/algebras/orlik_terao.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Orlik-Terao Algebras """ @@ -130,10 +131,12 @@ def __init__(self, R, M, ordering=None): sage: OT = M.orlik_terao_algebra(QQ) sage: TestSuite(OT).run(elements=OT.basis()) + sage: # needs sage.graphs sage: M = matroids.CompleteGraphic(4).ternary_matroid() sage: OT = M.orlik_terao_algebra(GF(3)['t']) sage: TestSuite(OT).run(elements=OT.basis()) + sage: # needs sage.geometry.polyhedron sage: H = hyperplane_arrangements.Catalan(4).cone() sage: M = H.matroid() sage: OT = M.orlik_terao_algebra() @@ -144,6 +147,7 @@ def __init__(self, R, M, ordering=None): We check on the matroid associated to the graph with 3 vertices and 2 edges between each vertex:: + sage: # needs sage.graphs sage: G = Graph([[1,2],[1,2],[2,3],[2,3],[1,3],[1,3]], multiedges=True) sage: M = Matroid(G).regular_matroid() sage: OT = M.orlik_terao_algebra(QQ) @@ -321,6 +325,7 @@ def product_on_basis(self, a, b): Let us check that `e_{s_1} e_{s_2} \cdots e_{s_k} = e_S` for any subset `S = \{ s_1 < s_2 < \cdots < s_k \}` of the ground set:: + sage: # needs sage.graphs sage: G = Graph([[1,2],[1,2],[2,3],[3,4],[4,2]], multiedges=True) sage: M = Matroid(G).regular_matroid() sage: E = M.groundset_list() @@ -370,6 +375,7 @@ def subset_image(self, S): ([2, 5], -OT{0, 2} + OT{0, 5}) ([4, 5], -OT{3, 4} - OT{3, 5}) + sage: # needs sage.graphs sage: M4 = matroids.CompleteGraphic(4).ternary_matroid() sage: OT = M4.orlik_terao_algebra() sage: OT.subset_image(frozenset({2,3,4})) @@ -377,6 +383,7 @@ def subset_image(self, S): An example of a custom ordering:: + sage: # needs sage.graphs sage: G = Graph([[3, 4], [4, 1], [1, 2], [2, 3], [3, 5], [5, 6], [6, 3]]) sage: M = Matroid(G).regular_matroid() sage: s = [(5, 6), (1, 2), (3, 5), (2, 3), (1, 4), (3, 6), (3, 4)] @@ -404,6 +411,7 @@ def subset_image(self, S): TESTS:: + sage: # needs sage.graphs sage: G = Graph([[1,2],[1,2],[2,3],[2,3],[1,3],[1,3]], multiedges=True) sage: M = Matroid(G).regular_matroid() sage: sorted([sorted(c) for c in M.circuits()]) @@ -424,6 +432,7 @@ def subset_image(self, S): sage: OT.subset_image(frozenset([1, 5])) OT{0, 4} + sage: # needs sage.graphs sage: G = Graph([[1,2],[1,2],[2,3],[3,4],[4,2]], multiedges=True) sage: M = Matroid(G).regular_matroid() sage: sorted([sorted(c) for c in M.circuits()]) @@ -498,6 +507,7 @@ def _chi(self, X): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage: H = hyperplane_arrangements.Catalan(2).cone() sage: M = H.matroid() sage: OT = M.orlik_terao_algebra() @@ -541,7 +551,7 @@ class OrlikTeraoInvariantAlgebra(FiniteDimensionalInvariantModule): sage: M = Matroid(A) sage: M.groundset() frozenset({0, 1, 2}) - sage: G = SymmetricGroup(3) + sage: G = SymmetricGroup(3) # needs sage.groups Calling elements ``g`` of ``G`` on an element `i` of `\{1,2,3\}` defines the action we want, but since the groundset is `\{0,1,2\}` @@ -553,7 +563,8 @@ class OrlikTeraoInvariantAlgebra(FiniteDimensionalInvariantModule): Now that we have defined an action we can create the invariant, and get its basis:: - sage: OTG = M.orlik_terao_algebra(QQ, invariant = (G, on_groundset)) + sage: # needs sage.groups + sage: OTG = M.orlik_terao_algebra(QQ, invariant=(G, on_groundset)) sage: OTG.basis() Finite family {0: B[0], 1: B[1]} sage: [OTG.lift(b) for b in OTG.basis()] @@ -561,6 +572,7 @@ class OrlikTeraoInvariantAlgebra(FiniteDimensionalInvariantModule): Since it is invariant, the action of any ``g`` in ``G`` is trivial:: + sage: # needs sage.groups sage: x = OTG.an_element(); x 2*B[0] + 2*B[1] sage: g = G.an_element(); g @@ -568,6 +580,7 @@ class OrlikTeraoInvariantAlgebra(FiniteDimensionalInvariantModule): sage: g*x 2*B[0] + 2*B[1] + sage: # needs sage.groups sage: x = OTG.random_element() sage: g = G.random_element() sage: g*x == x @@ -576,11 +589,12 @@ class OrlikTeraoInvariantAlgebra(FiniteDimensionalInvariantModule): The underlying ambient module is the Orlik-Terao algebra, which is accessible via :meth:`ambient()`:: - sage: M.orlik_terao_algebra(QQ) is OTG.ambient() + sage: M.orlik_terao_algebra(QQ) is OTG.ambient() # needs sage.groups True For a bigger example, here we will look at the rank-`3` braid matroid:: + sage: # needs sage.groups sage: A = matrix([[1,1,1,0,0,0],[-1,0,0,1,1,0], ....: [0,-1,0,-1,0,1],[0,0,-1,0,-1,-1]]); A [ 1 1 1 0 0 0] @@ -590,9 +604,11 @@ class OrlikTeraoInvariantAlgebra(FiniteDimensionalInvariantModule): sage: M = Matroid(A); M.groundset() frozenset({0, 1, 2, 3, 4, 5}) sage: G = SymmetricGroup(6) - sage: OTG = M.orlik_terao_algebra(QQ, invariant = (G, on_groundset)) + sage: OTG = M.orlik_terao_algebra(QQ, invariant=(G, on_groundset)) sage: OTG.ambient() - Orlik-Terao algebra of Linear matroid of rank 3 on 6 elements represented over the Rational Field over Rational Field + Orlik-Terao algebra of + Linear matroid of rank 3 on 6 elements represented over the Rational Field + over Rational Field sage: OTG.basis() Finite family {0: B[0], 1: B[1]} sage: [OTG.lift(b) for b in OTG.basis()] @@ -605,6 +621,7 @@ def __init__(self, R, M, G, action_on_groundset=None, *args, **kwargs): EXAMPLES:: + sage: # needs sage.groups sage: A = matrix([[1,1,1,0,0,0],[-1,0,0,1,1,0],[0,-1,0,-1,0,1], ....: [0,0,-1,0,-1,-1]]) sage: M = Matroid(A); @@ -668,6 +685,7 @@ def construction(self): TESTS:: + sage: # needs sage.groups sage: A = matrix([[1,1,0],[-1,0,1],[0,-1,-1]]) sage: M = Matroid(A) sage: G = SymmetricGroup(3) @@ -696,6 +714,7 @@ def _basis_action(self, g, f): EXAMPLES:: + sage: # needs sage.groups sage: A = matrix([[1,1,0],[-1,0,1],[0,-1,-1]]) sage: M = Matroid(A) sage: M.groundset() @@ -718,6 +737,7 @@ def _basis_action(self, g, f): We also check that the ordering is respected:: + sage: # needs sage.groups sage: fset = frozenset({1,2}) sage: OT1 = M.orlik_terao_algebra(QQ) sage: OT1.subset_image(fset) @@ -726,6 +746,7 @@ def _basis_action(self, g, f): sage: OT2.subset_image(fset) OT{1, 2} + sage: # needs sage.groups sage: OTG2 = M.orlik_terao_algebra(QQ, ....: invariant=(G,on_groundset), ....: ordering=range(2,-1,-1)) @@ -734,6 +755,7 @@ def _basis_action(self, g, f): This choice of ``g`` fixes these elements:: + sage: # needs sage.groups sage: OTG._basis_action(g, fset) -OT{0, 1} + OT{0, 2} sage: OTG2._basis_action(g, fset) @@ -741,6 +763,7 @@ def _basis_action(self, g, f): TESTS:: + sage: # needs sage.groups sage: [on_groundset(g, e) for e in M.groundset()] [0, 2, 1] sage: [OTG._groundset_action(g,e) for e in M.groundset()] diff --git a/src/sage/algebras/q_commuting_polynomials.py b/src/sage/algebras/q_commuting_polynomials.py index a50b2335787..10f5f55a987 100644 --- a/src/sage/algebras/q_commuting_polynomials.py +++ b/src/sage/algebras/q_commuting_polynomials.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.groups sage.modules r""" `q`-Commuting Polynomials diff --git a/src/sage/algebras/q_system.py b/src/sage/algebras/q_system.py index f7d495aac50..d35c51a32a5 100644 --- a/src/sage/algebras/q_system.py +++ b/src/sage/algebras/q_system.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat sage.graphs sage.modules r""" Q-Systems diff --git a/src/sage/algebras/quantum_clifford.py b/src/sage/algebras/quantum_clifford.py index 2b85615cf20..dc61084f2f8 100644 --- a/src/sage/algebras/quantum_clifford.py +++ b/src/sage/algebras/quantum_clifford.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Quantum Clifford Algebras diff --git a/src/sage/algebras/quantum_groups/ace_quantum_onsager.py b/src/sage/algebras/quantum_groups/ace_quantum_onsager.py index 91138258e5a..9d983529c73 100644 --- a/src/sage/algebras/quantum_groups/ace_quantum_onsager.py +++ b/src/sage/algebras/quantum_groups/ace_quantum_onsager.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Alternating Central Extension Quantum Onsager Algebra diff --git a/src/sage/algebras/quantum_groups/fock_space.py b/src/sage/algebras/quantum_groups/fock_space.py index 3352f143a7c..22665746325 100644 --- a/src/sage/algebras/quantum_groups/fock_space.py +++ b/src/sage/algebras/quantum_groups/fock_space.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat sage.modules r""" Fock Space diff --git a/src/sage/algebras/quantum_groups/quantum_group_gap.py b/src/sage/algebras/quantum_groups/quantum_group_gap.py index 8925c047916..4998af7b588 100644 --- a/src/sage/algebras/quantum_groups/quantum_group_gap.py +++ b/src/sage/algebras/quantum_groups/quantum_group_gap.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - gap_package_quagroup +# sage.doctest: optional - gap_package_quagroup sage.combinat sage.libs.gap sage.modules """ Quantum Groups Using GAP's QuaGroup Package @@ -21,7 +21,12 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +import re + +from copy import copy + from sage.misc.lazy_attribute import lazy_attribute +from sage.misc.lazy_import import lazy_import from sage.misc.cachefunc import cached_method from sage.structure.parent import Parent from sage.structure.element import Element @@ -33,7 +38,6 @@ from sage.combinat.root_system.cartan_type import CartanType from sage.libs.gap.libgap import libgap from sage.features.gap import GapPackage -from sage.graphs.digraph import DiGraph from sage.rings.rational_field import QQ from sage.categories.algebras import Algebras from sage.categories.cartesian_product import cartesian_product @@ -44,8 +48,7 @@ from sage.categories.morphism import Morphism from sage.categories.rings import Rings -from copy import copy -import re +lazy_import('sage.graphs.digraph', 'DiGraph') class QuaGroupModuleElement(Element): diff --git a/src/sage/algebras/quantum_groups/representations.py b/src/sage/algebras/quantum_groups/representations.py index b874d264669..cea110137db 100644 --- a/src/sage/algebras/quantum_groups/representations.py +++ b/src/sage/algebras/quantum_groups/representations.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.graphs sage.modules r""" Quantum Group Representations diff --git a/src/sage/algebras/quantum_matrix_coordinate_algebra.py b/src/sage/algebras/quantum_matrix_coordinate_algebra.py index 1579896fa86..c9f7e312788 100644 --- a/src/sage/algebras/quantum_matrix_coordinate_algebra.py +++ b/src/sage/algebras/quantum_matrix_coordinate_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Quantum Matrix Coordinate Algebras diff --git a/src/sage/algebras/quatalg/quaternion_algebra.py b/src/sage/algebras/quatalg/quaternion_algebra.py index 1b6001209a0..9c1562041e4 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra.py +++ b/src/sage/algebras/quatalg/quaternion_algebra.py @@ -119,15 +119,17 @@ class QuaternionAlgebraFactory(UniqueFactory): Quaternion Algebra (2, 3) with base ring Finite Field of size 5 sage: QuaternionAlgebra(2, GF(5)(3)) Quaternion Algebra (2, 3) with base ring Finite Field of size 5 - sage: QuaternionAlgebra(QQ[sqrt(2)](-1), -5) - Quaternion Algebra (-1, -5) with base ring Number Field in sqrt2 with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095? - sage: QuaternionAlgebra(sqrt(-1), sqrt(-3)) + sage: QuaternionAlgebra(QQ[sqrt(2)](-1), -5) # needs sage.symbolic + Quaternion Algebra (-1, -5) with base ring Number Field in sqrt2 + with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095? + sage: QuaternionAlgebra(sqrt(-1), sqrt(-3)) # needs sage.symbolic Quaternion Algebra (I, sqrt(-3)) with base ring Symbolic Ring sage: QuaternionAlgebra(1r,1) Quaternion Algebra (1, 1) with base ring Rational Field sage: A. = ZZ[] sage: QuaternionAlgebra(-1, t) - Quaternion Algebra (-1, t) with base ring Fraction Field of Univariate Polynomial Ring in t over Integer Ring + Quaternion Algebra (-1, t) with base ring + Fraction Field of Univariate Polynomial Ring in t over Integer Ring Python ints and floats may be passed to the ``QuaternionAlgebra(a, b)`` constructor, as may all pairs of @@ -138,11 +140,13 @@ class QuaternionAlgebraFactory(UniqueFactory): sage: QuaternionAlgebra(1r,1) Quaternion Algebra (1, 1) with base ring Rational Field sage: QuaternionAlgebra(1,1.0r) - Quaternion Algebra (1.00000000000000, 1.00000000000000) with base ring Real Field with 53 bits of precision + Quaternion Algebra (1.00000000000000, 1.00000000000000) with base ring + Real Field with 53 bits of precision sage: QuaternionAlgebra(0,0) Traceback (most recent call last): ... - ValueError: defining elements of quaternion algebra (0, 0) are not invertible in Rational Field + ValueError: defining elements of quaternion algebra (0, 0) + are not invertible in Rational Field sage: QuaternionAlgebra(GF(2)(1),1) Traceback (most recent call last): ... @@ -158,8 +162,9 @@ class QuaternionAlgebraFactory(UniqueFactory): sage: QuaternionAlgebra(QQ, -7, -21) Quaternion Algebra (-7, -21) with base ring Rational Field - sage: QuaternionAlgebra(QQ[sqrt(2)], -2,-3) - Quaternion Algebra (-2, -3) with base ring Number Field in sqrt2 with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095? + sage: QuaternionAlgebra(QQ[sqrt(2)], -2,-3) # needs sage.symbolic + Quaternion Algebra (-2, -3) with base ring Number Field in sqrt2 + with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095? ``QuaternionAlgebra(D)`` -- `D` is a squarefree integer; return a rational quaternion algebra of discriminant `D`:: @@ -540,8 +545,8 @@ def random_element(self, *args, **kwds): EXAMPLES:: - sage: g = QuaternionAlgebra(QQ[sqrt(2)], -3, 7).random_element() - sage: g.parent() is QuaternionAlgebra(QQ[sqrt(2)], -3, 7) + sage: g = QuaternionAlgebra(QQ[sqrt(2)], -3, 7).random_element() # needs sage.symbolic + sage: g.parent() is QuaternionAlgebra(QQ[sqrt(2)], -3, 7) # needs sage.symbolic True sage: g = QuaternionAlgebra(-3, 19).random_element() sage: g.parent() is QuaternionAlgebra(-3, 19) @@ -576,12 +581,13 @@ def free_module(self): sage: A. = LaurentPolynomialRing(GF(3)) sage: B = QuaternionAlgebra(A, -1, t) sage: B.free_module() - Ambient free quadratic module of rank 4 over the principal ideal domain Univariate Laurent Polynomial Ring in t over Finite Field of size 3 - Inner product matrix: - [2 0 0 0] - [0 2 0 0] - [0 0 t 0] - [0 0 0 t] + Ambient free quadratic module of rank 4 over the principal ideal domain + Univariate Laurent Polynomial Ring in t over Finite Field of size 3 + Inner product matrix: + [2 0 0 0] + [0 2 0 0] + [0 0 t 0] + [0 0 0 t] """ return FreeModule(self.base_ring(), 4, inner_product_matrix=self.inner_product_matrix()) @@ -594,10 +600,10 @@ def vector_space(self): sage: QuaternionAlgebra(-3,19).vector_space() Ambient quadratic space of dimension 4 over Rational Field Inner product matrix: - [ 2 0 0 0] - [ 0 6 0 0] - [ 0 0 -38 0] - [ 0 0 0 -114] + [ 2 0 0 0] + [ 0 6 0 0] + [ 0 0 -38 0] + [ 0 0 0 -114] """ return self.free_module() @@ -697,7 +703,8 @@ def maximal_order(self, take_shortcuts=True): EXAMPLES:: sage: QuaternionAlgebra(-1,-7).maximal_order() - Order of Quaternion Algebra (-1, -7) with base ring Rational Field with basis (1/2 + 1/2*j, 1/2*i + 1/2*k, j, k) + Order of Quaternion Algebra (-1, -7) with base ring Rational Field + with basis (1/2 + 1/2*j, 1/2*i + 1/2*k, j, k) sage: QuaternionAlgebra(-1,-1).maximal_order().basis() (1/2 + 1/2*i + 1/2*j + 1/2*k, i, j, k) @@ -732,13 +739,16 @@ def maximal_order(self, take_shortcuts=True): If you want bases containing 1, switch off ``take_shortcuts``:: sage: QuaternionAlgebra(-3,-89).maximal_order(take_shortcuts=False) - Order of Quaternion Algebra (-3, -89) with base ring Rational Field with basis (1, 1/2 + 1/2*i, j, 1/2 + 1/6*i + 1/2*j + 1/6*k) + Order of Quaternion Algebra (-3, -89) with base ring Rational Field + with basis (1, 1/2 + 1/2*i, j, 1/2 + 1/6*i + 1/2*j + 1/6*k) sage: QuaternionAlgebra(1,1).maximal_order(take_shortcuts=False) # Matrix ring - Order of Quaternion Algebra (1, 1) with base ring Rational Field with basis (1, 1/2 + 1/2*i, j, 1/2*j + 1/2*k) + Order of Quaternion Algebra (1, 1) with base ring Rational Field + with basis (1, 1/2 + 1/2*i, j, 1/2*j + 1/2*k) sage: QuaternionAlgebra(-22,210).maximal_order(take_shortcuts=False) - Order of Quaternion Algebra (-22, 210) with base ring Rational Field with basis (1, i, 1/2*i + 1/2*j, 1/2 + 17/22*i + 1/44*k) + Order of Quaternion Algebra (-22, 210) with base ring Rational Field + with basis (1, i, 1/2*i + 1/2*j, 1/2 + 17/22*i + 1/44*k) sage: for d in ( m for m in range(1, 750) if is_squarefree(m) ): # long time (3s) ....: A = QuaternionAlgebra(d) @@ -751,7 +761,8 @@ def maximal_order(self, take_shortcuts=True): sage: QuaternionAlgebra(K,-1,-1).maximal_order() Traceback (most recent call last): ... - NotImplementedError: maximal order only implemented for rational quaternion algebras + NotImplementedError: maximal order only implemented + for rational quaternion algebras """ if self.base_ring() != QQ: raise NotImplementedError("maximal order only implemented for rational quaternion algebras") @@ -1037,7 +1048,7 @@ def discriminant(self): sage: B.discriminant() Fractional ideal (2) - sage: QuaternionAlgebra(QQ[sqrt(2)],3,19).discriminant() + sage: QuaternionAlgebra(QQ[sqrt(2)], 3, 19).discriminant() # needs sage.symbolic Fractional ideal (1) """ if not is_RationalField(self.base_ring()): @@ -1082,11 +1093,13 @@ def _magma_init_(self, magma): A more complicated example involving a quaternion algebra over a number field:: - sage: K. = QQ[sqrt(2)]; Q = QuaternionAlgebra(K,-1,a); Q - Quaternion Algebra (-1, sqrt2) with base ring Number Field in sqrt2 with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095? - sage: magma(Q) # optional - magma - Quaternion Algebra with base ring Number Field with defining polynomial x^2 - 2 over the Rational Field, defined by i^2 = -1, j^2 = sqrt2 - sage: Q._magma_init_(magma) # optional - magma + sage: K. = QQ[sqrt(2)]; Q = QuaternionAlgebra(K,-1,a); Q # needs sage.symbolic + Quaternion Algebra (-1, sqrt2) with base ring Number Field in sqrt2 + with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095? + sage: magma(Q) # optional - magma, needs sage.symbolic + Quaternion Algebra with base ring Number Field with defining polynomial + x^2 - 2 over the Rational Field, defined by i^2 = -1, j^2 = sqrt2 + sage: Q._magma_init_(magma) # optional - magma, needs sage.symbolic 'QuaternionAlgebra(_sage_[...],(_sage_[...]![-1, 0]),(_sage_[...]![0, 1]))' """ R = magma(self.base_ring()) @@ -1107,14 +1120,17 @@ def quaternion_order(self, basis, check=True): sage: Q. = QuaternionAlgebra(-11,-1) sage: Q.quaternion_order([1,i,j,k]) - Order of Quaternion Algebra (-11, -1) with base ring Rational Field with basis (1, i, j, k) + Order of Quaternion Algebra (-11, -1) with base ring Rational Field + with basis (1, i, j, k) We test out ``check=False``:: sage: Q.quaternion_order([1,i,j,k], check=False) - Order of Quaternion Algebra (-11, -1) with base ring Rational Field with basis (1, i, j, k) + Order of Quaternion Algebra (-11, -1) with base ring Rational Field + with basis (1, i, j, k) sage: Q.quaternion_order([i,j,k], check=False) - Order of Quaternion Algebra (-11, -1) with base ring Rational Field with basis (i, j, k) + Order of Quaternion Algebra (-11, -1) with base ring Rational Field + with basis (i, j, k) """ return QuaternionOrder(self, basis, check=check) @@ -1210,7 +1226,9 @@ def modp_splitting_data(self, p): sage: Q.modp_splitting_data(5) Traceback (most recent call last): ... - NotImplementedError: algorithm for computing local splittings not implemented in general (currently require the first invariant to be coprime to p) + NotImplementedError: algorithm for computing local splittings + not implemented in general (currently require the first invariant + to be coprime to p) sage: Q.modp_splitting_data(2) Traceback (most recent call last): @@ -1363,7 +1381,8 @@ def __init__(self, A, basis, check=True): sage: K = QuadraticField(10) sage: A. = QuaternionAlgebra(K,-1,-1) sage: A.quaternion_order([1,i,j,k]) - Order of Quaternion Algebra (-1, -1) with base ring Number Field in a with defining polynomial x^2 - 10 with a = 3.162277660168380? with basis (1, i, j, k) + Order of Quaternion Algebra (-1, -1) with base ring Number Field in a + with defining polynomial x^2 - 10 with a = 3.162277660168380? with basis (1, i, j, k) sage: A.quaternion_order([1,i/2,j,k]) Traceback (most recent call last): ... @@ -1508,7 +1527,8 @@ def gen(self, n): EXAMPLES:: sage: R = QuaternionAlgebra(-11,-1).maximal_order(); R - Order of Quaternion Algebra (-11, -1) with base ring Rational Field with basis (1/2 + 1/2*i, 1/2*j - 1/2*k, i, -k) + Order of Quaternion Algebra (-11, -1) with base ring Rational Field + with basis (1/2 + 1/2*i, 1/2*j - 1/2*k, i, -k) sage: R.gen(0) 1/2 + 1/2*i sage: R.gen(1) @@ -1649,20 +1669,23 @@ def intersection(self, other): sage: R = QuaternionAlgebra(-11,-1).maximal_order() sage: R.intersection(R) - Order of Quaternion Algebra (-11, -1) with base ring Rational Field with basis (1/2 + 1/2*i, i, 1/2*j + 1/2*k, k) + Order of Quaternion Algebra (-11, -1) with base ring Rational Field + with basis (1/2 + 1/2*i, i, 1/2*j + 1/2*k, k) We intersect various orders in the quaternion algebra ramified at 11:: sage: B = BrandtModule(11,3) sage: R = B.maximal_order(); S = B.order_of_level_N() sage: R.intersection(S) - Order of Quaternion Algebra (-1, -11) with base ring Rational Field with basis (1/2 + 1/2*j, 1/2*i + 5/2*k, j, 3*k) + Order of Quaternion Algebra (-1, -11) with base ring Rational Field + with basis (1/2 + 1/2*j, 1/2*i + 5/2*k, j, 3*k) sage: R.intersection(S) == S True sage: B = BrandtModule(11,5) sage: T = B.order_of_level_N() sage: S.intersection(T) - Order of Quaternion Algebra (-1, -11) with base ring Rational Field with basis (1/2 + 1/2*j, 1/2*i + 23/2*k, j, 15*k) + Order of Quaternion Algebra (-1, -11) with base ring Rational Field + with basis (1/2 + 1/2*j, 1/2*i + 23/2*k, j, 15*k) """ if not isinstance(other, QuaternionOrder): raise TypeError("other must be a QuaternionOrder") @@ -2021,7 +2044,8 @@ def scale(self, alpha, left=False): EXAMPLES:: - sage: B = BrandtModule(5,37); I = B.right_ideals()[0]; i,j,k = B.quaternion_algebra().gens(); I + sage: B = BrandtModule(5,37); I = B.right_ideals()[0] + sage: i,j,k = B.quaternion_algebra().gens(); I Fractional ideal (2 + 2*j + 106*k, i + 2*j + 105*k, 4*j + 64*k, 148*k) sage: I.scale(i) Fractional ideal (2*i + 212*j - 2*k, -2 + 210*j - 2*k, 128*j - 4*k, 296*j) @@ -2101,9 +2125,11 @@ def _compute_order(self, side='left'): sage: R. = QuaternionAlgebra(-1,-11) sage: I = R.ideal([2 + 2*j + 140*k, 2*i + 4*j + 150*k, 8*j + 104*k, 152*k]) sage: Ol = I._compute_order('left'); Ol - Order of Quaternion Algebra (-1, -11) with base ring Rational Field with basis (1/2 + 1/2*j + 35*k, 1/4*i + 1/2*j + 75/4*k, j + 32*k, 38*k) + Order of Quaternion Algebra (-1, -11) with base ring Rational Field + with basis (1/2 + 1/2*j + 35*k, 1/4*i + 1/2*j + 75/4*k, j + 32*k, 38*k) sage: Or = I._compute_order('right'); Or - Order of Quaternion Algebra (-1, -11) with base ring Rational Field with basis (1/2 + 1/2*j + 16*k, 1/2*i + 11/2*k, j + 13*k, 19*k) + Order of Quaternion Algebra (-1, -11) with base ring Rational Field + with basis (1/2 + 1/2*j + 16*k, 1/2*i + 11/2*k, j + 13*k, 19*k) sage: Ol.discriminant() 209 sage: Or.discriminant() @@ -2163,7 +2189,8 @@ def left_order(self): sage: R = B.maximal_order() sage: I = R.unit_ideal() sage: I.left_order() - Order of Quaternion Algebra (-1, -11) with base ring Rational Field with basis (1/2 + 1/2*j, 1/2*i + 1/2*k, j, k) + Order of Quaternion Algebra (-1, -11) with base ring Rational Field + with basis (1/2 + 1/2*j, 1/2*i + 1/2*k, j, k) We do a consistency check:: @@ -2186,9 +2213,11 @@ def right_order(self): sage: I = BrandtModule(389).right_ideals()[1]; I Fractional ideal (2 + 6*j + 2*k, i + 2*j + k, 8*j, 8*k) sage: I.right_order() - Order of Quaternion Algebra (-2, -389) with base ring Rational Field with basis (1/2 + 1/2*j + 1/2*k, 1/4*i + 1/2*j + 1/4*k, j, k) + Order of Quaternion Algebra (-2, -389) with base ring Rational Field + with basis (1/2 + 1/2*j + 1/2*k, 1/4*i + 1/2*j + 1/4*k, j, k) sage: I.left_order() - Order of Quaternion Algebra (-2, -389) with base ring Rational Field with basis (1/2 + 1/2*j + 3/2*k, 1/8*i + 1/4*j + 9/8*k, j + k, 2*k) + Order of Quaternion Algebra (-2, -389) with base ring Rational Field + with basis (1/2 + 1/2*j + 3/2*k, 1/8*i + 1/4*j + 9/8*k, j + k, 2*k) The following is a big consistency check. We take reps for all the right ideal classes of a certain order, take the @@ -2238,7 +2267,8 @@ def quaternion_order(self): sage: R = QuaternionAlgebra(-11,-1).maximal_order() sage: R.unit_ideal().quaternion_order() is R - doctest:...: DeprecationWarning: quaternion_order() is deprecated, please use left_order() or right_order() + doctest:...: DeprecationWarning: quaternion_order() is deprecated, + please use left_order() or right_order() See https://github.com/sagemath/sage/issues/31583 for details. True """ @@ -2516,12 +2546,13 @@ def norm(self): sage: [I.norm() for I in C] [16, 32, 32] - sage: (a,b) = M.quaternion_algebra().invariants() # optional - magma - sage: magma.eval('A := QuaternionAlgebra' % (a,b)) # optional - magma + sage: # optional - magma + sage: (a,b) = M.quaternion_algebra().invariants() + sage: magma.eval('A := QuaternionAlgebra' % (a,b)) '' - sage: magma.eval('O := QuaternionOrder(%s)' % str(list(C[0].right_order().basis()))) # optional - magma + sage: magma.eval('O := QuaternionOrder(%s)' % str(list(C[0].right_order().basis()))) '' - sage: [ magma('rideal' % str(list(I.basis()))).Norm() for I in C] # optional - magma + sage: [ magma('rideal' % str(list(I.basis()))).Norm() for I in C] [16, 32, 32] sage: A. = QuaternionAlgebra(-1,-1) @@ -2838,31 +2869,47 @@ def cyclic_right_subideals(self, p, alpha=None): sage: B = BrandtModule(2,37); I = B.right_ideals()[0] sage: I.cyclic_right_subideals(3) - [Fractional ideal (2 + 2*i + 10*j + 90*k, 4*i + 4*j + 152*k, 12*j + 132*k, 444*k), Fractional ideal (2 + 2*i + 2*j + 150*k, 4*i + 8*j + 196*k, 12*j + 132*k, 444*k), Fractional ideal (2 + 2*i + 6*j + 194*k, 4*i + 8*j + 344*k, 12*j + 132*k, 444*k), Fractional ideal (2 + 2*i + 6*j + 46*k, 4*i + 4*j + 4*k, 12*j + 132*k, 444*k)] + [Fractional ideal (2 + 2*i + 10*j + 90*k, 4*i + 4*j + 152*k, 12*j + 132*k, 444*k), + Fractional ideal (2 + 2*i + 2*j + 150*k, 4*i + 8*j + 196*k, 12*j + 132*k, 444*k), + Fractional ideal (2 + 2*i + 6*j + 194*k, 4*i + 8*j + 344*k, 12*j + 132*k, 444*k), + Fractional ideal (2 + 2*i + 6*j + 46*k, 4*i + 4*j + 4*k, 12*j + 132*k, 444*k)] sage: B = BrandtModule(5,389); I = B.right_ideals()[0] sage: C = I.cyclic_right_subideals(3); C - [Fractional ideal (2 + 10*j + 546*k, i + 6*j + 133*k, 12*j + 3456*k, 4668*k), Fractional ideal (2 + 2*j + 2910*k, i + 6*j + 3245*k, 12*j + 3456*k, 4668*k), Fractional ideal (2 + i + 2295*k, 3*i + 2*j + 3571*k, 4*j + 2708*k, 4668*k), Fractional ideal (2 + 2*i + 2*j + 4388*k, 3*i + 2*j + 2015*k, 4*j + 4264*k, 4668*k)] + [Fractional ideal (2 + 10*j + 546*k, i + 6*j + 133*k, 12*j + 3456*k, 4668*k), + Fractional ideal (2 + 2*j + 2910*k, i + 6*j + 3245*k, 12*j + 3456*k, 4668*k), + Fractional ideal (2 + i + 2295*k, 3*i + 2*j + 3571*k, 4*j + 2708*k, 4668*k), + Fractional ideal (2 + 2*i + 2*j + 4388*k, 3*i + 2*j + 2015*k, 4*j + 4264*k, 4668*k)] sage: [(I.free_module()/J.free_module()).invariants() for J in C] [(3, 3), (3, 3), (3, 3), (3, 3)] sage: I.scale(3).cyclic_right_subideals(3) - [Fractional ideal (6 + 30*j + 1638*k, 3*i + 18*j + 399*k, 36*j + 10368*k, 14004*k), Fractional ideal (6 + 6*j + 8730*k, 3*i + 18*j + 9735*k, 36*j + 10368*k, 14004*k), Fractional ideal (6 + 3*i + 6885*k, 9*i + 6*j + 10713*k, 12*j + 8124*k, 14004*k), Fractional ideal (6 + 6*i + 6*j + 13164*k, 9*i + 6*j + 6045*k, 12*j + 12792*k, 14004*k)] + [Fractional ideal (6 + 30*j + 1638*k, 3*i + 18*j + 399*k, 36*j + 10368*k, 14004*k), + Fractional ideal (6 + 6*j + 8730*k, 3*i + 18*j + 9735*k, 36*j + 10368*k, 14004*k), + Fractional ideal (6 + 3*i + 6885*k, 9*i + 6*j + 10713*k, 12*j + 8124*k, 14004*k), + Fractional ideal (6 + 6*i + 6*j + 13164*k, 9*i + 6*j + 6045*k, 12*j + 12792*k, 14004*k)] sage: C = I.scale(1/9).cyclic_right_subideals(3); C - [Fractional ideal (2/9 + 10/9*j + 182/3*k, 1/9*i + 2/3*j + 133/9*k, 4/3*j + 384*k, 1556/3*k), Fractional ideal (2/9 + 2/9*j + 970/3*k, 1/9*i + 2/3*j + 3245/9*k, 4/3*j + 384*k, 1556/3*k), Fractional ideal (2/9 + 1/9*i + 255*k, 1/3*i + 2/9*j + 3571/9*k, 4/9*j + 2708/9*k, 1556/3*k), Fractional ideal (2/9 + 2/9*i + 2/9*j + 4388/9*k, 1/3*i + 2/9*j + 2015/9*k, 4/9*j + 4264/9*k, 1556/3*k)] + [Fractional ideal (2/9 + 10/9*j + 182/3*k, 1/9*i + 2/3*j + 133/9*k, 4/3*j + 384*k, 1556/3*k), + Fractional ideal (2/9 + 2/9*j + 970/3*k, 1/9*i + 2/3*j + 3245/9*k, 4/3*j + 384*k, 1556/3*k), + Fractional ideal (2/9 + 1/9*i + 255*k, 1/3*i + 2/9*j + 3571/9*k, 4/9*j + 2708/9*k, 1556/3*k), + Fractional ideal (2/9 + 2/9*i + 2/9*j + 4388/9*k, 1/3*i + 2/9*j + 2015/9*k, 4/9*j + 4264/9*k, 1556/3*k)] sage: [(I.scale(1/9).free_module()/J.free_module()).invariants() for J in C] [(3, 3), (3, 3), (3, 3), (3, 3)] sage: Q. = QuaternionAlgebra(-2,-5) sage: I = Q.ideal([Q(1),i,j,k]) sage: I.cyclic_right_subideals(3) - [Fractional ideal (1 + 2*j, i + k, 3*j, 3*k), Fractional ideal (1 + j, i + 2*k, 3*j, 3*k), Fractional ideal (1 + 2*i, 3*i, j + 2*k, 3*k), Fractional ideal (1 + i, 3*i, j + k, 3*k)] + [Fractional ideal (1 + 2*j, i + k, 3*j, 3*k), + Fractional ideal (1 + j, i + 2*k, 3*j, 3*k), + Fractional ideal (1 + 2*i, 3*i, j + 2*k, 3*k), + Fractional ideal (1 + i, 3*i, j + k, 3*k)] The general algorithm is not yet implemented here:: sage: I.cyclic_right_subideals(3)[0].cyclic_right_subideals(3) Traceback (most recent call last): ... - NotImplementedError: general algorithm not implemented (The given basis vectors must be linearly independent.) + NotImplementedError: general algorithm not implemented + (The given basis vectors must be linearly independent.) """ R = self.right_order() Q = self.quaternion_algebra() @@ -3075,7 +3122,8 @@ def normalize_basis_at_p(e, p, B=QuaternionAlgebraElement_abstract.pair): sage: A. = QuaternionAlgebra(-1,-7) sage: e = [A(1), k, j, 1/2 + 1/2*i + 1/2*j + 1/2*k] sage: normalize_basis_at_p(e, 2) - [(1, 0), (1/2 + 1/2*i + 1/2*j + 1/2*k, 0), (-34/105*i - 463/735*j + 71/105*k, 1), (-34/105*i - 463/735*j + 71/105*k, 1)] + [(1, 0), (1/2 + 1/2*i + 1/2*j + 1/2*k, 0), (-34/105*i - 463/735*j + 71/105*k, 1), + (-34/105*i - 463/735*j + 71/105*k, 1)] """ N = len(e) diff --git a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx index a1dd86a224c..b4c5eed5b49 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx +++ b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx @@ -1658,8 +1658,8 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra EXAMPLES:: - sage: K. = QQ[2^(1/5)]; Q. = QuaternionAlgebra(K,-a,a*17/3) - sage: Q([a,-2/3,a^2-1/2,a*2]) # implicit doctest + sage: K. = QQ[2^(1/5)]; Q. = QuaternionAlgebra(K,-a,a*17/3) # needs sage.symbolic + sage: Q([a,-2/3,a^2-1/2,a*2]) # implicit doctest # needs sage.symbolic a + (-2/3)*i + (a^2 - 1/2)*j + 2*a*k """ fmpz_poly_init(self.x) @@ -1688,8 +1688,8 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra """ EXAMPLES:: - sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K,-a,a+1) - sage: Q([a,-2/3,a^2-1/2,a*2]) # implicit doctest + sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K,-a,a+1) # needs sage.symbolic + sage: Q([a,-2/3,a^2-1/2,a*2]) # implicit doctest # needs sage.symbolic a + (-2/3)*i + (a^2 - 1/2)*j + 2*a*k """ self._parent = parent @@ -1732,6 +1732,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra """ EXAMPLES:: + sage: # needs sage.symbolic sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K,-a,a+1) sage: Q([a,-2/3,a^2-1/2,a*2]) a + (-2/3)*i + (a^2 - 1/2)*j + 2*a*k @@ -1773,6 +1774,7 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra """ EXAMPLES:: + sage: # needs sage.symbolic sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K, -3, a) sage: z = (i+j+k+a)^2; z a^2 + 4*a - 3 + 2*a*i + 2*a*j + 2*a*k @@ -1791,8 +1793,10 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra EXAMPLES:: + sage: # needs sage.symbolic sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K, -3, a) - sage: z = a + i + (2/3)*a^3*j + (1+a)*k; w = a - i - (2/3)*a^3*j + (1/3+a)*k + sage: z = a + i + (2/3)*a^3*j + (1+a)*k + sage: w = a - i - (2/3)*a^3*j + (1/3+a)*k sage: type(z) sage: z._add_(w) @@ -1863,8 +1867,10 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra EXAMPLES:: + sage: # needs sage.symbolic sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K, -3, a) - sage: z = a + i + (2/3)*a^3*j + (1+a)*k; w = a - i - (2/3)*a^3*j + (1/3+a)*k + sage: z = a + i + (2/3)*a^3*j + (1+a)*k + sage: w = a - i - (2/3)*a^3*j + (1/3+a)*k sage: type(z) sage: z._sub_(w) @@ -1912,8 +1918,10 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra EXAMPLES:: + sage: # needs sage.symbolic sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K, -3, a) - sage: z = a + i + (2/3)*a^3*j + (1+a)*k; w = a - i - (2/3)*a^3*j + (1/3+a)*k + sage: z = a + i + (2/3)*a^3*j + (1+a)*k + sage: w = a - i - (2/3)*a^3*j + (1/3+a)*k sage: type(z) sage: z._mul_(w) @@ -2060,11 +2068,13 @@ cdef class QuaternionAlgebraElement_number_field(QuaternionAlgebraElement_abstra TESTS:: + sage: # needs sage.symbolic sage: F = QQ[3^(1/3)] sage: a = F.gen() sage: K. = QuaternionAlgebra(F, -10 + a, -7 - a) sage: ((1/4 + 1/2 * i + a^3/7 * j + a/28 * k)*14*i)^3 # implicit doctest - 34503/2*a^2 + 132195/2*a + 791399/4 + (203/8*a^2 - 10591*a + 169225/4)*i + (-84695/4*a^2 + 483413/8*a + 18591/4)*j + (-87/2*a^2 + 18156*a - 72525)*k + 34503/2*a^2 + 132195/2*a + 791399/4 + (203/8*a^2 - 10591*a + 169225/4)*i + + (-84695/4*a^2 + 483413/8*a + 18591/4)*j + (-87/2*a^2 + 18156*a - 72525)*k """ # Note: this function changes the module-level global variables @@ -2137,6 +2147,7 @@ def unpickle_QuaternionAlgebraElement_number_field_v0(*args): """ EXAMPLES:: + sage: # needs sage.symbolic sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K, -3, a); z = i + j sage: f, t = z.__reduce__() sage: sage.algebras.quatalg.quaternion_algebra_element.unpickle_QuaternionAlgebraElement_number_field_v0(*t) diff --git a/src/sage/algebras/quaternion_algebra.py b/src/sage/algebras/quaternion_algebra.py index 0f577bbd0b9..4e92b73de69 100644 --- a/src/sage/algebras/quaternion_algebra.py +++ b/src/sage/algebras/quaternion_algebra.py @@ -1,3 +1,5 @@ +# sage.doctest: needs sage.modules + ############################################################ # Backwards compatible unpickling ############################################################ diff --git a/src/sage/algebras/quaternion_algebra_element.py b/src/sage/algebras/quaternion_algebra_element.py index ef527e2f269..ed0baaf0152 100644 --- a/src/sage/algebras/quaternion_algebra_element.py +++ b/src/sage/algebras/quaternion_algebra_element.py @@ -1,3 +1,5 @@ +# sage.doctest: needs sage.modules + ####################################################################### # Backward compatible unpickle functions ####################################################################### @@ -37,6 +39,7 @@ def unpickle_QuaternionAlgebraElement_number_field_v0(*args): """ EXAMPLES:: + sage: # needs sage.symbolic sage: K. = QQ[2^(1/3)]; Q. = QuaternionAlgebra(K, -3, a); z = i + j sage: f, t = z.__reduce__() sage: import sage.algebras.quaternion_algebra_element diff --git a/src/sage/algebras/rational_cherednik_algebra.py b/src/sage/algebras/rational_cherednik_algebra.py index 3b85c1e13a3..58b3ce5441d 100644 --- a/src/sage/algebras/rational_cherednik_algebra.py +++ b/src/sage/algebras/rational_cherednik_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules """ Rational Cherednik Algebras """ diff --git a/src/sage/algebras/schur_algebra.py b/src/sage/algebras/schur_algebra.py index ff960e56dd9..4fca609ecf7 100644 --- a/src/sage/algebras/schur_algebra.py +++ b/src/sage/algebras/schur_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.groups sage.modules r""" Schur algebras for `GL_n` diff --git a/src/sage/algebras/shuffle_algebra.py b/src/sage/algebras/shuffle_algebra.py index 5d383f8dfab..2db55513d66 100644 --- a/src/sage/algebras/shuffle_algebra.py +++ b/src/sage/algebras/shuffle_algebra.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat sage.modules r""" Shuffle algebras diff --git a/src/sage/algebras/splitting_algebra.py b/src/sage/algebras/splitting_algebra.py index 3b0dfce4586..8913932ffac 100644 --- a/src/sage/algebras/splitting_algebra.py +++ b/src/sage/algebras/splitting_algebra.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.libs.pari sage.modules r""" Splitting Algebras diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py index 7c4d444f81c..993e94dc828 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra.py +++ b/src/sage/algebras/steenrod/steenrod_algebra.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.combinat sage.modules r""" The Steenrod algebra @@ -552,8 +552,8 @@ def __init__(self, p=2, basis='milnor', **kwds): sage: TestSuite(SteenrodAlgebra(profile=[4,3,2,2,1])).run() sage: TestSuite(SteenrodAlgebra(basis='adem')).run() sage: TestSuite(SteenrodAlgebra(basis='wall')).run() - sage: TestSuite(SteenrodAlgebra(basis='arnonc')).run() # long time - sage: TestSuite(SteenrodAlgebra(basis='woody')).run() # long time + sage: TestSuite(SteenrodAlgebra(basis='arnonc')).run() # long time + sage: TestSuite(SteenrodAlgebra(basis='woody')).run() # long time sage: A3 = SteenrodAlgebra(3) sage: A3.category() Category of supercocommutative super hopf algebras @@ -562,7 +562,7 @@ def __init__(self, p=2, basis='milnor', **kwds): sage: TestSuite(SteenrodAlgebra(basis='adem', p=3)).run() sage: TestSuite(SteenrodAlgebra(basis='pst_llex', p=7)).run() # long time sage: TestSuite(SteenrodAlgebra(basis='comm_deg', p=5)).run() # long time - sage: TestSuite(SteenrodAlgebra(p=2, generic=True)).run() # long time + sage: TestSuite(SteenrodAlgebra(p=2, generic=True)).run() # long time Two Steenrod algebras are equal iff their associated primes, bases, and profile functions (if present) are equal. Because @@ -753,8 +753,8 @@ def _repr_(self): mod 3 Steenrod algebra, milnor basis sage: SteenrodAlgebra(2, basis='adem') mod 2 Steenrod algebra, serre-cartan basis - sage: B = SteenrodAlgebra(2003) - sage: B._repr_() + sage: B = SteenrodAlgebra(2003) # needs sage.rings.finite_rings + sage: B._repr_() # needs sage.rings.finite_rings 'mod 2003 Steenrod algebra, milnor basis' sage: SteenrodAlgebra(generic=True, basis='adem') generic mod 2 Steenrod algebra, serre-cartan basis @@ -1393,14 +1393,14 @@ def coproduct(self, x, algorithm='milnor'): INPUT: - - ``x`` -- element of self + - ``x`` -- element of ``self`` - - ``algorithm`` -- ``None`` or a string, either 'milnor' or - 'serre-cartan' (or anything which will be converted to one + - ``algorithm`` -- ``None`` or a string, either ``'milnor'`` or + ``'serre-cartan'`` (or anything which will be converted to one of these by the function :func:`get_basis_name `. - If ``None``, default to 'serre-cartan' if current basis is - 'serre-cartan'; otherwise use 'milnor'. + If ``None``, default to ``'serre-cartan'`` if current basis is + ``'serre-cartan'``; otherwise use ``'milnor'``. This calls :meth:`coproduct_on_basis` on the summands of ``x`` and extends linearly. @@ -1440,12 +1440,12 @@ def antipode_on_basis(self, t): INPUT: - - ``t`` -- tuple, the index of a basis element of self + - ``t`` -- tuple, the index of a basis element of ``self`` OUTPUT: the antipode of the corresponding basis element, - as an element of self. + as an element of ``self``. ALGORITHM: according to a result of Milnor's, the antipode of `\text{Sq}(n)` is the sum of all of the Milnor basis elements @@ -1490,7 +1490,7 @@ def antipode_on_basis(self, t): TESTS:: sage: Milnor = SteenrodAlgebra() - sage: all(x.antipode().antipode() == x for x in Milnor.basis(11)) # long time + sage: all(x.antipode().antipode() == x for x in Milnor.basis(11)) # long time True sage: A5 = SteenrodAlgebra(p=5, basis='adem') sage: all(x.antipode().antipode() == x for x in A5.basis(25)) @@ -1531,7 +1531,7 @@ def counit_on_basis(self, t): INPUT: - - ``t`` -- tuple, the index of a basis element of self + - ``t`` -- tuple, the index of a basis element of ``self`` EXAMPLES:: @@ -2237,7 +2237,9 @@ def basis(self, d=None): This does not print in a very helpful way, unfortunately:: sage: A7.basis() - Lazy family (Term map from basis key family of mod 7 Steenrod algebra, milnor basis to mod 7 Steenrod algebra, milnor basis(i))_{i in basis key family of mod 7 Steenrod algebra, milnor basis} + Lazy family (Term map from basis key family of mod 7 Steenrod algebra, milnor basis + to mod 7 Steenrod algebra, milnor basis(i))_{i in basis key family + of mod 7 Steenrod algebra, milnor basis} sage: for (idx,a) in zip((1,..,9),A7.basis()): ....: print("{} {}".format(idx, a)) 1 1 @@ -2251,7 +2253,8 @@ def basis(self, d=None): 9 Q_0 P(2) sage: D = SteenrodAlgebra(p=3, profile=([1], [2,2])) sage: sorted(D.basis()) - [1, P(1), P(2), Q_0, Q_0 P(1), Q_0 P(2), Q_0 Q_1, Q_0 Q_1 P(1), Q_0 Q_1 P(2), Q_1, Q_1 P(1), Q_1 P(2)] + [1, P(1), P(2), Q_0, Q_0 P(1), Q_0 P(2), Q_0 Q_1, + Q_0 Q_1 P(1), Q_0 Q_1 P(2), Q_1, Q_1 P(1), Q_1 P(2)] """ from sage.sets.family import Family if d is None: @@ -2573,7 +2576,7 @@ def pst(self,s,t): def ngens(self): r""" - Number of generators of self. + Number of generators of ``self``. OUTPUT: number or Infinity @@ -2601,7 +2604,7 @@ def ngens(self): 3 sage: SteenrodAlgebra(profile=[3,2,1], basis='pst').ngens() 3 - sage: SteenrodAlgebra(p=3, profile=[[3,2,1], [2,2,2,2]]).ngens() # A(3) at p=3 + sage: SteenrodAlgebra(p=3, profile=[[3,2,1], [2,2,2,2]]).ngens() # A(3) at p=3 4 sage: SteenrodAlgebra(profile=[1,2,1,1]).ngens() 5 @@ -2647,7 +2650,8 @@ def gens(self): sage: A3 = SteenrodAlgebra(3, 'adem') sage: A3.gens() - Lazy family ((i))_{i in Non negative integers} + Lazy family ((i))_{i in Non negative integers} sage: A3.gens()[0] beta sage: A3.gens()[1] @@ -2666,7 +2670,9 @@ def gens(self): sage: SteenrodAlgebra(p=5, profile=[[2,1], [2,2,2]]).gens() Family (Q_0, P(1), P(5)) sage: SteenrodAlgebra(profile=lambda n: n).gens() - Lazy family ((i))_{i in Non negative integers} + Lazy family ((i))_{i in Non negative integers} You may also use ``algebra_generators`` instead of ``gens``:: @@ -2932,16 +2938,16 @@ def top_class(self): EXAMPLES:: - sage: SteenrodAlgebra(2,profile=(3,2,1)).top_class() + sage: SteenrodAlgebra(2, profile=(3,2,1)).top_class() Sq(7,3,1) - sage: SteenrodAlgebra(3,profile=((2,2,1),(1,2,2,2,2))).top_class() + sage: SteenrodAlgebra(3, profile=((2,2,1),(1,2,2,2,2))).top_class() Q_1 Q_2 Q_3 Q_4 P(8,8,2) TESTS:: - sage: SteenrodAlgebra(2,profile=(3,2,1),basis='pst').top_class() + sage: SteenrodAlgebra(2, profile=(3,2,1), basis='pst').top_class() P^0_1 P^0_2 P^1_1 P^0_3 P^1_2 P^2_1 - sage: SteenrodAlgebra(5,profile=((0,),(2,1,2,2))).top_class() + sage: SteenrodAlgebra(5, profile=((0,),(2,1,2,2))).top_class() Q_0 Q_2 Q_3 sage: SteenrodAlgebra(5).top_class() Traceback (most recent call last): @@ -2953,12 +2959,12 @@ def top_class(self): but far from optimal for the 'pst' basis. Occasionally, it also gives an awkward leading coefficient:: - sage: SteenrodAlgebra(3,profile=((2,1),(1,2,2)),basis='pst').top_class() + sage: SteenrodAlgebra(3, profile=((2,1),(1,2,2)), basis='pst').top_class() 2 Q_1 Q_2 (P^0_1)^2 (P^0_2)^2 (P^1_1)^2 TESTS:: - sage: A=SteenrodAlgebra(2,profile=(3,2,1),basis='pst') + sage: A=SteenrodAlgebra(2, profile=(3,2,1), basis='pst') sage: A.top_class().parent() is A True """ @@ -3080,7 +3086,7 @@ def is_generic(self): True sage: SteenrodAlgebra(2).is_generic() False - sage: SteenrodAlgebra(2,generic=True).is_generic() + sage: SteenrodAlgebra(2, generic=True).is_generic() True """ return self._generic @@ -4146,7 +4152,8 @@ def SteenrodAlgebra(p=2, basis='milnor', generic='auto', **kwds): sage: EA = SteenrodAlgebra(p=2,generic=True) ; EA generic mod 2 Steenrod algebra, milnor basis sage: EA[8] - Vector space spanned by (Q_0 Q_2, Q_0 Q_1 P(2), P(1,1), P(4)) over Finite Field of size 2 + Vector space spanned by (Q_0 Q_2, Q_0 Q_1 P(2), P(1,1), P(4)) + over Finite Field of size 2 TESTS: @@ -4201,9 +4208,11 @@ def AA(n=None, p=2): sage: A() mod 2 Steenrod algebra, milnor basis sage: A(2) - sub-Hopf algebra of mod 2 Steenrod algebra, milnor basis, profile function [3, 2, 1] + sub-Hopf algebra of mod 2 Steenrod algebra, milnor basis, + profile function [3, 2, 1] sage: A(2, p=5) - sub-Hopf algebra of mod 5 Steenrod algebra, milnor basis, profile function ([2, 1], [2, 2, 2]) + sub-Hopf algebra of mod 5 Steenrod algebra, milnor basis, + profile function ([2, 1], [2, 2, 2]) """ if n is None: return SteenrodAlgebra(p=p) diff --git a/src/sage/algebras/steenrod/steenrod_algebra_bases.py b/src/sage/algebras/steenrod/steenrod_algebra_bases.py index c289b284fe1..9c8cc0935c8 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra_bases.py +++ b/src/sage/algebras/steenrod/steenrod_algebra_bases.py @@ -20,29 +20,29 @@ Monks [Mon1998]_ and Wood [Woo1998]_ for more information about them. For commutator bases, see the preprint by Palmieri and Zhang [PZ2008]_. -- 'milnor': Milnor basis. +- ``'milnor'``: Milnor basis. -- 'serre-cartan' or 'adem' or 'admissible': Serre-Cartan basis. +- ``'serre-cartan'`` or ``'adem'`` or ``'admissible'``: Serre-Cartan basis. Most of the rest of the bases are only defined when `p=2`. The only exceptions are the `P^s_t`-bases and the commutator bases, which are defined at all primes. -- 'wood_y': Wood's Y basis. +- ``'wood_y'``: Wood's Y basis. -- 'wood_z': Wood's Z basis. +- ``'wood_z'``: Wood's Z basis. -- 'wall', 'wall_long': Wall's basis. +- ``'wall'``, ``'wall_long'``: Wall's basis. -- 'arnon_a', 'arnon_a_long': Arnon's A basis. +- ``'arnon_a'``, ``'arnon_a_long'``: Arnon's A basis. -- 'arnon_c': Arnon's C basis. +- ``'arnon_c'``: Arnon's C basis. -- 'pst', 'pst_rlex', 'pst_llex', 'pst_deg', 'pst_revz': +- ``'pst'``, ``'pst_rlex'``, ``'pst_llex'``, ``'pst_deg'``, ``'pst_revz'``: various `P^s_t`-bases. -- 'comm', 'comm_rlex', 'comm_llex', 'comm_deg', 'comm_revz', - or these with '_long' appended: various commutator bases. +- ``'comm'``, ``'comm_rlex'``, ``'comm_llex'``, ``'comm_deg'``, ``'comm_revz'``, + or these with ``'_long'`` appended: various commutator bases. The main functions provided here are @@ -121,23 +121,24 @@ def convert_to_milnor_matrix(n, basis, p=2, generic='auto'): INPUT: - - ``n`` - non-negative integer, the dimension - - ``basis`` - string, the basis from which to convert - - ``p`` - positive prime number (optional, default 2) + - ``n`` -- non-negative integer, the dimension + - ``basis`` -- string, the basis from which to convert + - ``p`` -- positive prime number (optional, default 2) OUTPUT: - ``matrix`` - change-of-basis matrix, a square matrix over ``GF(p)`` + ``matrix`` -- change-of-basis matrix, a square matrix over `\GF{p}` EXAMPLES:: + sage: # needs sage.modules sage: from sage.algebras.steenrod.steenrod_algebra_bases import convert_to_milnor_matrix - sage: convert_to_milnor_matrix(5, 'adem') # indirect doctest + sage: convert_to_milnor_matrix(5, 'adem') # indirect doctest [0 1] [1 1] sage: convert_to_milnor_matrix(45, 'milnor') 111 x 111 dense matrix over Finite Field of size 2 (use the '.str()' method to see the entries) - sage: convert_to_milnor_matrix(12,'wall') + sage: convert_to_milnor_matrix(12, 'wall') [1 0 0 1 0 0 0] [1 1 0 0 0 1 0] [0 1 0 1 0 0 0] @@ -149,15 +150,16 @@ def convert_to_milnor_matrix(n, basis, p=2, generic='auto'): The function takes an optional argument, the prime `p` over which to work:: - sage: convert_to_milnor_matrix(17,'adem',3) + sage: # needs sage.modules + sage: convert_to_milnor_matrix(17, 'adem', 3) [0 0 1 1] [0 0 0 1] [1 1 1 1] [0 1 0 1] - sage: convert_to_milnor_matrix(48,'adem',5) + sage: convert_to_milnor_matrix(48, 'adem', 5) [0 1] [1 1] - sage: convert_to_milnor_matrix(36,'adem',3) + sage: convert_to_milnor_matrix(36, 'adem', 3) [0 0 1] [0 1 0] [1 2 0] @@ -182,20 +184,19 @@ def convert_to_milnor_matrix(n, basis, p=2, generic='auto'): def convert_from_milnor_matrix(n, basis, p=2, generic='auto'): r""" - Change-of-basis matrix, Milnor to 'basis', in dimension - `n`. + Change-of-basis matrix, Milnor to ``basis``, in dimension `n`. INPUT: - - ``n`` - non-negative integer, the dimension + - ``n`` -- non-negative integer, the dimension - - ``basis`` - string, the basis to which to convert + - ``basis`` -- string, the basis to which to convert - - ``p`` - positive prime number (optional, default 2) + - ``p`` -- positive prime number (optional, default 2) OUTPUT: - ``matrix`` - change-of-basis matrix, a square matrix over GF(p) + ``matrix`` -- change-of-basis matrix, a square matrix over `\GF{p}` .. note:: @@ -205,8 +206,9 @@ def convert_from_milnor_matrix(n, basis, p=2, generic='auto'): EXAMPLES:: + sage: # needs sage.modules sage: from sage.algebras.steenrod.steenrod_algebra_bases import convert_from_milnor_matrix, convert_to_milnor_matrix - sage: convert_from_milnor_matrix(12,'wall') + sage: convert_from_milnor_matrix(12, 'wall') [1 0 0 1 0 0 0] [0 0 1 1 0 0 0] [0 0 0 1 0 1 1] @@ -214,10 +216,10 @@ def convert_from_milnor_matrix(n, basis, p=2, generic='auto'): [1 0 1 0 1 0 0] [1 1 1 0 0 0 0] [1 0 1 0 1 0 1] - sage: convert_from_milnor_matrix(38,'serre_cartan') + sage: convert_from_milnor_matrix(38, 'serre_cartan') 72 x 72 dense matrix over Finite Field of size 2 (use the '.str()' method to see the entries) - sage: x = convert_to_milnor_matrix(20,'wood_y') - sage: y = convert_from_milnor_matrix(20,'wood_y') + sage: x = convert_to_milnor_matrix(20, 'wood_y') + sage: y = convert_from_milnor_matrix(20, 'wood_y') sage: x*y [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] @@ -240,7 +242,7 @@ def convert_from_milnor_matrix(n, basis, p=2, generic='auto'): The function takes an optional argument, the prime `p` over which to work:: - sage: convert_from_milnor_matrix(17,'adem',3) + sage: convert_from_milnor_matrix(17, 'adem', 3) # needs sage.modules [2 1 1 2] [0 2 0 1] [1 2 0 0] @@ -259,17 +261,17 @@ def steenrod_algebra_basis(n, basis='milnor', p=2, **kwds): INPUT: - - ``n`` - non-negative integer - - ``basis`` - string, which basis to use (optional, default = 'milnor') - - ``p`` - positive prime number (optional, default = 2) - - ``profile`` - profile function (optional, default None). This + - ``n`` -- non-negative integer + - ``basis`` -- string, which basis to use (optional, default: ``'milnor'``) + - ``p`` -- positive prime number (optional, default: 2) + - ``profile`` -- profile function (optional, default: ``None``). This is just passed on to the functions :func:`milnor_basis` and :func:`pst_basis`. - - ``truncation_type`` - truncation type, either 0 or Infinity + - ``truncation_type`` -- truncation type, either 0 or Infinity (optional, default Infinity if no profile function is specified, 0 otherwise). This is just passed on to the function :func:`milnor_basis`. - - ``generic`` - boolean (optional, default = None) + - ``generic`` -- boolean (optional, default: ``None``) OUTPUT: @@ -280,25 +282,25 @@ def steenrod_algebra_basis(n, basis='milnor', p=2, **kwds): documentation for :mod:`sage.algebras.steenrod.steenrod_algebra` for details on each basis: - - 'milnor': Milnor basis. - - 'serre-cartan' or 'adem' or 'admissible': Serre-Cartan basis. - - 'pst', 'pst_rlex', 'pst_llex', 'pst_deg', 'pst_revz': + - ``'milnor'``: Milnor basis. + - ``'serre-cartan'`` or ``'adem'`` or ``'admissible'``: Serre-Cartan basis. + - ``'pst'``, ``'pst_rlex'``, ``'pst_llex'``, ``'pst_deg'``, ``'pst_revz'``: various `P^s_t`-bases. - - 'comm', 'comm_rlex', 'comm_llex', 'comm_deg', 'comm_revz', or - any of these with '_long' appended: various commutator bases. + - ``'comm'``, ``'comm_rlex'``, ``'comm_llex'``, ``'comm_deg'``, ``'comm_revz'``, or + any of these with ``'_long'`` appended: various commutator bases. The rest of these bases are only defined when `p=2`. - - 'wood_y': Wood's Y basis. - - 'wood_z': Wood's Z basis. - - 'wall' or 'wall_long': Wall's basis. - - 'arnon_a' or 'arnon_a_long': Arnon's A basis. - - 'arnon_c': Arnon's C basis. + - ``'wood_y'``: Wood's Y basis. + - ``'wood_z'``: Wood's Z basis. + - ``'wall'`` or ``'wall_long'``: Wall's basis. + - ``'arnon_a'`` or ``'arnon_a_long'``: Arnon's A basis. + - ``'arnon_c'``: Arnon's C basis. EXAMPLES:: sage: from sage.algebras.steenrod.steenrod_algebra_bases import steenrod_algebra_basis - sage: steenrod_algebra_basis(7,'milnor') # indirect doctest + sage: steenrod_algebra_basis(7, 'milnor') # indirect doctest ((0, 0, 1), (1, 2), (4, 1), (7,)) sage: steenrod_algebra_basis(5) # milnor basis is the default ((2, 1), (5,)) @@ -320,15 +322,15 @@ def steenrod_algebra_basis(n, basis='milnor', p=2, **kwds): Other bases:: - sage: steenrod_algebra_basis(7,'admissible') + sage: steenrod_algebra_basis(7, 'admissible') ((7,), (6, 1), (4, 2, 1), (5, 2)) - sage: steenrod_algebra_basis(13,'admissible',p=3) + sage: steenrod_algebra_basis(13, 'admissible', p=3) ((1, 3, 0), (0, 3, 1)) - sage: steenrod_algebra_basis(5,'wall') + sage: steenrod_algebra_basis(5, 'wall') (((2, 2), (0, 0)), ((1, 1), (1, 0))) - sage: steenrod_algebra_basis(5,'wall_long') + sage: steenrod_algebra_basis(5, 'wall_long') (((2, 2), (0, 0)), ((1, 1), (1, 0))) - sage: steenrod_algebra_basis(5,'pst-rlex') + sage: steenrod_algebra_basis(5, 'pst-rlex') (((0, 1), (2, 1)), ((1, 1), (0, 2))) """ from .steenrod_algebra_misc import get_basis_name @@ -375,14 +377,14 @@ def steenrod_algebra_basis(n, basis='milnor', p=2, **kwds): def restricted_partitions(n, l, no_repeats=False): """ - List of 'restricted' partitions of n: partitions with parts taken - from list. + List of 'restricted' partitions of `n`: partitions with parts taken + from list `l`. INPUT: - - ``n`` - non-negative integer - - ``l`` - list of positive integers - - ``no_repeats`` - boolean (optional, default = False), if True, + - ``n`` -- non-negative integer + - ``l`` -- list of positive integers + - ``no_repeats`` -- boolean (optional, default: ``False``), if ``True``, only return partitions with no repeated parts OUTPUT: list of lists @@ -406,10 +408,10 @@ def restricted_partitions(n, l, no_repeats=False): sage: restricted_partitions(10, [6,4,2], no_repeats=True) [[6, 4]] - 'l' may have repeated elements. If 'no_repeats' is False, this - has no effect. If 'no_repeats' is True, and if the repeated - elements appear consecutively in 'l', then each element may be - used only as many times as it appears in 'l':: + ``l`` may have repeated elements. If ``no_repeats`` is ``False``, this + has no effect. If ``no_repeats`` is ``True``, and if the repeated + elements appear consecutively in ``l``, then each element may be + used only as many times as it appears in ``l``:: sage: restricted_partitions(10, [6,4,2,2], no_repeats=True) [[6, 4], [6, 2, 2]] @@ -420,7 +422,7 @@ def restricted_partitions(n, l, no_repeats=False): are likely meaningless, containing several partitions more than once, for example.) - In the following examples, 'no_repeats' is False:: + In the following examples, ``no_repeats`` is ``False``:: sage: restricted_partitions(10, [6,4,2]) [[6, 4], [6, 2, 2], [4, 4, 2], [4, 2, 2, 2], [2, 2, 2, 2, 2]] @@ -448,25 +450,25 @@ def restricted_partitions(n, l, no_repeats=False): old_i = i return results -def xi_degrees(n,p=2, reverse=True): +def xi_degrees(n, p=2, reverse=True): r""" - Decreasing list of degrees of the xi_i's, starting in degree n. + Decreasing list of degrees of the `\xi_i`'s, starting in degree `n`. INPUT: - - `n` - integer - - `p` - prime number, optional (default 2) - - ``reverse`` - bool, optional (default True) + - ``n`` -- integer + - ``p`` -- prime number, optional (default: 2) + - ``reverse`` -- bool, optional (default: ``True``) - OUTPUT: ``list`` - list of integers + OUTPUT: ``list`` -- list of integers When `p=2`: decreasing list of the degrees of the `\xi_i`'s with - degree at most n. + degree at most `n`. At odd primes: decreasing list of these degrees, each divided by `2(p-1)`. - If ``reverse`` is False, then return an increasing list rather + If ``reverse`` is ``False``, then return an increasing list rather than a decreasing one. EXAMPLES:: @@ -475,9 +477,9 @@ def xi_degrees(n,p=2, reverse=True): [15, 7, 3, 1] sage: sage.algebras.steenrod.steenrod_algebra_bases.xi_degrees(17, reverse=False) [1, 3, 7, 15] - sage: sage.algebras.steenrod.steenrod_algebra_bases.xi_degrees(17,p=3) + sage: sage.algebras.steenrod.steenrod_algebra_bases.xi_degrees(17, p=3) [13, 4, 1] - sage: sage.algebras.steenrod.steenrod_algebra_bases.xi_degrees(400,p=17) + sage: sage.algebras.steenrod.steenrod_algebra_bases.xi_degrees(400, p=17) [307, 18, 1] """ from sage.rings.integer import Integer @@ -505,23 +507,23 @@ def milnor_basis(n, p=2, **kwds): INPUT: - - ``n`` - non-negative integer + - ``n`` -- non-negative integer - - ``p`` - positive prime number (optional, default 2) + - ``p`` -- positive prime number (optional, default 2) - - ``profile`` - profile function (optional, default None). + - ``profile`` - profile function (optional, default ``None``). Together with ``truncation_type``, specify the profile function - to be used; None means the profile function for the entire + to be used; ``None`` means the profile function for the entire Steenrod algebra. See :mod:`sage.algebras.steenrod.steenrod_algebra` and :func:`SteenrodAlgebra ` for information on profile functions. - - ``truncation_type`` - truncation type, either 0 or Infinity + - ``truncation_type`` -- truncation type, either 0 or Infinity (optional, default Infinity if no profile function is specified, 0 otherwise) - OUTPUT: tuple of mod p Milnor basis elements in dimension n + OUTPUT: tuple of mod `p` Milnor basis elements in dimension `n` At the prime 2, the Milnor basis consists of symbols of the form `\text{Sq}(m_1, m_2, ..., m_t)`, where each @@ -669,11 +671,11 @@ def serre_cartan_basis(n, p=2, bound=1, **kwds): INPUT: - - ``n`` - non-negative integer - - ``bound`` - positive integer (optional) - - ``prime`` - positive prime number (optional, default 2) + - ``n`` -- non-negative integer + - ``bound`` -- positive integer (optional) + - ``prime`` -- positive prime number (optional, default 2) - OUTPUT: tuple of mod p Serre-Cartan basis elements in dimension n + OUTPUT: tuple of mod `p` Serre-Cartan basis elements in dimension `n` The Serre-Cartan basis consists of 'admissible monomials in the Steenrod squares'. Thus at the prime 2, it consists of monomials @@ -694,8 +696,8 @@ def serre_cartan_basis(n, p=2, bound=1, **kwds): ((1, 5, 0, 1, 1), (1, 6, 1)) If optional argument ``bound`` is present, include only those monomials - whose last term is at least ``bound`` (when p=2), or those for which - `s_k - e_k \geq bound` (when p is odd). :: + whose last term is at least ``bound`` (when `p=2`), or those for which + `s_k - e_k \geq bound` (when `p` is odd). :: sage: serre_cartan_basis(7, bound=2) ((7,), (5, 2)) @@ -753,27 +755,28 @@ def atomic_basis(n, basis, **kwds): INPUT: - - ``n`` - non-negative integer - - ``basis`` - string, the name of the basis + - ``n`` -- non-negative integer - - ``profile`` - profile function (optional, default None). + - ``basis`` -- string, the name of the basis + + - ``profile`` -- profile function (optional, default: ``None``). Together with ``truncation_type``, specify the profile function - to be used; None means the profile function for the entire + to be used; ``None`` means the profile function for the entire Steenrod algebra. See :mod:`sage.algebras.steenrod.steenrod_algebra` and :func:`SteenrodAlgebra` for information on profile functions. - - ``truncation_type`` - truncation type, either 0 or Infinity + - ``truncation_type`` -- truncation type, either 0 or Infinity (optional, default Infinity if no profile function is specified, 0 otherwise). - OUTPUT: tuple of basis elements in dimension n + OUTPUT: tuple of basis elements in dimension `n` The atomic bases include Wood's Y and Z bases, Wall's basis, Arnon's A basis, the `P^s_t`-bases, and the commutator bases. (All of these bases are constructed similarly, hence their constructions have been consolidated into a single function. Also, - see the documentation for 'steenrod_algebra_basis' for + see the documentation for :func:`steenrod_algebra_basis` for descriptions of them.) For `P^s_t`-bases, you may also specify a profile function and truncation type; profile functions are ignored for the other bases. @@ -824,12 +827,12 @@ def atomic_basis(n, basis, **kwds): """ def degree_dictionary(n, basis): """ - Dictionary of atomic degrees for basis up to degree n. + Dictionary of atomic degrees for basis up to degree `n`. - The keys for the dictionary are the atomic degrees - the numbers of - the form 2^i (2^j - 1) - which are less than or equal to n. The value + The keys for the dictionary are the atomic degrees -- the numbers of + the form `2^i (2^j - 1)` -- which are less than or equal to `n`. The value associated to such a degree depends on basis; it has the form - (s,t), where (s,t) is a pair of integers which indexes the + `(s,t)`, where `(s,t)` is a pair of integers which indexes the corresponding element. """ dict = {} @@ -931,11 +934,11 @@ def arnonC_basis(n,bound=1): INPUT: - - ``n`` - non-negative integer + - ``n`` -- non-negative integer - - ``bound`` - positive integer (optional) + - ``bound`` -- positive integer (optional) - OUTPUT: tuple of basis elements in dimension n + OUTPUT: tuple of basis elements in dimension `n` The elements of Arnon's C basis are monomials of the form `\text{Sq}^{t_1} ... \text{Sq}^{t_m}` where for each @@ -978,22 +981,24 @@ def atomic_basis_odd(n, basis, p, **kwds): INPUT: - - ``n`` - non-negative integer - - ``basis`` - string, the name of the basis - - ``p`` - positive prime number + - ``n`` -- non-negative integer + + - ``basis`` -- string, the name of the basis + + - ``p`` -- positive prime number - - ``profile`` - profile function (optional, default None). + - ``profile`` -- profile function (optional, default: ``None``). Together with ``truncation_type``, specify the profile function - to be used; None means the profile function for the entire + to be used; ``None`` means the profile function for the entire Steenrod algebra. See :mod:`sage.algebras.steenrod.steenrod_algebra` and :func:`SteenrodAlgebra` for information on profile functions. - - ``truncation_type`` - truncation type, either 0 or Infinity + - ``truncation_type`` -- truncation type, either 0 or Infinity (optional, default Infinity if no profile function is specified, 0 otherwise). - OUTPUT: tuple of basis elements in dimension n + OUTPUT: tuple of basis elements in dimension `n` The only possible difference in the implementations for `P^s_t` bases and commutator bases is that the former make sense, and @@ -1091,8 +1096,8 @@ def steenrod_basis_error_check(dim, p, **kwds): INPUT: - - ``dim`` - non-negative integer - - ``p`` - positive prime number + - ``dim`` -- non-negative integer + - ``p`` -- positive prime number OUTPUT: None @@ -1100,7 +1105,7 @@ def steenrod_basis_error_check(dim, p, **kwds): if the change-of-basis matrices are invertible. If something goes wrong, an error message is printed. - This function checks at the prime ``p`` as the dimension goes up + This function checks at the prime `p` as the dimension goes up from 0 to ``dim``. If you set the Sage verbosity level to a positive integer (using @@ -1108,11 +1113,12 @@ def steenrod_basis_error_check(dim, p, **kwds): EXAMPLES:: + sage: # long time sage: from sage.algebras.steenrod.steenrod_algebra_bases import steenrod_basis_error_check - sage: steenrod_basis_error_check(15,2) # long time - sage: steenrod_basis_error_check(15,2,generic=True) # long time - sage: steenrod_basis_error_check(40,3) # long time - sage: steenrod_basis_error_check(80,5) # long time + sage: steenrod_basis_error_check(15, 2) + sage: steenrod_basis_error_check(15, 2, generic=True) + sage: steenrod_basis_error_check(40, 3) + sage: steenrod_basis_error_check(80, 5) """ from sage.misc.verbose import verbose generic = kwds.get('generic', p != 2) diff --git a/src/sage/algebras/steenrod/steenrod_algebra_mult.py b/src/sage/algebras/steenrod/steenrod_algebra_mult.py index 1fb52aba028..e2d48f616b7 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra_mult.py +++ b/src/sage/algebras/steenrod/steenrod_algebra_mult.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings r""" Multiplication for elements of the Steenrod algebra diff --git a/src/sage/algebras/tensor_algebra.py b/src/sage/algebras/tensor_algebra.py index 664027ee6ae..a14ab916336 100644 --- a/src/sage/algebras/tensor_algebra.py +++ b/src/sage/algebras/tensor_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Tensor Algebras diff --git a/src/sage/algebras/weyl_algebra.py b/src/sage/algebras/weyl_algebra.py index 13604578430..b033a24065c 100644 --- a/src/sage/algebras/weyl_algebra.py +++ b/src/sage/algebras/weyl_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Weyl Algebras @@ -53,12 +54,12 @@ def repr_from_monomials(monomials, term_repr, use_latex=False): sage: from sage.algebras.weyl_algebra import repr_from_monomials sage: R. = QQ[] - sage: d = [(z, 4/7), (y, sqrt(2)), (x, -5)] - sage: repr_from_monomials(d, lambda m: repr(m)) + sage: d = [(z, 4/7), (y, sqrt(2)), (x, -5)] # needs sage.symbolic + sage: repr_from_monomials(d, lambda m: repr(m)) # needs sage.symbolic '4/7*z + sqrt(2)*y - 5*x' - sage: a = repr_from_monomials(d, lambda m: latex(m), True); a + sage: a = repr_from_monomials(d, lambda m: latex(m), True); a # needs sage.symbolic \frac{4}{7} z + \sqrt{2} y - 5 x - sage: type(a) + sage: type(a) # needs sage.symbolic The zero element:: @@ -90,6 +91,7 @@ def repr_from_monomials(monomials, term_repr, use_latex=False): Leading minus signs are dealt with appropriately:: + sage: # needs sage.symbolic sage: d = [(z, -4/7), (y, -sqrt(2)), (x, -5)] sage: repr_from_monomials(d, lambda m: repr(m)) '-4/7*z - sqrt(2)*y - 5*x' diff --git a/src/sage/algebras/yangian.py b/src/sage/algebras/yangian.py index 55bb61fccf5..8e19b92ba07 100644 --- a/src/sage/algebras/yangian.py +++ b/src/sage/algebras/yangian.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Yangians diff --git a/src/sage/algebras/yokonuma_hecke_algebra.py b/src/sage/algebras/yokonuma_hecke_algebra.py index df474b8d4f7..779beb95ffe 100644 --- a/src/sage/algebras/yokonuma_hecke_algebra.py +++ b/src/sage/algebras/yokonuma_hecke_algebra.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules """ Yokonuma-Hecke Algebras