diff --git a/bootstrap b/bootstrap index 5156f369c38..aa5755cfc63 100755 --- a/bootstrap +++ b/bootstrap @@ -98,8 +98,8 @@ SAGE_SPKG_CONFIGURE_$(echo ${pkgname} | tr '[a-z]' '[A-Z]')" if test -f "$DIR/requirements.txt" -o -f "$DIR/install-requires.txt"; then # A Python package SPKG_TREE_VAR=SAGE_VENV - echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions.m4 - echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires-toml ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions_toml.m4 + echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(ENABLE_SYSTEM_SITE_PACKAGES=yes sage-get-system-packages install-requires ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions.m4 + echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(ENABLE_SYSTEM_SITE_PACKAGES=yes sage-get-system-packages install-requires-toml ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions_toml.m4 fi fi spkg_configures="$spkg_configures diff --git a/build/pkgs/setuptools_wheel/install-requires.txt b/build/pkgs/setuptools_wheel/install-requires.txt index d1dc532ceab..d3767a68c8f 100644 --- a/build/pkgs/setuptools_wheel/install-requires.txt +++ b/build/pkgs/setuptools_wheel/install-requires.txt @@ -1 +1 @@ -# We use this file to mark the package as a Python package +setuptools >= 65.6 diff --git a/pkgs/sagemath-bliss/pyproject.toml.m4 b/pkgs/sagemath-bliss/pyproject.toml.m4 index 439482ad26b..1cbcdf7e162 100644 --- a/pkgs/sagemath-bliss/pyproject.toml.m4 +++ b/pkgs/sagemath-bliss/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_conf SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment diff --git a/pkgs/sagemath-categories/pyproject.toml.m4 b/pkgs/sagemath-categories/pyproject.toml.m4 index 6ce29ddcb71..cf4c97f1fd1 100644 --- a/pkgs/sagemath-categories/pyproject.toml.m4 +++ b/pkgs/sagemath-categories/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment diff --git a/pkgs/sagemath-coxeter3/pyproject.toml.m4 b/pkgs/sagemath-coxeter3/pyproject.toml.m4 index e5b939e414d..a7d65382b21 100644 --- a/pkgs/sagemath-coxeter3/pyproject.toml.m4 +++ b/pkgs/sagemath-coxeter3/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-environment/pyproject.toml.m4 b/pkgs/sagemath-environment/pyproject.toml.m4 index 7f62a86cd69..fb2db955ed5 100644 --- a/pkgs/sagemath-environment/pyproject.toml.m4 +++ b/pkgs/sagemath-environment/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_wheel ] build-backend = "setuptools.build_meta" diff --git a/pkgs/sagemath-mcqd/pyproject.toml.m4 b/pkgs/sagemath-mcqd/pyproject.toml.m4 index d28ff179a00..7e651119193 100644 --- a/pkgs/sagemath-mcqd/pyproject.toml.m4 +++ b/pkgs/sagemath-mcqd/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-meataxe/pyproject.toml.m4 b/pkgs/sagemath-meataxe/pyproject.toml.m4 index e5b939e414d..a7d65382b21 100644 --- a/pkgs/sagemath-meataxe/pyproject.toml.m4 +++ b/pkgs/sagemath-meataxe/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-objects/pyproject.toml.m4 b/pkgs/sagemath-objects/pyproject.toml.m4 index 0c5558f3412..d8fda57a8f8 100644 --- a/pkgs/sagemath-objects/pyproject.toml.m4 +++ b/pkgs/sagemath-objects/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment diff --git a/pkgs/sagemath-repl/pyproject.toml.m4 b/pkgs/sagemath-repl/pyproject.toml.m4 index 7f62a86cd69..fb2db955ed5 100644 --- a/pkgs/sagemath-repl/pyproject.toml.m4 +++ b/pkgs/sagemath-repl/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_wheel ] build-backend = "setuptools.build_meta" diff --git a/pkgs/sagemath-sirocco/pyproject.toml.m4 b/pkgs/sagemath-sirocco/pyproject.toml.m4 index 1b000bd5c3b..99894dd5e5e 100644 --- a/pkgs/sagemath-sirocco/pyproject.toml.m4 +++ b/pkgs/sagemath-sirocco/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-tdlib/pyproject.toml.m4 b/pkgs/sagemath-tdlib/pyproject.toml.m4 index e5b939e414d..a7d65382b21 100644 --- a/pkgs/sagemath-tdlib/pyproject.toml.m4 +++ b/pkgs/sagemath-tdlib/pyproject.toml.m4 @@ -2,7 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- [build-system] # Minimum requirements for the build system to execute. requires = [ - SPKG_INSTALL_REQUIRES_setuptools + SPKG_INSTALL_REQUIRES_setuptools_wheel SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython diff --git a/src/pyproject.toml.m4 b/src/pyproject.toml.m4 index 56f1b2b03ab..f707b6f890e 100644 --- a/src/pyproject.toml.m4 +++ b/src/pyproject.toml.m4 @@ -6,7 +6,7 @@ requires = [ # https://github.com/pypa/pip/issues/6144 esyscmd(`sage-get-system-packages install-requires-toml \ sage_conf \ - setuptools \ + setuptools_wheel \ wheel \ sage_setup \ cypari \ diff --git a/src/sage/combinat/root_system/coxeter_group.py b/src/sage/combinat/root_system/coxeter_group.py index 33c8858d5f8..f33003b35f6 100644 --- a/src/sage/combinat/root_system/coxeter_group.py +++ b/src/sage/combinat/root_system/coxeter_group.py @@ -9,9 +9,11 @@ # https://www.gnu.org/licenses/ # *************************************************************************** -from sage.combinat.root_system.weyl_group import WeylGroup -from sage.combinat.root_system.reflection_group_real import ReflectionGroup from sage.combinat.root_system.cartan_type import CartanType +from sage.misc.lazy_import import lazy_import + +lazy_import('from sage.combinat.root_system.reflection_group_real', 'ReflectionGroup') +lazy_import('sage.combinat.root_system.weyl_group', 'WeylGroup') def CoxeterGroup(data, implementation="reflection", base_ring=None, index_set=None): diff --git a/src/sage/groups/abelian_gps/abelian_group.py b/src/sage/groups/abelian_gps/abelian_group.py index f2d088adbf4..a72ad3e180c 100644 --- a/src/sage/groups/abelian_gps/abelian_group.py +++ b/src/sage/groups/abelian_gps/abelian_group.py @@ -254,35 +254,38 @@ def word_problem(words, g, verbose=False): EXAMPLES:: - sage: G. = AbelianGroup(3,[2,3,4]); G + sage: # needs sage.libs.gap + sage: G. = AbelianGroup(3, [2,3,4]); G Multiplicative Abelian group isomorphic to C2 x C3 x C4 - sage: w = word_problem([a*b,a*c], b*c); w #random + sage: w = word_problem([a*b,a*c], b*c); w # random [[a*b, 1], [a*c, 1]] sage: prod([x^i for x,i in w]) == b*c True - sage: w = word_problem([a*c,c],a); w #random + sage: w = word_problem([a*c,c], a); w # random [[a*c, 1], [c, -1]] sage: prod([x^i for x,i in w]) == a True - sage: word_problem([a*c,c],a,verbose=True) #random + sage: word_problem([a*c,c], a, verbose=True) # random a = (a*c)^1*(c)^-1 [[a*c, 1], [c, -1]] :: - sage: A. = AbelianGroup(5,[4, 5, 5, 7, 8]) + sage: # needs sage.libs.gap + sage: A. = AbelianGroup(5, [4, 5, 5, 7, 8]) sage: b1 = a^3*b*c*d^2*e^5 sage: b2 = a^2*b*c^2*d^3*e^3 sage: b3 = a^7*b^3*c^5*d^4*e^4 sage: b4 = a^3*b^2*c^2*d^3*e^5 sage: b5 = a^2*b^4*c^2*d^4*e^5 - sage: w = word_problem([b1,b2,b3,b4,b5],e); w #random - [[a^3*b*c*d^2*e^5, 1], [a^2*b*c^2*d^3*e^3, 1], [a^3*b^3*d^4*e^4, 3], [a^2*b^4*c^2*d^4*e^5, 1]] + sage: w = word_problem([b1,b2,b3,b4,b5], e); w # random + [[a^3*b*c*d^2*e^5, 1], [a^2*b*c^2*d^3*e^3, 1], + [a^3*b^3*d^4*e^4, 3], [a^2*b^4*c^2*d^4*e^5, 1]] sage: prod([x^i for x,i in w]) == e True - sage: word_problem([a,b,c,d,e],e) + sage: word_problem([a,b,c,d,e], e) [[e, 1]] - sage: word_problem([a,b,c,d,e],b) + sage: word_problem([a,b,c,d,e], b) [[b, 1]] .. warning:: @@ -413,7 +416,7 @@ def AbelianGroup(n, gens_orders=None, names="f"): a^2*b^2*c^2*d^2 sage: d * b**2 * c**3 b^2*c^3*d - sage: F = AbelianGroup(3,[2]*3); F + sage: F = AbelianGroup(3, [2]*3); F Multiplicative Abelian group isomorphic to C2 x C2 x C2 sage: H = AbelianGroup([2,3], names="xy"); H Multiplicative Abelian group isomorphic to C2 x C3 @@ -447,7 +450,7 @@ def is_AbelianGroup(x): EXAMPLES:: sage: from sage.groups.abelian_gps.abelian_group import is_AbelianGroup - sage: F = AbelianGroup(5,[5,5,7,8,9],names = list("abcde")); F + sage: F = AbelianGroup(5,[5,5,7,8,9], names=list("abcde")); F Multiplicative Abelian group isomorphic to C5 x C5 x C7 x C8 x C9 sage: is_AbelianGroup(F) True @@ -487,9 +490,9 @@ class AbelianGroup_class(UniqueRepresentation, AbelianGroupBase): sage: Z2xZ3.is_isomorphic(Z6) True - sage: F = AbelianGroup(5,[5,5,7,8,9],names = list("abcde")); F + sage: F = AbelianGroup(5,[5,5,7,8,9], names=list("abcde")); F Multiplicative Abelian group isomorphic to C5 x C5 x C7 x C8 x C9 - sage: F = AbelianGroup(5,[2, 4, 12, 24, 120],names = list("abcde")); F + sage: F = AbelianGroup(5,[2, 4, 12, 24, 120], names=list("abcde")); F Multiplicative Abelian group isomorphic to C2 x C4 x C12 x C24 x C120 sage: F.elementary_divisors() (2, 4, 12, 24, 120) @@ -516,7 +519,7 @@ def __init__(self, generator_orders, names, category=None): TESTS:: - sage: G = AbelianGroup([0,5,0,7],names = list("abcd")); G + sage: G = AbelianGroup([0,5,0,7], names=list("abcd")); G Multiplicative Abelian group isomorphic to Z x C5 x Z x C7 sage: TestSuite(G).run() @@ -577,8 +580,8 @@ def is_subgroup(left, right): sage: G.is_subgroup(G) True - sage: H = G.subgroup([G.1]) - sage: H.is_subgroup(G) + sage: H = G.subgroup([G.1]) # needs sage.libs.gap + sage: H.is_subgroup(G) # needs sage.libs.gap True sage: G. = AbelianGroup(2) @@ -654,7 +657,7 @@ def __bool__(self) -> bool: EXAMPLES:: sage: T = AbelianGroup([2, 3]) - sage: bool(T) # indirect doctest + sage: bool(T) # indirect doctest True sage: bool(AbelianGroup([])) False @@ -683,11 +686,11 @@ def dual_group(self, names="X", base_ring=None): EXAMPLES:: sage: G = AbelianGroup([2]) - sage: G.dual_group() + sage: G.dual_group() # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/2Z over Cyclotomic Field of order 2 and degree 1 - sage: G.dual_group().gens() + sage: G.dual_group().gens() # needs sage.rings.number_field (X,) - sage: G.dual_group(names='Z').gens() + sage: G.dual_group(names='Z').gens() # needs sage.rings.number_field (Z,) sage: G.dual_group(base_ring=QQ) @@ -736,13 +739,13 @@ def elementary_divisors(self): EXAMPLES:: - sage: G = AbelianGroup(2,[2,3]) + sage: G = AbelianGroup(2, [2,3]) sage: G.elementary_divisors() (6,) sage: G = AbelianGroup(1, [6]) sage: G.elementary_divisors() (6,) - sage: G = AbelianGroup(2,[2,6]) + sage: G = AbelianGroup(2, [2,6]) sage: G Multiplicative Abelian group isomorphic to C2 x C6 sage: G.gens_orders() @@ -752,7 +755,7 @@ def elementary_divisors(self): sage: J = AbelianGroup([1,3,5,12]) sage: J.elementary_divisors() (3, 60) - sage: G = AbelianGroup(2,[0,6]) + sage: G = AbelianGroup(2, [0,6]) sage: G.elementary_divisors() (6, 0) sage: AbelianGroup([3,4,5]).elementary_divisors() @@ -845,12 +848,12 @@ def _libgap_(self): EXAMPLES:: sage: G = AbelianGroup([2,3,9]) - sage: libgap(G) + sage: libgap(G) # needs sage.libs.gap The result is cached:: - sage: libgap(G) is libgap(G) + sage: libgap(G) is libgap(G) # needs sage.libs.gap True Requires the optional ``gap_packages`` for infinite groups:: @@ -878,7 +881,7 @@ def _gap_init_(self): sage: G = AbelianGroup([2,3,9]) sage: G._gap_init_() 'AbelianGroup([2, 3, 9])' - sage: gap(G) + sage: gap(G) # needs sage.libs.gap Group( [ f1, f2, f3 ] ) Requires the optional ``gap_packages`` for infinite groups:: @@ -933,10 +936,10 @@ def gens(self): EXAMPLES:: - sage: F = AbelianGroup(5,[3,2],names='abcde') + sage: F = AbelianGroup(5, [3,2], names='abcde') sage: F.gens() (a, b, c, d, e) - sage: [ g.order() for g in F.gens() ] + sage: [g.order() for g in F.gens()] [+Infinity, +Infinity, +Infinity, 3, 2] """ return tuple( self.gen(i) for i in range(self.ngens()) ) @@ -1059,12 +1062,12 @@ def is_cyclic(self): (2, 4) sage: H.is_cyclic() False - sage: H.permutation_group().is_cyclic() + sage: H.permutation_group().is_cyclic() # needs sage.groups False sage: T = AbelianGroup([]) sage: T.is_cyclic() True - sage: T = AbelianGroup(1,[0]); T + sage: T = AbelianGroup(1, [0]); T Multiplicative Abelian group isomorphic to Z sage: T.is_cyclic() True @@ -1094,10 +1097,10 @@ def order(self): EXAMPLES:: - sage: G = AbelianGroup(2,[2,3]) + sage: G = AbelianGroup(2, [2,3]) sage: G.order() 6 - sage: G = AbelianGroup(3,[2,3,0]) + sage: G = AbelianGroup(3, [2,3,0]) sage: G.order() +Infinity """ @@ -1121,7 +1124,7 @@ def permutation_group(self): sage: G = AbelianGroup(2,[2,3]); G Multiplicative Abelian group isomorphic to C2 x C3 - sage: G.permutation_group() + sage: G.permutation_group() # needs sage.groups Permutation Group with generators [(3,4,5), (1,2)] TESTS: @@ -1198,27 +1201,29 @@ def subgroup(self, gensH, names="f"): INPUT: - ``gensH`` -- list of elements which are products of the - generators of the ambient abelian group G = self + generators of the ambient abelian group `G` = ``self`` EXAMPLES:: - sage: G. = AbelianGroup(3, [2,3,4]); G - Multiplicative Abelian group isomorphic to C2 x C3 x C4 - sage: H = G.subgroup([a*b,a]); H - Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a*b, a} - sage: H < G - True - sage: F = G.subgroup([a,b^2]) - sage: F - Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a, b^2} - sage: F.gens() - (a, b^2) - sage: F = AbelianGroup(5,[30,64,729],names = list("abcde")) - sage: a,b,c,d,e = F.gens() - sage: F.subgroup([a,b]) - Multiplicative Abelian subgroup isomorphic to Z x Z generated by {a, b} - sage: F.subgroup([c,e]) - Multiplicative Abelian subgroup isomorphic to C2 x C3 x C5 x C729 generated by {c, e} + sage: # needs sage.libs.gap + sage: G. = AbelianGroup(3, [2,3,4]); G + Multiplicative Abelian group isomorphic to C2 x C3 x C4 + sage: H = G.subgroup([a*b,a]); H + Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a*b, a} + sage: H < G + True + sage: F = G.subgroup([a,b^2]) + sage: F + Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a, b^2} + sage: F.gens() + (a, b^2) + sage: F = AbelianGroup(5, [30,64,729], names=list("abcde")) + sage: a,b,c,d,e = F.gens() + sage: F.subgroup([a,b]) + Multiplicative Abelian subgroup isomorphic to Z x Z generated by {a, b} + sage: F.subgroup([c,e]) + Multiplicative Abelian subgroup isomorphic to C2 x C3 x C5 x C729 + generated by {c, e} """ G = self gensH = tuple(gensH) @@ -1327,10 +1332,12 @@ def number_of_subgroups(self, order=None): EXAMPLES:: - sage: AbelianGroup([2,3]).number_of_subgroups() - 4 sage: AbelianGroup([2,0,0,3,0]).number_of_subgroups() +Infinity + + sage: # needs sage.combinat + sage: AbelianGroup([2,3]).number_of_subgroups() + 4 sage: AbelianGroup([2,4,8]).number_of_subgroups() 81 sage: AbelianGroup([2,4,8]).number_of_subgroups(order=4) @@ -1344,6 +1351,7 @@ def number_of_subgroups(self, order=None): TESTS:: + sage: # needs sage.combinat sage: AbelianGroup([]).number_of_subgroups() 1 sage: AbelianGroup([1,3,1]).number_of_subgroups() @@ -1352,7 +1360,7 @@ def number_of_subgroups(self, order=None): 0 sage: AbelianGroup([1,3,1]).number_of_subgroups(order=2) 0 - sage: AbelianGroup([1,3,0,1]).number_of_subgroups(order=3) + sage: AbelianGroup([1,3,0,1]).number_of_subgroups(order=3) # needs sage.libs.gap 1 sage: AbelianGroup([1,3,1]).number_of_subgroups(order=-2) Traceback (most recent call last): @@ -1442,12 +1450,12 @@ def subgroups(self, check=False): EXAMPLES:: - sage: AbelianGroup([2,3]).subgroups() + sage: AbelianGroup([2,3]).subgroups() # needs sage.libs.gap [Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {f0*f1^2}, Multiplicative Abelian subgroup isomorphic to C2 generated by {f0}, Multiplicative Abelian subgroup isomorphic to C3 generated by {f1}, Trivial Abelian subgroup] - sage: len(AbelianGroup([2,4,8]).subgroups()) + sage: len(AbelianGroup([2,4,8]).subgroups()) # needs sage.libs.gap 81 TESTS:: @@ -1458,10 +1466,10 @@ def subgroups(self, check=False): Check that :trac:`14196` is fixed:: sage: B = AbelianGroup([1,2]) - sage: B.subgroups() + sage: B.subgroups() # needs sage.libs.gap [Multiplicative Abelian subgroup isomorphic to C2 generated by {f1}, Trivial Abelian subgroup] - sage: B.subgroups(check=True) + sage: B.subgroups(check=True) # needs sage.libs.gap [Multiplicative Abelian subgroup isomorphic to C2 generated by {f1}, Trivial Abelian subgroup] """ @@ -1525,10 +1533,10 @@ def subgroup_reduced(self, elts, verbose=False): EXAMPLES:: sage: G = AbelianGroup([4,4]) - sage: G.subgroup( [ G([1,0]), G([1,2]) ]) + sage: G.subgroup( [ G([1,0]), G([1,2]) ]) # needs sage.libs.gap Multiplicative Abelian subgroup isomorphic to C2 x C4 generated by {f0, f0*f1^2} - sage: AbelianGroup([4,4]).subgroup_reduced( [ [1,0], [1,2] ]) + sage: AbelianGroup([4,4]).subgroup_reduced( [ [1,0], [1,2] ]) # needs sage.libs.gap Multiplicative Abelian subgroup isomorphic to C2 x C4 generated by {f0^2*f1^2, f0^3} """ @@ -1559,6 +1567,7 @@ def torsion_subgroup(self, n=None): EXAMPLES:: + sage: # needs sage.libs.gap sage: G = AbelianGroup([2, 3]) sage: G.torsion_subgroup() Multiplicative Abelian subgroup isomorphic to C2 x C3 generated @@ -1577,7 +1586,7 @@ def torsion_subgroup(self, n=None): :: sage: G = AbelianGroup([2, 2*3, 2*3*5, 0, 2*3*5*7, 2*3*5*7*11]) - sage: G.torsion_subgroup(5) + sage: G.torsion_subgroup(5) # needs sage.libs.gap Multiplicative Abelian subgroup isomorphic to C5 x C5 x C5 generated by {f2^6, f4^42, f5^462} """ if n is None: @@ -1610,7 +1619,8 @@ def __init__(self, ambient, gens, names="f", category=None): """ EXAMPLES:: - sage: F = AbelianGroup(5,[30,64,729],names = list("abcde")) + sage: # needs sage.libs.gap + sage: F = AbelianGroup(5, [30,64,729], names=list("abcde")) sage: a,b,c,d,e = F.gens() sage: F.subgroup([a^3,b]) Multiplicative Abelian subgroup isomorphic to Z x Z generated by {a^3, b} @@ -1622,11 +1632,11 @@ def __init__(self, ambient, gens, names="f", category=None): Multiplicative Abelian subgroup isomorphic to Z x Z generated by {a, b*c} sage: F.subgroup([b*c, d]) Multiplicative Abelian subgroup isomorphic to C64 x Z generated by {b*c, d} - sage: F.subgroup([a*b, c^6, d],names=list("xyz")) + sage: F.subgroup([a*b, c^6, d], names=list("xyz")) Multiplicative Abelian subgroup isomorphic to C5 x C64 x Z generated by {a*b, c^6, d} sage: H. = F.subgroup([a*b, c^6, d]); H Multiplicative Abelian subgroup isomorphic to C5 x C64 x Z generated by {a*b, c^6, d} - sage: G = F.subgroup([a*b, c^6, d],names = list("xyz")); G + sage: G = F.subgroup([a*b, c^6, d], names=list("xyz")); G Multiplicative Abelian subgroup isomorphic to C5 x C64 x Z generated by {a*b, c^6, d} sage: x,y,z = G.gens() sage: x.order() @@ -1635,7 +1645,7 @@ def __init__(self, ambient, gens, names="f", category=None): 5 sage: z.order() 64 - sage: A = AbelianGroup(5,[3, 5, 5, 7, 8], names = "abcde") + sage: A = AbelianGroup(5, [3, 5, 5, 7, 8], names="abcde") sage: a,b,c,d,e = A.gens() sage: A.subgroup([a,b]) Multiplicative Abelian subgroup isomorphic to C3 x C5 generated by {a, b} @@ -1647,7 +1657,7 @@ def __init__(self, ambient, gens, names="f", category=None): Multiplicative Abelian subgroup isomorphic to C4 x C5 x C5 x C7 generated by {b, c, d, e^2} sage: B.gens_orders() (4, 5, 5, 7) - sage: A = AbelianGroup(4,[1009, 2003, 3001, 4001], names = "abcd") + sage: A = AbelianGroup(4,[1009, 2003, 3001, 4001], names="abcd") sage: a,b,c,d = A.gens() sage: B = A.subgroup([a^3,b,c,d]) sage: B.gens_orders() @@ -1656,7 +1666,7 @@ def __init__(self, ambient, gens, names="f", category=None): 24266473210027 sage: B.order() 24266473210027 - sage: A = AbelianGroup(4,[1008, 2003, 3001, 4001], names = "abcd") + sage: A = AbelianGroup(4, [1008, 2003, 3001, 4001], names="abcd") sage: a,b,c,d = A.gens() sage: B = A.subgroup([a^3,b,c,d]); B Multiplicative Abelian subgroup isomorphic @@ -1664,23 +1674,25 @@ def __init__(self, ambient, gens, names="f", category=None): Infinite groups can also be handled:: - sage: G = AbelianGroup([3,4,0], names = "abc") + sage: G = AbelianGroup([3,4,0], names="abc") sage: a,b,c = G.gens() - sage: F = G.subgroup([a, b^2, c]); F - Multiplicative Abelian subgroup isomorphic to C2 x C3 x Z generated by {a, b^2, c} + sage: F = G.subgroup([a, b^2, c]); F # needs sage.libs.gap + Multiplicative Abelian subgroup isomorphic to C2 x C3 x Z + generated by {a, b^2, c} - sage: F.gens_orders() + sage: F.gens_orders() # needs sage.libs.gap (2, 3, 0) - sage: F.gens() + sage: F.gens() # needs sage.libs.gap (a, b^2, c) - sage: F.order() + sage: F.order() # needs sage.libs.gap +Infinity Testing issue :trac:`18863`:: sage: G = AbelianGroup(5,[2]) - sage: G.subgroup([prod(g^k for g,k in zip(G.gens(),[1,-2,3,-4,5]))]) - Multiplicative Abelian subgroup isomorphic to Z generated by {f0*f1^-2*f2^3*f3^-4*f4} + sage: G.subgroup([prod(g^k for g,k in zip(G.gens(),[1,-2,3,-4,5]))]) # needs sage.libs.gap + Multiplicative Abelian subgroup isomorphic to Z + generated by {f0*f1^-2*f2^3*f3^-4*f4} """ from sage.libs.gap.libgap import libgap if not isinstance(ambient, AbelianGroup_class): @@ -1713,10 +1725,10 @@ def __contains__(self, x): EXAMPLES:: sage: G. = AbelianGroup(2) - sage: A = G.subgroup([a]) + sage: A = G.subgroup([a]) # needs sage.libs.gap sage: a in G True - sage: a in A + sage: a in A # needs sage.libs.gap True TESTS: @@ -1725,22 +1737,22 @@ def __contains__(self, x): sage: G. = AbelianGroup(2, [4, 576]) sage: Hgens = [a^2, a*b^2] - sage: H = G.subgroup(Hgens) - sage: [g in H for g in (a^3, b^2, b^3, a^3*b^2, "junk")] + sage: H = G.subgroup(Hgens) # needs sage.libs.gap + sage: [g in H for g in (a^3, b^2, b^3, a^3*b^2, "junk")] # needs sage.libs.gap [False, False, False, True, False] Check that :trac:`31507` is fixed:: sage: G = AbelianGroup(2, gens_orders=[16, 16]) sage: f0, f1 = G.gens() - sage: H = G.subgroup([f0*f1^3]) - sage: [g in H for g in (f0, f0*f1^2, f0*f1^3, f0*f1^4)] + sage: H = G.subgroup([f0*f1^3]) # needs sage.libs.gap + sage: [g in H for g in (f0, f0*f1^2, f0*f1^3, f0*f1^4)] # needs sage.libs.gap [False, False, True, False] sage: G. = AbelianGroup(2) sage: Hgens = [a*b, a*b^-1] - sage: H = G.subgroup(Hgens) - sage: b^2 in H + sage: H = G.subgroup(Hgens) # needs sage.libs.gap + sage: b^2 in H # needs sage.libs.gap True """ if not isinstance(x, AbelianGroupElement): @@ -1769,8 +1781,8 @@ def ambient_group(self): EXAMPLES:: sage: G. = AbelianGroup([2,3,4]) - sage: H = G.subgroup([a, b^2]) - sage: H.ambient_group() is G + sage: H = G.subgroup([a, b^2]) # needs sage.libs.gap + sage: H.ambient_group() is G # needs sage.libs.gap True """ return self._ambient_group @@ -1795,15 +1807,16 @@ def equals(left, right): sage: G = AbelianGroup(3, [2,3,4], names="abc"); G Multiplicative Abelian group isomorphic to C2 x C3 x C4 sage: a,b,c = G.gens() - sage: F = G.subgroup([a,b^2]); F + sage: F = G.subgroup([a,b^2]); F # needs sage.libs.gap Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {a, b^2} - sage: F = AbelianGroup(2) sage: A = G.subgroup([a]) sage: B = G.subgroup([b]) @@ -1835,8 +1848,8 @@ def _repr_(self): sage: G. = AbelianGroup(2) sage: G._repr_() 'Multiplicative Abelian group isomorphic to Z x Z' - sage: A = G.subgroup([a]) - sage: A._repr_() + sage: A = G.subgroup([a]) # needs sage.libs.gap + sage: A._repr_() # needs sage.libs.gap 'Multiplicative Abelian subgroup isomorphic to Z generated by {a}' """ eldv = self._abinvs @@ -1859,10 +1872,10 @@ def gens(self): EXAMPLES:: sage: G. = AbelianGroup(2) - sage: A = G.subgroup([a]) + sage: A = G.subgroup([a]) # needs sage.libs.gap sage: G.gens() (a, b) - sage: A.gens() + sage: A.gens() # needs sage.libs.gap (a,) """ return self._gens @@ -1874,8 +1887,8 @@ def gen(self, n): EXAMPLES:: sage: G. = AbelianGroup(2) - sage: A = G.subgroup([a]) - sage: A.gen(0) + sage: A = G.subgroup([a]) # needs sage.libs.gap + sage: A.gen(0) # needs sage.libs.gap a """ return self._gens[n] diff --git a/src/sage/groups/abelian_gps/abelian_group_element.py b/src/sage/groups/abelian_gps/abelian_group_element.py index 1b0c9cd590c..6ae81844f98 100644 --- a/src/sage/groups/abelian_gps/abelian_group_element.py +++ b/src/sage/groups/abelian_gps/abelian_group_element.py @@ -97,16 +97,16 @@ def as_permutation(self): EXAMPLES:: - sage: G = AbelianGroup(3,[2,3,4],names="abc"); G + sage: G = AbelianGroup(3, [2,3,4], names="abc"); G Multiplicative Abelian group isomorphic to C2 x C3 x C4 sage: a,b,c = G.gens() - sage: Gp = G.permutation_group(); Gp + sage: Gp = G.permutation_group(); Gp # needs sage.groups Permutation Group with generators [(6,7,8,9), (3,4,5), (1,2)] - sage: a.as_permutation() + sage: a.as_permutation() # needs sage.libs.gap (1,2) - sage: ap = a.as_permutation(); ap + sage: ap = a.as_permutation(); ap # needs sage.libs.gap (1,2) - sage: ap in Gp + sage: ap in Gp # needs sage.groups sage.libs.gap True """ from sage.libs.gap.libgap import libgap @@ -138,13 +138,14 @@ def word_problem(self, words): EXAMPLES:: - sage: G = AbelianGroup(2,[2,3], names="xy") + sage: # needs sage.libs.gap + sage: G = AbelianGroup(2, [2,3], names="xy") sage: x,y = G.gens() sage: x.word_problem([x,y]) [[x, 1]] sage: y.word_problem([x,y]) [[y, 1]] - sage: v = (y*x).word_problem([x,y]); v #random + sage: v = (y*x).word_problem([x,y]); v # random [[x, 1], [y, 1]] sage: prod([x^i for x,i in v]) == y*x True diff --git a/src/sage/groups/abelian_gps/dual_abelian_group.py b/src/sage/groups/abelian_gps/dual_abelian_group.py index 2d5441daaca..2ee86f7f423 100644 --- a/src/sage/groups/abelian_gps/dual_abelian_group.py +++ b/src/sage/groups/abelian_gps/dual_abelian_group.py @@ -25,6 +25,7 @@ sage: F = AbelianGroup(5, [2,5,7,8,9], names='abcde') sage: (a, b, c, d, e) = F.gens() + sage: # needs sage.rings.number_field sage: Fd = F.dual_group(names='ABCDE') sage: Fd.base_ring() Cyclotomic Field of order 2520 and degree 576 @@ -34,6 +35,7 @@ sage: A(b), A(c), A(d), A(e) (1, 1, 1, 1) + sage: # needs sage.rings.real_mpfr sage: Fd = F.dual_group(names='ABCDE', base_ring=CC) sage: A,B,C,D,E = Fd.gens() sage: A(a) # abs tol 1e-8 @@ -78,6 +80,7 @@ def is_DualAbelianGroup(x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.groups.abelian_gps.dual_abelian_group import is_DualAbelianGroup sage: F = AbelianGroup(5,[3,5,7,8,9], names=list("abcde")) sage: Fd = F.dual_group() @@ -100,11 +103,12 @@ class DualAbelianGroup_class(UniqueRepresentation, AbelianGroupBase): EXAMPLES:: sage: F = AbelianGroup(5,[3,5,7,8,9], names="abcde") - sage: F.dual_group() + sage: F.dual_group() # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/3Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z over Cyclotomic Field of order 2520 and degree 576 + sage: F = AbelianGroup(4,[15,7,8,9], names="abcd") - sage: F.dual_group(base_ring=CC) + sage: F.dual_group(base_ring=CC) # needs sage.rings.real_mpfr Dual of Abelian Group isomorphic to Z/15Z x Z/7Z x Z/8Z x Z/9Z over Complex Field with 53 bits of precision """ @@ -117,7 +121,7 @@ def __init__(self, G, names, base_ring): EXAMPLES:: sage: F = AbelianGroup(5,[3,5,7,8,9], names="abcde") - sage: F.dual_group() + sage: F.dual_group() # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/3Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z over Cyclotomic Field of order 2520 and degree 576 """ @@ -174,12 +178,13 @@ def _repr_(self): EXAMPLES:: sage: F = AbelianGroup(5, [2,5,7,8,9], names='abcde') - sage: Fd = F.dual_group(names='ABCDE', base_ring=CyclotomicField(2*5*7*8*9)) - sage: Fd # indirect doctest + sage: Fd = F.dual_group(names='ABCDE', # needs sage.rings.number_field + ....: base_ring=CyclotomicField(2*5*7*8*9)) + sage: Fd # indirect doctest # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/2Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z over Cyclotomic Field of order 5040 and degree 1152 - sage: Fd = F.dual_group(names='ABCDE', base_ring=CC) - sage: Fd + sage: Fd = F.dual_group(names='ABCDE', base_ring=CC) # needs sage.rings.real_mpfr + sage: Fd # needs sage.rings.real_mpfr Dual of Abelian Group isomorphic to Z/2Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z over Complex Field with 53 bits of precision """ @@ -202,8 +207,8 @@ def _latex_(self): EXAMPLES:: sage: F = AbelianGroup(3, [2]*3) - sage: Fd = F.dual_group() - sage: Fd._latex_() + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: Fd._latex_() # needs sage.rings.number_field '$\\mathrm{DualAbelianGroup}( AbelianGroup ( 3, (2, 2, 2) ) )$' """ return r"$\mathrm{DualAbelianGroup}( AbelianGroup ( %s, %s ) )$" % (self.ngens(), self.gens_orders()) @@ -215,12 +220,13 @@ def random_element(self): EXAMPLES:: sage: G = AbelianGroup([2,3,9]) - sage: Gd = G.dual_group(base_ring=CC) - sage: Gd.random_element().parent() is Gd + sage: Gd = G.dual_group(base_ring=CC) # needs sage.rings.real_mpfr + sage: Gd.random_element().parent() is Gd # needs sage.rings.real_mpfr True - sage: N = 43^2-1 - sage: G = AbelianGroup([N],names="a") + sage: # needs sage.rings.real_mpfr + sage: N = 43^2 - 1 + sage: G = AbelianGroup([N], names="a") sage: Gd = G.dual_group(names="A", base_ring=CC) sage: a, = G.gens() sage: A, = Gd.gens() @@ -243,7 +249,8 @@ def gen(self, i=0): EXAMPLES:: - sage: F = AbelianGroup(3,[1,2,3],names='a') + sage: # needs sage.rings.number_field + sage: F = AbelianGroup(3, [1,2,3], names='a') sage: Fd = F.dual_group(names="A") sage: Fd.0 1 @@ -270,8 +277,8 @@ def gens(self): EXAMPLES:: - sage: F = AbelianGroup([7,11]).dual_group() - sage: F.gens() + sage: F = AbelianGroup([7,11]).dual_group() # needs sage.rings.number_field + sage: F.gens() # needs sage.rings.number_field (X0, X1) """ n = self.group().ngens() @@ -284,8 +291,8 @@ def ngens(self): EXAMPLES:: sage: F = AbelianGroup([7]*100) - sage: Fd = F.dual_group() - sage: Fd.ngens() + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: Fd.ngens() # needs sage.rings.number_field 100 """ return self.group().ngens() @@ -301,8 +308,8 @@ def gens_orders(self): EXAMPLES:: sage: F = AbelianGroup([5]*1000) - sage: Fd = F.dual_group() - sage: invs = Fd.gens_orders(); len(invs) + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: invs = Fd.gens_orders(); len(invs) # needs sage.rings.number_field 1000 """ return self.group().gens_orders() @@ -316,8 +323,8 @@ def invariants(self): EXAMPLES:: sage: F = AbelianGroup([5]*1000) - sage: Fd = F.dual_group() - sage: invs = Fd.gens_orders(); len(invs) + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: invs = Fd.gens_orders(); len(invs) # needs sage.rings.number_field 1000 """ # TODO: deprecate @@ -331,9 +338,9 @@ def __contains__(self, X): sage: F = AbelianGroup(5,[2, 3, 5, 7, 8], names="abcde") sage: a,b,c,d,e = F.gens() - sage: Fd = F.dual_group(names = "ABCDE") - sage: A,B,C,D,E = Fd.gens() - sage: A*B^2*D^7 in Fd + sage: Fd = F.dual_group(names="ABCDE") # needs sage.rings.number_field + sage: A,B,C,D,E = Fd.gens() # needs sage.rings.number_field + sage: A*B^2*D^7 in Fd # needs sage.rings.number_field True """ return X.parent() == self and is_DualAbelianGroupElement(X) @@ -345,8 +352,8 @@ def order(self): EXAMPLES:: sage: G = AbelianGroup([2,3,9]) - sage: Gd = G.dual_group() - sage: Gd.order() + sage: Gd = G.dual_group() # needs sage.rings.number_field + sage: Gd.order() # needs sage.rings.number_field 54 """ G = self.group() @@ -359,10 +366,10 @@ def is_commutative(self): EXAMPLES:: sage: G = AbelianGroup([2,3,9]) - sage: Gd = G.dual_group() - sage: Gd.is_commutative() + sage: Gd = G.dual_group() # needs sage.rings.number_field + sage: Gd.is_commutative() # needs sage.rings.number_field True - sage: Gd.is_abelian() + sage: Gd.is_abelian() # needs sage.rings.number_field True """ return True @@ -375,8 +382,8 @@ def list(self): EXAMPLES:: sage: G = AbelianGroup([2,3], names="ab") - sage: Gd = G.dual_group(names="AB") - sage: Gd.list() + sage: Gd = G.dual_group(names="AB") # needs sage.rings.number_field + sage: Gd.list() # needs sage.rings.number_field (1, B, B^2, A, A*B, A*B^2) """ if not self.is_finite(): @@ -391,18 +398,21 @@ def __iter__(self): EXAMPLES:: sage: G = AbelianGroup([2,3], names="ab") - sage: Gd = G.dual_group(names="AB") - sage: [X for X in Gd] + sage: Gd = G.dual_group(names="AB") # needs sage.rings.number_field + sage: [X for X in Gd] # needs sage.rings.number_field [1, B, B^2, A, A*B, A*B^2] - sage: N = 43^2-1 - sage: G = AbelianGroup([N],names="a") + + sage: # needs sage.rings.real_mpfr + sage: N = 43^2 - 1 + sage: G = AbelianGroup([N], names="a") sage: Gd = G.dual_group(names="A", base_ring=CC) sage: a, = G.gens() sage: A, = Gd.gens() sage: x = a^(N/4) sage: y = a^(N/3) sage: z = a^(N/14) - sage: len([X for X in Gd if abs(X(x)-1)>0.01 and abs(X(y)-1)>0.01 and abs(X(z)-1)>0.01]) + sage: len([X for X in Gd + ....: if abs(X(x)-1)>0.01 and abs(X(y)-1)>0.01 and abs(X(z)-1)>0.01]) 880 """ yield from self.list() diff --git a/src/sage/groups/abelian_gps/dual_abelian_group_element.py b/src/sage/groups/abelian_gps/dual_abelian_group_element.py index e32d7b09762..407323d4f34 100644 --- a/src/sage/groups/abelian_gps/dual_abelian_group_element.py +++ b/src/sage/groups/abelian_gps/dual_abelian_group_element.py @@ -8,13 +8,13 @@ sage: F Multiplicative Abelian group isomorphic to C2 x C3 x C5 x C7 x C8 - sage: Fd = F.dual_group(names="ABCDE") - sage: Fd + sage: Fd = F.dual_group(names="ABCDE"); Fd # needs sage.rings.number_field Dual of Abelian Group isomorphic to Z/2Z x Z/3Z x Z/5Z x Z/7Z x Z/8Z over Cyclotomic Field of order 840 and degree 192 The elements of the dual group can be evaluated on elements of the original group:: + sage: # needs sage.rings.number_field sage: a,b,c,d,e = F.gens() sage: A,B,C,D,E = Fd.gens() sage: A*B^2*D^7 @@ -71,10 +71,10 @@ def is_DualAbelianGroupElement(x) -> bool: EXAMPLES:: sage: from sage.groups.abelian_gps.dual_abelian_group import is_DualAbelianGroupElement - sage: F = AbelianGroup(5, [5,5,7,8,9], names=list("abcde")).dual_group() - sage: is_DualAbelianGroupElement(F) + sage: F = AbelianGroup(5, [5,5,7,8,9], names=list("abcde")).dual_group() # needs sage.rings.number_field + sage: is_DualAbelianGroupElement(F) # needs sage.rings.number_field False - sage: is_DualAbelianGroupElement(F.an_element()) + sage: is_DualAbelianGroupElement(F.an_element()) # needs sage.rings.number_field True """ return isinstance(x, DualAbelianGroupElement) @@ -96,6 +96,7 @@ def __call__(self, g): EXAMPLES:: + sage: # needs sage.rings.number_field sage: F = AbelianGroup(5, [2,3,5,7,8], names="abcde") sage: a,b,c,d,e = F.gens() sage: Fd = F.dual_group(names="ABCDE") @@ -117,7 +118,7 @@ def __call__(self, g): sage: a, = F.gens() sage: Fd = F.dual_group(names="A", base_ring=GF(29)) sage: A, = Fd.gens() - sage: A(a) + sage: A(a) # needs sage.libs.pari 16 """ F = self.parent().base_ring() @@ -146,6 +147,7 @@ def word_problem(self, words): EXAMPLES:: + sage: # needs sage.rings.number_field sage: G = AbelianGroup(5,[3, 5, 5, 7, 8], names="abcde") sage: Gd = G.dual_group(names="abcde") sage: a,b,c,d,e = Gd.gens() diff --git a/src/sage/groups/abelian_gps/element_base.py b/src/sage/groups/abelian_gps/element_base.py index 00abd05eb8c..6a46bd7f444 100644 --- a/src/sage/groups/abelian_gps/element_base.py +++ b/src/sage/groups/abelian_gps/element_base.py @@ -48,9 +48,9 @@ class AbelianGroupElementBase(MultiplicativeGroupElement): EXAMPLES:: sage: F = AbelianGroup(3,[7,8,9]) - sage: Fd = F.dual_group(names="ABC") - sage: A,B,C = Fd.gens() - sage: A*B^-1 in Fd + sage: Fd = F.dual_group(names="ABC") # needs sage.rings.number_field + sage: A,B,C = Fd.gens() # needs sage.rings.number_field + sage: A*B^-1 in Fd # needs sage.rings.number_field True """ @@ -61,9 +61,9 @@ def __init__(self, parent, exponents): EXAMPLES:: sage: F = AbelianGroup(3,[7,8,9]) - sage: Fd = F.dual_group(names="ABC") - sage: A,B,C = Fd.gens() - sage: A*B^-1 in Fd + sage: Fd = F.dual_group(names="ABC") # needs sage.rings.number_field + sage: A,B,C = Fd.gens() # needs sage.rings.number_field + sage: A*B^-1 in Fd # needs sage.rings.number_field True Check that :issue:`35216` is fixed:: @@ -125,7 +125,7 @@ def _libgap_(self): TESTS:: sage: F. = AbelianGroup([7,8,9]) - sage: libgap(a**2 * c) * libgap(b * c**2) + sage: libgap(a**2 * c) * libgap(b * c**2) # needs sage.libs.gap f1^2*f2*f6 """ from sage.misc.misc_c import prod @@ -147,6 +147,7 @@ def list(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: F = AbelianGroup(5,[2, 3, 5, 7, 8], names="abcde") sage: a,b,c,d,e = F.gens() sage: Ad = F.dual_group(names="ABCDE") @@ -208,8 +209,8 @@ def _richcmp_(self, other, op): sage: a > b True - sage: Gd. = G.dual_group() - sage: A > B + sage: Gd. = G.dual_group() # needs sage.rings.number_field + sage: A > B # needs sage.rings.number_field True """ return richcmp(self._exponents, other._exponents, op) @@ -226,9 +227,9 @@ def order(self): EXAMPLES:: sage: F = AbelianGroup(3,[7,8,9]) - sage: Fd = F.dual_group() - sage: A,B,C = Fd.gens() - sage: (B*C).order() + sage: Fd = F.dual_group() # needs sage.rings.number_field + sage: A,B,C = Fd.gens() # needs sage.rings.number_field + sage: (B*C).order() # needs sage.rings.number_field 72 sage: F = AbelianGroup(3,[7,8,9]); F diff --git a/src/sage/groups/abelian_gps/values.py b/src/sage/groups/abelian_gps/values.py index e476176cb7d..3db117123f0 100644 --- a/src/sage/groups/abelian_gps/values.py +++ b/src/sage/groups/abelian_gps/values.py @@ -48,6 +48,7 @@ :meth:`~AbelianGroupWithValues_class.values_group`, so you can use the group elements instead of the values:: + sage: # needs sage.rings.number_field sage: CF3. = CyclotomicField(3) sage: Z3. = AbelianGroupWithValues([zeta], [3]) sage: Z3.values_group() @@ -159,6 +160,7 @@ class AbelianGroupWithValuesEmbedding(Morphism): EXAMPLES:: + sage: # needs sage.symbolic sage: Z4. = AbelianGroupWithValues([I], [4]) sage: embedding = Z4.values_embedding(); embedding Generic morphism: @@ -178,9 +180,9 @@ def __init__(self, domain, codomain): TESTS:: - sage: Z4 = AbelianGroupWithValues([I], [4]) + sage: Z4 = AbelianGroupWithValues([I], [4]) # needs sage.symbolic sage: from sage.groups.abelian_gps.values import AbelianGroupWithValuesEmbedding - sage: AbelianGroupWithValuesEmbedding(Z4, Z4.values_group()) + sage: AbelianGroupWithValuesEmbedding(Z4, Z4.values_group()) # needs sage.symbolic Generic morphism: From: Multiplicative Abelian group isomorphic to C4 To: Number Field in I with defining polynomial x^2 + 1 with I = 1*I @@ -203,6 +205,7 @@ def _call_(self, x): EXAMPLES:: + sage: # needs sage.symbolic sage: Z4. = AbelianGroupWithValues([I], [4]) sage: embedding = Z4.values_embedding() sage: embedding(g) @@ -417,7 +420,7 @@ def gen(self, i=0): EXAMPLES:: - sage: F = AbelianGroupWithValues([1,2,3,4,5], 5,[],names='a') + sage: F = AbelianGroupWithValues([1,2,3,4,5], 5, [], names='a') sage: F.0 a0 sage: F.0.value() @@ -473,8 +476,8 @@ def values_group(self): sage: G.values_group() Integer Ring - sage: Z4 = AbelianGroupWithValues([I], [4]) - sage: Z4.values_group() + sage: Z4 = AbelianGroupWithValues([I], [4]) # needs sage.symbolic + sage: Z4.values_group() # needs sage.symbolic Number Field in I with defining polynomial x^2 + 1 with I = 1*I """ return self._values_group @@ -489,8 +492,8 @@ def values_embedding(self): EXAMPLES:: - sage: Z4 = AbelianGroupWithValues([I], [4]) - sage: Z4.values_embedding() + sage: Z4 = AbelianGroupWithValues([I], [4]) # needs sage.symbolic + sage: Z4.values_embedding() # needs sage.symbolic Generic morphism: From: Multiplicative Abelian group isomorphic to C4 To: Number Field in I with defining polynomial x^2 + 1 with I = 1*I diff --git a/src/sage/groups/additive_abelian/additive_abelian_group.py b/src/sage/groups/additive_abelian/additive_abelian_group.py index de8c4a41656..358302ffd13 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_group.py +++ b/src/sage/groups/additive_abelian/additive_abelian_group.py @@ -450,7 +450,7 @@ def permutation_group(self): EXAMPLES:: sage: G = AdditiveAbelianGroup([2, 3]) - sage: G.permutation_group() + sage: G.permutation_group() # needs sage.groups Permutation Group with generators [(3,4,5), (1,2)] TESTS: diff --git a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py index 5d211f6383b..2a7496cb215 100644 --- a/src/sage/groups/additive_abelian/additive_abelian_wrapper.py +++ b/src/sage/groups/additive_abelian/additive_abelian_wrapper.py @@ -11,10 +11,10 @@ We create a toy example based on the Mordell-Weil group of an elliptic curve over `\QQ`:: + sage: # needs sage.schemes sage: E = EllipticCurve('30a2') sage: pts = [E(4,-7,1), E(7/4, -11/8, 1), E(3, -2, 1)] - sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [3, 2, 2]) - sage: M + sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [3, 2, 2]); M Additive abelian group isomorphic to Z/3 + Z/2 + Z/2 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - 19*x + 26 over Rational Field @@ -24,7 +24,7 @@ (0 : 1 : 0) sage: 3000000000000001 * M.0 (4 : -7 : 1) - sage: M == loads(dumps(M)) # known bug, see https://github.com/sagemath/sage/issues/11599#comment:7 + sage: M == loads(dumps(M)) # known bug (https://github.com/sagemath/sage/issues/11599#comment:7) True TESTS: @@ -33,7 +33,7 @@ sage: from sage.misc.verbose import set_verbose sage: set_verbose(2, 'additive_abelian_wrapper.py') - sage: 300001 * M.0 + sage: 300001 * M.0 # needs sage.schemes verbose 1 (...: additive_abelian_wrapper.py, discrete_exp) Calling discrete exp on (1, 0, 0) (4 : -7 : 1) sage: set_verbose(0, 'additive_abelian_wrapper.py') @@ -85,12 +85,13 @@ def __init__(self, domain): r""" EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: F = QQbar.coerce_map_from(G); F + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) + sage: F = QQbar.coerce_map_from(G); F # needs sage.rings.number_field Generic morphism: From: Additive abelian group isomorphic to Z + Z embedded in Algebraic Field To: Algebraic Field - sage: type(F) + sage: type(F) # needs sage.rings.number_field """ Morphism.__init__(self, domain.Hom(domain.universe())) @@ -99,13 +100,14 @@ def _call_(self, x): r""" TESTS:: + sage: # needs sage.schemes sage: E = EllipticCurve("65a1") sage: G = E.torsion_subgroup() sage: isinstance(G, sage.groups.additive_abelian.additive_abelian_wrapper.AdditiveAbelianGroupWrapper) True sage: P1 = E([1,-1,1]) sage: P2 = E([0,1,0]) - sage: P1 in G # indirect doctest + sage: P1 in G # indirect doctest False sage: P2 in G True @@ -127,8 +129,9 @@ def __init__(self, parent, vector, element=None, check=False): EXAMPLES:: sage: from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: G.0 # indirect doctest + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) + sage: G.0 # indirect doctest # needs sage.rings.number_field 1.414213562373095? """ addgp.AdditiveAbelianGroupElement.__init__(self, parent, vector, check) @@ -142,11 +145,11 @@ def element(self): EXAMPLES:: - sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) - sage: T; type(T) + sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) # needs sage.schemes + sage: T; type(T) # needs sage.schemes (0 : 0 : 1) - sage: T.element(); type(T.element()) + sage: T.element(); type(T.element()) # needs sage.schemes (0 : 0 : 1) """ @@ -160,8 +163,8 @@ def _repr_(self): EXAMPLES:: - sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) - sage: repr(T) # indirect doctest + sage: T = EllipticCurve('65a').torsion_subgroup().gen(0) # needs sage.schemes + sage: repr(T) # indirect doctest # needs sage.schemes '(0 : 0 : 1)' """ return repr(self.element()) @@ -179,19 +182,22 @@ class AdditiveAbelianGroupWrapper(addgp.AdditiveAbelianGroup_fixed_gens): sage: G6 = AdditiveAbelianGroupWrapper(Zmod(42), [6], [7]); G6 Additive abelian group isomorphic to Z/7 embedded in Ring of integers modulo 42 sage: G = AdditiveAbelianGroupWrapper(Zmod(42), [21,14,6], [2,3,7]); G - Additive abelian group isomorphic to Z/2 + Z/3 + Z/7 embedded in Ring of integers modulo 42 + Additive abelian group isomorphic to Z/2 + Z/3 + Z/7 embedded in + Ring of integers modulo 42 sage: G.invariants() (42,) :: - sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(2), sqrt(3)], [0, 0]) + sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(2), sqrt(3)], [0, 0]) # needs sage.rings.number_field sage.symbolic Additive abelian group isomorphic to Z + Z embedded in Algebraic Field :: - sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest - Additive abelian group isomorphic to Z/420 + Z/420 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 419^2 + sage: EllipticCurve(GF(419**2), [1,0]).abelian_group() # indirect doctest # needs sage.rings.finite_rings sage.schemes + Additive abelian group isomorphic to Z/420 + Z/420 embedded in + Abelian group of points on Elliptic Curve + defined by y^2 = x^3 + x over Finite Field in z2 of size 419^2 """ Element = AdditiveAbelianGroupWrapperElement @@ -200,7 +206,8 @@ def __init__(self, universe, gens, invariants): r""" EXAMPLES:: - sage: AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) # indirect doctest + sage: AdditiveAbelianGroupWrapper(QQbar, # indirect doctest # needs sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) Additive abelian group isomorphic to Z + Z embedded in Algebraic Field """ self._universe = universe @@ -217,8 +224,10 @@ def universe(self): EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: G.universe() + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], + ....: [0, 0]) + sage: G.universe() # needs sage.rings.number_field Algebraic Field """ return self._universe @@ -246,8 +255,9 @@ def _repr_(self): r""" EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) - sage: repr(G) # indirect doctest + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field + ....: [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0]) + sage: repr(G) # indirect doctest # needs sage.rings.number_field 'Additive abelian group isomorphic to Z + Z embedded in Algebraic Field' """ return addgp.AdditiveAbelianGroup_fixed_gens._repr_(self) + " embedded in " + self.universe()._repr_() @@ -283,10 +293,11 @@ def discrete_exp(self, v): EXAMPLES:: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), -1], [0, 0]) - sage: v = G.discrete_exp([3, 5]); v + sage: G = AdditiveAbelianGroupWrapper(QQbar, # needs sage.rings.number_field + ....: [sqrt(QQbar(2)), -1], [0, 0]) + sage: v = G.discrete_exp([3, 5]); v # needs sage.rings.number_field -0.7573593128807148? - sage: v.parent() is QQbar + sage: v.parent() is QQbar # needs sage.rings.number_field True This method is an inverse of :meth:`discrete_log`:: @@ -332,16 +343,17 @@ def discrete_log(self, x, gens=None): EXAMPLES:: sage: G = AdditiveAbelianGroup([2, 2*3, 2*3*5, 2*3*5*7, 2*3*5*7*11]) - sage: A = AdditiveAbelianGroupWrapper(G.0.parent(), G.gens(), [g.order() for g in G.gens()]) + sage: A = AdditiveAbelianGroupWrapper(G.0.parent(), G.gens(), + ....: [g.order() for g in G.gens()]) sage: A.discrete_log(A.discrete_exp([1,5,23,127,539])) (1, 5, 23, 127, 539) :: sage: x = polygen(ZZ, 'x') - sage: F. = GF(1009**2, modulus=x**2+11); E = EllipticCurve(j=F(940)) # optional - sage.rings.finite_rings - sage: P, Q = E(900*t + 228, 974*t + 185), E(1007*t + 214, 865*t + 802) # optional - sage.rings.finite_rings - sage: E.abelian_group().discrete_log(123 * P + 777 * Q, [P, Q]) # optional - sage.rings.finite_rings + sage: F. = GF(1009**2, modulus=x**2+11); E = EllipticCurve(j=F(940)) # needs sage.rings.finite_rings sage.schemes + sage: P, Q = E(900*t + 228, 974*t + 185), E(1007*t + 214, 865*t + 802) # needs sage.rings.finite_rings sage.schemes + sage: E.abelian_group().discrete_log(123 * P + 777 * Q, [P, Q]) # needs sage.rings.finite_rings sage.schemes (123, 777) :: @@ -357,8 +369,8 @@ def discrete_log(self, x, gens=None): :: - sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) - sage: G.discrete_log(QQbar(2*sqrt(2))) + sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(2)], [0]) # needs sage.rings.number_field sage.symbolic + sage: G.discrete_log(QQbar(2*sqrt(2))) # needs sage.rings.number_field sage.symbolic Traceback (most recent call last): ... NotImplementedError: No black-box discrete log for infinite abelian groups @@ -426,33 +438,43 @@ def torsion_subgroup(self, n=None): sage: A = AdditiveAbelianGroupWrapper(G.0.parent(), G.gens(), ords) sage: T = A.torsion_subgroup(5) sage: T - Additive abelian group isomorphic to Z/5 + Z/5 + Z/5 embedded in Additive abelian group isomorphic to Z/2 + Z/6 + Z/30 + Z + Z/210 + Z/2310 + Additive abelian group isomorphic to Z/5 + Z/5 + Z/5 embedded in + Additive abelian group isomorphic to Z/2 + Z/6 + Z/30 + Z + Z/210 + Z/2310 sage: T.gens() ((0, 0, 6, 0, 0, 0), (0, 0, 0, 0, 42, 0), (0, 0, 0, 0, 0, 462)) :: + sage: # needs sage.rings.finite_rings sage.schemes sage: E = EllipticCurve(GF(487^2), [311,205]) - sage: T = E.abelian_group().torsion_subgroup(42) - sage: T - Additive abelian group isomorphic to Z/42 + Z/6 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 311*x + 205 over Finite Field in z2 of size 487^2 + sage: T = E.abelian_group().torsion_subgroup(42); T + Additive abelian group isomorphic to Z/42 + Z/6 embedded in + Abelian group of points on Elliptic Curve + defined by y^2 = x^3 + 311*x + 205 over Finite Field in z2 of size 487^2 sage: [P.order() for P in T.gens()] [42, 6] :: + sage: # needs sage.schemes sage: E = EllipticCurve('574i1') sage: pts = [E(103,172), E(61,18)] sage: assert pts[0].order() == 7 and pts[1].order() == infinity - sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [7,0]) - sage: M - Additive abelian group isomorphic to Z/7 + Z embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field + sage: M = AdditiveAbelianGroupWrapper(pts[0].parent(), pts, [7,0]); M + Additive abelian group isomorphic to Z/7 + Z embedded in + Abelian group of points on Elliptic Curve defined by + y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field sage: M.torsion_subgroup() - Additive abelian group isomorphic to Z/7 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field + Additive abelian group isomorphic to Z/7 embedded in + Abelian group of points on Elliptic Curve defined by + y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field sage: M.torsion_subgroup(7) - Additive abelian group isomorphic to Z/7 embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field + Additive abelian group isomorphic to Z/7 embedded in + Abelian group of points on Elliptic Curve defined by + y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field sage: M.torsion_subgroup(5) - Trivial group embedded in Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field + Trivial group embedded in Abelian group of points on Elliptic Curve + defined by y^2 + x*y + y = x^3 - x^2 - 19353*x + 958713 over Rational Field AUTHORS: @@ -493,7 +515,8 @@ def from_generators(gens, universe=None): sage: G = AdditiveAbelianGroup([15, 30, 45]) sage: gs = [G((1,2,3)), G((4,5,6)), G((7,7,7)), G((3,2,1))] sage: H = AdditiveAbelianGroupWrapper.from_generators(gs); H - Additive abelian group isomorphic to Z/90 + Z/15 embedded in Additive abelian group isomorphic to Z/15 + Z/30 + Z/45 + Additive abelian group isomorphic to Z/90 + Z/15 embedded in + Additive abelian group isomorphic to Z/15 + Z/30 + Z/45 sage: H.gens() ((12, 13, 14), (1, 26, 21)) @@ -552,12 +575,13 @@ def _discrete_log_pgroup(p, vals, aa, b): Check for :trac:`34716`:: + sage: # needs sage.rings.finite_rings sage.schemes sage: E = EllipticCurve(GF(487^2), [311,205]) sage: G = E.abelian_group().torsion_subgroup(42) sage: G.invariants() (6, 42) sage: P, Q = G.torsion_subgroup(6).gens() - sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest + sage: G.discrete_log(2*P + 3*Q, [P, Q]) # indirect doctest # needs sage.groups (2, 3) """ from itertools import product as iproduct @@ -748,6 +772,7 @@ def basis_from_generators(gens, ords=None): EXAMPLES:: + sage: # needs sage.groups sage.rings.finite_rings sage: from sage.groups.additive_abelian.additive_abelian_wrapper import basis_from_generators sage: E = EllipticCurve(GF(31337^6,'a'), j=37) sage: E.order() diff --git a/src/sage/groups/affine_gps/affine_group.py b/src/sage/groups/affine_gps/affine_group.py index 81074a3e50d..bfcdd282df1 100644 --- a/src/sage/groups/affine_gps/affine_group.py +++ b/src/sage/groups/affine_gps/affine_group.py @@ -129,11 +129,11 @@ class AffineGroup(UniqueRepresentation, Group): Some additional ways to create affine groups:: - sage: A = AffineSpace(2, GF(4,'a')); A # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(4,'a')); A # needs sage.rings.finite_rings Affine Space of dimension 2 over Finite Field in a of size 2^2 - sage: G = AffineGroup(A); G # optional - sage.rings.finite_rings + sage: G = AffineGroup(A); G # needs sage.rings.finite_rings Affine Group of degree 2 over Finite Field in a of size 2^2 - sage: G is AffineGroup(2,4) # shorthand # optional - sage.rings.finite_rings + sage: G is AffineGroup(2,4) # shorthand # needs sage.rings.finite_rings True sage: V = ZZ^3; V @@ -152,10 +152,10 @@ def __classcall__(cls, *args, **kwds): EXAMPLES:: - sage: A = AffineSpace(2, GF(4,'a')) # optional - sage.rings.finite_rings - sage: AffineGroup(A) is AffineGroup(2,4) # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(4,'a')) # needs sage.rings.finite_rings + sage: AffineGroup(A) is AffineGroup(2,4) # needs sage.rings.finite_rings True - sage: AffineGroup(A) is AffineGroup(2, GF(4,'a')) # optional - sage.rings.finite_rings + sage: AffineGroup(A) is AffineGroup(2, GF(4,'a')) # needs sage.rings.finite_rings True sage: A = AffineGroup(2, QQ) sage: V = QQ^2 @@ -202,10 +202,10 @@ def __init__(self, degree, ring): TESTS:: - sage: G = AffineGroup(2, GF(5)); G # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(5)); G Affine Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # optional - sage.rings.finite_rings - sage: G.category() # optional - sage.rings.finite_rings + sage: TestSuite(G).run() + sage: G.category() Category of finite groups sage: Aff6 = AffineGroup(6, QQ) @@ -264,8 +264,8 @@ def _latex_(self): EXAMPLES:: - sage: G = AffineGroup(6, GF(5)) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = AffineGroup(6, GF(5)) + sage: latex(G) \mathrm{Aff}_{6}(\Bold{F}_{5}) """ return "\\mathrm{Aff}_{%s}(%s)" % (self.degree(), @@ -277,7 +277,7 @@ def _repr_(self): EXAMPLES:: - sage: AffineGroup(6, GF(5)) # optional - sage.rings.finite_rings + sage: AffineGroup(6, GF(5)) Affine Group of degree 6 over Finite Field of size 5 """ return "Affine Group of degree %s over %s" % (self.degree(), @@ -289,7 +289,7 @@ def cardinality(self): EXAMPLES:: - sage: AffineGroup(6, GF(5)).cardinality() # optional - sage.rings.finite_rings + sage: AffineGroup(6, GF(5)).cardinality() 172882428468750000000000000000 sage: AffineGroup(6, ZZ).cardinality() +Infinity @@ -305,11 +305,11 @@ def degree(self): EXAMPLES:: - sage: G = AffineGroup(6, GF(5)) # optional - sage.rings.finite_rings - sage: g = G.an_element() # optional - sage.rings.finite_rings - sage: G.degree() # optional - sage.rings.finite_rings + sage: G = AffineGroup(6, GF(5)) + sage: g = G.an_element() + sage: G.degree() 6 - sage: G.degree() == g.A().nrows() == g.A().ncols() == g.b().degree() # optional - sage.rings.finite_rings + sage: G.degree() == g.A().nrows() == g.A().ncols() == g.b().degree() True """ return self._degree @@ -327,8 +327,8 @@ def matrix_space(self): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.matrix_space() # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.matrix_space() Full MatrixSpace of 3 by 3 dense matrices over Finite Field of size 5 """ d = self.degree() @@ -341,8 +341,8 @@ def vector_space(self): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.vector_space() # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.vector_space() Vector space of dimension 3 over Finite Field of size 5 """ return FreeModule(self.base_ring(), self.degree()) @@ -371,8 +371,8 @@ def linear_space(self): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.linear_space() # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.linear_space() Full MatrixSpace of 4 by 4 dense matrices over Finite Field of size 5 """ dp = self.degree() + 1 @@ -390,8 +390,8 @@ def linear(self, A): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.linear([1,2,3,4,5,6,7,8,0]) # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.linear([1,2,3,4,5,6,7,8,0]) [1 2 3] [0] x |-> [4 0 1] x + [0] [2 3 0] [0] @@ -411,8 +411,8 @@ def translation(self, b): EXAMPLES:: - sage: G = AffineGroup(3, GF(5)) # optional - sage.rings.finite_rings - sage: G.translation([1,4,8]) # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(5)) + sage: G.translation([1,4,8]) [1 0 0] [1] x |-> [0 1 0] x + [4] [0 0 1] [3] @@ -440,12 +440,12 @@ def reflection(self, v): EXAMPLES:: - sage: G = AffineGroup(3, QQ) # optional - sage.rings.finite_rings - sage: G.reflection([1,0,0]) # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, QQ) + sage: G.reflection([1,0,0]) [-1 0 0] [0] x |-> [ 0 1 0] x + [0] [ 0 0 1] [0] - sage: G.reflection([3,4,-5]) # optional - sage.rings.finite_rings + sage: G.reflection([3,4,-5]) [ 16/25 -12/25 3/5] [0] x |-> [-12/25 9/25 4/5] x + [0] [ 3/5 4/5 0] [0] @@ -464,13 +464,13 @@ def random_element(self): EXAMPLES:: - sage: G = AffineGroup(4, GF(3)) # optional - sage.rings.finite_rings - sage: G.random_element() # random # optional - sage.rings.finite_rings + sage: G = AffineGroup(4, GF(3)) + sage: G.random_element() # random [2 0 1 2] [1] [2 1 1 2] [2] x |-> [1 0 2 2] x + [2] [1 1 1 1] [2] - sage: G.random_element() in G # optional - sage.rings.finite_rings + sage: G.random_element() in G True """ A = self._GL.random_element() @@ -484,8 +484,8 @@ def _an_element_(self): TESTS:: - sage: G = AffineGroup(4,5) # optional - sage.rings.finite_rings - sage: G.an_element() in G # optional - sage.rings.finite_rings + sage: G = AffineGroup(4,5) + sage: G.an_element() in G True """ A = self._GL.an_element() @@ -498,8 +498,8 @@ def some_elements(self): EXAMPLES:: - sage: G = AffineGroup(4,5) # optional - sage.rings.finite_rings - sage: G.some_elements() # optional - sage.rings.finite_rings + sage: G = AffineGroup(4,5) + sage: G.some_elements() [ [2 0 0 0] [1] [0 1 0 0] [0] x |-> [0 0 1 0] x + [0] @@ -512,7 +512,7 @@ def some_elements(self): [0 1 0 0] [...] x |-> [0 0 1 0] x + [...] [0 0 0 1] [...]] - sage: all(v.parent() is G for v in G.some_elements()) # optional - sage.rings.finite_rings + sage: all(v.parent() is G for v in G.some_elements()) True sage: G = AffineGroup(2,QQ) diff --git a/src/sage/groups/affine_gps/euclidean_group.py b/src/sage/groups/affine_gps/euclidean_group.py index b88b4f741ac..07349c40292 100644 --- a/src/sage/groups/affine_gps/euclidean_group.py +++ b/src/sage/groups/affine_gps/euclidean_group.py @@ -121,11 +121,11 @@ class EuclideanGroup(AffineGroup): Some additional ways to create Euclidean groups:: - sage: A = AffineSpace(2, GF(4,'a')); A # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(4,'a')); A # needs sage.rings.finite_rings Affine Space of dimension 2 over Finite Field in a of size 2^2 - sage: G = EuclideanGroup(A); G # optional - sage.rings.finite_rings + sage: G = EuclideanGroup(A); G # needs sage.rings.finite_rings Euclidean Group of degree 2 over Finite Field in a of size 2^2 - sage: G is EuclideanGroup(2,4) # shorthand # optional - sage.rings.finite_rings + sage: G is EuclideanGroup(2,4) # shorthand # needs sage.rings.finite_rings True sage: V = ZZ^3; V @@ -144,9 +144,9 @@ class EuclideanGroup(AffineGroup): sage: V = QQ^6 sage: E6 is EuclideanGroup(V) True - sage: G = EuclideanGroup(2, GF(5)); G # optional - sage.rings.finite_rings + sage: G = EuclideanGroup(2, GF(5)); G Euclidean Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # optional - sage.rings.finite_rings + sage: TestSuite(G).run() REFERENCES: @@ -195,8 +195,8 @@ def _latex_(self): r""" EXAMPLES:: - sage: G = EuclideanGroup(6, GF(5)) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = EuclideanGroup(6, GF(5)) + sage: latex(G) \mathrm{E}_{6}(\Bold{F}_{5}) """ return "\\mathrm{E}_{%s}(%s)"%(self.degree(), self.base_ring()._latex_()) @@ -207,7 +207,7 @@ def _repr_(self): EXAMPLES:: - sage: EuclideanGroup(6, GF(5)) # optional - sage.rings.finite_rings + sage: EuclideanGroup(6, GF(5)) Euclidean Group of degree 6 over Finite Field of size 5 """ return "Euclidean Group of degree %s over %s"%(self.degree(), self.base_ring()) @@ -218,18 +218,18 @@ def random_element(self): EXAMPLES:: - sage: G = EuclideanGroup(4, GF(3)) # optional - sage.rings.finite_rings - sage: G.random_element() # random # optional - sage.rings.finite_rings + sage: G = EuclideanGroup(4, GF(3)) + sage: G.random_element() # random [2 1 2 1] [1] [1 2 2 1] [0] x |-> [2 2 2 2] x + [1] [1 1 2 2] [2] - sage: G.random_element() in G # optional - sage.rings.finite_rings + sage: G.random_element() in G True TESTS:: - sage: G.random_element().A().is_unitary() # optional - sage.rings.finite_rings + sage: G.random_element().A().is_unitary() True """ while True: diff --git a/src/sage/groups/affine_gps/group_element.py b/src/sage/groups/affine_gps/group_element.py index 48126ba64a8..74d8b684bbb 100644 --- a/src/sage/groups/affine_gps/group_element.py +++ b/src/sage/groups/affine_gps/group_element.py @@ -78,13 +78,13 @@ class AffineGroupElement(MultiplicativeGroupElement): EXAMPLES:: - sage: G = AffineGroup(2, GF(3)) # optional - sage.rings.finite_rings - sage: g = G.random_element() # optional - sage.rings.finite_rings - sage: type(g) # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(3)) + sage: g = G.random_element() + sage: type(g) - sage: G(g.matrix()) == g # optional - sage.rings.finite_rings + sage: G(g.matrix()) == g True - sage: G(2) # optional - sage.rings.finite_rings + sage: G(2) [2 0] [0] x |-> [0 2] x + [0] @@ -108,9 +108,9 @@ def __init__(self, parent, A, b=0, convert=True, check=True): TESTS:: - sage: G = AffineGroup(4, GF(5)) # optional - sage.rings.finite_rings - sage: g = G.random_element() # optional - sage.rings.finite_rings - sage: TestSuite(g).run() # optional - sage.rings.finite_rings + sage: G = AffineGroup(4, GF(5)) + sage: g = G.random_element() + sage: TestSuite(g).run() """ try: A = A.matrix() @@ -181,29 +181,29 @@ def matrix(self): EXAMPLES:: - sage: G = AffineGroup(3, GF(7)) # optional - sage.rings.finite_rings - sage: g = G([1,2,3,4,5,6,7,8,0], [10,11,12]) # optional - sage.rings.finite_rings - sage: g # optional - sage.rings.finite_rings + sage: G = AffineGroup(3, GF(7)) + sage: g = G([1,2,3,4,5,6,7,8,0], [10,11,12]) + sage: g [1 2 3] [3] x |-> [4 5 6] x + [4] [0 1 0] [5] - sage: g.matrix() # optional - sage.rings.finite_rings + sage: g.matrix() [1 2 3|3] [4 5 6|4] [0 1 0|5] [-----+-] [0 0 0|1] - sage: parent(g.matrix()) # optional - sage.rings.finite_rings + sage: parent(g.matrix()) Full MatrixSpace of 4 by 4 dense matrices over Finite Field of size 7 - sage: g.matrix() == matrix(g) # optional - sage.rings.finite_rings + sage: g.matrix() == matrix(g) True Composition of affine group elements equals multiplication of the matrices:: - sage: g1 = G.random_element() # optional - sage.rings.finite_rings - sage: g2 = G.random_element() # optional - sage.rings.finite_rings - sage: g1.matrix() * g2.matrix() == (g1*g2).matrix() # optional - sage.rings.finite_rings + sage: g1 = G.random_element() + sage: g2 = G.random_element() + sage: g1.matrix() * g2.matrix() == (g1*g2).matrix() True """ A = self._A @@ -332,13 +332,13 @@ def _mul_(self, other): EXAMPLES:: - sage: G = AffineGroup(2, GF(3)) # optional - sage.rings.finite_rings - sage: g = G([1,1, 0,1], [0,1]) # optional - sage.rings.finite_rings - sage: h = G([1,1, 0,1], [1,2]) # optional - sage.rings.finite_rings - sage: g*h # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(3)) + sage: g = G([1,1, 0,1], [0,1]) + sage: h = G([1,1, 0,1], [1,2]) + sage: g*h [1 2] [0] x |-> [0 1] x + [0] - sage: g.matrix() * h.matrix() == (g*h).matrix() # optional - sage.rings.finite_rings + sage: g.matrix() * h.matrix() == (g*h).matrix() True """ parent = self.parent() @@ -395,8 +395,8 @@ def __call__(self, v): sage: M = matrix(3, [-1, -2, 0, 0, 0, 1, -2, 1, -1]) sage: v = vector(QQ,(1,2,3)) sage: f = F(M, v) - sage: cube = polytopes.cube() - sage: f(cube) + sage: cube = polytopes.cube() # needs sage.geometry.polyhedron + sage: f(cube) # needs sage.geometry.polyhedron A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 8 vertices """ @@ -432,16 +432,16 @@ def _act_on_(self, x, self_on_left): EXAMPLES:: - sage: G = AffineGroup(2, GF(3)) # optional - sage.rings.finite_rings - sage: g = G([1,2,3,4], [5,6]) # optional - sage.rings.finite_rings - sage: g # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(3)) + sage: g = G([1,2,3,4], [5,6]) + sage: g [1 2] [2] x |-> [0 1] x + [0] - sage: v = vector(GF(3), [1,-1]); v # optional - sage.rings.finite_rings + sage: v = vector(GF(3), [1,-1]); v (1, 2) - sage: g*v # optional - sage.rings.finite_rings + sage: g*v (1, 2) - sage: g*v == g.A() * v + g.b() # optional - sage.rings.finite_rings + sage: g*v == g.A() * v + g.b() True """ if self_on_left: @@ -455,18 +455,18 @@ def __invert__(self): EXAMPLES:: - sage: G = AffineGroup(2, GF(3)) # optional - sage.rings.finite_rings - sage: g = G([1,2,3,4], [5,6]) # optional - sage.rings.finite_rings - sage: g # optional - sage.rings.finite_rings + sage: G = AffineGroup(2, GF(3)) + sage: g = G([1,2,3,4], [5,6]) + sage: g [1 2] [2] x |-> [0 1] x + [0] - sage: ~g # optional - sage.rings.finite_rings + sage: ~g [1 1] [1] x |-> [0 1] x + [0] - sage: g * g.inverse() # indirect doctest # optional - sage.rings.finite_rings + sage: g * g.inverse() # indirect doctest [1 0] [0] x |-> [0 1] x + [0] - sage: g * g.inverse() == g.inverse() * g == G(1) # optional - sage.rings.finite_rings + sage: g * g.inverse() == g.inverse() * g == G(1) True """ parent = self.parent() diff --git a/src/sage/groups/artin.py b/src/sage/groups/artin.py index 617852bacc6..4387e503ba7 100644 --- a/src/sage/groups/artin.py +++ b/src/sage/groups/artin.py @@ -39,6 +39,7 @@ class ArtinGroupElement(FinitelyPresentedGroupElement): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A. = ArtinGroup(['B',3]) sage: A Artin group of type ['B', 3] @@ -57,9 +58,9 @@ def _latex_(self): TESTS:: - sage: A = ArtinGroup(['B',3]) - sage: b = A([1, 2, 3, -1, 2, -3]) - sage: b._latex_() + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: b = A([1, 2, 3, -1, 2, -3]) # needs sage.rings.number_field + sage: b._latex_() # needs sage.rings.number_field '\\sigma_{1}\\sigma_{2}\\sigma_{3}\\sigma_{1}^{-1}\\sigma_{2}\\sigma_{3}^{-1}' sage: B = BraidGroup(4) @@ -80,6 +81,7 @@ def exponent_sum(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['E',6]) sage: b = A([1, 4, -3, 2]) sage: b.exponent_sum() @@ -113,6 +115,7 @@ def coxeter_group_element(self, W=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: B. = ArtinGroup(['B',3]) sage: b = s1 * s2 / s3 / s2 sage: b1 = b.coxeter_group_element(); b1 @@ -163,6 +166,7 @@ def _richcmp_(self, other, op): TESTS:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['B',3]) sage: x = A([1, 2, 1]) sage: y = A([2, 1, 2]) @@ -191,6 +195,7 @@ def __hash__(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: B. = ArtinGroup(['B',3]) sage: hash(s1*s3) == hash(s3*s1) True @@ -218,6 +223,7 @@ def left_normal_form(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['B',3]) sage: A([1]).left_normal_form() (1, s1) @@ -259,6 +265,7 @@ def _left_normal_form_coxeter(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['E',6]) sage: A([2, -4, 2, 3, 1, 3, 2, 1, -2])._left_normal_form_coxeter() ( @@ -375,9 +382,9 @@ class ArtinGroup(FinitelyPresentedGroup): EXAMPLES:: - sage: A. = ArtinGroup(['B',3]); A + sage: A. = ArtinGroup(['B',3]); A # needs sage.rings.number_field Artin group of type ['B', 3] - sage: ArtinGroup(['B',3]) + sage: ArtinGroup(['B',3]) # needs sage.rings.number_field Artin group of type ['B', 3] The input must always include the Coxeter data, but the ``names`` @@ -385,11 +392,11 @@ class ArtinGroup(FinitelyPresentedGroup): the explicit names of the generators. Otherwise the default prefix of ``'s'`` is used:: - sage: ArtinGroup(['B',2]).generators() + sage: ArtinGroup(['B',2]).generators() # needs sage.rings.number_field (s1, s2) - sage: ArtinGroup(['B',2], 'g').generators() + sage: ArtinGroup(['B',2], 'g').generators() # needs sage.rings.number_field (g1, g2) - sage: ArtinGroup(['B',2], 'x,y').generators() + sage: ArtinGroup(['B',2], 'x,y').generators() # needs sage.rings.number_field (x, y) REFERENCES: @@ -407,26 +414,28 @@ def __classcall_private__(cls, coxeter_data, names=None): TESTS:: + sage: # needs sage.rings.number_field sage: A1 = ArtinGroup(['B',3]) sage: A2 = ArtinGroup(['B',3], 's') sage: A3 = ArtinGroup(['B',3], ['s1','s2','s3']) sage: A1 is A2 and A2 is A3 True + sage: # needs sage.rings.number_field sage: A1 = ArtinGroup(['B',2], 'a,b') sage: A2 = ArtinGroup([[1,4],[4,1]], 'a,b') sage: A3. = ArtinGroup('B2') sage: A1 is A2 and A2 is A3 True - sage: ArtinGroup(['A',3]) is BraidGroup(4, 's1,s2,s3') + sage: ArtinGroup(['A',3]) is BraidGroup(4, 's1,s2,s3') # needs sage.rings.number_field True sage: G = graphs.PathGraph(3) sage: CM = CoxeterMatrix([[1,-1,2],[-1,1,-1],[2,-1,1]], index_set=G.vertices(sort=True)) - sage: A = groups.misc.Artin(CM) - sage: Ap = groups.misc.RightAngledArtin(G, 's') - sage: A is Ap + sage: A = groups.misc.Artin(CM) # needs sage.rings.number_field + sage: Ap = groups.misc.RightAngledArtin(G, 's') # needs sage.rings.number_field + sage: A is Ap # needs sage.rings.number_field True """ coxeter_data = CoxeterMatrix(coxeter_data) @@ -457,6 +466,7 @@ def __init__(self, coxeter_matrix, names): TESTS:: + sage: # needs sage.rings.number_field sage: A = ArtinGroup(['D',4]) sage: TestSuite(A).run() sage: A = ArtinGroup(['B',3], ['x','y','z']) @@ -484,9 +494,9 @@ def _repr_(self): TESTS:: - sage: ArtinGroup(['B',3]) + sage: ArtinGroup(['B',3]) # needs sage.rings.number_field Artin group of type ['B', 3] - sage: ArtinGroup(['D',4], 'g') + sage: ArtinGroup(['D',4], 'g') # needs sage.rings.number_field Artin group of type ['D', 4] """ try: @@ -511,8 +521,8 @@ def cardinality(self): sage: G.cardinality() +Infinity - sage: A = ArtinGroup(['A',1]) - sage: A.cardinality() + sage: A = ArtinGroup(['A',1]) # needs sage.rings.number_field + sage: A.cardinality() # needs sage.rings.number_field +Infinity """ from sage.rings.infinity import Infinity @@ -536,8 +546,8 @@ def as_permutation_group(self): ... ValueError: the group is infinite - sage: A = ArtinGroup(['D',4], 'g') - sage: A.as_permutation_group() + sage: A = ArtinGroup(['D',4], 'g') # needs sage.rings.number_field + sage: A.as_permutation_group() # needs sage.rings.number_field Traceback (most recent call last): ... ValueError: the group is infinite @@ -550,8 +560,8 @@ def coxeter_type(self): EXAMPLES:: - sage: A = ArtinGroup(['D',4]) - sage: A.coxeter_type() + sage: A = ArtinGroup(['D',4]) # needs sage.rings.number_field + sage: A.coxeter_type() # needs sage.rings.number_field Coxeter type of ['D', 4] """ return self._coxeter_group.coxeter_type() @@ -562,8 +572,8 @@ def coxeter_matrix(self): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A.coxeter_matrix() + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A.coxeter_matrix() # needs sage.rings.number_field [1 3 2] [3 1 4] [2 4 1] @@ -576,8 +586,8 @@ def coxeter_group(self): EXAMPLES:: - sage: A = ArtinGroup(['D',4]) - sage: A.coxeter_group() + sage: A = ArtinGroup(['D',4]) # needs sage.rings.number_field + sage: A.coxeter_group() # needs sage.rings.number_field Finite Coxeter group over Integer Ring with Coxeter matrix: [1 3 2 2] [3 1 3 3] @@ -596,8 +606,8 @@ def index_set(self): EXAMPLES:: - sage: A = ArtinGroup(['E',7]) - sage: A.index_set() + sage: A = ArtinGroup(['E',7]) # needs sage.rings.number_field + sage: A.index_set() # needs sage.rings.number_field (1, 2, 3, 4, 5, 6, 7) """ return self._coxeter_group.index_set() @@ -606,8 +616,8 @@ def _element_constructor_(self, x): """ TESTS:: - sage: A = ArtinGroup(['B',3]) - sage: A([2,1,-2,3,3,3,1]) + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A([2,1,-2,3,3,3,1]) # needs sage.rings.number_field s2*s1*s2^-1*s3^3*s1 """ if x in self._coxeter_group: @@ -621,8 +631,8 @@ def an_element(self): EXAMPLES:: - sage: A = ArtinGroup(['B',2]) - sage: A.an_element() + sage: A = ArtinGroup(['B',2]) # needs sage.rings.number_field + sage: A.an_element() # needs sage.rings.number_field s1 """ return self.gen(0) @@ -633,8 +643,8 @@ def some_elements(self): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A.some_elements() + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A.some_elements() # needs sage.rings.number_field [s1, s1*s2*s3, (s1*s2*s3)^3] """ rank = self.coxeter_matrix().rank() @@ -654,8 +664,8 @@ def _standard_lift_Tietze(self, w): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A._standard_lift_Tietze(A.coxeter_group().long_element()) + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A._standard_lift_Tietze(A.coxeter_group().long_element()) # needs sage.rings.number_field [3, 2, 3, 1, 2, 3, 1, 2, 1] """ return w.reduced_word() @@ -672,8 +682,8 @@ def _standard_lift(self, w): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A._standard_lift(A.coxeter_group().long_element()) + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A._standard_lift(A.coxeter_group().long_element()) # needs sage.rings.number_field s3*(s2*s3*s1)^2*s2*s1 sage: B = BraidGroup(5) @@ -701,7 +711,7 @@ class FiniteTypeArtinGroup(ArtinGroup): EXAMPLES:: - sage: ArtinGroup(['E',7]) + sage: ArtinGroup(['E',7]) # needs sage.rings.number_field Artin group of type ['E', 7] Since the word problem for finite-type Artin groups is solvable, their @@ -714,15 +724,15 @@ class FiniteTypeArtinGroup(ArtinGroup): ....: for w in Words(alphabet=group.gens(), length=length): ....: ret.add(prod(w)) ....: return ret - sage: A = ArtinGroup(['B',3]) - sage: GA = A.cayley_graph(elements=ball(A, 4), generators=A.gens()); GA + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: GA = A.cayley_graph(elements=ball(A, 4), generators=A.gens()); GA # needs sage.rings.number_field Digraph on 32 vertices Since the Artin group has nontrivial relations, this graph contains less vertices than the one associated to the free group (which is a tree):: sage: F = FreeGroup(3) - sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF + sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF # needs sage.combinat Digraph on 40 vertices """ def delta(self): @@ -731,12 +741,12 @@ def delta(self): EXAMPLES:: - sage: A = ArtinGroup(['B',3]) - sage: A.delta() + sage: A = ArtinGroup(['B',3]) # needs sage.rings.number_field + sage: A.delta() # needs sage.rings.number_field s3*(s2*s3*s1)^2*s2*s1 - sage: A = ArtinGroup(['G',2]) - sage: A.delta() + sage: A = ArtinGroup(['G',2]) # needs sage.rings.number_field + sage: A.delta() # needs sage.rings.number_field (s2*s1)^3 sage: B = BraidGroup(5) diff --git a/src/sage/groups/braid.py b/src/sage/groups/braid.py index acc89d5a5e5..8d6c062bd63 100644 --- a/src/sage/groups/braid.py +++ b/src/sage/groups/braid.py @@ -92,6 +92,7 @@ from sage.rings.integer_ring import IntegerRing from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing from sage.sets.set import Set +from sage.structure.element import Expression from sage.structure.richcmp import richcmp, rich_to_bool lazy_import('sage.libs.braiding', @@ -519,14 +520,14 @@ def plot(self, color='rainbow', orientation='bottom-top', gap=0.05, aspect_ratio False sage: B = BraidGroup(4, 's') sage: b = B([1, 2, 3, 1, 2, 1]) - sage: b.plot() + sage: b.plot() # needs sage.plot Graphics object consisting of 30 graphics primitives - sage: b.plot(color=["red", "blue", "red", "blue"]) + sage: b.plot(color=["red", "blue", "red", "blue"]) # needs sage.plot Graphics object consisting of 30 graphics primitives sage: B. = BraidGroup(3) sage: b = t^-1*s^2 - sage: b.plot(orientation="left-right", color="red") + sage: b.plot(orientation="left-right", color="red") # needs sage.plot Graphics object consisting of 12 graphics primitives """ from sage.plot.bezier_path import bezier_path @@ -620,11 +621,11 @@ def plot3d(self, color='rainbow'): sage: B = BraidGroup(4, 's') sage: b = B([1, 2, 3, 1, 2, 1]) - sage: b.plot3d() + sage: b.plot3d() # needs sage.plot sage.symbolic Graphics3d Object - sage: b.plot3d(color="red") + sage: b.plot3d(color="red") # needs sage.plot sage.symbolic Graphics3d Object - sage: b.plot3d(color=["red", "blue", "red", "blue"]) + sage: b.plot3d(color=["red", "blue", "red", "blue"]) # needs sage.plot sage.symbolic Graphics3d Object """ from sage.plot.plot3d.shapes2 import bezier3d @@ -826,8 +827,8 @@ def links_gould_matrix(self, symbolics=False): Univariate Quotient Polynomial Ring in Yrbar over Multivariate Laurent Polynomial Ring in s0r, s1r over Integer Ring with modulus Yr^2 + s0r^2*s1r^2 - s0r^2 - s1r^2 + 1 - sage: HopfLGs = Hopf.links_gould_matrix(symbolics=True) - sage: HopfLGs.base_ring() + sage: HopfLGs = Hopf.links_gould_matrix(symbolics=True) # needs sage.symbolic + sage: HopfLGs.base_ring() # needs sage.symbolic Symbolic Ring """ rep = self.parent()._links_gould_representation(symbolics=symbolics) @@ -1030,15 +1031,15 @@ def _jones_polynomial(self): sage: B = BraidGroup(9) sage: b = B([1, 2, 3, 4, 5, 6, 7, 8]) - sage: b.jones_polynomial() + sage: b.jones_polynomial() # needs sage.symbolic 1 sage: B = BraidGroup(2) sage: b = B([]) - sage: b._jones_polynomial + sage: b._jones_polynomial # needs sage.symbolic -A^-2 - A^2 sage: b = B([-1, -1, -1]) - sage: b._jones_polynomial + sage: b._jones_polynomial # needs sage.symbolic -A^-16 + A^-12 + A^-4 """ trace = self.markov_trace(normalized=False) @@ -1086,25 +1087,26 @@ def jones_polynomial(self, variab=None, skein_normalization=False): sage: B = BraidGroup(9) sage: b = B([1, 2, 3, 4, 5, 6, 7, 8]) - sage: b.jones_polynomial() + sage: b.jones_polynomial() # needs sage.symbolic 1 Two unlinked unknots:: sage: B = BraidGroup(2) sage: b = B([]) - sage: b.jones_polynomial() + sage: b.jones_polynomial() # needs sage.symbolic -sqrt(t) - 1/sqrt(t) The Hopf link:: sage: B = BraidGroup(2) sage: b = B([-1,-1]) - sage: b.jones_polynomial() + sage: b.jones_polynomial() # needs sage.symbolic -1/sqrt(t) - 1/t^(5/2) Different representations of the trefoil and one of its mirror:: + sage: # needs sage.symbolic sage: B = BraidGroup(2) sage: b = B([-1, -1, -1]) sage: b.jones_polynomial(skein_normalization=True) @@ -1129,7 +1131,7 @@ def jones_polynomial(self, variab=None, skein_normalization=False): sage: B = BraidGroup(4) sage: b11n42 = B([1, -2, 3, -2, 3, -2, -2, -1, 2, -3, -3, 2, 2]) sage: b11n34 = B([1, 1, 2, -3, 2, -3, 1, -2, -2, -3, -3]) - sage: bool(b11n42.jones_polynomial() == b11n34.jones_polynomial()) + sage: bool(b11n42.jones_polynomial() == b11n34.jones_polynomial()) # needs sage.symbolic True """ if skein_normalization: @@ -1138,12 +1140,14 @@ def jones_polynomial(self, variab=None, skein_normalization=False): else: return self._jones_polynomial(variab) else: - from sage.symbolic.ring import SR from sage.rings.integer_ring import ZZ if variab is None: variab = 't' + if not isinstance(variab, Expression): + from sage.symbolic.ring import SR + variab = SR(variab) # We force the result to be in the symbolic ring because of the expand - return self._jones_polynomial(SR(variab)**(ZZ(1)/ZZ(4))).expand() + return self._jones_polynomial(variab**(ZZ(1)/ZZ(4))).expand() @cached_method def _enhanced_states(self): @@ -1505,15 +1509,15 @@ def left_normal_form(self, algorithm='libbraiding'): sage: b = B([-2, 2, -4, -4, 4, -5, -1, 4, -1, 1]) sage: L1 = b.left_normal_form(); L1 (s0^-1*s1^-1*s0^-1*s2^-1*s1^-1*s0^-1*s3^-1*s2^-1*s1^-1*s0^-1*s4^-1*s3^-1*s2^-1*s1^-1*s0^-1, - s0*s2*s1*s0*s3*s2*s1*s0*s4*s3*s2*s1, - s3) + s0*s2*s1*s0*s3*s2*s1*s0*s4*s3*s2*s1, + s3) sage: L1 == b.left_normal_form() True sage: B([1]).left_normal_form(algorithm='artin') (1, s0) sage: B([-3]).left_normal_form(algorithm='artin') (s0^-1*s1^-1*s0^-1*s2^-1*s1^-1*s0^-1*s3^-1*s2^-1*s1^-1*s0^-1*s4^-1*s3^-1*s2^-1*s1^-1*s0^-1, - s0*s1*s2*s3*s4*s0*s1*s2*s3*s1*s2*s0*s1*s0) + s0*s1*s2*s3*s4*s0*s1*s2*s3*s1*s2*s0*s1*s0) sage: B = BraidGroup(3) sage: B([1,2,-1]).left_normal_form() (s0^-1*s1^-1*s0^-1, s1*s0, s0*s1) @@ -1646,9 +1650,9 @@ def super_summit_set(self): sage: b = B([1, 2, -1, -2, -2, 1]) sage: b.super_summit_set() [s0^-1*s1^-1*s0^-2*s1^2*s0^2, - (s0^-1*s1^-1*s0^-1)^2*s1^2*s0^3*s1, - (s0^-1*s1^-1*s0^-1)^2*s1*s0^3*s1^2, - s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^3*s0] + (s0^-1*s1^-1*s0^-1)^2*s1^2*s0^3*s1, + (s0^-1*s1^-1*s0^-1)^2*s1*s0^3*s1^2, + s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^3*s0] """ sss = supersummitset(self) @@ -1733,8 +1737,8 @@ def conjugating_braid(self, other): True sage: d1 * a / d1 == c False - sage: l = sage.groups.braid.conjugatingbraid(a,c) - sage: d1 == B._element_from_libbraiding(l) + sage: l = sage.groups.braid.conjugatingbraid(a,c) # needs sage.groups + sage: d1 == B._element_from_libbraiding(l) # needs sage.groups True sage: b = B([2, 2, 2, 2, 1]) sage: c = b * a / b @@ -1747,9 +1751,9 @@ def conjugating_braid(self, other): False sage: d1 s1^2*s0^2*s1^2*s0 - sage: l = sage.groups.braid.conjugatingbraid(a,c) - sage: d2 = B._element_from_libbraiding(l) - sage: len(d2.Tietze()) + sage: l = sage.groups.braid.conjugatingbraid(a,c) # needs sage.groups + sage: d2 = B._element_from_libbraiding(l) # needs sage.groups + sage: len(d2.Tietze()) # needs sage.groups 13 sage: c.conjugating_braid(b) is None True @@ -1891,17 +1895,17 @@ def ultra_summit_set(self): [[s0*s1*s0^2, (s0*s1)^2]] sage: a.ultra_summit_set() [[(s0^-1*s1^-1*s0^-1)^2*s1^3*s0^2*s1^3, - (s0^-1*s1^-1*s0^-1)^2*s1^2*s0^2*s1^4, - (s0^-1*s1^-1*s0^-1)^2*s1*s0^2*s1^5, - s0^-1*s1^-1*s0^-2*s1^5*s0, - (s0^-1*s1^-1*s0^-1)^2*s1^5*s0^2*s1, - (s0^-1*s1^-1*s0^-1)^2*s1^4*s0^2*s1^2], - [s0^-1*s1^-1*s0^-2*s1^-1*s0^2*s1^2*s0^3, - s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^2*s0^4, - s0^-1*s1^-1*s0^-2*s1*s0^5, - (s0^-1*s1^-1*s0^-1)^2*s1*s0^6*s1, - s0^-1*s1^-1*s0^-2*s1^-1*s0^4*s1^2*s0, - s0^-1*s1^-1*s0^-2*s1^-1*s0^3*s1^2*s0^2]] + (s0^-1*s1^-1*s0^-1)^2*s1^2*s0^2*s1^4, + (s0^-1*s1^-1*s0^-1)^2*s1*s0^2*s1^5, + s0^-1*s1^-1*s0^-2*s1^5*s0, + (s0^-1*s1^-1*s0^-1)^2*s1^5*s0^2*s1, + (s0^-1*s1^-1*s0^-1)^2*s1^4*s0^2*s1^2], + [s0^-1*s1^-1*s0^-2*s1^-1*s0^2*s1^2*s0^3, + s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^2*s0^4, + s0^-1*s1^-1*s0^-2*s1*s0^5, + (s0^-1*s1^-1*s0^-1)^2*s1*s0^6*s1, + s0^-1*s1^-1*s0^-2*s1^-1*s0^4*s1^2*s0, + s0^-1*s1^-1*s0^-2*s1^-1*s0^3*s1^2*s0^2]] """ uss = ultrasummitset(self) B = self.parent() @@ -2573,10 +2577,10 @@ def __init__(self, names): d*f*d^-1*f^-1, e*f*e*f^-1*e^-1*f^-1) - sage: BraidGroup([]) - Traceback (most recent call last): - ... - ValueError: the number of strands must be at least 2 + sage: BraidGroup([]) + Traceback (most recent call last): + ... + ValueError: the number of strands must be at least 2 """ n = len(names) # n is the number of generators, not the number of strands @@ -2625,7 +2629,7 @@ def _repr_(self): TESTS:: sage: B1 = BraidGroup(5) - sage: B1 # indirect doctest + sage: B1 # indirect doctest Braid group on 5 strands """ return "Braid group on %s strands" % self._nstrands @@ -2989,11 +2993,11 @@ def dimension_of_TL_space(self, drain_size): The direct sum of endomorphism spaces of these vector spaces make up the entire Temperley--Lieb algebra:: - sage: import sage.combinat.diagram_algebras as da + sage: import sage.combinat.diagram_algebras as da # needs sage.combinat sage: B = BraidGroup(6) sage: dimensions = [B.dimension_of_TL_space(d)**2 for d in [0, 2, 4, 6]] sage: total_dim = sum(dimensions) - sage: total_dim == len(list(da.temperley_lieb_diagrams(6))) # long time + sage: total_dim == len(list(da.temperley_lieb_diagrams(6))) # long time, needs sage.combinat True """ n = self.strands() @@ -3539,14 +3543,14 @@ def BraidGroup(n=None, names='s'): ....: ret.add(prod(w)) ....: return ret sage: B = BraidGroup(4) - sage: GB = B.cayley_graph(elements=ball(B, 4), generators=B.gens()); GB + sage: GB = B.cayley_graph(elements=ball(B, 4), generators=B.gens()); GB # needs sage.combinat sage.graphs Digraph on 31 vertices Since the braid group has nontrivial relations, this graph contains less vertices than the one associated to the free group (which is a tree):: sage: F = FreeGroup(3) - sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF + sage: GF = F.cayley_graph(elements=ball(F, 4), generators=F.gens()); GF # needs sage.combinat sage.graphs Digraph on 40 vertices TESTS:: diff --git a/src/sage/groups/cactus_group.py b/src/sage/groups/cactus_group.py index 9a481cc783c..a12fbb88563 100644 --- a/src/sage/groups/cactus_group.py +++ b/src/sage/groups/cactus_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field r""" Cactus Groups @@ -970,7 +971,7 @@ def gens(self): sage: gen == b True """ - from sage.functions.other import factorial + from sage.arith.misc import factorial J = self.ambient() G = J.gens() one = J.one() diff --git a/src/sage/groups/class_function.py b/src/sage/groups/class_function.py index 08d69ce57b0..c788a596809 100644 --- a/src/sage/groups/class_function.py +++ b/src/sage/groups/class_function.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field r""" Class functions of groups. @@ -27,10 +28,12 @@ from sage.structure.richcmp import richcmp, richcmp_method from sage.interfaces.gap import gap from sage.rings.integer import Integer -from sage.rings.number_field.number_field import CyclotomicField from sage.libs.gap.element import GapElement from sage.libs.gap.libgap import libgap from sage.libs.gap.element import GapElement as LibGapElement +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.rings.number_field.number_field', 'CyclotomicField') # TODO: # @@ -712,7 +715,8 @@ def restrict(self, H): Character of Symmetric group of order 5! as a permutation group sage: H = G.subgroup([(1,2,3), (1,2), (4,5)]) sage: chi.restrict(H) - Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of (Symmetric group of order 5! as a permutation group) + Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of + (Symmetric group of order 5! as a permutation group) sage: chi.restrict(H).values() [3, -3, -3, -1, 0, 0] """ @@ -738,7 +742,8 @@ def induct(self, G): sage: G = SymmetricGroup(5) sage: H = G.subgroup([(1,2,3), (1,2), (4,5)]) sage: xi = H.trivial_character(); xi - Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of (Symmetric group of order 5! as a permutation group) + Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of + (Symmetric group of order 5! as a permutation group) sage: xi.induct(G) Character of Symmetric group of order 5! as a permutation group sage: xi.induct(G).values() @@ -1331,7 +1336,7 @@ def values(self): EXAMPLES:: sage: G = GL(2,3) - sage: [x.values() for x in G.irreducible_characters()] #random + sage: [x.values() for x in G.irreducible_characters()] # random [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, -1, -1, -1], [2, -1, 2, -1, 2, 0, 0, 0], @@ -1409,7 +1414,8 @@ def restrict(self, H): Character of Symmetric group of order 5! as a permutation group sage: H = G.subgroup([(1,2,3), (1,2), (4,5)]) sage: chi.restrict(H) - Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of (Symmetric group of order 5! as a permutation group) + Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of + (Symmetric group of order 5! as a permutation group) sage: chi.restrict(H).values() [3, -3, -3, -1, 0, 0] """ @@ -1440,7 +1446,8 @@ def induct(self, G): sage: G = SymmetricGroup(5) sage: H = G.subgroup([(1,2,3), (1,2), (4,5)]) sage: xi = H.trivial_character(); xi - Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of (Symmetric group of order 5! as a permutation group) + Character of Subgroup generated by [(4,5), (1,2), (1,2,3)] of + (Symmetric group of order 5! as a permutation group) sage: xi.induct(G) Character of Symmetric group of order 5! as a permutation group sage: xi.induct(G).values() diff --git a/src/sage/groups/conjugacy_classes.py b/src/sage/groups/conjugacy_classes.py index fd79d60ee5b..4ad8200ef23 100644 --- a/src/sage/groups/conjugacy_classes.py +++ b/src/sage/groups/conjugacy_classes.py @@ -24,7 +24,7 @@ sage: G = SymmetricGroup(4) sage: g = G((1,2,3,4)) - sage: G.conjugacy_class(g) + sage: G.conjugacy_class(g) # needs sage.combinat Conjugacy class of cycle type [4] in Symmetric group of order 4! as a permutation group Conjugacy classes for groups of matrices:: @@ -90,7 +90,7 @@ def __init__(self, group, element): sage: ConjugacyClass(G,g) Conjugacy class of (1,2,3,4) in Symmetric group of order 4! as a permutation group - sage: TestSuite(G).run() + sage: TestSuite(G).run() # needs sage.rings.number_field """ self._parent = group self._representative = element @@ -432,6 +432,7 @@ def cardinality(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: W = WeylGroup(['C',6]) sage: cc = W.conjugacy_class(W.an_element()) sage: cc.cardinality() @@ -449,6 +450,7 @@ def __contains__(self, g): TESTS:: + sage: # needs sage.rings.number_field sage: W = WeylGroup(['C',6]) sage: g0,g1,g2,g3,g4,g5 = W.gens() sage: cc = W.conjugacy_class(g0) diff --git a/src/sage/groups/cubic_braid.py b/src/sage/groups/cubic_braid.py index f49293e9924..5c72c9a7aef 100644 --- a/src/sage/groups/cubic_braid.py +++ b/src/sage/groups/cubic_braid.py @@ -80,19 +80,22 @@ # https://www.gnu.org/licenses/ # **************************************************************************** +from enum import Enum + +import sage.rings.abc + from sage.categories.groups import Groups from sage.categories.shephard_groups import ShephardGroups -from sage.misc.cachefunc import cached_method -from sage.libs.gap.element import GapElement from sage.groups.free_group import FreeGroup from sage.groups.finitely_presented import FinitelyPresentedGroup, FinitelyPresentedGroupElement from sage.groups.braid import BraidGroup +from sage.misc.cachefunc import cached_method from sage.rings.integer import Integer -from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField -from sage.rings.number_field.number_field import CyclotomicField -from sage.rings.finite_rings.finite_field_constructor import GF -from enum import Enum +try: + from sage.libs.gap.element import GapElement +except ImportError: + GapElement = () ############################################################################## @@ -386,13 +389,15 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, sage: C3. = CubicBraidGroup(3) sage: ele = c1*c2*c1 + + sage: # needs sage.rings.number_field sage: BuMa = ele.burau_matrix(); BuMa [ -zeta3 1 zeta3] [ -zeta3 zeta3 + 1 0] [ 1 0 0] sage: BuMa.base_ring() Cyclotomic Field of order 3 and degree 2 - sage: BuMa == ele.burau_matrix(characteristic = 0) + sage: BuMa == ele.burau_matrix(characteristic=0) True sage: BuMa = ele.burau_matrix(domain=QQ); BuMa [-t + 1 1 t - 1] @@ -400,18 +405,21 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Number Field in t with defining polynomial t^2 - t + 1 - sage: BuMa = ele.burau_matrix(domain = QQ[I, sqrt(3)]); BuMa + sage: BuMa = ele.burau_matrix(domain = QQ[I, sqrt(3)]); BuMa # needs sage.symbolic [ 1/2*sqrt3*I + 1/2 1 -1/2*sqrt3*I - 1/2] [ 1/2*sqrt3*I + 1/2 -1/2*sqrt3*I + 1/2 0] [ 1 0 0] - sage: BuMa.base_ring() + sage: BuMa.base_ring() # needs sage.symbolic Number Field in I with defining polynomial x^2 + 1 over its base field + sage: BuMa = ele.burau_matrix(characteristic=7); BuMa [3 1 4] [3 5 0] [1 0 0] sage: BuMa.base_ring() Finite Field of size 7 + + sage: # needs sage.rings.finite_rings sage: BuMa = ele.burau_matrix(characteristic=2); BuMa [t + 1 1 t + 1] [t + 1 t 0] @@ -431,6 +439,8 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, [ 1 0 0] sage: BuMa.base_ring() Finite Field in t of size 5^2 + + sage: # needs sage.rings.number_field sage: BuMa, BuMaAd, H = ele.burau_matrix(reduced='unitary'); BuMa [ 0 zeta12^3] [zeta12^3 0] @@ -438,10 +448,11 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, True sage: BuMa.base_ring() Cyclotomic Field of order 12 and degree 4 - sage: BuMa, BuMaAd, H = ele.burau_matrix(domain = QQ[I, sqrt(3)], reduced='unitary'); BuMa + sage: BuMa, BuMaAd, H = ele.burau_matrix(domain=QQ[I, sqrt(3)], # needs sage.symbolic + ....: reduced='unitary'); BuMa [0 I] [I 0] - sage: BuMa.base_ring() + sage: BuMa.base_ring() # needs sage.symbolic Number Field in I with defining polynomial x^2 + 1 over its base field """ braid = self.braid() @@ -460,7 +471,7 @@ def burau_matrix(self, root_bur=None, domain=None, characteristic=None, burau_ori, burau_ori_adj, herm_form_ori = burau_ori if domain is not None: - if isinstance(domain, UniversalCyclotomicField): + if isinstance(domain, sage.rings.abc.UniversalCyclotomicField): if root_bur is None: if unitary: root_bur = domain.gen(12) @@ -504,11 +515,13 @@ def find_root(domain): if not characteristic.is_zero() and not characteristic.is_prime(): raise ValueError('characteristic must be a prime') if characteristic.is_zero(): + from sage.rings.number_field.number_field import CyclotomicField if unitary: domain = CyclotomicField(12) else: domain = CyclotomicField(3) else: + from sage.rings.finite_rings.finite_field_constructor import GF domain = GF(characteristic) root_bur = find_root(domain) domain = root_bur.parent() @@ -628,13 +641,15 @@ class CubicBraidGroup(FinitelyPresentedGroup): #I Forcing finiteness test True sage: U3.as_classical_group() - Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] + Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), + (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] of (The projective general unitary group of degree 3 over Finite Field of size 2) sage: C3.as_classical_group() Subgroup with 2 generators ( [ E(3)^2 0] [ 1 -E(12)^7] [-E(12)^7 1], [ 0 E(3)^2] - ) of General Unitary Group of degree 2 over Universal Cyclotomic Field with respect to positive definite hermitian form + ) of General Unitary Group of degree 2 over Universal Cyclotomic Field + with respect to positive definite hermitian form [-E(12)^7 + E(12)^11 -1] [ -1 -E(12)^7 + E(12)^11] @@ -963,12 +978,19 @@ def _test_matrix_group(self, **options): sage: CBG2._test_matrix_group() """ tester = self._tester(**options) + + MatDEF = self.as_matrix_group() + self._internal_test_attached_group(MatDEF, tester) + + try: + from sage.rings.finite_rings.finite_field_constructor import GF + except ImportError: + return + F3 = GF(3) r63 = F3(2) F4 = GF(4) r64 = F4.gen() - MatDEF = self.as_matrix_group() - self._internal_test_attached_group(MatDEF, tester) if self._cbg_type != CubicBraidGroup.type.AssionU or self.strands() < 5: # not well defined else-wise matrix_grpF3 = self.as_matrix_group(root_bur=r63) @@ -1317,6 +1339,8 @@ def transvec2mat(v, bas=bas, bform=bform, fact=a): # now 1 + 2*cos(\pi/6)*i\theta = 1 + sqrt(3)*(-sqrt(3)/2 + I/2) = 1- 3/2 + sqrt(3)I/2 = z12^4 = - ~z12^2 # finally: Coxeter's Realization is the unitary Burau representation of Squier for s = ~z12 # ----------------------------------------------------------------------------------------------- + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField + UCF = UniversalCyclotomicField() z12 = UCF.gen(12) classical_group = self.as_matrix_group(root_bur=~z12, domain=UCF, reduced='unitary') @@ -1464,6 +1488,7 @@ def as_matrix_group(self, root_bur=None, domain=None, characteristic=None, var=' EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: C5 = CubicBraidGroup(5) sage: C5Mch5 = C5.as_matrix_group(characteristic=5); C5Mch5 Matrix group over Finite Field in t of size 5^2 with 4 generators ( @@ -1641,10 +1666,12 @@ def as_classical_group(self, embedded=False): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: U3 = AssionGroupU(3) sage: U3Cl = U3.as_classical_group(); U3Cl - Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] - of (The projective general unitary group of degree 3 over Finite Field of size 2) + Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), + (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] of + (The projective general unitary group of degree 3 over Finite Field of size 2) sage: U3Clemb = U3.as_classical_group(embedded=True); U3Clemb Subgroup with 2 generators ( [0 0 a] [a + 1 a a] @@ -1668,6 +1695,8 @@ def as_classical_group(self, embedded=False): General Unitary Group of degree 3 over Finite Field in a of size 2^2 sage: U3Clemb.ambient() == U4Cl True + + sage: # needs sage.rings.number_field sage: C4 = CubicBraidGroup(4) sage: C4Cl = C4.as_classical_group(); C4Cl Subgroup with 3 generators ( @@ -1678,7 +1707,8 @@ def as_classical_group(self, embedded=False): [ 1 0 0] [ 0 1 -E(12)^7] [ 0 0 E(3)^2] - ) of General Unitary Group of degree 3 over Universal Cyclotomic Field with respect to positive definite hermitian form + ) of General Unitary Group of degree 3 over Universal Cyclotomic Field + with respect to positive definite hermitian form [-E(12)^7 + E(12)^11 -1 0] [ -1 -E(12)^7 + E(12)^11 -1] [ 0 -1 -E(12)^7 + E(12)^11] @@ -1726,27 +1756,29 @@ def as_reflection_group(self): EXAMPLES:: - sage: C3. = CubicBraidGroup(3) # optional - gap3 - sage: R3 = C3.as_reflection_group(); R3 # optional - gap3 + sage: # optional - gap3 + sage: C3. = CubicBraidGroup(3) + sage: R3 = C3.as_reflection_group(); R3 Irreducible complex reflection group of rank 2 and type ST4 - sage: R3.cartan_matrix() # optional - gap3 + sage: R3.cartan_matrix() [-2*E(3) - E(3)^2 E(3)^2] [ -E(3)^2 -2*E(3) - E(3)^2] - sage: R3.simple_roots() # optional - gap3 + sage: R3.simple_roots() Finite family {1: (0, -2*E(3) - E(3)^2), 2: (2*E(3)^2, E(3)^2)} - sage: R3.simple_coroots() # optional - gap3 + sage: R3.simple_coroots() Finite family {1: (0, 1), 2: (1/3*E(3) - 1/3*E(3)^2, 1/3*E(3) - 1/3*E(3)^2)} Conversion maps:: - sage: r = R3.an_element() # optional - gap3 - sage: cr = C3(r); cr # optional - gap3 + sage: # optional - gap3 + sage: r = R3.an_element() + sage: cr = C3(r); cr c1*c2 - sage: mr = r.matrix(); mr # optional - gap3 + sage: mr = r.matrix(); mr [ 1/3*E(3) - 1/3*E(3)^2 2/3*E(3) + 1/3*E(3)^2] [-2/3*E(3) + 2/3*E(3)^2 2/3*E(3) + 1/3*E(3)^2] - sage: C3Cl = C3.as_classical_group() # optional - gap3 - sage: C3Cl(cr) # optional - gap3 + sage: C3Cl = C3.as_classical_group() + sage: C3Cl(cr) [ E(3)^2 -E(4)] [-E(12)^7 0] @@ -1756,13 +1788,14 @@ def as_reflection_group(self): the classical group due to different hermitian forms for the unitary groups they live in:: - sage: C4 = CubicBraidGroup(4) # optional - gap3 - sage: R4 = C4.as_reflection_group() # optional - gap3 - sage: R4.invariant_form() # optional - gap3 + sage: # optional - gap3 + sage: C4 = CubicBraidGroup(4) + sage: R4 = C4.as_reflection_group() + sage: R4.invariant_form() [1 0 0] [0 1 0] [0 0 1] - sage: _ == C4.classical_invariant_form() # optional - gap3 + sage: _ == C4.classical_invariant_form() False """ # ------------------------------------------------------------------------------- @@ -1895,7 +1928,8 @@ def centralizing_element(self, embedded=False): sage: U3 = AssionGroupU(3); U3 Assion group on 3 strands of type U sage: U3Cl = U3.as_classical_group(); U3Cl - Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] + Subgroup generated by [(1,7,6)(3,19,14)(4,15,10)(5,11,18)(12,16,20), + (1,12,13)(2,15,19)(4,9,14)(5,18,8)(6,21,16)] of (The projective general unitary group of degree 3 over Finite Field of size 2) sage: c = U3.centralizing_element(); c (1,16)(2,9)(3,10)(4,19)(6,12)(7,20)(13,21)(14,15) diff --git a/src/sage/groups/finitely_presented_named.py b/src/sage/groups/finitely_presented_named.py index 177f7908895..4968293e30d 100644 --- a/src/sage/groups/finitely_presented_named.py +++ b/src/sage/groups/finitely_presented_named.py @@ -548,7 +548,7 @@ def BinaryDihedralPresentation(n): TESTS:: - sage: for n in range(3, 9): + sage: for n in range(3, 9): # needs sage.modules ....: P = groups.presentation.BinaryDihedral(n) ....: M = groups.matrix.BinaryDihedral(n) ....: assert P.is_isomorphic(M) @@ -574,7 +574,7 @@ def CactusPresentation(n): EXAMPLES:: - sage: J3 = groups.presentation.Cactus(3); J3 + sage: J3 = groups.presentation.Cactus(3); J3 # needs sage.graphs Finitely presented group < s12, s13, s23 | s12^2, s13^2, s23^2, s13*s12*s13^-1*s23^-1, s13*s23*s13^-1*s12^-1 > """ diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py index 32a434d3bd9..bf9ab9000e2 100644 --- a/src/sage/groups/fqf_orthogonal.py +++ b/src/sage/groups/fqf_orthogonal.py @@ -8,19 +8,20 @@ EXAMPLES:: - sage: L = IntegralLattice("A2").twist(2) - sage: T = L.discriminant_group() - sage: Oq = T.orthogonal_group() + sage: L = IntegralLattice("A2").twist(2) # needs sage.graphs + sage: T = L.discriminant_group() # needs sage.graphs + sage: Oq = T.orthogonal_group() # needs sage.graphs The isometries act on elements of their domain:: - sage: g = Oq(matrix(ZZ, 2, [0, 3, 1, 2])) - sage: T.gen(0) * g + sage: g = Oq(matrix(ZZ, 2, [0, 3, 1, 2])) # needs sage.graphs + sage: T.gen(0) * g # needs sage.graphs (0, 3) Isometries are represented with respect to the Smith form generators of `T`:: + sage: # needs sage.graphs sage: L = IntegralLattice("A2").twist(2).direct_sum(IntegralLattice('U')) sage: T = L.discriminant_group().normal_form() sage: OT = T.orthogonal_group() @@ -216,6 +217,7 @@ def _element_constructor_(self, x, check=True): EXAMPLES:: + sage: # needs sage.graphs sage: L = IntegralLattice("A2").twist(2).direct_sum(IntegralLattice("A2")) sage: q = L.discriminant_group() sage: OL = L.orthogonal_group() @@ -230,18 +232,19 @@ def _element_constructor_(self, x, check=True): Note that the following does not work since it may lead to ambiguities, see :trac:`30669`:: - sage: Oq(f.matrix()) + sage: Oq(f.matrix()) # needs sage.graphs Traceback (most recent call last): ... ValueError: ... But a matrix in the covering works:: - sage: fbar == Oq(fbar.matrix()) + sage: fbar == Oq(fbar.matrix()) # needs sage.graphs True TESTS:: + sage: # needs sage.graphs sage: all(x*f==x*fbar for x in q.gens()) True sage: L = IntegralLattice("A2").twist(3) diff --git a/src/sage/groups/free_group.py b/src/sage/groups/free_group.py index 0c51deafc64..654a91c7372 100644 --- a/src/sage/groups/free_group.py +++ b/src/sage/groups/free_group.py @@ -89,11 +89,11 @@ def is_FreeGroup(x): EXAMPLES:: sage: from sage.groups.free_group import is_FreeGroup - sage: is_FreeGroup('a string') + sage: is_FreeGroup('a string') # needs sage.combinat False sage: is_FreeGroup(FreeGroup(0)) True - sage: is_FreeGroup(FreeGroup(index_set=ZZ)) + sage: is_FreeGroup(FreeGroup(index_set=ZZ)) # needs sage.combinat True """ if isinstance(x, FreeGroup_class): @@ -645,9 +645,9 @@ def FreeGroup(n=None, names='x', index_set=None, abelian=False, **kwds): We give two examples using the ``index_set`` option:: - sage: FreeGroup(index_set=ZZ) + sage: FreeGroup(index_set=ZZ) # needs sage.combinat Free group indexed by Integer Ring - sage: FreeGroup(index_set=ZZ, abelian=True) + sage: FreeGroup(index_set=ZZ, abelian=True) # needs sage.combinat Free abelian group indexed by Integer Ring TESTS:: diff --git a/src/sage/groups/galois_group.py b/src/sage/groups/galois_group.py index bc1b9a807f1..ed9e6d61bd4 100644 --- a/src/sage/groups/galois_group.py +++ b/src/sage/groups/galois_group.py @@ -31,9 +31,9 @@ def _alg_key(self, algorithm=None, recompute=False): sage: from sage.groups.galois_group import _alg_key sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: _alg_key(G, algorithm="pari", recompute=True) + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: _alg_key(G, algorithm="pari", recompute=True) # needs sage.rings.number_field 'pari' """ if recompute: @@ -55,9 +55,9 @@ def _default_algorithm(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: G._default_algorithm + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G._default_algorithm # needs sage.rings.number_field 'pari' """ return NotImplemented @@ -74,9 +74,9 @@ def _gcdata(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 - 2) - sage: G = K.galois_group() - sage: G._gcdata + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G._gcdata # needs sage.rings.number_field (Number Field in ac with defining polynomial x^6 + 108, Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 @@ -91,6 +91,7 @@ def _get_algorithm(self, algorithm): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] sage: K. = NumberField(x^3 + 2*x + 2) sage: G = K.galois_group() @@ -109,9 +110,9 @@ def _galois_closure(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group(names='b') - sage: G._galois_closure + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group(names='b') # needs sage.rings.number_field + sage: G._galois_closure # needs sage.rings.number_field Number Field in b with defining polynomial x^6 + 12*x^4 + 36*x^2 + 140 """ return self._gcdata[0] @@ -122,6 +123,7 @@ def splitting_field(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K = NumberField(x^3 - x + 1, 'a') sage: K.galois_group(names='b').splitting_field() @@ -139,9 +141,9 @@ def _gc_map(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group(names='b') - sage: G._gc_map + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group(names='b') # needs sage.rings.number_field + sage: G._gc_map # needs sage.rings.number_field Ring morphism: From: Number Field in a with defining polynomial x^3 + 2*x + 2 To: Number Field in b with defining polynomial x^6 + 12*x^4 + 36*x^2 + 140 @@ -162,9 +164,9 @@ def _field(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: G._field + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G._field # needs sage.rings.number_field Number Field in a with defining polynomial x^3 + 2*x + 2 """ return NotImplemented @@ -177,9 +179,9 @@ def _repr_(self): sage: from sage.groups.galois_group import GaloisGroup_perm sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: GaloisGroup_perm._repr_(G) + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: GaloisGroup_perm._repr_(G) # needs sage.rings.number_field 'Galois group of x^3 + 2*x + 2' """ f = self._field.defining_polynomial() @@ -193,6 +195,7 @@ def top_field(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] sage: K. = NumberField(x^3 + 2*x + 2) sage: L = K.galois_closure('b') @@ -212,6 +215,7 @@ def _field_degree(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] sage: K. = NumberField(x^3 + 2*x + 2) sage: L. = K.extension(x^2 + 3*a^2 + 8) @@ -229,11 +233,11 @@ def _field_degree(self): This behavior may change in the future:: - sage: GL._field_degree + sage: GL._field_degree # needs sage.rings.number_field 6 - sage: GL.transitive_label() + sage: GL.transitive_label() # needs sage.rings.number_field '6T2' - sage: GL + sage: GL # needs sage.rings.number_field Galois group 6T2 ([3]2) with order 6 of x^2 + 3*a^2 + 8 """ try: @@ -249,9 +253,9 @@ def transitive_label(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^8 - x^5 + x^4 - x^3 + 1) - sage: G = K.galois_group() - sage: G.transitive_label() + sage: K. = NumberField(x^8 - x^5 + x^4 - x^3 + 1) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G.transitive_label() # needs sage.rings.number_field '8T44' """ return "%sT%s" % (self._field_degree, self.transitive_number()) @@ -263,10 +267,10 @@ def is_galois(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^8 - x^5 + x^4 - x^3 + 1) - sage: G = K.galois_group() + sage: K. = NumberField(x^8 - x^5 + x^4 - x^3 + 1) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field sage: from sage.groups.galois_group import GaloisGroup_perm - sage: GaloisGroup_perm.is_galois(G) + sage: GaloisGroup_perm.is_galois(G) # needs sage.rings.number_field False """ return self.order() == self._field_degree @@ -283,6 +287,7 @@ def _ambient_group(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: L. = NumberField(x^4 + 1) sage: G = L.galois_group() @@ -309,6 +314,7 @@ def fixed_field(self, name=None, polred=None, threshold=None): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k. = GF(3^12) sage: g = k.galois_group()([8]) sage: k0, embed = g.fixed_field() @@ -323,11 +329,12 @@ def _gcdata(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: L. = NumberField(x^4 + 1) sage: G = L.galois_group() sage: H = G.decomposition_group(L.primes_above(3)[0]) - sage: H.splitting_field() # indirect doctest + sage: H.splitting_field() # indirect doctest Number Field in a with defining polynomial x^4 + 1 """ return self._ambient_group._gcdata @@ -355,9 +362,9 @@ def transitive_number(self, algorithm=None, recompute=False): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: G.transitive_number() + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: G.transitive_number() # needs sage.rings.number_field 2 """ @@ -371,9 +378,9 @@ def _gens(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) - sage: G = K.galois_group(gc_numbering=False) - sage: G._gens + sage: K. = NumberField(x^5 - 2) # needs sage.rings.number_field + sage: G = K.galois_group(gc_numbering=False) # needs sage.rings.number_field + sage: G._gens # needs sage.rings.number_field [(1,2,3,5), (1,4,3,2,5)] """ return NotImplemented @@ -383,9 +390,9 @@ def __init__(self, field, algorithm=None, names=None, gc_numbering=False): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^3 + 2*x + 2) - sage: G = K.galois_group() - sage: TestSuite(G).run() + sage: K. = NumberField(x^3 + 2*x + 2) # needs sage.rings.number_field + sage: G = K.galois_group() # needs sage.rings.number_field + sage: TestSuite(G).run() # needs sage.rings.number_field """ self._field = field self._default_algorithm = algorithm @@ -413,8 +420,9 @@ def _deg(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) + sage: K. = NumberField(x^5 - 2) sage: G = K.galois_group(gc_numbering=False); G Galois group 5T3 (5:4) with order 20 of x^5 - 2 sage: G._deg @@ -437,8 +445,9 @@ def _domain(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) + sage: K. = NumberField(x^5 - 2) sage: G = K.galois_group(gc_numbering=False); G Galois group 5T3 (5:4) with order 20 of x^5 - 2 sage: G._domain @@ -456,9 +465,9 @@ def _domain_to_gap(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) - sage: G = K.galois_group(gc_numbering=False) - sage: G._domain_to_gap[5] + sage: K. = NumberField(x^5 - 2) # needs sage.rings.number_field + sage: G = K.galois_group(gc_numbering=False) # needs sage.rings.number_field + sage: G._domain_to_gap[5] # needs sage.rings.number_field 5 """ return dict((key, i+1) for i, key in enumerate(self._domain)) @@ -471,9 +480,9 @@ def _domain_from_gap(self): EXAMPLES:: sage: R. = ZZ[] - sage: K. = NumberField(x^5-2) - sage: G = K.galois_group(gc_numbering=True) - sage: G._domain_from_gap[20] + sage: K. = NumberField(x^5 - 2) # needs sage.rings.number_field + sage: G = K.galois_group(gc_numbering=True) # needs sage.rings.number_field + sage: G._domain_from_gap[20] # needs sage.rings.number_field 20 """ return dict((i+1, key) for i, key in enumerate(self._domain)) @@ -484,7 +493,7 @@ def ngens(self): EXAMPLES:: - sage: QuadraticField(-23, 'a').galois_group().ngens() + sage: QuadraticField(-23, 'a').galois_group().ngens() # needs sage.rings.number_field 1 """ return len(self._gens) @@ -499,7 +508,7 @@ def __init__(self, field, generator_orders, algorithm=None, gen_names='sigma'): TESTS:: - sage: TestSuite(GF(9).galois_group()).run() + sage: TestSuite(GF(9).galois_group()).run() # needs sage.rings.finite_rings """ self._field = field self._default_algorithm = algorithm @@ -513,7 +522,7 @@ def is_galois(self): EXAMPLES:: - sage: GF(9).galois_group().is_galois() + sage: GF(9).galois_group().is_galois() # needs sage.rings.finite_rings True """ return True @@ -525,7 +534,7 @@ def _gcdata(self): EXAMPLES:: - sage: GF(3^2).galois_group()._gcdata + sage: GF(3^2).galois_group()._gcdata # needs sage.rings.finite_rings (Finite Field in z2 of size 3^2, Identity endomorphism of Finite Field in z2 of size 3^2) """ @@ -537,11 +546,12 @@ def permutation_group(self): r""" Return a permutation group giving the action on the roots of a defining polynomial. - This is the regular representation for the abelian group, which is not necessarily the smallest degree permutation representation. + This is the regular representation for the abelian group, which is + not necessarily the smallest degree permutation representation. EXAMPLES:: - sage: GF(3^10).galois_group().permutation_group() + sage: GF(3^10).galois_group().permutation_group() # needs sage.rings.finite_rings Permutation Group with generators [(1,2,3,4,5,6,7,8,9,10)] """ return PermutationGroup(gap_group=self._gap_().RegularActionHomomorphism().Image()) @@ -573,11 +583,11 @@ def transitive_number(self, algorithm=None, recompute=False): EXAMPLES:: - sage: GF(2^8).galois_group().transitive_number() + sage: GF(2^8).galois_group().transitive_number() # needs sage.rings.finite_rings 1 - sage: GF(3^32).galois_group().transitive_number() + sage: GF(3^32).galois_group().transitive_number() # needs sage.rings.finite_rings 33 - sage: GF(2^60).galois_group().transitive_number() + sage: GF(2^60).galois_group().transitive_number() # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: transitive database only computed up to degree 47 @@ -597,9 +607,9 @@ def signature(self): EXAMPLES:: - sage: GF(3^2).galois_group().signature() + sage: GF(3^2).galois_group().signature() # needs sage.rings.finite_rings -1 - sage: GF(3^3).galois_group().signature() + sage: GF(3^3).galois_group().signature() # needs sage.rings.finite_rings 1 """ return ZZ(1) if (self._field.degree() % 2) else ZZ(-1) diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py index 33e92d43ca5..17deee71ef6 100644 --- a/src/sage/groups/generic.py +++ b/src/sage/groups/generic.py @@ -5,15 +5,15 @@ groups, including additive and multiplicative groups. In all cases the group operation is specified by a parameter -'operation', which is a string either one of the set of -multiplication_names or addition_names specified below, or 'other'. -In the latter case, the caller must provide an identity, inverse() and -op() functions. +``operation``, which is a string either one of the set of +``multiplication_names`` or ``addition_names`` specified below, or other. +In the latter case, the caller must provide an identity, ``inverse()`` and +``op()`` functions. :: - multiplication_names = ( 'multiplication', 'times', 'product', '*') - addition_names = ( 'addition', 'plus', 'sum', '+') + multiplication_names = ('multiplication', 'times', 'product', '*') + addition_names = ('addition', 'plus', 'sum', '+') Also included are a generic function for computing multiples (or @@ -25,14 +25,16 @@ - Discrete logs:: + sage: # needs sage.rings.finite_rings sage: K = GF(3^6,'b') sage: b = K.gen() sage: a = b^210 - sage: discrete_log(a, b, K.order()-1) + sage: discrete_log(a, b, K.order() - 1) 210 - Linear relation finder:: + sage: # needs sage.rings.finite_rings sage: F. = GF(3^6,'a') sage: a.multiplicative_order().factor() 2^3 * 7 * 13 @@ -45,18 +47,20 @@ - Orders of elements:: + sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import order_from_multiple, order_from_bounds sage: k. = GF(5^5) sage: b = a^4 - sage: order_from_multiple(b,5^5-1,operation='*') + sage: order_from_multiple(b, 5^5 - 1, operation='*') 781 - sage: order_from_bounds(b,(5^4,5^5),operation='*') + sage: order_from_bounds(b, (5^4, 5^5), operation='*') 781 Some examples in the group of points of an elliptic curve over a finite field: - Discrete logs:: + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: F = GF(37^2,'a') sage: E = EllipticCurve(F,[1,1]) sage: F. = GF(37^2,'a') @@ -66,11 +70,12 @@ 672 sage: Q = 39*P; Q (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q,P,P.order(),operation='+') + sage: discrete_log(Q, P, P.order(), operation='+') 39 - Linear relation finder:: + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: F. = GF(3^6,'a') sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2 , 0) @@ -82,10 +87,11 @@ - Orders of elements:: + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: from sage.groups.generic import order_from_multiple, order_from_bounds sage: k. = GF(5^5) sage: E = EllipticCurve(k,[2,4]) - sage: P = E(3*a^4 + 3*a , 2*a + 1 ) + sage: P = E(3*a^4 + 3*a, 2*a + 1) sage: M = E.cardinality(); M 3227 sage: plist = M.prime_factors() @@ -134,36 +140,37 @@ def multiple(a, n, operation='*', identity=None, inverse=None, op=None): EXAMPLES:: - sage: multiple(2,5) + sage: multiple(2, 5) 32 - sage: multiple(RealField()('2.5'),4) + sage: multiple(RealField()('2.5'), 4) # needs sage.rings.real_mpfr 39.0625000000000 - sage: multiple(2,-3) + sage: multiple(2, -3) 1/8 - sage: multiple(2,100,'+') == 100*2 + sage: multiple(2, 100, '+') == 100*2 True - sage: multiple(2,100) == 2**100 + sage: multiple(2, 100) == 2**100 True - sage: multiple(2,-100,) == 2**-100 + sage: multiple(2, -100,) == 2**-100 True - sage: R.=ZZ[] - sage: multiple(x,100) + sage: R. = ZZ[] + sage: multiple(x, 100) x^100 - sage: multiple(x,100,'+') + sage: multiple(x, 100, '+') 100*x - sage: multiple(x,-10) + sage: multiple(x, -10) 1/x^10 Idempotence is detected, making the following fast:: - sage: multiple(1,10^1000) + sage: multiple(1, 10^1000) 1 + sage: # needs sage.schemes sage: E = EllipticCurve('389a1') sage: P = E(-1,1) - sage: multiple(P,10,'+') + sage: multiple(P, 10, '+') (645656132358737542773209599489/22817025904944891235367494656 : 525532176124281192881231818644174845702936831/3446581505217248068297884384990762467229696 : 1) - sage: multiple(P,-10,'+') + sage: multiple(P, -10, '+') (645656132358737542773209599489/22817025904944891235367494656 : -528978757629498440949529703029165608170166527/3446581505217248068297884384990762467229696 : 1) """ from operator import inv, mul, neg, add @@ -247,14 +254,14 @@ class multiples: EXAMPLES:: - sage: list(multiples(1,10)) + sage: list(multiples(1, 10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - sage: list(multiples(1,10,100)) + sage: list(multiples(1, 10, 100)) [100, 101, 102, 103, 104, 105, 106, 107, 108, 109] - sage: E = EllipticCurve('389a1') - sage: P = E(-1,1) - sage: for Q in multiples(P,5): print((Q, Q.height()/P.height())) + sage: E = EllipticCurve('389a1') # needs sage.schemes + sage: P = E(-1,1) # needs sage.schemes + sage: for Q in multiples(P, 5): print((Q, Q.height()/P.height())) # needs sage.schemes ((0 : 1 : 0), 0.000000000000000) ((-1 : 1 : 1), 1.00000000000000) ((10/9 : -35/27 : 1), 4.00000000000000) @@ -262,22 +269,23 @@ class multiples: ((47503/16641 : 9862190/2146689 : 1), 16.0000000000000) sage: R. = ZZ[] - sage: list(multiples(x,5)) + sage: list(multiples(x, 5)) [0, x, 2*x, 3*x, 4*x] - sage: list(multiples(x,5,operation='*')) + sage: list(multiples(x, 5, operation='*')) [1, x, x^2, x^3, x^4] - sage: list(multiples(x,5,indexed=True)) + sage: list(multiples(x, 5, indexed=True)) [(0, 0), (1, x), (2, 2*x), (3, 3*x), (4, 4*x)] - sage: list(multiples(x,5,indexed=True,operation='*')) + sage: list(multiples(x, 5, indexed=True, operation='*')) [(0, 1), (1, x), (2, x^2), (3, x^3), (4, x^4)] - sage: for i,y in multiples(x,5,indexed=True): print("%s times %s = %s"%(i,x,y)) + sage: for i,y in multiples(x, 5, indexed=True): print("%s times %s = %s"%(i,x,y)) 0 times x = 0 1 times x = x 2 times x = 2*x 3 times x = 3*x 4 times x = 4*x - sage: for i,n in multiples(3,5,indexed=True,operation='*'): print("3 to the power %s = %s" % (i,n)) + sage: for i,n in multiples(3, 5, indexed=True, operation='*'): + ....: print("3 to the power %s = %s" % (i,n)) 3 to the power 0 = 1 3 to the power 1 = 3 3 to the power 2 = 9 @@ -286,26 +294,25 @@ class multiples: """ def __init__(self, P, n, P0=None, indexed=False, operation='+', op=None): """ - Create a multiples iterator + Create a multiples iterator. INPUT: - - ``P`` - step value: any Sage object on which a binary - operation is defined - - ``n`` - number of multiples: non-negative integer + - ``P`` -- step value: any Sage object on which a binary operation is defined + - ``n`` -- number of multiples: non-negative integer - ``P0`` - offset (default 0): Sage object which can be 'added' to P - - ``indexed`` - boolean (default False) + - ``indexed`` -- boolean (default ``False``) - If ``indexed==False`` then the iterator delivers ``P0+i*P`` + If ``indexed==False``, then the iterator delivers ``P0+i*P`` (if ``operation=='+'``) or ``P0*P**i`` (if ``operation=='*'``), for ``i`` in ``range(n)``. If ``indexed==True`` then the iterator delivers tuples - ``(i,P0+i*P)`` or ``(i,P0*P**i)``. + ``(i, P0+i*P)`` or ``(i, P0*P**i)``. - - ``operation`` - string: '+' (default ) or '*' or `other`. + - ``operation`` -- string: ``'+'`` (the default) or ``'*'`` or other. - If `other`, a function ``op()`` must be supplied (a function + If other, a function ``op()`` must be supplied (a function of 2 arguments) defining the group binary operation; also ``P0`` must be supplied. """ @@ -377,18 +384,18 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): INPUT: - - ``a`` - group element - - ``b`` - group element - - ``bounds`` - a 2-tuple of integers ``(lower,upper)`` with ``0<=lower<=upper`` - - ``operation`` - string: '*', '+', 'other' - - ``identity`` - the identity element of the group - - ``inverse()`` - function of 1 argument ``x`` returning inverse of ``x`` + - ``a`` -- group element + - ``b`` -- group element + - ``bounds`` -- a 2-tuple of integers ``(lower,upper)`` with ``0<=lower<=upper`` + - ``operation`` -- string: ``'*'``, ``'+'``, other + - ``identity`` -- the identity element of the group + - ``inverse()`` -- function of 1 argument ``x``, returning inverse of ``x`` - ``op()`` - function of 2 arguments ``x``, ``y`` returning ``x*y`` in the group OUTPUT: An integer `n` such that `a^n = b` (or `na = b`). If no - such `n` exists, this function raises a ValueError exception. + such `n` exists, this function raises a :class:`ValueError` exception. NOTE: This is a generalization of discrete logarithm. One situation where this version is useful is to find the order of @@ -403,27 +410,29 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): sage: from sage.groups.generic import bsgs sage: b = Mod(2,37); a = b^20 - sage: bsgs(b, a, (0,36)) + sage: bsgs(b, a, (0, 36)) 20 - sage: p = next_prime(10^20) - sage: a = Mod(2,p); b = a^(10^25) - sage: bsgs(a, b, (10^25-10^6,10^25+10^6)) == 10^25 + sage: p = next_prime(10^20) # needs sage.libs.pari + sage: a = Mod(2,p); b = a^(10^25) # needs sage.libs.pari + sage: bsgs(a, b, (10^25 - 10^6, 10^25 + 10^6)) == 10^25 # needs sage.libs.pari True + sage: # needs sage.rings.finite_rings sage: K = GF(3^6,'b') sage: a = K.gen() sage: b = a^210 - sage: bsgs(a, b, (0,K.order()-1)) + sage: bsgs(a, b, (0, K.order() - 1)) 210 - sage: K. = CyclotomicField(230) - sage: w = z^500 - sage: bsgs(z,w,(0,229)) + sage: K. = CyclotomicField(230) # needs sage.rings.number_field + sage: w = z^500 # needs sage.rings.number_field + sage: bsgs(z, w, (0, 229)) # needs sage.rings.number_field 40 An additive example in an elliptic curve group:: + sage: # needs sage.rings.finite_rings sage.schemes sage: F. = GF(37^5) sage: E = EllipticCurve(F, [1,1]) sage: P = E.lift_x(a); P @@ -431,7 +440,7 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): This will return a multiple of the order of P:: - sage: bsgs(P,P.parent()(0),Hasse_bounds(F.order()),operation='+') + sage: bsgs(P, P.parent()(0), Hasse_bounds(F.order()), operation='+') # needs sage.rings.finite_rings sage.schemes 69327408 AUTHOR: @@ -513,9 +522,9 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No to compute it - ``operation`` -- a string (default: ``'*'``) denoting whether we are in an additive group or a multiplicative one - - ``identity`` - the group's identity - - ``inverse()`` - function of 1 argument ``x`` returning inverse of ``x`` - - ``op()`` - function of 2 arguments ``x``, ``y`` returning ``x*y`` in the group + - ``identity`` -- the group's identity + - ``inverse()`` -- function of 1 argument ``x``, returning inverse of ``x`` + - ``op()`` - function of 2 arguments ``x``, ``y``, returning ``x*y`` in the group - ``hash_function`` -- having an efficient hash function is critical for this algorithm (see examples) @@ -527,11 +536,12 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No EXAMPLES:: - sage: F. = GF(2^13) - sage: g = F.gen() - sage: discrete_log_rho(g^1234, g) + sage: F. = GF(2^13) # needs sage.rings.finite_rings + sage: g = F.gen() # needs sage.rings.finite_rings + sage: discrete_log_rho(g^1234, g) # needs sage.rings.finite_rings 1234 + sage: # needs sage.rings.finite_rings sage.schemes sage: F. = GF(37^5) sage: E = EllipticCurve(F, [1,1]) sage: G = (3*31*2^4)*E.lift_x(a) @@ -540,33 +550,36 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No It also works with matrices:: - sage: A = matrix(GF(50021),[[10577,23999,28893],[14601,41019,30188],[3081,736,27092]]) - sage: discrete_log_rho(A^1234567, A) + sage: A = matrix(GF(50021), [[10577, 23999, 28893], # needs sage.rings.finite_rings + ....: [14601, 41019, 30188], + ....: [3081, 736, 27092]]) + sage: discrete_log_rho(A^1234567, A) # needs sage.rings.finite_rings 1234567 Beware, the order must be prime:: sage: I = IntegerModRing(171980) - sage: discrete_log_rho(I(2), I(3)) + sage: discrete_log_rho(I(2), I(3)) # needs sage.libs.pari Traceback (most recent call last): ... ValueError: for Pollard rho algorithm the order of the group must be prime - If it fails to find a suitable logarithm, it raises a ``ValueError``:: + If it fails to find a suitable logarithm, it raises a :class:`ValueError`:: sage: I = IntegerModRing(171980) - sage: discrete_log_rho(I(31002),I(15501)) + sage: discrete_log_rho(I(31002), I(15501)) # needs sage.libs.pari Traceback (most recent call last): ... ValueError: Pollard rho algorithm failed to find a logarithm The main limitation on the hash function is that we don't want to have - `hash(x*y) = hash(x) + hash(y)`:: + ``hash(x*y) == hash(x) + hash(y)``:: + sage: # needs sage.libs.pari sage: I = IntegerModRing(next_prime(2^23)) sage: def test(): ....: try: - ....: discrete_log_rho(I(123456),I(1),operation='+') + ....: discrete_log_rho(I(123456), I(1), operation='+') ....: except Exception: ....: print("FAILURE") sage: test() # random failure @@ -574,7 +587,8 @@ def discrete_log_rho(a, base, ord=None, operation='*', identity=None, inverse=No If this happens, we can provide a better hash function:: - sage: discrete_log_rho(I(123456),I(1),operation='+', hash_function=lambda x: hash(x*x)) + sage: discrete_log_rho(I(123456), I(1), operation='+', # needs sage.libs.pari + ....: hash_function=lambda x: hash(x*x)) 123456 AUTHOR: @@ -673,21 +687,21 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i INPUT: - - ``a`` - group element - - ``base`` - group element (the base) - - ``ord`` - integer (multiple of order of base, or ``None``) - - ``bounds`` - a priori bounds on the log - - ``operation`` - string: '*', '+', 'other' - - ``identity`` - the group's identity - - ``inverse()`` - function of 1 argument ``x`` returning inverse of ``x`` - - ``op()`` - function of 2 arguments ``x``, ``y`` returning ``x*y`` in the group - - ``algorithm`` - string denoting what algorithm to use for prime-order logarithms: 'bsgs', 'rho', 'lambda' + - ``a`` -- group element + - ``base`` -- group element (the base) + - ``ord`` -- integer (multiple of order of base, or ``None``) + - ``bounds`` -- a priori bounds on the log + - ``operation`` -- string: ``'*'``, ``'+'``, other + - ``identity`` -- the group's identity + - ``inverse()`` - function of 1 argument ``x``, returning inverse of ``x`` + - ``op()`` - function of 2 arguments ``x``, ``y``, returning ``x*y`` in the group + - ``algorithm`` -- string denoting what algorithm to use for prime-order logarithms: ``'bsgs'``, ``'rho'``, ``'lambda'`` ``a`` and ``base`` must be elements of some group with identity - given by identity, inverse of ``x`` by ``inverse(x)``, and group + given by ``identity``, inverse of ``x`` by ``inverse(x)``, and group operation on ``x``, ``y`` by ``op(x,y)``. - If operation is '*' or '+' then the other + If operation is ``'*'`` or ``'+'``, then the other arguments are provided automatically; otherwise they must be provided by the caller. @@ -697,13 +711,13 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i assuming that ``ord`` is a multiple of the order of the base `b`. If ``ord`` is not specified, an attempt is made to compute it. - If no such `n` exists, this function raises a ``ValueError`` exception. + If no such `n` exists, this function raises a :class:`ValueError` exception. .. warning:: - If ``x`` has a log method, it is likely to be vastly faster + If ``x`` has a ``log`` method, it is likely to be vastly faster than using this function. E.g., if ``x`` is an integer modulo - `n`, use its log method instead! + `n`, use its ``log`` method instead! ALGORITHM: Pohlig-Hellman, Baby step giant step, Pollard's lambda/kangaroo, and Pollard's rho. @@ -716,10 +730,11 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: discrete_log(a, b, bounds=(10, 100)) 20 - sage: K = GF(3^6,'b') + sage: # needs sage.rings.finite_rings + sage: K = GF(3^6, 'b') sage: b = K.gen() sage: a = b^210 - sage: discrete_log(a, b, K.order()-1) + sage: discrete_log(a, b, K.order() - 1) 210 sage: b = Mod(1,37); x = Mod(2,37) @@ -735,63 +750,66 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i See :trac:`2356`:: - sage: F. = GF(121) - sage: v = w^120 - sage: v.log(w) + sage: F. = GF(121) # needs sage.rings.finite_rings + sage: v = w^120 # needs sage.rings.finite_rings + sage: v.log(w) # needs sage.rings.finite_rings 0 - sage: K. = CyclotomicField(230) - sage: w = z^50 - sage: discrete_log(w,z) + sage: K. = CyclotomicField(230) # needs sage.rings.number_field + sage: w = z^50 # needs sage.rings.number_field + sage: discrete_log(w, z) # needs sage.rings.number_field 50 An example where the order is infinite: note that we must give an upper bound here:: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(23) - sage: eps = 5*a-24 # a fundamental unit + sage: eps = 5*a - 24 # a fundamental unit sage: eps.multiplicative_order() +Infinity sage: eta = eps^100 - sage: discrete_log(eta,eps,bounds=(0,1000)) + sage: discrete_log(eta, eps, bounds=(0,1000)) 100 In this case we cannot detect negative powers:: - sage: eta = eps^(-3) - sage: discrete_log(eta,eps,bounds=(0,100)) + sage: eta = eps^(-3) # needs sage.rings.number_field + sage: discrete_log(eta,eps,bounds=(0,100)) # needs sage.rings.number_field Traceback (most recent call last): ... ValueError: no discrete log of -11515*a - 55224 found to base 5*a - 24 But we can invert the base (and negate the result) instead:: - sage: - discrete_log(eta^-1,eps,bounds=(0,100)) + sage: -discrete_log(eta^-1, eps, bounds=(0,100)) # needs sage.rings.number_field -3 An additive example: elliptic curve DLOG:: + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes sage: F = GF(37^2,'a') - sage: E = EllipticCurve(F,[1,1]) + sage: E = EllipticCurve(F, [1,1]) sage: F. = GF(37^2,'a') - sage: E = EllipticCurve(F,[1,1]) - sage: P = E(25*a + 16 , 15*a + 7 ) + sage: E = EllipticCurve(F, [1,1]) + sage: P = E(25*a + 16, 15*a + 7) sage: P.order() 672 sage: Q = 39*P; Q (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q,P,P.order(),operation='+') + sage: discrete_log(Q, P, P.order(), operation='+') 39 An example of big smooth group:: + sage: # needs sage.rings.finite_rings sage: F. = GF(2^63) sage: g = F.gen() sage: u = g**123456789 sage: discrete_log(u,g) 123456789 - The above examples also work when the 'rho' and 'lambda' algorithms are used:: + The above examples also work when the ``'rho'`` and ``'lambda'`` algorithms are used:: sage: b = Mod(2,37); a = b^20 sage: discrete_log(a, b, algorithm='rho') @@ -800,6 +818,7 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: discrete_log(a, b, algorithm='lambda', bounds=(10, 100)) 20 + sage: # needs sage.rings.finite_rings sage: K = GF(3^6,'b') sage: b = K.gen() sage: a = b^210 @@ -817,22 +836,24 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i ... ValueError: no discrete log of 2 found to base 1 - sage: F=GF(37^2,'a') - sage: E=EllipticCurve(F,[1,1]) - sage: F.=GF(37^2,'a') - sage: E=EllipticCurve(F,[1,1]) - sage: P=E(25*a + 16 , 15*a + 7 ) + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes + sage: F = GF(37^2,'a') + sage: E = EllipticCurve(F, [1,1]) + sage: F. = GF(37^2,'a') + sage: E = EllipticCurve(F, [1,1]) + sage: P = E(25*a + 16, 15*a + 7) sage: P.order() 672 - sage: Q=39*P; Q + sage: Q = 39*P; Q (36*a + 32 : 5*a + 12 : 1) - sage: discrete_log(Q,P,P.order(),operation='+',algorithm='lambda') + sage: discrete_log(Q, P, P.order(), operation='+', algorithm='lambda') 39 + sage: # needs sage.rings.finite_rings sage: F. = GF(2^63) sage: g = F.gen() sage: u = g**123456789 - sage: discrete_log(u,g,algorithm='rho') + sage: discrete_log(u, g, algorithm='rho') 123456789 TESTS: @@ -849,8 +870,8 @@ def discrete_log(a, base, ord=None, bounds=None, operation='*', identity=None, i sage: kwargs = {'operation': '+'} sage: kwargs['algorithm'] = choice(['bsgs', 'rho', 'lambda']) sage: if randrange(2): - ....: lo = randrange(-order, sol+1) - ....: hi = randrange(sol+1, 2*order) + ....: lo = randrange(-order, sol + 1) + ....: hi = randrange(sol + 1, 2*order) ....: assert lo <= sol <= hi ....: kwargs['bounds'] = (lo, hi) sage: try: @@ -973,10 +994,11 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N EXAMPLES:: - sage: F. = GF(2^63) - sage: discrete_log_lambda(a^1234567, a, (1200000,1250000)) + sage: F. = GF(2^63) # needs sage.rings.finite_rings + sage: discrete_log_lambda(a^1234567, a, (1200000,1250000)) # needs sage.rings.finite_rings 1234567 + sage: # needs sage.rings.finite_rings sage.schemes sage: F. = GF(37^5) sage: E = EllipticCurve(F, [1,1]) sage: P = E.lift_x(a); P @@ -984,12 +1006,14 @@ def discrete_log_lambda(a, base, bounds, operation='*', identity=None, inverse=N This will return a multiple of the order of P:: - sage: discrete_log_lambda(P.parent()(0), P, Hasse_bounds(F.order()), operation='+') + sage: discrete_log_lambda(P.parent()(0), P, Hasse_bounds(F.order()), # needs sage.rings.finite_rings sage.schemes + ....: operation='+') 69327408 - sage: K. = GF(89**5) + sage: K. = GF(89**5) # needs sage.rings.finite_rings sage: hs = lambda x: hash(x) + 15 - sage: discrete_log_lambda(a**(89**3 - 3), a, (89**2, 89**4), operation = '*', hash_function = hs) # long time (10s on sage.math, 2011) + sage: discrete_log_lambda(a**(89**3 - 3), # long time (10s on sage.math, 2011), needs sage.rings.finite_rings + ....: a, (89**2, 89**4), operation='*', hash_function=hs) 704966 AUTHOR: @@ -1082,25 +1106,27 @@ def linear_relation(P, Q, operation='+', identity=None, inverse=None, op=None): An additive example (in an elliptic curve group):: + sage: # needs sage.rings.finite_rings sage.schemes sage: F. = GF(3^6,'a') - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a,a^4 + a^3 + 2*a + 1]) - sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2 , 0) - sage: Q = E(2*a^3 + 2*a^2 + 2*a , a^3 + 2*a^2 + 1) - sage: linear_relation(P,Q,'+') + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) + sage: P = E(a^5 + a^4 + a^3 + a^2 + a + 2, 0) + sage: Q = E(2*a^3 + 2*a^2 + 2*a, a^3 + 2*a^2 + 1) + sage: linear_relation(P, Q, '+') (1, 2) sage: P == 2*Q True A multiplicative example (in a finite field's multiplicative group):: + sage: # needs sage.rings.finite_rings sage: F. = GF(3^6,'a') sage: a.multiplicative_order().factor() 2^3 * 7 * 13 sage: b = a^7 sage: c = a^13 - sage: linear_relation(b,c,'*') + sage: linear_relation(b, c, '*') (13, 7) - sage: b^13==c^7 + sage: b^13 == c^7 True """ Z = integer_ring.ZZ @@ -1164,16 +1190,16 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, INPUT: - - ``P`` - a Sage object which is a group element; - - ``m`` - a Sage integer which is a multiple of the order of ``P``, + - ``P`` -- a Sage object which is a group element; + - ``m`` -- a Sage integer which is a multiple of the order of ``P``, i.e. we require that ``m*P=0`` (or ``P**m=1``); - - ``check`` - a Boolean (default:True), indicating whether we check if ``m`` + - ``check`` -- a Boolean (default: ``True``), indicating whether we check if ``m`` really is a multiple of the order; - - ``factorization`` - the factorization of ``m``, or ``None`` in which + - ``factorization`` -- the factorization of ``m``, or ``None`` in which case this function will need to factor ``m``; - - ``plist`` - a list of the prime factors of ``m``, or ``None`` - kept for compatibility only, + - ``plist`` -- a list of the prime factors of ``m``, or ``None`` - kept for compatibility only, prefer the use of ``factorization``; - - ``operation`` - string: '+' (default) or '*'. + - ``operation`` -- string: ``'+'`` (default) or ``'*'``. .. note:: @@ -1183,12 +1209,16 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, EXAMPLES:: sage: from sage.groups.generic import order_from_multiple + + sage: # needs sage.rings.finite_rings sage: k. = GF(5^5) sage: b = a^4 - sage: order_from_multiple(b,5^5-1,operation='*') + sage: order_from_multiple(b, 5^5 - 1, operation='*') 781 - sage: E = EllipticCurve(k,[2,4]) - sage: P = E(3*a^4 + 3*a , 2*a + 1 ) + + sage: # needs sage.rings.finite_rings sage.schemes + sage: E = EllipticCurve(k, [2,4]) + sage: P = E(3*a^4 + 3*a, 2*a + 1) sage: M = E.cardinality(); M 3227 sage: F = M.factor() @@ -1198,18 +1228,22 @@ def order_from_multiple(P, m, plist=None, factorization=None, check=True, sage: order_from_multiple(Q, M, factorization=F, operation='+') 7 + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(230) sage: w = z^50 - sage: order_from_multiple(w,230,operation='*') + sage: order_from_multiple(w, 230, operation='*') 23 + sage: # needs sage.rings.finite_rings sage: F = GF(2^1279,'a') - sage: n = F.cardinality()-1 # Mersenne prime - sage: order_from_multiple(F.random_element(),n,factorization=[(n,1)],operation='*') == n + sage: n = F.cardinality() - 1 # Mersenne prime + sage: order_from_multiple(F.random_element(), n, + ....: factorization=[(n,1)], operation='*') == n True + sage: # needs sage.rings.finite_rings sage: K. = GF(3^60) - sage: order_from_multiple(a, 3^60-1, operation='*', check=False) + sage: order_from_multiple(a, 3^60 - 1, operation='*', check=False) 42391158275216203514294433200 """ Z = integer_ring.ZZ @@ -1294,21 +1328,21 @@ def order_from_bounds(P, bounds, d=None, operation='+', INPUT: - - ``P`` - a Sage object which is a group element + - ``P`` -- a Sage object which is a group element - - ``bounds`` - a 2-tuple ``(lb,ub)`` such that ``m*P=0`` (or + - ``bounds`` -- a 2-tuple ``(lb,ub)`` such that ``m*P=0`` (or ``P**m=1``) for some ``m`` with ``lb<=m<=ub``. - - ``d`` - (optional) a positive integer; only ``m`` which are + - ``d`` -- (optional) a positive integer; only ``m`` which are multiples of this will be considered. - - ``operation`` - string: '+' (default ) or '*' or other. + - ``operation`` -- string: ``'+'`` (default ) or ``'*'`` or other. If other, the following must be supplied: - - ``identity``: the identity element for the group; - - ``inverse()``: a function of one argument giving the inverse + - ``identity`` -- the identity element for the group; + - ``inverse()`` -- a function of one argument giving the inverse of a group element; - - ``op()``: a function of 2 arguments defining the group binary + - ``op()`` -- a function of 2 arguments defining the group binary operation. @@ -1321,12 +1355,16 @@ def order_from_bounds(P, bounds, d=None, operation='+', EXAMPLES:: sage: from sage.groups.generic import order_from_bounds + + sage: # needs sage.rings.finite_rings sage: k. = GF(5^5) sage: b = a^4 - sage: order_from_bounds(b,(5^4,5^5),operation='*') + sage: order_from_bounds(b, (5^4, 5^5), operation='*') 781 - sage: E = EllipticCurve(k,[2,4]) - sage: P = E(3*a^4 + 3*a , 2*a + 1 ) + + sage: # needs sage.rings.finite_rings sage.schemes + sage: E = EllipticCurve(k, [2,4]) + sage: P = E(3*a^4 + 3*a, 2*a + 1) sage: bounds = Hasse_bounds(5^5) sage: Q = E(0,2) sage: order_from_bounds(Q, bounds, operation='+') @@ -1334,9 +1372,10 @@ def order_from_bounds(P, bounds, d=None, operation='+', sage: order_from_bounds(P, bounds, 7, operation='+') 3227 - sage: K.=CyclotomicField(230) + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(230) sage: w = z^50 - sage: order_from_bounds(w,(200,250),operation='*') + sage: order_from_bounds(w, (200, 250), operation='*') 23 """ from operator import mul, add @@ -1378,15 +1417,14 @@ def merge_points(P1, P2, operation='+', - ``P1`` -- a pair `(g_1,n_1)` where `g_1` is a group element of order `n_1` - ``P2`` -- a pair `(g_2,n_2)` where `g_2` is a group element of order `n_2` - - ``operation`` -- string: '+' (default ) or '*' or other. If + - ``operation`` -- string: ``'+'`` (default) or ``'*'`` or other. If other, the following must be supplied: - - ``identity``: the identity element for the group; - - ``inverse()``: a function of one argument giving the inverse - of a group element; - - ``op()``: a function of 2 arguments defining the group - binary operation. - + - ``identity`` -- the identity element for the group; + - ``inverse()`` -- a function of one argument giving the inverse + of a group element; + - ``op()`` -- a function of 2 arguments defining the group + binary operation. OUTPUT: @@ -1394,28 +1432,30 @@ def merge_points(P1, P2, operation='+', EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.groups.generic import merge_points - sage: F.=GF(3^6,'a') + sage: F. = GF(3^6,'a') sage: b = a^7 sage: c = a^13 sage: ob = (3^6-1)//7 sage: oc = (3^6-1)//13 - sage: merge_points((b,ob),(c,oc),operation='*') + sage: merge_points((b,ob), (c,oc), operation='*') (a^4 + 2*a^3 + 2*a^2, 728) - sage: d,od = merge_points((b,ob),(c,oc),operation='*') + sage: d, od = merge_points((b,ob), (c,oc), operation='*') sage: od == d.multiplicative_order() True - sage: od == lcm(ob,oc) + sage: od == lcm(ob, oc) True - sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a,a^4 + a^3 + 2*a + 1]) - sage: P = E(2*a^5 + 2*a^4 + a^3 + 2 , a^4 + a^3 + a^2 + 2*a + 2) + sage: # needs sage.libs.gap sage.rings.finite_rings sage.schemes + sage: E = EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]) + sage: P = E(2*a^5 + 2*a^4 + a^3 + 2, a^4 + a^3 + a^2 + 2*a + 2) sage: P.order() 7 - sage: Q = E(2*a^5 + 2*a^4 + 1 , a^5 + 2*a^3 + 2*a + 2 ) + sage: Q = E(2*a^5 + 2*a^4 + 1, a^5 + 2*a^3 + 2*a + 2) sage: Q.order() 4 - sage: R,m = merge_points((P,7),(Q,4), operation='+') + sage: R, m = merge_points((P,7), (Q,4), operation='+') sage: R.order() == m True sage: m == lcm(7,4) @@ -1466,12 +1506,12 @@ def structure_description(G, latex=False): INPUT: - - ``latex`` -- a boolean (default: ``False``). If ``True`` return a + - ``latex`` -- a boolean (default: ``False``). If ``True``, return a LaTeX formatted string. OUTPUT: - - string + string .. WARNING:: @@ -1483,6 +1523,7 @@ def structure_description(G, latex=False): EXAMPLES:: + sage: # needs sage.groups sage: G = CyclicPermutationGroup(6) sage: G.structure_description() 'C6' @@ -1495,26 +1536,26 @@ def structure_description(G, latex=False): This method is mainly intended for small groups or groups with few normal subgroups. Even then there are some surprises:: - sage: D3 = DihedralGroup(3) - sage: D3.structure_description() + sage: D3 = DihedralGroup(3) # needs sage.groups + sage: D3.structure_description() # needs sage.groups 'S3' We use the Sage notation for the degree of dihedral groups:: - sage: D4 = DihedralGroup(4) - sage: D4.structure_description() + sage: D4 = DihedralGroup(4) # needs sage.groups + sage: D4.structure_description() # needs sage.groups 'D4' Works for finitely presented groups (:trac:`17573`):: - sage: F. = FreeGroup() - sage: G = F / [x^2*y^-1, x^3*y^2, x*y*x^-1*y^-1] - sage: G.structure_description() + sage: F. = FreeGroup() # needs sage.groups + sage: G = F / [x^2*y^-1, x^3*y^2, x*y*x^-1*y^-1] # needs sage.groups + sage: G.structure_description() # needs sage.groups 'C7' And matrix groups (:trac:`17573`):: - sage: groups.matrix.GL(4,2).structure_description() + sage: groups.matrix.GL(4,2).structure_description() # needs sage.libs.gap sage.modules 'A8' """ import re diff --git a/src/sage/groups/group.pyx b/src/sage/groups/group.pyx index 872d5c509d7..cd2521e3478 100644 --- a/src/sage/groups/group.pyx +++ b/src/sage/groups/group.pyx @@ -35,9 +35,9 @@ def is_Group(x): EXAMPLES:: - sage: F. = FreeGroup() + sage: F. = FreeGroup() # needs sage.combinat sage: from sage.groups.group import is_Group - sage: is_Group(F) + sage: is_Group(F) # needs sage.combinat True sage: is_Group("a string") False @@ -87,7 +87,7 @@ cdef class Group(Parent): sage: G = Group(category=Groups()) # todo: do the same test with some subcategory of Groups when there will exist one sage: G.category() Category of groups - sage: G = Group(category = CommutativeAdditiveGroups()) + sage: G = Group(category=CommutativeAdditiveGroups()) Traceback (most recent call last): ... ValueError: (Category of commutative additive groups,) is not a subcategory of Category of groups @@ -96,6 +96,7 @@ cdef class Group(Parent): Check for :trac:`8119`:: + sage: # needs sage.groups sage: G = SymmetricGroup(2) sage: h = hash(G) sage: G.rename('S2') @@ -139,7 +140,7 @@ cdef class Group(Parent): EXAMPLES:: - sage: SL(2, 7).is_commutative() # optional - sage.rings.finite_rings + sage: SL(2, 7).is_commutative() # needs sage.modules sage.rings.finite_rings False """ return self.is_abelian() @@ -161,8 +162,8 @@ cdef class Group(Parent): TESTS:: - sage: H = SL(2, QQ) - sage: H.order() + sage: H = SL(2, QQ) # needs sage.modules + sage: H.order() # needs sage.modules +Infinity """ try: @@ -211,8 +212,8 @@ cdef class Group(Parent): EXAMPLES:: - sage: G = AbelianGroup([2,3,4,5]) # optional - sage.groups - sage: G.an_element() # optional - sage.groups + sage: G = AbelianGroup([2,3,4,5]) # needs sage.groups + sage: G.an_element() # needs sage.groups f0*f1*f2*f3 """ return self.prod(self.gens()) diff --git a/src/sage/groups/group_semidirect_product.py b/src/sage/groups/group_semidirect_product.py index 3ac629b9411..1805dbbc53a 100644 --- a/src/sage/groups/group_semidirect_product.py +++ b/src/sage/groups/group_semidirect_product.py @@ -33,7 +33,8 @@ def _repr_(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist) # indirect doctest + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # indirect doctest + ....: WeylGroup(['A',3],prefix="t"), twist) Semidirect product of Weyl Group of type ['A', 2] (as a matrix group acting on the ambient space) acting on Weyl Group of type ['A', 3] @@ -67,6 +68,7 @@ def __invert__(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: L = RootSystem(['A',2]).root_lattice() sage: from sage.groups.group_exp import GroupExp sage: EL = GroupExp()(L) @@ -95,6 +97,7 @@ def to_opposite(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: L = RootSystem(['A',2]).root_lattice(); L Root lattice of the Root system of type ['A', 2] sage: from sage.groups.group_exp import GroupExp @@ -117,7 +120,10 @@ def to_opposite(self): sage: g.to_opposite() t[-2*alpha[1]] * s1*s2 sage: g.to_opposite().parent() - Semidirect product of Multiplicative form of Root lattice of the Root system of type ['A', 2] acted upon by Weyl Group of type ['A', 2] (as a matrix group acting on the root lattice) + Semidirect product of + Multiplicative form of Root lattice of the Root system of type ['A', 2] + acted upon by Weyl Group of type ['A', 2] + (as a matrix group acting on the root lattice) """ par = self.parent() Gop = par.opposite_semidirect_product() @@ -141,7 +147,7 @@ class GroupSemidirectProduct(CartesianProduct): - ``prefix0`` -- (default: ``None``) optional string - ``prefix1`` -- (default: ``None``) optional string - ``print_tuple`` -- ``True`` or ``False`` (default: ``False``) - - ``category`` -- A category (default: Groups()) + - ``category`` -- A category (default: ``Groups()``) A semidirect product of groups `G` and `H` is a group structure on the Cartesian product `G \times H` whose product agrees with that @@ -207,10 +213,10 @@ class GroupSemidirectProduct(CartesianProduct): sage: G = GL(2,QQ) sage: V = QQ^2 - sage: EV = GroupExp()(V) # make a multiplicative version of V + sage: EV = GroupExp()(V) # make a multiplicative version of V sage: def twist(g,v): ....: return EV(g*v.value) - sage: H = GroupSemidirectProduct(G, EV, twist=twist, prefix1 = 't'); H + sage: H = GroupSemidirectProduct(G, EV, twist=twist, prefix1='t'); H Semidirect product of General Linear Group of degree 2 over Rational Field acting on Multiplicative form of Vector space of dimension 2 over Rational Field @@ -218,11 +224,13 @@ class GroupSemidirectProduct(CartesianProduct): t[(1, 0)] sage: x^2 t[(2, 0)] + + sage: # needs sage.rings.number_field sage: cartan_type = CartanType(['A',2]) sage: W = WeylGroup(cartan_type, prefix="s") sage: def twist(w,v): ....: return w*v*(~w) - sage: WW = GroupSemidirectProduct(W,W, twist=twist, print_tuple=True) + sage: WW = GroupSemidirectProduct(W, W, twist=twist, print_tuple=True) sage: s = Family(cartan_type.index_set(), lambda i: W.simple_reflection(i)) sage: y = WW((s[1],s[2])); y (s1, s2) @@ -247,7 +255,8 @@ def __init__(self, G, H, twist=None, act_to_right=True, prefix0=None, ....: return y sage: import __main__ sage: __main__.twist = twist - sage: G = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist) + sage: G = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), + ....: WeylGroup(['A',3],prefix="t"), twist) sage: TestSuite(G).run() The ``__main__`` business is a trick to pass the pickling test. @@ -289,7 +298,8 @@ def act_to_right(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist).act_to_right() + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), + ....: WeylGroup(['A',3],prefix="t"), twist).act_to_right() True """ return self._act_to_right @@ -302,7 +312,8 @@ def _repr_(self): sage: def twist(x,y): ....: return y - sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist) # indirect doctest + sage: GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), # indirect doctest + ....: WeylGroup(['A',3],prefix="t"), twist) Semidirect product of Weyl Group of type ['A', 2] (as a matrix group acting on the ambient space) acting on Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space) @@ -324,7 +335,8 @@ def _element_constructor_(self, x): ....: return y sage: import __main__ sage: __main__.twist = twist - sage: g = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"),twist).an_element() + sage: g = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), + ....: WeylGroup(['A',3],prefix="t"), twist).an_element() sage: TestSuite(g).run() """ def type_error(): @@ -354,10 +366,10 @@ def one(self): sage: G = GL(2,QQ) sage: V = QQ^2 - sage: EV = GroupExp()(V) # make a multiplicative version of V + sage: EV = GroupExp()(V) # make a multiplicative version of V sage: def twist(g,v): ....: return EV(g*v.value) - sage: one = GroupSemidirectProduct(G, EV, twist=twist, prefix1 = 't').one(); one + sage: one = GroupSemidirectProduct(G, EV, twist=twist, prefix1='t').one(); one 1 sage: one.cartesian_projection(0) [1 0] @@ -378,7 +390,7 @@ def group_generators(self): sage: import __main__ sage: __main__.twist = twist sage: EZ = GroupExp()(ZZ) - sage: GroupSemidirectProduct(EZ,EZ,twist,print_tuple=True).group_generators() + sage: GroupSemidirectProduct(EZ, EZ, twist, print_tuple=True).group_generators() ((1, 0), (0, 1)) """ def has_gens(G): @@ -404,10 +416,10 @@ def product(self, x, y): sage: G = GL(2,QQ) sage: V = QQ^2 - sage: EV = GroupExp()(V) # make a multiplicative version of V + sage: EV = GroupExp()(V) # make a multiplicative version of V sage: def twist(g,v): ....: return EV(g*v.value) - sage: S = GroupSemidirectProduct(G, EV, twist=twist, prefix1 = 't') + sage: S = GroupSemidirectProduct(G, EV, twist=twist, prefix1='t') sage: g = G([[2,1],[3,1]]); g [2 1] [3 1] @@ -442,7 +454,8 @@ def opposite_semidirect_product(self): sage: G = GL(2,QQ) sage: L = QQ^2 sage: EL = GroupExp()(L) - sage: H = GroupSemidirectProduct(G, EL, twist = lambda g,v: EL(g*v.value), prefix1 = 't'); H + sage: H = GroupSemidirectProduct(G, EL, prefix1='t', + ....: twist=lambda g,v: EL(g*v.value)); H Semidirect product of General Linear Group of degree 2 over Rational Field acting on Multiplicative form of Vector space of dimension 2 over Rational Field @@ -479,7 +492,8 @@ def construction(self): sage: def twist(x,y): ....: return y - sage: H = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), WeylGroup(['A',3],prefix="t"), twist) + sage: H = GroupSemidirectProduct(WeylGroup(['A',2],prefix="s"), + ....: WeylGroup(['A',3],prefix="t"), twist) sage: H.construction() """ return None diff --git a/src/sage/groups/groups_catalog.py b/src/sage/groups/groups_catalog.py index 47e6e230508..a95ffaefb4a 100644 --- a/src/sage/groups/groups_catalog.py +++ b/src/sage/groups/groups_catalog.py @@ -101,9 +101,13 @@ # groups.presentation - free groups with relations # groups.symmetries - permutation groups of regular solids, or similar -from sage.groups.matrix_gps import catalog as matrix -from sage.groups.perm_gps import permutation_groups_catalog as permutation -from sage.groups.misc_gps import misc_groups_catalog as misc -from sage.groups.affine_gps import catalog as affine -from sage.groups.lie_gps import catalog as lie -from sage.groups import finitely_presented_catalog as presentation +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.groups.matrix_gps', 'catalog', as_='matrix') +lazy_import('sage.groups.perm_gps', 'permutation_groups_catalog', as_='permutation') +lazy_import('sage.groups.misc_gps', 'misc_groups_catalog', as_='misc') +lazy_import('sage.groups.affine_gps', 'catalog', as_='affine') +lazy_import('sage.groups', 'finitely_presented_catalog', as_='presentation') +lazy_import('sage.groups.lie_gps', 'catalog', as_='lie') + +del lazy_import diff --git a/src/sage/groups/indexed_free_group.py b/src/sage/groups/indexed_free_group.py index 0cbcf9b8a2d..287ab021b1d 100644 --- a/src/sage/groups/indexed_free_group.py +++ b/src/sage/groups/indexed_free_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.combinat """ Indexed Free Groups diff --git a/src/sage/groups/kernel_subgroup.py b/src/sage/groups/kernel_subgroup.py index 024e8f47b3b..605778784e4 100644 --- a/src/sage/groups/kernel_subgroup.py +++ b/src/sage/groups/kernel_subgroup.py @@ -94,8 +94,8 @@ def defining_morphism(self): EXAMPLES:: - sage: PJ3 = groups.misc.PureCactus(3) - sage: PJ3.defining_morphism() + sage: PJ3 = groups.misc.PureCactus(3) # needs sage.rings.number_field + sage: PJ3.defining_morphism() # needs sage.rings.number_field Conversion via _from_cactus_group_element map: From: Cactus Group with 3 fruit To: Symmetric group of order 3! as a permutation group @@ -109,8 +109,8 @@ def ambient(self): EXAMPLES:: - sage: PJ3 = groups.misc.PureCactus(3) - sage: PJ3.ambient() + sage: PJ3 = groups.misc.PureCactus(3) # needs sage.rings.number_field + sage: PJ3.ambient() # needs sage.rings.number_field Cactus Group with 3 fruit """ return self._morphism.domain() @@ -121,8 +121,8 @@ def _an_element_(self): EXAMPLES:: - sage: PJ3 = groups.misc.PureCactus(3) - sage: PJ3.an_element() + sage: PJ3 = groups.misc.PureCactus(3) # needs sage.rings.number_field + sage: PJ3.an_element() # needs sage.rings.number_field 1 """ return self.element_class(self, self.ambient().one()) @@ -133,8 +133,8 @@ def lift(self, x): EXAMPLES:: - sage: PJ3 = groups.misc.PureCactus(3) - sage: PJ3.lift(PJ3.an_element()).parent() + sage: PJ3 = groups.misc.PureCactus(3) # needs sage.rings.number_field + sage: PJ3.lift(PJ3.an_element()).parent() # needs sage.rings.number_field Cactus Group with 3 fruit """ return x.value @@ -145,6 +145,7 @@ def retract(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.group_generators() sage: PJ3 = groups.misc.PureCactus(3) @@ -161,6 +162,7 @@ def _element_constructor_(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.group_generators() sage: PJ3 = groups.misc.PureCactus(3) @@ -200,6 +202,7 @@ def _mul_(self, other): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.group_generators() sage: PJ3 = groups.misc.PureCactus(3) @@ -215,6 +218,7 @@ def __invert__(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.group_generators() sage: PJ3 = groups.misc.PureCactus(3) diff --git a/src/sage/groups/libgap_mixin.py b/src/sage/groups/libgap_mixin.py index 6fb27280d8b..e2da04e9ed3 100644 --- a/src/sage/groups/libgap_mixin.py +++ b/src/sage/groups/libgap_mixin.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules """ Mix-in Class for GAP-based Groups @@ -250,8 +251,8 @@ def conjugacy_classes_representatives(self): EXAMPLES:: - sage: G = SU(3,GF(2)) - sage: len(G.conjugacy_classes_representatives()) + sage: G = SU(3,GF(2)) # needs sage.rings.finite_rings + sage: len(G.conjugacy_classes_representatives()) # needs sage.rings.finite_rings 16 sage: G = GL(2,GF(3)) @@ -261,7 +262,7 @@ def conjugacy_classes_representatives(self): [0 1], [1 1], [0 2], [1 2], [1 0], [1 2], [1 1], [0 1] ) - sage: len(GU(2,GF(5)).conjugacy_classes_representatives()) + sage: len(GU(2,GF(5)).conjugacy_classes_representatives()) # needs sage.rings.finite_rings 36 :: @@ -338,8 +339,8 @@ class function on the conjugacy classes, in that order. EXAMPLES:: sage: G = GL(2,GF(3)) - sage: chi = G.class_function(range(8)) - sage: list(chi) + sage: chi = G.class_function(range(8)) # needs sage.rings.number_field + sage: list(chi) # needs sage.rings.number_field [0, 1, 2, 3, 4, 5, 6, 7] """ from sage.groups.class_function import ClassFunction_libgap @@ -356,8 +357,8 @@ def center(self): EXAMPLES:: - sage: G = SU(3, GF(2)) - sage: G.center() + sage: G = SU(3, GF(2)) # needs sage.rings.finite_rings + sage: G.center() # needs sage.rings.finite_rings Subgroup with 1 generators ( [a 0 0] [0 a 0] @@ -374,7 +375,7 @@ def center(self): [0 2 0] [0 0 2] ) of General Linear Group of degree 3 over Finite Field of size 3 - sage: GU(3, GF(2)).center() + sage: GU(3, GF(2)).center() # needs sage.rings.finite_rings Subgroup with 1 generators ( [a + 1 0 0] [ 0 a + 1 0] @@ -477,7 +478,8 @@ def subgroups(self): sage: G = groups.matrix.GL(2, 2) sage: G.subgroups() - [Subgroup with 0 generators () of General Linear Group of degree 2 over Finite Field of size 2, + [Subgroup with 0 generators () + of General Linear Group of degree 2 over Finite Field of size 2, Subgroup with 1 generators ( [0 1] [1 0] @@ -522,7 +524,8 @@ def conjugacy_classes_subgroups(self): sage: G = groups.matrix.GL(2,2) sage: G.conjugacy_classes_subgroups() - [Subgroup with 0 generators () of General Linear Group of degree 2 over Finite Field of size 2, + [Subgroup with 0 generators () + of General Linear Group of degree 2 over Finite Field of size 2, Subgroup with 1 generators ( [1 1] [0 1] @@ -622,10 +625,10 @@ def intersection(self, other): [-2 -1 2] [ 0 0 1] ) of Matrix group over Rational Field with 2 generators ( - [ 0 1/2 0] [ 0 1/2 0] - [ 2 0 0] [ -2 -1 2] - [ 0 0 1], [ 0 0 1] - ) + [ 0 1/2 0] [ 0 1/2 0] + [ 2 0 0] [ -2 -1 2] + [ 0 0 1], [ 0 0 1] + ) sage: GL(3,ZZ).intersection(G) Subgroup with 1 generators ( [ 1 0 0] @@ -633,11 +636,12 @@ def intersection(self, other): [ 0 0 1] ) of General Linear Group of degree 3 over Integer Ring sage: G.intersection(SL(3,ZZ)) - Subgroup with 0 generators () of Matrix group over Rational Field with 2 generators ( - [ 0 1/2 0] [ 0 1/2 0] - [ 2 0 0] [ -2 -1 2] - [ 0 0 1], [ 0 0 1] - ) + Subgroup with 0 generators () + of Matrix group over Rational Field with 2 generators ( + [ 0 1/2 0] [ 0 1/2 0] + [ 2 0 0] [ -2 -1 2] + [ 0 0 1], [ 0 0 1] + ) """ G = self.gap() H = other.gap() @@ -656,7 +660,7 @@ def irreducible_characters(self): EXAMPLES:: sage: G = GL(2,2) - sage: G.irreducible_characters() + sage: G.irreducible_characters() # needs sage.rings.number_field (Character of General Linear Group of degree 2 over Finite Field of size 2, Character of General Linear Group of degree 2 over Finite Field of size 2, Character of General Linear Group of degree 2 over Finite Field of size 2) @@ -691,7 +695,7 @@ def character(self, values): EXAMPLES:: sage: G = MatrixGroup(AlternatingGroup(4)) - sage: G.character([1]*len(G.conjugacy_classes_representatives())) + sage: G.character([1]*len(G.conjugacy_classes_representatives())) # needs sage.rings.number_field Character of Matrix group over Integer Ring with 12 generators :: @@ -714,7 +718,7 @@ def trivial_character(self): EXAMPLES:: - sage: MatrixGroup(SymmetricGroup(3)).trivial_character() + sage: MatrixGroup(SymmetricGroup(3)).trivial_character() # needs sage.rings.number_field Character of Matrix group over Integer Ring with 6 generators :: @@ -742,10 +746,10 @@ def character_table(self): EXAMPLES:: - sage: MatrixGroup(SymmetricGroup(2)).character_table() + sage: MatrixGroup(SymmetricGroup(2)).character_table() # needs sage.rings.number_field [ 1 -1] [ 1 1] - sage: MatrixGroup(SymmetricGroup(3)).character_table() + sage: MatrixGroup(SymmetricGroup(3)).character_table() # needs sage.rings.number_field [ 1 1 -1] [ 2 -1 0] [ 1 1 1] @@ -797,7 +801,7 @@ def random_element(self): True sage: F = GF(5); MS = MatrixSpace(F,2,2) - sage: gens = [MS([[1,2],[-1,1]]),MS([[1,1],[0,1]])] + sage: gens = [MS([[1,2],[-1,1]]), MS([[1,1],[0,1]])] sage: G = MatrixGroup(gens) sage: G.random_element() # random [1 3] diff --git a/src/sage/groups/libgap_morphism.py b/src/sage/groups/libgap_morphism.py index 93f33bf68a4..a559b6ef504 100644 --- a/src/sage/groups/libgap_morphism.py +++ b/src/sage/groups/libgap_morphism.py @@ -108,7 +108,7 @@ class GroupMorphism_libgap(Morphism): [1 0] [1 1] sage: F = GF(7); MS = MatrixSpace(F,2,2) - sage: F.multiplicative_generator() + sage: F.multiplicative_generator() # needs sage.libs.pari 3 sage: G = MatrixGroup([MS([3,0,0,1])]) sage: a = G.gens()[0]^2 @@ -136,7 +136,7 @@ class GroupMorphism_libgap(Morphism): sage: F = GF(7); MS = MatrixSpace(F,2,2) - sage: F.multiplicative_generator() + sage: F.multiplicative_generator() # needs sage.libs.pari 3 sage: G = MatrixGroup([MS([3,0,0,1])]) sage: a = G.gens()[0]^2 @@ -151,7 +151,7 @@ class GroupMorphism_libgap(Morphism): ) sage: F = GF(7); MS = MatrixSpace(F,2,2) - sage: F.multiplicative_generator() + sage: F.multiplicative_generator() # needs sage.libs.pari 3 sage: G = MatrixGroup([MS([3,0,0,1])]) sage: a = G.gens()[0]^2 @@ -212,6 +212,7 @@ class GroupMorphism_libgap(Morphism): sage: phi(G.one()).parent() General Linear Group of degree 3 over Finite Field of size 3 + sage: # needs sage.symbolic sage: MS = MatrixSpace(SR, 2, 2) sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) sage: G.Hom(G) @@ -400,12 +401,15 @@ def pushforward(self, J, *args, **kwds): a sage: x.parent() Finitely presented group < a, b | a, b^3 > + + sage: # needs sage.rings.finite_rings sage: G = GU(3,2) sage: P = PGU(3,2) sage: pr = Hom(G, P).natural_map() sage: GS = G.subgroup([G.gen(0)]) sage: pr.pushforward(GS) - Subgroup generated by [(3,4,5)(10,18,14)(11,19,15)(12,20,16)(13,21,17)] of (The projective general unitary group of degree 3 over Finite Field of size 2) + Subgroup generated by [(3,4,5)(10,18,14)(11,19,15)(12,20,16)(13,21,17)] of + (The projective general unitary group of degree 3 over Finite Field of size 2) """ dom = self.domain() codom = self.codomain() @@ -564,6 +568,7 @@ def section(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: G = GU(3,2) sage: P = PGU(3,2) sage: pr = Hom(G, P).natural_map() @@ -644,6 +649,7 @@ def _element_constructor_(self, x, check=True, **options): A group homomorphism between a finitely presented group and a subgroup of a permutation group:: + sage: # needs sage.rings.finite_rings sage: PG = PGU(6,2) sage: g, h = PG.gens() sage: p1 = h^-3*(h^-1*g^-1)^2*h*g*h^2*g^-1*h^2*g*h^-5*g^-1 diff --git a/src/sage/groups/matrix_gps/binary_dihedral.py b/src/sage/groups/matrix_gps/binary_dihedral.py index c8813eeabd4..ccce9eeb17b 100644 --- a/src/sage/groups/matrix_gps/binary_dihedral.py +++ b/src/sage/groups/matrix_gps/binary_dihedral.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap sage.modules sage.rings.number_field """ Binary Dihedral Groups diff --git a/src/sage/groups/matrix_gps/coxeter_group.py b/src/sage/groups/matrix_gps/coxeter_group.py index 66a877c61ac..27d65a55a37 100644 --- a/src/sage/groups/matrix_gps/coxeter_group.py +++ b/src/sage/groups/matrix_gps/coxeter_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.graphs """ Coxeter Groups As Matrix Groups @@ -19,23 +20,19 @@ # http://www.gnu.org/licenses/ ############################################################################## -from sage.structure.unique_representation import UniqueRepresentation +import sage.rings.abc + from sage.categories.coxeter_groups import CoxeterGroups from sage.combinat.root_system.coxeter_matrix import CoxeterMatrix from sage.groups.matrix_gps.finitely_generated import FinitelyGeneratedMatrixGroup_generic from sage.groups.matrix_gps.group_element import MatrixGroupElement_generic from sage.matrix.args import SparseEntry from sage.matrix.matrix_space import MatrixSpace - -import sage.rings.abc +from sage.misc.cachefunc import cached_method from sage.rings.integer_ring import ZZ from sage.rings.infinity import infinity -from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField -from sage.rings.number_field.number_field import QuadraticField - -from sage.misc.cachefunc import cached_method - from sage.sets.family import Family +from sage.structure.unique_representation import UniqueRepresentation class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_generic): @@ -82,8 +79,8 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene We can create Coxeter groups from Coxeter matrices:: - sage: W = CoxeterGroup([[1, 6, 3], [6, 1, 10], [3, 10, 1]]) - sage: W + sage: # needs sage.rings.number_field + sage: W = CoxeterGroup([[1, 6, 3], [6, 1, 10], [3, 10, 1]]); W Coxeter group over Universal Cyclotomic Field with Coxeter matrix: [ 1 6 3] [ 6 1 10] @@ -102,6 +99,7 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene [ 0 1 0] [ 1 E(20) - E(20)^9 -1] ) + sage: m = matrix([[1,3,3,3], [3,1,3,2], [3,3,1,2], [3,2,2,1]]) sage: W = CoxeterGroup(m) sage: W.gens() @@ -143,7 +141,7 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene [3 1 3 2] [3 3 1 2] [3 2 2 1] - sage: CoxeterGroup([[1,4],[4,1]], base_ring=QQ) + sage: CoxeterGroup([[1,4],[4,1]], base_ring=QQ) # needs sage.symbolic Traceback (most recent call last): ... TypeError: unable to convert sqrt(2) to a rational @@ -152,6 +150,7 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene graphs, we can input a Coxeter graph. Following the standard convention, edges with no label (i.e. labelled by ``None``) are treated as 3:: + sage: # needs sage.rings.number_field sage: G = Graph([(0,3,None), (1,3,15), (2,3,7), (0,1,3)]) sage: W = CoxeterGroup(G); W Coxeter group over Universal Cyclotomic Field with Coxeter matrix: @@ -166,6 +165,7 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene Because there currently is no class for `\ZZ \cup \{ \infty \}`, labels of `\infty` are given by `-1` in the Coxeter matrix:: + sage: # needs sage.rings.number_field sage: G = Graph([(0,1,None), (1,2,4), (0,2,oo)]) sage: W = CoxeterGroup(G) sage: W.coxeter_matrix() @@ -176,16 +176,14 @@ class CoxeterMatrixGroup(UniqueRepresentation, FinitelyGeneratedMatrixGroup_gene We can also create Coxeter groups from Cartan types using the ``implementation`` keyword:: - sage: W = CoxeterGroup(['D',5], implementation="reflection") - sage: W + sage: W = CoxeterGroup(['D',5], implementation="reflection"); W Finite Coxeter group over Integer Ring with Coxeter matrix: [1 3 2 2 2] [3 1 3 2 2] [2 3 1 3 3] [2 2 3 1 2] [2 2 3 2 1] - sage: W = CoxeterGroup(['H',3], implementation="reflection") - sage: W + sage: W = CoxeterGroup(['H',3], implementation="reflection"); W # needs sage.rings.number_field Finite Coxeter group over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? with Coxeter matrix: @@ -219,6 +217,7 @@ def __classcall_private__(cls, data, base_ring=None, index_set=None): if data.is_simply_laced(): base_ring = ZZ elif data.is_finite(): + from sage.rings.number_field.number_field import QuadraticField letter = data.coxeter_type().cartan_type().type() if letter in ['B', 'C', 'F']: base_ring = QuadraticField(2) @@ -227,8 +226,10 @@ def __classcall_private__(cls, data, base_ring=None, index_set=None): elif letter == 'H': base_ring = QuadraticField(5) else: + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField base_ring = UniversalCyclotomicField() else: + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField base_ring = UniversalCyclotomicField() return super().__classcall__(cls, data, base_ring, data.index_set()) @@ -240,6 +241,8 @@ def __init__(self, coxeter_matrix, base_ring, index_set): sage: W = CoxeterGroup([[1,3,2],[3,1,3],[2,3,1]]) sage: TestSuite(W).run() # long time + + sage: # needs sage.rings.number_field sage: W = CoxeterGroup([[1,3,2],[3,1,4],[2,4,1]], base_ring=QQbar) sage: TestSuite(W).run() # long time sage: W = CoxeterGroup([[1,3,2],[3,1,6],[2,6,1]]) @@ -251,6 +254,8 @@ def __init__(self, coxeter_matrix, base_ring, index_set): sage: CoxeterGroup(['D',4], base_ring=QQ).category() Category of finite irreducible coxeter groups + + sage: # needs sage.rings.number_field sage: CoxeterGroup(['H',4], base_ring=QQbar).category() Category of finite irreducible coxeter groups sage: F = CoxeterGroups().Finite() @@ -274,8 +279,8 @@ def __init__(self, coxeter_matrix, base_ring, index_set): MS = MatrixSpace(base_ring, n, sparse=True) one = MS.one() # FIXME: Hack because there is no ZZ \cup \{ \infty \}: -1 represents \infty - E = UniversalCyclotomicField().gen - if base_ring is UniversalCyclotomicField(): + if isinstance(base_ring, sage.rings.abc.UniversalCyclotomicField): + E = base_ring.gen def val(x): if x == -1: @@ -283,6 +288,9 @@ def val(x): else: return E(2 * x) + ~E(2 * x) elif isinstance(base_ring, sage.rings.abc.NumberField_quadratic): + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField + + E = UniversalCyclotomicField().gen def val(x): if x == -1: @@ -332,7 +340,7 @@ def _repr_(self): EXAMPLES:: - sage: CoxeterGroup([[1,3,2],[3,1,4],[2,4,1]]) + sage: CoxeterGroup([[1,3,2],[3,1,4],[2,4,1]]) # needs sage.rings.number_field Finite Coxeter group over Number Field in a with defining polynomial x^2 - 2 with a = 1.414213562373095? with Coxeter matrix: [1 3 2] [3 1 4] @@ -349,6 +357,7 @@ def _coerce_map_from_(self, P): EXAMPLES:: + sage: # needs sage.combinat sage: W = CoxeterGroup(["A",4]) sage: W2 = WeylGroup(["A",4]) sage: W._coerce_map_from_(W2) @@ -374,7 +383,7 @@ def coxeter_matrix(self): sage: W.coxeter_matrix() [1 3] [3 1] - sage: W = CoxeterGroup(['H',3]) + sage: W = CoxeterGroup(['H',3]) # needs sage.rings.number_field sage: W.coxeter_matrix() [1 3 2] [3 1 5] @@ -400,7 +409,7 @@ def bilinear_form(self): EXAMPLES:: sage: W = CoxeterGroup(['D',4]) - sage: W.bilinear_form() + sage: W.bilinear_form() # needs sage.symbolic [ 1 -1/2 0 0] [-1/2 1 -1/2 -1/2] [ 0 -1/2 1 0] @@ -414,6 +423,7 @@ def is_finite(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: [l for l in range(2, 9) if ....: CoxeterGroup([[1,3,2],[3,1,l],[2,l,1]]).is_finite()] [2, 3, 4, 5] @@ -468,6 +478,7 @@ def order(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: W = CoxeterGroup([[1,3],[3,1]]) sage: W.order() 6 @@ -581,6 +592,8 @@ def positive_roots(self): sage: W = CoxeterGroup(['A',3], implementation='reflection') sage: W.positive_roots() ((1, 0, 0), (1, 1, 0), (0, 1, 0), (1, 1, 1), (0, 1, 1), (0, 0, 1)) + + sage: # needs sage.rings.number_field sage: W = CoxeterGroup(['I',5], implementation='reflection') sage: W.positive_roots() ((1, 0), @@ -637,6 +650,8 @@ def roots(self): (-1, -1, -1), (0, -1, -1), (0, 0, -1)) + + sage: # needs sage.rings.number_field sage: W = CoxeterGroup(['I',5], implementation='reflection') sage: len(W.roots()) 10 @@ -677,7 +692,7 @@ def fundamental_weights(self): EXAMPLES:: sage: W = CoxeterGroup(['A',3], implementation='reflection') - sage: W.fundamental_weights() + sage: W.fundamental_weights() # needs sage.symbolic Finite family {1: (3/2, 1, 1/2), 2: (1, 2, 1), 3: (1/2, 1, 3/2)} """ simple_weights = self.bilinear_form().inverse() @@ -694,7 +709,7 @@ def fundamental_weight(self, i): EXAMPLES:: sage: W = CoxeterGroup(['A',3], implementation='reflection') - sage: W.fundamental_weight(1) + sage: W.fundamental_weight(1) # needs sage.symbolic (3/2, 1, 1/2) """ return self.fundamental_weights()[i] diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py index 874b6b72d7b..d0ec214bb3b 100644 --- a/src/sage/groups/matrix_gps/finitely_generated.py +++ b/src/sage/groups/matrix_gps/finitely_generated.py @@ -6,10 +6,10 @@ EXAMPLES:: - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: gens = [matrix(F, 2, [1,0, -1,1]), matrix(F, 2, [1,1,0,1])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens) # optional - sage.rings.finite_rings - sage: G.conjugacy_classes_representatives() # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: gens = [matrix(F, 2, [1,0, -1,1]), matrix(F, 2, [1,1,0,1])] + sage: G = MatrixGroup(gens) + sage: G.conjugacy_classes_representatives() ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] @@ -161,37 +161,37 @@ def QuaternionMatrixGroupGF3(): is the product of `I` and `J`. :: sage: from sage.groups.matrix_gps.finitely_generated import QuaternionMatrixGroupGF3 - sage: Q = QuaternionMatrixGroupGF3() # optional - sage.rings.finite_rings - sage: Q.order() # optional - sage.rings.finite_rings + sage: Q = QuaternionMatrixGroupGF3() + sage: Q.order() 8 - sage: aye = Q.gens()[0]; aye # optional - sage.rings.finite_rings + sage: aye = Q.gens()[0]; aye [1 1] [1 2] - sage: jay = Q.gens()[1]; jay # optional - sage.rings.finite_rings + sage: jay = Q.gens()[1]; jay [2 1] [1 1] - sage: kay = aye*jay; kay # optional - sage.rings.finite_rings + sage: kay = aye*jay; kay [0 2] [1 0] TESTS:: - sage: groups.matrix.QuaternionGF3() # optional - sage.rings.finite_rings + sage: groups.matrix.QuaternionGF3() # needs sage.modules sage.rings.finite_rings Matrix group over Finite Field of size 3 with 2 generators ( [1 1] [2 1] [1 2], [1 1] ) - sage: Q = QuaternionMatrixGroupGF3() # optional - sage.rings.finite_rings - sage: QP = Q.as_permutation_group() # optional - sage.rings.finite_rings - sage: QP.is_isomorphic(QuaternionGroup()) # optional - sage.rings.finite_rings + sage: Q = QuaternionMatrixGroupGF3() + sage: QP = Q.as_permutation_group() + sage: QP.is_isomorphic(QuaternionGroup()) True - sage: H = DihedralGroup(4) # optional - sage.groups sage.rings.finite_rings - sage: H.order() # optional - sage.groups sage.rings.finite_rings + sage: H = DihedralGroup(4) # needs sage.groups + sage: H.order() # needs sage.groups 8 - sage: QP.is_abelian(), H.is_abelian() # optional - sage.groups sage.rings.finite_rings + sage: QP.is_abelian(), H.is_abelian() # needs sage.groups (False, False) - sage: QP.is_isomorphic(H) # optional - sage.groups sage.rings.finite_rings + sage: QP.is_isomorphic(H) # needs sage.groups False """ from sage.rings.finite_rings.finite_field_constructor import FiniteField @@ -216,9 +216,9 @@ def MatrixGroup(*gens, **kwds): EXAMPLES:: - sage: F = GF(5) # optional - sage.rings.finite_rings - sage: gens = [matrix(F, 2, [1,2, -1,1]), matrix(F,2, [1,1, 0,1])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens); G # optional - sage.rings.finite_rings + sage: F = GF(5) + sage: gens = [matrix(F, 2, [1,2, -1,1]), matrix(F,2, [1,1, 0,1])] + sage: G = MatrixGroup(gens); G Matrix group over Finite Field of size 5 with 2 generators ( [1 2] [1 1] [4 1], [0 1] @@ -230,8 +230,8 @@ def MatrixGroup(*gens, **kwds): matrices over the finite field, so creates that matrix group there:: - sage: gens = [matrix(2, [1,2, -1,1]), matrix(GF(7), 2, [1,1, 0,1]), 2] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens); G # optional - sage.rings.finite_rings + sage: gens = [matrix(2, [1,2, -1,1]), matrix(GF(7), 2, [1,1, 0,1]), 2] + sage: G = MatrixGroup(gens); G Matrix group over Finite Field of size 7 with 3 generators ( [1 2] [1 1] [2 0] [6 1], [0 1], [0 2] @@ -244,12 +244,12 @@ def MatrixGroup(*gens, **kwds): ... ValueError: each generator must be an invertible matrix - sage: F = GF(5); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: MatrixGroup([MS.0]) # optional - sage.rings.finite_rings + sage: F = GF(5); MS = MatrixSpace(F, 2, 2) + sage: MatrixGroup([MS.0]) Traceback (most recent call last): ... ValueError: each generator must be an invertible matrix - sage: MatrixGroup([MS.0], check=False) # works formally but is mathematical nonsense # optional - sage.rings.finite_rings + sage: MatrixGroup([MS.0], check=False) # works formally but is mathematical nonsense Matrix group over Finite Field of size 5 with 1 generators ( [1 0] [0 0] @@ -319,15 +319,16 @@ class FinitelyGeneratedMatrixGroup_generic(MatrixGroup_generic): """ TESTS:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # optional - sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # optional - sage.symbolic - sage: MatrixGroup(m1) == MatrixGroup(m1) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) + sage: m2 = matrix(SR, [[1,3], [-1,0]]) + sage: MatrixGroup(m1) == MatrixGroup(m1) True - sage: MatrixGroup(m1) == MatrixGroup(m1.change_ring(QQ)) # optional - sage.symbolic + sage: MatrixGroup(m1) == MatrixGroup(m1.change_ring(QQ)) False - sage: MatrixGroup(m1) == MatrixGroup(m2) # optional - sage.symbolic + sage: MatrixGroup(m1) == MatrixGroup(m2) False - sage: MatrixGroup(m1, m2) == MatrixGroup(m2, m1) # optional - sage.symbolic + sage: MatrixGroup(m1, m2) == MatrixGroup(m2, m1) False sage: m1 = matrix(QQ, [[1,2], [3,4]]) @@ -339,9 +340,9 @@ class FinitelyGeneratedMatrixGroup_generic(MatrixGroup_generic): sage: MatrixGroup(m1, m2) == MatrixGroup(m2, m1) False - sage: G = GL(2, GF(3)) # optional - sage.rings.finite_rings - sage: H = G.as_matrix_group() # optional - sage.rings.finite_rings - sage: H == G, G == H # optional - sage.rings.finite_rings + sage: G = GL(2, GF(3)) + sage: H = G.as_matrix_group() + sage: H == G, G == H (True, True) """ @@ -351,11 +352,12 @@ def __init__(self, degree, base_ring, generator_matrices, category=None): EXAMPLES:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # optional - sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # optional - sage.symbolic - sage: G = MatrixGroup(m1, m2) # optional - sage.symbolic - sage: TestSuite(G).run() # optional - sage.symbolic - sage: type(G) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) + sage: m2 = matrix(SR, [[1,3], [-1,0]]) + sage: G = MatrixGroup(m1, m2) + sage: TestSuite(G).run() + sage: type(G) sage: from sage.groups.matrix_gps.finitely_generated import \ @@ -377,24 +379,24 @@ def gens(self): EXAMPLES:: - sage: F = GF(3); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens) # optional - sage.rings.finite_rings - sage: gens[0] in G # optional - sage.rings.finite_rings + sage: F = GF(3); MS = MatrixSpace(F, 2, 2) + sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] + sage: G = MatrixGroup(gens) + sage: gens[0] in G True - sage: gens = G.gens() # optional - sage.rings.finite_rings - sage: gens[0] in G # optional - sage.rings.finite_rings + sage: gens = G.gens() + sage: gens[0] in G True - sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] # optional - sage.rings.finite_rings + sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] - sage: F = GF(5); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: G = MatrixGroup([MS(1), MS([1,2, 3,4])]) # optional - sage.rings.finite_rings - sage: G # optional - sage.rings.finite_rings + sage: F = GF(5); MS = MatrixSpace(F, 2, 2) + sage: G = MatrixGroup([MS(1), MS([1,2, 3,4])]) + sage: G Matrix group over Finite Field of size 5 with 2 generators ( [1 0] [1 2] [0 1], [3 4] ) - sage: G.gens() # optional - sage.rings.finite_rings + sage: G.gens() ( [1 0] [1 2] [0 1], [3 4] @@ -413,13 +415,13 @@ def gen(self, i): EXAMPLES:: - sage: H = GL(2, GF(3)) # optional - sage.rings.finite_rings - sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) # optional - sage.rings.finite_rings - sage: G = H.subgroup([h1, h2]) # optional - sage.rings.finite_rings - sage: G.gen(0) # optional - sage.rings.finite_rings + sage: H = GL(2, GF(3)) + sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) + sage: G = H.subgroup([h1, h2]) + sage: G.gen(0) [1 0] [2 1] - sage: G.gen(0).matrix() == h1.matrix() # optional - sage.rings.finite_rings + sage: G.gen(0).matrix() == h1.matrix() True """ return self.gens()[i] @@ -434,10 +436,10 @@ def ngens(self): EXAMPLES:: - sage: H = GL(2, GF(3)) # optional - sage.rings.finite_rings - sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) # optional - sage.rings.finite_rings - sage: G = H.subgroup([h1, h2]) # optional - sage.rings.finite_rings - sage: G.ngens() # optional - sage.rings.finite_rings + sage: H = GL(2, GF(3)) + sage: h1, h2 = H([[1,0], [2,1]]), H([[1,1], [0,1]]) + sage: G = H.subgroup([h1, h2]) + sage: G.ngens() 2 """ return len(self._gens_matrix) @@ -455,10 +457,11 @@ def __reduce__(self): Check that :trac:`22128` is fixed:: - sage: R = MatrixSpace(SR, 2) # optional - sage.symbolic - sage: G = MatrixGroup([R([[1, 1], [0, 1]])]) # optional - sage.symbolic - sage: G.register_embedding(R) # optional - sage.symbolic - sage: loads(dumps(G)) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: R = MatrixSpace(SR, 2) + sage: G = MatrixGroup([R([[1, 1], [0, 1]])]) + sage: G.register_embedding(R) + sage: loads(dumps(G)) Matrix group over Symbolic Ring with 1 generators ( [1 1] [0 1] @@ -470,10 +473,11 @@ def _test_matrix_generators(self, **options): """ EXAMPLES:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # optional - sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # optional - sage.symbolic - sage: G = MatrixGroup(m1, m2) # optional - sage.symbolic - sage: G._test_matrix_generators() # optional - sage.symbolic + sage: # needs sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) + sage: m2 = matrix(SR, [[1,3], [-1,0]]) + sage: G = MatrixGroup(m1, m2) + sage: G._test_matrix_generators() """ tester = self._tester(**options) for g,h in zip(self.gens(), MatrixGroup(self.gens()).gens()): diff --git a/src/sage/groups/matrix_gps/finitely_generated_gap.py b/src/sage/groups/matrix_gps/finitely_generated_gap.py index a171742b60a..5864f64afd3 100644 --- a/src/sage/groups/matrix_gps/finitely_generated_gap.py +++ b/src/sage/groups/matrix_gps/finitely_generated_gap.py @@ -34,10 +34,8 @@ from sage.modules.free_module_element import vector from sage.rings.fraction_field import FractionField from sage.rings.integer_ring import ZZ -from sage.rings.number_field.number_field import CyclotomicField from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.power_series_ring import PowerSeriesRing -from sage.rings.qqbar import QQbar from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence @@ -179,10 +177,11 @@ def as_permutation_group(self, algorithm=None, seed=None): Check that :trac:`25706` still works after :trac:`26903`:: + sage: # needs sage.libs.pari sage: MG = GU(3,2).as_matrix_group() sage: PG = MG.as_permutation_group() sage: mg = MG.an_element() - sage: PG(mg).order() # particular element depends on the set of GAP packages installed + sage: PG(mg).order() # particular element depends on the set of GAP packages installed 6 """ # Note that the output of IsomorphismPermGroup() depends on @@ -211,14 +210,14 @@ def module_composition_factors(self, algorithm=None): sage: F = GF(3); MS = MatrixSpace(F,4,4) sage: M = MS(0) - sage: M[0,1]=1;M[1,2]=1;M[2,3]=1;M[3,0]=1 + sage: M[0,1] = 1; M[1,2] = 1; M[2,3] = 1; M[3,0] = 1 sage: G = MatrixGroup([M]) sage: G.module_composition_factors() [(Finite Field of size 3, 1, True), (Finite Field of size 3, 1, True), (Finite Field of size 3, 2, True)] sage: F = GF(7); MS = MatrixSpace(F,2,2) - sage: gens = [MS([[0,1],[-1,0]]),MS([[1,1],[2,3]])] + sage: gens = [MS([[0,1],[-1,0]]), MS([[1,1],[2,3]])] sage: G = MatrixGroup(gens) sage: G.module_composition_factors() [(Finite Field of size 7, 2, True)] @@ -272,20 +271,22 @@ def invariant_generators(self): sage: F = GF(7); MS = MatrixSpace(F,2,2) sage: gens = [MS([[0,1],[-1,0]]),MS([[1,1],[2,3]])] sage: G = MatrixGroup(gens) - sage: G.invariant_generators() + sage: G.invariant_generators() # needs sage.libs.singular [x1^7*x2 - x1*x2^7, x1^12 - 2*x1^9*x2^3 - x1^6*x2^6 + 2*x1^3*x2^9 + x2^12, x1^18 + 2*x1^15*x2^3 + 3*x1^12*x2^6 + 3*x1^6*x2^12 - 2*x1^3*x2^15 + x2^18] sage: q = 4; a = 2 sage: MS = MatrixSpace(QQ, 2, 2) - sage: gen1 = [[1/a,(q-1)/a],[1/a, -1/a]]; gen2 = [[1,0],[0,-1]]; gen3 = [[-1,0],[0,1]] - sage: G = MatrixGroup([MS(gen1),MS(gen2),MS(gen3)]) + sage: gen1 = [[1/a, (q-1)/a], [1/a, -1/a]] + sage: gen2 = [[1,0], [0,-1]]; gen3 = [[-1,0], [0,1]] + sage: G = MatrixGroup([MS(gen1), MS(gen2), MS(gen3)]) sage: G.cardinality() 12 - sage: G.invariant_generators() + sage: G.invariant_generators() # needs sage.libs.singular [x1^2 + 3*x2^2, x1^6 + 15*x1^4*x2^2 + 15*x1^2*x2^4 + 33*x2^6] + sage: # needs sage.rings.number_field sage: F = CyclotomicField(8) sage: z = F.gen() sage: a = z+1/z @@ -294,7 +295,7 @@ def invariant_generators(self): sage: g1 = MS([[1/a, 1/a], [1/a, -1/a]]) sage: g2 = MS([[-b, 0], [0, b]]) sage: G = MatrixGroup([g1,g2]) - sage: G.invariant_generators() + sage: G.invariant_generators() # needs sage.libs.singular [x1^4 + 2*x1^2*x2^2 + x2^4, x1^5*x2 - x1*x2^5, x1^8 + 28/9*x1^6*x2^2 + 70/9*x1^4*x2^4 + 28/9*x1^2*x2^6 + x2^8] @@ -442,13 +443,14 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): Traceback (most recent call last): ... NotImplementedError: only implemented for finite groups - sage: MatrixGroup(matrix(GF(3),2,2,[1,1,0,1])).molien_series() + sage: MatrixGroup(matrix(GF(3),2,2,[1,1,0,1])).molien_series() # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: characteristic cannot divide group order Tetrahedral Group:: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(4) sage: Tetra = MatrixGroup([(-1+i)/2,(-1+i)/2, (1+i)/2,(-1-i)/2], [0,i, -i,0]) sage: Tetra.molien_series(prec=30) @@ -466,12 +468,12 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): :: + sage: # needs sage.groups sage.rings.number_field sage: S3 = MatrixGroup(SymmetricGroup(3)) sage: mol = S3.molien_series(prec=10); mol 1 + t + 2*t^2 + 3*t^3 + 4*t^4 + 5*t^5 + 7*t^6 + 8*t^7 + 10*t^8 + 12*t^9 + O(t^10) sage: mol.parent() Power Series Ring in t over Integer Ring - sage: mol = S3.molien_series(prec=oo); mol 1 + t + 2*t^2 + 3*t^3 + 4*t^4 + 5*t^5 + 7*t^6 + O(t^7) sage: mol.parent() @@ -479,28 +481,32 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): Octahedral Group:: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(8) - sage: a = v-v^3 #sqrt(2) + sage: a = v - v^3 # sqrt(2) sage: i = v^2 - sage: Octa = MatrixGroup([(-1+i)/2, (-1+i)/2, (1+i)/2, (-1-i)/2], + sage: Octa = MatrixGroup([(-1+i)/2, (-1+i)/2, (1+i)/2, (-1-i)/2], # needs sage.symbolic ....: [(1+i)/a, 0, 0, (1-i)/a]) - sage: Octa.molien_series(prec=30) + sage: Octa.molien_series(prec=30) # needs sage.symbolic 1 + t^8 + t^12 + t^16 + t^18 + t^20 + 2*t^24 + t^26 + t^28 + O(t^30) Icosahedral Group:: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(10) sage: z5 = v^2 sage: i = z5^5 - sage: a = 2*z5^3 + 2*z5^2 + 1 #sqrt(5) + sage: a = 2*z5^3 + 2*z5^2 + 1 #sqrt(5) sage: Ico = MatrixGroup([[z5^3,0, 0,z5^2], ....: [0,1, -1,0], - ....: [(z5^4-z5)/a, (z5^2-z5^3)/a, (z5^2-z5^3)/a, -(z5^4-z5)/a]]) + ....: [(z5^4-z5)/a, (z5^2-z5^3)/a, + ....: (z5^2-z5^3)/a, -(z5^4-z5)/a]]) sage: Ico.molien_series(prec=40) 1 + t^12 + t^20 + t^24 + t^30 + t^32 + t^36 + O(t^40) :: + sage: # needs sage.groups sage.rings.number_field sage: G = MatrixGroup(CyclicPermutationGroup(3)) sage: chi = G.character(G.character_table()[1]) sage: G.molien_series(chi, prec=10) @@ -509,15 +515,18 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): :: + sage: # needs sage.groups sage.rings.number_field sage: K = GF(5) sage: S = MatrixGroup(SymmetricGroup(4)) - sage: G = MatrixGroup([matrix(K, 4, 4, [K(y) for u in m.list() for y in u]) + sage: G = MatrixGroup([matrix(K, 4, 4, + ....: [K(y) for u in m.list() for y in u]) ....: for m in S.gens()]) sage: G.molien_series(return_series=False) 1/(t^10 - t^9 - t^8 + 2*t^5 - t^2 - t + 1) :: + sage: # needs sage.rings.number_field sage: i = GF(7)(3) sage: G = MatrixGroup([[i^3,0, 0,-i^3], [i^2,0, 0,-i^2]]) sage: chi = G.character(G.character_table()[4]) @@ -554,6 +563,7 @@ def molien_series(self, chi=None, return_series=True, prec=20, variable='t'): w = F.roots(ring=R.algebraic_closure(), multiplicities=False)[0] # don't need to extend further in this case since the order of # the roots of unity in the character divide the order of the group + from sage.rings.number_field.number_field import CyclotomicField L = CyclotomicField(N, 'v') v = L.gen() # construct Molien series @@ -627,11 +637,12 @@ def reynolds_operator(self, poly, chi=None): sage: S3 = MatrixGroup(SymmetricGroup(3)) sage: R. = QQ[] sage: f = x*y*z^3 - sage: S3.reynolds_operator(f) + sage: S3.reynolds_operator(f) # needs sage.rings.number_field 1/3*x^3*y*z + 1/3*x*y^3*z + 1/3*x*y*z^3 :: + sage: # needs sage.groups sage.rings.number_field sage: G = MatrixGroup(CyclicPermutationGroup(4)) sage: chi = G.character(G.character_table()[3]) sage: K. = CyclotomicField(4) @@ -645,6 +656,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.groups sage.rings.number_field sage: K. = CyclotomicField(4) sage: G = MatrixGroup(CyclicPermutationGroup(3)) sage: chi = G.character(G.character_table()[1]) @@ -659,6 +671,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(4) sage: Tetra = MatrixGroup([(-1+i)/2,(-1+i)/2, (1+i)/2,(-1-i)/2], [0,i, -i,0]) sage: chi = Tetra.character(Tetra.character_table()[4]) @@ -678,6 +691,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.groups sage.rings.number_field sage: G = MatrixGroup(DihedralGroup(4)) sage: chi = G.character(G.character_table()[1]) sage: R. = QQ[] @@ -705,10 +719,10 @@ def reynolds_operator(self, poly, chi=None): sage: i = GF(7)(3) sage: G = MatrixGroup([[i^3,0, 0,-i^3], [i^2,0, 0,-i^2]]) - sage: chi = G.character(G.character_table()[4]) + sage: chi = G.character(G.character_table()[4]) # needs sage.rings.number_field sage: R. = GF(7)[] sage: f = w^5*x + x^6 - sage: G.reynolds_operator(f, chi) + sage: G.reynolds_operator(f, chi) # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: nontrivial characters not implemented for characteristic > 0 @@ -717,6 +731,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.rings.finite_rings sage: K = GF(3^2,'t') sage: G = MatrixGroup([matrix(K, 2, 2, [0,K.gen(), 1,0])]) sage: R. = GF(3)[] @@ -725,6 +740,7 @@ def reynolds_operator(self, poly, chi=None): :: + sage: # needs sage.rings.finite_rings sage: K = GF(3^2,'t') sage: G = MatrixGroup([matrix(GF(3), 2, 2, [0,1, 1,0])]) sage: R. = K[] @@ -738,6 +754,7 @@ def reynolds_operator(self, poly, chi=None): C = FractionField(self.base_ring()) if chi is None: # then this is the trivial character if R.characteristic() == 0: + from sage.rings.qqbar import QQbar # non-modular case if C == QQbar or R == QQbar: L = QQbar @@ -770,6 +787,7 @@ def reynolds_operator(self, poly, chi=None): # non-trivial character case K = chi.values()[0].parent() if R.characteristic() == 0: + from sage.rings.qqbar import QQbar # extend base_ring to compositum if C == QQbar or K == QQbar or R == QQbar: L = QQbar @@ -831,6 +849,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): EXAMPLES:: + sage: # needs sage.groups sage.rings.number_field sage: Gr = MatrixGroup(SymmetricGroup(2)) sage: sorted(Gr.invariants_of_degree(3)) [x0^2*x1 + x0*x1^2, x0^3 + x1^3] @@ -840,6 +859,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): :: + sage: # needs sage.groups sage.rings.number_field sage: R. = QQ[] sage: Gr = MatrixGroup(DihedralGroup(3)) sage: ct = Gr.character_table() @@ -852,11 +872,12 @@ def invariants_of_degree(self, deg, chi=None, R=None): sage: i = GF(7)(3) sage: G = MatrixGroup([[i^3,0,0,-i^3],[i^2,0,0,-i^2]]) - sage: G.invariants_of_degree(25) + sage: G.invariants_of_degree(25) # needs sage.rings.number_field [] :: + sage: # needs sage.groups sage: G = MatrixGroup(SymmetricGroup(5)) sage: R = QQ['x,y'] sage: G.invariants_of_degree(3, R=R) @@ -866,6 +887,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): :: + sage: # needs sage.groups sage.rings.number_field sage: K. = CyclotomicField(4) sage: G = MatrixGroup(CyclicPermutationGroup(3)) sage: chi = G.character(G.character_table()[1]) @@ -878,6 +900,7 @@ def invariants_of_degree(self, deg, chi=None, R=None): :: + sage: # needs sage.groups sage.rings.number_field sage: S3 = MatrixGroup(SymmetricGroup(3)) sage: chi = S3.character(S3.character_table()[0]) sage: sorted(S3.invariants_of_degree(5, chi=chi)) @@ -907,13 +930,14 @@ def invariants_of_degree(self, deg, chi=None, R=None): def _new_invariant_is_linearly_independent(F, invariants): """ - EXAMPLES :: + EXAMPLES:: + sage: gens = [matrix(QQ, [[-1,1],[-1,0]]), matrix(QQ, [[0,1],[1,0]])] sage: G = MatrixGroup(gens) - sage: s = Sequence(G.invariants_of_degree(14)) - sage: s.coefficient_matrix()[0].rank() + sage: s = Sequence(G.invariants_of_degree(14)) # needs sage.rings.number_field + sage: s.coefficient_matrix()[0].rank() # needs sage.rings.number_field 3 - sage: len(s) + sage: len(s) # needs sage.rings.number_field 3 """ if len(invariants)==0: diff --git a/src/sage/groups/matrix_gps/group_element.pyx b/src/sage/groups/matrix_gps/group_element.pyx index 4e57798b384..2764e33a7a8 100644 --- a/src/sage/groups/matrix_gps/group_element.pyx +++ b/src/sage/groups/matrix_gps/group_element.pyx @@ -3,15 +3,15 @@ Matrix Group Elements EXAMPLES:: - sage: F = GF(3); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens); G # optional - sage.rings.finite_rings + sage: F = GF(3); MS = MatrixSpace(F, 2, 2) + sage: gens = [MS([[1,0], [0,1]]), MS([[1,1], [0,1]])] + sage: G = MatrixGroup(gens); G Matrix group over Finite Field of size 3 with 2 generators ( [1 0] [1 1] [0 1], [0 1] ) - sage: g = G([[1,1], [0,1]]) # optional - sage.rings.finite_rings - sage: h = G([[1,2], [0,1]]) # optional - sage.rings.finite_rings - sage: g*h # optional - sage.rings.finite_rings + sage: g = G([[1,1], [0,1]]) + sage: h = G([[1,2], [0,1]]) + sage: g*h [1 0] [0 1] @@ -19,7 +19,7 @@ You cannot add two matrices, since this is not a group operation. You can coerce matrices back to the matrix space and add them there:: - sage: g + h # optional - sage.rings.finite_rings + sage: g + h Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for +: @@ -32,14 +32,14 @@ there:: [0 1], [0 1] )' - sage: g.matrix() + h.matrix() # optional - sage.rings.finite_rings + sage: g.matrix() + h.matrix() [2 0] [0 2] Similarly, you cannot multiply group elements by scalars but you can do it with the underlying matrices:: - sage: 2*g # optional - sage.rings.finite_rings + sage: 2*g Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for *: 'Integer Ring' @@ -105,8 +105,8 @@ cpdef is_MatrixGroupElement(x): sage: is_MatrixGroupElement('helloooo') False - sage: G = GL(2,3) # optional - sage.rings.finite_rings - sage: is_MatrixGroupElement(G.an_element()) # optional - sage.rings.finite_rings + sage: G = GL(2,3) + sage: is_MatrixGroupElement(G.an_element()) True """ return isinstance(x, (MatrixGroupElement_generic, MatrixGroupElement_gap)) @@ -137,8 +137,8 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element(); g # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element(); g # needs sage.graphs [ 0 0 -1] [ 1 0 -1] [ 0 1 -1] @@ -149,9 +149,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: TestSuite(g).run() # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element() # needs sage.graphs + sage: TestSuite(g).run() # needs sage.graphs """ if convert: M = parent.matrix_space()(M) @@ -172,9 +172,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): r""" TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: hash(g) # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element() # needs sage.graphs + sage: hash(g) # needs sage.graphs 660522311176098153 # 64-bit -606138007 # 32-bit """ @@ -186,9 +186,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): TESTS:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: loads(g.dumps()) == g # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element() # needs sage.graphs + sage: loads(g.dumps()) == g # needs sage.graphs True """ return (_unpickle_generic_element, (self.parent(), self._matrix,)) @@ -199,8 +199,8 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: W.an_element() # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: W.an_element() # needs sage.graphs [ 0 0 -1] [ 1 0 -1] [ 0 1 -1] @@ -211,9 +211,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): r""" EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: latex(g) # optional - sage.combinat + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # needs sage.graphs + sage: g = W.an_element() # needs sage.graphs + sage: latex(g) # needs sage.graphs \left(\begin{array}{rrr} 0 & 0 & -1 \\ 1 & 0 & -1 \\ @@ -226,13 +226,14 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): """ EXAMPLES:: - sage: W = CoxeterGroup(['A',4], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: g * vector([1,1,1,1]) # optional - sage.combinat + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',4], base_ring=ZZ) + sage: g = W.gen(0) + sage: g * vector([1,1,1,1]) (0, 1, 1, 1) - sage: v = vector([3,2,1,-1]) # optional - sage.combinat - sage: g = W.gen(1) # optional - sage.combinat - sage: v * g == v * g.matrix() # indirect doctest # optional - sage.combinat + sage: v = vector([3,2,1,-1]) + sage: g = W.gen(1) + sage: v * g == v * g.matrix() # indirect doctest True """ if not is_MatrixGroupElement(x) and x not in self.parent().base_ring(): @@ -248,16 +249,17 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): """ EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: TestSuite(g).run() # optional - sage.combinat - sage: h = W.gen(0) * W.gen(1) * W.gen(2) # optional - sage.combinat - sage: g == h # optional - sage.combinat + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.an_element() + sage: TestSuite(g).run() + sage: h = W.gen(0) * W.gen(1) * W.gen(2) + sage: g == h True - sage: a = W.gen(0) # optional - sage.combinat - sage: a == g # optional - sage.combinat + sage: a = W.gen(0) + sage: a == g False - sage: a != g # optional - sage.combinat + sage: a != g True """ cdef MatrixGroupElement_generic x = self @@ -270,13 +272,14 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: g # optional - sage.combinat + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.gen(0) + sage: g [-1 1 0] [ 0 1 0] [ 0 0 1] - sage: g.list() # optional - sage.combinat + sage: g.list() [[-1, 1, 0], [0, 1, 0], [0, 0, 1]] """ return [r.list() for r in self._matrix.rows()] @@ -291,19 +294,20 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: g.matrix() # optional - sage.combinat + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.gen(0) + sage: g.matrix() [-1 1 0] [ 0 1 0] [ 0 0 1] - sage: parent(g.matrix()) # optional - sage.combinat + sage: parent(g.matrix()) Full MatrixSpace of 3 by 3 dense matrices over Integer Ring Matrices have extra functionality that matrix group elements do not have:: - sage: g.matrix().charpoly('t') # optional - sage.combinat + sage: g.matrix().charpoly('t') # needs sage.combinat sage.libs.gap t^3 - t^2 - t + 1 """ return self._matrix @@ -314,9 +318,9 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A', 3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: matrix(RDF, g) # optional - sage.combinat + sage: W = CoxeterGroup(['A', 3], base_ring=ZZ) # needs sage.graphs + sage: g = W.gen(0) # needs sage.graphs + sage: matrix(RDF, g) # needs sage.graphs [-1.0 1.0 0.0] [ 0.0 1.0 0.0] [ 0.0 0.0 1.0] @@ -330,10 +334,11 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: h = W.an_element() # optional - sage.combinat - sage: g * h # optional - sage.combinat + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.gen(0) + sage: h = W.an_element() + sage: g * h [ 1 0 0] [ 1 0 -1] [ 0 1 -1] @@ -351,14 +356,14 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3]) # optional - sage.combinat - sage: g = W.gen(0) # optional - sage.combinat - sage: g.is_one() # optional - sage.combinat + sage: # needs sage.graphs + sage: W = CoxeterGroup(['A',3]) + sage: g = W.gen(0) + sage: g.is_one() False - - sage: W.an_element().is_one() # optional - sage.combinat + sage: W.an_element().is_one() False - sage: W.one().is_one() # optional - sage.combinat + sage: W.one().is_one() True """ return self._matrix.is_one() @@ -371,22 +376,24 @@ cdef class MatrixGroupElement_generic(MultiplicativeGroupElement): EXAMPLES:: - sage: W = CoxeterGroup(['A',3], base_ring=ZZ) # optional - sage.combinat - sage: g = W.an_element() # optional - sage.combinat - sage: ~g # optional - sage.combinat + sage: # needs sage.combinat sage.libs.gap + sage: W = CoxeterGroup(['A',3], base_ring=ZZ) + sage: g = W.an_element() + sage: ~g [-1 1 0] [-1 0 1] [-1 0 0] - sage: g * ~g == W.one() # optional - sage.combinat + sage: g * ~g == W.one() True - sage: ~g * g == W.one() # optional - sage.combinat + sage: ~g * g == W.one() True - sage: W = CoxeterGroup(['B',3]) # optional - sage.combinat sage.rings.number_field - sage: W.base_ring() # optional - sage.combinat sage.rings.number_field + sage: # needs sage.combinat sage.libs.gap sage.rings.number_field + sage: W = CoxeterGroup(['B',3]) + sage: W.base_ring() Number Field in a with defining polynomial x^2 - 2 with a = 1.414213562373095? - sage: g = W.an_element() # optional - sage.combinat sage.rings.number_field - sage: ~g # optional - sage.combinat sage.rings.number_field + sage: g = W.an_element() + sage: ~g [-1 1 0] [-1 0 a] [-a 0 1] @@ -413,12 +420,13 @@ def _unpickle_generic_element(G, mat): EXAMPLES:: - sage: m1 = matrix(SR, [[1,2], [3,4]]) # optional - sage.symbolic - sage: m2 = matrix(SR, [[1,3], [-1,0]]) # optional - sage.symbolic - sage: G = MatrixGroup(m1, m2) # optional - sage.symbolic - sage: m = G.an_element() # optional - sage.symbolic - sage: from sage.groups.matrix_gps.group_element import _unpickle_generic_element # optional - sage.symbolic - sage: _unpickle_generic_element(G, m.matrix()) == m # optional - sage.symbolic + sage: # needs sage.symbolic + sage: m1 = matrix(SR, [[1,2], [3,4]]) + sage: m2 = matrix(SR, [[1,3], [-1,0]]) + sage: G = MatrixGroup(m1, m2) + sage: m = G.an_element() + sage: from sage.groups.matrix_gps.group_element import _unpickle_generic_element + sage: _unpickle_generic_element(G, m.matrix()) == m True """ return G.element_class(G, mat, False, False) diff --git a/src/sage/groups/matrix_gps/group_element_gap.pyx b/src/sage/groups/matrix_gps/group_element_gap.pyx index c26ddebde71..b07c0f01a44 100644 --- a/src/sage/groups/matrix_gps/group_element_gap.pyx +++ b/src/sage/groups/matrix_gps/group_element_gap.pyx @@ -223,7 +223,7 @@ cdef class MatrixGroupElement_gap(ElementLibGAP): sage: F = GF(3); MS = MatrixSpace(F,2,2) sage: G = MatrixGroup([MS([1,1,0,1])]) sage: g = G.gen(0) - sage: M = matrix(GF(9), g); M; parent(M) + sage: M = matrix(GF(9), g); M; parent(M) # needs sage.rings.finite_rings [1 1] [0 1] Full MatrixSpace of 2 by 2 dense matrices over Finite Field in z2 of size 3^2 diff --git a/src/sage/groups/matrix_gps/heisenberg.py b/src/sage/groups/matrix_gps/heisenberg.py index 17705a55cde..8a262ddf1c7 100644 --- a/src/sage/groups/matrix_gps/heisenberg.py +++ b/src/sage/groups/matrix_gps/heisenberg.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.gap sage.modules """ Heisenberg Group diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py index 3810a80cadc..cbc88ccb184 100644 --- a/src/sage/groups/matrix_gps/isometries.py +++ b/src/sage/groups/matrix_gps/isometries.py @@ -8,9 +8,8 @@ EXAMPLES:: - sage: L = IntegralLattice("D4") - sage: O = L.orthogonal_group() - sage: O + sage: L = IntegralLattice("D4") # needs sage.graphs + sage: O = L.orthogonal_group(); O # needs sage.graphs Group of isometries with 3 generators ( [0 0 0 1] [ 1 1 0 0] [ 1 0 0 0] [0 1 0 0] [ 0 0 1 0] [-1 -1 -1 -1] @@ -20,9 +19,9 @@ Basic functionality is provided by GAP:: - sage: O.cardinality() + sage: O.cardinality() # needs sage.graphs 1152 - sage: len(O.conjugacy_classes_representatives()) + sage: len(O.conjugacy_classes_representatives()) # needs sage.graphs 25 AUTHORS: diff --git a/src/sage/groups/matrix_gps/linear.py b/src/sage/groups/matrix_gps/linear.py index 8dc29267923..d13904dec51 100644 --- a/src/sage/groups/matrix_gps/linear.py +++ b/src/sage/groups/matrix_gps/linear.py @@ -9,22 +9,22 @@ General Linear Group of degree 1 over Integer Ring sage: GL(100, RR) General Linear Group of degree 100 over Real Field with 53 bits of precision - sage: GL(3, GF(49,'a')) # optional - sage.rings.finite_rings + sage: GL(3, GF(49,'a')) # needs sage.rings.finite_rings General Linear Group of degree 3 over Finite Field in a of size 7^2 sage: SL(2, ZZ) Special Linear Group of degree 2 over Integer Ring - sage: G = SL(2, GF(3)); G # optional - sage.rings.finite_rings + sage: G = SL(2, GF(3)); G Special Linear Group of degree 2 over Finite Field of size 3 - sage: G.is_finite() # optional - sage.rings.finite_rings + sage: G.is_finite() True - sage: G.conjugacy_classes_representatives() # optional - sage.rings.finite_rings + sage: G.conjugacy_classes_representatives() ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] ) - sage: G = SL(6, GF(5)) # optional - sage.rings.finite_rings - sage: G.gens() # optional - sage.rings.finite_rings + sage: G = SL(6, GF(5)) + sage: G.gens() ( [2 0 0 0 0 0] [4 0 0 0 0 1] [0 3 0 0 0 0] [4 0 0 0 0 0] @@ -93,14 +93,14 @@ def GL(n, R, var='a'): EXAMPLES:: - sage: G = GL(6, GF(5)) # optional - sage.rings.finite_rings - sage: G.order() # optional - sage.rings.finite_rings + sage: G = GL(6, GF(5)) + sage: G.order() 11064475422000000000000000 - sage: G.base_ring() # optional - sage.rings.finite_rings + sage: G.base_ring() Finite Field of size 5 - sage: G.category() # optional - sage.rings.finite_rings + sage: G.category() Category of finite groups - sage: TestSuite(G).run() # optional - sage.rings.finite_rings + sage: TestSuite(G).run() sage: G = GL(6, QQ) sage: G.category() @@ -109,34 +109,34 @@ def GL(n, R, var='a'): Here is the Cayley graph of (relatively small) finite General Linear Group:: - sage: g = GL(2,3) # optional - sage.rings.finite_rings - sage: d = g.cayley_graph(); d # optional - sage.graphs sage.rings.finite_rings + sage: g = GL(2,3) + sage: d = g.cayley_graph(); d # needs sage.graphs Digraph on 48 vertices - sage: d.plot(color_by_label=True, vertex_size=0.03, # long time # optional - sage.graphs sage.rings.finite_rings sage.plot + sage: d.plot(color_by_label=True, vertex_size=0.03, # long time # needs sage.graphs sage.plot ....: vertex_labels=False) Graphics object consisting of 144 graphics primitives - sage: d.plot3d(color_by_label=True) # long time # optional - sage.graphs sage.rings.finite_rings sage.plot + sage: d.plot3d(color_by_label=True) # long time # needs sage.graphs sage.plot Graphics3d Object :: - sage: F = GF(3); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: gens = [MS([[2,0], [0,1]]), MS([[2,1], [2,0]])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens) # optional - sage.rings.finite_rings - sage: G.order() # optional - sage.rings.finite_rings + sage: F = GF(3); MS = MatrixSpace(F, 2, 2) + sage: gens = [MS([[2,0], [0,1]]), MS([[2,1], [2,0]])] + sage: G = MatrixGroup(gens) + sage: G.order() 48 - sage: G.cardinality() # optional - sage.rings.finite_rings + sage: G.cardinality() 48 - sage: H = GL(2,F) # optional - sage.rings.finite_rings - sage: H.order() # optional - sage.rings.finite_rings + sage: H = GL(2,F) + sage: H.order() 48 - sage: H == G # optional - sage.rings.finite_rings + sage: H == G True - sage: H.gens() == G.gens() # optional - sage.rings.finite_rings + sage: H.gens() == G.gens() True - sage: H.as_matrix_group() == H # optional - sage.rings.finite_rings + sage: H.as_matrix_group() == H True - sage: H.gens() # optional - sage.rings.finite_rings + sage: H.gens() ( [2 0] [2 1] [0 1], [2 0] @@ -144,11 +144,11 @@ def GL(n, R, var='a'): TESTS:: - sage: groups.matrix.GL(2, 3) # optional - sage.groups sage.rings.finite_rings + sage: groups.matrix.GL(2, 3) General Linear Group of degree 2 over Finite Field of size 3 - sage: groups.matrix.GL(1, ZZ).category() # optional - sage.groups + sage: groups.matrix.GL(1, ZZ).category() Category of groups - sage: groups.matrix.GL(1, QQ).category() # optional - sage.groups + sage: groups.matrix.GL(1, QQ).category() Category of infinite groups """ degree, ring = normalize_args_vectorspace(n, R, var='a') @@ -207,15 +207,15 @@ def SL(n, R, var='a'): EXAMPLES:: - sage: SL(3, GF(2)) # optional - sage.rings.finite_rings + sage: SL(3, GF(2)) Special Linear Group of degree 3 over Finite Field of size 2 - sage: G = SL(15, GF(7)); G # optional - sage.rings.finite_rings + sage: G = SL(15, GF(7)); G Special Linear Group of degree 15 over Finite Field of size 7 - sage: G.category() # optional - sage.rings.finite_rings + sage: G.category() Category of finite groups - sage: G.order() # optional - sage.rings.finite_rings + sage: G.order() 1956712595698146962015219062429586341124018007182049478916067369638713066737882363393519966343657677430907011270206265834819092046250232049187967718149558134226774650845658791865745408000000 - sage: len(G.gens()) # optional - sage.rings.finite_rings + sage: len(G.gens()) 2 sage: G = SL(2, ZZ); G Special Linear Group of degree 2 over Integer Ring @@ -285,8 +285,8 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = SL(2, GF(5)) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings + sage: G = SL(2, GF(5)) + sage: G._check_matrix(G.an_element().matrix()) """ if self._special: if x.determinant() != 1: diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index 526c86695b0..c0c22456320 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -5,14 +5,14 @@ Loading, saving, ... works:: - sage: G = GL(2,5); G # optional - sage.rings.finite_rings + sage: G = GL(2,5); G General Linear Group of degree 2 over Finite Field of size 5 - sage: TestSuite(G).run() # optional - sage.rings.finite_rings + sage: TestSuite(G).run() - sage: g = G.1; g # optional - sage.rings.finite_rings + sage: g = G.1; g [4 1] [4 0] - sage: TestSuite(g).run() # optional - sage.rings.finite_rings + sage: TestSuite(g).run() We test that :trac:`9437` is fixed:: @@ -107,9 +107,9 @@ class MatrixGroup_base(Group): TESTS:: - sage: G = SO(3, GF(11)); G # optional - sage.rings.finite_rings + sage: G = SO(3, GF(11)); G Special Orthogonal Group of degree 3 over Finite Field of size 11 - sage: G.category() # optional - sage.rings.finite_rings + sage: G.category() Category of finite groups """ _ambient = None # internal attribute to register the ambient group in case this instance is a subgroup @@ -137,9 +137,9 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = SU(2, GF(5)); F = G.base_ring() # this is GF(5^2,'a') # optional - sage.rings.finite_rings - sage: G._check_matrix(identity_matrix(F, 2)) # optional - sage.rings.finite_rings - sage: G._check_matrix(matrix(F, [[1,1], [0,1]])) # optional - sage.rings.finite_rings + sage: G = SU(2, GF(5)); F = G.base_ring() # this is GF(5^2,'a') # needs sage.rings.finite_rings + sage: G._check_matrix(identity_matrix(F, 2)) # needs sage.rings.finite_rings + sage: G._check_matrix(matrix(F, [[1,1], [0,1]])) # needs sage.rings.finite_rings Traceback (most recent call last): ... TypeError: matrix must be unitary with respect to the hermitian form @@ -158,8 +158,8 @@ def as_matrix_group(self): EXAMPLES:: - sage: G = SU(4, GF(5)) # optional - sage.rings.finite_rings - sage: G.as_matrix_group() # optional - sage.rings.finite_rings + sage: G = SU(4, GF(5)) # needs sage.rings.finite_rings + sage: G.as_matrix_group() # needs sage.rings.finite_rings Matrix group over Finite Field in a of size 5^2 with 2 generators ( [ a 0 0 0] [ 1 0 4*a + 3 0] [ 0 2*a + 3 0 0] [ 1 0 0 0] @@ -167,8 +167,8 @@ def as_matrix_group(self): [ 0 0 0 3*a], [ 0 3*a + 1 0 0] ) - sage: G = GO(3,GF(5)) # optional - sage.rings.finite_rings - sage: G.as_matrix_group() # optional - sage.rings.finite_rings + sage: G = GO(3,GF(5)) + sage: G.as_matrix_group() Matrix group over Finite Field of size 5 with 2 generators ( [2 0 0] [0 1 0] [0 3 0] [1 4 4] @@ -191,22 +191,24 @@ def subgroup(self, generators, check=True): EXAMPLES:: - sage: UCF = UniversalCyclotomicField() # optional - sage.rings.number_field - sage: G = GL(3, UCF) # optional - sage.rings.number_field - sage: e3 = UCF.gen(3); e5 = UCF.gen(5) # optional - sage.rings.number_field - sage: m = matrix(UCF, 3,3, [[e3, 1, 0], [0, e5, 7],[4, 3, 2]]) # optional - sage.rings.number_field - sage: S = G.subgroup([m]); S # optional - sage.rings.number_field + sage: # needs sage.libs.gap sage.rings.number_field + sage: UCF = UniversalCyclotomicField() + sage: G = GL(3, UCF) + sage: e3 = UCF.gen(3); e5 = UCF.gen(5) + sage: m = matrix(UCF, 3,3, [[e3, 1, 0], [0, e5, 7],[4, 3, 2]]) + sage: S = G.subgroup([m]); S Subgroup with 1 generators ( [E(3) 1 0] [ 0 E(5) 7] [ 4 3 2] ) of General Linear Group of degree 3 over Universal Cyclotomic Field - sage: CF3 = CyclotomicField(3) # optional - sage.rings.number_field - sage: G = GL(3, CF3) # optional - sage.rings.number_field - sage: e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3,3, [[e3, 1, 0], [0, ~e3, 7],[4, 3, 2]]) # optional - sage.rings.number_field - sage: S = G.subgroup([m]); S # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3) + sage: G = GL(3, CF3) + sage: e3 = CF3.gen() + sage: m = matrix(CF3, 3,3, [[e3, 1, 0], [0, ~e3, 7],[4, 3, 2]]) + sage: S = G.subgroup([m]); S Subgroup with 1 generators ( [ zeta3 1 0] [ 0 -zeta3 - 1 7] @@ -215,8 +217,8 @@ def subgroup(self, generators, check=True): TESTS:: - sage: TestSuite(G).run() # optional - sage.rings.number_field - sage: TestSuite(S).run() # optional - sage.rings.number_field + sage: TestSuite(G).run() # needs sage.rings.number_field + sage: TestSuite(S).run() # needs sage.rings.number_field """ try: test = self.is_finite() @@ -265,10 +267,10 @@ def _repr_(self): EXAMPLES:: - sage: F = GF(5); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: gens = [MS([[1,2], [-1,1]]), MS([[1,1], [0,1]])] # optional - sage.rings.finite_rings - sage: G = MatrixGroup(gens) # optional - sage.rings.finite_rings - sage: G # optional - sage.rings.finite_rings + sage: F = GF(5); MS = MatrixSpace(F, 2, 2) + sage: gens = [MS([[1,2], [-1,1]]), MS([[1,1], [0,1]])] + sage: G = MatrixGroup(gens) + sage: G Matrix group over Finite Field of size 5 with 2 generators ( [1 2] [1 1] [4 1], [0 1] @@ -276,11 +278,12 @@ def _repr_(self): case of being a subgroup:: - sage: CF3 = CyclotomicField(3) # optional - sage.rings.number_field - sage: G = GL(2, CF3) # optional - sage.rings.number_field - sage: e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 2, 2, [[e3, 1], [0, ~e3]]) # optional - sage.rings.number_field - sage: S = G.subgroup([m]); S # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3) + sage: G = GL(2, CF3) + sage: e3 = CF3.gen() + sage: m = matrix(CF3, 2, 2, [[e3, 1], [0, ~e3]]) + sage: S = G.subgroup([m]); S Subgroup with 1 generators ( [ zeta3 1] [ 0 -zeta3 - 1] @@ -313,8 +316,8 @@ def _repr_option(self, key): EXAMPLES:: - sage: SO3 = groups.matrix.SO(3, QQ) # optional - sage.groups - sage: SO3._repr_option('element_ascii_art') # optional - sage.groups + sage: SO3 = groups.matrix.SO(3, QQ) # needs sage.groups sage.modules + sage: SO3._repr_option('element_ascii_art') # needs sage.groups sage.modules True """ if key == 'element_ascii_art': @@ -325,9 +328,9 @@ def _latex_(self): r""" EXAMPLES:: - sage: MS = MatrixSpace(GF(5), 2, 2) # optional - sage.rings.finite_rings - sage: G = MatrixGroup(MS([[1,2], [-1,1]]), MS([[1,1], [0,1]])) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: MS = MatrixSpace(GF(5), 2, 2) + sage: G = MatrixGroup(MS([[1,2], [-1,1]]), MS([[1,1], [0,1]])) + sage: latex(G) \left\langle \left(\begin{array}{rr} 1 & 2 \\ 4 & 1 @@ -355,19 +358,19 @@ def sign_representation(self, base_ring=None, side="twosided"): EXAMPLES:: sage: G = GL(2, QQ) - sage: V = G.sign_representation() # optional - sage.combinat - sage: e = G.an_element() # optional - sage.combinat - sage: e # optional - sage.combinat + sage: V = G.sign_representation() + sage: e = G.an_element() + sage: e [1 0] [0 1] - sage: V._default_sign(e) # optional - sage.combinat + sage: V._default_sign(e) 1 - sage: m2 = V.an_element() # optional - sage.combinat - sage: m2 # optional - sage.combinat + sage: m2 = V.an_element() + sage: m2 2*B['v'] - sage: m2*e # optional - sage.combinat + sage: m2*e 2*B['v'] - sage: m2*e*e # optional - sage.combinat + sage: m2*e*e 2*B['v'] """ if base_ring is None: @@ -432,7 +435,7 @@ def degree(self): EXAMPLES:: - sage: SU(5,5).degree() # optional - sage.rings.finite_rings + sage: SU(5,5).degree() # needs sage.rings.finite_rings 5 """ return self._deg @@ -447,11 +450,11 @@ def matrix_space(self): EXAMPLES:: - sage: F = GF(5); MS = MatrixSpace(F, 2, 2) # optional - sage.rings.finite_rings - sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) # optional - sage.rings.finite_rings - sage: G.matrix_space() # optional - sage.rings.finite_rings + sage: F = GF(5); MS = MatrixSpace(F, 2, 2) + sage: G = MatrixGroup([MS(1), MS([1,2,3,4])]) + sage: G.matrix_space() Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 5 - sage: G.matrix_space() is MS # optional - sage.rings.finite_rings + sage: G.matrix_space() is MS True """ return MatrixSpace(self.base_ring(), self.degree()) @@ -476,11 +479,11 @@ def __richcmp__(self, other, op): EXAMPLES:: - sage: G = GL(2,3) # optional - sage.rings.finite_rings - sage: H = MatrixGroup(G.gens()) # optional - sage.rings.finite_rings - sage: H == G # optional - sage.rings.finite_rings + sage: G = GL(2,3) + sage: H = MatrixGroup(G.gens()) + sage: H == G True - sage: G == H # optional - sage.rings.finite_rings + sage: G == H True sage: MS = MatrixSpace(QQ, 2, 2) @@ -492,11 +495,12 @@ def __richcmp__(self, other, op): TESTS:: - sage: G = groups.matrix.GL(4,2) # optional - sage.groups sage.rings.finite_rings - sage: H = MatrixGroup(G.gens()) # optional - sage.groups sage.rings.finite_rings - sage: G == H # optional - sage.groups sage.rings.finite_rings + sage: # needs sage.groups sage.rings.finite_rings + sage: G = groups.matrix.GL(4,2) + sage: H = MatrixGroup(G.gens()) + sage: G == H True - sage: G != H # optional - sage.groups sage.rings.finite_rings + sage: G != H False """ if not is_MatrixGroup(other): diff --git a/src/sage/groups/matrix_gps/matrix_group_gap.py b/src/sage/groups/matrix_gps/matrix_group_gap.py index b4c06acbd0f..9205951ccdd 100644 --- a/src/sage/groups/matrix_gps/matrix_group_gap.py +++ b/src/sage/groups/matrix_gps/matrix_group_gap.py @@ -154,8 +154,8 @@ def __iter__(self): infinite groups can be dealt with:: sage: import itertools - sage: W = WeylGroup(["A",3,1]) - sage: list(itertools.islice(W, int(4))) + sage: W = WeylGroup(["A",3,1]) # needs sage.rings.number_field + sage: list(itertools.islice(W, int(4))) # needs sage.rings.number_field [ [1 0 0 0] [-1 1 0 1] [ 1 0 0 0] [ 1 0 0 0] [0 1 0 0] [ 0 1 0 0] [ 1 -1 1 0] [ 0 1 0 0] @@ -238,6 +238,7 @@ def subgroup(self, generators, check=True): EXAMPLES:: + sage: # needs sage.rings.number_field sage: UCF = UniversalCyclotomicField() sage: G = GL(3, UCF) sage: e3 = UCF.gen(3); e5 = UCF.gen(5) @@ -249,6 +250,7 @@ def subgroup(self, generators, check=True): [ 4 3 2] ) of General Linear Group of degree 3 over Universal Cyclotomic Field + sage: # needs sage.rings.number_field sage: CF3 = CyclotomicField(3) sage: G = GL(3, CF3) sage: e3 = CF3.gen() @@ -262,15 +264,17 @@ def subgroup(self, generators, check=True): TESTS:: - sage: TestSuite(G).run() - sage: TestSuite(S).run() + sage: TestSuite(G).run() # needs sage.rings.number_field + sage: TestSuite(S).run() # needs sage.rings.number_field + sage: # needs sage.rings.number_field sage: W = CoxeterGroup(['I',7]) sage: s = W.simple_reflections() sage: G = W.subgroup([s[1]]) sage: G.category() Category of finite groups + sage: # needs sage.rings.number_field sage: W = WeylGroup(['A',2]) sage: s = W.simple_reflections() sage: G = W.subgroup([s[1]]) diff --git a/src/sage/groups/matrix_gps/named_group.py b/src/sage/groups/matrix_gps/named_group.py index 08717dd7110..4568c43d326 100644 --- a/src/sage/groups/matrix_gps/named_group.py +++ b/src/sage/groups/matrix_gps/named_group.py @@ -8,17 +8,17 @@ sage: SL(2, ZZ) Special Linear Group of degree 2 over Integer Ring - sage: G = SL(2, GF(3)); G # optional - sage.rings.finite_rings + sage: G = SL(2, GF(3)); G Special Linear Group of degree 2 over Finite Field of size 3 - sage: G.is_finite() # optional - sage.rings.finite_rings + sage: G.is_finite() True - sage: G.conjugacy_classes_representatives() # optional - sage.rings.finite_rings + sage: G.conjugacy_classes_representatives() ( [1 0] [0 2] [0 1] [2 0] [0 2] [0 1] [0 2] [0 1], [1 1], [2 1], [0 2], [1 2], [2 2], [1 0] ) - sage: G = SL(6, GF(5)) # optional - sage.rings.finite_rings - sage: G.gens() # optional - sage.rings.finite_rings + sage: G = SL(6, GF(5)) + sage: G.gens() ( [2 0 0 0 0 0] [4 0 0 0 0 1] [0 3 0 0 0 0] [4 0 0 0 0 0] @@ -83,12 +83,12 @@ def normalize_args_vectorspace(*args, **kwds): TESTS:: sage: from sage.groups.matrix_gps.named_group import normalize_args_vectorspace - sage: A = AffineSpace(2, GF(4,'a')); A # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(4,'a')); A # needs sage.rings.finite_rings Affine Space of dimension 2 over Finite Field in a of size 2^2 - sage: normalize_args_vectorspace(A) # optional - sage.rings.finite_rings + sage: normalize_args_vectorspace(A) # needs sage.rings.finite_rings (2, Finite Field in a of size 2^2) - sage: normalize_args_vectorspace(2,4) # shorthand # optional - sage.rings.finite_rings + sage: normalize_args_vectorspace(2,4) # shorthand # needs sage.rings.finite_rings (2, Finite Field in a of size 2^2) sage: V = ZZ^3; V @@ -150,12 +150,12 @@ def normalize_args_invariant_form(R, d, invariant_form): TESTS:: sage: from sage.groups.matrix_gps.named_group import normalize_args_invariant_form - sage: CF3 = CyclotomicField(3) # optional - sage.rings.number_field - sage: m = normalize_args_invariant_form(CF3, 3, (1,2,3,0,2,0,0,2,1)); m # optional - sage.rings.number_field + sage: CF3 = CyclotomicField(3) # needs sage.rings.number_field + sage: m = normalize_args_invariant_form(CF3, 3, (1,2,3,0,2,0,0,2,1)); m # needs sage.rings.number_field [1 2 3] [0 2 0] [0 2 1] - sage: m.base_ring() == CF3 # optional - sage.rings.number_field + sage: m.base_ring() == CF3 # needs sage.rings.number_field True sage: normalize_args_invariant_form(ZZ, 3, (1,2,3,0,2,0,0,2)) @@ -288,15 +288,16 @@ def __richcmp__(self, other, op): EXAMPLES:: - sage: G = GL(2,3) # optional - sage.rings.finite_rings - sage: G == MatrixGroup(G.gens()) # optional - sage.rings.finite_rings + sage: G = GL(2,3) + sage: G == MatrixGroup(G.gens()) True - sage: G = groups.matrix.GL(4,2) # optional - sage.rings.finite_rings - sage: H = MatrixGroup(G.gens()) # optional - sage.rings.finite_rings - sage: G == H # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: G = groups.matrix.GL(4,2) # needs sage.modules + sage: H = MatrixGroup(G.gens()) + sage: G == H True - sage: G != H # optional - sage.rings.finite_rings + sage: G != H False """ return MatrixGroup_generic.__richcmp__(self, other, op) diff --git a/src/sage/groups/matrix_gps/orthogonal.py b/src/sage/groups/matrix_gps/orthogonal.py index 694401d6d31..b05be536955 100644 --- a/src/sage/groups/matrix_gps/orthogonal.py +++ b/src/sage/groups/matrix_gps/orthogonal.py @@ -33,13 +33,13 @@ EXAMPLES:: - sage: GO(3,7) # optional - sage.rings.finite_rings + sage: GO(3,7) General Orthogonal Group of degree 3 over Finite Field of size 7 - sage: G = SO(4, GF(7), 1); G # optional - sage.rings.finite_rings + sage: G = SO(4, GF(7), 1); G Special Orthogonal Group of degree 4 and form parameter 1 over Finite Field of size 7 - sage: G.random_element() # random # optional - sage.rings.finite_rings + sage: G.random_element() # random [4 3 5 2] [6 6 4 0] [0 4 6 0] @@ -47,14 +47,14 @@ TESTS:: - sage: G = GO(3, GF(5)) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = GO(3, GF(5)) + sage: latex(G) \text{GO}_{3}(\Bold{F}_{5}) - sage: G = SO(3, GF(5)) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = SO(3, GF(5)) + sage: latex(G) \text{SO}_{3}(\Bold{F}_{5}) - sage: G = SO(4, GF(5), 1) # optional - sage.rings.finite_rings - sage: latex(G) # optional - sage.rings.finite_rings + sage: G = SO(4, GF(5), 1) + sage: latex(G) \text{SO}_{4}(\Bold{F}_{5}, +) AUTHORS: @@ -121,13 +121,13 @@ def normalize_args_e(degree, ring, e): TESTS:: sage: from sage.groups.matrix_gps.orthogonal import normalize_args_e - sage: normalize_args_e(2, GF(3), +1) # optional - sage.rings.finite_rings + sage: normalize_args_e(2, GF(3), +1) 1 - sage: normalize_args_e(3, GF(3), 0) # optional - sage.rings.finite_rings + sage: normalize_args_e(3, GF(3), 0) 0 - sage: normalize_args_e(3, GF(3), +1) # optional - sage.rings.finite_rings + sage: normalize_args_e(3, GF(3), +1) 0 - sage: normalize_args_e(2, GF(3), 0) # optional - sage.rings.finite_rings + sage: normalize_args_e(2, GF(3), 0) Traceback (most recent call last): ... ValueError: must have e=-1 or e=1 for even degree @@ -154,14 +154,14 @@ def _OG(n, R, special, e=0, var='a', invariant_form=None): Check that :trac:`26028` is fixed:: - sage: GO(3,25).order() # indirect doctest # optional - sage.rings.finite_rings + sage: GO(3,25).order() # indirect doctest # needs sage.rings.finite_rings 31200 Check that :trac:`28054` is fixed:: - sage: G = SO(2, GF(3), -1) # optional - sage.rings.finite_rings - sage: m = G.invariant_form() # optional - sage.rings.finite_rings - sage: G2 = SO(2, GF(3), 1, invariant_form=m) # optional - sage.rings.finite_rings + sage: G = SO(2, GF(3), -1) + sage: m = G.invariant_form() + sage: G2 = SO(2, GF(3), 1, invariant_form=m) Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -268,11 +268,11 @@ def GO(n, R, e=0, var='a', invariant_form=None): EXAMPLES:: - sage: GO(3, GF(7)) # optional - sage.rings.finite_rings + sage: GO(3, GF(7)) General Orthogonal Group of degree 3 over Finite Field of size 7 - sage: GO(3, GF(7)).order() # optional - sage.rings.finite_rings + sage: GO(3, GF(7)).order() 672 - sage: GO(3, GF(7)).gens() # optional - sage.rings.finite_rings + sage: GO(3, GF(7)).gens() ( [3 0 0] [0 1 0] [0 5 0] [1 6 6] @@ -294,13 +294,13 @@ def GO(n, R, e=0, var='a', invariant_form=None): [0 1 0] [1 0 0] [0 0 3] - sage: pm = Permutation([2,3,1]).to_matrix() # optional - sage.combinat - sage: g = GO3(pm); g in GO3; g # optional - sage.combinat + sage: pm = Permutation([2,3,1]).to_matrix() + sage: g = GO3(pm); g in GO3; g True [0 0 1] [1 0 0] [0 1 0] - sage: GO3m(pm) # optional - sage.combinat + sage: GO3m(pm) Traceback (most recent call last): ... TypeError: matrix must be orthogonal with respect to the symmetric form @@ -375,19 +375,18 @@ def SO(n, R, e=None, var='a', invariant_form=None): EXAMPLES:: - sage: G = SO(3,GF(5)) # optional - sage.rings.finite_rings - sage: G # optional - sage.rings.finite_rings + sage: G = SO(3,GF(5)); G Special Orthogonal Group of degree 3 over Finite Field of size 5 - sage: G = SO(3,GF(5)) # optional - sage.rings.finite_rings - sage: G.gens() # optional - sage.rings.finite_rings + sage: G = SO(3,GF(5)) + sage: G.gens() ( [2 0 0] [3 2 3] [1 4 4] [0 3 0] [0 2 0] [4 0 0] [0 0 1], [0 3 1], [2 0 4] ) - sage: G = SO(3,GF(5)) # optional - sage.rings.finite_rings - sage: G.as_matrix_group() # optional - sage.rings.finite_rings + sage: G = SO(3,GF(5)) + sage: G.as_matrix_group() Matrix group over Finite Field of size 5 with 3 generators ( [2 0 0] [3 2 3] [1 4 4] [0 3 0] [0 2 0] [4 0 0] @@ -396,27 +395,28 @@ def SO(n, R, e=None, var='a', invariant_form=None): Using the ``invariant_form`` option:: - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3,2,0], [0,0,1]]) # optional - sage.rings.number_field - sage: SO3 = SO(3, CF3) # optional - sage.rings.number_field - sage: SO3m = SO(3, CF3, invariant_form=m) # optional - sage.rings.number_field - sage: SO3 == SO3m # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3,2,0], [0,0,1]]) + sage: SO3 = SO(3, CF3) + sage: SO3m = SO(3, CF3, invariant_form=m) + sage: SO3 == SO3m False - sage: SO3.invariant_form() # optional - sage.rings.number_field + sage: SO3.invariant_form() [1 0 0] [0 1 0] [0 0 1] - sage: SO3m.invariant_form() # optional - sage.rings.number_field + sage: SO3m.invariant_form() [ 1 zeta3 0] [zeta3 2 0] [ 0 0 1] - sage: pm = Permutation([2,3,1]).to_matrix() # optional - sage.combinat - sage: g = SO3(pm); g in SO3; g # optional - sage.combinat sage.rings.number_field + sage: pm = Permutation([2,3,1]).to_matrix() + sage: g = SO3(pm); g in SO3; g True [0 0 1] [1 0 0] [0 1 0] - sage: SO3m(pm) # optional - sage.combinat sage.rings.number_field + sage: SO3m(pm) Traceback (most recent call last): ... TypeError: matrix must be orthogonal with respect to the symmetric form @@ -424,7 +424,7 @@ def SO(n, R, e=None, var='a', invariant_form=None): [zeta3 2 0] [ 0 0 1] - sage: SO(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) # optional - sage.combinat sage.rings.number_field + sage: SO(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -433,8 +433,8 @@ def SO(n, R, e=None, var='a', invariant_form=None): TESTS:: - sage: TestSuite(SO3m).run() # optional - sage.rings.number_field - sage: groups.matrix.SO(2, 3, e=1) # optional - sage.rings.number_field + sage: TestSuite(SO3m).run() # needs sage.rings.number_field + sage: groups.matrix.SO(2, 3, e=1) Special Orthogonal Group of degree 2 and form parameter 1 over Finite Field of size 3 """ return _OG(n, R, True, e=e, var=var, invariant_form=invariant_form) @@ -450,20 +450,21 @@ class OrthogonalMatrixGroup_generic(NamedMatrixGroup_generic): EXAMPLES:: - sage: G = GO(3, GF(7)); G # optional - sage.rings.finite_rings + sage: G = GO(3, GF(7)); G General Orthogonal Group of degree 3 over Finite Field of size 7 - sage: latex(G) # optional - sage.rings.finite_rings + sage: latex(G) \text{GO}_{3}(\Bold{F}_{7}) - sage: G = SO(3, GF(5)); G # optional - sage.rings.finite_rings + sage: G = SO(3, GF(5)); G Special Orthogonal Group of degree 3 over Finite Field of size 5 - sage: latex(G) # optional - sage.rings.finite_rings + sage: latex(G) \text{SO}_{3}(\Bold{F}_{5}) - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3,3, [[1,e3,0],[e3,2,0],[0,0,1]]) # optional - sage.rings.number_field - sage: G = SO(3, CF3, invariant_form=m) # optional - sage.rings.number_field - sage: latex(G) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() + sage: m = matrix(CF3, 3,3, [[1,e3,0],[e3,2,0],[0,0,1]]) + sage: G = SO(3, CF3, invariant_form=m) + sage: latex(G) \text{SO}_{3}(\Bold{Q}(\zeta_{3}))\text{ with respect to non positive definite symmetric form }\left(\begin{array}{rrr} 1 & \zeta_{3} & 0 \\ \zeta_{3} & 2 & 0 \\ @@ -482,10 +483,10 @@ def invariant_bilinear_form(self): EXAMPLES:: - sage: GO(2,3,+1).invariant_bilinear_form() # optional - sage.rings.finite_rings + sage: GO(2,3,+1).invariant_bilinear_form() [0 1] [1 0] - sage: GO(2,3,-1).invariant_bilinear_form() # optional - sage.rings.finite_rings + sage: GO(2,3,-1).invariant_bilinear_form() [2 1] [1 1] sage: G = GO(4, QQ) @@ -527,8 +528,8 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = GO(4, GF(5), +1) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings + sage: G = GO(4, GF(5), +1) + sage: G._check_matrix(G.an_element().matrix()) """ if self._special and x.determinant() != 1: raise TypeError('matrix must have determinant one') diff --git a/src/sage/groups/matrix_gps/symplectic.py b/src/sage/groups/matrix_gps/symplectic.py index aad18def93b..3a7e7258fe9 100644 --- a/src/sage/groups/matrix_gps/symplectic.py +++ b/src/sage/groups/matrix_gps/symplectic.py @@ -3,17 +3,17 @@ EXAMPLES:: - sage: G = Sp(4, GF(7)); G # optional - sage.rings.finite_rings + sage: G = Sp(4, GF(7)); G Symplectic Group of degree 4 over Finite Field of size 7 - sage: g = prod(G.gens()); g # optional - sage.rings.finite_rings + sage: g = prod(G.gens()); g [3 0 3 0] [1 0 0 0] [0 1 0 1] [0 2 0 0] - sage: m = g.matrix() # optional - sage.rings.finite_rings - sage: m * G.invariant_form() * m.transpose() == G.invariant_form() # optional - sage.rings.finite_rings + sage: m = g.matrix() + sage: m * G.invariant_form() * m.transpose() == G.invariant_form() True - sage: G.order() # optional - sage.rings.finite_rings + sage: G.order() 276595200 AUTHORS: @@ -82,13 +82,13 @@ def Sp(n, R, var='a', invariant_form=None): EXAMPLES:: - sage: Sp(4, 5) # optional - sage.rings.finite_rings + sage: Sp(4, 5) Symplectic Group of degree 4 over Finite Field of size 5 sage: Sp(4, IntegerModRing(15)) Symplectic Group of degree 4 over Ring of integers modulo 15 - sage: Sp(3, GF(7)) # optional - sage.rings.finite_rings + sage: Sp(3, GF(7)) Traceback (most recent call last): ... ValueError: the degree must be even @@ -110,14 +110,14 @@ def Sp(n, R, var='a', invariant_form=None): [ 0 0 0 2] [-1 0 0 0] [ 0 -2 0 0] - sage: pm = Permutation([2,1,4,3]).to_matrix() # optional - sage.combinat - sage: g = Sp4(pm); g in Sp4; g # optional - sage.combinat + sage: pm = Permutation([2,1,4,3]).to_matrix() + sage: g = Sp4(pm); g in Sp4; g True [0 1 0 0] [1 0 0 0] [0 0 0 1] [0 0 1 0] - sage: Sp4m(pm) # optional - sage.combinat + sage: Sp4m(pm) Traceback (most recent call last): ... TypeError: matrix must be symplectic with respect to the alternating form @@ -126,7 +126,7 @@ def Sp(n, R, var='a', invariant_form=None): [-1 0 0 0] [ 0 -2 0 0] - sage: Sp(4,3, invariant_form=[[0,0,0,1],[0,0,1,0],[0,2,0,0], [2,0,0,0]]) # optional - sage.rings.finite_rings + sage: Sp(4,3, invariant_form=[[0,0,0,1],[0,0,1,0],[0,2,0,0], [2,0,0,0]]) Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -135,11 +135,11 @@ def Sp(n, R, var='a', invariant_form=None): sage: TestSuite(Sp4).run() sage: TestSuite(Sp4m).run() - sage: groups.matrix.Sp(2, 3) # optional - sage.rings.finite_rings + sage: groups.matrix.Sp(2, 3) # needs sage.modules sage.rings.finite_rings Symplectic Group of degree 2 over Finite Field of size 3 - sage: G = Sp(4,5) # optional - sage.rings.finite_rings - sage: TestSuite(G).run() # optional - sage.rings.finite_rings + sage: G = Sp(4,5) + sage: TestSuite(G).run() """ degree, ring = normalize_args_vectorspace(n, R, var=var) if degree % 2: @@ -181,9 +181,9 @@ class SymplecticMatrixGroup_generic(NamedMatrixGroup_generic): EXAMPLES:: - sage: Sp43 = Sp(4,3); Sp43 # optional - sage.rings.finite_rings + sage: Sp43 = Sp(4,3); Sp43 Symplectic Group of degree 4 over Finite Field of size 3 - sage: latex(Sp43) # optional - sage.rings.finite_rings + sage: latex(Sp43) \text{Sp}_{4}(\Bold{F}_{3}) sage: Sp4m = Sp(4, QQ, invariant_form=(0, 0, 1, 0, 0, 0, 0, 2, @@ -239,8 +239,8 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = Sp(4, GF(5)) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings + sage: G = Sp(4, GF(5)) + sage: G._check_matrix(G.an_element().matrix()) """ F = self.invariant_form() if x * F * x.transpose() != F: diff --git a/src/sage/groups/matrix_gps/symplectic_gap.py b/src/sage/groups/matrix_gps/symplectic_gap.py index adeefea218f..96bf1fb5a75 100644 --- a/src/sage/groups/matrix_gps/symplectic_gap.py +++ b/src/sage/groups/matrix_gps/symplectic_gap.py @@ -27,7 +27,7 @@ class SymplecticMatrixGroup_gap(SymplecticMatrixGroup_generic, NamedMatrixGroup_ EXAMPLES:: - sage: Sp(2,4) + sage: Sp(2,4) # needs sage.rings.finite_rings Symplectic Group of degree 2 over Finite Field in a of size 2^2 sage: latex(Sp(4,5)) diff --git a/src/sage/groups/matrix_gps/unitary.py b/src/sage/groups/matrix_gps/unitary.py index 8d8a4d23491..22dd25b1a4b 100644 --- a/src/sage/groups/matrix_gps/unitary.py +++ b/src/sage/groups/matrix_gps/unitary.py @@ -6,18 +6,19 @@ EXAMPLES:: - sage: G = SU(3,5) # optional - sage.rings.finite_rings - sage: G.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: G = SU(3,5) + sage: G.order() 378000 - sage: G # optional - sage.rings.finite_rings + sage: G Special Unitary Group of degree 3 over Finite Field in a of size 5^2 - sage: G.gens() # optional - sage.rings.finite_rings + sage: G.gens() ( [ a 0 0] [4*a 4 1] [ 0 2*a + 2 0] [ 4 4 0] [ 0 0 3*a], [ 1 0 0] ) - sage: G.base_ring() # optional - sage.rings.finite_rings + sage: G.base_ring() Finite Field in a of size 5^2 AUTHORS: @@ -76,7 +77,7 @@ def finite_field_sqrt(ring): EXAMPLES:: sage: from sage.groups.matrix_gps.unitary import finite_field_sqrt - sage: finite_field_sqrt(GF(4, 'a')) # optional - sage.rings.finite_rings + sage: finite_field_sqrt(GF(4, 'a')) # needs sage.rings.finite_rings 2 """ if not isinstance(ring, FiniteField): @@ -99,7 +100,7 @@ def _UG(n, R, special, var='a', invariant_form=None): TESTS:: - sage: GU(3,25).order() # indirect doctest # optional - sage.rings.finite_rings + sage: GU(3,25).order() # indirect doctest # needs sage.rings.finite_rings 3961191000000 """ prefix = 'General' @@ -192,9 +193,9 @@ def GU(n, R, var='a', invariant_form=None): EXAMPLES:: - sage: G = GU(3, 7); G # optional - sage.rings.finite_rings + sage: G = GU(3, 7); G # needs sage.rings.finite_rings General Unitary Group of degree 3 over Finite Field in a of size 7^2 - sage: G.gens() # optional - sage.rings.finite_rings + sage: G.gens() # needs sage.rings.finite_rings ( [ a 0 0] [6*a 6 1] [ 0 1 0] [ 6 6 0] @@ -203,10 +204,10 @@ def GU(n, R, var='a', invariant_form=None): sage: GU(2, QQ) General Unitary Group of degree 2 over Rational Field - sage: G = GU(3, 5, var='beta') # optional - sage.rings.finite_rings - sage: G.base_ring() # optional - sage.rings.finite_rings + sage: G = GU(3, 5, var='beta') # needs sage.rings.finite_rings + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in beta of size 5^2 - sage: G.gens() # optional - sage.rings.finite_rings + sage: G.gens() # needs sage.rings.finite_rings ( [ beta 0 0] [4*beta 4 1] [ 0 1 0] [ 4 4 0] @@ -215,27 +216,28 @@ def GU(n, R, var='a', invariant_form=None): Using the ``invariant_form`` option:: - sage: UCF = UniversalCyclotomicField(); e5 = UCF.gen(5) # optional - sage.rings.number_field - sage: m = matrix(UCF, 3, 3, [[1,e5,0], [e5.conjugate(),2,0], [0,0,1]]) # optional - sage.rings.number_field - sage: G = GU(3, UCF) # optional - sage.rings.number_field - sage: Gm = GU(3, UCF, invariant_form=m) # optional - sage.rings.number_field - sage: G == Gm # optional - sage.rings.number_field + sage: # needs sage.libs.gap sage.rings.number_field + sage: UCF = UniversalCyclotomicField(); e5 = UCF.gen(5) + sage: m = matrix(UCF, 3, 3, [[1,e5,0], [e5.conjugate(),2,0], [0,0,1]]) + sage: G = GU(3, UCF) + sage: Gm = GU(3, UCF, invariant_form=m) + sage: G == Gm False - sage: G.invariant_form() # optional - sage.rings.number_field + sage: G.invariant_form() [1 0 0] [0 1 0] [0 0 1] - sage: Gm.invariant_form() # optional - sage.rings.number_field + sage: Gm.invariant_form() [ 1 E(5) 0] [E(5)^4 2 0] [ 0 0 1] - sage: pm = Permutation((1,2,3)).to_matrix() # optional - sage.combinat sage.rings.number_field - sage: g = G(pm); g in G; g # optional - sage.combinat sage.rings.number_field + sage: pm = Permutation((1,2,3)).to_matrix() + sage: g = G(pm); g in G; g # needs sage.combinat True [0 0 1] [1 0 0] [0 1 0] - sage: Gm(pm) # optional - sage.combinat sage.rings.number_field + sage: Gm(pm) # needs sage.combinat Traceback (most recent call last): ... TypeError: matrix must be unitary with respect to the hermitian form @@ -243,7 +245,7 @@ def GU(n, R, var='a', invariant_form=None): [E(5)^4 2 0] [ 0 0 1] - sage: GU(3, 3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) # optional - sage.rings.number_field + sage: GU(3, 3, invariant_form=[[1,0,0], [0,2,0], [0,0,1]]) # needs sage.libs.pari Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP @@ -255,8 +257,8 @@ def GU(n, R, var='a', invariant_form=None): TESTS:: - sage: TestSuite(G).run() # optional - sage.rings.number_field - sage: groups.matrix.GU(2, 3) # optional - sage.groups sage.rings.finite_rings + sage: TestSuite(G).run() # needs sage.libs.gap sage.rings.number_field + sage: groups.matrix.GU(2, 3) # needs sage.groups sage.rings.finite_rings General Unitary Group of degree 2 over Finite Field in a of size 3^2 """ return _UG(n, R, False, var=var, invariant_form=invariant_form) @@ -305,35 +307,36 @@ def SU(n, R, var='a', invariant_form=None): EXAMPLES:: - sage: SU(3,5) # optional - sage.rings.finite_rings + sage: SU(3,5) # needs sage.rings.finite_rings Special Unitary Group of degree 3 over Finite Field in a of size 5^2 - sage: SU(3, GF(5)) # optional - sage.rings.finite_rings + sage: SU(3, GF(5)) # needs sage.rings.finite_rings Special Unitary Group of degree 3 over Finite Field in a of size 5^2 sage: SU(3, QQ) Special Unitary Group of degree 3 over Rational Field Using the ``invariant_form`` option:: - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) # optional - sage.rings.number_field - sage: G = SU(3, CF3) # optional - sage.rings.number_field - sage: Gm = SU(3, CF3, invariant_form=m) # optional - sage.rings.number_field - sage: G == Gm # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) + sage: G = SU(3, CF3) + sage: Gm = SU(3, CF3, invariant_form=m) + sage: G == Gm False - sage: G.invariant_form() # optional - sage.rings.number_field + sage: G.invariant_form() [1 0 0] [0 1 0] [0 0 1] - sage: Gm.invariant_form() # optional - sage.rings.number_field + sage: Gm.invariant_form() [ 1 zeta3 0] [-zeta3 - 1 2 0] [ 0 0 1] - sage: pm = Permutation((1,2,3)).to_matrix() # optional - sage.combinat sage.rings.number_field - sage: G(pm) # optional - sage.combinat sage.rings.number_field + sage: pm = Permutation((1,2,3)).to_matrix() + sage: G(pm) # needs sage.combinat [0 0 1] [1 0 0] [0 1 0] - sage: Gm(pm) # optional - sage.combinat sage.rings.number_field + sage: Gm(pm) # needs sage.combinat Traceback (most recent call last): ... TypeError: matrix must be unitary with respect to the hermitian form @@ -341,15 +344,15 @@ def SU(n, R, var='a', invariant_form=None): [-zeta3 - 1 2 0] [ 0 0 1] - sage: SU(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) # optional - sage.rings.finite_rings + sage: SU(3, 5, invariant_form=[[1,0,0], [0,2,0], [0,0,3]]) # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: invariant_form for finite groups is fixed by GAP TESTS:: - sage: TestSuite(Gm).run() # optional - sage.rings.number_field - sage: groups.matrix.SU(2, 3) # optional - sage.rings.finite_rings + sage: TestSuite(Gm).run() # needs sage.rings.number_field + sage: groups.matrix.SU(2, 3) # needs sage.modules sage.rings.finite_rings Special Unitary Group of degree 2 over Finite Field in a of size 3^2 """ return _UG(n, R, True, var=var, invariant_form=invariant_form) @@ -365,20 +368,21 @@ class UnitaryMatrixGroup_generic(NamedMatrixGroup_generic): EXAMPLES:: - sage: G = GU(3, GF(7)); G # optional - sage.rings.finite_rings + sage: G = GU(3, GF(7)); G # needs sage.rings.finite_rings General Unitary Group of degree 3 over Finite Field in a of size 7^2 - sage: latex(G) # optional - sage.rings.finite_rings + sage: latex(G) # needs sage.rings.finite_rings \text{GU}_{3}(\Bold{F}_{7^{2}}) - sage: G = SU(3, GF(5)); G # optional - sage.rings.finite_rings + sage: G = SU(3, GF(5)); G # needs sage.rings.finite_rings Special Unitary Group of degree 3 over Finite Field in a of size 5^2 - sage: latex(G) # optional - sage.rings.finite_rings + sage: latex(G) # needs sage.rings.finite_rings \text{SU}_{3}(\Bold{F}_{5^{2}}) - sage: CF3 = CyclotomicField(3); e3 = CF3.gen() # optional - sage.rings.number_field - sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) # optional - sage.rings.number_field - sage: G = SU(3, CF3, invariant_form=m) # optional - sage.rings.number_field - sage: latex(G) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF3 = CyclotomicField(3); e3 = CF3.gen() + sage: m = matrix(CF3, 3, 3, [[1,e3,0], [e3.conjugate(),2,0], [0,0,1]]) + sage: G = SU(3, CF3, invariant_form=m) + sage: latex(G) \text{SU}_{3}(\Bold{Q}(\zeta_{3}))\text{ with respect to positive definite hermitian form }\left(\begin{array}{rrr} 1 & \zeta_{3} & 0 \\ -\zeta_{3} - 1 & 2 & 0 \\ @@ -420,10 +424,11 @@ def _check_matrix(self, x, *args): EXAMPLES:: - sage: G = GU(2, GF(5)) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings - sage: G = SU(2, GF(5)) # optional - sage.rings.finite_rings - sage: G._check_matrix(G.an_element().matrix()) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: G = GU(2, GF(5)) + sage: G._check_matrix(G.an_element().matrix()) + sage: G = SU(2, GF(5)) + sage: G._check_matrix(G.an_element().matrix()) """ if self._special and x.determinant() != 1: raise TypeError('matrix must have determinant one') diff --git a/src/sage/groups/matrix_gps/unitary_gap.py b/src/sage/groups/matrix_gps/unitary_gap.py index 02b0456decb..0aa547f32e2 100644 --- a/src/sage/groups/matrix_gps/unitary_gap.py +++ b/src/sage/groups/matrix_gps/unitary_gap.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings r""" Unitary Groups `GU(n,q)` and `SU(n,q)` with GAP """ diff --git a/src/sage/groups/misc_gps/argument_groups.py b/src/sage/groups/misc_gps/argument_groups.py index d6128ee7fdb..1c949a57f51 100644 --- a/src/sage/groups/misc_gps/argument_groups.py +++ b/src/sage/groups/misc_gps/argument_groups.py @@ -191,13 +191,13 @@ def _eq_(self, other): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(I) == C(I) + sage: C(I) == C(I) # needs sage.symbolic True As we do not have normalization in :class:`ArgumentByElement`, then following, although equal, is not equal:: - sage: C(I) == C(2*I) + sage: C(I) == C(2*I) # needs sage.symbolic False """ return self._element_ == other._element_ @@ -256,12 +256,12 @@ def _act_on_(self, other, is_left): :: sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup - sage: C = ArgumentByElementGroup(SR) - sage: C(-1) * 4 + sage: C = ArgumentByElementGroup(SR) # needs sage.symbolic + sage: C(-1) * 4 # needs sage.symbolic -4 sage: _.parent() Symbolic Ring - sage: 4 * C(-1) + sage: 4 * C(-1) # needs sage.symbolic -4 sage: _.parent() Symbolic Ring @@ -704,10 +704,10 @@ def _element_constructor_(self, data, exponent=None, **kwds): sage: U(exponent=1/3) zeta3 - sage: C. = CyclotomicField(6) - sage: z, U(z) + sage: C. = CyclotomicField(6) # needs sage.rings.number_field + sage: z, U(z) # needs sage.rings.number_field (z, zeta6) - sage: z^2, U(z^2) + sage: z^2, U(z^2) # needs sage.rings.number_field (z - 1, zeta3) sage: U(ZZ(-1)) @@ -805,12 +805,12 @@ def _create_element_in_extension_(self, exponent): sage: from sage.groups.misc_gps.argument_groups import UnitCircleGroup, RootsOfUnityGroup sage: C = UnitCircleGroup(QQ) - sage: C._create_element_in_extension_(2.12).parent() + sage: C._create_element_in_extension_(2.12).parent() # needs sage.rings.number_field Unit Circle Group with Exponents in Real Field with 53 bits of precision modulo ZZ sage: U = RootsOfUnityGroup() - sage: U._create_element_in_extension_(2.12).parent() + sage: U._create_element_in_extension_(2.12).parent() # needs sage.rings.number_field Unit Circle Group with Exponents in Real Field with 53 bits of precision modulo ZZ """ @@ -1070,7 +1070,7 @@ def __init__(self, parent, element, normalize=True): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(1+2*I) # indirect doctest + sage: C(1+2*I) # indirect doctest # needs sage.symbolic e^(I*arg(1.00000000000000 + 2.00000000000000*I)) """ super().__init__(parent, element, normalize=normalize) @@ -1108,7 +1108,7 @@ def _repr_(self): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(2+3*I) # indirect doctest + sage: C(2+3*I) # indirect doctest # needs sage.symbolic e^(I*arg(2.00000000000000 + 3.00000000000000*I)) """ return 'e^(I*arg({}))'.format(self._element_) @@ -1131,7 +1131,7 @@ def _symbolic_(self, R=None): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(ZZ) - sage: C(-2)._symbolic_() + sage: C(-2)._symbolic_() # needs sage.symbolic -1 sage: _.parent() Symbolic Ring @@ -1153,7 +1153,7 @@ def _mul_(self, other): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(I) * C(1 + I) # indirect doctest + sage: C(I) * C(1 + I) # indirect doctest # needs sage.symbolic e^(I*arg(-1.00000000000000 + 1.00000000000000*I)) """ P = self.parent() @@ -1168,12 +1168,12 @@ def __pow__(self, exponent): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(I)^5 # indirect doctest + sage: C(I)^5 # indirect doctest # needs sage.symbolic e^(I*arg(1.00000000000000*I)) sage: _.parent() Unit Circle Group with Argument of Elements in Complex Field with 53 bits of precision - sage: C(1+I)^3 # indirect doctest + sage: C(1+I)^3 # indirect doctest # needs sage.symbolic e^(I*arg(-2.00000000000000 + 2.00000000000000*I)) sage: _.parent() Unit Circle Group with Argument of Elements in @@ -1208,7 +1208,7 @@ def __invert__(self): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: ~C(I) # indirect doctest + sage: ~C(I) # indirect doctest # needs sage.symbolic e^(I*arg(-1.00000000000000*I)) """ P = self.parent() @@ -1233,7 +1233,7 @@ class ArgumentByElementGroup(AbstractArgumentGroup): sage: C = ArgumentByElementGroup(CC); C Unit Circle Group with Argument of Elements in Complex Field with 53 bits of precision - sage: C(1 + 2*I) + sage: C(1 + 2*I) # needs sage.symbolic e^(I*arg(1.00000000000000 + 2.00000000000000*I)) """ @@ -1283,7 +1283,7 @@ def _element_constructor_(self, data, **kwds): sage: from sage.groups.misc_gps.argument_groups import ArgumentByElementGroup sage: C = ArgumentByElementGroup(CC) - sage: C(1 + 2*I) # indirect doctest + sage: C(1 + 2*I) # indirect doctest # needs sage.symbolic e^(I*arg(1.00000000000000 + 2.00000000000000*I)) sage: C(1) e^(I*arg(1.00000000000000)) @@ -1545,7 +1545,7 @@ def _act_on_(self, other, is_left): -4.00000000000000 sage: _.parent() Complex Field with 53 bits of precision - sage: S(-1) * SR.var('x') + sage: S(-1) * SR.var('x') # needs sage.symbolic -x sage: _.parent() Symbolic Ring @@ -1760,9 +1760,10 @@ class ArgumentGroupFactory(UniqueFactory): sage: from sage.groups.misc_gps.argument_groups import ArgumentGroup - sage: ArgumentGroup('UU') + sage: ArgumentGroup('UU') # needs sage.rings.number_field Group of Roots of Unity + sage: # needs sage.rings.number_field sage: ArgumentGroup(ZZ) Sign Group sage: ArgumentGroup(QQ) @@ -1772,19 +1773,19 @@ class ArgumentGroupFactory(UniqueFactory): sage: ArgumentGroup(AA) Sign Group - sage: ArgumentGroup(RR) + sage: ArgumentGroup(RR) # needs sage.rings.number_field Sign Group - sage: ArgumentGroup('Arg_RR') + sage: ArgumentGroup('Arg_RR') # needs sage.rings.number_field Sign Group - sage: ArgumentGroup(RIF) + sage: ArgumentGroup(RIF) # needs sage.rings.real_interval_field Sign Group sage: ArgumentGroup(RBF) Sign Group - sage: ArgumentGroup(CC) + sage: ArgumentGroup(CC) # needs sage.rings.number_field Unit Circle Group with Exponents in Real Field with 53 bits of precision modulo ZZ - sage: ArgumentGroup('Arg_CC') + sage: ArgumentGroup('Arg_CC') # needs sage.rings.number_field Unit Circle Group with Exponents in Real Field with 53 bits of precision modulo ZZ sage: ArgumentGroup(CIF) @@ -1794,7 +1795,7 @@ class ArgumentGroupFactory(UniqueFactory): Unit Circle Group with Exponents in Real ball field with 53 bits of precision modulo ZZ - sage: ArgumentGroup(CyclotomicField(3)) + sage: ArgumentGroup(CyclotomicField(3)) # needs sage.rings.number_field Unit Circle Group with Argument of Elements in Cyclotomic Field of order 3 and degree 2 """ @@ -1813,6 +1814,7 @@ def create_key_and_extra_args(self, sage: from sage.groups.misc_gps.argument_groups import ArgumentGroup + sage: # needs sage.rings.number_field sage: ArgumentGroup(specification='UU') Group of Roots of Unity sage: ArgumentGroup('UU') is ArgumentGroup(exponents=QQ) # indirect doctest @@ -1887,7 +1889,7 @@ def create_object(self, version, key, **kwds): TESTS:: sage: from sage.groups.misc_gps.argument_groups import ArgumentGroup - sage: ArgumentGroup('UU') # indirect doctest + sage: ArgumentGroup('UU') # indirect doctest # needs sage.rings.number_field Group of Roots of Unity """ cls, args = key diff --git a/src/sage/groups/misc_gps/imaginary_groups.py b/src/sage/groups/misc_gps/imaginary_groups.py index ff2d34ddade..41fe79f9959 100644 --- a/src/sage/groups/misc_gps/imaginary_groups.py +++ b/src/sage/groups/misc_gps/imaginary_groups.py @@ -81,9 +81,9 @@ def imag(self): sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup sage: J = ImaginaryGroup(ZZ) - sage: J(I).imag() + sage: J(I).imag() # needs sage.symbolic 1 - sage: imag_part(J(I)) # indirect doctest + sage: imag_part(J(I)) # indirect doctest # needs sage.symbolic 1 """ return self._imag_ @@ -96,9 +96,9 @@ def real(self): sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup sage: J = ImaginaryGroup(ZZ) - sage: J(I).real() + sage: J(I).real() # needs sage.symbolic 0 - sage: real_part(J(I)) # indirect doctest + sage: real_part(J(I)) # indirect doctest # needs sage.symbolic 0 """ return self.parent().base().zero() @@ -111,7 +111,7 @@ def __hash__(self): sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup sage: J = ImaginaryGroup(ZZ) - sage: hash(J(I)) # indirect doctest, random + sage: hash(J(I)) # indirect doctest, random # needs sage.symbolic 42 """ return hash((self.parent(), self._imag_)) @@ -247,9 +247,9 @@ class ImaginaryGroup(UniqueRepresentation, Parent): 0 sage: J(imag=100) 100*I - sage: J(3*I) + sage: J(3*I) # needs sage.symbolic 3*I - sage: J(1+2*I) + sage: J(1 + 2*I) # needs sage.symbolic Traceback (most recent call last): ... ValueError: 2*I + 1 is not in @@ -393,6 +393,7 @@ def _element_constructor_(self, data, imag=None): sage: J(imag=100) 100*I + sage: # needs sage.symbolic sage: J(3*I) 3*I sage: J(1+2*I) diff --git a/src/sage/groups/old.pyx b/src/sage/groups/old.pyx index 92b69af07db..761034cff65 100644 --- a/src/sage/groups/old.pyx +++ b/src/sage/groups/old.pyx @@ -47,6 +47,7 @@ cdef class Group(sage.structure.parent.Parent): Check for :trac:`8119`:: + sage: # needs sage.groups sage: G = SymmetricGroup(2) sage: h = hash(G) sage: G.rename('S2') @@ -120,7 +121,7 @@ cdef class Group(sage.structure.parent.Parent): EXAMPLES:: - sage: SL(2, 7).is_commutative() + sage: SL(2, 7).is_commutative() # needs sage.libs.gap sage.modules False """ return self.is_abelian() diff --git a/src/sage/groups/pari_group.py b/src/sage/groups/pari_group.py index c54cd4885df..bbcb1c0a6c9 100644 --- a/src/sage/groups/pari_group.py +++ b/src/sage/groups/pari_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari r""" PARI Groups diff --git a/src/sage/groups/perm_gps/constructor.py b/src/sage/groups/perm_gps/constructor.py index 73dc5f94c41..5a130eb19be 100644 --- a/src/sage/groups/perm_gps/constructor.py +++ b/src/sage/groups/perm_gps/constructor.py @@ -23,10 +23,15 @@ from sage.misc.sage_eval import sage_eval from sage.misc.lazy_import import lazy_import from sage.interfaces.gap import GapElement -from sage.libs.pari.all import pari_gen from sage.libs.gap.element import GapElement_Permutation + lazy_import('sage.combinat.permutation', ['Permutation', 'from_cycles']) +try: + from sage.libs.pari.all import pari_gen +except ImportError: + pari_gen = () + def PermutationGroupElement(g, parent=None, check=True): r""" @@ -156,8 +161,8 @@ def standardize_generator(g, convert_dict=None, as_cycles=False): INPUT: - - ``g`` -- a list, tuple, string, GapElement, - PermutationGroupElement, Permutation + - ``g`` -- a :class:`list`, :class:`tuple`, :class:`string`, :class:`GapElement`, + :class:`PermutationGroupElement`, or :class:`Permutation` - ``convert_dict`` -- (optional) a dictionary used to convert the points to a number compatible with GAP diff --git a/src/sage/groups/perm_gps/cubegroup.py b/src/sage/groups/perm_gps/cubegroup.py index c27ed7521dd..128d3beb480 100644 --- a/src/sage/groups/perm_gps/cubegroup.py +++ b/src/sage/groups/perm_gps/cubegroup.py @@ -191,7 +191,8 @@ def polygon_plot3d(points, tilt=30, turn=30, **kwargs): EXAMPLES:: sage: from sage.groups.perm_gps.cubegroup import polygon_plot3d,green - sage: P = polygon_plot3d([[1,3,1],[2,3,1],[2,3,2],[1,3,2],[1,3,1]],rgbcolor=green) + sage: P = polygon_plot3d([[1,3,1],[2,3,1],[2,3,2],[1,3,2],[1,3,1]], # needs sage.plot + ....: rgbcolor=green) """ rot = rotation_list(tilt, turn) points2 = [(xproj(x, y, z, rot), yproj(x, y, z, rot)) @@ -288,7 +289,7 @@ def create_poly(face, color): EXAMPLES:: sage: from sage.groups.perm_gps.cubegroup import create_poly, red - sage: create_poly('ur', red) + sage: create_poly('ur', red) # needs sage.plot Graphics object consisting of 1 graphics primitive """ return polygon(face_polys[face], rgbcolor=color) @@ -492,7 +493,7 @@ def plot3d_cubie(cnt, clrs): sage: from sage.groups.perm_gps.cubegroup import plot3d_cubie, blue, red, green sage: clrF = blue; clrU = red; clrR = green - sage: P = plot3d_cubie([1/2,1/2,1/2],[clrF,clrU,clrR]) + sage: P = plot3d_cubie([1/2,1/2,1/2],[clrF,clrU,clrR]) # needs sage.plot """ half = QQ((1, 2)) x = cnt[0] - half @@ -955,11 +956,11 @@ def plot_cube(self, mv, title=True, colors=[lpurple, yellow, red, green, orange, EXAMPLES:: sage: rubik = CubeGroup() - sage: P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2", title = False) + sage: P = rubik.plot_cube("R^2*U^2*R^2*U^2*R^2*U^2", title=False) # needs sage.plot sage: # (R^2U^2)^3 permutes 2 pairs of edges (uf,ub)(fr,br) - sage: P = rubik.plot_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") + sage: P = rubik.plot_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") # needs sage.plot sage: # the superflip (in 20f* moves) - sage: P = rubik.plot_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") + sage: P = rubik.plot_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") # needs sage.plot sage: # "superflip+4 spot" (in 26q* moves) """ g = self.parse(mv) @@ -992,8 +993,8 @@ def plot3d_cube(self, mv, title=True): EXAMPLES:: sage: rubik = CubeGroup() - sage: P = rubik.plot3d_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") - sage: P = rubik.plot3d_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") + sage: P = rubik.plot3d_cube("U^2*F*U^2*L*R^(-1)*F^2*U*F^3*B^3*R*L*U^2*R*D^3*U*L^3*R*D*R^3*L^3*D^2") # needs sage.plot + sage: P = rubik.plot3d_cube("R*L*D^2*B^3*L^2*F^2*R^2*U^3*D*R^3*D^2*F^3*B^3*D^3*F^2*D^3*R^2*U^3*F^2*D^3") # needs sage.plot """ g = self.parse(mv) state = self.facets(g) @@ -1196,7 +1197,7 @@ class RubiksCube(SageObject): EXAMPLES:: sage: C = RubiksCube().move("R U R'") - sage: C.show3d() + sage: C.show3d() # needs sage.plot :: @@ -1214,7 +1215,7 @@ class RubiksCube(SageObject): | 37 bottom 21 | | 35 47 24 | +--------------+ - sage: C.show() + sage: C.show() # needs sage.plot sage: C.solve(algorithm='gap') # long time 'L*R' sage: C == RubiksCube("L*R") @@ -1317,7 +1318,7 @@ def plot(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.plot() + sage: C.plot() # needs sage.plot Graphics object consisting of 55 graphics primitives """ return self._group.plot_cube(self._state) @@ -1329,7 +1330,7 @@ def show(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.show() + sage: C.show() # needs sage.plot """ self.plot().show() @@ -1348,7 +1349,7 @@ def cubie(self, size, gap, x, y, z, colors, stickers=True): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.cubie(0.15, 0.025, 0,0,0, C.colors*3) + sage: C.cubie(0.15, 0.025, 0,0,0, C.colors*3) # needs sage.plot Graphics3d Object """ sides = cubie_face_list[x,y,z] @@ -1368,7 +1369,7 @@ def plot3d(self, stickers=True): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.plot3d() + sage: C.plot3d() # needs sage.plot Graphics3d Object """ while len(self.colors) < 7: @@ -1391,7 +1392,7 @@ def show3d(self): EXAMPLES:: sage: C = RubiksCube("R*U") - sage: C.show3d() + sage: C.show3d() # needs sage.plot """ return self.plot3d().show() diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index d174874194f..f59db412e8f 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.groups r""" Automorphism groups and canonical labels diff --git a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx index cd6284fb1b8..ea5409fdfcd 100644 --- a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx +++ b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx @@ -1229,6 +1229,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, TESTS:: + sage: # needs sage.groups sage: from sage.groups.perm_gps.partn_ref.data_structures import SC_test_list_perms sage: limit = 10^7 sage: def test_Sn_on_m_points(n, m, gap, contains): @@ -1239,7 +1240,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: test_Sn_on_m_points(i,i,1,0) sage: for i in range(2,9): ....: test_Sn_on_m_points(i,i,0,1) - sage: for i in range(2,9): # long time + sage: for i in range(2,9): # long time ....: test_Sn_on_m_points(i,i,1,1) sage: test_Sn_on_m_points(8,8,1,1) sage: def test_stab_chain_fns_1(n, gap, contains): @@ -1263,7 +1264,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: test_stab_chain_fns_2(n, 1, 0) sage: for n in range(2,11): ....: test_stab_chain_fns_2(n, 0, 1) - sage: for n in range(2,11): # long time + sage: for n in range(2,11): # long time ....: test_stab_chain_fns_2(n, 1, 1) sage: test_stab_chain_fns_2(11, 1, 1) sage: def test_stab_chain_fns_3(n, gap, contains): @@ -1274,7 +1275,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: test_stab_chain_fns_3(n, 1, 0) sage: for n in range(2,20): ....: test_stab_chain_fns_3(n, 0, 1) - sage: for n in range(2,14): # long time + sage: for n in range(2,14): # long time ....: test_stab_chain_fns_3(n, 1, 1) sage: test_stab_chain_fns_3(20, 1, 1) sage: def test_stab_chain_fns_4(n, g, gap, contains): @@ -1284,19 +1285,19 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: shuffle(perm) ....: perms.append(perm) ....: SC_test_list_perms(perms, n, limit, gap, 0, contains) - sage: for n in range(4,9): # long time + sage: for n in range(4,9): # long time ....: test_stab_chain_fns_4(n, 1, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 2, 1, 0) ....: test_stab_chain_fns_4(n, 3, 1, 0) - sage: for n in range(4,9): # not tested, known bug (see :trac:`32187`) + sage: for n in range(4,9): # known bug (see :trac:`32187`), not tested ....: test_stab_chain_fns_4(n, 1, 0, 1) ....: for j in range(6): ....: test_stab_chain_fns_4(n, 2, 0, 1) ....: test_stab_chain_fns_4(n, 3, 0, 1) - sage: for n in range(4,8): # long time + sage: for n in range(4,8): # long time ....: test_stab_chain_fns_4(n, 1, 1, 1) ....: test_stab_chain_fns_4(n, 2, 1, 1) ....: test_stab_chain_fns_4(n, 2, 1, 1) @@ -1312,12 +1313,12 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: shuffle(perm2) ....: perm2 = list(range(m)) + perm2 ....: SC_test_list_perms([perm1, perm2], n, limit, gap, 0, contains) - sage: for n in [4..9]: # long time + sage: for n in [4..9]: # long time ....: for _ in range(2): ....: test_stab_chain_fns_5(n, 1, 0) - sage: for n in [4..8]: # long time + sage: for n in [4..8]: # long time ....: test_stab_chain_fns_5(n, 0, 1) - sage: for n in [4..9]: # long time + sage: for n in [4..9]: # long time ....: test_stab_chain_fns_5(n, 1, 1) sage: def random_perm(x): ....: shuffle(x) @@ -1328,7 +1329,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, ....: perm = sum([random_perm(list(range(i*(n//m),min(n,(i+1)*(n//m))))) for i in range(m)], []) ....: perms.append(perm) ....: SC_test_list_perms(perms, m*(n//m), limit, gap, 0, contains) - sage: for m in range(2,9): # long time + sage: for m in range(2,9): # long time ....: for n in range(m,3*m): ....: for k in range(1,3): ....: test_stab_chain_fns_6(m,n,k, 1, 0) @@ -1358,7 +1359,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, sage: for n in [6..30]: ....: test_stab_chain_fns_7(n, 1, 0, 1) ....: test_stab_chain_fns_7(n, 0, 0, 1) - sage: for n in [6..14]: # long time + sage: for n in [6..14]: # long time ....: test_stab_chain_fns_7(n, 1, 1, 1) ....: test_stab_chain_fns_7(n, 0, 1, 1) sage: test_stab_chain_fns_7(20, 1, 1, 1) diff --git a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx index 56a97f6ece4..e3c7bc75f05 100644 --- a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx +++ b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.groups r""" Double cosets diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx index 3616decd7e4..56e4a062d02 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_binary.pyx @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.modules sage.rings.finite_rings """ Partition backtrack functions for binary codes diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index 17ddfce42db..8a5c1278a70 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -304,7 +304,10 @@ def search_tree(G_in, partition, lab=True, dig=False, dict_rep=False, certificat ....: if bde.has_arc(i,j): ....: bdg.add_edge(i,j) sage: a, b.graph6_string() - ([[0, 19, 3, 2, 6, 5, 4, 17, 18, 11, 10, 9, 13, 12, 16, 15, 14, 7, 8, 1], [0, 1, 8, 9, 13, 14, 7, 6, 2, 3, 19, 18, 17, 4, 5, 15, 16, 12, 11, 10], [1, 8, 9, 10, 11, 12, 13, 14, 7, 6, 2, 3, 4, 5, 15, 16, 17, 18, 19, 0]], 'S?[PG__OQ@?_?_?P?CO?_?AE?EC?Ac?@O') + ([[0, 19, 3, 2, 6, 5, 4, 17, 18, 11, 10, 9, 13, 12, 16, 15, 14, 7, 8, 1], + [0, 1, 8, 9, 13, 14, 7, 6, 2, 3, 19, 18, 17, 4, 5, 15, 16, 12, 11, 10], + [1, 8, 9, 10, 11, 12, 13, 14, 7, 6, 2, 3, 4, 5, 15, 16, 17, 18, 19, 0]], + 'S?[PG__OQ@?_?_?P?CO?_?AE?EC?Ac?@O') sage: a == asp True sage: a == ade @@ -903,6 +906,7 @@ def orbit_partition(gamma, list_perm=False): EXAMPLES:: + sage: # needs sage.groups sage: from sage.groups.perm_gps.partn_ref.refinement_graphs import orbit_partition sage: G = graphs.PetersenGraph() sage: S = SymmetricGroup(10) @@ -1294,7 +1298,7 @@ def generate_dense_graphs_edge_addition(int n, bint loops, G=None, depth=None, 34 156 1044 - sage: generate_dense_graphs_edge_addition(8,0) # long time - about 14 seconds at 2.4 GHz + sage: generate_dense_graphs_edge_addition(8,0) # long time (about 14 seconds at 2.4 GHz) 12346 """ @@ -1563,7 +1567,7 @@ def generate_dense_graphs_vert_addition(int n, base_G=None, 53 209 1253 - sage: generate_dense_graphs_vert_addition(8) # long time + sage: generate_dense_graphs_vert_addition(8) # long time 13599 TESTS:: diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py index 7dee76ad643..130c0960361 100644 --- a/src/sage/groups/perm_gps/permgroup.py +++ b/src/sage/groups/perm_gps/permgroup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- r""" Permutation groups @@ -287,6 +286,7 @@ def PermutationGroup(gens=None, *args, **kwds): We can also make permutation groups from PARI groups:: + sage: # needs sage.libs.pari sage: H = pari('x^4 - 2*x^3 - 2*x + 1').polgalois() sage: G = PariGroup(H, 4); G PARI group [8, -1, 3, "D(4)"] of degree 4 @@ -295,7 +295,7 @@ def PermutationGroup(gens=None, *args, **kwds): sage: H.gens() ((1,2,3,4), (1,3)) - We can also create permutation groups whose generators are Gap + We can also create permutation groups whose generators are GAP permutation objects:: sage: p = gap('(1,2)(3,7)(4,6)(5,8)'); p @@ -335,10 +335,10 @@ def PermutationGroup(gens=None, *args, **kwds): We can create a permutation group from a group action:: sage: a = lambda x: (2*x) % 7 - sage: H = PermutationGroup(action=a, domain=range(7)) - sage: H.orbits() + sage: H = PermutationGroup(action=a, domain=range(7)) # needs sage.combinat + sage: H.orbits() # needs sage.libs.pari ((0,), (1, 2, 4), (3, 6, 5)) - sage: H.gens() + sage: H.gens() # needs sage.libs.pari ((1,2,4), (3,6,5)) Note that we provide generators for the acting group. The @@ -362,7 +362,9 @@ def PermutationGroup(gens=None, *args, **kwds): i.e., in bijection with integer partitions:: sage: a = lambda g, x: g*x*g^-1 - sage: [len(PermutationGroup(SymmetricGroup(n).gens(), action=a, domain=SymmetricGroup(n)).orbits()) for n in range(1, 8)] + sage: [len(PermutationGroup(SymmetricGroup(n).gens(), action=a, # needs sage.combinat + ....: domain=SymmetricGroup(n)).orbits()) + ....: for n in range(1, 8)] [1, 2, 3, 5, 7, 11, 15] TESTS:: @@ -427,7 +429,8 @@ class PermutationGroup_generic(FiniteGroup): sage: G Permutation Group with generators [(3,4), (1,2,3)(4,5)] sage: G.center() - Subgroup generated by [()] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]) + Subgroup generated by [()] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]) sage: G.group_id() [120, 34] sage: n = G.order(); n @@ -614,14 +617,14 @@ def _has_natural_domain(self): def _gap_init_(self): r""" - Return a string showing how to declare / initialize ``self`` in Gap. + Return a string showing how to declare / initialize ``self`` in GAP. Stored in the ``self._gap_string`` attribute. EXAMPLES: The ``_gap_init_`` method shows how you would define the Sage ``PermutationGroup_generic`` - object in Gap:: + object in GAP:: sage: A4 = PermutationGroup([[(1,2,3)],[(2,3,4)]]); A4 Permutation Group with generators [(2,3,4), (1,2,3)] @@ -633,7 +636,7 @@ def _gap_init_(self): @cached_method def gap(self): r""" - this method from :class:`sage.groups.libgap_wrapper.ParentLibGAP` is added in order to achieve + This method from :class:`sage.groups.libgap_wrapper.ParentLibGAP` is added in order to achieve compatibility and have :class:`sage.groups.libgap_morphism.GroupHomset_libgap` work for permutation groups, as well @@ -643,7 +646,7 @@ def gap(self): EXAMPLES:: - sage: P8=PSp(8,3) + sage: P8 = PSp(8,3) sage: P8.gap() sage: gap(P8) == P8.gap() @@ -666,6 +669,7 @@ def gap(self): the following test shows, that support for the ``self._libgap`` attribute is needed in the constructor of the class:: + sage: # needs sage.libs.pari sage: PG = PGU(6,2) sage: g, h = PG.gens() sage: p1 = h^-3*(h^-1*g^-1)^2*h*g*h^2*g^-1*h^2*g*h^-5*g^-1 @@ -740,7 +744,7 @@ def __richcmp__(self, right, op): The comparison extends the subgroup relation. Hence, it is first checked whether one of the groups is subgroup of the other. If this is not the - case then the ordering is whatever it is in Gap. + case then the ordering is whatever it is in GAP. .. NOTE:: @@ -762,9 +766,9 @@ def __richcmp__(self, right, op): sage: H1 = PermutationGroup([[(1,2)],[(5,6)]]) sage: H2 = PermutationGroup([[(3,4)]]) sage: H3 = PermutationGroup([[(1,2)]]) - sage: H1 < H2 # according to Gap's ordering + sage: H1 < H2 # according to GAP's ordering True - sage: H2 < H3 # according to Gap's ordering + sage: H2 < H3 # according to GAP's ordering True sage: H3 < H1 # since H3 is a subgroup of H1 True @@ -850,7 +854,8 @@ def _element_constructor_(self, x, check=True): sage: G([(1,2)]) Traceback (most recent call last): ... - ValueError: permutation [(1, 2)] not in Permutation Group with generators [(1,2,3,4)] + ValueError: permutation [(1, 2)] not in + Permutation Group with generators [(1,2,3,4)] TESTS: @@ -923,6 +928,7 @@ def _coerce_map_from_(self, G): If this permutation group has been constructed via ``as_permutation_group`` method (from finite matrix groups):: + sage: # needs sage.libs.pari sage: MG = GU(3,2).as_matrix_group() sage: PG = MG.as_permutation_group() sage: f = PG._coerce_map_from_(MG) @@ -1166,11 +1172,11 @@ def iteration(self, algorithm="SGS"): - ``algorithm`` -- (default: ``"SGS"``) either - * ``"SGS"`` - using strong generating system - * ``"BFS"`` - a breadth first search on the Cayley graph with - respect to ``self.gens()`` - * ``"DFS"`` - a depth first search on the Cayley graph with - respect to ``self.gens()`` + * ``"SGS"`` -- using strong generating system + * ``"BFS"`` -- a breadth first search on the Cayley graph with + respect to ``self.gens()`` + * ``"DFS"`` -- a depth first search on the Cayley graph with + respect to ``self.gens()`` .. NOTE:: @@ -1312,7 +1318,7 @@ def gens_small(self): def gen(self, i=None): r""" - Return the i-th generator of ``self``; that is, the i-th element of + Return the `i`-th generator of ``self``; that is, the `i`-th element of the list ``self.gens()``. The argument `i` may be omitted if there is only one generator (but @@ -1367,8 +1373,7 @@ def one(self): EXAMPLES:: sage: G = PermutationGroup([[(1,2,3),(4,5)]]) - sage: e = G.identity() # indirect doctest - sage: e + sage: e = G.identity(); e # indirect doctest () sage: g = G.gen(0) sage: g*e @@ -1531,13 +1536,13 @@ def representative_action(self,x,y): INPUT: - - ``x,y`` -- two elements of the domain. + - ``x``, ``y`` -- two elements of the domain. EXAMPLES:: sage: G = groups.permutation.Cyclic(14) - sage: g = G.representative_action(1,10) - sage: all(g(x) == 1+((x+9-1)%14) for x in G.domain()) + sage: g = G.representative_action(1, 10) + sage: all(g(x) == 1 + ((x+9-1)%14) for x in G.domain()) True TESTS:: @@ -1657,7 +1662,7 @@ def orbit(self, point, action="OnPoints"): Action of `S_4` (on a nonstandard domain) on tuples of sets:: sage: S4 = PermutationGroup([ [('c','d')], [('a','c')], [('a','b')] ]) - sage: orb = S4.orbit((('a','c'),('b','d')),"OnTuplesSets") + sage: orb = S4.orbit((('a','c'),('b','d')), "OnTuplesSets") sage: expect = (({'a', 'c'}, {'b', 'd'}), ({'a', 'd'}, {'c', 'b'}), ....: ({'c', 'b'}, {'a', 'd'}), ({'b', 'd'}, {'a', 'c'}), ....: ({'c', 'd'}, {'a', 'b'}), ({'a', 'b'}, {'c', 'd'})) @@ -1668,7 +1673,8 @@ def orbit(self, point, action="OnPoints"): sage: S4 = PermutationGroup([ [((11,(12,13)),'d')], ....: [((12,(12,11)),(11,(12,13)))], [((12,(12,11)),'b')] ]) - sage: orb = S4.orbit((( (11,(12,13)), (12,(12,11))),('b','d')),"OnTuplesSets") + sage: orb = S4.orbit((( (11,(12,13)), (12,(12,11))),('b','d')), + ....: "OnTuplesSets") sage: expect = (({(11, (12, 13)), (12, (12, 11))}, {'b', 'd'}), ....: ({'d', (12, (12, 11))}, {(11, (12, 13)), 'b'}), ....: ({(11, (12, 13)), 'b'}, {'d', (12, (12, 11))}), @@ -1755,9 +1761,9 @@ def stabilizer(self, point, action="OnPoints"): - ``point`` -- a point of the :meth:`domain`, or a set of points depending on the value of ``action``. - - ``action`` (string; default ``"OnPoints"``) -- should the group be + - ``action`` -- (string; default ``"OnPoints"``) should the group be considered to act on points (``action="OnPoints"``) or on sets of - points (``action="OnSets"``) ? In the latter case, the first argument + points (``action="OnSets"``)? In the latter case, the first argument must be a subset of :meth:`domain`. EXAMPLES:: @@ -1848,8 +1854,8 @@ def base(self, seed=None): INPUT: - ``seed`` (optional, default: ``None``), if given must be a - subset of the domain of `base`. When used, an attempt to - create a base containing all or part of `seed` will be + subset of the domain of a base. When used, an attempt to + create a base containing all or part of ``seed`` will be made. EXAMPLES:: @@ -1915,10 +1921,10 @@ def strong_generating_system(self, base_of_group=None, implementation="sage"): - ``implementation`` -- (default: ``"sage"``) either - * ``"sage"`` - use the direct implementation in Sage + * ``"sage"`` -- use the direct implementation in Sage - * ``"gap"`` - if used, the ``base_of_group`` must be ``None`` - and the computation is directly performed in GAP + * ``"gap"`` -- if used, the ``base_of_group`` must be ``None`` + and the computation is directly performed in GAP OUTPUT: @@ -2140,7 +2146,7 @@ def _order(self): # This special case only works with more than 1 generator. if not gens or len(gens) < 2: return None - # Special case: certain subgroups of the symmetric group for which Gap reports + # Special case: certain subgroups of the symmetric group for which GAP reports # generators of the form ((1, 2), (1, 3), ...) # This means that this group is isomorphic to a smaller symmetric group # S_n, where n is the number of generators supported. @@ -2188,7 +2194,8 @@ def _order(self): def order(self): """ Return the number of elements of this group. - See also: G.degree() + + See also: :meth:`degree`. EXAMPLES:: @@ -2202,7 +2209,7 @@ def order(self): sage: G.order() 1 - ``cardinality`` is just an alias:: + :meth:`cardinality` is just an alias:: sage: PermutationGroup([(1,2,3)]).cardinality() 3 @@ -2255,8 +2262,9 @@ def group_id(self): def id(self): """ - (Same as ``self.group_id()``.) Return the ID code of this group, which - is a list of two integers. + Return the ID code of this group, which is a list of two integers. + + Same as :meth:`group_id`. EXAMPLES:: @@ -2273,7 +2281,7 @@ def group_primitive_id(self): OUTPUT: A positive integer, following GAP's conventions. A - ``ValueError`` is raised if the group is not primitive. + :class:`ValueError` is raised if the group is not primitive. EXAMPLES:: @@ -2307,10 +2315,12 @@ def center(self): sage: G = PermutationGroup([[(1,2,3,4)]]) sage: G.center() - Subgroup generated by [(1,2,3,4)] of (Permutation Group with generators [(1,2,3,4)]) + Subgroup generated by [(1,2,3,4)] of + (Permutation Group with generators [(1,2,3,4)]) sage: G = PermutationGroup([[(1,2,3,4)], [(1,2)]]) sage: G.center() - Subgroup generated by [()] of (Permutation Group with generators [(1,2), (1,2,3,4)]) + Subgroup generated by [()] of + (Permutation Group with generators [(1,2), (1,2,3,4)]) """ return self.subgroup(gap_group=self._libgap_().Center()) @@ -2325,9 +2335,12 @@ def socle(self): sage: G = SymmetricGroup(4) sage: G.socle() - Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of (Symmetric group of order 4! as a permutation group) + Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of + (Symmetric group of order 4! as a permutation group) sage: G.socle().socle() - Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of (Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of (Symmetric group of order 4! as a permutation group)) + Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of + (Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] + of (Symmetric group of order 4! as a permutation group)) """ return self.subgroup(gap_group=self._gap_().Socle()) @@ -2342,10 +2355,12 @@ def frattini_subgroup(self): sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]]) sage: G.frattini_subgroup() - Subgroup generated by [(1,3)(2,4)] of (Permutation Group with generators [(2,4), (1,2,3,4)]) + Subgroup generated by [(1,3)(2,4)] of + (Permutation Group with generators [(2,4), (1,2,3,4)]) sage: G = SymmetricGroup(4) sage: G.frattini_subgroup() - Subgroup generated by [()] of (Symmetric group of order 4! as a permutation group) + Subgroup generated by [()] of + (Symmetric group of order 4! as a permutation group) """ return self.subgroup(gap_group=self._libgap_().FrattiniSubgroup()) @@ -2361,10 +2376,12 @@ def fitting_subgroup(self): sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]]) sage: G.fitting_subgroup() - Subgroup generated by [(2,4), (1,2,3,4), (1,3)] of (Permutation Group with generators [(2,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,2,3,4), (1,3)] of + (Permutation Group with generators [(2,4), (1,2,3,4)]) sage: G = PermutationGroup([[(1,2,3,4)],[(1,2)]]) sage: G.fitting_subgroup() - Subgroup generated by [(1,2)(3,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2), (1,2,3,4)]) + Subgroup generated by [(1,2)(3,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2), (1,2,3,4)]) """ return self.subgroup(gap_group=self._libgap_().FittingSubgroup()) @@ -2380,10 +2397,12 @@ def solvable_radical(self): sage: G = SymmetricGroup(4) sage: G.solvable_radical() - Subgroup generated by [(1,2), (1,2,3,4)] of (Symmetric group of order 4! as a permutation group) + Subgroup generated by [(1,2), (1,2,3,4)] of + (Symmetric group of order 4! as a permutation group) sage: G = SymmetricGroup(5) sage: G.solvable_radical() - Subgroup generated by [()] of (Symmetric group of order 5! as a permutation group) + Subgroup generated by [()] of + (Symmetric group of order 5! as a permutation group) """ return self.subgroup(gap_group=self._libgap_().RadicalGroup()) @@ -2489,7 +2508,7 @@ def conjugate(self, g): INPUT: - - ``g`` - a permutation group element, or an object that converts + - ``g`` -- a permutation group element, or an object that converts to a permutation group element, such as a list of integers or a string of cycles. @@ -2583,28 +2602,27 @@ def direct_product(self, other, maps=True): INPUT: - - ``self, other`` - permutation groups + - ``self``, ``other`` -- permutation groups OUTPUT: - - ``D`` - a direct product of the inputs, returned as + - ``D`` -- a direct product of the inputs, returned as a permutation group as well - - ``iota1`` - an embedding of ``self`` into ``D`` + - ``iota1`` -- an embedding of ``self`` into ``D`` - - ``iota2`` - an embedding of ``other`` into ``D`` + - ``iota2`` -- an embedding of ``other`` into ``D`` - - ``pr1`` - the projection of ``D`` onto ``self`` (giving a - splitting 1 - other - D - self - 1) + - ``pr1`` -- the projection of ``D`` onto ``self`` (giving a + splitting ``1 - other - D - self - 1``) - - ``pr2`` - the projection of ``D`` onto ``other`` (giving a - splitting 1 - self - D - other - 1) + - ``pr2`` -- the projection of ``D`` onto ``other`` (giving a + splitting ``1 - self - D - other - 1``) EXAMPLES:: sage: G = CyclicPermutationGroup(4) - sage: D = G.direct_product(G,False) - sage: D + sage: D = G.direct_product(G, False); D Permutation Group with generators [(5,6,7,8), (1,2,3,4)] sage: D,iota1,iota2,pr1,pr2 = G.direct_product(G) sage: D; iota1; iota2; pr1; pr2 @@ -2657,22 +2675,22 @@ def semidirect_product(self, N, mapping, check=True): naturally embeds as a normal subgroup of the returned semidirect product. - - ``mapping`` - A pair of lists that together define a - homomorphism, `\phi :` self `\rightarrow` Aut(N), by giving, + - ``mapping`` -- A pair of lists that together define a + homomorphism, `\phi :` ``self`` `\rightarrow` Aut(``N``), by giving, in the second list, the images of the generators of ``self`` in the order given in the first list. - - ``check`` - A boolean that, if set to False, will skip the + - ``check`` -- A boolean that, if set to ``False``, will skip the initial tests which are made on ``mapping``. This may be beneficial for large ``N``, since in such cases the injectivity test can be - expensive. Set to True by default. + expensive. Set to ``True`` by default. OUTPUT: The semidirect product of ``self`` and ``N`` defined by the action of ``self`` on ``N`` given in ``mapping`` (note that a - homomorphism from A to the automorphism group of B is - equivalent to an action of A on the B's underlying set). The + homomorphism from `A` to the automorphism group of `B` is + equivalent to an action of `A` on `B`'s underlying set). The semidirect product of two groups, `H` and `N`, is a construct similar to the direct product in so far as the elements are the Cartesian product of the elements of `H` and the elements @@ -2739,7 +2757,8 @@ def semidirect_product(self, N, mapping, check=True): sage: S1.is_isomorphic(DiCyclicGroup(6)) False sage: S1.center() - Subgroup generated by [(1,3)(2,4)] of (Permutation Group with generators [(5,6,7), (1,2,3,4)(6,7), (1,3)]) + Subgroup generated by [(1,3)(2,4)] of + (Permutation Group with generators [(5,6,7), (1,2,3,4)(6,7), (1,3)]) sage: len(S1.conjugacy_classes_representatives()) 9 @@ -2855,7 +2874,8 @@ def holomorph(self): sage: A.is_abelian() False sage: A.center() - Subgroup generated by [()] of (Permutation Group with generators [(5,6,7,8,9), (1,2,4,3)(6,7,9,8)]) + Subgroup generated by [()] of + (Permutation Group with generators [(5,6,7,8,9), (1,2,4,3)(6,7,9,8)]) sage: A Permutation Group with generators [(5,6,7,8,9), (1,2,4,3)(6,7,9,8)] @@ -2903,14 +2923,15 @@ def subgroup(self, gens=None, gap_group=None, domain=None, category=None, canoni sage: G = PermutationGroup([(1,2,3),(3,4,5)]) sage: g = G((1,2,3)) sage: G.subgroup([g]) - Subgroup generated by [(1,2,3)] of (Permutation Group with generators [(3,4,5), (1,2,3)]) + Subgroup generated by [(1,2,3)] of + (Permutation Group with generators [(3,4,5), (1,2,3)]) """ return self.Subgroup(self, gens=gens, gap_group=gap_group, domain=None, category=category, canonicalize=canonicalize, check=check) def _subgroup_constructor(self, libgap_group): """ - this method is added for compatibility reason with the + This method is added for compatibility reason with the :meth:`sage.groups.libgap_wrapper.ParentLibGAP_subgroup_constructor` and for usage in :class:`sage.groups.libgap_morphism.GroupMorphism_libgap` @@ -2921,10 +2942,11 @@ def _subgroup_constructor(self, libgap_group): OUTPUT: - the corresponding subgroup of self as an instance of this class + The corresponding subgroup of ``self`` as an instance of this class EXAMPLES:: + sage: # needs sage.libs.pari sage: G = PGU(3,2); G The projective general unitary group of degree 3 over Finite Field of size 2 sage: g1, g2 = G.gens() @@ -2933,7 +2955,8 @@ def _subgroup_constructor(self, libgap_group): sage: type(Hgap) sage: H = G._subgroup_constructor(Hgap); H - Subgroup generated by [(1,6,21,12,20,17)(2,10,15,9,11,5)(3,14,8)(4,18)(7,16)] of (The projective general unitary group of degree 3 over Finite Field of size 2) + Subgroup generated by [(1,6,21,12,20,17)(2,10,15,9,11,5)(3,14,8)(4,18)(7,16)] of + (The projective general unitary group of degree 3 over Finite Field of size 2) """ gens = [gen.sage() for gen in libgap_group.GeneratorsOfGroup()] return self.subgroup(gens=gens, gap_group=libgap_group) @@ -2947,15 +2970,15 @@ def as_finitely_presented_group(self, reduced=False): INPUT: - - ``reduced`` -- Default ``False``, if ``True`` :meth:`FinitelyPresentedGroup.simplified + - ``reduced`` -- (default ``False``) if ``True``, :meth:`FinitelyPresentedGroup.simplified ` is called, attempting to simplify the presentation of the finitely presented group to be returned. OUTPUT: - Finite presentation of self, obtained by taking the image - of the isomorphism returned by the GAP function, ``IsomorphismFpGroupByGenerators``. + Finite presentation of ``self``, obtained by taking the image + of the isomorphism returned by the GAP function ``IsomorphismFpGroupByGenerators``. ALGORITHM: @@ -2982,9 +3005,10 @@ def as_finitely_presented_group(self, reduced=False): We can attempt to reduce the output presentation:: - sage: PermutationGroup(['(1,2,3,4,5)','(1,3,5,2,4)']).as_finitely_presented_group() + sage: H = PermutationGroup(['(1,2,3,4,5)', '(1,3,5,2,4)']) + sage: H.as_finitely_presented_group() Finitely presented group < a, b | b^-2*a^-1, b*a^-2 > - sage: PermutationGroup(['(1,2,3,4,5)','(1,3,5,2,4)']).as_finitely_presented_group(reduced=True) + sage: H.as_finitely_presented_group(reduced=True) Finitely presented group < a | a^5 > TESTS:: @@ -3080,11 +3104,11 @@ def commutator(self, other=None): INPUT: - - ``other`` - default: ``None`` - a permutation group. + - ``other`` -- (default: ``None``) a permutation group. OUTPUT: - Let `G` denote ``self``. If ``other`` is ``None`` then this method + Let `G` denote ``self``. If ``other`` is ``None``, then this method returns the subgroup of `G` generated by the set of commutators, .. MATH:: @@ -3277,8 +3301,7 @@ def homology(self, n, p=0): `H_7(S_5, \ZZ / 2 \ZZ)`, `H_7(S_5, \ZZ / 3 \ZZ)`, and `H_7(S_5, \ZZ / 5 \ZZ)`, respectively. To compute the - `2`-part of `H_7(S_5, \ZZ)`, use the ``homology_part`` - function. + `2`-part of `H_7(S_5, \ZZ)`, use the method :meth:`homology_part`. EXAMPLES:: @@ -3352,7 +3375,7 @@ def character_table(self): sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3)]]) sage: G.order() 12 - sage: G.character_table() + sage: G.character_table() # needs sage.rings.number_field [ 1 1 1 1] [ 1 -zeta3 - 1 zeta3 1] [ 1 zeta3 -zeta3 - 1 1] @@ -3367,7 +3390,7 @@ def character_table(self): sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]]) sage: G.order() 8 - sage: G.character_table() + sage: G.character_table() # needs sage.rings.number_field [ 1 1 1 1 1] [ 1 -1 -1 1 1] [ 1 -1 1 -1 1] @@ -3379,6 +3402,7 @@ def character_table(self): :: + sage: # needs sage.rings.number_field sage: SymmetricGroup(2).character_table() [ 1 -1] [ 1 1] @@ -3395,7 +3419,10 @@ def character_table(self): [ 4 2 0 1 -1 0 -1] [ 1 1 1 1 1 1 1] sage: list(AlternatingGroup(6).character_table()) - [(1, 1, 1, 1, 1, 1, 1), (5, 1, 2, -1, -1, 0, 0), (5, 1, -1, 2, -1, 0, 0), (8, 0, -1, -1, 0, zeta5^3 + zeta5^2 + 1, -zeta5^3 - zeta5^2), (8, 0, -1, -1, 0, -zeta5^3 - zeta5^2, zeta5^3 + zeta5^2 + 1), (9, 1, 0, 0, 1, -1, -1), (10, -2, 1, 1, 0, 0, 0)] + [(1, 1, 1, 1, 1, 1, 1), (5, 1, 2, -1, -1, 0, 0), (5, 1, -1, 2, -1, 0, 0), + (8, 0, -1, -1, 0, zeta5^3 + zeta5^2 + 1, -zeta5^3 - zeta5^2), + (8, 0, -1, -1, 0, -zeta5^3 - zeta5^2, zeta5^3 + zeta5^2 + 1), + (9, 1, 0, 0, 1, -1, -1), (10, -2, 1, 1, 0, 0, 0)] Suppose that you have a class function `f(g)` on `G` and you know the values `v_1, \ldots, v_n` on @@ -3438,8 +3465,8 @@ def irreducible_characters(self): EXAMPLES:: - sage: irr = SymmetricGroup(3).irreducible_characters() - sage: [x.values() for x in irr] + sage: irr = SymmetricGroup(3).irreducible_characters() # needs sage.rings.number_field + sage: [x.values() for x in irr] # needs sage.rings.number_field [[1, -1, 1], [2, 0, -1], [1, 1, 1]] """ return [ClassFunction_libgap(self, irr) for irr in self._libgap_().Irr()] @@ -3450,7 +3477,7 @@ def trivial_character(self): EXAMPLES:: - sage: SymmetricGroup(3).trivial_character() + sage: SymmetricGroup(3).trivial_character() # needs sage.rings.number_field Character of Symmetric group of order 3! as a permutation group """ values = [1]*self._libgap_().NrConjugacyClasses().sage() @@ -3466,7 +3493,7 @@ def character(self, values): sage: G = AlternatingGroup(4) sage: n = len(G.conjugacy_classes_representatives()) - sage: G.character([1]*n) + sage: G.character([1]*n) # needs sage.rings.number_field Character of Alternating group of order 4!/2 as a permutation group """ return ClassFunction_libgap(self, values) @@ -3489,13 +3516,13 @@ def conjugacy_classes_representatives(self): :: sage: G = SymmetricGroup(5) - sage: G.conjugacy_classes_representatives() + sage: G.conjugacy_classes_representatives() # needs sage.combinat [(), (1,2), (1,2)(3,4), (1,2,3), (1,2,3)(4,5), (1,2,3,4), (1,2,3,4,5)] :: sage: S = SymmetricGroup(['a','b','c']) - sage: S.conjugacy_classes_representatives() + sage: S.conjugacy_classes_representatives() # needs sage.combinat [(), ('a','b'), ('a','b','c')] AUTHORS: @@ -3515,25 +3542,36 @@ def conjugacy_classes_subgroups(self): EXAMPLES:: sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]]) - sage: cl = G.conjugacy_classes_subgroups() - sage: cl - [Subgroup generated by [()] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(1,2)(3,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(2,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(1,2,3,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), - Subgroup generated by [(2,4), (1,2)(3,4), (1,4)(2,3)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)])] + sage: cl = G.conjugacy_classes_subgroups(); cl + [Subgroup generated by [()] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(1,2)(3,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(1,2)(3,4), (1,4)(2,3)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(2,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(1,2,3,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]), + Subgroup generated by [(2,4), (1,2)(3,4), (1,4)(2,3)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)])] :: sage: G = SymmetricGroup(3) sage: G.conjugacy_classes_subgroups() - [Subgroup generated by [()] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(2,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(1,2,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(2,3), (1,2,3)] of (Symmetric group of order 3! as a permutation group)] + [Subgroup generated by [()] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(2,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(1,2,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(2,3), (1,2,3)] of + (Symmetric group of order 3! as a permutation group)] AUTHORS: @@ -3575,19 +3613,30 @@ def subgroups(self): sage: G = SymmetricGroup(3) sage: G.subgroups() - [Subgroup generated by [()] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(2,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(1,2)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(1,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(1,2,3)] of (Symmetric group of order 3! as a permutation group), - Subgroup generated by [(2,3), (1,2,3)] of (Symmetric group of order 3! as a permutation group)] + [Subgroup generated by [()] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(2,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(1,2)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(1,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(1,2,3)] of + (Symmetric group of order 3! as a permutation group), + Subgroup generated by [(2,3), (1,2,3)] of + (Symmetric group of order 3! as a permutation group)] sage: G = CyclicPermutationGroup(14) sage: G.subgroups() - [Subgroup generated by [()] of (Cyclic group of order 14 as a permutation group), - Subgroup generated by [(1,8)(2,9)(3,10)(4,11)(5,12)(6,13)(7,14)] of (Cyclic group of order 14 as a permutation group), - Subgroup generated by [(1,3,5,7,9,11,13)(2,4,6,8,10,12,14)] of (Cyclic group of order 14 as a permutation group), - Subgroup generated by [(1,2,3,4,5,6,7,8,9,10,11,12,13,14), (1,3,5,7,9,11,13)(2,4,6,8,10,12,14)] of (Cyclic group of order 14 as a permutation group)] + [Subgroup generated by [()] of + (Cyclic group of order 14 as a permutation group), + Subgroup generated by [(1,8)(2,9)(3,10)(4,11)(5,12)(6,13)(7,14)] of + (Cyclic group of order 14 as a permutation group), + Subgroup generated by [(1,3,5,7,9,11,13)(2,4,6,8,10,12,14)] of + (Cyclic group of order 14 as a permutation group), + Subgroup generated by [(1,2,3,4,5,6,7,8,9,10,11,12,13,14), + (1,3,5,7,9,11,13)(2,4,6,8,10,12,14)] of + (Cyclic group of order 14 as a permutation group)] AUTHOR: @@ -3636,9 +3685,9 @@ def has_regular_subgroup(self, return_group=False): INPUT: - - ``return_group`` (boolean) -- If ``return_group = True``, a regular + - ``return_group`` -- (boolean) If ``True``, a regular subgroup is returned if there is one, and ``None`` if there isn't. - When ``return_group = False`` (default), only a boolean indicating + When ``return_group=False`` (default), only a boolean indicating whether such a group exists is returned instead. EXAMPLES: @@ -3648,8 +3697,9 @@ def has_regular_subgroup(self, return_group=False): sage: S4 = groups.permutation.Symmetric(4) sage: S4.has_regular_subgroup() True - sage: S4.has_regular_subgroup(return_group = True) # random - Subgroup of (Symmetric group of order 4! as a permutation group) generated by [(1,3)(2,4), (1,4)(2,3)] + sage: S4.has_regular_subgroup(return_group=True) # random + Subgroup of (Symmetric group of order 4! as a permutation group) + generated by [(1,3)(2,4), (1,4)(2,3)] But the automorphism group of Petersen's graph does not:: @@ -3682,7 +3732,7 @@ def blocks_all(self, representatives=True): INPUT: - - ``representative`` (boolean) -- whether to return all possible block + - ``representative`` -- (boolean) whether to return all possible block systems of imprimitivity or only one of their representatives (the block can be obtained from its representative set `S` by computing the orbit of `S` under ``self``). @@ -3698,13 +3748,13 @@ def blocks_all(self, representatives=True): * A list of length (#number of different block systems) of - * block systems, each of them being defined as + * block systems, each of them being defined as - * If ``representatives = True`` : a list of representatives of - each set of the block system + * If ``representatives=True``: a list of representatives of + each set of the block system - * If ``representatives = False`` : a partition of the elements - defining an imprimitivity block. + * If ``representatives=False``: a partition of the elements + defining an imprimitivity block. .. SEEALSO:: @@ -3729,7 +3779,8 @@ def blocks_all(self, representatives=True): Now the full block:: sage: sorted(ag.blocks_all(representatives = False)[0]) - [[0, 15], [1, 16], [2, 12], [3, 13], [4, 9], [5, 10], [6, 11], [7, 18], [8, 17], [14, 19]] + [[0, 15], [1, 16], [2, 12], [3, 13], [4, 9], + [5, 10], [6, 11], [7, 18], [8, 17], [14, 19]] TESTS:: @@ -3754,13 +3805,13 @@ def cosets(self, S, side='right'): INPUT: - - ``S`` - a subgroup of ``self``. An error is raised + - ``S`` -- a subgroup of ``self``. An error is raised if ``S`` is not a subgroup. - - ``side`` - default: 'right' - determines if right cosets or + - ``side`` -- (default: ``'right'``) Determines if right cosets or left cosets are returned. ``side`` refers to where the representative is placed in the products forming the cosets - and thus allowable values are only 'right' and 'left'. + and thus allowable values are only ``'right'`` and ``'left'``. OUTPUT: @@ -3947,13 +3998,16 @@ def normalizer(self, g): sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]]) sage: g = G([(1,3)]) sage: G.normalizer(g) - Subgroup generated by [(2,4), (1,3)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,3)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) sage: g = G([(1,2,3,4)]) sage: G.normalizer(g) - Subgroup generated by [(2,4), (1,2,3,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,2,3,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) sage: H = G.subgroup([G([(1,2,3,4)])]) sage: G.normalizer(H) - Subgroup generated by [(2,4), (1,2,3,4), (1,3)(2,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,2,3,4), (1,3)(2,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) """ return self.subgroup(gap_group=self._libgap_().Normalizer(g)) @@ -3966,13 +4020,16 @@ def centralizer(self, g): sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3,4)]]) sage: g = G([(1,3)]) sage: G.centralizer(g) - Subgroup generated by [(2,4), (1,3)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(2,4), (1,3)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) sage: g = G([(1,2,3,4)]) sage: G.centralizer(g) - Subgroup generated by [(1,2,3,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(1,2,3,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) sage: H = G.subgroup([G([(1,2,3,4)])]) sage: G.centralizer(H) - Subgroup generated by [(1,2,3,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + Subgroup generated by [(1,2,3,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) """ return self.subgroup(gap_group=self._libgap_().Centralizer(g)) @@ -4080,9 +4137,9 @@ def isomorphism_to(self, right): INPUT: - - ``self`` - this group + - ``self`` -- this group - - ``right`` - a permutation group + - ``right`` -- a permutation group OUTPUT: @@ -4133,9 +4190,9 @@ def is_isomorphic(self, right): INPUT: - - ``self`` - this group + - ``self`` -- this group - - ``right`` - a permutation group + - ``right`` -- a permutation group OUTPUT: @@ -4243,7 +4300,7 @@ def is_polycyclic(self): Return ``True`` if this group is polycyclic. A group is polycyclic if it has a subnormal series with cyclic factors. (For finite groups, this is the same as if the group is solvable - see - ``is_solvable``.) + :meth:`is_solvable`.) EXAMPLES:: @@ -4574,13 +4631,17 @@ def composition_series(self): sage: set_random_seed(0) sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.composition_series() - [Subgroup generated by [(3,4), (1,2,3)(4,5)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), - Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), - Subgroup generated by [()] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] + [Subgroup generated by [(3,4), (1,2,3)(4,5)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), + Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), + Subgroup generated by [()] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] sage: G = PermutationGroup([[(1,2,3),(4,5)], [(1,2)]]) sage: CS = G.composition_series() sage: CS[3] - Subgroup generated by [()] of (Permutation Group with generators [(1,2), (1,2,3)(4,5)]) + Subgroup generated by [()] of + (Permutation Group with generators [(1,2), (1,2,3)(4,5)]) """ libgap.set_seed() CS = self._libgap_().CompositionSeries() @@ -4601,8 +4662,10 @@ def derived_series(self): sage: set_random_seed(0) sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.derived_series() - [Subgroup generated by [(3,4), (1,2,3)(4,5)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), - Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] + [Subgroup generated by [(3,4), (1,2,3)(4,5)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), + Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] """ libgap.set_seed() DS = self._libgap_().DerivedSeries() @@ -4623,8 +4686,10 @@ def lower_central_series(self): sage: set_random_seed(0) sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.lower_central_series() - [Subgroup generated by [(3,4), (1,2,3)(4,5)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), - Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] + [Subgroup generated by [(3,4), (1,2,3)(4,5)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)]), + Subgroup generated by [(1,3,5), (1,5)(3,4), (1,5)(2,4)] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] """ libgap.set_seed() LCS = self._libgap_().LowerCentralSeriesOfGroup() @@ -4701,11 +4766,11 @@ def molien_series(self): R(str(dd).replace("_1", ""))) def normal_subgroups(self): - """ + r""" Return the normal subgroups of this group as a (sorted in increasing order) list of permutation groups. - The normal subgroups of `H = PSL(2,7) \\times PSL(2,7)` are + The normal subgroups of `H = PSL(2,7) \times PSL(2,7)` are `1`, two copies of `PSL(2,7)` and `H` itself, as the following example shows. @@ -4740,10 +4805,10 @@ def poincare_series(self, p=2, n=10): EXAMPLES:: sage: G = SymmetricGroup(5) - sage: G.poincare_series(2,10) # optional - gap_package_hap + sage: G.poincare_series(2, 10) # optional - gap_package_hap (x^2 + 1)/(x^4 - x^3 - x + 1) sage: G = SymmetricGroup(3) - sage: G.poincare_series(2,10) # optional - gap_package_hap + sage: G.poincare_series(2, 10) # optional - gap_package_hap -1/(x - 1) AUTHORS: @@ -4777,9 +4842,11 @@ def sylow_subgroup(self, p): sage: G = PermutationGroup(['(1,2,3)', '(2,3)']) sage: G.sylow_subgroup(2) - Subgroup generated by [(2,3)] of (Permutation Group with generators [(2,3), (1,2,3)]) + Subgroup generated by [(2,3)] of + (Permutation Group with generators [(2,3), (1,2,3)]) sage: G.sylow_subgroup(5) - Subgroup generated by [()] of (Permutation Group with generators [(2,3), (1,2,3)]) + Subgroup generated by [()] of + (Permutation Group with generators [(2,3), (1,2,3)]) TESTS: @@ -4804,7 +4871,8 @@ def upper_central_series(self): sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G.upper_central_series() - [Subgroup generated by [()] of (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] + [Subgroup generated by [()] of + (Permutation Group with generators [(3,4), (1,2,3)(4,5)])] """ libgap.set_seed() UCS = self._libgap_().UpperCentralSeriesOfGroup() @@ -4846,7 +4914,8 @@ class PermutationGroup_subgroup(PermutationGroup_generic): sage: gens = G.gens() sage: H = DihedralGroup(4) sage: H.subgroup(gens) - Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group) + Subgroup generated by [(1,2,3,4)] of + (Dihedral group of order 8 as a permutation group) sage: K = H.subgroup(gens) sage: K.list() [(), (1,2,3,4), (1,3)(2,4), (1,4,3,2)] @@ -4863,18 +4932,18 @@ def __init__(self, ambient, gens=None, gap_group=None, domain=None, INPUT: - - ``ambient`` - the ambient group from which to construct this + - ``ambient`` -- the ambient group from which to construct this subgroup - - ``gens`` - the generators of the subgroup + - ``gens`` -- the generators of the subgroup - - ``gap_group`` - a GAP permutation group contained in the ambient group; - constructed from ``gens`` if not given. + - ``gap_group`` -- a GAP permutation group contained in the ambient group; + constructed from ``gens`` if not given. - - ``check`` - ``True``: checks if ``gens`` are indeed elements of the + - ``check`` -- ``True``: checks if ``gens`` are indeed elements of the ambient group - - ``canonicalize`` - boolean (default: ``True``); if ``True``, sort + - ``canonicalize`` -- boolean (default: ``True``); if ``True``, sort generators and remove duplicates EXAMPLES: @@ -5078,7 +5147,8 @@ def is_normal(self, other=None): sage: S = SymmetricGroup(['a','b','c']) sage: H = S.subgroup([('a', 'b', 'c')]); H - Subgroup generated by [('a','b','c')] of (Symmetric group of order 3! as a permutation group) + Subgroup generated by [('a','b','c')] of + (Symmetric group of order 3! as a permutation group) sage: H.is_normal() True @@ -5101,9 +5171,9 @@ class PermutationGroup_action(PermutationGroup_generic): sage: n = 3 sage: a = lambda x: SetPartition([[e % n + 1 for e in b] for b in x]) - sage: S = SetPartitions(n) - sage: G = PermutationGroup(action=a, domain=S) - sage: G.orbits() + sage: S = SetPartitions(n) # needs sage.combinat + sage: G = PermutationGroup(action=a, domain=S) # needs sage.combinat + sage: G.orbits() # needs sage.combinat (({{1}, {2}, {3}},), ({{1, 2}, {3}}, {{1}, {2, 3}}, {{1, 3}, {2}}), ({{1, 2, 3}},)) @@ -5112,13 +5182,14 @@ class PermutationGroup_action(PermutationGroup_generic): sage: a = lambda g, x: g*x*g^-1 sage: S = SymmetricGroup(3) - sage: G = PermutationGroup(S.gens(), action=a, domain=S) - sage: G.orbits() + sage: G = PermutationGroup(S.gens(), action=a, domain=S) # needs sage.combinat + sage: G.orbits() # needs sage.combinat (((),), ((1,3,2), (1,2,3)), ((2,3), (1,3), (1,2))) The trivial action of the symmetric group:: - sage: PermutationGroup(SymmetricGroup(3).gens(), action=lambda g, x: x, domain=[1]) + sage: PermutationGroup(SymmetricGroup(3).gens(), # needs sage.combinat + ....: action=lambda g, x: x, domain=[1]) Permutation Group with generators [()] """ def __init__(self, gens, action, domain, gap_group=None, category=None, canonicalize=None): @@ -5148,8 +5219,8 @@ def __init__(self, gens, action, domain, gap_group=None, category=None, canonica EXAMPLES:: sage: a = lambda x: (2*x) % 7 - sage: G = PermutationGroup(action=a, domain=range(7)) - sage: G.orbits() + sage: G = PermutationGroup(action=a, domain=range(7)) # needs sage.combinat + sage: G.orbits() # needs sage.combinat ((0,), (1, 2, 4), (3, 6, 5)) """ @@ -5189,8 +5260,8 @@ def orbits(self): EXAMPLES:: sage: a = lambda x: (2*x) % 7 - sage: G = PermutationGroup(action=a, domain=range(7)) - sage: G.orbits() + sage: G = PermutationGroup(action=a, domain=range(7)) # needs sage.combinat + sage: G.orbits() # needs sage.combinat ((0,), (1, 2, 4), (3, 6, 5)) """ return self._orbits diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index efc5e502cc0..2522b5c346d 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -115,19 +115,21 @@ from libc.stdlib cimport qsort from cysignals.memory cimport sig_malloc, sig_calloc, sig_realloc, sig_free from cpython.list cimport * -from cypari2.gen cimport Gen +try: + from cypari2.gen import Gen +except ImportError: + Gen = () from sage.ext.stdsage cimport HAS_DICTIONARY -from sage.rings.integer_ring import ZZ +from sage.interfaces.abc import GpElement from sage.rings.integer import Integer +from sage.rings.integer_ring import ZZ from sage.rings.polynomial.multi_polynomial import MPolynomial from sage.rings.polynomial.polynomial_element import Polynomial -from sage.structure.element import is_Matrix -from sage.matrix.matrix_space import MatrixSpace from sage.sets.finite_enumerated_set import FiniteEnumeratedSet -from sage.structure.richcmp cimport richcmp_not_equal, rich_to_bool from sage.structure.coerce cimport coercion_model -from sage.interfaces.abc import GpElement +from sage.structure.element import is_Matrix +from sage.structure.richcmp cimport richcmp_not_equal, rich_to_bool import sage.interfaces.abc @@ -151,8 +153,8 @@ cdef int etuple_index_cmp(const void * a, const void * b) nogil: return (( a)[0] > ( b)[0]) - (( a)[0] < ( b)[0]) def make_permgroup_element(G, x): - """ - Returns a PermutationGroupElement given the permutation group + r""" + Return a :class:`PermutationGroupElement` given the permutation group ``G`` and the permutation ``x`` in list notation. This is function is used when unpickling old (pre-domain) versions @@ -171,8 +173,8 @@ def make_permgroup_element(G, x): return make_permgroup_element_v2(G, x, domain) def make_permgroup_element_v2(G, x, domain): - """ - Returns a PermutationGroupElement given the permutation group + r""" + Return a :class:`PermutationGroupElement` given the permutation group ``G``, the permutation ``x`` in list notation, and the domain ``domain`` of the permutation group. @@ -198,8 +200,8 @@ def make_permgroup_element_v2(G, x, domain): return G.element_class(x, G, check=False) def is_PermutationGroupElement(x): - """ - Returns True if ``x`` is a PermutationGroupElement. + r""" + Return ``True`` if ``x`` is a :class:`PermutationGroupElement`. EXAMPLES:: @@ -211,13 +213,12 @@ def is_PermutationGroupElement(x): return isinstance(x, PermutationGroupElement) cdef class PermutationGroupElement(MultiplicativeGroupElement): - """ + r""" An element of a permutation group. EXAMPLES:: - sage: G = PermutationGroup(['(1,2,3)(4,5)']) - sage: G + sage: G = PermutationGroup(['(1,2,3)(4,5)']); G Permutation Group with generators [(1,2,3)(4,5)] sage: g = G.random_element() sage: g in G @@ -262,7 +263,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): There are several ways to define a permutation group element: - Define a permutation group `G`, then use - ``G.gens()`` and multiplication \* to construct + ``G.gens()`` and multiplication ``*`` to construct elements. - Define a permutation group `G`, then use, e.g., @@ -278,9 +279,9 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): - ``g`` -- defines element - ``parent`` -- defines parent group (``g`` must be in - parent if specified, or a ``TypeError`` is raised) + parent if specified, or a :class:`TypeError` is raised) - - ``check`` - bool (default: ``True``); if ``False`` assumes ``g`` + - ``check`` -- bool (default: ``True``); if ``False`` assumes ``g`` is a gap element in parent (if specified) @@ -310,8 +311,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): :: - sage: g = G([(1,2),(3,5,6)]) - sage: g + sage: g = G([(1,2),(3,5,6)]); g (1,2)(3,5,6) sage: g.parent() Permutation Group with generators [(1,2)(3,4), (3,4,5,6)] @@ -328,15 +328,14 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): True We can also make a permutation group element directly using the - ``PermutationGroupElement`` command. Note that the + :class:`PermutationGroupElement` command. Note that the parent is then the full symmetric group `S_n`, where `n` is the largest integer that is moved by the permutation. :: - sage: k = PermutationGroupElement('(1,2)(3,5,6)') - sage: k + sage: k = PermutationGroupElement('(1,2)(3,5,6)'); k (1,2)(3,5,6) sage: k.parent() Symmetric group of order 6! as a permutation group @@ -368,11 +367,11 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): sage: S = SymmetricGroup(5) sage: S(Permutation([5,1,4,3,2])) (1,5,2)(3,4) - sage: S(gp.Vecsmall([5,1,4,3,2])) + sage: S(gp.Vecsmall([5,1,4,3,2])) # needs sage.libs.pari (1,5,2)(3,4) sage: S(gap.PermList([5,1,4,3,2])) (1,5,2)(3,4) - sage: S(pari.Vecsmall([5,1,4,3,2])) + sage: S(pari.Vecsmall([5,1,4,3,2])) # needs sage.libs.pari (1,5,2)(3,4) sage: S(libgap.PermList([5,1,4,3,2])) (1,5,2)(3,4) @@ -794,7 +793,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def __reduce__(self): - """ + r""" Returns a function and its arguments needed to create this permutation group element. This is used in pickling. @@ -828,7 +827,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return other def _gap_(self, gap=None): - """ + r""" TESTS:: sage: g = PermutationGroupElement([(1,2,3),(4,5)]); g @@ -854,12 +853,14 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): sage: S(p_libgap) == p True + sage: # needs sage.rings.finite_rings sage: P = PGU(8,2) sage: p, q = P.gens() sage: p_libgap = p.gap() TESTS:: + sage: # needs sage.rings.finite_rings sage: P = PGU(8,2) sage: p, q = P.gens() sage: p_pexpect = gap(p) @@ -899,7 +900,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): gap = _libgap_ def _gap_init_(self): - """ + r""" Returns a GAP string representation for this PermutationGroupElement. @@ -911,9 +912,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): """ return 'PermList(%s)' % self._gap_list() - def _repr_(self): - """ + r""" Return string representation of this permutation. EXAMPLES: @@ -956,8 +956,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): for cycle in self.cycle_tuples()) def __getitem__(self, i): - """ - Return the ith permutation cycle in the disjoint cycle + r""" + Return the ``i``-th permutation cycle in the disjoint cycle representation of self. INPUT: @@ -978,7 +978,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return self.cycles()[i] cpdef _richcmp_(self, other, int op): - """ + r""" Compare group elements ``self`` and ``other``. EXAMPLES:: @@ -1024,7 +1024,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return rich_to_bool(op, 0) def __call__(self, i): - """ + r""" Returns the image of the integer i under this permutation. Alternately, if i is a list, tuple or string, returns the result of self acting on i. @@ -1046,7 +1046,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): :: - sage: g(x) + sage: g(x) # needs sage.symbolic Traceback (most recent call last): ... ValueError: must be in the domain or a list, tuple or string @@ -1087,7 +1087,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return from_gap[i] cpdef list _act_on_list_on_position(self, list x): - """ + r""" Returns the right action of ``self`` on the list ``x``. This is the action on positions. @@ -1115,7 +1115,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return [ x[self.perm[i]] for i in range(self.n) ] cpdef ClonableIntArray _act_on_array_on_position(self, ClonableIntArray x): - """ + r""" Returns the right action of ``self`` on the ClonableIntArray ``x``. This is the action on positions. @@ -1299,7 +1299,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return coercion_model.bin_op(left, right, operator.mul) cpdef _mul_(left, _right): - """ + r""" EXAMPLES:: sage: S = SymmetricGroup(['a', 'b']) @@ -1316,7 +1316,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return prod cpdef PermutationGroupElement _generate_new(self, list v): - """ + r""" Generate a new permutation group element with the same parent as ``self`` from ``v``. @@ -1334,7 +1334,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return new cpdef PermutationGroupElement _generate_new_GAP(self, lst_in): - """ + r""" Generate a new permutation group element with the same parent as ``self`` from the GAP list ``lst_in``. @@ -1367,7 +1367,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return new def __invert__(self): - """ + r""" Return the inverse of this permutation. EXAMPLES:: @@ -1385,7 +1385,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return inv cpdef _gap_list(self): - """ + r""" Returns this permutation in list notation compatible with the GAP numbering. @@ -1409,7 +1409,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return [self.perm[i]+1 for i from 0 <= i < self.n] def _gap_cycle_string(self): - """ + r""" Returns a cycle string for this permutation compatible with the GAP numbering. @@ -1433,8 +1433,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return Permutation(self._gap_list()).cycle_string() cpdef domain(self): - """ - Returns the domain of self. + r""" + Return the domain of ``self``. EXAMPLES:: @@ -1466,7 +1466,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return [from_gap[self.perm[i]+1] for i from 0 <= i < self.n] def __hash__(self): - """ + r""" Return a hash for this permutation. EXAMPLES:: @@ -1495,8 +1495,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return ans def tuple(self): - """ - Return tuple of images of the domain under self. + r""" + Return tuple of images of the domain under ``self``. EXAMPLES:: @@ -1517,8 +1517,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return tuple([from_gap[self.perm[i]+1] for i in range(self.n)]) def dict(self): - """ - Returns a dictionary associating each element of the domain with its + r""" + Return a dictionary associating each element of the domain with its image. EXAMPLES:: @@ -1541,7 +1541,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return {e:from_gap[self.perm[i-1]+1] for e,i in to_gap.iteritems()} def multiplicative_order(self): - """ + r""" Return the order of this group element, which is the smallest positive integer `n` for which `g^n = 1`. @@ -1551,13 +1551,14 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): sage: s.multiplicative_order() 6 - ``order`` is just an alias for ``multiplicative_order``:: + :meth:`order` is just an alias for :meth:`multiplicative_order`:: sage: s.order() 6 TESTS:: + sage: # needs sage.libs.pari sage: prod(primes(150)) 1492182350939279320058875736615841068547583863326864530410 sage: L = [tuple(range(sum(primes(p))+1, sum(primes(p))+1+p)) for p in primes(150)] @@ -1593,7 +1594,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def inverse(self): r""" - Returns the inverse permutation. + Return the inverse permutation. OUTPUT: @@ -1625,7 +1626,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def sign(self): r""" - Returns the sign of self, which is `(-1)^{s}`, where + Return the sign of ``self``, which is `(-1)^{s}`, where `s` is the number of swaps. EXAMPLES:: @@ -1661,8 +1662,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def orbit(self, n, bint sorted=True): - """ - Returns the orbit of the integer `n` under this group + r""" + Return the orbit of the integer `n` under this group element, as a sorted list. EXAMPLES:: @@ -1705,8 +1706,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return from_gap[n] def cycles(self): - """ - Return self as a list of disjoint cycles. + r""" + Return ``self`` as a list of disjoint cycles. EXAMPLES:: @@ -1740,13 +1741,13 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return L def cycle_tuples(self, singletons=False): - """ - Return self as a list of disjoint cycles, represented as tuples + r""" + Return ``self`` as a list of disjoint cycles, represented as tuples rather than permutation group elements. INPUT: - - ``singletons`` - boolean (default: False) whether or not consider the + - ``singletons`` -- boolean (default: ``False``) whether or not consider the cycle that correspond to fixed point EXAMPLES:: @@ -1799,10 +1800,10 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return L def cycle_string(self, singletons=False): - """ + r""" Return string representation of this permutation. - EXAMPLES:: + EXAMPLES:: sage: g = PermutationGroupElement([(1,2,3),(4,5)]) sage: g.cycle_string() @@ -1820,29 +1821,30 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): def cycle_type(self, singletons=True, as_list=False): r""" - Return the partition that gives the cycle type of ``g`` as an element of - ``self``. + Return the partition that gives the cycle type of ``self`` as an element of + its parent. INPUT: - ``g`` -- an element of the permutation group ``self.parent()`` - - ``singletons`` -- ``True`` or ``False`` depending on whether on or not + - ``singletons`` -- ``True`` or ``False`` depending on whether or not trivial cycles should be counted (default: ``True``) - ``as_list`` -- ``True`` or ``False`` depending on whether the cycle - type should be returned as a ``list`` or as a :class:`Partition` + type should be returned as a :class:`list` or as a :class:`Partition` (default: ``False``) OUTPUT: - A :class:`Partition`, or list if ``is_list`` is ``True``, - giving the cycle type of ``g`` + A :class:`Partition`, or :class:`list` if ``is_list`` is ``True``, + giving the cycle type of ``self`` - If speed is a concern then ``as_list=True`` should be used. + If speed is a concern, then ``as_list=True`` should be used. EXAMPLES:: + sage: # needs sage.combinat sage: G = DihedralGroup(3) sage: [g.cycle_type() for g in G] [[1, 1, 1], [3], [3], [2, 1], [2, 1], [2, 1]] @@ -1870,11 +1872,11 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): INPUT: - ``i`` -- an element of the index set - - ``side`` -- "left" or "right" (default: "right") - - ``positive`` -- a boolean (default: False) + - ``side`` -- ``"left"`` or ``"right"`` (default: ``"right"``) + - ``positive`` -- a boolean (default: ``False``) Returns whether ``self`` has a left (resp. right) descent at - position ``i``. If ``positive`` is True, then test for a non + position ``i``. If ``positive`` is ``True``, then test for a non descent instead. Beware that, since permutations are acting on the right, the @@ -1891,13 +1893,13 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): False sage: s = S.simple_reflections() sage: x = s[1]*s[2] - sage: x.has_descent(1, side = "right") + sage: x.has_descent(1, side="right") False - sage: x.has_descent(2, side = "right") + sage: x.has_descent(2, side="right") True - sage: x.has_descent(1, side = "left") + sage: x.has_descent(1, side="left") True - sage: x.has_descent(2, side = "left") + sage: x.has_descent(2, side="left") False sage: S._test_has_descent() @@ -1924,9 +1926,9 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return (to_gap[self(i)] > to_gap[self(i1)]) is not positive def matrix(self): - """ - Returns deg x deg permutation matrix associated to the permutation - self + r""" + Return a deg `\times` deg permutation matrix associated to the permutation + ``self``. EXAMPLES:: @@ -1939,6 +1941,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): [0 0 0 0 1] [0 0 0 1 0] """ + from sage.matrix.matrix_space import MatrixSpace M = MatrixSpace(ZZ, self.n, self.n, sparse=True) cdef int i entries = {} @@ -1947,7 +1950,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): return M(entries) def word_problem(self, words, display=True, as_list=False): - """ + r""" Try to solve the word problem for ``self``. INPUT: @@ -1979,8 +1982,8 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): This function does not solve the word problem in Sage. Rather it pushes it over to GAP, which has optimized algorithms for the word problem. Essentially, this function is a wrapper for the GAP - functions "EpimorphismFromFreeGroup" and - "PreImagesRepresentative". + functions ``EpimorphismFromFreeGroup`` and + ``PreImagesRepresentative``. EXAMPLES:: @@ -2045,11 +2048,11 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): cdef class SymmetricGroupElement(PermutationGroupElement): - """ + r""" An element of the symmetric group. """ def absolute_length(self): - """ + r""" Return the absolute length of ``self``. The absolute length is the size minus the number of its disjoint @@ -2063,14 +2066,14 @@ cdef class SymmetricGroupElement(PermutationGroupElement): EXAMPLES:: sage: S = SymmetricGroup(3) - sage: [x.absolute_length() for x in S] + sage: [x.absolute_length() for x in S] # needs sage.combinat [0, 2, 2, 1, 1, 1] """ from sage.combinat.permutation import Permutation return Permutation(self).absolute_length() def has_left_descent(self, i): - """ + r""" Return whether `i` is a left descent of ``self``. EXAMPLES:: @@ -2084,7 +2087,7 @@ cdef class SymmetricGroupElement(PermutationGroupElement): cdef bint is_valid_permutation(int* perm, int n): - """ + r""" This is used in the __init__ method. Returns True iff the first n elements of perm are literally a diff --git a/src/sage/groups/perm_gps/permgroup_morphism.py b/src/sage/groups/perm_gps/permgroup_morphism.py index 917ddd01865..0a86068790b 100644 --- a/src/sage/groups/perm_gps/permgroup_morphism.py +++ b/src/sage/groups/perm_gps/permgroup_morphism.py @@ -15,7 +15,8 @@ sage: g = G([(1,2,3,4)]) sage: phi = PermutationGroupMorphism_im_gens(G, H, map(H, G.gens())) sage: phi.image(G) - Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group) + Subgroup generated by [(1,2,3,4)] of + (Dihedral group of order 8 as a permutation group) sage: phi.kernel() Subgroup generated by [()] of (Cyclic group of order 4 as a permutation group) sage: phi.image(g) @@ -42,11 +43,11 @@ class PermutationGroupMorphism(Morphism): - """ + r""" A set-theoretic map between PermutationGroups. """ def _repr_type(self): - """ + r""" Return the type of this morphism. This is used for printing the morphism. @@ -61,7 +62,7 @@ def _repr_type(self): return "Permutation group" def kernel(self): - """ + r""" Return the kernel of this homomorphism as a permutation group. EXAMPLES:: @@ -71,7 +72,8 @@ def kernel(self): sage: g = G([(1,2,3,4)]) sage: phi = PermutationGroupMorphism_im_gens(G, H, [1]) sage: phi.kernel() - Subgroup generated by [(1,2,3,4)] of (Cyclic group of order 4 as a permutation group) + Subgroup generated by [(1,2,3,4)] of + (Cyclic group of order 4 as a permutation group) :: @@ -85,9 +87,10 @@ def kernel(self): return self.domain().subgroup(gap_group=self._gap_().Kernel()) def image(self, J): - """ - J must be a subgroup of G. Computes the subgroup of H which is the - image of J. + r""" + Compute the subgroup of the codomain `H` which is the image of `J`. + + `J` must be a subgroup of the domain `G`. EXAMPLES:: @@ -96,7 +99,8 @@ def image(self, J): sage: g = G([(1,2,3,4)]) sage: phi = PermutationGroupMorphism_im_gens(G, H, map(H, G.gens())) sage: phi.image(G) - Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group) + Subgroup generated by [(1,2,3,4)] of + (Dihedral group of order 8 as a permutation group) sage: phi.image(g) (1,2,3,4) @@ -107,12 +111,14 @@ def image(self, J): sage: H = D[0] sage: pr1 = D[3] sage: pr1.image(G) - Subgroup generated by [(3,7,5)(4,8,6), (1,2,6)(3,4,8)] of (The projective special linear group of degree 2 over Finite Field of size 7) + Subgroup generated by [(3,7,5)(4,8,6), (1,2,6)(3,4,8)] of + (The projective special linear group of degree 2 over Finite Field of size 7) sage: G.is_isomorphic(pr1.image(G)) True Check that :trac:`28324` is fixed:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: f = x^4 + x^2 - 3 sage: L. = f.splitting_field() @@ -134,9 +140,9 @@ def image(self, J): return H.subgroup(gap_group=G) def __call__(self, g): - """ - Some python code for wrapping GAP's Images function but only for - permutation groups. This returns an error if g is not in G. + r""" + Some python code for wrapping GAP's ``Images`` function but only for + permutation groups. This raises an error if g is not in G. EXAMPLES:: @@ -157,18 +163,18 @@ class PermutationGroupMorphism_id(PermutationGroupMorphism): class PermutationGroupMorphism_from_gap(PermutationGroupMorphism): def __init__(self, G, H, gap_hom): - """ + r""" This is a Python trick to allow Sage programmers to create a group homomorphism using GAP using very general constructions. An example of its usage is in the direct_product instance method of the - PermutationGroup_generic class in permgroup.py. + :class:`PermutationGroup_generic` class in permgroup.py. Basic syntax: - PermutationGroupMorphism_from_gap(domain_group, - range_group,'phi:=gap_hom_command;','phi') And don't forget the - line: from sage.groups.perm_gps.permgroup_morphism import - PermutationGroupMorphism_from_gap in your program. + ``PermutationGroupMorphism_from_gap(domain_group, + range_group, 'phi:=gap_hom_command;', 'phi')``. And don't forget the + line: ``from sage.groups.perm_gps.permgroup_morphism import + PermutationGroupMorphism_from_gap`` in your program. EXAMPLES:: @@ -177,7 +183,8 @@ def __init__(self, G, H, gap_hom): sage: H = G.subgroup([G([(1,2,3,4)])]) sage: PermutationGroupMorphism_from_gap(H, G, gap.Identity) Permutation group morphism: - From: Subgroup generated by [(1,2,3,4)] of (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) + From: Subgroup generated by [(1,2,3,4)] of + (Permutation Group with generators [(1,2)(3,4), (1,2,3,4)]) To: Permutation Group with generators [(1,2)(3,4), (1,2,3,4)] Defn: Identity """ @@ -187,7 +194,7 @@ def __init__(self, G, H, gap_hom): self._gap_hom = gap_hom def _repr_defn(self): - """ + r""" Return the definition of this morphism. This is used when printing the morphism. @@ -204,7 +211,7 @@ def _repr_defn(self): return str(self._gap_hom).replace('\n', '') def _gap_(self, gap=None): - """ + r""" Return a GAP version of this morphism. EXAMPLES:: @@ -219,7 +226,7 @@ def _gap_(self, gap=None): return self._gap_hom def __call__(self, g): - """ + r""" Some python code for wrapping GAP's Images function but only for permutation groups. This returns an error if g is not in G. @@ -237,8 +244,8 @@ def __call__(self, g): class PermutationGroupMorphism_im_gens(PermutationGroupMorphism): def __init__(self, G, H, gens=None): - """ - Some python code for wrapping GAP's GroupHomomorphismByImages + r""" + Some python code for wrapping GAP's ``GroupHomomorphismByImages`` function but only for permutation groups. Can be expensive if G is large. This returns "fail" if gens does not generate self or if the map does not extend to a group homomorphism, self - other. @@ -273,7 +280,7 @@ def __init__(self, G, H, gens=None): self._images = [H(img) for img in gens] def _repr_defn(self): - """ + r""" Return the definition of this morphism. This is used when printing the morphism. @@ -289,7 +296,7 @@ def _repr_defn(self): return "%s -> %s" % (list(self.domain().gens()), self._images) def _gap_(self): - """ + r""" Return a GAP representation of this morphism. EXAMPLES:: @@ -305,8 +312,8 @@ def _gap_(self): def is_PermutationGroupMorphism(f) -> bool: - """ - Return True if the argument ``f`` is a PermutationGroupMorphism. + r""" + Return ``True`` if the argument ``f`` is a :class:`PermutationGroupMorphism`. EXAMPLES:: diff --git a/src/sage/groups/perm_gps/permgroup_named.py b/src/sage/groups/perm_gps/permgroup_named.py index 7b3d4947f75..75e26765b3a 100644 --- a/src/sage/groups/perm_gps/permgroup_named.py +++ b/src/sage/groups/perm_gps/permgroup_named.py @@ -3,65 +3,64 @@ You can construct the following permutation groups: --- SymmetricGroup, `S_n` of order `n!` (n can also be a list `X` of distinct - positive integers, in which case it returns `S_X`) +- :class:`SymmetricGroup`, `S_n` of order `n!` (`n` can also be a list `X` of distinct + positive integers, in which case it returns `S_X`) --- AlternatingGroup, `A_n` of order `n!/2` (n can also be a list `X` - of distinct positive integers, in which case it returns - `A_X`) +- :class:`AlternatingGroup`, `A_n` of order `n!/2` (n can also be a list `X` + of distinct positive integers, in which case it returns `A_X`) --- DihedralGroup, `D_n` of order `2n` +- :class:`DihedralGroup`, `D_n` of order `2n` --- GeneralDihedralGroup, `Dih(G)`, where G is an abelian group +- :class:`GeneralDihedralGroup`, `Dih(G)`, where `G` is an abelian group --- CyclicPermutationGroup, `C_n` of order `n` +- :class:`CyclicPermutationGroup`, `C_n` of order `n` --- DiCyclicGroup, nonabelian groups of order `4m` with a unique element of order 2 +- :class:`DiCyclicGroup`, nonabelian groups of order `4m` with a unique element of order 2 --- TransitiveGroup, `n^{th}` transitive group of degree `d` - from the GAP tables of transitive groups +- :class:`TransitiveGroup`, `n`-th` transitive group of degree `d` + from the GAP tables of transitive groups --- TransitiveGroups(d), TransitiveGroups(), set of all of the above +- ``TransitiveGroups(d)``, ``TransitiveGroups()``, set of all of the above --- PrimitiveGroup, `n^{th}` primitive group of degree `d` - from the GAP tables of primitive groups +- :class:`PrimitiveGroup`, `n`-th` primitive group of degree `d` + from the GAP tables of primitive groups --- PrimitiveGroups(d), PrimitiveGroups(), set of all of the above +- ``PrimitiveGroups(d)``, ``PrimitiveGroups()``, set of all of the above --- MathieuGroup(degree), Mathieu group of degree 9, 10, 11, 12, 21, 22, 23, or 24. +- ``MathieuGroup(degree)``, Mathieu group of degree 9, 10, 11, 12, 21, 22, 23, or 24. --- KleinFourGroup, subgroup of `S_4` of order `4` which is not `C_2 \times C_2` +- :class:`KleinFourGroup`, subgroup of `S_4` of order `4` which is not `C_2 \times C_2` --- QuaternionGroup, non-abelian group of order `8`, `\{\pm 1, \pm I, \pm J, \pm K\}` +- :class:`QuaternionGroup`, non-abelian group of order `8`, `\{\pm 1, \pm I, \pm J, \pm K\}` --- SplitMetacyclicGroup, nonabelian groups of order `p^m` with cyclic -subgroups of index p +- :class:`SplitMetacyclicGroup`, nonabelian groups of order `p^m` with cyclic + subgroups of index p --- SemidihedralGroup, nonabelian 2-groups with cyclic subgroups of index 2 +- :class:`SemidihedralGroup`, nonabelian 2-groups with cyclic subgroups of index 2 --- PGL(n,q), projective general linear group of `n\times n` matrices over - the finite field GF(q) +- ``PGL(n,q)``, projective general linear group of `n\times n` matrices over + the finite field `\GF(q)` --- PSL(n,q), projective special linear group of `n\times n` matrices over - the finite field GF(q) +- ``PSL(n,q)``, projective special linear group of `n\times n` matrices over + the finite field `\GF(q)` --- PSp(2n,q), projective symplectic linear group of `2n\times 2n` matrices - over the finite field GF(q) +- ``PSp(2n,q)``, projective symplectic linear group of `2n\times 2n` matrices + over the finite field `\GF(q)` --- PSU(n,q), projective special unitary group of `n \times n` matrices having - coefficients in the finite field `GF(q^2)` that respect a - fixed nondegenerate sesquilinear form, of determinant 1. +- ``PSU(n,q)``, projective special unitary group of `n \times n` matrices having + coefficients in the finite field `\GF(q^2)` that respect a + fixed nondegenerate sesquilinear form, of determinant 1. --- PGU(n,q), projective general unitary group of `n\times n` matrices having - coefficients in the finite field `GF(q^2)` that respect a - fixed nondegenerate sesquilinear form, modulo the centre. +- ``PGU(n,q)``, projective general unitary group of `n\times n` matrices having + coefficients in the finite field `\GF(q^2)` that respect a + fixed nondegenerate sesquilinear form, modulo the centre. --- SuzukiGroup(q), Suzuki group over GF(q), `^2 B_2(2^{2k+1}) = Sz(2^{2k+1})`. +- ``SuzukiGroup(q)``, Suzuki group over `\GF(q)`, `^2 B_2(2^{2k+1}) = Sz(2^{2k+1})`. --- ComplexReflectionGroup, the complex reflection group `G(m, p, n)` or - the exceptional complex reflection group `G_m` +- :class:`ComplexReflectionGroup`, the complex reflection group `G(m, p, n)` or + the exceptional complex reflection group `G_m` --- SmallPermutationGroup, a permutation realization of an group specified by its GAP id. +- :class:`SmallPermutationGroup`, a permutation realization of a group specified by its GAP id. AUTHOR: @@ -148,7 +147,7 @@ def __classcall__(cls, *args, **kwds): class PermutationGroup_symalt(PermutationGroup_unique): """ This is a class used to factor out some of the commonality - in the SymmetricGroup and AlternatingGroup classes. + in the :class:`SymmetricGroup` and :class:`AlternatingGroup` classes. """ @staticmethod @@ -251,9 +250,9 @@ def __init__(self, domain=None): TESTS:: - sage: TestSuite(SymmetricGroup(0)).run() - sage: TestSuite(SymmetricGroup(1)).run() - sage: TestSuite(SymmetricGroup(3)).run() + sage: TestSuite(SymmetricGroup(0)).run() # needs sage.rings.number_field + sage: TestSuite(SymmetricGroup(1)).run() # needs sage.rings.number_field + sage: TestSuite(SymmetricGroup(3)).run() # needs sage.rings.number_field """ from sage.categories.finite_weyl_groups import FiniteWeylGroups from sage.categories.finite_permutation_groups import FinitePermutationGroups @@ -339,14 +338,14 @@ def _coerce_map_from_(self, G): EXAMPLES:: - sage: J3 = groups.misc.Cactus(3) + sage: J3 = groups.misc.Cactus(3) # needs sage.rings.number_field sage: S5 = SymmetricGroup(5) - sage: S5.coerce_map_from(J3) + sage: S5.coerce_map_from(J3) # needs sage.rings.number_field Conversion via _from_cactus_group_element map: From: Cactus Group with 3 fruit To: Symmetric group of order 5! as a permutation group sage: S2 = SymmetricGroup(2) - sage: S2._coerce_map_from_(J3) is None + sage: S2._coerce_map_from_(J3) is None # needs sage.rings.number_field True """ from sage.groups.cactus_group import CactusGroup @@ -360,6 +359,7 @@ def _from_cactus_group_element(self, x): EXAMPLES:: + sage: # needs sage.rings.number_field sage: J3 = groups.misc.Cactus(3) sage: s12,s13,s23 = J3.gens() sage: elt = s12*s23*s13 @@ -392,7 +392,7 @@ def coxeter_matrix(self): EXAMPLES:: - sage: A = SymmetricGroup([2,3,7,'a']); A.coxeter_matrix() + sage: A = SymmetricGroup([2,3,7,'a']); A.coxeter_matrix() # needs sage.graphs [1 3 2] [3 1 3] [2 3 1] @@ -401,7 +401,7 @@ def coxeter_matrix(self): def simple_reflection(self, i): r""" - For `i` in the index set of ``self``, this returns the + For `i` in the index set of ``self``, return the elementary transposition `s_i = (i,i+1)`. EXAMPLES:: @@ -439,11 +439,13 @@ def young_subgroup(self, comp): sage: S = SymmetricGroup(8) sage: c = Composition([2,2,2,2]) sage: S.young_subgroup(c) - Subgroup generated by [(7,8), (5,6), (3,4), (1,2)] of (Symmetric group of order 8! as a permutation group) + Subgroup generated by [(7,8), (5,6), (3,4), (1,2)] of + (Symmetric group of order 8! as a permutation group) sage: S = SymmetricGroup(['a','b','c']) sage: S.young_subgroup([2,1]) - Subgroup generated by [('a','b')] of (Symmetric group of order 3! as a permutation group) + Subgroup generated by [('a','b')] of + (Symmetric group of order 3! as a permutation group) sage: Y = S.young_subgroup([2,2,2,2,2]) Traceback (most recent call last): @@ -483,10 +485,10 @@ def major_index(self, parameter=None): EXAMPLES:: sage: S4 = SymmetricGroup(4) - sage: S4.major_index() + sage: S4.major_index() # needs sage.combinat q^6 + 3*q^5 + 5*q^4 + 6*q^3 + 5*q^2 + 3*q + 1 sage: K. = QQ[] - sage: S4.major_index(t) + sage: S4.major_index(t) # needs sage.combinat t^6 + 3*t^5 + 5*t^4 + 6*t^3 + 5*t^2 + 3*t + 1 """ from sage.combinat.q_analogues import q_factorial @@ -505,14 +507,14 @@ def conjugacy_classes_representatives(self): EXAMPLES:: sage: G = SymmetricGroup(5) - sage: G.conjugacy_classes_representatives() + sage: G.conjugacy_classes_representatives() # needs sage.combinat [(), (1,2), (1,2)(3,4), (1,2,3), (1,2,3)(4,5), (1,2,3,4), (1,2,3,4,5)] :: sage: S = SymmetricGroup(['a','b','c']) - sage: S.conjugacy_classes_representatives() + sage: S.conjugacy_classes_representatives() # needs sage.combinat [(), ('a','b'), ('a','b','c')] TESTS: @@ -520,10 +522,10 @@ def conjugacy_classes_representatives(self): Check some border cases:: sage: S = SymmetricGroup(0) - sage: S.conjugacy_classes_representatives() + sage: S.conjugacy_classes_representatives() # needs sage.combinat [()] sage: S = SymmetricGroup(1) - sage: S.conjugacy_classes_representatives() + sage: S.conjugacy_classes_representatives() # needs sage.combinat [()] """ from sage.combinat.partition import Partitions_n @@ -539,7 +541,7 @@ def conjugacy_classes_iterator(self): EXAMPLES:: sage: G = SymmetricGroup(5) - sage: list(G.conjugacy_classes_iterator()) == G.conjugacy_classes() + sage: list(G.conjugacy_classes_iterator()) == G.conjugacy_classes() # needs sage.combinat True """ from sage.combinat.partition import Partitions_n @@ -555,7 +557,7 @@ def conjugacy_classes(self): EXAMPLES:: sage: G = SymmetricGroup(5) - sage: G.conjugacy_classes() + sage: G.conjugacy_classes() # needs sage.combinat [Conjugacy class of cycle type [1, 1, 1, 1, 1] in Symmetric group of order 5! as a permutation group, Conjugacy class of cycle type [2, 1, 1, 1] in @@ -590,7 +592,7 @@ def conjugacy_class(self, g): sage: G = SymmetricGroup(5) sage: g = G((1,2,3,4)) - sage: G.conjugacy_class(g) + sage: G.conjugacy_class(g) # needs sage.combinat Conjugacy class of cycle type [4, 1] in Symmetric group of order 5! as a permutation group """ @@ -614,37 +616,37 @@ def algebra(self, base_ring, category=None): EXAMPLES:: sage: S4 = SymmetricGroup(4) - sage: S4.algebra(QQ) + sage: S4.algebra(QQ) # needs sage.combinat Symmetric group algebra of order 4 over Rational Field sage: S3 = SymmetricGroup([1,2,3]) - sage: A = S3.algebra(QQ); A + sage: A = S3.algebra(QQ); A # needs sage.combinat Symmetric group algebra of order 3 over Rational Field sage: a = S3.an_element(); a (2,3) - sage: A(a) + sage: A(a) # needs sage.combinat (2,3) We illustrate the choice of the category:: - sage: A.category() + sage: A.category() # needs sage.combinat Join of Category of coxeter group algebras over Rational Field and Category of finite group algebras over Rational Field and Category of finite dimensional cellular algebras with basis over Rational Field - sage: A = S3.algebra(QQ, category=Semigroups()) - sage: A.category() + sage: A = S3.algebra(QQ, category=Semigroups()) # needs sage.combinat + sage: A.category() # needs sage.combinat Category of finite dimensional unital cellular semigroup algebras over Rational Field In the following case, a usual group algebra is returned:: sage: S = SymmetricGroup([2,3,5]) - sage: S.algebra(QQ) + sage: S.algebra(QQ) # needs sage.combinat Algebra of Symmetric group of order 3! as a permutation group over Rational Field sage: a = S.an_element(); a (3,5) - sage: S.algebra(QQ)(a) + sage: S.algebra(QQ)(a) # needs sage.combinat (3,5) """ from sage.combinat.symmetric_group_algebra import SymmetricGroupAlgebra @@ -725,11 +727,11 @@ def _gap_init_(self, gap=None): class CyclicPermutationGroup(PermutationGroup_unique): def __init__(self, n): """ - A cyclic group of order n, as a permutation group. + A cyclic group of order `n`, as a permutation group. INPUT: - n -- a positive integer + - ``n`` -- a positive integer .. note:: @@ -774,7 +776,7 @@ def _repr_(self): def is_commutative(self): """ - Return True if this group is commutative. + Return ``True`` if this group is commutative. EXAMPLES:: @@ -786,7 +788,7 @@ def is_commutative(self): def is_abelian(self): """ - Return True if this group is abelian. + Return ``True`` if this group is abelian. EXAMPLES:: @@ -798,7 +800,7 @@ def is_abelian(self): def as_AbelianGroup(self): """ - Returns the corresponding Abelian Group instance. + Return the corresponding :class:`AbelianGroup` instance. EXAMPLES:: @@ -819,7 +821,7 @@ class DiCyclicGroup(PermutationGroup_unique): INPUT: - - n -- a positive integer, two or greater + - ``n`` -- a positive integer, two or greater OUTPUT: @@ -1127,7 +1129,7 @@ class QuaternionGroup(DiCyclicGroup): OUTPUT: The quaternion group of order 8, as a permutation group. - See the ``DiCyclicGroup`` class for a generalization of this + See the :class:`DiCyclicGroup` class for a generalization of this construction. .. note:: @@ -1198,7 +1200,7 @@ class GeneralDihedralGroup(PermutationGroup_generic): INPUT: - - ``factors`` - a list of the sizes of the cyclic factors of the + - ``factors`` -- a list of the sizes of the cyclic factors of the abelian group being dihedralized (this will be sorted once entered) @@ -1266,7 +1268,7 @@ class GeneralDihedralGroup(PermutationGroup_generic): If two nonidentical input lists generate isomorphic abelian groups, then they will generate identical groups (with each direct factor broken up into its prime factors), but they will still have - distinct descriptions. Note that If `gcd(n,m)=1`, then `C_n \times + distinct descriptions. Note that if `\gcd(n,m)=1`, then `C_n \times C_m \cong C_{nm}`, while the general dihedral groups generated by isomorphic abelian groups should be themselves isomorphic. :: @@ -1433,7 +1435,8 @@ def __init__(self, n): sage: DihedralGroup(5).gens() ((1,2,3,4,5), (1,5)(2,4)) sage: sorted(DihedralGroup(5)) - [(), (2,5)(3,4), (1,2)(3,5), (1,2,3,4,5), (1,3)(4,5), (1,3,5,2,4), (1,4)(2,3), (1,4,2,5,3), (1,5,4,3,2), (1,5)(2,4)] + [(), (2,5)(3,4), (1,2)(3,5), (1,2,3,4,5), (1,3)(4,5), (1,3,5,2,4), + (1,4)(2,3), (1,4,2,5,3), (1,5,4,3,2), (1,5)(2,4)] sage: G = DihedralGroup(6) sage: G.order() @@ -1644,7 +1647,7 @@ def __init__(self, m): INPUT: - - ``m`` - a positive integer; the power of 2 that is the + - ``m`` -- a positive integer; the power of 2 that is the group's order OUTPUT: @@ -1754,11 +1757,11 @@ def __init__(self, n): INPUT: - n -- a positive integer in {9, 10, 11, 12, 21, 22, 23, 24}. + - ``n`` -- a positive integer in {9, 10, 11, 12, 21, 22, 23, 24}. OUTPUT: - the Mathieu group of degree n, as a permutation group + the Mathieu group of degree `n`, as a permutation group .. note:: @@ -1766,8 +1769,7 @@ def __init__(self, n): EXAMPLES:: - sage: G = MathieuGroup(12) - sage: G + sage: G = MathieuGroup(12); G Mathieu group of degree 12 and order 95040 as a permutation group TESTS:: @@ -1807,13 +1809,13 @@ def __init__(self, d, n): INPUT: - - d -- non-negative integer; the degree - - n -- positive integer; the index of the group in the GAP database, + - ``d`` -- non-negative integer; the degree + - ``n`` -- positive integer; the index of the group in the GAP database, starting at 1 OUTPUT: - the n-th transitive group of degree d + the `n`-th transitive group of degree `d` .. note:: @@ -1847,7 +1849,8 @@ def __init__(self, d, n): sage: TransitiveGroup(32,1) Traceback (most recent call last): ... - NotImplementedError: only the transitive groups of degree at most 31 are available in GAP's database + NotImplementedError: only the transitive groups of degree at most 31 + are available in GAP's database TESTS:: @@ -1915,7 +1918,7 @@ def TransitiveGroups(d=None): - ``d`` -- an integer (optional) - Returns the set of all transitive groups of a given degree + Return the set of all transitive groups of a given degree ``d`` up to isomorphisms. If ``d`` is not specified, it returns the set of all transitive groups up to isomorphisms. @@ -1937,7 +1940,8 @@ def TransitiveGroups(d=None): sage: TransitiveGroups(32).cardinality() Traceback (most recent call last): ... - NotImplementedError: only the transitive groups of degree at most 31 are available in GAP's database + NotImplementedError: only the transitive groups of degree at most 31 + are available in GAP's database """ if d is None: @@ -2167,7 +2171,8 @@ def cardinality(self): sage: TransitiveGroups(32).cardinality() Traceback (most recent call last): ... - NotImplementedError: only the transitive groups of degree at most 31 are available in GAP's database + NotImplementedError: only the transitive groups of degree at most 31 + are available in GAP's database TESTS:: @@ -2617,18 +2622,18 @@ def matrix_degree(self): class PGL(PermutationGroup_plg): def __init__(self, n, q, name='a'): - """ - The projective general linear groups over GF(q). + r""" + The projective general linear groups over `\GF(q)`. INPUT: - - n -- positive integer; the degree - - q -- prime power; the size of the ground field - - name -- (default: 'a') variable name of indeterminate of finite field GF(q) + - ``n`` -- positive integer; the degree + - ``q`` -- prime power; the size of the ground field + - ``name`` -- (default: ``'a'``) variable name of indeterminate of finite field `\GF(q)` OUTPUT: - PGL(n,q) + PGL(`n`, `q`) .. note:: @@ -2645,7 +2650,7 @@ def __init__(self, n, q, name='a'): sage: G.order() 24 - sage: G = PGL(2, 9, 'b'); G + sage: G = PGL(2, 9, 'b'); G # needs sage.rings.finite_rings Permutation Group with generators [(3,10,9,8,4,7,6,5), (1,2,4)(5,6,8)(7,9,10)] sage: G.base_ring() Finite Field in b of size 3^2 @@ -2679,18 +2684,18 @@ def __str__(self): class PSL(PermutationGroup_plg): def __init__(self, n, q, name='a'): - """ - The projective special linear groups over GF(q). + r""" + The projective special linear groups over `\GF(q)`. INPUT: - - n -- positive integer; the degree - - q -- either a prime power (the size of the ground field) or a finite field - - name -- (default: 'a') variable name of indeterminate of finite field GF(q) + - ``n`` -- positive integer; the degree + - ``q`` -- either a prime power (the size of the ground field) or a finite field + - ``name`` -- (default: ``'a'``) variable name of indeterminate of finite field `\GF(q)` OUTPUT: - the group PSL(n,q) + the group PSL(`n`, `q`) .. note:: @@ -2709,11 +2714,11 @@ def __init__(self, n, q, name='a'): We create two groups over nontrivial finite fields:: - sage: G = PSL(2, 4, 'b'); G + sage: G = PSL(2, 4, 'b'); G # needs sage.rings.finite_rings Permutation Group with generators [(3,4,5), (1,2,3)] sage: G.base_ring() Finite Field in b of size 2^2 - sage: G = PSL(2, 8); G + sage: G = PSL(2, 8); G # needs sage.rings.finite_rings Permutation Group with generators [(3,8,6,4,9,7,5), (1,2,3)(4,7,5)(6,9,8)] sage: G.base_ring() Finite Field in a of size 2^3 @@ -2766,7 +2771,7 @@ def __str__(self): def ramification_module_decomposition_hurwitz_curve(self): r""" Helps compute the decomposition of the ramification module - for the Hurwitz curves X (over CC say) with automorphism group + for the Hurwitz curves X (over `\CC` say) with automorphism group G = PSL(2,q), q a "Hurwitz prime" (ie, p is `\pm 1 \pmod 7`). Using this computation and Borne's formula helps determine the G-module structure of the RR spaces of equivariant @@ -2779,9 +2784,11 @@ def ramification_module_decomposition_hurwitz_curve(self): Here IrrRepns(G) = [pi_1,...,pi_n] (in the order listed in the output of self.character_table()). - REFERENCE: David Joyner, Amy Ksir, Roger Vogeler, - "Group representations on Riemann-Roch spaces of some - Hurwitz curves," preprint, 2006. + REFERENCE: + + David Joyner, Amy Ksir, Roger Vogeler, + "Group representations on Riemann-Roch spaces of some + Hurwitz curves," preprint, 2006. EXAMPLES:: @@ -2813,7 +2820,7 @@ def ramification_module_decomposition_hurwitz_curve(self): return mults.sage() def ramification_module_decomposition_modular_curve(self): - """ + r""" Helps compute the decomposition of the ramification module for the modular curve X(p) (over CC say) with automorphism group G = PSL(2,q), q a prime > 5. Using this computation and Borne's formula helps determine the @@ -2859,18 +2866,18 @@ def ramification_module_decomposition_modular_curve(self): class PSp(PermutationGroup_plg): def __init__(self, n, q, name='a'): - """ - The projective symplectic linear groups over GF(q). + r""" + The projective symplectic linear groups over `\GF(q)`. INPUT: - - n -- positive integer; the degree - - q -- prime power; the size of the ground field - - name -- (default: 'a') variable name of indeterminate of finite field GF(q) + - ``n`` -- positive integer; the degree + - ``q`` -- prime power; the size of the ground field + - ``name`` -- (default: ``'a'``) variable name of indeterminate of finite field `\GF(q)` OUTPUT: - PSp(n,q) + PSp(`n`, `q`) .. note:: @@ -2891,7 +2898,7 @@ def __init__(self, n, q, name='a'): sage: G.base_ring() Finite Field of size 3 - sage: G = PSp(2, 8, name='alpha'); G + sage: G = PSp(2, 8, name='alpha'); G # needs sage.rings.finite_rings Permutation Group with generators [(3,8,6,4,9,7,5), (1,2,3)(4,7,5)(6,9,8)] sage: G.base_ring() Finite Field in alpha of size 2^3 @@ -2929,7 +2936,7 @@ def field_of_definition(self): """ EXAMPLES:: - sage: PSU(2,3).field_of_definition() + sage: PSU(2,3).field_of_definition() # needs sage.rings.finite_rings Finite Field in a of size 3^2 """ return self._field_of_definition @@ -2937,8 +2944,8 @@ def field_of_definition(self): class PSU(PermutationGroup_pug): def __init__(self, n, q, name='a'): - """ - The projective special unitary groups over GF(q). + r""" + The projective special unitary groups over `\GF(q)`. INPUT: @@ -2956,17 +2963,17 @@ def __init__(self, n, q, name='a'): EXAMPLES:: - sage: PSU(2,3) + sage: PSU(2,3) # needs sage.rings.finite_rings The projective special unitary group of degree 2 over Finite Field of size 3 - sage: G = PSU(2, 8, name='alpha'); G + sage: G = PSU(2, 8, name='alpha'); G # needs sage.rings.finite_rings The projective special unitary group of degree 2 over Finite Field in alpha of size 2^3 - sage: G.base_ring() + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in alpha of size 2^3 TESTS:: - sage: groups.permutation.PSU(2, 3) + sage: groups.permutation.PSU(2, 3) # needs sage.rings.finite_rings The projective special unitary group of degree 2 over Finite Field of size 3 """ id = 'PSU(%s,%s)' % (n, q) @@ -2980,7 +2987,7 @@ def _repr_(self): """ EXAMPLES:: - sage: PSU(2,3) + sage: PSU(2,3) # needs sage.rings.finite_rings The projective special unitary group of degree 2 over Finite Field of size 3 """ @@ -2989,18 +2996,18 @@ def _repr_(self): class PGU(PermutationGroup_pug): def __init__(self, n, q, name='a'): - """ - The projective general unitary groups over GF(q). + r""" + The projective general unitary groups over `\GF(q)`. INPUT: - - n -- positive integer; the degree - - q -- prime power; the size of the ground field - - name -- (default: 'a') variable name of indeterminate of finite field GF(q) + - ``n`` -- positive integer; the degree + - ``q`` -- prime power; the size of the ground field + - ``name`` -- (default: ``'a'``) variable name of indeterminate of finite field `\GF(q)` OUTPUT: - PGU(n,q) + PGU(`n`, `q`) .. note:: @@ -3008,17 +3015,18 @@ def __init__(self, n, q, name='a'): EXAMPLES:: - sage: PGU(2,3) + sage: PGU(2,3) # needs sage.rings.finite_rings The projective general unitary group of degree 2 over Finite Field of size 3 - sage: G = PGU(2, 8, name='alpha'); G - The projective general unitary group of degree 2 over Finite Field in alpha of size 2^3 - sage: G.base_ring() + sage: G = PGU(2, 8, name='alpha'); G # needs sage.rings.finite_rings + The projective general unitary group of degree 2 + over Finite Field in alpha of size 2^3 + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in alpha of size 2^3 TESTS:: - sage: groups.permutation.PGU(2, 3) + sage: groups.permutation.PGU(2, 3) # needs sage.rings.finite_rings The projective general unitary group of degree 2 over Finite Field of size 3 """ id = 'PGU(%s,%s)' % (n, q) @@ -3032,7 +3040,7 @@ def _repr_(self): """ EXAMPLES:: - sage: PGU(2,3) + sage: PGU(2,3) # needs sage.rings.finite_rings The projective general unitary group of degree 2 over Finite Field of size 3 """ @@ -3042,22 +3050,22 @@ def _repr_(self): class SuzukiGroup(PermutationGroup_unique): def __init__(self, q, name='a'): r""" - The Suzuki group over GF(q), + The Suzuki group over `\GF(q)`, `^2 B_2(2^{2k+1}) = Sz(2^{2k+1})`. - A wrapper for the GAP function SuzukiGroup. + A wrapper for the GAP function ``SuzukiGroup``. INPUT: - - q -- 2^n, an odd power of 2; the size of the ground - field. (Strictly speaking, n should be greater than 1, or - else this group os not simple.) - - name -- (default: 'a') variable name of indeterminate of - finite field GF(q) + - ``q`` -- `2^n`, an odd power of 2; the size of the ground + field. (Strictly speaking, `n` should be greater than 1, or + else this group is not simple.) + - ``name`` -- (default: ``'a'``) variable name of indeterminate of + finite field `\GF(q)` OUTPUT: - - A Suzuki group. + A Suzuki group. .. note:: @@ -3065,12 +3073,13 @@ def __init__(self, q, name='a'): EXAMPLES:: - sage: SuzukiGroup(8) + sage: SuzukiGroup(8) # needs sage.rings.finite_rings Permutation Group with generators [(1,2)(3,10)(4,42)(5,18)(6,50)(7,26)(8,58)(9,34)(12,28)(13,45)(14,44)(15,23)(16,31)(17,21)(19,39)(20,38)(22,25)(24,61)(27,60)(29,65)(30,55)(32,33)(35,52)(36,49)(37,59)(40,54)(41,62)(43,53)(46,48)(47,56)(51,63)(57,64), (1,28,10,44)(3,50,11,42)(4,43,53,64)(5,9,39,52)(6,36,63,13)(7,51,60,57)(8,33,37,16)(12,24,55,29)(14,30,48,47)(15,19,61,54)(17,59,22,62)(18,23,34,31)(20,38,49,25)(21,26,45,58)(27,32,41,65)(35,46,40,56)] - sage: print(SuzukiGroup(8)) + sage: print(SuzukiGroup(8)) # needs sage.rings.finite_rings The Suzuki group over Finite Field in a of size 2^3 + sage: # needs sage.rings.finite_rings sage: G = SuzukiGroup(32, name='alpha') sage: G.order() 32537600 @@ -3081,7 +3090,7 @@ def __init__(self, q, name='a'): TESTS:: - sage: groups.permutation.Suzuki(8) + sage: groups.permutation.Suzuki(8) # needs sage.rings.finite_rings Permutation Group with generators [(1,2)(3,10)(4,42)(5,18)(6,50)(7,26)(8,58)(9,34)(12,28)(13,45)(14,44)(15,23)(16,31)(17,21)(19,39)(20,38)(22,25)(24,61)(27,60)(29,65)(30,55)(32,33)(35,52)(36,49)(37,59)(40,54)(41,62)(43,53)(46,48)(47,56)(51,63)(57,64), (1,28,10,44)(3,50,11,42)(4,43,53,64)(5,9,39,52)(6,36,63,13)(7,51,60,57)(8,33,37,16)(12,24,55,29)(14,30,48,47)(15,19,61,54)(17,59,22,62)(18,23,34,31)(20,38,49,25)(21,26,45,58)(27,32,41,65)(35,46,40,56)] @@ -3102,8 +3111,8 @@ def base_ring(self): """ EXAMPLES:: - sage: G = SuzukiGroup(32, name='alpha') - sage: G.base_ring() + sage: G = SuzukiGroup(32, name='alpha') # needs sage.rings.finite_rings + sage: G.base_ring() # needs sage.rings.finite_rings Finite Field in alpha of size 2^5 """ return self._base_ring @@ -3112,8 +3121,8 @@ def __str__(self): """ EXAMPLES:: - sage: G = SuzukiGroup(32, name='alpha') - sage: print(G) + sage: G = SuzukiGroup(32, name='alpha') # needs sage.rings.finite_rings + sage: print(G) # needs sage.rings.finite_rings The Suzuki group over Finite Field in alpha of size 2^5 """ @@ -3469,9 +3478,9 @@ class SmallPermutationGroup(PermutationGroup_generic): Group of order 12 and GAP Id 4 as a permutation group sage: G.gens() ((1,2)(3,5)(4,10)(6,8)(7,12)(9,11), - (1,3)(2,5)(4,7)(6,9)(8,11)(10,12), - (1,4,8)(2,6,10)(3,7,11)(5,9,12)) - sage: G.character_table() + (1,3)(2,5)(4,7)(6,9)(8,11)(10,12), + (1,4,8)(2,6,10)(3,7,11)(5,9,12)) + sage: G.character_table() # needs sage.rings.number_field [ 1 1 1 1 1 1] [ 1 -1 -1 1 1 -1] [ 1 -1 1 1 -1 1] @@ -3479,15 +3488,19 @@ class SmallPermutationGroup(PermutationGroup_generic): [ 2 0 -2 -1 0 1] [ 2 0 2 -1 0 -1] sage: def numgps(n): return ZZ(libgap.NumberSmallGroups(n)) - sage: all(SmallPermutationGroup(n,k).id()==[n,k] for n in [1..64] for k in [1..numgps(n)]) + sage: all(SmallPermutationGroup(n,k).id() == [n,k] + ....: for n in [1..64] for k in [1..numgps(n)]) True sage: H = SmallPermutationGroup(6,1) sage: H.is_abelian() False sage: [H.centralizer(g) for g in H.conjugacy_classes_representatives()] - [Subgroup generated by [(1,2)(3,6)(4,5), (1,3,5)(2,4,6)] of (Group of order 6 and GAP Id 1 as a permutation group), - Subgroup generated by [(1,2)(3,6)(4,5)] of (Group of order 6 and GAP Id 1 as a permutation group), - Subgroup generated by [(1,3,5)(2,4,6), (1,5,3)(2,6,4)] of (Group of order 6 and GAP Id 1 as a permutation group)] + [Subgroup generated by [(1,2)(3,6)(4,5), (1,3,5)(2,4,6)] of + (Group of order 6 and GAP Id 1 as a permutation group), + Subgroup generated by [(1,2)(3,6)(4,5)] of + (Group of order 6 and GAP Id 1 as a permutation group), + Subgroup generated by [(1,3,5)(2,4,6), (1,5,3)(2,6,4)] of + (Group of order 6 and GAP Id 1 as a permutation group)] """ def __init__(self, order, gap_id): @@ -3528,10 +3541,10 @@ def gap_small_group(self): r""" Return the GAP small group object corresponding to ``self``. - GAP realizes some small groups as PermutationGroup, others as PcGroups + GAP realizes some small groups as ``PermutationGroup``, others as ``PcGroups`` (polycyclic groups). The :class:`SmallPermutationGroup` class always - returns a PermutationGroup, but in the process of creating this group - a GAP SmallGroup is generated. This method returns that group. + returns a ``PermutationGroup``, but in the process of creating this group + a GAP ``SmallGroup`` is generated. This method returns that group. EXAMPLES:: diff --git a/src/sage/groups/perm_gps/symgp_conjugacy_class.py b/src/sage/groups/perm_gps/symgp_conjugacy_class.py index d6112df67af..5a8d5f435fa 100644 --- a/src/sage/groups/perm_gps/symgp_conjugacy_class.py +++ b/src/sage/groups/perm_gps/symgp_conjugacy_class.py @@ -28,8 +28,8 @@ def __init__(self, domain, part): sage: G = SymmetricGroup(5) sage: g = G([(1,2), (3,4,5)]) - sage: C = G.conjugacy_class(Partition([3,2])) - sage: type(C._part) + sage: C = G.conjugacy_class(Partition([3,2])) # needs sage.combinat + sage: type(C._part) # needs sage.combinat """ P = Partitions_n(len(domain)) @@ -44,7 +44,7 @@ def _repr_(self): EXAMPLES:: sage: G = SymmetricGroup(4) - sage: G.conjugacy_class(Partition([4])) + sage: G.conjugacy_class(Partition([4])) # needs sage.combinat Conjugacy class of cycle type [4] in Symmetric group of order 4! as a permutation group """ @@ -59,9 +59,9 @@ def __eq__(self, other): sage: G = SymmetricGroup(5) sage: g = G([(1,2), (3,4,5)]) - sage: C = G.conjugacy_class(Partition([3,2])) - sage: Cp = G.conjugacy_class(g) - sage: C == Cp + sage: C = G.conjugacy_class(Partition([3,2])) # needs sage.combinat + sage: Cp = G.conjugacy_class(g) # needs sage.combinat + sage: C == Cp # needs sage.combinat True """ if not isinstance(other, SymmetricGroupConjugacyClassMixin): @@ -76,9 +76,9 @@ def __ne__(self, other): sage: G = SymmetricGroup(5) sage: g = G([(1,3), (2,4,5)]) - sage: C = G.conjugacy_class(Partition([3,2])) - sage: Cp = G.conjugacy_class(g) - sage: C != Cp + sage: C = G.conjugacy_class(Partition([3,2])) # needs sage.combinat + sage: Cp = G.conjugacy_class(g) # needs sage.combinat + sage: C != Cp # needs sage.combinat False """ return not (self == other) @@ -91,7 +91,7 @@ def partition(self): sage: G = SymmetricGroup(5) sage: g = G([(1,2), (3,4,5)]) - sage: C = G.conjugacy_class(g) + sage: C = G.conjugacy_class(g) # needs sage.combinat """ return self._part @@ -111,6 +111,7 @@ def __init__(self, group, part): EXAMPLES:: + sage: # needs sage.combinat sage: G = SymmetricGroup(5) sage: g = G([(1,2), (3,4,5)]) sage: C = G.conjugacy_class(g) @@ -133,8 +134,8 @@ def __iter__(self): EXAMPLES:: sage: G = SymmetricGroup(4) - sage: C = G.conjugacy_class(Partition([3,1])) - sage: for x in C: x + sage: C = G.conjugacy_class(Partition([3,1])) # needs sage.combinat + sage: for x in C: x # needs sage.combinat (2,3,4) (2,4,3) (1,2,3) @@ -160,9 +161,9 @@ def set(self): sage: G = SymmetricGroup(3) sage: g = G((1,2)) - sage: C = G.conjugacy_class(g) + sage: C = G.conjugacy_class(g) # needs sage.combinat sage: S = [(2,3), (1,2), (1,3)] - sage: C.set() == Set(G(x) for x in S) + sage: C.set() == Set(G(x) for x in S) # needs sage.combinat True """ if not self._set: @@ -186,6 +187,7 @@ def __init__(self, P, part): EXAMPLES:: + sage: # needs sage.combinat sage: G = Permutations(5) sage: g = G([2, 1, 4, 5, 3]) sage: C = G.conjugacy_class(g) @@ -208,8 +210,8 @@ def __iter__(self): EXAMPLES:: sage: G = Permutations(4) - sage: C = G.conjugacy_class(Partition([3,1])) - sage: for x in C: x + sage: C = G.conjugacy_class(Partition([3,1])) # needs sage.combinat + sage: for x in C: x # needs sage.combinat [1, 3, 4, 2] [1, 4, 2, 3] [2, 3, 1, 4] @@ -235,9 +237,9 @@ def set(self): sage: G = Permutations(3) sage: g = G([2, 1, 3]) - sage: C = G.conjugacy_class(g) + sage: C = G.conjugacy_class(g) # needs sage.combinat sage: S = [[1, 3, 2], [2, 1, 3], [3, 2, 1]] - sage: C.set() == Set(G(x) for x in S) + sage: C.set() == Set(G(x) for x in S) # needs sage.combinat True """ if not self._set: @@ -272,9 +274,9 @@ def default_representative(part, G): EXAMPLES:: - sage: from sage.groups.perm_gps.symgp_conjugacy_class import default_representative + sage: from sage.groups.perm_gps.symgp_conjugacy_class import default_representative # needs sage.combinat sage: S = SymmetricGroup(4) - sage: for p in Partitions(4): + sage: for p in Partitions(4): # needs sage.combinat ....: print(default_representative(p, S)) (1,2,3,4) (1,2,3) @@ -312,8 +314,8 @@ def conjugacy_class_iterator(part, S=None): EXAMPLES:: - sage: from sage.groups.perm_gps.symgp_conjugacy_class import conjugacy_class_iterator - sage: for p in conjugacy_class_iterator([2,2]): print(p) + sage: from sage.groups.perm_gps.symgp_conjugacy_class import conjugacy_class_iterator # needs sage.combinat + sage: for p in conjugacy_class_iterator([2,2]): print(p) # needs sage.combinat [(1, 2), (3, 4)] [(1, 4), (2, 3)] [(1, 3), (2, 4)] @@ -321,7 +323,7 @@ def conjugacy_class_iterator(part, S=None): In order to get permutations, one just has to wrap:: sage: S = SymmetricGroup(5) - sage: for p in conjugacy_class_iterator([3,2]): print(S(p)) + sage: for p in conjugacy_class_iterator([3,2]): print(S(p)) # needs sage.combinat (1,3)(2,4,5) (1,3)(2,5,4) (1,2)(3,4,5) @@ -334,15 +336,15 @@ def conjugacy_class_iterator(part, S=None): the conjugacy class:: sage: s = lambda p: sum(1 for _ in conjugacy_class_iterator(p)) - sage: all(s(p) == p.conjugacy_class_size() for p in Partitions(5)) + sage: all(s(p) == p.conjugacy_class_size() for p in Partitions(5)) # needs sage.combinat True It is also possible to specify any underlying set:: - sage: it = conjugacy_class_iterator([2,2,2], 'abcdef') - sage: sorted(flatten(next(it))) + sage: it = conjugacy_class_iterator([2,2,2], 'abcdef') # needs sage.combinat + sage: sorted(flatten(next(it))) # needs sage.combinat ['a', 'b', 'c', 'd', 'e', 'f'] - sage: all(len(x) == 2 for x in next(it)) + sage: all(len(x) == 2 for x in next(it)) # needs sage.combinat True """ n = sum(part) diff --git a/src/sage/groups/raag.py b/src/sage/groups/raag.py index 736430e8af2..4bd3787d484 100644 --- a/src/sage/groups/raag.py +++ b/src/sage/groups/raag.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.graphs sage.rings.number_field r""" Right-Angled Artin Groups diff --git a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx index d84683ce5ee..ae9ce18efb1 100644 --- a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx +++ b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings r""" Elements of a semimonomial transformation group @@ -9,13 +10,13 @@ the semidirect product of the monomial transformation group of degree `n` The multiplication of two elements `(\phi, \pi, \alpha)(\psi, \sigma, \beta)` with - - `\phi, \psi \in {R^{\times}}^n` +- `\phi, \psi \in {R^{\times}}^n` - - `\pi, \sigma \in S_n` (with the multiplication `\pi\sigma` - done from left to right (like in GAP) -- - that is, `(\pi\sigma)(i) = \sigma(\pi(i))` for all `i`.) +- `\pi, \sigma \in S_n` (with the multiplication `\pi\sigma` + done from left to right (like in GAP) -- + that is, `(\pi\sigma)(i) = \sigma(\pi(i))` for all `i`.) - - `\alpha, \beta \in Aut(R)` +- `\alpha, \beta \in Aut(R)` is defined by @@ -114,7 +115,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): ((2*a + 1, 1, 2, 2); (1,2,3,4), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) sage: S(g) ((2, a, 1, 2); (), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) - sage: S(1) # the one element in the group + sage: S(1) # the one element in the group ((1, 1, 1, 1); (), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) """ def __init__(self, parent, v, perm, alpha): @@ -127,7 +128,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: S = SemimonomialTransformationGroup(F, 4) - sage: g = S(v = [2, a, 1, 2]) #indirect doctest + sage: g = S(v = [2, a, 1, 2]) #indirect doctest """ MultiplicativeGroupElement.__init__(self, parent) self.v = tuple(v) @@ -152,7 +153,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: s = SemimonomialTransformationGroup(F, 4).an_element() - sage: t = copy(s) #indirect doctest + sage: t = copy(s) # indirect doctest sage: t is s False sage: t == s @@ -203,7 +204,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: s = SemimonomialTransformationGroup(F, 4).an_element() - sage: s*s #indirect doctest + sage: s*s # indirect doctest ((a, 2*a + 1, 1, 1); (1,3)(2,4), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) """ cdef SemimonomialTransformation right = _right @@ -223,7 +224,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: S = SemimonomialTransformationGroup(F, 4) sage: s = S.an_element() - sage: s*s**(-1) == S(1) # indirect doctest + sage: s*s**(-1) == S(1) # indirect doctest True """ cdef i @@ -240,7 +241,7 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): EXAMPLES:: sage: F. = GF(9) - sage: SemimonomialTransformationGroup(F, 4).an_element() # indirect doctest + sage: SemimonomialTransformationGroup(F, 4).an_element() # indirect doctest ((a, 1, 1, 1); (1,4,3,2), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) """ return "(%s; %s, %s)"%(self.v, self.perm.cycle_string(), @@ -254,9 +255,9 @@ cdef class SemimonomialTransformation(MultiplicativeGroupElement): sage: F. = GF(9) sage: g = SemimonomialTransformationGroup(F, 4).gens() - sage: g[0] > g[1] # indirect doctest + sage: g[0] > g[1] # indirect doctest True - sage: g[1] != g[2] # indirect doctest + sage: g[1] != g[2] # indirect doctest True """ cdef SemimonomialTransformation right = _right diff --git a/src/sage/groups/semimonomial_transformations/semimonomial_transformation_group.py b/src/sage/groups/semimonomial_transformations/semimonomial_transformation_group.py index 78c485bfc02..40bbed2c6bb 100644 --- a/src/sage/groups/semimonomial_transformations/semimonomial_transformation_group.py +++ b/src/sage/groups/semimonomial_transformations/semimonomial_transformation_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings r""" Semimonomial transformation group @@ -105,13 +106,17 @@ class SemimonomialTransformationGroup(FiniteGroup, UniqueRepresentation): sage: g = S(v = [2, a, 1, 2]) sage: h = S(perm = Permutation('(1,2,3,4)'), autom=F.hom([a**3])) sage: g*h - ((2, a, 1, 2); (1,2,3,4), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) + ((2, a, 1, 2); (1,2,3,4), + Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) sage: h*g - ((2*a + 1, 1, 2, 2); (1,2,3,4), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) + ((2*a + 1, 1, 2, 2); (1,2,3,4), + Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> 2*a + 1) sage: S(g) - ((2, a, 1, 2); (), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) + ((2, a, 1, 2); (), + Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) sage: S(1) - ((1, 1, 1, 1); (), Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) + ((1, 1, 1, 1); (), + Ring endomorphism of Finite Field in a of size 3^2 Defn: a |--> a) """ Element = SemimonomialTransformation @@ -256,7 +261,7 @@ def _an_element_(self): EXAMPLES:: sage: F. = GF(4) - sage: SemimonomialTransformationGroup(F, 3).an_element() # indirect doctest + sage: SemimonomialTransformationGroup(F, 3).an_element() # indirect doctest ((a, 1, 1); (1,3,2), Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a + 1) """ R = self.base_ring() @@ -275,9 +280,9 @@ def __contains__(self, item) -> bool: sage: F. = GF(4) sage: S = SemimonomialTransformationGroup(F, 3) - sage: 1 in S # indirect doctest + sage: 1 in S # indirect doctest True - sage: a in S # indirect doctest + sage: a in S # indirect doctest False """ try: @@ -294,11 +299,14 @@ def gens(self) -> tuple: sage: F. = GF(4) sage: SemimonomialTransformationGroup(F, 3).gens() - (((a, 1, 1); (), Ring endomorphism of Finite Field in a of size 2^2 - Defn: a |--> a), ((1, 1, 1); (1,2,3), Ring endomorphism of Finite Field in a of size 2^2 - Defn: a |--> a), ((1, 1, 1); (1,2), Ring endomorphism of Finite Field in a of size 2^2 - Defn: a |--> a), ((1, 1, 1); (), Ring endomorphism of Finite Field in a of size 2^2 - Defn: a |--> a + 1)) + (((a, 1, 1); (), + Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a), + ((1, 1, 1); (1,2,3), + Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a), + ((1, 1, 1); (1,2), + Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a), + ((1, 1, 1); (), + Ring endomorphism of Finite Field in a of size 2^2 Defn: a |--> a + 1)) """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup R = self.base_ring() @@ -349,7 +357,7 @@ def _get_action_(self, X, op, self_on_left): sage: s*v # indirect doctest (0, 1, 0) sage: M = MatrixSpace(F, 3).one() - sage: s*M # indirect doctest + sage: s*M # indirect doctest [ 0 1 0] [ 0 0 1] [a + 1 0 0] @@ -376,7 +384,7 @@ def _repr_(self) -> str: EXAMPLES:: sage: F. = GF(4) - sage: SemimonomialTransformationGroup(F, 3) # indirect doctest + sage: SemimonomialTransformationGroup(F, 3) # indirect doctest Semimonomial transformation group over Finite Field in a of size 2^2 of degree 3 """ return ('Semimonomial transformation group over %s' % self.base_ring() + @@ -389,7 +397,7 @@ def _latex_(self) -> str: EXAMPLES:: sage: F. = GF(4) - sage: latex(SemimonomialTransformationGroup(F, 3)) # indirect doctest + sage: latex(SemimonomialTransformationGroup(F, 3)) # indirect doctest \left(\Bold{F}_{2^{2}}^3\wr\langle (1,2,3), (1,2) \rangle \right) \rtimes \operatorname{Aut}(\Bold{F}_{2^{2}}) """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup @@ -470,7 +478,7 @@ def __init__(self, G, M, check=True): sage: F. = GF(4) sage: s = SemimonomialTransformationGroup(F, 3).an_element() sage: M = MatrixSpace(F, 3).one() - sage: s*M # indirect doctest + sage: s*M # indirect doctest [ 0 1 0] [ 0 0 1] [a + 1 0 0] @@ -497,7 +505,7 @@ def _act_(self, a, b): sage: F. = GF(4) sage: s = SemimonomialTransformationGroup(F, 3).an_element() sage: M = MatrixSpace(F, 3).one() - sage: s*M # indirect doctest + sage: s*M # indirect doctest [ 0 1 0] [ 0 0 1] [a + 1 0 0] diff --git a/src/sage/sets/set_from_iterator.py b/src/sage/sets/set_from_iterator.py index 11f12e6d5ea..4c92deb5d52 100644 --- a/src/sage/sets/set_from_iterator.py +++ b/src/sage/sets/set_from_iterator.py @@ -509,7 +509,7 @@ def _sage_src_lines_(self): sage: S[0][2] ' Return the number of elements of this group.\n' sage: S[0][25] - ' return Integer(1)\n' + ' if not gens:\n' """ from sage.misc.sageinspect import sage_getsourcelines return sage_getsourcelines(self.f)