diff --git a/build/pkgs/sagemath_standard_no_symbolics/SPKG.rst b/build/pkgs/sagemath_standard_no_symbolics/SPKG.rst
new file mode 120000
index 00000000000..b4545b4bda6
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/SPKG.rst
@@ -0,0 +1 @@
+src/README.rst
\ No newline at end of file
diff --git a/build/pkgs/sagemath_standard_no_symbolics/bootstrap b/build/pkgs/sagemath_standard_no_symbolics/bootstrap
new file mode 120000
index 00000000000..40542346a4e
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/bootstrap
@@ -0,0 +1 @@
+../sagelib/bootstrap
\ No newline at end of file
diff --git a/build/pkgs/sagemath_standard_no_symbolics/dependencies b/build/pkgs/sagemath_standard_no_symbolics/dependencies
new file mode 100644
index 00000000000..193d6021572
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/dependencies
@@ -0,0 +1,9 @@
+FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython eclib ecm flint fplll fpylll libgd gap givaro glpk gmpy2 gsl iml jinja2 jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup
+
+----------
+All lines of this file are ignored except the first.
+
+The above are the *build-time* dependencies of the Sage library. These are,
+on the one hand, programs needed for the build/install process of the
+Sage library (e.g. CYTHON, JINJA2), and on the other hand all
+dependencies for Cython files (e.g. PARI, NTL, MP_LIBRARY).
diff --git a/build/pkgs/sagemath_standard_no_symbolics/dependencies_check b/build/pkgs/sagemath_standard_no_symbolics/dependencies_check
new file mode 100644
index 00000000000..053148f8486
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/dependencies_check
@@ -0,0 +1 @@
+tox
diff --git a/build/pkgs/sagemath_standard_no_symbolics/install-requires.txt b/build/pkgs/sagemath_standard_no_symbolics/install-requires.txt
new file mode 100644
index 00000000000..168c71a3540
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/install-requires.txt
@@ -0,0 +1 @@
+sagemath-standard-no-symbolics
diff --git a/build/pkgs/sagemath_standard_no_symbolics/package-version.txt b/build/pkgs/sagemath_standard_no_symbolics/package-version.txt
new file mode 120000
index 00000000000..cf10fe4b4e4
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/package-version.txt
@@ -0,0 +1 @@
+../sagelib/package-version.txt
\ No newline at end of file
diff --git a/build/pkgs/sagemath_standard_no_symbolics/spkg-install b/build/pkgs/sagemath_standard_no_symbolics/spkg-install
new file mode 120000
index 00000000000..e60fac9ffa1
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/spkg-install
@@ -0,0 +1 @@
+../sagemath_objects/spkg-install
\ No newline at end of file
diff --git a/build/pkgs/sagemath_standard_no_symbolics/spkg-src b/build/pkgs/sagemath_standard_no_symbolics/spkg-src
new file mode 100755
index 00000000000..e0527d500e9
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/spkg-src
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# Script to prepare an sdist tarball.
+# This script is not used during build.
+#
+# HOW TO MAKE THE TARBALL:
+# ./sage --sh build/pkgs/sagemath_standard_no_symbolics/spkg-src
+
+if [ -z "$SAGE_ROOT" ] ; then
+ echo >&2 "Error - SAGE_ROOT undefined ... exiting"
+ echo >&2 "Maybe run 'sage -sh'?"
+ exit 1
+fi
+
+# Exit on failure
+set -e
+
+cd build/pkgs/sagemath_standard_no_symbolics
+
+cd src
+python3 -u setup.py --no-user-cfg sdist --dist-dir "$SAGE_DISTFILES"
diff --git a/build/pkgs/sagemath_standard_no_symbolics/src b/build/pkgs/sagemath_standard_no_symbolics/src
new file mode 120000
index 00000000000..6a31af2c005
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/src
@@ -0,0 +1 @@
+../../../pkgs/sagemath-standard-no-symbolics
\ No newline at end of file
diff --git a/build/pkgs/sagemath_standard_no_symbolics/type b/build/pkgs/sagemath_standard_no_symbolics/type
new file mode 100644
index 00000000000..9839eb20815
--- /dev/null
+++ b/build/pkgs/sagemath_standard_no_symbolics/type
@@ -0,0 +1 @@
+experimental
diff --git a/pkgs/sagemath-categories/tox.ini b/pkgs/sagemath-categories/tox.ini
index a240b091e30..bc5213f1730 100644
--- a/pkgs/sagemath-categories/tox.ini
+++ b/pkgs/sagemath-categories/tox.ini
@@ -1,23 +1,23 @@
# To build and test in the tox environment:
#
-# ./sage -sh -c '(cd pkgs/sagemath-categories && tox -v -v -v -e sagepython)'
+# make SAGE_WHEELS=yes sagemath_categories-build-deps && ./sage -sh -c '(cd pkgs/sagemath-categories && SAGE_NUM_THREADS=8 tox -v -v -v -e sagepython-sagewheels-nopypi-norequirements)'
#
-# To test interactively:
+# After this, to test interactively:
#
-# pkgs/sagemath-categories/.tox/sagepython/bin/python
+# pkgs/sagemath-categories/.tox/sagepython-sagewheels-nopypi-norequirements/bin/sage
#
[tox]
envlist =
- sagepython-norequirements
+ sagepython-sagewheels-nopypi-norequirements
-[testenv]
-deps =
- !norequirements: -rrequirements.txt
- # tox 3.x does not handle extras when using --installpkg. https://github.com/tox-dev/tox/issues/1576
- sagemath-repl
-
-extras = test
+requires =
+ # Auto-provision a modern tox.
+ # [pkgenv] added in 4.2 - https://tox.wiki/en/latest/upgrading.html#packaging-configuration-and-inheritance
+ tox>=4.2
+[pkgenv]
+# Environment in which to build the sdist.
+# https://tox.wiki/en/latest/upgrading.html#packaging-environments
passenv =
# Variables set by .homebrew-build-env
CPATH
@@ -32,36 +32,73 @@ passenv =
sagewheels: SAGE_SPKG_WHEELS
setenv =
- # Sage scripts such as sage-runtests like to use $HOME/.sage
- HOME={envdir}
# We supply pip options by environment variables so that they
# apply both to the installation of the dependencies and of the package
sagewheels: PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
nopypi: PIP_NO_INDEX=true
+[testenv]
+deps =
+ !norequirements: -rrequirements.txt
+
+extras = test
+
+passenv = {[pkgenv]passenv}
+
+setenv = {[pkgenv]setenv}
+ # Sage scripts such as sage-runtests like to use $HOME/.sage
+ HOME={envdir}
+
allowlist_externals =
bash
commands =
- # Beware of the treacherous non-src layout. "./sage/" shadows the install sage package.
+ # Beware of the treacherous non-src layout. "./sage/" shadows the installed sage package.
{envpython} -c 'import sys; "" in sys.path and sys.path.remove(""); import sage.cpython.builtin_types, sage.cpython.cython_metaclass, sage.cpython.debug, sage.structure.all, sage.categories.all'
# Test that importing sage.categories.all initializes categories
{envpython} -c 'import sys; "" in sys.path and sys.path.remove(""); from sage.categories.all import *; SimplicialComplexes(); FunctionFields()'
- bash -c 'cd {temp_dir} && SAGE_SRC=$(python -c "from sage.env import SAGE_SRC; print(SAGE_SRC)") && sage-runtests --initial --environment=sage.all__sagemath_categories --optional=sage $SAGE_SRC/sage/structure || echo "(lots of doctest failures are expected)"'
+ bash -c 'cd $(python -c "import sys; \"\" in sys.path and sys.path.remove(\"\"); from sage.env import SAGE_LIB; print(SAGE_LIB)") \
+ && sage-runtests -p --initial --environment=sage.all__sagemath_categories --optional=sage sage/structure || echo "(lots of doctest failures are expected)"'
+
+[testenv:.tox]
+# Allow access to PyPI for auto-provisioning a suitable tox version
+passenv =
+setenv = PIP_NO_INDEX=false
+
+[testenv:.pkg-sagepython]
+# Environment in which to build the sdist.
+# inherits from [pkgenv] - https://tox.wiki/en/latest/upgrading.html#packaging-environments
+basepython = {env:SAGE_VENV}/bin/python3
+
+[testenv:.pkg-sagepython-sagewheels-nopypi]
+passenv = {[pkgenv]passenv}
+ SAGE_VENV
+ SAGE_SPKG_WHEELS
+
+setenv = {[pkgenv]setenv}
+ PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
+ PIP_NO_INDEX=true
+
+basepython = {env:SAGE_VENV}/bin/python3
[testenv:sagepython]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
[testenv:sagepython-sagewheels-nopypi]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels-nopypi-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels]
-basepython = {env:SAGE_VENV}/bin/python3
+basepython = {env:SAGE_VENV}/bin/python
+package_env = .pkg-sagepython
[testenv:sagepython-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
diff --git a/pkgs/sagemath-environment/tox.ini b/pkgs/sagemath-environment/tox.ini
index 46077bd8e27..65bcdc902e0 100644
--- a/pkgs/sagemath-environment/tox.ini
+++ b/pkgs/sagemath-environment/tox.ini
@@ -1,22 +1,28 @@
# To build and test in the tox environment:
#
-# ./sage -sh -c '(cd pkgs/sagemath-environment && tox -v -v -e sagepython)'
+# ./sage -sh -c '(cd pkgs/sagemath-environment && tox -v -v -e sagepython-norequirements)'
#
# To test interactively:
#
-# pkgs/sagemath-environment/.tox/sagepython/bin/python
+# pkgs/sagemath-environment/.tox/sagepython-norequirements/bin/python
#
[tox]
envlist =
sagepython-norequirements
-isolated_build = True
-
-[testenv]
-deps =
- !norequirements: -rrequirements.txt
+requires =
+ # Auto-provision a modern tox.
+ # [pkgenv] added in 4.2 - https://tox.wiki/en/latest/upgrading.html#packaging-configuration-and-inheritance
+ tox>=4.2
+[pkgenv]
+# Environment in which to build the sdist.
+# https://tox.wiki/en/latest/upgrading.html#packaging-environments
passenv =
+ # Variables set by .homebrew-build-env
+ CPATH
+ LIBRARY_PATH
+ PKG_CONFIG_PATH
# Parallel build
SAGE_NUM_THREADS
SAGE_NUM_THREADS_PARALLEL
@@ -26,13 +32,23 @@ passenv =
sagewheels: SAGE_SPKG_WHEELS
setenv =
- # Sage scripts such as sage-runtests like to use $HOME/.sage
- HOME={envdir}
# We supply pip options by environment variables so that they
# apply both to the installation of the dependencies and of the package
sagewheels: PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
nopypi: PIP_NO_INDEX=true
+[testenv]
+deps =
+ !norequirements: -rrequirements.txt
+
+extras = test
+
+passenv = {[pkgenv]passenv}
+
+setenv = {[pkgenv]setenv}
+ # Sage scripts such as sage-runtests like to use $HOME/.sage
+ HOME={envdir}
+
allowlist_externals =
bash
@@ -40,17 +56,43 @@ commands =
# Beware of the treacherous non-src layout. "./sage/" shadows the installed sage package.
{envpython} -c 'import sys; "" in sys.path and sys.path.remove(""); from sage.features.all import all_features; print(sorted(all_features(), key=lambda x: x.name)); import sage.misc.package'
+[testenv:.tox]
+# Allow access to PyPI for auto-provisioning a suitable tox version
+passenv =
+setenv = PIP_NO_INDEX=false
+
+[testenv:.pkg-sagepython]
+# Environment in which to build the sdist.
+# inherits from [pkgenv] - https://tox.wiki/en/latest/upgrading.html#packaging-environments
+basepython = {env:SAGE_VENV}/bin/python3
+
+[testenv:.pkg-sagepython-sagewheels-nopypi]
+passenv = {[pkgenv]passenv}
+ SAGE_VENV
+ SAGE_SPKG_WHEELS
+
+setenv = {[pkgenv]setenv}
+ PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
+ PIP_NO_INDEX=true
+
+basepython = {env:SAGE_VENV}/bin/python3
+
[testenv:sagepython]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
[testenv:sagepython-sagewheels-nopypi]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels-nopypi-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels]
-basepython = {env:SAGE_VENV}/bin/python3
+basepython = {env:SAGE_VENV}/bin/python
+package_env = .pkg-sagepython
[testenv:sagepython-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
diff --git a/pkgs/sagemath-objects/tox.ini b/pkgs/sagemath-objects/tox.ini
index e34531467e5..e5bf1e6dac7 100644
--- a/pkgs/sagemath-objects/tox.ini
+++ b/pkgs/sagemath-objects/tox.ini
@@ -1,21 +1,23 @@
# To build and test in the tox environment:
#
-# ./sage -sh -c '(cd pkgs/sagemath-objects && tox -v -v -e sagepython)'
+# ./sage -sh -c '(cd pkgs/sagemath-objects && SAGE_NUM_THREADS=8 tox -v -v -e sagepython-norequirements)'
#
-# To test interactively:
+# After this, to test interactively:
#
-# pkgs/sagemath-objects/.tox/sagepython/bin/python
+# pkgs/sagemath-objects/.tox/sagepython-norequirements/bin/python
#
[tox]
envlist =
sagepython-norequirements
-[testenv]
-deps =
- !norequirements: -rrequirements.txt
-
-extras = test
+requires =
+ # Auto-provision a modern tox.
+ # [pkgenv] added in 4.2 - https://tox.wiki/en/latest/upgrading.html#packaging-configuration-and-inheritance
+ tox>=4.2
+[pkgenv]
+# Environment in which to build the sdist.
+# https://tox.wiki/en/latest/upgrading.html#packaging-environments
passenv =
# Variables set by .homebrew-build-env
CPATH
@@ -30,13 +32,23 @@ passenv =
sagewheels: SAGE_SPKG_WHEELS
setenv =
- # Sage scripts such as sage-runtests like to use $HOME/.sage
- HOME={envdir}
# We supply pip options by environment variables so that they
# apply both to the installation of the dependencies and of the package
sagewheels: PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
nopypi: PIP_NO_INDEX=true
+[testenv]
+deps =
+ !norequirements: -rrequirements.txt
+
+extras = test
+
+passenv = {[pkgenv]passenv}
+
+setenv = {[pkgenv]setenv}
+ # Sage scripts such as sage-runtests like to use $HOME/.sage
+ HOME={envdir}
+
allowlist_externals =
bash
@@ -48,17 +60,43 @@ commands =
#bash -c 'cd {temp_dir} && SAGE_SRC=$(python -c "from sage.env import SAGE_SRC; print(SAGE_SRC)") && sage-runtests --environment=sage.all__sagemath_objects --initial --optional=sage $SAGE_SRC/sage/structure || echo "(lots of doctest failures are expected)"'
+[testenv:.tox]
+# Allow access to PyPI for auto-provisioning a suitable tox version
+passenv =
+setenv = PIP_NO_INDEX=false
+
+[testenv:.pkg-sagepython]
+# Environment in which to build the sdist.
+# inherits from [pkgenv] - https://tox.wiki/en/latest/upgrading.html#packaging-environments
+basepython = {env:SAGE_VENV}/bin/python3
+
+[testenv:.pkg-sagepython-sagewheels-nopypi]
+passenv = {[pkgenv]passenv}
+ SAGE_VENV
+ SAGE_SPKG_WHEELS
+
+setenv = {[pkgenv]setenv}
+ PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
+ PIP_NO_INDEX=true
+
+basepython = {env:SAGE_VENV}/bin/python3
+
[testenv:sagepython]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
[testenv:sagepython-sagewheels-nopypi]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels-nopypi-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels]
-basepython = {env:SAGE_VENV}/bin/python3
+basepython = {env:SAGE_VENV}/bin/python
+package_env = .pkg-sagepython
[testenv:sagepython-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
diff --git a/pkgs/sagemath-repl/tox.ini b/pkgs/sagemath-repl/tox.ini
index 084016ce768..1637788be39 100644
--- a/pkgs/sagemath-repl/tox.ini
+++ b/pkgs/sagemath-repl/tox.ini
@@ -1,21 +1,23 @@
# To build and test in the tox environment:
#
-# ./sage -sh -c '(cd pkgs/sagemath-repl && tox -v -v -e sagepython)'
+# make SAGE_WHEELS=yes sagemath_repl-build-deps && ./sage -sh -c '(cd pkgs/sagemath-repl && SAGE_NUM_THREADS=8 tox -v -v -e sagepython-sagewheels-nopypi-norequirements)'
#
-# To test interactively:
+# After this, to test interactively:
#
-# pkgs/sagemath-repl/.tox/sagepython/bin/python
+# pkgs/sagemath-repl/.tox/sagepython-sagewheels-nopypi-norequirements/bin/python
#
[tox]
envlist =
- sagepython-norequirements
+ sagepython-sagewheels-nopypi-norequirements
-isolated_build = True
-
-[testenv]
-deps =
- !norequirements: -rrequirements.txt
+requires =
+ # Auto-provision a modern tox.
+ # [pkgenv] added in 4.2 - https://tox.wiki/en/latest/upgrading.html#packaging-configuration-and-inheritance
+ tox>=4.2
+[pkgenv]
+# Environment in which to build the sdist.
+# https://tox.wiki/en/latest/upgrading.html#packaging-environments
passenv =
# Variables set by .homebrew-build-env
CPATH
@@ -30,13 +32,23 @@ passenv =
sagewheels: SAGE_SPKG_WHEELS
setenv =
- # Sage scripts such as sage-runtests like to use $HOME/.sage
- HOME={envdir}
# We supply pip options by environment variables so that they
# apply both to the installation of the dependencies and of the package
sagewheels: PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
nopypi: PIP_NO_INDEX=true
+[testenv]
+deps =
+ !norequirements: -rrequirements.txt
+
+extras = test
+
+passenv = {[pkgenv]passenv}
+
+setenv = {[pkgenv]setenv}
+ # Sage scripts such as sage-runtests like to use $HOME/.sage
+ HOME={envdir}
+
allowlist_externals =
bash
@@ -44,19 +56,45 @@ commands =
# Beware of the treacherous non-src layout. "./sage/" shadows the installed sage package.
{envpython} -c 'import sys; "" in sys.path and sys.path.remove(""); import sage.repl.all; import sage.doctest.all'
- bash -c 'cd bin && SAGE_SRC=$({envpython} -c "from sage.env import SAGE_SRC; print(SAGE_SRC)") && sage-runtests --environment=sage.all__sagemath_repl --initial --optional=sage $SAGE_SRC/sage/repl $SAGE_SRC/sage/doctest $SAGE_SRC/sage/misc/sage_input.py $SAGE_SRC/sage/misc/sage_eval.py || echo "(lots of doctest failures are expected)"'
+ bash -c 'cd $({envpython} -c "import sys; \"\" in sys.path and sys.path.remove(\"\"); from sage.env import SAGE_LIB; print(SAGE_LIB)") && sage-runtests -p --environment=sage.all__sagemath_repl --initial --optional=sage sage/repl sage/doctest sage/misc/sage_input.py sage/misc/sage_eval.py || echo "(lots of doctest failures are expected)"'
+
+[testenv:.tox]
+# Allow access to PyPI for auto-provisioning a suitable tox version
+passenv =
+setenv = PIP_NO_INDEX=false
+
+[testenv:.pkg-sagepython]
+# Environment in which to build the sdist.
+# inherits from [pkgenv] - https://tox.wiki/en/latest/upgrading.html#packaging-environments
+basepython = {env:SAGE_VENV}/bin/python3
+
+[testenv:.pkg-sagepython-sagewheels-nopypi]
+passenv = {[pkgenv]passenv}
+ SAGE_VENV
+ SAGE_SPKG_WHEELS
+
+setenv = {[pkgenv]setenv}
+ PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
+ PIP_NO_INDEX=true
+
+basepython = {env:SAGE_VENV}/bin/python3
[testenv:sagepython]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
[testenv:sagepython-sagewheels-nopypi]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels-nopypi-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels]
-basepython = {env:SAGE_VENV}/bin/python3
+basepython = {env:SAGE_VENV}/bin/python
+package_env = .pkg-sagepython
[testenv:sagepython-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
diff --git a/pkgs/sagemath-standard-no-symbolics/MANIFEST.in.m4 b/pkgs/sagemath-standard-no-symbolics/MANIFEST.in.m4
new file mode 100644
index 00000000000..05f172a8c92
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/MANIFEST.in.m4
@@ -0,0 +1,32 @@
+dnl MANIFEST.in is generated from this file by SAGE_ROOT/bootstrap via m4.
+
+dnl Include all from sagemath-categories (via m4 include)
+include(`../sagelib/src/MANIFEST.in')
+
+exclude *.m4
+include requirements.txt
+
+global-include all__sagemath_standard_no_symbolics.py
+
+prune sage/symbolic
+prune sage/functions
+prune sage/manifolds
+prune sage/lfunctions
+prune sage/geometry/riemannian_manifolds
+prune sage/geometry/hyperbolic_space
+prune sage/dynamics/complex_dynamics
+prune sage/rings/asymptotic
+
+exclude sage/calculus/calculus.*
+exclude sage/calculus/var.*
+
+exclude sage/modules/vector_*symbol*.*
+exclude sage/matrix/matrix_symbolic_*.*
+exclude sage/groups/misc_gps/argument_groups.*
+exclude sage/groups/misc_gps/imaginary_groups.*
+
+prune sage/libs/pynac
+exclude sage/libs/ecl.p*
+exclude sage/libs/giac.p*
+
+exclude sage/interfaces/maxima*.p*
diff --git a/pkgs/sagemath-standard-no-symbolics/README.rst b/pkgs/sagemath-standard-no-symbolics/README.rst
new file mode 100644
index 00000000000..f8ad2583442
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/README.rst
@@ -0,0 +1,25 @@
+======================================================================================
+ Sage: Open Source Mathematics Software: Sage library without the symbolics subsystem
+======================================================================================
+
+About SageMath
+--------------
+
+ "Creating a Viable Open Source Alternative to
+ Magma, Maple, Mathematica, and MATLAB"
+
+ Copyright (C) 2005-2022 The Sage Development Team
+
+ https://www.sagemath.org
+
+SageMath fully supports all major Linux distributions, recent versions of macOS, and Windows (using Cygwin or Windows Subsystem for Linux).
+
+The traditional and recommended way to install SageMath is from source via Sage-the-distribution (https://www.sagemath.org/download-source.html). Sage-the-distribution first builds a large number of open source packages from source (unless it finds suitable versions installed in the system) and then installs the Sage Library (sagelib, implemented in Python and Cython).
+
+
+About this experimental pip-installable source distribution
+-----------------------------------------------------------
+
+This pip-installable source distribution `sagemath-standard-no-symbolics` is an experimental subset distribution of the Sage library.
+
+Its main purpose is as a technical tool for the modularization project (https://trac.sagemath.org/ticket/29705), to test that large parts of the Sage library are independent of the symbolics subsystem.
diff --git a/pkgs/sagemath-standard-no-symbolics/VERSION.txt b/pkgs/sagemath-standard-no-symbolics/VERSION.txt
new file mode 120000
index 00000000000..43f4773d7de
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/VERSION.txt
@@ -0,0 +1 @@
+../../src/VERSION.txt
\ No newline at end of file
diff --git a/pkgs/sagemath-standard-no-symbolics/bin b/pkgs/sagemath-standard-no-symbolics/bin
new file mode 120000
index 00000000000..2f8b9b30ee7
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/bin
@@ -0,0 +1 @@
+../../src/bin
\ No newline at end of file
diff --git a/pkgs/sagemath-standard-no-symbolics/pyproject.toml.m4 b/pkgs/sagemath-standard-no-symbolics/pyproject.toml.m4
new file mode 120000
index 00000000000..21eac63af37
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/pyproject.toml.m4
@@ -0,0 +1 @@
+../sagemath-standard/pyproject.toml.m4
\ No newline at end of file
diff --git a/pkgs/sagemath-standard-no-symbolics/requirements.txt.m4 b/pkgs/sagemath-standard-no-symbolics/requirements.txt.m4
new file mode 120000
index 00000000000..625ede57362
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/requirements.txt.m4
@@ -0,0 +1 @@
+../sagemath-standard/requirements.txt.m4
\ No newline at end of file
diff --git a/pkgs/sagemath-standard-no-symbolics/sage b/pkgs/sagemath-standard-no-symbolics/sage
new file mode 120000
index 00000000000..e0da5daa6f2
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/sage
@@ -0,0 +1 @@
+../../src/sage
\ No newline at end of file
diff --git a/pkgs/sagemath-standard-no-symbolics/setup.cfg.m4 b/pkgs/sagemath-standard-no-symbolics/setup.cfg.m4
new file mode 100644
index 00000000000..2b917d9d400
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/setup.cfg.m4
@@ -0,0 +1,158 @@
+# -*- conf-unix -*-
+[metadata]
+name = sagemath-standard-no-symbolics
+version = file: VERSION.txt
+description = Sage: Open Source Mathematics Software: Sage library without the symbolics subsystem
+long_description = file: README.rst
+long_description_content_type = text/x-rst
+license = GNU General Public License (GPL) v2 or later
+license_files = LICENSE.txt
+author = The Sage Developers
+author_email = sage-support@googlegroups.com
+url = https://www.sagemath.org
+
+classifiers =
+ Development Status :: 6 - Mature
+ Intended Audience :: Education
+ Intended Audience :: Science/Research
+ License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
+ Operating System :: POSIX
+ Operating System :: MacOS :: MacOS X
+ Programming Language :: Python :: 3 :: Only
+ Programming Language :: Python :: 3.8
+ Programming Language :: Python :: 3.9
+ Programming Language :: Python :: 3.10
+ Programming Language :: Python :: 3.11
+ Programming Language :: Python :: Implementation :: CPython
+ Topic :: Scientific/Engineering :: Mathematics
+
+[options]
+python_requires = >=3.8, <3.12
+install_requires =
+ esyscmd(`sage-get-system-packages install-requires \
+ sage_conf \
+ six \
+ | sed "2,\$s/^/ /;"')dnl'
+dnl From build/pkgs/sagelib/dependencies
+ esyscmd(`sage-get-system-packages install-requires \
+ cypari \
+ cysignals \
+ cython \
+ gmpy2 \
+ jinja2 \
+ jupyter_core \
+ lrcalc_python \
+ memory_allocator \
+ numpy \
+ pkgconfig \
+ pplpy \
+ primecountpy \
+ requests \
+ | sed "2,\$s/^/ /;"')dnl'
+dnl From Makefile.in: SAGERUNTIME
+ esyscmd(`sage-get-system-packages install-requires \
+ ipython \
+ pexpect \
+ | sed "2,\$s/^/ /;"')dnl'
+dnl From Makefile.in: DOC_DEPENDENCIES
+ esyscmd(`sage-get-system-packages install-requires \
+ sphinx \
+ networkx \
+ scipy \
+ sympy \
+ matplotlib \
+ pillow \
+ mpmath \
+ ipykernel \
+ jupyter_client \
+ ipywidgets \
+ | sed "2,\$s/^/ /;"')dnl'
+dnl Other Python packages that are standard spkg, used in doctests
+ esyscmd(`sage-get-system-packages install-requires \
+ fpylll \
+ | sed "2,\$s/^/ /;"')dnl'
+dnl pycryptosat # Sage distribution installs it as part of cryptominisat. According to its README on https://pypi.org/project/pycryptosat/: "The pycryptosat python package compiles while compiling CryptoMiniSat. It cannot be compiled on its own, it must be compiled at the same time as CryptoMiniSat."
+dnl Packages with important upper version bounds
+ esyscmd(`sage-get-system-packages install-requires \
+ ptyprocess \
+ | sed "2,\$s/^/ /;"')dnl'
+
+scripts =
+ # The sage script
+ bin/sage
+ # Other scripts that should be in the path also for OS packaging of sage:
+ bin/sage-eval
+ # Included because it is useful for doctesting/coverage testing user scripts too:
+ bin/sage-runtests
+ bin/sage-fixdoctests
+ bin/sage-coverage
+ # The following is deprecated but might still be used in user package install scripts
+ bin/sage-cython
+ # Helper scripts invoked by sage script
+ # (they would actually belong to something like libexec)
+ bin/sage-cachegrind
+ bin/sage-callgrind
+ bin/sage-massif
+ bin/sage-omega
+ bin/sage-valgrind
+ bin/sage-venv-config
+ bin/sage-version.sh
+ bin/sage-cleaner
+ # Only makes sense in sage-the-distribution. TODO: Move to another installation script.
+ bin/sage-list-packages
+ # Uncategorized scripts in alphabetical order
+ bin/sage-env
+ # sage-env-config -- installed by sage_conf
+ # sage-env-config.in -- not to be installed
+ bin/sage-grep
+ bin/sage-grepdoc
+ bin/sage-inline-fortran
+ bin/sage-ipynb2rst
+ bin/sage-ipython
+ bin/sage-notebook
+ bin/sage-num-threads.py
+ bin/sage-preparse
+ bin/sage-python
+ bin/sage-rebase.bat
+ bin/sage-rebase.sh
+ bin/sage-rebaseall.bat
+ bin/sage-rebaseall.sh
+ bin/sage-run
+ bin/sage-run-cython
+ bin/sage-startuptime.py
+ bin/sage-update-version
+
+[options.package_data]
+
+sage.libs.gap =
+ sage.gaprc
+
+sage.doctest =
+ tests/*
+
+sage.repl.rich_output =
+ example*
+
+sage =
+ ext_data/*
+ ext_data/kenzo/*
+ ext_data/singular/*
+ ext_data/singular/function_field/*
+ ext_data/images/*
+ ext_data/doctest/*
+ ext_data/doctest/invalid/*
+ ext_data/gap/*
+ ext_data/gap/joyner/*
+ ext_data/mwrank/*
+ ext_data/notebook-ipython/*
+ ext_data/nbconvert/*
+ ext_data/graphs/*
+ ext_data/pari/*
+ ext_data/pari/dokchitser/*
+ ext_data/pari/buzzard/*
+ ext_data/pari/simon/*
+ ext_data/magma/*
+ ext_data/magma/latex/*
+ ext_data/magma/sage/*
+ ext_data/valgrind/*
+ ext_data/threejs/*
diff --git a/pkgs/sagemath-standard-no-symbolics/setup.py b/pkgs/sagemath-standard-no-symbolics/setup.py
new file mode 120000
index 00000000000..e1f81d537ae
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/setup.py
@@ -0,0 +1 @@
+../sagemath-standard/setup.py
\ No newline at end of file
diff --git a/pkgs/sagemath-standard-no-symbolics/tox.ini b/pkgs/sagemath-standard-no-symbolics/tox.ini
new file mode 120000
index 00000000000..f3bd09cc088
--- /dev/null
+++ b/pkgs/sagemath-standard-no-symbolics/tox.ini
@@ -0,0 +1 @@
+../sagemath-standard/tox.ini
\ No newline at end of file
diff --git a/pkgs/sagemath-standard/tox.ini b/pkgs/sagemath-standard/tox.ini
index 305eddd7586..f63b107e2ed 100644
--- a/pkgs/sagemath-standard/tox.ini
+++ b/pkgs/sagemath-standard/tox.ini
@@ -1,7 +1,3 @@
-# First install tox:
-#
-# ./sage -i tox
-#
# All tests require an installation of the non-Python components of the Sage distribution
# in SAGE_LOCAL.
#
@@ -67,14 +63,14 @@ envlist =
#
sagepython-sagewheels-pipenv
-[testenv]
-deps =
- pipenv: pipenv
- !pipenv-!norequirements: -rrequirements.txt
- ## Needed for fpylll
- norequirements: Cython
- norequirements: cysignals
+requires =
+ # Auto-provision a modern tox.
+ # [pkgenv] added in 4.2 - https://tox.wiki/en/latest/upgrading.html#packaging-configuration-and-inheritance
+ tox>=4.2
+[pkgenv]
+# Environment in which to build the sdist.
+# https://tox.wiki/en/latest/upgrading.html#packaging-environments
passenv =
# Variables set by .homebrew-build-env
CPATH
@@ -82,14 +78,13 @@ passenv =
PKG_CONFIG_PATH
# Parallel build
SAGE_NUM_THREADS
+ SAGE_NUM_THREADS_PARALLEL
# SAGE_VENV only for referring to the basepython or finding the wheels
sagepython, sagewheels: SAGE_VENV
# Location of the wheels
sagewheels: SAGE_SPKG_WHEELS
setenv =
- # Sage scripts such as sage-runtests like to use $HOME/.sage
- HOME={envdir}
# We supply pip options by environment variables so that they
# apply both to the installation of the dependencies and of the package
sagewheels: PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
@@ -103,23 +98,28 @@ setenv =
# so we cannot isolate it in the tox environment.
pipenv: PIPENV_SKIP_LOCK=true
+[testenv]
+deps =
+ pipenv: pipenv
+ !pipenv-!norequirements: -rrequirements.txt
+ ## Needed for fpylll
+ norequirements: Cython
+ norequirements: cysignals
+
sitepackages =
sitepackages: True
!sitepackages: False
-allowlist_externals =
- bash
+extras = test
-skip_install =
- pipenv: True
- !pipenv: False
+passenv = {[pkgenv]passenv}
-commands_pre =
- # Use Pipenv to install according to Pipfile into the virtual environment created by tox.
- # https://pipenv-searchable.readthedocs.io/advanced.html#tox-automation-project
- pipenv-!dist: pipenv install -v -v -v
- # Same, but use $SAGE_ROOT/Pipfile
- pipenv-dist: bash -c '(cd ../../../.. && pipenv install -v -v -v)'
+setenv = {[pkgenv]setenv}
+ # Sage scripts such as sage-runtests like to use $HOME/.sage
+ HOME={envdir}
+
+allowlist_externals =
+ bash
commands =
# Beware of the treacherous non-src layout. "./sage/" shadows the installed sage package.
@@ -128,25 +128,53 @@ commands =
# We check that the "sage" script invokes the correct Python.
sage -c 'import sys; print("sys.path =", sys.path); import sage.all; print(sage.all.__file__)'
- sage -t -p --all
+ sage -t -p --initial --installed
+
+[testenv:.tox]
+# Allow access to PyPI for auto-provisioning a suitable tox version
+passenv =
+setenv = PIP_NO_INDEX=false
+
+[testenv:.pkg-sagepython]
+# Environment in which to build the sdist.
+# inherits from [pkgenv] - https://tox.wiki/en/latest/upgrading.html#packaging-environments
+basepython = {env:SAGE_VENV}/bin/python3
+
+[testenv:.pkg-sagepython-sagewheels-nopypi]
+passenv = {[pkgenv]passenv}
+ SAGE_VENV
+ SAGE_SPKG_WHEELS
+
+setenv = {[pkgenv]setenv}
+ PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
+ PIP_NO_INDEX=true
+
+basepython = {env:SAGE_VENV}/bin/python3
[testenv:sagepython]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
[testenv:sagepython-sagewheels-nopypi]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels-nopypi-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython-sagewheels-nopypi
[testenv:sagepython-sagewheels]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
[testenv:sagepython-sagewheels-pipenv-dist]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
[testenv:sagepython-sagewheels-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
[testenv:sagepython-sagewheels-pipenv]
basepython = {env:SAGE_VENV}/bin/python3
+package_env = .pkg-sagepython
diff --git a/src/bin/sage-eval b/src/bin/sage-eval
index 875c98a785b..664e1051742 100755
--- a/src/bin/sage-eval
+++ b/src/bin/sage-eval
@@ -2,7 +2,10 @@
import sys
from sage.all import *
-from sage.calculus.predefined import x
+try:
+ from sage.calculus.predefined import x
+except ImportError:
+ pass
from sage.repl.preparse import preparse
if len(sys.argv) > 1:
diff --git a/src/doc/en/developer/packaging_sage_library.rst b/src/doc/en/developer/packaging_sage_library.rst
index 229c3dc01d7..03eab612a1d 100644
--- a/src/doc/en/developer/packaging_sage_library.rst
+++ b/src/doc/en/developer/packaging_sage_library.rst
@@ -591,16 +591,14 @@ distribution to be tested (and its Python dependencies).
Let's try it out first with the entire Sage library, represented by
the distribution **sagemath-standard**. Note that after Sage has been
-built normally, a set of wheels for all installed Python packages is
-available in ``SAGE_VENV/var/lib/sage/wheels/``::
+built normally, a set of wheels for most installed Python distribution
+packages is available in ``SAGE_VENV/var/lib/sage/wheels/``::
$ ls venv/var/lib/sage/wheels
Babel-2.9.1-py2.py3-none-any.whl
Cython-0.29.24-cp39-cp39-macosx_11_0_x86_64.whl
Jinja2-2.11.2-py2.py3-none-any.whl
...
- sage_conf-9.5b6-py3-none-any.whl
- ...
scipy-1.7.2-cp39-cp39-macosx_11_0_x86_64.whl
setuptools-58.2.0-py3-none-any.whl
...
@@ -608,6 +606,22 @@ available in ``SAGE_VENV/var/lib/sage/wheels/``::
widgetsnbextension-3.5.1-py2.py3-none-any.whl
zipp-3.5.0-py3-none-any.whl
+However, in a build of Sage with the default configuration
+``configure --enable-editable``, there will be no wheels for the
+distributions ``sage_*`` and ``sagemath-*``.
+
+To create these wheels, use the command ``make wheels``::
+
+ $ make wheels
+ ...
+ $ ls venv/var/lib/sage/wheels/sage*
+ ...
+ sage_conf-10.0b2-py3-none-any.whl
+ ...
+
+(You can also use ``./configure --enable-wheels`` to ensure that
+these wheels are always available and up to date.)
+
Note in particular the wheel for **sage-conf**, which provides
configuration variable settings and the connection to the non-Python
packages installed in ``SAGE_LOCAL``.
@@ -648,7 +662,7 @@ without depending on optional packages, but without the packages
Again we can run the test with ``tox`` in a separate virtual environment::
- $ ./bootstrap && ./sage -sh -c '(cd pkgs/sagemath-standard-no-symbolics && SAGE_NUM_THREADS=16 tox -v -v -v -e sagepython-sagewheels-nopypi)'
+ $ ./bootstrap && make wheels && ./sage -sh -c '(cd pkgs/sagemath-standard-no-symbolics && SAGE_NUM_THREADS=16 tox -v -v -v -e sagepython-sagewheels-nopypi-norequirements)'
Some small distributions, for example the ones providing the two
lowest levels, `sagemath-objects `_
diff --git a/src/doc/en/reference/rings/index.rst b/src/doc/en/reference/rings/index.rst
index d43d1be4003..52847e952b4 100644
--- a/src/doc/en/reference/rings/index.rst
+++ b/src/doc/en/reference/rings/index.rst
@@ -8,6 +8,7 @@ Base Classes for Rings, Algebras and Fields
:maxdepth: 1
sage/rings/ring
+ sage/rings/abc
Ideals
------
diff --git a/src/doc/en/reference/rings_standard/index.rst b/src/doc/en/reference/rings_standard/index.rst
index 4bb5338609f..97bf2b8ea35 100644
--- a/src/doc/en/reference/rings_standard/index.rst
+++ b/src/doc/en/reference/rings_standard/index.rst
@@ -12,6 +12,8 @@ Integers
sage/rings/bernmm
sage/rings/bernoulli_mod_p
sage/rings/factorint
+ sage/rings/factorint_flint
+ sage/rings/factorint_pari
sage/rings/fast_arith
sage/rings/sum_of_squares
sage/arith/functions
diff --git a/src/sage/algebras/quantum_clifford.py b/src/sage/algebras/quantum_clifford.py
index 1e57682f255..5079283e8ec 100644
--- a/src/sage/algebras/quantum_clifford.py
+++ b/src/sage/algebras/quantum_clifford.py
@@ -27,7 +27,7 @@
from sage.rings.fraction_field import FractionField
from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
from itertools import product
-from sage.misc.misc import powerset
+from sage.combinat.subset import powerset
class QuantumCliffordAlgebra(CombinatorialFreeModule):
r"""
diff --git a/src/sage/all.py b/src/sage/all.py
index 288039a72f4..f3433d56961 100644
--- a/src/sage/all.py
+++ b/src/sage/all.py
@@ -85,7 +85,6 @@
from sage.arith.all import *
from sage.matrix.all import *
-from sage.symbolic.all import *
from sage.modules.all import *
from sage.monoids.all import *
from sage.algebras.all import *
@@ -101,9 +100,6 @@
from sage.probability.all import *
from sage.interfaces.all import *
-from sage.functions.all import *
-from sage.calculus.all import *
-
lazy_import('sage.tests', 'all', as_='tests', deprecation=27337)
from sage.cpython.all import *
@@ -116,11 +112,8 @@
from sage.coding.all import *
from sage.combinat.all import *
-from sage.lfunctions.all import *
-
from sage.geometry.all import *
from sage.geometry.triangulation.all import *
-from sage.geometry.riemannian_manifolds.all import *
from sage.dynamics.all import *
@@ -158,8 +151,6 @@
from sage.knots.all import *
-from sage.manifolds.all import *
-
from cysignals.alarm import alarm, cancel_alarm
# Lazily import interacts (#15335)
@@ -171,6 +162,16 @@
from sage.rings.qqbar import _init_qqbar
_init_qqbar()
+try:
+ from sage.symbolic.all import *
+ from sage.functions.all import *
+ from sage.calculus.all import *
+ from sage.manifolds.all import *
+ from sage.lfunctions.all import *
+ from sage.geometry.riemannian_manifolds.all import *
+except ImportError:
+ pass
+
###########################################################
#### WARNING:
# DO *not* import numpy / matplotlib / networkx here!!
diff --git a/src/sage/all_cmdline.py b/src/sage/all_cmdline.py
index 197d34ebc90..836a649d747 100644
--- a/src/sage/all_cmdline.py
+++ b/src/sage/all_cmdline.py
@@ -15,7 +15,11 @@
sage_mode = 'cmdline'
from sage.all import *
-from sage.calculus.predefined import x
+
+try:
+ from sage.calculus.predefined import x
+except ImportError:
+ pass
from sage.misc.lazy_import import lazy_import
diff --git a/src/sage/arith/all.py b/src/sage/arith/all.py
index c93e9f05bc9..b826b6557d0 100644
--- a/src/sage/arith/all.py
+++ b/src/sage/arith/all.py
@@ -24,6 +24,10 @@
dedekind_sum,
prime_factors, prime_range, valuation)
+# These will be overridden by sage.functions.all
+from .misc import (integer_ceil as ceil,
+ integer_floor as floor)
+
lazy_import('sage.arith.misc', ('Sigma', 'Moebius', 'Euler_Phi'), deprecation=30322)
from .functions import lcm
diff --git a/src/sage/arith/functions.pyx b/src/sage/arith/functions.pyx
index 2fe15bbb974..58a1fc91bd9 100644
--- a/src/sage/arith/functions.pyx
+++ b/src/sage/arith/functions.pyx
@@ -39,17 +39,17 @@ def lcm(a, b=None):
EXAMPLES::
- sage: lcm(97,100)
+ sage: lcm(97, 100)
9700
- sage: LCM(97,100)
+ sage: LCM(97, 100)
9700
- sage: LCM(0,2)
+ sage: LCM(0, 2)
0
- sage: LCM(-3,-5)
+ sage: LCM(-3, -5)
15
sage: LCM([1,2,3,4,5])
60
- sage: v = LCM(range(1,10000)) # *very* fast!
+ sage: v = LCM(range(1, 10000)) # *very* fast!
sage: len(str(v))
4349
@@ -72,25 +72,25 @@ def lcm(a, b=None):
Make sure we try `\QQ` and not merely `\ZZ` (:trac:`13014`)::
- sage: bool(lcm(2/5, 3/7) == lcm(SR(2/5), SR(3/7)))
+ sage: bool(lcm(2/5, 3/7) == lcm(SR(2/5), SR(3/7))) # optional - sage.symbolic
True
Make sure that the lcm of Expressions stays symbolic::
sage: parent(lcm(2, 4))
Integer Ring
- sage: parent(lcm(SR(2), 4))
+ sage: parent(lcm(SR(2), 4)) # optional - sage.symbolic
Symbolic Ring
- sage: parent(lcm(2, SR(4)))
+ sage: parent(lcm(2, SR(4))) # optional - sage.symbolic
Symbolic Ring
- sage: parent(lcm(SR(2), SR(4)))
+ sage: parent(lcm(SR(2), SR(4))) # optional - sage.symbolic
Symbolic Ring
Verify that objects without lcm methods but which can't be
coerced to `\ZZ` or `\QQ` raise an error::
- sage: F. = FreeMonoid(2)
- sage: lcm(x,y)
+ sage: F. = FreeMonoid(2) # optional - sage.groups
+ sage: lcm(x,y) # optional - sage.groups
Traceback (most recent call last):
...
TypeError: unable to find lcm of x and y
diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
index 9c671105c5a..2e975bc7ffd 100644
--- a/src/sage/arith/misc.py
+++ b/src/sage/arith/misc.py
@@ -20,7 +20,6 @@
import math
from collections.abc import Iterable
-from sage.misc.misc import powerset
from sage.misc.misc_c import prod
from sage.structure.element import parent
@@ -82,26 +81,26 @@ def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None,
EXAMPLES::
- sage: algdep(1.888888888888888, 1)
+ sage: algdep(1.888888888888888, 1) # optional - sage.libs.pari
9*x - 17
- sage: algdep(0.12121212121212,1)
+ sage: algdep(0.12121212121212, 1) # optional - sage.libs.pari
33*x - 4
- sage: algdep(sqrt(2),2)
+ sage: algdep(sqrt(2), 2) # optional - sage.libs.pari sage.symbolic
x^2 - 2
This example involves a complex number::
- sage: z = (1/2)*(1 + RDF(sqrt(3)) *CC.0); z
+ sage: z = (1/2) * (1 + RDF(sqrt(3)) * CC.0); z # optional - sage.symbolic
0.500000000000000 + 0.866025403784439*I
- sage: algdep(z, 6)
+ sage: algdep(z, 6) # optional - sage.symbolic
x^2 - x + 1
This example involves a `p`-adic number::
- sage: K = Qp(3, print_mode = 'series')
- sage: a = K(7/19); a
+ sage: K = Qp(3, print_mode='series') # optional - sage.rings.padics
+ sage: a = K(7/19); a # optional - sage.rings.padics
1 + 2*3 + 3^2 + 3^3 + 2*3^4 + 2*3^5 + 3^8 + 2*3^9 + 3^11 + 3^12 + 2*3^15 + 2*3^16 + 3^17 + 2*3^19 + O(3^20)
- sage: algdep(a, 1)
+ sage: algdep(a, 1) # optional - sage.rings.padics
19*x - 7
These examples show the importance of proper precision control. We
@@ -109,82 +108,82 @@ def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None,
33'rd bit::
sage: z = sqrt(RealField(200)(2)) + (1/2)^33
- sage: p = algdep(z, 4); p
+ sage: p = algdep(z, 4); p # optional - sage.libs.pari
227004321085*x^4 - 216947902586*x^3 - 99411220986*x^2 + 82234881648*x - 211871195088
- sage: factor(p)
+ sage: factor(p) # optional - sage.libs.pari
227004321085*x^4 - 216947902586*x^3 - 99411220986*x^2 + 82234881648*x - 211871195088
- sage: algdep(z, 4, known_bits=32)
+ sage: algdep(z, 4, known_bits=32) # optional - sage.libs.pari
x^2 - 2
- sage: algdep(z, 4, known_digits=10)
+ sage: algdep(z, 4, known_digits=10) # optional - sage.libs.pari
x^2 - 2
- sage: algdep(z, 4, use_bits=25)
+ sage: algdep(z, 4, use_bits=25) # optional - sage.libs.pari
x^2 - 2
- sage: algdep(z, 4, use_digits=8)
+ sage: algdep(z, 4, use_digits=8) # optional - sage.libs.pari
x^2 - 2
Using the ``height_bound`` and ``proof`` parameters, we can see that
`pi` is not the root of an integer polynomial of degree at most 5
and coefficients bounded above by 10::
- sage: algdep(pi.n(), 5, height_bound=10, proof=True) is None
+ sage: algdep(pi.n(), 5, height_bound=10, proof=True) is None # optional - sage.libs.pari sage.symbolic
True
For stronger results, we need more precision::
- sage: algdep(pi.n(), 5, height_bound=100, proof=True) is None
+ sage: algdep(pi.n(), 5, height_bound=100, proof=True) is None # optional - sage.libs.pari sage.symbolic
Traceback (most recent call last):
...
ValueError: insufficient precision for non-existence proof
- sage: algdep(pi.n(200), 5, height_bound=100, proof=True) is None
+ sage: algdep(pi.n(200), 5, height_bound=100, proof=True) is None # optional - sage.libs.pari sage.symbolic
True
- sage: algdep(pi.n(), 10, height_bound=10, proof=True) is None
+ sage: algdep(pi.n(), 10, height_bound=10, proof=True) is None # optional - sage.libs.pari sage.symbolic
Traceback (most recent call last):
...
ValueError: insufficient precision for non-existence proof
- sage: algdep(pi.n(200), 10, height_bound=10, proof=True) is None
+ sage: algdep(pi.n(200), 10, height_bound=10, proof=True) is None # optional - sage.libs.pari sage.symbolic
True
We can also use ``proof=True`` to get positive results::
- sage: a = sqrt(2) + sqrt(3) + sqrt(5)
- sage: algdep(a.n(), 8, height_bound=1000, proof=True)
+ sage: a = sqrt(2) + sqrt(3) + sqrt(5) # optional - sage.libs.pari sage.symbolic
+ sage: algdep(a.n(), 8, height_bound=1000, proof=True) # optional - sage.libs.pari sage.symbolic
Traceback (most recent call last):
...
ValueError: insufficient precision for uniqueness proof
- sage: f = algdep(a.n(1000), 8, height_bound=1000, proof=True); f
+ sage: f = algdep(a.n(1000), 8, height_bound=1000, proof=True); f # optional - sage.libs.pari sage.symbolic
x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576
- sage: f(a).expand()
+ sage: f(a).expand() # optional - sage.libs.pari sage.symbolic
0
TESTS::
- sage: algdep(complex("1+2j"), 4)
+ sage: algdep(complex("1+2j"), 4) # optional - sage.libs.pari
x^2 - 2*x + 5
We get an irreducible polynomial even if PARI returns a reducible
one::
sage: z = CDF(1, RR(3).sqrt())/2
- sage: pari(z).algdep(5)
+ sage: pari(z).algdep(5) # optional - sage.libs.pari
x^5 + x^2
- sage: algdep(z, 5)
+ sage: algdep(z, 5) # optional - sage.libs.pari
x^2 - x + 1
Check that cases where a constant polynomial might look better
get handled correctly::
- sage: z=CC(-1)**(1/3)
- sage: algdep(z,1)
+ sage: z = CC(-1)**(1/3)
+ sage: algdep(z, 1) # optional - sage.libs.pari
x
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8, float64
- sage: algdep(float64(1.888888888888888), int8(1))
+ sage: from numpy import int8, float64 # optional - numpy
+ sage: algdep(float64(1.888888888888888), int8(1)) # optional - numpy sage.libs.pari
9*x - 17
sage: from gmpy2 import mpz, mpfr
- sage: algdep(mpfr(1.888888888888888), mpz(1))
+ sage: algdep(mpfr(1.888888888888888), mpz(1)) # optional - sage.libs.pari
9*x - 17
"""
if proof and not height_bound:
@@ -303,47 +302,54 @@ def bernoulli(n, algorithm='default', num_threads=1):
EXAMPLES::
- sage: bernoulli(12)
+ sage: bernoulli(12) # optional - sage.libs.flint
-691/2730
- sage: bernoulli(50)
+ sage: bernoulli(50) # optional - sage.libs.flint
495057205241079648212477525/66
We demonstrate each of the alternative algorithms::
- sage: bernoulli(12, algorithm='arb')
+ sage: bernoulli(12, algorithm='arb') # optional - sage.libs.flint
-691/2730
- sage: bernoulli(12, algorithm='flint')
+ sage: bernoulli(12, algorithm='flint') # optional - sage.libs.flint
-691/2730
- sage: bernoulli(12, algorithm='gap')
+ sage: bernoulli(12, algorithm='gap') # optional - sage.libs.gap
-691/2730
- sage: bernoulli(12, algorithm='gp')
+ sage: bernoulli(12, algorithm='gp') # optional - sage.libs.pari
-691/2730
sage: bernoulli(12, algorithm='magma') # optional - magma
-691/2730
- sage: bernoulli(12, algorithm='pari')
+ sage: bernoulli(12, algorithm='pari') # optional - sage.libs.pari
-691/2730
- sage: bernoulli(12, algorithm='bernmm')
+ sage: bernoulli(12, algorithm='bernmm') # optional - sage.libs.ntl
-691/2730
- sage: bernoulli(12, algorithm='bernmm', num_threads=4)
+ sage: bernoulli(12, algorithm='bernmm', num_threads=4) # optional - sage.libs.ntl
-691/2730
TESTS::
- sage: algs = ['arb', 'gap', 'gp', 'pari', 'bernmm', 'flint']
+ sage: algs = []
+ sage: algs += ['arb'] # optional - sage.libs.flint
+ sage: algs += ['gap'] # optional - sage.libs.gap
+ sage: algs += ['gp', 'pari'] # optional - sage.libs.pari
+ sage: algs += ['bernmm'] # optional - sage.libs.ntl
+ sage: algs += ['flint'] # optional - sage.libs.flint
sage: test_list = [ZZ.random_element(2, 2255) for _ in range(500)]
sage: vals = [[bernoulli(i, algorithm=j) for j in algs] for i in test_list] # long time (up to 21s on sage.math, 2011)
- sage: all(len(set(x))==1 for x in vals) # long time (depends on previous line)
+ sage: all(len(set(x)) == 1 for x in vals) # long time (depends on previous line)
True
- sage: algs = ['gp', 'pari', 'bernmm']
+ sage: algs = []
+ sage: algs += ['gp', 'pari'] # optional - sage.libs.pari
+ sage: algs += ['bernmm'] # optional - sage.libs.ntl
sage: test_list = [ZZ.random_element(2256, 5000) for _ in range(500)]
sage: vals = [[bernoulli(i, algorithm=j) for j in algs] for i in test_list] # long time (up to 30s on sage.math, 2011)
sage: all(len(set(x))==1 for x in vals) # long time (depends on previous line)
True
- sage: from numpy import int8
- sage: bernoulli(int8(12))
+ sage: from numpy import int8 # optional - numpy
+ sage: bernoulli(int8(12)) # optional - numpy sage.libs.flint
-691/2730
sage: from gmpy2 import mpz
- sage: bernoulli(mpz(12))
+ sage: bernoulli(mpz(12)) # optional - sage.libs.flint
-691/2730
AUTHOR:
@@ -433,8 +439,8 @@ def factorial(n, algorithm='gmp'):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: factorial(int8(4))
+ sage: from numpy import int8 # optional - numpy
+ sage: factorial(int8(4)) # optional - numpy
24
sage: from gmpy2 import mpz
sage: factorial(mpz(4))
@@ -519,7 +525,7 @@ def is_prime(n):
sage: a = 2**2048 + 981
sage: is_prime(a) # not tested - takes ~ 1min
sage: proof.arithmetic(False)
- sage: is_prime(a) # instantaneous!
+ sage: is_prime(a) # instantaneous! # optional - sage.libs.pari
True
sage: proof.arithmetic(True)
@@ -543,8 +549,9 @@ def is_prime(n):
However, number fields redefine ``.is_prime()`` in an incompatible fashion
(cf. :trac:`32340`) and we should not warn::
- sage: K. = NumberField(x^2+1)
- sage: is_prime(1+i)
+ sage: x = polygen(ZZ, 'x')
+ sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field
+ sage: is_prime(1 + i) # optional - sage.rings.number_field
True
"""
try:
@@ -585,19 +592,19 @@ def is_pseudoprime(n):
EXAMPLES::
- sage: is_pseudoprime(389)
+ sage: is_pseudoprime(389) # optional - sage.libs.pari
True
- sage: is_pseudoprime(2000)
+ sage: is_pseudoprime(2000) # optional - sage.libs.pari
False
- sage: is_pseudoprime(2)
+ sage: is_pseudoprime(2) # optional - sage.libs.pari
True
- sage: is_pseudoprime(-1)
+ sage: is_pseudoprime(-1) # optional - sage.libs.pari
False
sage: factor(-6)
-1 * 2 * 3
- sage: is_pseudoprime(1)
+ sage: is_pseudoprime(1) # optional - sage.libs.pari
False
- sage: is_pseudoprime(-2)
+ sage: is_pseudoprime(-2) # optional - sage.libs.pari
False
"""
return ZZ(n).is_pseudoprime()
@@ -620,51 +627,51 @@ def is_prime_power(n, get_data=False):
EXAMPLES::
- sage: is_prime_power(389)
+ sage: is_prime_power(389) # optional - sage.libs.pari
True
- sage: is_prime_power(2000)
+ sage: is_prime_power(2000) # optional - sage.libs.pari
False
- sage: is_prime_power(2)
+ sage: is_prime_power(2) # optional - sage.libs.pari
True
- sage: is_prime_power(1024)
+ sage: is_prime_power(1024) # optional - sage.libs.pari
True
- sage: is_prime_power(1024, get_data=True)
+ sage: is_prime_power(1024, get_data=True) # optional - sage.libs.pari
(2, 10)
The same results can be obtained with::
- sage: 389.is_prime_power()
+ sage: 389.is_prime_power() # optional - sage.libs.pari
True
- sage: 2000.is_prime_power()
+ sage: 2000.is_prime_power() # optional - sage.libs.pari
False
- sage: 2.is_prime_power()
+ sage: 2.is_prime_power() # optional - sage.libs.pari
True
- sage: 1024.is_prime_power()
+ sage: 1024.is_prime_power() # optional - sage.libs.pari
True
- sage: 1024.is_prime_power(get_data=True)
+ sage: 1024.is_prime_power(get_data=True) # optional - sage.libs.pari
(2, 10)
TESTS::
- sage: is_prime_power(-1)
+ sage: is_prime_power(-1) # optional - sage.libs.pari
False
- sage: is_prime_power(1)
+ sage: is_prime_power(1) # optional - sage.libs.pari
False
- sage: is_prime_power(QQ(997^100))
+ sage: is_prime_power(QQ(997^100)) # optional - sage.libs.pari
True
- sage: is_prime_power(1/2197)
+ sage: is_prime_power(1/2197) # optional - sage.libs.pari
Traceback (most recent call last):
...
TypeError: no conversion of this rational to integer
- sage: is_prime_power("foo")
+ sage: is_prime_power("foo") # optional - sage.libs.pari
Traceback (most recent call last):
...
TypeError: unable to convert 'foo' to an integer
sage: from gmpy2 import mpz
- sage: is_prime_power(mpz(389))
+ sage: is_prime_power(mpz(389)) # optional - sage.libs.pari
True
- sage: from numpy import int16
- sage: is_prime_power(int16(389))
+ sage: from numpy import int16 # optional - numpy
+ sage: is_prime_power(int16(389)) # optional - numpy sage.libs.pari
True
"""
return ZZ(n).is_prime_power(get_data=get_data)
@@ -687,39 +694,39 @@ def is_pseudoprime_power(n, get_data=False):
EXAMPLES::
- sage: is_pseudoprime_power(389)
+ sage: is_pseudoprime_power(389) # optional - sage.libs.pari
True
- sage: is_pseudoprime_power(2000)
+ sage: is_pseudoprime_power(2000) # optional - sage.libs.pari
False
- sage: is_pseudoprime_power(2)
+ sage: is_pseudoprime_power(2) # optional - sage.libs.pari
True
- sage: is_pseudoprime_power(1024)
+ sage: is_pseudoprime_power(1024) # optional - sage.libs.pari
True
- sage: is_pseudoprime_power(-1)
+ sage: is_pseudoprime_power(-1) # optional - sage.libs.pari
False
- sage: is_pseudoprime_power(1)
+ sage: is_pseudoprime_power(1) # optional - sage.libs.pari
False
- sage: is_pseudoprime_power(997^100)
+ sage: is_pseudoprime_power(997^100) # optional - sage.libs.pari
True
Use of the get_data keyword::
- sage: is_pseudoprime_power(3^1024, get_data=True)
+ sage: is_pseudoprime_power(3^1024, get_data=True) # optional - sage.libs.pari
(3, 1024)
- sage: is_pseudoprime_power(2^256, get_data=True)
+ sage: is_pseudoprime_power(2^256, get_data=True) # optional - sage.libs.pari
(2, 256)
- sage: is_pseudoprime_power(31, get_data=True)
+ sage: is_pseudoprime_power(31, get_data=True) # optional - sage.libs.pari
(31, 1)
- sage: is_pseudoprime_power(15, get_data=True)
+ sage: is_pseudoprime_power(15, get_data=True) # optional - sage.libs.pari
(15, 0)
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int16
- sage: is_pseudoprime_power(int16(1024))
+ sage: from numpy import int16 # optional - numpy
+ sage: is_pseudoprime_power(int16(1024)) # optional - numpy sage.libs.pari
True
sage: from gmpy2 import mpz
- sage: is_pseudoprime_power(mpz(1024))
+ sage: is_pseudoprime_power(mpz(1024)) # optional - sage.libs.pari
True
"""
return ZZ(n).is_prime_power(proof=False, get_data=get_data)
@@ -783,8 +790,8 @@ def valuation(m, *args, **kwds):
Traceback (most recent call last):
...
ValueError: You can only compute the valuation with respect to a integer larger than 1.
- sage: from numpy import int16
- sage: valuation(int16(512), int16(2))
+ sage: from numpy import int16 # optional - numpy
+ sage: valuation(int16(512), int16(2)) # optional - numpy
9
sage: from gmpy2 import mpz
sage: valuation(mpz(512), mpz(2))
@@ -821,49 +828,49 @@ def prime_powers(start, stop=None):
EXAMPLES::
- sage: prime_powers(20)
+ sage: prime_powers(20) # optional - sage.libs.pari
[2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19]
- sage: len(prime_powers(1000))
+ sage: len(prime_powers(1000)) # optional - sage.libs.pari
193
- sage: len(prime_range(1000))
+ sage: len(prime_range(1000)) # optional - sage.libs.pari
168
- sage: a = [z for z in range(95,1234) if is_prime_power(z)]
- sage: b = prime_powers(95,1234)
- sage: len(b)
+ sage: a = [z for z in range(95, 1234) if is_prime_power(z)] # optional - sage.libs.pari
+ sage: b = prime_powers(95, 1234) # optional - sage.libs.pari
+ sage: len(b) # optional - sage.libs.pari
194
- sage: len(a)
+ sage: len(a) # optional - sage.libs.pari
194
- sage: a[:10]
+ sage: a[:10] # optional - sage.libs.pari
[97, 101, 103, 107, 109, 113, 121, 125, 127, 128]
- sage: b[:10]
+ sage: b[:10] # optional - sage.libs.pari
[97, 101, 103, 107, 109, 113, 121, 125, 127, 128]
- sage: a == b
+ sage: a == b # optional - sage.libs.pari
True
- sage: prime_powers(100) == [i for i in range(100) if is_prime_power(i)]
+ sage: prime_powers(100) == [i for i in range(100) if is_prime_power(i)] # optional - sage.libs.pari
True
- sage: prime_powers(10,7)
+ sage: prime_powers(10, 7) # optional - sage.libs.pari
[]
- sage: prime_powers(-5)
+ sage: prime_powers(-5) # optional - sage.libs.pari
[]
- sage: prime_powers(-1,3)
+ sage: prime_powers(-1, 3) # optional - sage.libs.pari
[2]
TESTS:
Check that output are always Sage integers (:trac:`922`)::
- sage: v = prime_powers(10)
- sage: type(v[0])
+ sage: v = prime_powers(10) # optional - sage.libs.pari
+ sage: type(v[0]) # optional - sage.libs.pari
- sage: prime_powers(0,1)
+ sage: prime_powers(0, 1) # optional - sage.libs.pari
[]
- sage: prime_powers(2)
+ sage: prime_powers(2) # optional - sage.libs.pari
[]
- sage: prime_powers(3)
+ sage: prime_powers(3) # optional - sage.libs.pari
[2]
sage: prime_powers("foo")
@@ -878,18 +885,18 @@ def prime_powers(start, stop=None):
Check that long input are accepted (:trac:`17852`)::
- sage: prime_powers(6l)
+ sage: prime_powers(6l) # optional - sage.libs.pari
[2, 3, 4, 5]
- sage: prime_powers(6l,10l)
+ sage: prime_powers(6l, 10l) # optional - sage.libs.pari
[7, 8, 9]
Check numpy and gmpy2 support::
- sage: from numpy import int8
- sage: prime_powers(int8(20))
+ sage: from numpy import int8 # optional - numpy
+ sage: prime_powers(int8(20)) # optional - numpy sage.libs.pari
[2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19]
sage: from gmpy2 import mpz
- sage: prime_powers(mpz(20))
+ sage: prime_powers(mpz(20)) # optional - sage.libs.pari
[2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19]
"""
start = ZZ(start)
@@ -931,11 +938,11 @@ def primes_first_n(n, leave_pari=False):
EXAMPLES::
- sage: primes_first_n(10)
+ sage: primes_first_n(10) # optional - sage.libs.pari
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
- sage: len(primes_first_n(1000))
+ sage: len(primes_first_n(1000)) # optional - sage.libs.pari
1000
- sage: primes_first_n(0)
+ sage: primes_first_n(0) # optional - sage.libs.pari
[]
"""
if n < 0:
@@ -973,13 +980,13 @@ def eratosthenes(n):
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
sage: len(eratosthenes(100))
25
- sage: eratosthenes(213) == prime_range(213)
+ sage: eratosthenes(213) == prime_range(213) # optional - sage.libs.pari
True
TESTS::
- sage: from numpy import int8
- sage: eratosthenes(int8(3))
+ sage: from numpy import int8 # optional - numpy
+ sage: eratosthenes(int8(3)) # optional - numpy
[2, 3]
sage: from gmpy2 import mpz
sage: eratosthenes(mpz(3))
@@ -1046,41 +1053,41 @@ def primes(start=2, stop=None, proof=None):
EXAMPLES::
- sage: for p in primes(5,10):
+ sage: for p in primes(5, 10): # optional - sage.libs.pari
....: print(p)
5
7
- sage: list(primes(13))
+ sage: list(primes(13)) # optional - sage.libs.pari
[2, 3, 5, 7, 11]
- sage: list(primes(10000000000, 10000000100))
+ sage: list(primes(10000000000, 10000000100)) # optional - sage.libs.pari
[10000000019, 10000000033, 10000000061, 10000000069, 10000000097]
- sage: max(primes(10^100, 10^100+10^4, proof=False))
+ sage: max(primes(10^100, 10^100+10^4, proof=False)) # optional - sage.libs.pari
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009631
- sage: next(p for p in primes(10^20, infinity) if is_prime(2*p+1))
+ sage: next(p for p in primes(10^20, infinity) if is_prime(2*p+1)) # optional - sage.libs.pari
100000000000000001243
TESTS::
- sage: for a in range(-10, 50):
+ sage: for a in range(-10, 50): # optional - sage.libs.pari
....: for b in range(-10, 50):
....: assert list(primes(a,b)) == list(filter(is_prime, range(a,b)))
- sage: sum(primes(-10, 9973, proof=False)) == sum(filter(is_prime, range(-10, 9973)))
+ sage: sum(primes(-10, 9973, proof=False)) == sum(filter(is_prime, range(-10, 9973))) # optional - sage.libs.pari
True
- sage: for p in primes(10, infinity):
+ sage: for p in primes(10, infinity): # optional - sage.libs.pari
....: if p > 20: break
....: print(p)
11
13
17
19
- sage: next(p for p in primes(10,oo)) # checks alternate infinity notation
+ sage: next(p for p in primes(10,oo)) # checks alternate infinity notation # optional - sage.libs.pari
11
- sage: from numpy import int8
- sage: list(primes(int8(13)))
+ sage: from numpy import int8 # optional - numpy
+ sage: list(primes(int8(13))) # optional - numpy sage.libs.pari
[2, 3, 5, 7, 11]
sage: from gmpy2 import mpz
- sage: list(primes(mpz(13)))
+ sage: list(primes(mpz(13))) # optional - sage.libs.pari
[2, 3, 5, 7, 11]
"""
from sage.rings.infinity import infinity
@@ -1120,40 +1127,40 @@ def next_prime_power(n):
EXAMPLES::
- sage: next_prime_power(1)
+ sage: next_prime_power(1) # optional - sage.libs.pari
2
- sage: next_prime_power(2)
+ sage: next_prime_power(2) # optional - sage.libs.pari
3
- sage: next_prime_power(10)
+ sage: next_prime_power(10) # optional - sage.libs.pari
11
- sage: next_prime_power(7)
+ sage: next_prime_power(7) # optional - sage.libs.pari
8
- sage: next_prime_power(99)
+ sage: next_prime_power(99) # optional - sage.libs.pari
101
The same results can be obtained with::
- sage: 1.next_prime_power()
+ sage: 1.next_prime_power() # optional - sage.libs.pari
2
- sage: 2.next_prime_power()
+ sage: 2.next_prime_power() # optional - sage.libs.pari
3
- sage: 10.next_prime_power()
+ sage: 10.next_prime_power() # optional - sage.libs.pari
11
Note that `2` is the smallest prime power::
- sage: next_prime_power(-10)
+ sage: next_prime_power(-10) # optional - sage.libs.pari
2
- sage: next_prime_power(0)
+ sage: next_prime_power(0) # optional - sage.libs.pari
2
TESTS::
- sage: from numpy import int8
- sage: next_prime_power(int8(10))
+ sage: from numpy import int8 # optional - numpy
+ sage: next_prime_power(int8(10)) # optional - numpy sage.libs.pari
11
sage: from gmpy2 import mpz
- sage: next_prime_power(mpz(10))
+ sage: next_prime_power(mpz(10)) # optional - sage.libs.pari
11
"""
return ZZ(n).next_prime_power()
@@ -1171,22 +1178,22 @@ def next_probable_prime(n):
EXAMPLES::
- sage: next_probable_prime(-100)
+ sage: next_probable_prime(-100) # optional - sage.libs.pari
2
- sage: next_probable_prime(19)
+ sage: next_probable_prime(19) # optional - sage.libs.pari
23
- sage: next_probable_prime(int(999999999))
+ sage: next_probable_prime(int(999999999)) # optional - sage.libs.pari
1000000007
- sage: next_probable_prime(2^768)
+ sage: next_probable_prime(2^768) # optional - sage.libs.pari
1552518092300708935148979488462502555256886017116696611139052038026050952686376886330878408828646477950487730697131073206171580044114814391444287275041181139204454976020849905550265285631598444825262999193716468750892846853816058039
TESTS::
- sage: from numpy import int8
- sage: next_probable_prime(int8(19))
+ sage: from numpy import int8 # optional - numpy
+ sage: next_probable_prime(int8(19)) # optional - numpy sage.libs.pari
23
sage: from gmpy2 import mpz
- sage: next_probable_prime(mpz(19))
+ sage: next_probable_prime(mpz(19)) # optional - sage.libs.pari
23
"""
return ZZ(n).next_probable_prime()
@@ -1210,33 +1217,33 @@ def next_prime(n, proof=None):
EXAMPLES::
- sage: next_prime(-100)
+ sage: next_prime(-100) # optional - sage.libs.pari
2
- sage: next_prime(1)
+ sage: next_prime(1) # optional - sage.libs.pari
2
- sage: next_prime(2)
+ sage: next_prime(2) # optional - sage.libs.pari
3
- sage: next_prime(3)
+ sage: next_prime(3) # optional - sage.libs.pari
5
- sage: next_prime(4)
+ sage: next_prime(4) # optional - sage.libs.pari
5
Notice that the next_prime(5) is not 5 but 7.
::
- sage: next_prime(5)
+ sage: next_prime(5) # optional - sage.libs.pari
7
- sage: next_prime(2004)
+ sage: next_prime(2004) # optional - sage.libs.pari
2011
TESTS::
- sage: from numpy import int8
- sage: next_prime(int8(3))
+ sage: from numpy import int8 # optional - numpy
+ sage: next_prime(int8(3)) # optional - numpy sage.libs.pari
5
sage: from gmpy2 import mpz
- sage: next_probable_prime(mpz(3))
+ sage: next_probable_prime(mpz(3)) # optional - sage.libs.pari
5
"""
return ZZ(n).next_prime(proof)
@@ -1249,38 +1256,38 @@ def previous_prime(n):
EXAMPLES::
- sage: previous_prime(10)
+ sage: previous_prime(10) # optional - sage.libs.pari
7
- sage: previous_prime(7)
+ sage: previous_prime(7) # optional - sage.libs.pari
5
- sage: previous_prime(8)
+ sage: previous_prime(8) # optional - sage.libs.pari
7
- sage: previous_prime(7)
+ sage: previous_prime(7) # optional - sage.libs.pari
5
- sage: previous_prime(5)
+ sage: previous_prime(5) # optional - sage.libs.pari
3
- sage: previous_prime(3)
+ sage: previous_prime(3) # optional - sage.libs.pari
2
- sage: previous_prime(2)
+ sage: previous_prime(2) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no previous prime
- sage: previous_prime(1)
+ sage: previous_prime(1) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no previous prime
- sage: previous_prime(-20)
+ sage: previous_prime(-20) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no previous prime
TESTS::
- sage: from numpy import int8
- sage: previous_prime(int8(7))
+ sage: from numpy import int8 # optional - numpy
+ sage: previous_prime(int8(7)) # optional - numpy sage.libs.pari
5
sage: from gmpy2 import mpz
- sage: previous_prime(mpz(7))
+ sage: previous_prime(mpz(7)) # optional - sage.libs.pari
5
"""
n = ZZ(n) - 1
@@ -1315,52 +1322,52 @@ def previous_prime_power(n):
EXAMPLES::
- sage: previous_prime_power(3)
+ sage: previous_prime_power(3) # optional - sage.libs.pari
2
- sage: previous_prime_power(10)
+ sage: previous_prime_power(10) # optional - sage.libs.pari
9
- sage: previous_prime_power(7)
+ sage: previous_prime_power(7) # optional - sage.libs.pari
5
- sage: previous_prime_power(127)
+ sage: previous_prime_power(127) # optional - sage.libs.pari
125
The same results can be obtained with::
- sage: 3.previous_prime_power()
+ sage: 3.previous_prime_power() # optional - sage.libs.pari
2
- sage: 10.previous_prime_power()
+ sage: 10.previous_prime_power() # optional - sage.libs.pari
9
- sage: 7.previous_prime_power()
+ sage: 7.previous_prime_power() # optional - sage.libs.pari
5
- sage: 127.previous_prime_power()
+ sage: 127.previous_prime_power() # optional - sage.libs.pari
125
Input less than or equal to `2` raises errors::
- sage: previous_prime_power(2)
+ sage: previous_prime_power(2) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no prime power less than 2
- sage: previous_prime_power(-10)
+ sage: previous_prime_power(-10) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no prime power less than 2
::
- sage: n = previous_prime_power(2^16 - 1)
- sage: while is_prime(n):
+ sage: n = previous_prime_power(2^16 - 1) # optional - sage.libs.pari
+ sage: while is_prime(n): # optional - sage.libs.pari
....: n = previous_prime_power(n)
- sage: factor(n)
+ sage: factor(n) # optional - sage.libs.pari
251^2
TESTS::
- sage: from numpy import int8
- sage: previous_prime_power(int8(10))
+ sage: from numpy import int8 # optional - numpy
+ sage: previous_prime_power(int8(10)) # optional - numpy sage.libs.pari
9
sage: from gmpy2 import mpz
- sage: previous_prime_power(mpz(10))
+ sage: previous_prime_power(mpz(10)) # optional - sage.libs.pari
9
"""
return ZZ(n).previous_prime_power()
@@ -1388,42 +1395,42 @@ def random_prime(n, proof=None, lbound=2):
EXAMPLES::
- sage: p = random_prime(100000)
- sage: p.is_prime()
+ sage: p = random_prime(100000) # optional - sage.libs.pari
+ sage: p.is_prime() # optional - sage.libs.pari
True
- sage: p <= 100000
+ sage: p <= 100000 # optional - sage.libs.pari
True
- sage: random_prime(2)
+ sage: random_prime(2) # optional - sage.libs.pari
2
Here we generate a random prime between 100 and 200::
- sage: p = random_prime(200, lbound=100)
- sage: p.is_prime()
+ sage: p = random_prime(200, lbound=100) # optional - sage.libs.pari
+ sage: p.is_prime() # optional - sage.libs.pari
True
- sage: 100 <= p <= 200
+ sage: 100 <= p <= 200 # optional - sage.libs.pari
True
If all we care about is finding a pseudo prime, then we can pass
in ``proof=False`` ::
- sage: p = random_prime(200, proof=False, lbound=100)
- sage: p.is_pseudoprime()
+ sage: p = random_prime(200, proof=False, lbound=100) # optional - sage.libs.pari
+ sage: p.is_pseudoprime() # optional - sage.libs.pari
True
- sage: 100 <= p <= 200
+ sage: 100 <= p <= 200 # optional - sage.libs.pari
True
TESTS::
- sage: type(random_prime(2))
+ sage: type(random_prime(2)) # optional - sage.libs.pari
- sage: type(random_prime(100))
+ sage: type(random_prime(100)) # optional - sage.libs.pari
- sage: random_prime(1, lbound=-2) #caused Sage hang #10112
+ sage: random_prime(1, lbound=-2) #caused Sage hang #10112 # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: n must be greater than or equal to 2
- sage: random_prime(126, lbound=114)
+ sage: random_prime(126, lbound=114) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: there are no primes between 114 and 126 (inclusive)
@@ -1515,22 +1522,22 @@ def divisors(n):
This function works whenever one has unique factorization::
- sage: K. = QuadraticField(7)
- sage: divisors(K.ideal(7))
+ sage: K. = QuadraticField(7) # optional - sage.rings.number_field
+ sage: divisors(K.ideal(7)) # optional - sage.rings.number_field
[Fractional ideal (1), Fractional ideal (a), Fractional ideal (7)]
- sage: divisors(K.ideal(3))
+ sage: divisors(K.ideal(3)) # optional - sage.rings.number_field
[Fractional ideal (1), Fractional ideal (3),
- Fractional ideal (a - 2), Fractional ideal (a + 2)]
- sage: divisors(K.ideal(35))
+ Fractional ideal (a - 2), Fractional ideal (a + 2)]
+ sage: divisors(K.ideal(35)) # optional - sage.rings.number_field
[Fractional ideal (1), Fractional ideal (5), Fractional ideal (a),
- Fractional ideal (7), Fractional ideal (5*a), Fractional ideal (35)]
+ Fractional ideal (7), Fractional ideal (5*a), Fractional ideal (35)]
TESTS::
sage: divisors(int(300))
[1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 25, 30, 50, 60, 75, 100, 150, 300]
- sage: import numpy
- sage: divisors(numpy.int8(100))
+ sage: import numpy # optional - numpy
+ sage: divisors(numpy.int8(100)) # optional - numpy
[1, 2, 4, 5, 10, 20, 25, 50, 100]
sage: import gmpy2
sage: divisors(gmpy2.mpz(100))
@@ -1592,13 +1599,13 @@ class Sigma:
::
- sage: P = plot(sigma, 1, 100)
+ sage: P = plot(sigma, 1, 100) # optional - sage.plot
This method also works with k-th powers.
::
- sage: P = plot(sigma, 1, 100, k=2)
+ sage: P = plot(sigma, 1, 100, k=2) # optional - sage.plot
AUTHORS:
@@ -1610,21 +1617,21 @@ class Sigma:
sage: sigma(100,4)
106811523
- sage: sigma(factorial(100),3).mod(144169)
+ sage: sigma(factorial(100), 3).mod(144169) # optional - sage.libs.pari
3672
- sage: sigma(factorial(150),12).mod(691)
+ sage: sigma(factorial(150), 12).mod(691) # optional - sage.libs.pari
176
- sage: RR(sigma(factorial(133),20))
+ sage: RR(sigma(factorial(133),20)) # optional - sage.libs.pari
2.80414775675747e4523
- sage: sigma(factorial(100),0)
+ sage: sigma(factorial(100),0) # optional - sage.libs.pari
39001250856960000
- sage: sigma(factorial(41),1)
+ sage: sigma(factorial(41),1) # optional - sage.libs.pari
229199532273029988767733858700732906511758707916800
- sage: from numpy import int8
- sage: sigma(int8(100),int8(4))
+ sage: from numpy import int8 # optional - numpy
+ sage: sigma(int8(100), int8(4)) # optional - numpy sage.libs.pari
106811523
sage: from gmpy2 import mpz
- sage: sigma(mpz(100),mpz(4))
+ sage: sigma(mpz(100), mpz(4)) # optional - sage.libs.pari
106811523
"""
def __repr__(self):
@@ -1648,9 +1655,9 @@ def __call__(self, n, k=1):
sage: from sage.arith.misc import Sigma
sage: q = Sigma()
- sage: q(10)
+ sage: q(10) # optional - sage.libs.pari
18
- sage: q(10,2)
+ sage: q(10,2) # optional - sage.libs.pari
130
"""
n = ZZ(n)
@@ -1692,8 +1699,8 @@ def plot(self, xmin=1, xmax=50, k=1, pointsize=30, rgbcolor=(0,0,1), join=True,
EXAMPLES::
sage: from sage.arith.misc import Sigma
- sage: p = Sigma().plot()
- sage: p.ymax()
+ sage: p = Sigma().plot() # optional - sage.libs.pari sage.plot
+ sage: p.ymax() # optional - sage.libs.pari sage.plot
124.0
"""
v = [(n, sigma(n, k)) for n in range(xmin, xmax + 1)]
@@ -1783,33 +1790,33 @@ def gcd(a, b=None, **kwargs):
Make sure we try QQ and not merely ZZ (:trac:`13014`)::
- sage: bool(gcd(2/5, 3/7) == gcd(SR(2/5), SR(3/7)))
+ sage: bool(gcd(2/5, 3/7) == gcd(SR(2/5), SR(3/7))) # optional - sage.symbolic
True
Make sure that the gcd of Expressions stays symbolic::
sage: parent(gcd(2, 4))
Integer Ring
- sage: parent(gcd(SR(2), 4))
+ sage: parent(gcd(SR(2), 4)) # optional - sage.symbolic
Symbolic Ring
- sage: parent(gcd(2, SR(4)))
+ sage: parent(gcd(2, SR(4))) # optional - sage.symbolic
Symbolic Ring
- sage: parent(gcd(SR(2), SR(4)))
+ sage: parent(gcd(SR(2), SR(4))) # optional - sage.symbolic
Symbolic Ring
Verify that objects without gcd methods but which cannot be
coerced to ZZ or QQ raise an error::
- sage: F. = FreeMonoid(2)
- sage: gcd(a,b)
+ sage: F. = FreeMonoid(2) # optional - sage.groups
+ sage: gcd(a, b) # optional - sage.groups
Traceback (most recent call last):
...
TypeError: unable to call gcd with a
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: GCD(int8(97),int8(100))
+ sage: from numpy import int8 # optional - numpy
+ sage: GCD(int8(97), int8(100)) # optional - numpy
1
sage: from gmpy2 import mpq, mpz
sage: GCD(mpq(2/3), mpq(4/5))
@@ -1908,8 +1915,8 @@ def xlcm(m, n):
TESTS::
- sage: from numpy import int16
- sage: xlcm(int16(120), int16(36))
+ sage: from numpy import int16 # optional - numpy
+ sage: xlcm(int16(120), int16(36)) # optional - numpy
(360, 40, 9)
sage: from gmpy2 import mpz
sage: xlcm(mpz(120), mpz(36))
@@ -1974,15 +1981,15 @@ def xgcd(a, b):
sage: xgcd(x^3 - 1, x^2 - 1)
(x - 1, 1, -x)
- sage: K. = NumberField(x^2-3)
- sage: g.xgcd(g+2)
+ sage: K. = NumberField(x^2 - 3) # optional - sage.rings.number_field
+ sage: g.xgcd(g + 2) # optional - sage.rings.number_field
(1, 1/3*g, 0)
- sage: R. = K[]
- sage: S. = R.fraction_field()[]
- sage: xgcd(y^2, a*y+b)
+ sage: R. = K[] # optional - sage.rings.number_field
+ sage: S. = R.fraction_field()[] # optional - sage.rings.number_field
+ sage: xgcd(y^2, a*y + b) # optional - sage.rings.number_field
(1, a^2/b^2, ((-a)/b^2)*y + 1/b)
- sage: xgcd((b+g)*y^2, (a+g)*y+b)
+ sage: xgcd((b+g)*y^2, (a+g)*y + b) # optional - sage.rings.number_field
(1, (a^2 + (2*g)*a + 3)/(b^3 + g*b^2), ((-a + (-g))/b^2)*y + 1/b)
Here is an example of a xgcd for two polynomials over the integers, where the linear
@@ -1998,10 +2005,10 @@ def xgcd(a, b):
Tests with numpy and gmpy2 types::
- sage: from numpy import int8
- sage: xgcd(4,int8(8))
+ sage: from numpy import int8 # optional - numpy
+ sage: xgcd(4, int8(8)) # optional - numpy
(4, 1, 0)
- sage: xgcd(int8(4),int8(8))
+ sage: xgcd(int8(4), int8(8)) # optional - numpy
(4, 1, 0)
sage: from gmpy2 import mpz
sage: xgcd(mpz(4), mpz(8))
@@ -2013,10 +2020,10 @@ def xgcd(a, b):
We check that :trac:`3330` has been fixed::
- sage: R. = NumberField(x^2-3,'g').extension(x^2-7,'h')[]
- sage: h = R.base_ring().gen()
- sage: S. = R.fraction_field()[]
- sage: xgcd(y^2, a*h*y+b)
+ sage: R. = NumberField(x^2 - 3, 'g').extension(x^2 - 7, 'h')[] # optional - sage.rings.number_field
+ sage: h = R.base_ring().gen() # optional - sage.rings.number_field
+ sage: S. = R.fraction_field()[] # optional - sage.rings.number_field
+ sage: xgcd(y^2, a*h*y + b) # optional - sage.rings.number_field
(1, 7*a^2/b^2, (((-h)*a)/b^2)*y + 1/b)
"""
try:
@@ -2131,20 +2138,20 @@ def inverse_mod(a, m):
::
- sage: inverse_mod(7,1)
+ sage: inverse_mod(7, 1)
0
- sage: inverse_mod(5,14)
+ sage: inverse_mod(5, 14)
3
- sage: inverse_mod(3,-5)
+ sage: inverse_mod(3, -5)
2
Tests with numpy and mpz numbers::
- sage: from numpy import int8
- sage: inverse_mod(int8(5),int8(14))
+ sage: from numpy import int8 # optional - numpy
+ sage: inverse_mod(int8(5), int8(14)) # optional - numpy
3
sage: from gmpy2 import mpz
- sage: inverse_mod(mpz(5),mpz(14))
+ sage: inverse_mod(mpz(5), mpz(14))
3
"""
try:
@@ -2221,13 +2228,13 @@ def power_mod(a, n, m):
EXAMPLES::
- sage: power_mod(2,388,389)
+ sage: power_mod(2, 388, 389)
1
- sage: power_mod(2,390,391)
+ sage: power_mod(2, 390, 391)
285
- sage: power_mod(2,-1,7)
+ sage: power_mod(2, -1, 7)
4
- sage: power_mod(11,1,7)
+ sage: power_mod(11, 1, 7)
4
This function works for fairly general rings::
@@ -2235,7 +2242,7 @@ def power_mod(a, n, m):
sage: R. = ZZ[]
sage: power_mod(3*x, 10, 7)
4*x^10
- sage: power_mod(-3*x^2+4, 7, 2*x^3-5)
+ sage: power_mod(-3*x^2 + 4, 7, 2*x^3 - 5)
x^14 + x^8 + x^6 + x^3 + 962509*x^2 - 791910*x - 698281
TESTS::
@@ -2249,11 +2256,11 @@ def power_mod(a, n, m):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int32
- sage: power_mod(int32(2),int32(390),int32(391))
+ sage: from numpy import int32 # optional - numpy
+ sage: power_mod(int32(2), int32(390), int32(391)) # optional - numpy
285
sage: from gmpy2 import mpz
- sage: power_mod(mpz(2),mpz(390),mpz(391))
+ sage: power_mod(mpz(2), mpz(390), mpz(391))
mpz(285)
"""
if not m:
@@ -2372,8 +2379,8 @@ def rational_reconstruction(a, m, algorithm='fast'):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int32
- sage: rational_reconstruction(int32(3), int32(292393))
+ sage: from numpy import int32 # optional - numpy
+ sage: rational_reconstruction(int32(3), int32(292393)) # optional - numpy
3
sage: from gmpy2 import mpz
sage: rational_reconstruction(mpz(3), mpz(292393))
@@ -2407,16 +2414,16 @@ def mqrr_rational_reconstruction(u, m, T):
EXAMPLES::
- sage: mqrr_rational_reconstruction(21,3100,13)
+ sage: mqrr_rational_reconstruction(21, 3100, 13)
(21, 1)
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int16
- sage: mqrr_rational_reconstruction(int16(21),int16(3100),int16(13))
+ sage: from numpy import int16 # optional - numpy
+ sage: mqrr_rational_reconstruction(int16(21), int16(3100), int16(13)) # optional - numpy
(21, 1)
sage: from gmpy2 import mpz
- sage: mqrr_rational_reconstruction(mpz(21),mpz(3100),mpz(13))
+ sage: mqrr_rational_reconstruction(mpz(21), mpz(3100), mpz(13))
(21, 1)
"""
u = py_scalar_to_element(u)
@@ -2480,8 +2487,8 @@ def trial_division(n, bound=None):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: trial_division(int8(91))
+ sage: from numpy import int8 # optional - numpy
+ sage: trial_division(int8(91)) # optional - numpy
7
sage: from gmpy2 import mpz
sage: trial_division(mpz(91))
@@ -2512,10 +2519,10 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
EXAMPLES::
- sage: f(n)=n^2
- sage: is_prime(f(3))
+ sage: f(n) = n^2 # optional - sage.symbolic
+ sage: is_prime(f(3)) # optional - sage.symbolic
False
- sage: factor(f(3))
+ sage: factor(f(3)) # optional - sage.symbolic
9
INPUT:
@@ -2578,7 +2585,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
-1
sage: f.value()
-20
- sage: factor( -next_prime(10^2) * next_prime(10^7) )
+ sage: factor(-next_prime(10^2) * next_prime(10^7)) # optional - sage.libs.pari
-1 * 101 * 10000019
::
@@ -2606,7 +2613,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
1
sage: factor(-1)
-1
- sage: factor(2^(2^7)+1)
+ sage: factor(2^(2^7) +1) # optional - sage.libs.pari
59649589127497217 * 5704689200685129054721
Sage calls PARI's factor, which has proof False by default.
@@ -2616,42 +2623,42 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
::
- sage: factor(3^89-1, proof=False)
+ sage: factor(3^89 - 1, proof=False) # optional - sage.libs.pari
2 * 179 * 1611479891519807 * 5042939439565996049162197
::
- sage: factor(2^197 + 1) # long time (2s)
+ sage: factor(2^197 + 1) # long time (2s) # optional - sage.libs.pari
3 * 197002597249 * 1348959352853811313 * 251951573867253012259144010843
Any object which has a factor method can be factored like this::
- sage: K. = QuadraticField(-1)
- sage: factor(122 - 454*i)
+ sage: K. = QuadraticField(-1) # optional - sage.rings.number_field
+ sage: factor(122 - 454*i) # optional - sage.rings.number_field
(-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
To access the data in a factorization::
- sage: f = factor(420); f
+ sage: f = factor(420); f # optional - sage.libs.pari
2^2 * 3 * 5 * 7
- sage: [x for x in f]
+ sage: [x for x in f] # optional - sage.libs.pari
[(2, 2), (3, 1), (5, 1), (7, 1)]
- sage: [p for p,e in f]
+ sage: [p for p,e in f] # optional - sage.libs.pari
[2, 3, 5, 7]
- sage: [e for p,e in f]
+ sage: [e for p,e in f] # optional - sage.libs.pari
[2, 1, 1, 1]
- sage: [p^e for p,e in f]
+ sage: [p^e for p,e in f] # optional - sage.libs.pari
[4, 3, 5, 7]
We can factor Python, numpy and gmpy2 numbers::
sage: factor(math.pi)
3.141592653589793
- sage: import numpy
- sage: factor(numpy.int8(30))
+ sage: import numpy # optional - numpy
+ sage: factor(numpy.int8(30)) # optional - numpy sage.libs.pari
2 * 3 * 5
sage: import gmpy2
- sage: factor(gmpy2.mpz(30))
+ sage: factor(gmpy2.mpz(30)) # optional - sage.libs.pari
2 * 3 * 5
TESTS::
@@ -2703,14 +2710,14 @@ def radical(n, *args, **kwds):
Traceback (most recent call last):
...
ArithmeticError: radical of 0 is not defined
- sage: K. = QuadraticField(-1)
- sage: radical(K(2))
+ sage: K. = QuadraticField(-1) # optional - sage.rings.number_field
+ sage: radical(K(2)) # optional - sage.rings.number_field
i + 1
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: radical(int8(50))
+ sage: from numpy import int8 # optional - numpy
+ sage: radical(int8(50)) # optional - numpy
10
sage: from gmpy2 import mpz
sage: radical(mpz(50))
@@ -2763,13 +2770,13 @@ def prime_divisors(n):
For polynomials we get all irreducible factors::
sage: R. = PolynomialRing(QQ)
- sage: prime_divisors(x^12 - 1)
+ sage: prime_divisors(x^12 - 1) # optional - sage.libs.pari
[x - 1, x + 1, x^2 - x + 1, x^2 + 1, x^2 + x + 1, x^4 - x^2 + 1]
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: prime_divisors(int8(-100))
+ sage: from numpy import int8 # optional - numpy
+ sage: prime_divisors(int8(-100)) # optional - numpy
[2, 5]
sage: from gmpy2 import mpz
sage: prime_divisors(mpz(-100))
@@ -2801,8 +2808,8 @@ def odd_part(n):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: odd_part(int8(5))
+ sage: from numpy import int8 # optional - numpy
+ sage: odd_part(int8(5)) # optional - numpy
5
sage: from gmpy2 import mpz
sage: odd_part(mpz(5))
@@ -2845,8 +2852,8 @@ def prime_to_m_part(n, m):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int16
- sage: prime_to_m_part(int16(240), int16(2))
+ sage: from numpy import int16 # optional - numpy
+ sage: prime_to_m_part(int16(240), int16(2)) # optional - numpy
15
sage: from gmpy2 import mpz
sage: prime_to_m_part(mpz(240), mpz(2))
@@ -2901,8 +2908,8 @@ def is_square(n, root=False):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: is_square(int8(4))
+ sage: from numpy import int8 # optional - numpy
+ sage: is_square(int8(4)) # optional - numpy
True
sage: from gmpy2 import mpz
sage: is_square(mpz(4))
@@ -2940,47 +2947,47 @@ def is_squarefree(n):
EXAMPLES::
- sage: is_squarefree(100)
+ sage: is_squarefree(100) # optional - sage.libs.pari
False
- sage: is_squarefree(101)
+ sage: is_squarefree(101) # optional - sage.libs.pari
True
sage: R = ZZ['x']
sage: x = R.gen()
- sage: is_squarefree((x^2+x+1) * (x-2))
+ sage: is_squarefree((x^2+x+1) * (x-2)) # optional - sage.libs.pari
True
- sage: is_squarefree((x-1)**2 * (x-3))
+ sage: is_squarefree((x-1)**2 * (x-3)) # optional - sage.libs.pari
False
- sage: O = ZZ[sqrt(-1)]
- sage: I = O.gen(1)
- sage: is_squarefree(I+1)
+ sage: O = ZZ[sqrt(-1)] # optional - sage.rings.number_field sage.symbolic
+ sage: I = O.gen(1) # optional - sage.rings.number_field sage.symbolic
+ sage: is_squarefree(I + 1) # optional - sage.rings.number_field sage.symbolic
True
- sage: is_squarefree(O(2))
+ sage: is_squarefree(O(2)) # optional - sage.rings.number_field sage.symbolic
False
- sage: O(2).factor()
+ sage: O(2).factor() # optional - sage.rings.number_field sage.symbolic
(-I) * (I + 1)^2
This method fails on domains which are not Unique Factorization Domains::
- sage: O = ZZ[sqrt(-5)]
- sage: a = O.gen(1)
- sage: is_squarefree(a - 3)
+ sage: O = ZZ[sqrt(-5)] # optional - sage.rings.number_field sage.symbolic
+ sage: a = O.gen(1) # optional - sage.rings.number_field sage.symbolic
+ sage: is_squarefree(a - 3) # optional - sage.rings.number_field sage.symbolic
Traceback (most recent call last):
...
ArithmeticError: non-principal ideal in factorization
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: is_squarefree(int8(100))
+ sage: from numpy import int8 # optional - numpy
+ sage: is_squarefree(int8(100)) # optional - numpy sage.libs.pari
False
- sage: is_squarefree(int8(101))
+ sage: is_squarefree(int8(101)) # optional - numpy sage.libs.pari
True
sage: from gmpy2 import mpz
- sage: is_squarefree(mpz(100))
+ sage: is_squarefree(mpz(100)) # optional - sage.libs.pari
False
- sage: is_squarefree(mpz(101))
+ sage: is_squarefree(mpz(101)) # optional - sage.libs.pari
True
"""
e = py_scalar_to_element(n)
@@ -3017,11 +3024,11 @@ class Euler_Phi:
1
sage: euler_phi(2)
1
- sage: euler_phi(3)
+ sage: euler_phi(3) # optional - sage.libs.pari
2
- sage: euler_phi(12)
+ sage: euler_phi(12) # optional - sage.libs.pari
4
- sage: euler_phi(37)
+ sage: euler_phi(37) # optional - sage.libs.pari
36
Notice that euler_phi is defined to be 0 on negative numbers and
@@ -3040,7 +3047,7 @@ class Euler_Phi:
::
- sage: euler_phi(21)
+ sage: euler_phi(21) # optional - sage.libs.pari
12
sage: [i for i in range(21) if gcd(21,i) == 1]
[1, 2, 4, 5, 8, 10, 11, 13, 16, 17, 19, 20]
@@ -3050,22 +3057,22 @@ class Euler_Phi:
::
- sage: len([i for i in range(21) if gcd(21,i) == 1]) == euler_phi(21)
+ sage: len([i for i in range(21) if gcd(21,i) == 1]) == euler_phi(21) # optional - sage.libs.pari
True
The phi function also has a special plotting method.
::
- sage: P = plot(euler_phi, -3, 71)
+ sage: P = plot(euler_phi, -3, 71) # optional - sage.libs.pari sage.plot
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: euler_phi(int8(37))
+ sage: from numpy import int8 # optional - numpy
+ sage: euler_phi(int8(37)) # optional - numpy sage.libs.pari sage.plot
36
sage: from gmpy2 import mpz
- sage: euler_phi(mpz(37))
+ sage: euler_phi(mpz(37)) # optional - sage.libs.pari sage.plot
36
AUTHORS:
@@ -3093,9 +3100,9 @@ def __call__(self, n):
EXAMPLES::
sage: from sage.arith.misc import Euler_Phi
- sage: Euler_Phi()(10)
+ sage: Euler_Phi()(10) # optional - sage.libs.pari
4
- sage: Euler_Phi()(720)
+ sage: Euler_Phi()(720) # optional - sage.libs.pari
192
"""
if n <= 0:
@@ -3129,8 +3136,8 @@ def plot(self, xmin=1, xmax=50, pointsize=30, rgbcolor=(0, 0, 1),
EXAMPLES::
sage: from sage.arith.misc import Euler_Phi
- sage: p = Euler_Phi().plot()
- sage: p.ymax()
+ sage: p = Euler_Phi().plot() # optional - sage.plot
+ sage: p.ymax() # optional - sage.plot
46.0
"""
v = [(n, euler_phi(n)) for n in range(xmin, xmax + 1)]
@@ -3186,7 +3193,7 @@ def carmichael_lambda(n):
The Carmichael function of the first ten primes::
- sage: list(map(carmichael_lambda, primes_first_n(10)))
+ sage: list(map(carmichael_lambda, primes_first_n(10))) # optional - sage.libs.pari
[1, 2, 4, 6, 10, 12, 16, 18, 22, 28]
Cases where the Carmichael function is equivalent to the Euler phi
@@ -3194,19 +3201,19 @@ def carmichael_lambda(n):
sage: carmichael_lambda(2) == euler_phi(2)
True
- sage: carmichael_lambda(4) == euler_phi(4)
+ sage: carmichael_lambda(4) == euler_phi(4) # optional - sage.libs.pari
True
sage: p = random_prime(1000, lbound=3, proof=True)
sage: k = randint(1, 1000)
- sage: carmichael_lambda(p^k) == euler_phi(p^k)
+ sage: carmichael_lambda(p^k) == euler_phi(p^k) # optional - sage.libs.pari
True
A case where `\lambda(n) \neq \varphi(n)`::
sage: k = randint(3, 1000)
- sage: carmichael_lambda(2^k) == 2^(k - 2)
+ sage: carmichael_lambda(2^k) == 2^(k - 2) # optional - sage.libs.pari
True
- sage: carmichael_lambda(2^k) == 2^(k - 2) == euler_phi(2^k)
+ sage: carmichael_lambda(2^k) == 2^(k - 2) == euler_phi(2^k) # optional - sage.libs.pari
False
Verifying the current implementation of the Carmichael function using
@@ -3216,7 +3223,7 @@ def carmichael_lambda(n):
sage: from sage.arith.misc import carmichael_lambda
sage: n = randint(1, 500)
- sage: c = carmichael_lambda(n)
+ sage: c = carmichael_lambda(n) # optional - sage.libs.pari
sage: def coprime(n):
....: return [i for i in range(n) if gcd(i, n) == 1]
sage: def znpower(n, k):
@@ -3231,7 +3238,7 @@ def carmichael_lambda(n):
....: T = [L[i] == ones[i] for i in range(len(L))]
....: if all(T):
....: return k
- sage: c == my_carmichael(n)
+ sage: c == my_carmichael(n) # optional - sage.libs.pari
True
Carmichael's theorem states that `a^{\lambda(n)} \equiv 1 \pmod{n}`
@@ -3240,12 +3247,12 @@ def carmichael_lambda(n):
sage: from sage.arith.misc import carmichael_lambda
sage: n = randint(2, 1000)
- sage: c = carmichael_lambda(n)
+ sage: c = carmichael_lambda(n) # optional - sage.libs.pari
sage: ZnZ = IntegerModRing(n)
sage: M = ZnZ.list_of_elements_of_multiplicative_group()
sage: ones = [1] * len(M)
- sage: P = [power_mod(a, c, n) for a in M]
- sage: P == ones
+ sage: P = [power_mod(a, c, n) for a in M] # optional - sage.libs.pari
+ sage: P == ones # optional - sage.libs.pari
True
TESTS:
@@ -3265,7 +3272,7 @@ def carmichael_lambda(n):
Bug reported in :trac:`8283`::
sage: from sage.arith.misc import carmichael_lambda
- sage: type(carmichael_lambda(16))
+ sage: type(carmichael_lambda(16)) # optional - sage.libs.pari
REFERENCES:
@@ -3346,50 +3353,55 @@ def crt(a, b, m=None, n=None):
Note that this also works for polynomial rings::
- sage: K. = NumberField(x^3 - 7)
- sage: R. = K[]
- sage: f = y^2 + 3
- sage: g = y^3 - 5
- sage: CRT(1,3,f,g)
+ sage: x = polygen(ZZ, 'x')
+ sage: K. = NumberField(x^3 - 7) # optional - sage.rings.number_field
+ sage: R. = K[] # optional - sage.rings.number_field
+ sage: f = y^2 + 3 # optional - sage.rings.number_field
+ sage: g = y^3 - 5 # optional - sage.rings.number_field
+ sage: CRT(1, 3, f, g) # optional - sage.rings.number_field
-3/26*y^4 + 5/26*y^3 + 15/26*y + 53/26
- sage: CRT(1,a,f,g)
+ sage: CRT(1, a, f, g) # optional - sage.rings.number_field
(-3/52*a + 3/52)*y^4 + (5/52*a - 5/52)*y^3 + (15/52*a - 15/52)*y + 27/52*a + 25/52
You can also do this for any number of moduli::
- sage: K. = NumberField(x^3 - 7)
- sage: R. = K[]
- sage: CRT([], [])
+ sage: K. = NumberField(x^3 - 7) # optional - sage.rings.number_field
+ sage: R. = K[] # optional - sage.rings.number_field
+ sage: CRT([], []) # optional - sage.rings.number_field
0
- sage: CRT([a], [x])
+ sage: CRT([a], [x]) # optional - sage.rings.number_field
a
- sage: f = x^2 + 3
- sage: g = x^3 - 5
- sage: h = x^5 + x^2 - 9
- sage: k = CRT([1, a, 3], [f, g, h]); k
- (127/26988*a - 5807/386828)*x^9 + (45/8996*a - 33677/1160484)*x^8 + (2/173*a - 6/173)*x^7 + (133/6747*a - 5373/96707)*x^6 + (-6/2249*a + 18584/290121)*x^5 + (-277/8996*a + 38847/386828)*x^4 + (-135/4498*a + 42673/193414)*x^3 + (-1005/8996*a + 470245/1160484)*x^2 + (-1215/8996*a + 141165/386828)*x + 621/8996*a + 836445/386828
- sage: k.mod(f)
+ sage: f = x^2 + 3 # optional - sage.rings.number_field
+ sage: g = x^3 - 5 # optional - sage.rings.number_field
+ sage: h = x^5 + x^2 - 9 # optional - sage.rings.number_field
+ sage: k = CRT([1, a, 3], [f, g, h]); k # optional - sage.rings.number_field
+ (127/26988*a - 5807/386828)*x^9 + (45/8996*a - 33677/1160484)*x^8
+ + (2/173*a - 6/173)*x^7 + (133/6747*a - 5373/96707)*x^6
+ + (-6/2249*a + 18584/290121)*x^5 + (-277/8996*a + 38847/386828)*x^4
+ + (-135/4498*a + 42673/193414)*x^3 + (-1005/8996*a + 470245/1160484)*x^2
+ + (-1215/8996*a + 141165/386828)*x + 621/8996*a + 836445/386828
+ sage: k.mod(f) # optional - sage.rings.number_field
1
- sage: k.mod(g)
+ sage: k.mod(g) # optional - sage.rings.number_field
a
- sage: k.mod(h)
+ sage: k.mod(h) # optional - sage.rings.number_field
3
If the moduli are not coprime, a solution may not exist::
- sage: crt(4,8,8,12)
+ sage: crt(4, 8, 8, 12)
20
- sage: crt(4,6,8,12)
+ sage: crt(4, 6, 8, 12)
Traceback (most recent call last):
...
ValueError: no solution to crt problem since gcd(8,12) does not divide 4-6
sage: x = polygen(QQ)
- sage: crt(2,3,x-1,x+1)
+ sage: crt(2, 3, x - 1, x + 1)
-1/2*x + 5/2
- sage: crt(2,x,x^2-1,x^2+1)
+ sage: crt(2, x, x^2 - 1, x^2 + 1)
-1/2*x^3 + x^2 + 1/2*x + 1
- sage: crt(2,x,x^2-1,x^3-1)
+ sage: crt(2, x, x^2 - 1, x^3 - 1)
Traceback (most recent call last):
...
ValueError: no solution to crt problem since gcd(x^2 - 1,x^3 - 1) does not divide 2-x
@@ -3399,13 +3411,13 @@ def crt(a, b, m=None, n=None):
crt also work with numpy and gmpy2 numbers::
- sage: import numpy
- sage: crt(numpy.int8(2), numpy.int8(3), numpy.int8(7), numpy.int8(11))
+ sage: import numpy # optional - numpy
+ sage: crt(numpy.int8(2), numpy.int8(3), numpy.int8(7), numpy.int8(11)) # optional - numpy
58
sage: from gmpy2 import mpz
sage: crt(mpz(2), mpz(3), mpz(7), mpz(11))
58
- sage: crt(mpz(2), 3, mpz(7), numpy.int8(11))
+ sage: crt(mpz(2), 3, mpz(7), numpy.int8(11)) # optional - numpy
58
"""
if isinstance(a, list):
@@ -3492,8 +3504,8 @@ def CRT_list(values, moduli):
sage: CRT([32r,2r,2r],[60r,90r,150r])
452
- sage: from numpy import int8
- sage: CRT_list([int8(2),int8(3),int8(2)], [int8(3),int8(5),int8(7)])
+ sage: from numpy import int8 # optional - numpy
+ sage: CRT_list([int8(2), int8(3), int8(2)], [int8(3), int8(5), int8(7)]) # optional - numpy
23
sage: from gmpy2 import mpz
sage: CRT_list([mpz(2),mpz(3),mpz(2)], [mpz(3),mpz(5),mpz(7)])
@@ -3597,7 +3609,7 @@ def CRT_vectors(X, moduli):
sage: CRT_vectors([[3,5,7],[3,5,11]], [2,3])
[3, 5, 5]
- sage: CRT_vectors([vector(ZZ, [2,3,1]), Sequence([1,7,8],ZZ)], [8,9])
+ sage: CRT_vectors([vector(ZZ, [2,3,1]), Sequence([1,7,8], ZZ)], [8,9]) # optional - sage.modules
[10, 43, 17]
"""
# First find the CRT basis:
@@ -3639,15 +3651,15 @@ def binomial(x, m, **kwds):
EXAMPLES::
sage: from sage.arith.misc import binomial
- sage: binomial(5,2)
+ sage: binomial(5, 2)
10
- sage: binomial(2,0)
+ sage: binomial(2, 0)
1
- sage: binomial(1/2, 0)
+ sage: binomial(1/2, 0) # optional - sage.libs.pari
1
- sage: binomial(3,-1)
+ sage: binomial(3, -1)
0
- sage: binomial(20,10)
+ sage: binomial(20, 10)
184756
sage: binomial(-2, 5)
-6
@@ -3655,11 +3667,11 @@ def binomial(x, m, **kwds):
0
sage: binomial(RealField()('2.5'), 2)
1.87500000000000
- sage: n=var('n'); binomial(n,2)
+ sage: n = var('n'); binomial(n, 2) # optional - sage.symbolic
1/2*(n - 1)*n
- sage: n=var('n'); binomial(n,n)
+ sage: n = var('n'); binomial(n, n) # optional - sage.symbolic
1
- sage: n=var('n'); binomial(n,n-1)
+ sage: n = var('n'); binomial(n, n - 1) # optional - sage.symbolic
n
sage: binomial(2^100, 2^100)
1
@@ -3667,7 +3679,7 @@ def binomial(x, m, **kwds):
sage: x = polygen(ZZ)
sage: binomial(x, 3)
1/6*x^3 - 1/2*x^2 + 1/3*x
- sage: binomial(x, x-3)
+ sage: binomial(x, x - 3)
1/6*x^3 - 1/2*x^2 + 1/3*x
If `x \in \ZZ`, there is an optional 'algorithm' parameter, which
@@ -3688,21 +3700,21 @@ def binomial(x, m, **kwds):
We test conversion of arguments to Integers -- see :trac:`6870`::
- sage: binomial(1/2,1/1)
+ sage: binomial(1/2, 1/1)
1/2
- sage: binomial(10^20+1/1,10^20)
+ sage: binomial(10^20 + 1/1, 10^20)
100000000000000000001
- sage: binomial(SR(10**7),10**7)
+ sage: binomial(SR(10**7), 10**7) # optional - sage.symbolic
1
- sage: binomial(3/2,SR(1/1))
+ sage: binomial(3/2, SR(1/1)) # optional - sage.symbolic
3/2
Some floating point cases -- see :trac:`7562`, :trac:`9633`, and
:trac:`12448`::
- sage: binomial(1.,3)
+ sage: binomial(1., 3)
0.000000000000000
- sage: binomial(-2.,3)
+ sage: binomial(-2., 3)
-4.00000000000000
sage: binomial(0.5r, 5)
0.02734375
@@ -3759,8 +3771,8 @@ def binomial(x, m, **kwds):
...
TypeError: either m or x-m must be an integer
- sage: k, i = var('k,i')
- sage: binomial(k,i)
+ sage: k, i = var('k,i') # optional - sage.symbolic
+ sage: binomial(k,i) # optional - sage.symbolic
Traceback (most recent call last):
...
TypeError: either m or x-m must be an integer
@@ -3797,15 +3809,15 @@ def binomial(x, m, **kwds):
:func:`~sage.functions.other.binomial` from the module
:mod:`sage.functions.other`::
- sage: from sage.functions.other import binomial
- sage: binomial(k, i)
+ sage: from sage.functions.other import binomial # optional - sage.symbolic
+ sage: binomial(k, i) # optional - sage.symbolic
binomial(k, i)
binomial support numpy and gmpy2 parameters::
sage: from sage.arith.misc import binomial
- sage: import numpy
- sage: binomial(numpy.int32(20), numpy.int32(10))
+ sage: import numpy # optional - numpy
+ sage: binomial(numpy.int32(20), numpy.int32(10)) # optional - numpy
184756
sage: import gmpy2
sage: binomial(gmpy2.mpz(20), gmpy2.mpz(10))
@@ -3886,17 +3898,17 @@ def multinomial(*ks):
618970023101454657175683075
sage: multinomial([2^30, 2, 1])
618970023101454657175683075
- sage: multinomial(Composition([1, 3]))
+ sage: multinomial(Composition([1, 3])) # optional - sage.combinat
4
- sage: multinomial(Partition([4, 2]))
+ sage: multinomial(Partition([4, 2])) # optional - sage.combinat
15
TESTS:
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: multinomial(int8(3), int8(2))
+ sage: from numpy import int8 # optional - numpy
+ sage: multinomial(int8(3), int8(2)) # optional - numpy
10
sage: from gmpy2 import mpz
sage: multinomial(mpz(3), mpz(2))
@@ -3952,8 +3964,8 @@ def binomial_coefficients(n):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: sorted(binomial_coefficients(int8(3)).items())
+ sage: from numpy import int8 # optional - numpy
+ sage: sorted(binomial_coefficients(int8(3)).items()) # optional - numpy
[((0, 3), 1), ((1, 2), 3), ((2, 1), 3), ((3, 0), 1)]
sage: from gmpy2 import mpz
sage: sorted(binomial_coefficients(mpz(3)).items())
@@ -4029,8 +4041,8 @@ def multinomial_coefficients(m, n):
{(): 1}
sage: multinomial_coefficients(0, 3)
{}
- sage: from numpy import int8
- sage: sorted(multinomial_coefficients(int8(2), int8(5)).items())
+ sage: from numpy import int8 # optional - numpy
+ sage: sorted(multinomial_coefficients(int8(2), int8(5)).items()) # optional - numpy
[((0, 5), 1), ((1, 4), 5), ((2, 3), 10), ((3, 2), 10), ((4, 1), 5), ((5, 0), 1)]
sage: from gmpy2 import mpz
sage: sorted(multinomial_coefficients(mpz(2), mpz(5)).items())
@@ -4118,8 +4130,8 @@ def kronecker_symbol(x,y):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: kronecker_symbol(int8(13),int8(21))
+ sage: from numpy import int8 # optional - numpy
+ sage: kronecker_symbol(int8(13),int8(21)) # optional - numpy
-1
sage: from gmpy2 import mpz
sage: kronecker_symbol(mpz(13),mpz(21))
@@ -4170,8 +4182,8 @@ def legendre_symbol(x, p):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: legendre_symbol(int8(2),int8(3))
+ sage: from numpy import int8 # optional - numpy
+ sage: legendre_symbol(int8(2), int8(3)) # optional - numpy
-1
sage: from gmpy2 import mpz
sage: legendre_symbol(mpz(2),mpz(3))
@@ -4226,8 +4238,8 @@ def jacobi_symbol(a, b):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int16
- sage: jacobi_symbol(int16(10),int16(777))
+ sage: from numpy import int16 # optional - numpy
+ sage: jacobi_symbol(int16(10), int16(777)) # optional - numpy
-1
sage: from gmpy2 import mpz
sage: jacobi_symbol(mpz(10),mpz(777))
@@ -4262,15 +4274,15 @@ def primitive_root(n, check=True):
EXAMPLES::
- sage: primitive_root(23)
+ sage: primitive_root(23) # optional - sage.libs.pari
5
- sage: primitive_root(-46)
+ sage: primitive_root(-46) # optional - sage.libs.pari
5
- sage: primitive_root(25)
+ sage: primitive_root(25) # optional - sage.libs.pari
2
- sage: print([primitive_root(p) for p in primes(100)])
+ sage: print([primitive_root(p) for p in primes(100)]) # optional - sage.libs.pari
[1, 2, 2, 3, 2, 2, 3, 2, 5, 2, 3, 2, 6, 3, 5, 2, 2, 2, 2, 7, 5, 3, 2, 3, 5]
- sage: primitive_root(8)
+ sage: primitive_root(8) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no primitive root
@@ -4286,57 +4298,57 @@ def primitive_root(n, check=True):
::
sage: n = 10^50 + 151 # a prime
- sage: primitive_root(n)
+ sage: primitive_root(n) # optional - sage.libs.pari
11
- sage: primitive_root(n, check=False)
+ sage: primitive_root(n, check=False) # optional - sage.libs.pari
11
TESTS:
Various special cases::
- sage: primitive_root(-1)
+ sage: primitive_root(-1) # optional - sage.libs.pari
0
- sage: primitive_root(0)
+ sage: primitive_root(0) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no primitive root
- sage: primitive_root(1)
+ sage: primitive_root(1) # optional - sage.libs.pari
0
- sage: primitive_root(2)
+ sage: primitive_root(2) # optional - sage.libs.pari
1
- sage: primitive_root(3)
+ sage: primitive_root(3) # optional - sage.libs.pari
2
- sage: primitive_root(4)
+ sage: primitive_root(4) # optional - sage.libs.pari
3
We test that various numbers without primitive roots give
an error - see :trac:`10836`::
- sage: primitive_root(15)
+ sage: primitive_root(15) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no primitive root
- sage: primitive_root(16)
+ sage: primitive_root(16) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no primitive root
- sage: primitive_root(1729)
+ sage: primitive_root(1729) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no primitive root
- sage: primitive_root(4*7^8)
+ sage: primitive_root(4*7^8) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: no primitive root
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: primitive_root(int8(-46))
+ sage: from numpy import int8 # optional - numpy
+ sage: primitive_root(int8(-46)) # optional - numpy sage.libs.pari
5
sage: from gmpy2 import mpz
- sage: primitive_root(mpz(-46))
+ sage: primitive_root(mpz(-46)) # optional - sage.libs.pari
5
"""
from sage.libs.pari.all import pari
@@ -4372,29 +4384,29 @@ def nth_prime(n):
EXAMPLES::
- sage: nth_prime(3)
+ sage: nth_prime(3) # optional - sage.libs.pari
5
- sage: nth_prime(10)
+ sage: nth_prime(10) # optional - sage.libs.pari
29
- sage: nth_prime(10^7)
+ sage: nth_prime(10^7) # optional - sage.libs.pari
179424673
::
- sage: nth_prime(0)
+ sage: nth_prime(0) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: nth prime meaningless for non-positive n (=0)
TESTS::
- sage: all(prime_pi(nth_prime(j)) == j for j in range(1, 1000, 10))
+ sage: all(prime_pi(nth_prime(j)) == j for j in range(1, 1000, 10)) # optional - sage.libs.pari
True
- sage: from numpy import int8
- sage: nth_prime(int8(10))
+ sage: from numpy import int8 # optional - numpy
+ sage: nth_prime(int8(10)) # optional - numpy sage.libs.pari
29
sage: from gmpy2 import mpz
- sage: nth_prime(mpz(10))
+ sage: nth_prime(mpz(10)) # optional - sage.libs.pari
29
"""
if n <= 0:
@@ -4425,8 +4437,8 @@ def quadratic_residues(n):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: quadratic_residues(int8(11))
+ sage: from numpy import int8 # optional - numpy
+ sage: quadratic_residues(int8(11)) # optional - numpy
[0, 1, 3, 4, 5, 9]
sage: from gmpy2 import mpz
sage: quadratic_residues(mpz(11))
@@ -4460,39 +4472,39 @@ class Moebius:
EXAMPLES::
- sage: moebius(-5)
+ sage: moebius(-5) # optional - sage.libs.pari
-1
- sage: moebius(9)
+ sage: moebius(9) # optional - sage.libs.pari
0
- sage: moebius(12)
+ sage: moebius(12) # optional - sage.libs.pari
0
- sage: moebius(-35)
+ sage: moebius(-35) # optional - sage.libs.pari
1
- sage: moebius(-1)
+ sage: moebius(-1) # optional - sage.libs.pari
1
- sage: moebius(7)
+ sage: moebius(7) # optional - sage.libs.pari
-1
::
- sage: moebius(0) # potentially nonstandard!
+ sage: moebius(0) # potentially nonstandard! # optional - sage.libs.pari
0
The moebius function even makes sense for non-integer inputs.
::
- sage: x = GF(7)['x'].0
- sage: moebius(x+2)
+ sage: x = GF(7)['x'].0 # optional - sage.libs.pari
+ sage: moebius(x + 2) # optional - sage.libs.pari
-1
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: moebius(int8(-5))
+ sage: from numpy import int8 # optional - numpy
+ sage: moebius(int8(-5)) # optional - numpy sage.libs.pari
-1
sage: from gmpy2 import mpz
- sage: moebius(mpz(-5))
+ sage: moebius(mpz(-5)) # optional - sage.libs.pari
-1
"""
def __call__(self, n):
@@ -4500,7 +4512,7 @@ def __call__(self, n):
EXAMPLES::
sage: from sage.arith.misc import Moebius
- sage: Moebius().__call__(7)
+ sage: Moebius().__call__(7) # optional - sage.libs.pari
-1
"""
n = py_scalar_to_element(n)
@@ -4558,8 +4570,8 @@ def plot(self, xmin=0, xmax=50, pointsize=30, rgbcolor=(0,0,1), join=True,
EXAMPLES::
sage: from sage.arith.misc import Moebius
- sage: p = Moebius().plot()
- sage: p.ymax()
+ sage: p = Moebius().plot() # optional - sage.plot
+ sage: p.ymax() # optional - sage.plot
1.0
"""
values = self.range(xmin, xmax + 1)
@@ -4581,12 +4593,12 @@ def range(self, start, stop=None, step=None):
EXAMPLES::
- sage: v = moebius.range(-10,10); v
+ sage: v = moebius.range(-10, 10); v # optional - sage.libs.pari
[1, 0, 0, -1, 1, -1, 0, -1, -1, 1, 0, 1, -1, -1, 0, -1, 1, -1, 0, 0]
- sage: v == [moebius(n) for n in range(-10,10)]
+ sage: v == [moebius(n) for n in range(-10, 10)] # optional - sage.libs.pari
True
- sage: v = moebius.range(-1000, 2000, 4)
- sage: v == [moebius(n) for n in range(-1000,2000, 4)]
+ sage: v = moebius.range(-1000, 2000, 4) # optional - sage.libs.pari
+ sage: v == [moebius(n) for n in range(-1000, 2000, 4)] # optional - sage.libs.pari
True
"""
if stop is None:
@@ -4650,14 +4662,15 @@ def continuant(v, n=None):
sage: q = continuant([1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10])
sage: p/q
517656/190435
- sage: continued_fraction([2, 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10]).convergent(14)
+ sage: F = continued_fraction([2, 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10])
+ sage: F.convergent(14) # optional - sage.libs.pari
517656/190435
- sage: x = PolynomialRing(RationalField(),'x',5).gens()
+ sage: x = PolynomialRing(RationalField(), 'x', 5).gens()
sage: continuant(x)
x0*x1*x2*x3*x4 + x0*x1*x2 + x0*x1*x4 + x0*x3*x4 + x2*x3*x4 + x0 + x2 + x4
sage: continuant(x, 3)
x0*x1*x2 + x0 + x2
- sage: continuant(x,2)
+ sage: continuant(x, 2)
x0*x1 + 1
We verify the identity
@@ -4669,7 +4682,7 @@ def continuant(v, n=None):
for `n = 6` using polynomial arithmetic::
sage: z = QQ['z'].0
- sage: continuant((z,z,z,z,z,z,z,z,z,z,z,z,z,z,z),6)
+ sage: continuant((z,z,z,z,z,z,z,z,z,z,z,z,z,z,z), 6)
z^6 + 5*z^4 + 6*z^2 + 1
sage: continuant(9)
@@ -4679,11 +4692,11 @@ def continuant(v, n=None):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: continuant([int8(1),int8(2),int8(3)])
+ sage: from numpy import int8 # optional - numpy
+ sage: continuant([int8(1), int8(2), int8(3)]) # optional - numpy
10
sage: from gmpy2 import mpz
- sage: continuant([mpz(1),mpz(2),mpz(3)])
+ sage: continuant([mpz(1), mpz(2), mpz(3)])
mpz(10)
AUTHORS:
@@ -4717,18 +4730,18 @@ def number_of_divisors(n):
EXAMPLES::
- sage: number_of_divisors(100)
+ sage: number_of_divisors(100) # optional - sage.libs.pari
9
- sage: number_of_divisors(-720)
+ sage: number_of_divisors(-720) # optional - sage.libs.pari
30
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: number_of_divisors(int8(100))
+ sage: from numpy import int8 # optional - numpy
+ sage: number_of_divisors(int8(100)) # optional - numpy sage.libs.pari
9
sage: from gmpy2 import mpz
- sage: number_of_divisors(mpz(100))
+ sage: number_of_divisors(mpz(100)) # optional - sage.libs.pari
9
"""
m = ZZ(n)
@@ -4766,33 +4779,33 @@ def hilbert_symbol(a, b, p, algorithm="pari"):
EXAMPLES::
- sage: hilbert_symbol (-1, -1, -1, algorithm='all')
+ sage: hilbert_symbol(-1, -1, -1, algorithm='all') # optional - sage.libs.pari
-1
- sage: hilbert_symbol (2,3, 5, algorithm='all')
+ sage: hilbert_symbol(2, 3, 5, algorithm='all') # optional - sage.libs.pari
1
- sage: hilbert_symbol (4, 3, 5, algorithm='all')
+ sage: hilbert_symbol(4, 3, 5, algorithm='all') # optional - sage.libs.pari
1
- sage: hilbert_symbol (0, 3, 5, algorithm='all')
+ sage: hilbert_symbol(0, 3, 5, algorithm='all') # optional - sage.libs.pari
0
- sage: hilbert_symbol (-1, -1, 2, algorithm='all')
+ sage: hilbert_symbol(-1, -1, 2, algorithm='all') # optional - sage.libs.pari
-1
- sage: hilbert_symbol (1, -1, 2, algorithm='all')
+ sage: hilbert_symbol(1, -1, 2, algorithm='all') # optional - sage.libs.pari
1
- sage: hilbert_symbol (3, -1, 2, algorithm='all')
+ sage: hilbert_symbol(3, -1, 2, algorithm='all') # optional - sage.libs.pari
-1
- sage: hilbert_symbol(QQ(-1)/QQ(4), -1, 2) == -1
+ sage: hilbert_symbol(QQ(-1)/QQ(4), -1, 2) == -1 # optional - sage.libs.pari
True
- sage: hilbert_symbol(QQ(-1)/QQ(4), -1, 3) == 1
+ sage: hilbert_symbol(QQ(-1)/QQ(4), -1, 3) == 1 # optional - sage.libs.pari
True
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: hilbert_symbol(int8(2),int8(3),int8(5),algorithm='all')
+ sage: from numpy import int8 # optional - numpy
+ sage: hilbert_symbol(int8(2), int8(3), int8(5), algorithm='all') # optional - numpy sage.libs.pari
1
sage: from gmpy2 import mpz
- sage: hilbert_symbol(mpz(2),mpz(3),mpz(5),algorithm='all')
+ sage: hilbert_symbol(mpz(2), mpz(3), mpz(5), algorithm='all') # optional - sage.libs.pari
1
AUTHORS:
@@ -4871,22 +4884,22 @@ def hilbert_conductor(a, b):
EXAMPLES::
- sage: hilbert_conductor(-1, -1)
+ sage: hilbert_conductor(-1, -1) # optional - sage.libs.pari
2
- sage: hilbert_conductor(-1, -11)
+ sage: hilbert_conductor(-1, -11) # optional - sage.libs.pari
11
- sage: hilbert_conductor(-2, -5)
+ sage: hilbert_conductor(-2, -5) # optional - sage.libs.pari
5
- sage: hilbert_conductor(-3, -17)
+ sage: hilbert_conductor(-3, -17) # optional - sage.libs.pari
17
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: hilbert_conductor(int8(-3), int8(-17))
+ sage: from numpy import int8 # optional - numpy
+ sage: hilbert_conductor(int8(-3), int8(-17)) # optional - numpy sage.libs.pari
17
sage: from gmpy2 import mpz
- sage: hilbert_conductor(mpz(-3), mpz(-17))
+ sage: hilbert_conductor(mpz(-3), mpz(-17)) # optional - sage.libs.pari
17
AUTHOR:
@@ -4914,19 +4927,19 @@ def hilbert_conductor_inverse(d):
EXAMPLES::
- sage: hilbert_conductor_inverse(2)
+ sage: hilbert_conductor_inverse(2) # optional - sage.libs.pari
(-1, -1)
- sage: hilbert_conductor_inverse(3)
+ sage: hilbert_conductor_inverse(3) # optional - sage.libs.pari
(-1, -3)
- sage: hilbert_conductor_inverse(6)
+ sage: hilbert_conductor_inverse(6) # optional - sage.libs.pari
(-1, 3)
- sage: hilbert_conductor_inverse(30)
+ sage: hilbert_conductor_inverse(30) # optional - sage.libs.pari
(-3, -10)
- sage: hilbert_conductor_inverse(4)
+ sage: hilbert_conductor_inverse(4) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: d needs to be squarefree
- sage: hilbert_conductor_inverse(-1)
+ sage: hilbert_conductor_inverse(-1) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: d needs to be positive
@@ -4937,18 +4950,18 @@ def hilbert_conductor_inverse(d):
TESTS::
- sage: for i in range(100):
+ sage: for i in range(100): # optional - sage.libs.pari
....: d = ZZ.random_element(2**32).squarefree_part()
....: if hilbert_conductor(*hilbert_conductor_inverse(d)) != d:
....: print("hilbert_conductor_inverse failed for d = {}".format(d))
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: hilbert_conductor_inverse(int8(30))
+ sage: from numpy import int8 # optional - numpy
+ sage: hilbert_conductor_inverse(int8(30)) # optional - numpy sage.libs.pari
(-3, -10)
sage: from gmpy2 import mpz
- sage: hilbert_conductor_inverse(mpz(30))
+ sage: hilbert_conductor_inverse(mpz(30)) # optional - sage.libs.pari
(-3, -10)
"""
Z = ZZ
@@ -5024,25 +5037,25 @@ def falling_factorial(x, a):
sage: falling_factorial(10, 3)
720
- sage: falling_factorial(10, RR('3.0'))
+ sage: falling_factorial(10, RR('3.0')) # optional - sage.symbolic
720.000000000000
- sage: falling_factorial(10, RR('3.3'))
+ sage: falling_factorial(10, RR('3.3')) # optional - sage.symbolic
1310.11633396601
sage: falling_factorial(10, 10)
3628800
sage: factorial(10)
3628800
- sage: a = falling_factorial(1+I, I); a
+ sage: a = falling_factorial(1 + I, I); a # optional - sage.symbolic
gamma(I + 2)
- sage: CC(a)
+ sage: CC(a) # optional - sage.symbolic
0.652965496420167 + 0.343065839816545*I
- sage: falling_factorial(1+I, 4)
+ sage: falling_factorial(1 + I, 4)
4*I + 2
sage: falling_factorial(I, 4)
-10
sage: M = MatrixSpace(ZZ, 4, 4)
- sage: A = M([1,0,1,0,1,0,1,0,1,0,10,10,1,0,1,1])
+ sage: A = M([1,0,1,0, 1,0,1,0, 1,0,10,10, 1,0,1,1])
sage: falling_factorial(A, 2) # A(A - I)
[ 1 0 10 10]
[ 1 0 10 10]
@@ -5057,13 +5070,13 @@ def falling_factorial(x, a):
Check that :trac:`14858` is fixed::
- sage: falling_factorial(-4, SR(2))
+ sage: falling_factorial(-4, SR(2)) # optional - sage.symbolic
20
Check that :trac:`16770` is fixed::
- sage: d = var('d')
- sage: parent(falling_factorial(d, 0))
+ sage: d = var('d') # optional - sage.symbolic
+ sage: parent(falling_factorial(d, 0)) # optional - sage.symbolic
Symbolic Ring
Check that :trac:`20075` is fixed::
@@ -5073,8 +5086,8 @@ def falling_factorial(x, a):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: falling_factorial(int8(10), int8(3))
+ sage: from numpy import int8 # optional - numpy
+ sage: falling_factorial(int8(10), int8(3)) # optional - numpy
720
sage: from gmpy2 import mpz
sage: falling_factorial(mpz(10), mpz(3))
@@ -5149,7 +5162,7 @@ def rising_factorial(x, a):
Check that :trac:`14858` is fixed::
- sage: bool(rising_factorial(-4, 2) ==
+ sage: bool(rising_factorial(-4, 2) == # optional - sage.symbolic
....: rising_factorial(-4, SR(2)) ==
....: rising_factorial(SR(-4), SR(2)))
True
@@ -5167,8 +5180,8 @@ def rising_factorial(x, a):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: rising_factorial(int8(10), int8(3))
+ sage: from numpy import int8 # optional - numpy
+ sage: rising_factorial(int8(10), int8(3)) # optional - numpy
1320
sage: from gmpy2 import mpz
sage: rising_factorial(mpz(10), mpz(3))
@@ -5197,15 +5210,15 @@ def integer_ceil(x):
sage: integer_ceil(5.4)
6
- sage: integer_ceil(x)
+ sage: integer_ceil(x) # optional - sage.symbolic
Traceback (most recent call last):
...
NotImplementedError: computation of ceil of x not implemented
Tests with numpy and gmpy2 numbers::
- sage: from numpy import float32
- sage: integer_ceil(float32(5.4))
+ sage: from numpy import float32 # optional - numpy
+ sage: integer_ceil(float32(5.4)) # optional - numpy
6
sage: from gmpy2 import mpfr
sage: integer_ceil(mpfr(5.4))
@@ -5243,15 +5256,15 @@ def integer_floor(x):
sage: integer_floor(RDF(-5/2))
-3
- sage: integer_floor(x)
+ sage: integer_floor(x) # optional - sage.symbolic
Traceback (most recent call last):
...
NotImplementedError: computation of floor of x not implemented
Tests with numpy and gmpy2 numbers::
- sage: from numpy import float32
- sage: integer_floor(float32(5.4))
+ sage: from numpy import float32 # optional - numpy
+ sage: integer_floor(float32(5.4)) # optional - numpy
5
sage: from gmpy2 import mpfr
sage: integer_floor(mpfr(5.4))
@@ -5307,11 +5320,11 @@ def two_squares(n):
ValueError: 21 is not a sum of 2 squares
sage: two_squares(21^2)
(0, 21)
- sage: a,b = two_squares(100000000000000000129); a,b
+ sage: a, b = two_squares(100000000000000000129); a, b # optional - sage.libs.pari
(4418521500, 8970878873)
- sage: a^2 + b^2
+ sage: a^2 + b^2 # optional - sage.libs.pari
100000000000000000129
- sage: two_squares(2^222+1)
+ sage: two_squares(2^222 + 1) # optional - sage.libs.pari
(253801659504708621991421712450521, 2583712713213354898490304645018692)
sage: two_squares(0)
(0, 0)
@@ -5322,17 +5335,17 @@ def two_squares(n):
TESTS::
- sage: for _ in range(100):
+ sage: for _ in range(100): # optional - sage.libs.pari
....: a = ZZ.random_element(2**16, 2**20)
....: b = ZZ.random_element(2**16, 2**20)
....: n = a**2 + b**2
- ....: aa,bb = two_squares(n)
+ ....: aa, bb = two_squares(n)
....: assert aa**2 + bb**2 == n
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int16
- sage: two_squares(int16(389))
+ sage: from numpy import int16 # optional - numpy
+ sage: two_squares(int16(389)) # optional - numpy
(10, 17)
sage: from gmpy2 import mpz
sage: two_squares(mpz(389))
@@ -5429,11 +5442,11 @@ def three_squares(n):
(3, 24, 49)
sage: three_squares(7^100)
(0, 0, 1798465042647412146620280340569649349251249)
- sage: three_squares(11^111-1)
+ sage: three_squares(11^111 - 1) # optional - sage.libs.pari
(616274160655975340150706442680, 901582938385735143295060746161, 6270382387635744140394001363065311967964099981788593947233)
- sage: three_squares(7 * 2^41)
+ sage: three_squares(7 * 2^41) # optional - sage.libs.pari
(1048576, 2097152, 3145728)
- sage: three_squares(7 * 2^42)
+ sage: three_squares(7 * 2^42) # optional - sage.libs.pari
Traceback (most recent call last):
...
ValueError: 30786325577728 is not a sum of 3 squares
@@ -5446,18 +5459,18 @@ def three_squares(n):
TESTS::
- sage: for _ in range(100):
+ sage: for _ in range(100): # optional - sage.libs.pari
....: a = ZZ.random_element(2**16, 2**20)
....: b = ZZ.random_element(2**16, 2**20)
....: c = ZZ.random_element(2**16, 2**20)
....: n = a**2 + b**2 + c**2
- ....: aa,bb,cc = three_squares(n)
+ ....: aa, bb, cc = three_squares(n)
....: assert aa**2 + bb**2 + cc**2 == n
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int16
- sage: three_squares(int16(389))
+ sage: from numpy import int16 # optional - numpy
+ sage: three_squares(int16(389)) # optional - numpy
(1, 8, 18)
sage: from gmpy2 import mpz
sage: three_squares(mpz(389))
@@ -5573,23 +5586,23 @@ def four_squares(n):
(0, 0, 3, 11)
sage: four_squares(1101011011004)
(90, 102, 1220, 1049290)
- sage: four_squares(10^100-1)
+ sage: four_squares(10^100 - 1) # optional - sage.libs.pari
(155024616290, 2612183768627, 14142135623730950488016887, 99999999999999999999999999999999999999999999999999)
- sage: for i in range(2^129, 2^129+10000): # long time
+ sage: for i in range(2^129, 2^129+10000): # long time # optional - sage.libs.pari
....: S = four_squares(i)
....: assert sum(x^2 for x in S) == i
TESTS::
- sage: for _ in range(100):
- ....: n = ZZ.random_element(2**32,2**34)
- ....: aa,bb,cc,dd = four_squares(n)
+ sage: for _ in range(100): # optional - sage.libs.pari
+ ....: n = ZZ.random_element(2**32, 2**34)
+ ....: aa, bb, cc, dd = four_squares(n)
....: assert aa**2 + bb**2 + cc**2 + dd**2 == n
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int16
- sage: four_squares(int16(389))
+ sage: from numpy import int16 # optional - numpy
+ sage: four_squares(int16(389)) # optional - numpy
(0, 1, 8, 18)
sage: from gmpy2 import mpz
sage: four_squares(mpz(389))
@@ -5650,7 +5663,7 @@ def sum_of_k_squares(k, n):
(1, 2, 5, 98)
sage: sum_of_k_squares(5, 9634)
(0, 1, 2, 5, 98)
- sage: sum_of_k_squares(6, 11^1111-1)
+ sage: sum_of_k_squares(6, 11^1111 - 1) # optional - sage.libs.pari
(19215400822645944253860920437586326284, 37204645194585992174252915693267578306, 3473654819477394665857484221256136567800161086815834297092488779216863122, 5860191799617673633547572610351797996721850737768032876360978911074629287841061578270832330322236796556721252602860754789786937515870682024273948, 20457423294558182494001919812379023992538802203730791019728543439765347851316366537094696896669915675685581905102118246887673397020172285247862426612188418787649371716686651256443143210952163970564228423098202682066311189439731080552623884051737264415984619097656479060977602722566383385989, 311628095411678159849237738619458396497534696043580912225334269371611836910345930320700816649653412141574887113710604828156159177769285115652741014638785285820578943010943846225597311231847997461959204894255074229895666356909071243390280307709880906261008237873840245959883405303580405277298513108957483306488193844321589356441983980532251051786704380984788999660195252373574924026139168936921591652831237741973242604363696352878914129671292072201700073286987126265965322808664802662993006926302359371379531571194266134916767573373504566621665949840469229781956838744551367172353)
sage: sum_of_k_squares(7, 0)
(0, 0, 0, 0, 0, 0, 0)
@@ -5683,8 +5696,8 @@ def sum_of_k_squares(k, n):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int16
- sage: sum_of_k_squares(int16(2), int16(9634))
+ sage: from numpy import int16 # optional - numpy
+ sage: sum_of_k_squares(int16(2), int16(9634)) # optional - numpy
(15, 97)
sage: from gmpy2 import mpz
sage: sum_of_k_squares(mpz(2), mpz(9634))
@@ -5755,8 +5768,8 @@ def subfactorial(n):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: subfactorial(int8(8))
+ sage: from numpy import int8 # optional - numpy
+ sage: subfactorial(int8(8)) # optional - numpy
14833
sage: from gmpy2 import mpz
sage: subfactorial(mpz(8))
@@ -5796,10 +5809,10 @@ def is_power_of_two(n):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: is_power_of_two(int8(16))
+ sage: from numpy import int8 # optional - numpy
+ sage: is_power_of_two(int8(16)) # optional - numpy
True
- sage: is_power_of_two(int8(24))
+ sage: is_power_of_two(int8(24)) # optional - numpy
False
sage: from gmpy2 import mpz
sage: is_power_of_two(mpz(16))
@@ -5816,7 +5829,7 @@ def differences(lis, n=1):
EXAMPLES::
- sage: differences(prime_range(50))
+ sage: differences(prime_range(50)) # optional - sage.libs.pari
[1, 2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4]
sage: differences([i^2 for i in range(1,11)])
[3, 5, 7, 9, 11, 13, 15, 17, 19]
@@ -5824,16 +5837,16 @@ def differences(lis, n=1):
[10, 22, 40, 64, 94, 130, 172, 220, 274, 334, 400, 472, 550, 634, 724, 820, 922, 1030, 1144]
sage: differences([i^3 - i^2 for i in range(1,21)], 2)
[10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, 106, 112]
- sage: differences([p - i^2 for i, p in enumerate(prime_range(50))], 3)
+ sage: differences([p - i^2 for i, p in enumerate(prime_range(50))], 3) # optional - sage.libs.pari
[-1, 2, -4, 4, -4, 4, 0, -6, 8, -6, 0, 4]
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: differences([int8(1),int8(4),int8(6),int8(19)])
+ sage: from numpy import int8 # optional - numpy
+ sage: differences([int8(1), int8(4), int8(6), int8(19)]) # optional - numpy
[3, 2, 13]
sage: from gmpy2 import mpz
- sage: differences([mpz(1),mpz(4),mpz(6),mpz(19)])
+ sage: differences([mpz(1), mpz(4), mpz(6), mpz(19)])
[mpz(3), mpz(2), mpz(13)]
AUTHORS:
@@ -5975,8 +5988,8 @@ def fundamental_discriminant(D):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: fundamental_discriminant(int8(102))
+ sage: from numpy import int8 # optional - numpy
+ sage: fundamental_discriminant(int8(102)) # optional - numpy
408
sage: from gmpy2 import mpz
sage: fundamental_discriminant(mpz(102))
@@ -6033,13 +6046,15 @@ def squarefree_divisors(x):
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: list(squarefree_divisors(int8(12)))
+ sage: from numpy import int8 # optional - numpy
+ sage: list(squarefree_divisors(int8(12))) # optional - numpy
[1, 2, 3, 6]
sage: from gmpy2 import mpz
sage: list(squarefree_divisors(mpz(12)))
[1, 2, 3, 6]
"""
+ from sage.combinat.subset import powerset
+
for a in powerset(prime_divisors(x)):
yield prod(a, ZZ.one())
@@ -6084,7 +6099,7 @@ def dedekind_sum(p, q, algorithm='default'):
Several small values::
- sage: for q in range(10): print([dedekind_sum(p,q) for p in range(q+1)])
+ sage: for q in range(10): print([dedekind_sum(p,q) for p in range(q+1)]) # optional - sage.libs.flint
[0]
[0, 0]
[0, 0, 0]
@@ -6098,44 +6113,44 @@ def dedekind_sum(p, q, algorithm='default'):
Check relations for restricted arguments::
- sage: q = 23; dedekind_sum(1, q); (q-1)*(q-2)/(12*q)
+ sage: q = 23; dedekind_sum(1, q); (q-1)*(q-2)/(12*q) # optional - sage.libs.flint
77/46
77/46
sage: p, q = 100, 723 # must be coprime
- sage: dedekind_sum(p, q) + dedekind_sum(q, p)
+ sage: dedekind_sum(p, q) + dedekind_sum(q, p) # optional - sage.libs.flint
31583/86760
- sage: -1/4 + (p/q + q/p + 1/(p*q))/12
+ sage: -1/4 + (p/q + q/p + 1/(p*q))/12 # optional - sage.libs.flint
31583/86760
We check that evaluation works with large input::
- sage: dedekind_sum(3^54 - 1, 2^93 + 1)
+ sage: dedekind_sum(3^54 - 1, 2^93 + 1) # optional - sage.libs.flint
459340694971839990630374299870/29710560942849126597578981379
- sage: dedekind_sum(3^54 - 1, 2^93 + 1, algorithm='pari')
+ sage: dedekind_sum(3^54 - 1, 2^93 + 1, algorithm='pari') # optional - sage.libs.pari
459340694971839990630374299870/29710560942849126597578981379
We check consistency of the results::
- sage: dedekind_sum(5, 7, algorithm='default')
+ sage: dedekind_sum(5, 7, algorithm='default') # optional - sage.libs.flint
-1/14
- sage: dedekind_sum(5, 7, algorithm='flint')
+ sage: dedekind_sum(5, 7, algorithm='flint') # optional - sage.libs.flint
-1/14
- sage: dedekind_sum(5, 7, algorithm='pari')
+ sage: dedekind_sum(5, 7, algorithm='pari') # optional - sage.libs.pari
-1/14
- sage: dedekind_sum(6, 8, algorithm='default')
+ sage: dedekind_sum(6, 8, algorithm='default') # optional - sage.libs.flint
-1/8
- sage: dedekind_sum(6, 8, algorithm='flint')
+ sage: dedekind_sum(6, 8, algorithm='flint') # optional - sage.libs.flint
-1/8
- sage: dedekind_sum(6, 8, algorithm='pari')
+ sage: dedekind_sum(6, 8, algorithm='pari') # optional - sage.libs.pari
-1/8
Tests with numpy and gmpy2 numbers::
- sage: from numpy import int8
- sage: dedekind_sum(int8(5), int8(7), algorithm='default')
+ sage: from numpy import int8 # optional - numpy
+ sage: dedekind_sum(int8(5), int8(7), algorithm='default') # optional - numpy sage.libs.flint
-1/14
sage: from gmpy2 import mpz
- sage: dedekind_sum(mpz(5), mpz(7), algorithm='default')
+ sage: dedekind_sum(mpz(5), mpz(7), algorithm='default') # optional - sage.libs.flint
-1/14
REFERENCES:
@@ -6194,45 +6209,45 @@ def gauss_sum(char_value, finite_field):
EXAMPLES::
sage: from sage.arith.misc import gauss_sum
- sage: F = GF(5); q = 5
- sage: zq = UniversalCyclotomicField().zeta(q-1)
- sage: L = [gauss_sum(zq**i,F) for i in range(5)]; L
+ sage: F = GF(5); q = 5 # optional - sage.libs.pari
+ sage: zq = UniversalCyclotomicField().zeta(q - 1) # optional - sage.libs.pari
+ sage: L = [gauss_sum(zq**i, F) for i in range(5)]; L # optional - sage.libs.pari
[-1,
E(20)^4 + E(20)^13 - E(20)^16 - E(20)^17,
E(5) - E(5)^2 - E(5)^3 + E(5)^4,
E(20)^4 - E(20)^13 - E(20)^16 + E(20)^17,
-1]
- sage: [g*g.conjugate() for g in L]
+ sage: [g*g.conjugate() for g in L] # optional - sage.libs.pari
[1, 5, 5, 5, 1]
- sage: F = GF(11**2); q = 11**2
- sage: zq = UniversalCyclotomicField().zeta(q-1)
- sage: g = gauss_sum(zq**4,F)
- sage: g*g.conjugate()
+ sage: F = GF(11**2); q = 11**2 # optional - sage.libs.pari
+ sage: zq = UniversalCyclotomicField().zeta(q - 1) # optional - sage.libs.pari
+ sage: g = gauss_sum(zq**4, F) # optional - sage.libs.pari
+ sage: g*g.conjugate() # optional - sage.libs.pari
121
TESTS::
- sage: F = GF(11); q = 11
- sage: zq = UniversalCyclotomicField().zeta(q-1)
- sage: gauss_sum(zq**2,F).n(60)
+ sage: F = GF(11); q = 11 # optional - sage.libs.pari sage.rings.number_field
+ sage: zq = UniversalCyclotomicField().zeta(q - 1) # optional - sage.libs.pari sage.rings.number_field
+ sage: gauss_sum(zq**2, F).n(60) # optional - sage.libs.pari sage.rings.number_field
2.6361055643248352 + 2.0126965627574471*I
- sage: zq = QQbar.zeta(q-1)
- sage: gauss_sum(zq**2,F)
+ sage: zq = QQbar.zeta(q - 1) # optional - sage.libs.pari sage.rings.number_field
+ sage: gauss_sum(zq**2, F) # optional - sage.libs.pari sage.rings.number_field
2.636105564324836? + 2.012696562757447?*I
- sage: zq = ComplexField(60).zeta(q-1)
- sage: gauss_sum(zq**2,F)
+ sage: zq = ComplexField(60).zeta(q - 1) # optional - sage.libs.pari sage.rings.number_field
+ sage: gauss_sum(zq**2, F) # optional - sage.libs.pari sage.rings.number_field
2.6361055643248352 + 2.0126965627574471*I
- sage: F = GF(7); q = 7
- sage: zq = QQbar.zeta(q-1)
- sage: D = DirichletGroup(7, QQbar)
- sage: all(D[i].gauss_sum()==gauss_sum(zq**i,F) for i in range(6))
+ sage: F = GF(7); q = 7 # optional - sage.libs.pari sage.rings.number_field
+ sage: zq = QQbar.zeta(q - 1) # optional - sage.libs.pari sage.rings.number_field
+ sage: D = DirichletGroup(7, QQbar) # optional - sage.libs.pari sage.rings.number_field
+ sage: all(D[i].gauss_sum() == gauss_sum(zq**i, F) for i in range(6)) # optional - sage.libs.pari sage.rings.number_field
True
- sage: gauss_sum(1,QQ)
+ sage: gauss_sum(1, QQ)
Traceback (most recent call last):
...
ValueError: second input must be a finite field
diff --git a/src/sage/arith/multi_modular.pyx b/src/sage/arith/multi_modular.pyx
index 766c9923404..17505583fca 100644
--- a/src/sage/arith/multi_modular.pyx
+++ b/src/sage/arith/multi_modular.pyx
@@ -1,3 +1,4 @@
+# sage.doctest: optional - primecountpy
"""
Utility classes for multi-modular algorithms
"""
diff --git a/src/sage/calculus/all.py b/src/sage/calculus/all.py
index bc93e3f62a7..caaaa30e1fb 100644
--- a/src/sage/calculus/all.py
+++ b/src/sage/calculus/all.py
@@ -1,34 +1,12 @@
+from .all__sagemath_standard_no_symbolics import *
from .calculus import maxima as maxima_calculus
from .calculus import (laplace, inverse_laplace,
limit, lim)
-from .integration import numerical_integral, monte_carlo_integral
-integral_numerical = numerical_integral
-
-from .interpolation import spline, Spline
-
-from .functional import (diff, derivative,
- expand,
- taylor, simplify)
-
-from .functions import (wronskian,jacobian)
-
-from .ode import ode_solver, ode_system
-
-from .desolvers import (desolve, desolve_laplace, desolve_system,
- eulers_method, eulers_method_2x2,
- eulers_method_2x2_plot, desolve_rk4, desolve_system_rk4,
- desolve_odeint, desolve_mintides, desolve_tides_mpfr)
-
+from .functional import expand, simplify
from .var import (var, function, clear_vars)
-from .transforms.all import *
-
-# We lazy_import the following modules since they import numpy which slows down sage startup
-from sage.misc.lazy_import import lazy_import
-lazy_import("sage.calculus.riemann",["Riemann_Map"])
-lazy_import("sage.calculus.interpolators",["polygon_spline","complex_cubic_spline"])
from sage.modules.free_module_element import vector
from sage.matrix.constructor import matrix
diff --git a/src/sage/calculus/all__sagemath_standard_no_symbolics.py b/src/sage/calculus/all__sagemath_standard_no_symbolics.py
new file mode 100644
index 00000000000..a43c67fad32
--- /dev/null
+++ b/src/sage/calculus/all__sagemath_standard_no_symbolics.py
@@ -0,0 +1,22 @@
+from .integration import numerical_integral, monte_carlo_integral
+integral_numerical = numerical_integral
+
+from .interpolation import spline, Spline
+
+from .functional import diff, derivative, taylor
+
+from .functions import wronskian, jacobian
+
+from .ode import ode_solver, ode_system
+
+from .desolvers import (desolve, desolve_laplace, desolve_system,
+ eulers_method, eulers_method_2x2,
+ eulers_method_2x2_plot, desolve_rk4, desolve_system_rk4,
+ desolve_odeint, desolve_mintides, desolve_tides_mpfr)
+
+from .transforms.all import *
+
+# We lazy_import the following modules since they import numpy which slows down sage startup
+from sage.misc.lazy_import import lazy_import
+lazy_import("sage.calculus.riemann",["Riemann_Map"])
+lazy_import("sage.calculus.interpolators",["polygon_spline","complex_cubic_spline"])
diff --git a/src/sage/calculus/riemann.pyx b/src/sage/calculus/riemann.pyx
index 4dc18b964f2..b7969a8c4c2 100644
--- a/src/sage/calculus/riemann.pyx
+++ b/src/sage/calculus/riemann.pyx
@@ -1190,10 +1190,11 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
EXAMPLES::
sage: from sage.calculus.riemann import complex_to_spiderweb
- sage: import numpy
- sage: zval = numpy.array([[0, 1, 1000],[.2+.3j,1,-.3j],[0,0,0]],dtype = numpy.complex128)
- sage: deriv = numpy.array([[.1]],dtype = numpy.float64)
- sage: complex_to_spiderweb(zval, deriv,deriv, 4,4,[0,0,0],1,False,0.001)
+ sage: import numpy # optional - numpy
+ sage: zval = numpy.array([[0,1,1000], [.2+.3j,1,-.3j], [0,0,0]], # optional - numpy
+ ....: dtype=numpy.complex128)
+ sage: deriv = numpy.array([[.1]],dtype = numpy.float64) # optional - numpy
+ sage: complex_to_spiderweb(zval, deriv, deriv, 4, 4, [0,0,0], 1, False, 0.001) # optional - numpy
array([[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]],
@@ -1206,7 +1207,7 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
[1., 1., 1.],
[1., 1., 1.]]])
- sage: complex_to_spiderweb(zval, deriv,deriv, 4,4,[0,0,0],1,True,0.001)
+ sage: complex_to_spiderweb(zval, deriv, deriv, 4, 4, [0,0,0], 1, True, 0.001) # optional - numpy
array([[[1. , 1. , 1. ],
[1. , 0.05558355, 0.05558355],
[0.17301243, 0. , 0. ]],
@@ -1280,13 +1281,13 @@ cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values):
EXAMPLES::
sage: from sage.calculus.riemann import complex_to_rgb
- sage: import numpy
- sage: complex_to_rgb(numpy.array([[0, 1, 1000]], dtype = numpy.complex128))
+ sage: import numpy # optional - numpy
+ sage: complex_to_rgb(numpy.array([[0, 1, 1000]], dtype=numpy.complex128)) # optional - numpy
array([[[1. , 1. , 1. ],
[1. , 0.05558355, 0.05558355],
[0.17301243, 0. , 0. ]]])
- sage: complex_to_rgb(numpy.array([[0, 1j, 1000j]], dtype = numpy.complex128))
+ sage: complex_to_rgb(numpy.array([[0, 1j, 1000j]], dtype=numpy.complex128)) # optional - numpy
array([[[1. , 1. , 1. ],
[0.52779177, 1. , 0.05558355],
[0.08650622, 0.17301243, 0. ]]])
diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
index 927e6ee4fb6..a1db950bf10 100644
--- a/src/sage/calculus/test_sympy.py
+++ b/src/sage/calculus/test_sympy.py
@@ -102,98 +102,98 @@
And here are some actual tests of sympy::
- sage: from sympy import Symbol, cos, sympify, pprint
- sage: from sympy.abc import x
+ sage: from sympy import Symbol, cos, sympify, pprint # optional - sympy
+ sage: from sympy.abc import x # optional - sympy
::
- sage: e = (1/cos(x)^3)._sympy_(); e
+ sage: e = (1/cos(x)^3)._sympy_(); e # optional - sympy
cos(x)**(-3)
- sage: f = e.series(x, 0, int(10)); f
+ sage: f = e.series(x, 0, int(10)); f # optional - sympy
1 + 3*x**2/2 + 11*x**4/8 + 241*x**6/240 + 8651*x**8/13440 + O(x**10)
And the pretty-printer. Since unicode characters are not working on
some architectures, we disable it::
- sage: from sympy.printing import pprint_use_unicode
- sage: prev_use = pprint_use_unicode(False)
- sage: pprint(e)
+ sage: from sympy.printing import pprint_use_unicode # optional - sympy
+ sage: prev_use = pprint_use_unicode(False) # optional - sympy
+ sage: pprint(e) # optional - sympy
1
-------
3
cos (x)
- sage: pprint(f)
+ sage: pprint(f) # optional - sympy
2 4 6 8
3*x 11*x 241*x 8651*x / 10\
1 + ---- + ----- + ------ + ------- + O\x /
2 8 240 13440
- sage: pprint_use_unicode(prev_use)
+ sage: pprint_use_unicode(prev_use) # optional - sympy
False
And the functionality to convert from sympy format to Sage format::
- sage: e._sage_()
+ sage: e._sage_() # optional - sympy
cos(x)^(-3)
- sage: e._sage_().taylor(x._sage_(), 0, 8)
+ sage: e._sage_().taylor(x._sage_(), 0, 8) # optional - sympy
8651/13440*x^8 + 241/240*x^6 + 11/8*x^4 + 3/2*x^2 + 1
- sage: f._sage_()
+ sage: f._sage_() # optional - sympy
8651/13440*x^8 + 241/240*x^6 + 11/8*x^4 + 3/2*x^2 + Order(x^10) + 1
Mixing SymPy with Sage::
- sage: import sympy
- sage: var("x")._sympy_() + var("y")._sympy_()
+ sage: import sympy # optional - sympy
+ sage: var("x")._sympy_() + var("y")._sympy_() # optional - sympy
x + y
- sage: o = var("omega")
- sage: s = sympy.Symbol("x")
- sage: t1 = s + o
- sage: t2 = o + s
- sage: type(t1)
+ sage: o = var("omega") # optional - sympy
+ sage: s = sympy.Symbol("x") # optional - sympy
+ sage: t1 = s + o # optional - sympy
+ sage: t2 = o + s # optional - sympy
+ sage: type(t1) # optional - sympy
- sage: type(t2)
+ sage: type(t2) # optional - sympy
- sage: t1, t2
+ sage: t1, t2 # optional - sympy
(omega + x, omega + x)
- sage: e=sympy.sin(var("y"))+sage.all.cos(sympy.Symbol("x"))
- sage: type(e)
+ sage: e = sympy.sin(var("y"))+sage.all.cos(sympy.Symbol("x")) # optional - sympy
+ sage: type(e) # optional - sympy
- sage: e
+ sage: e # optional - sympy
sin(y) + cos(x)
- sage: e=e._sage_()
- sage: type(e)
+ sage: e=e._sage_() # optional - sympy
+ sage: type(e) # optional - sympy
- sage: e
+ sage: e # optional - sympy
cos(x) + sin(y)
- sage: e = sage.all.cos(var("y")**3)**4+var("x")**2
- sage: e = e._sympy_()
- sage: e
+ sage: e = sage.all.cos(var("y")**3)**4+var("x")**2 # optional - sympy
+ sage: e = e._sympy_() # optional - sympy
+ sage: e # optional - sympy
x**2 + cos(y**3)**4
::
- sage: a = sympy.Matrix([1, 2, 3])
- sage: a[1]
+ sage: a = sympy.Matrix([1, 2, 3]) # optional - sympy
+ sage: a[1] # optional - sympy
2
::
- sage: sympify(1.5)
+ sage: sympify(1.5) # optional - sympy
1.50000000000000
- sage: sympify(2)
+ sage: sympify(2) # optional - sympy
2
- sage: sympify(-2)
+ sage: sympify(-2) # optional - sympy
-2
TESTS:
This was fixed in Sympy, see :trac:`14437`::
- sage: from sympy import Function, Symbol, rsolve
- sage: u = Function('u')
- sage: n = Symbol('n', integer=True)
- sage: f = u(n+2) - u(n+1) + u(n)/4
- sage: expand(2**n * rsolve(f,u(n)))
+ sage: from sympy import Function, Symbol, rsolve # optional - sympy
+ sage: u = Function('u') # optional - sympy
+ sage: n = Symbol('n', integer=True) # optional - sympy
+ sage: f = u(n+2) - u(n+1) + u(n)/4 # optional - sympy
+ sage: expand(2**n * rsolve(f,u(n))) # optional - sympy
2*C1*n + C0
"""
diff --git a/src/sage/categories/action.pyx b/src/sage/categories/action.pyx
index 0c82d6cfe08..b90d97e0f02 100644
--- a/src/sage/categories/action.pyx
+++ b/src/sage/categories/action.pyx
@@ -21,7 +21,8 @@ A group action `G \times S \rightarrow S` is a functor from `G` to Sets.
sage: import gc
sage: _ = gc.collect()
sage: A
- ) failed: RuntimeError: This action acted on a set that became garbage collected>
+ ) failed:
+ RuntimeError: This action acted on a set that became garbage collected>
To avoid garbage collection of the underlying set, it is sufficient to
create a strong reference to it before the action is created.
@@ -265,15 +266,17 @@ cdef class Action(Functor):
sage: R = (ZZ['x'])['y']
sage: A = R.get_action(P,operator.mul,True)
sage: A # indirect doctest
- Right scalar multiplication by Univariate Polynomial Ring in x over
- Rational Field on Univariate Polynomial Ring in y over Univariate
- Polynomial Ring in x over Integer Ring
+ Right scalar multiplication
+ by Univariate Polynomial Ring in x over Rational Field
+ on Univariate Polynomial Ring in y over
+ Univariate Polynomial Ring in x over Integer Ring
In this example, the underlying set is the ring ``R``. This is the same
as the left domain, which is different from the codomain of the action::
sage: A.codomain()
- Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field
+ Univariate Polynomial Ring in y
+ over Univariate Polynomial Ring in x over Rational Field
sage: A.codomain() == R
False
sage: A.left_domain() is R
@@ -294,7 +297,8 @@ cdef class Action(Functor):
sage: import gc
sage: _ = gc.collect()
sage: A
- ) failed: RuntimeError: This action acted on a set that became garbage collected>
+ ) failed:
+ RuntimeError: This action acted on a set that became garbage collected>
"""
S = self.US()
if S is None:
@@ -329,24 +333,28 @@ cdef class InverseAction(Action):
EXAMPLES::
- sage: V = QQ^3
- sage: v = V((1, 2, 3))
+ sage: V = QQ^3 # optional - sage.modules
+ sage: v = V((1, 2, 3)) # optional - sage.modules
sage: cm = get_coercion_model()
- sage: a = cm.get_action(V, QQ, operator.mul)
- sage: a
- Right scalar multiplication by Rational Field on Vector space of dimension 3 over Rational Field
- sage: ~a
- Right inverse action by Rational Field on Vector space of dimension 3 over Rational Field
- sage: (~a)(v, 1/3)
+ sage: a = cm.get_action(V, QQ, operator.mul) # optional - sage.modules
+ sage: a # optional - sage.modules
+ Right scalar multiplication by Rational Field
+ on Vector space of dimension 3 over Rational Field
+ sage: ~a # optional - sage.modules
+ Right inverse action by Rational Field
+ on Vector space of dimension 3 over Rational Field
+ sage: (~a)(v, 1/3) # optional - sage.modules
(3, 6, 9)
- sage: b = cm.get_action(QQ, V, operator.mul)
- sage: b
- Left scalar multiplication by Rational Field on Vector space of dimension 3 over Rational Field
- sage: ~b
- Left inverse action by Rational Field on Vector space of dimension 3 over Rational Field
- sage: (~b)(1/3, v)
+ sage: b = cm.get_action(QQ, V, operator.mul) # optional - sage.modules
+ sage: b # optional - sage.modules
+ Left scalar multiplication by Rational Field
+ on Vector space of dimension 3 over Rational Field
+ sage: ~b # optional - sage.modules
+ Left inverse action by Rational Field
+ on Vector space of dimension 3 over Rational Field
+ sage: (~b)(1/3, v) # optional - sage.modules
(3, 6, 9)
sage: c = cm.get_action(ZZ, list, operator.mul)
@@ -390,11 +398,11 @@ cdef class InverseAction(Action):
Check that this action can be pickled (:trac:`29031`)::
- sage: V = QQ^3
- sage: v = V((1, 2, 3))
- sage: cm = get_coercion_model()
- sage: a = cm.get_action(V, QQ, operator.mul)
- sage: loads(dumps(~a)) is not None
+ sage: V = QQ^3 # optional - sage.modules
+ sage: v = V((1, 2, 3)) # optional - sage.modules
+ sage: cm = get_coercion_model() # optional - sage.modules
+ sage: a = cm.get_action(V, QQ, operator.mul) # optional - sage.modules
+ sage: loads(dumps(~a)) is not None # optional - sage.modules
True
"""
return (type(self), (self._action,))
@@ -434,8 +442,9 @@ cdef class PrecomposedAction(Action):
sage: c,x = v[0]
sage: y = x.modular_symbol_rep()
sage: coercion_model.get_action(QQ, parent(y), op=operator.mul)
- Left scalar multiplication by Rational Field on Abelian Group of all Formal Finite Sums over Rational Field
- with precomposition on right by Coercion map:
+ Left scalar multiplication by Rational Field
+ on Abelian Group of all Formal Finite Sums over Rational Field
+ with precomposition on right by Coercion map:
From: Abelian Group of all Formal Finite Sums over Integer Ring
To: Abelian Group of all Formal Finite Sums over Rational Field
"""
@@ -542,8 +551,8 @@ cdef class ActionEndomorphism(Morphism):
sage: A = ZZ['x'].get_action(QQ, self_on_left=False, op=operator.mul)
sage: A
- Left scalar multiplication by Rational Field on Univariate Polynomial
- Ring in x over Integer Ring
+ Left scalar multiplication by Rational Field
+ on Univariate Polynomial Ring in x over Integer Ring
sage: A(1/2)
Action of 1/2 on Univariate Polynomial Ring in x over Integer Ring
under Left scalar multiplication by Rational Field on Univariate
diff --git a/src/sage/categories/additive_magmas.py b/src/sage/categories/additive_magmas.py
index 8d2c46d0771..52c97ce71e3 100644
--- a/src/sage/categories/additive_magmas.py
+++ b/src/sage/categories/additive_magmas.py
@@ -33,7 +33,10 @@ class AdditiveMagmas(Category_singleton):
sage: AdditiveMagmas().super_categories()
[Category of sets]
sage: AdditiveMagmas().all_super_categories()
- [Category of additive magmas, Category of sets, Category of sets with partial maps, Category of objects]
+ [Category of additive magmas,
+ Category of sets,
+ Category of sets with partial maps,
+ Category of objects]
The following axioms are defined by this category::
@@ -45,11 +48,11 @@ class AdditiveMagmas(Category_singleton):
Category of additive commutative additive magmas
sage: AdditiveMagmas().AdditiveUnital().AdditiveInverse()
Category of additive inverse additive unital additive magmas
- sage: AdditiveMagmas().AdditiveAssociative().AdditiveCommutative()
+ sage: C = AdditiveMagmas().AdditiveAssociative().AdditiveCommutative(); C
Category of commutative additive semigroups
- sage: AdditiveMagmas().AdditiveAssociative().AdditiveCommutative().AdditiveUnital()
+ sage: C.AdditiveUnital()
Category of commutative additive monoids
- sage: AdditiveMagmas().AdditiveAssociative().AdditiveCommutative().AdditiveUnital().AdditiveInverse()
+ sage: C.AdditiveUnital().AdditiveInverse()
Category of commutative additive groups
TESTS::
@@ -112,9 +115,10 @@ def AdditiveCommutative(self):
sage: AdditiveMagmas().AdditiveCommutative()
Category of additive commutative additive magmas
- sage: AdditiveMagmas().AdditiveAssociative().AdditiveUnital().AdditiveCommutative()
+ sage: C = AdditiveMagmas().AdditiveAssociative().AdditiveUnital()
+ sage: C.AdditiveCommutative()
Category of commutative additive monoids
- sage: _ is CommutativeAdditiveMonoids()
+ sage: C.AdditiveCommutative() is CommutativeAdditiveMonoids()
True
TESTS::
@@ -279,7 +283,7 @@ def addition_table(self, names='letters', elements=None):
elements as lowercase ASCII letters. ::
sage: R = IntegerModRing(5)
- sage: R.addition_table()
+ sage: R.addition_table() # optional - sage.modules
+ a b c d e
+----------
a| a b c d e
@@ -294,8 +298,7 @@ def addition_table(self, names='letters', elements=None):
``digits`` will include leading zeros as padding. ::
sage: R = IntegerModRing(11)
- sage: P = R.addition_table(names='elements')
- sage: P
+ sage: P = R.addition_table(names='elements'); P # optional - sage.modules
+ 0 1 2 3 4 5 6 7 8 9 10
+---------------------------------
0| 0 1 2 3 4 5 6 7 8 9 10
@@ -310,8 +313,7 @@ def addition_table(self, names='letters', elements=None):
9| 9 10 0 1 2 3 4 5 6 7 8
10| 10 0 1 2 3 4 5 6 7 8 9
- sage: T = R.addition_table(names='digits')
- sage: T
+ sage: T = R.addition_table(names='digits'); T # optional - sage.modules
+ 00 01 02 03 04 05 06 07 08 09 10
+---------------------------------
00| 00 01 02 03 04 05 06 07 08 09 10
@@ -331,7 +333,7 @@ def addition_table(self, names='letters', elements=None):
sage: S = IntegerModRing(7)
sage: elts = [0, 3, 6, 2, 5, 1, 4]
- sage: S.addition_table(elements=elts)
+ sage: S.addition_table(elements=elts) # optional - sage.modules
+ a b c d e f g
+--------------
a| a b c d e f g
@@ -351,8 +353,8 @@ def addition_table(self, names='letters', elements=None):
representation. ::
sage: T = IntegerModRing(12)
- sage: elts=[0, 3, 6, 9]
- sage: T.addition_table(names='elements', elements=elts)
+ sage: elts = [0, 3, 6, 9]
+ sage: T.addition_table(names='elements', elements=elts) # optional - sage.modules
+ 0 3 6 9
+--------
0| 0 3 6 9
@@ -366,15 +368,15 @@ def addition_table(self, names='letters', elements=None):
comprehensive documentation. ::
sage: R = IntegerModRing(3)
- sage: T = R.addition_table()
- sage: T.column_keys()
+ sage: T = R.addition_table() # optional - sage.modules
+ sage: T.column_keys() # optional - sage.modules
(0, 1, 2)
- sage: sorted(T.translation().items())
+ sage: sorted(T.translation().items()) # optional - sage.modules
[('a', 0), ('b', 1), ('c', 2)]
- sage: T.change_names(['x', 'y', 'z'])
- sage: sorted(T.translation().items())
+ sage: T.change_names(['x', 'y', 'z']) # optional - sage.modules
+ sage: sorted(T.translation().items()) # optional - sage.modules
[('x', 0), ('y', 1), ('z', 2)]
- sage: T
+ sage: T # optional - sage.modules
+ x y z
+------
x| x y z
@@ -471,16 +473,16 @@ def _add_(self, right):
r"""
EXAMPLES::
- sage: G5=GF(5); G8=GF(4,'x'); GG = G5.cartesian_product(G8)
- sage: e = GG((G5(1),G8.primitive_element())); e
+ sage: G5 = GF(5); G8 = GF(4, 'x'); GG = G5.cartesian_product(G8) # optional - sage.rings.finite_rings
+ sage: e = GG((G5(1), G8.primitive_element())); e # optional - sage.rings.finite_rings
(1, x)
- sage: e+e
+ sage: e + e # optional - sage.rings.finite_rings
(2, 0)
- sage: e = groups.misc.AdditiveCyclic(8)
- sage: x = e.cartesian_product(e)((e(1),e(2)))
- sage: x
+ sage: e = groups.misc.AdditiveCyclic(8) # optional - sage.rings.finite_rings
+ sage: x = e.cartesian_product(e)((e(1), e(2))) # optional - sage.rings.finite_rings
+ sage: x # optional - sage.rings.finite_rings
(1, 2)
- sage: 4*x
+ sage: 4 * x # optional - sage.rings.finite_rings
(4, 0)
"""
return self.parent()._cartesian_product_of_elements(
@@ -497,7 +499,8 @@ def extra_super_categories(self):
[Category of magmatic algebras with basis over Rational Field]
sage: AdditiveMagmas().Algebras(QQ).super_categories()
- [Category of magmatic algebras with basis over Rational Field, Category of set algebras over Rational Field]
+ [Category of magmatic algebras with basis over Rational Field,
+ Category of set algebras over Rational Field]
"""
from sage.categories.magmatic_algebras import MagmaticAlgebras
return [MagmaticAlgebras(self.base_ring()).WithBasis()]
@@ -516,9 +519,10 @@ def algebra_generators(self):
EXAMPLES::
sage: S = CommutativeAdditiveSemigroups().example(); S
- An example of a commutative semigroup: the free commutative semigroup generated by ('a', 'b', 'c', 'd')
- sage: A = S.algebra(QQ)
- sage: A.algebra_generators()
+ An example of a commutative semigroup:
+ the free commutative semigroup generated by ('a', 'b', 'c', 'd')
+ sage: A = S.algebra(QQ) # optional - sage.modules
+ sage: A.algebra_generators() # optional - sage.modules
Family (B[a], B[b], B[c], B[d])
.. TODO::
@@ -541,10 +545,11 @@ def product_on_basis(self, g1, g2):
EXAMPLES::
sage: S = CommutativeAdditiveSemigroups().example(); S
- An example of a commutative semigroup: the free commutative semigroup generated by ('a', 'b', 'c', 'd')
- sage: A = S.algebra(QQ)
- sage: a,b,c,d = A.algebra_generators()
- sage: a * d * b
+ An example of a commutative semigroup:
+ the free commutative semigroup generated by ('a', 'b', 'c', 'd')
+ sage: A = S.algebra(QQ) # optional - sage.modules
+ sage: a, b, c, d = A.algebra_generators() # optional - sage.modules
+ sage: a * d * b # optional - sage.modules
B[a + b + d]
.. TODO::
@@ -580,10 +585,11 @@ def extra_super_categories(self):
EXAMPLES::
- sage: AdditiveMagmas().AdditiveCommutative().Algebras(QQ).extra_super_categories()
+ sage: C = AdditiveMagmas().AdditiveCommutative().Algebras(QQ)
+ sage: C.extra_super_categories()
[Category of commutative magmas]
- sage: AdditiveMagmas().AdditiveCommutative().Algebras(QQ).super_categories()
+ sage: C.super_categories()
[Category of additive magma algebras over Rational Field,
Category of commutative magmas]
"""
@@ -718,10 +724,10 @@ def is_empty(self):
EXAMPLES::
- sage: A = AdditiveAbelianGroup([3,3])
- sage: A in AdditiveMagmas()
+ sage: A = AdditiveAbelianGroup([3, 3]) # optional - sage.groups
+ sage: A in AdditiveMagmas() # optional - sage.groups
True
- sage: A.is_empty()
+ sage: A.is_empty() # optional - sage.groups
False
sage: B = CommutativeAdditiveMonoids().example()
@@ -733,7 +739,7 @@ def is_empty(self):
We check that the method ``is_empty`` is inherited from this
category in both examples above::
- sage: A.is_empty.__module__
+ sage: A.is_empty.__module__ # optional - sage.groups
'sage.categories.additive_magmas'
sage: B.is_empty.__module__
'sage.categories.additive_magmas'
@@ -801,17 +807,17 @@ def _sub_(left, right):
EXAMPLES::
- sage: F = CombinatorialFreeModule(QQ, ['a','b'])
- sage: a,b = F.basis()
- sage: a - b
+ sage: F = CombinatorialFreeModule(QQ, ['a', 'b']) # optional - sage.modules
+ sage: a, b = F.basis() # optional - sage.modules
+ sage: a - b # optional - sage.modules
B['a'] - B['b']
TESTS:
Check that :trac:`18275` is fixed::
- sage: C = GF(5).cartesian_product(GF(5))
- sage: C.one() - C.one()
+ sage: C = GF(5).cartesian_product(GF(5)) # optional - sage.rings.finite_rings
+ sage: C.one() - C.one() # optional - sage.rings.finite_rings
(0, 0)
"""
return left + (-right)
@@ -827,21 +833,21 @@ def __neg__(self):
EXAMPLES::
- sage: F = CombinatorialFreeModule(QQ, ['a','b'])
- sage: a,b = F.basis()
- sage: - b
+ sage: F = CombinatorialFreeModule(QQ, ['a', 'b']) # optional - sage.modules
+ sage: a, b = F.basis() # optional - sage.modules
+ sage: -b # optional - sage.modules
-B['b']
TESTS::
- sage: F = CombinatorialFreeModule(ZZ, ['a','b'])
- sage: a,b = F.gens()
- sage: FF = cartesian_product((F,F))
- sage: x = cartesian_product([a,2*a-3*b]) ; x
+ sage: F = CombinatorialFreeModule(ZZ, ['a', 'b']) # optional - sage.modules
+ sage: a, b = F.gens() # optional - sage.modules
+ sage: FF = cartesian_product((F, F)) # optional - sage.modules
+ sage: x = cartesian_product([a, 2*a-3*b]); x # optional - sage.modules
B[(0, 'a')] + 2*B[(1, 'a')] - 3*B[(1, 'b')]
- sage: x.parent() is FF
+ sage: x.parent() is FF # optional - sage.modules
True
- sage: -x
+ sage: -x # optional - sage.modules
-B[(0, 'a')] - 2*B[(1, 'a')] + 3*B[(1, 'b')]
"""
return self._neg_()
@@ -911,14 +917,15 @@ def _neg_(self):
EXAMPLES::
- sage: x = cartesian_product((GF(7)(2),17)) ; x
+ sage: x = cartesian_product((GF(7)(2), 17)); x # optional - sage.rings.finite_rings
(2, 17)
- sage: -x
+ sage: -x # optional - sage.rings.finite_rings
(5, -17)
TESTS::
- sage: x.parent() in AdditiveMagmas().AdditiveUnital().AdditiveInverse().CartesianProducts()
+ sage: C = AdditiveMagmas().AdditiveUnital().AdditiveInverse().CartesianProducts()
+ sage: x.parent() in C # optional - sage.rings.finite_rings
True
"""
return self.parent()._cartesian_product_of_elements(
@@ -947,7 +954,7 @@ def zero(self):
EXAMPLES::
- sage: GF(8,'x').cartesian_product(GF(5)).zero()
+ sage: GF(8, 'x').cartesian_product(GF(5)).zero() # optional - sage.rings.finite_rings
(0, 0)
"""
return self._cartesian_product_of_elements(
@@ -964,7 +971,8 @@ def extra_super_categories(self):
[Category of unital magmas]
sage: C.super_categories()
- [Category of unital algebras with basis over Rational Field, Category of additive magma algebras over Rational Field]
+ [Category of unital algebras with basis over Rational Field,
+ Category of additive magma algebras over Rational Field]
"""
from sage.categories.magmas import Magmas
return [Magmas().Unital()]
@@ -982,13 +990,14 @@ def one_basis(self):
EXAMPLES::
sage: S = CommutativeAdditiveMonoids().example(); S
- An example of a commutative monoid: the free commutative monoid generated by ('a', 'b', 'c', 'd')
- sage: A = S.algebra(ZZ)
- sage: A.one_basis()
+ An example of a commutative monoid:
+ the free commutative monoid generated by ('a', 'b', 'c', 'd')
+ sage: A = S.algebra(ZZ) # optional - sage.modules
+ sage: A.one_basis() # optional - sage.modules
0
- sage: A.one()
+ sage: A.one() # optional - sage.modules
B[0]
- sage: A(3)
+ sage: A(3) # optional - sage.modules
3*B[0]
"""
return self.basis().keys().zero()
@@ -1007,17 +1016,17 @@ def zero(self):
EXAMPLES::
- sage: A = Sets().WithRealizations().example(); A
+ sage: A = Sets().WithRealizations().example(); A # optional - sage.combinat
The subset algebra of {1, 2, 3} over Rational Field
- sage: A.zero.__module__
+ sage: A.zero.__module__ # optional - sage.combinat
'sage.categories.additive_magmas'
- sage: A.zero()
+ sage: A.zero() # optional - sage.combinat
0
TESTS::
- sage: A.zero() is A.a_realization().zero()
+ sage: A.zero() is A.a_realization().zero() # optional - sage.combinat
True
- sage: A._test_zero()
+ sage: A._test_zero() # optional - sage.combinat
"""
return self.a_realization().zero()
diff --git a/src/sage/categories/additive_semigroups.py b/src/sage/categories/additive_semigroups.py
index 0527867154b..667e27eb1e9 100644
--- a/src/sage/categories/additive_semigroups.py
+++ b/src/sage/categories/additive_semigroups.py
@@ -150,9 +150,10 @@ def algebra_generators(self):
EXAMPLES::
sage: S = CommutativeAdditiveSemigroups().example(); S
- An example of a commutative semigroup: the free commutative semigroup generated by ('a', 'b', 'c', 'd')
- sage: A = S.algebra(QQ)
- sage: A.algebra_generators()
+ An example of a commutative semigroup:
+ the free commutative semigroup generated by ('a', 'b', 'c', 'd')
+ sage: A = S.algebra(QQ) # optional - sage.modules
+ sage: A.algebra_generators() # optional - sage.modules
Family (B[a], B[b], B[c], B[d])
"""
return self.basis().keys().additive_semigroup_generators().map(self.monomial)
@@ -169,10 +170,11 @@ def product_on_basis(self, g1, g2):
EXAMPLES::
sage: S = CommutativeAdditiveSemigroups().example(); S
- An example of a commutative semigroup: the free commutative semigroup generated by ('a', 'b', 'c', 'd')
- sage: A = S.algebra(QQ)
- sage: a,b,c,d = A.algebra_generators()
- sage: b * d * c
+ An example of a commutative semigroup:
+ the free commutative semigroup generated by ('a', 'b', 'c', 'd')
+ sage: A = S.algebra(QQ) # optional - sage.modules
+ sage: a, b, c, d = A.algebra_generators() # optional - sage.modules
+ sage: b * d * c # optional - sage.modules
B[b + c + d]
"""
return self.monomial(g1 + g2)
diff --git a/src/sage/categories/affine_weyl_groups.py b/src/sage/categories/affine_weyl_groups.py
index 6bc26562b8e..3df85b07415 100644
--- a/src/sage/categories/affine_weyl_groups.py
+++ b/src/sage/categories/affine_weyl_groups.py
@@ -34,9 +34,9 @@ class AffineWeylGroups(Category_singleton):
sage: C.example()
NotImplemented
- sage: W = WeylGroup(["A",4,1]); W
+ sage: W = WeylGroup(["A", 4, 1]); W # optional - sage.combinat sage.groups
Weyl Group of type ['A', 4, 1] (as a matrix group acting on the root space)
- sage: W.category()
+ sage: W.category() # optional - sage.combinat sage.groups
Category of irreducible affine weyl groups
TESTS::
@@ -81,8 +81,8 @@ def special_node(self):
EXAMPLES::
- sage: W = WeylGroup(['A',3,1])
- sage: W.special_node()
+ sage: W = WeylGroup(['A', 3, 1]) # optional - sage.combinat sage.groups
+ sage: W.special_node() # optional - sage.combinat sage.groups
0
"""
return self.cartan_type().special_node()
@@ -95,8 +95,9 @@ def affine_grassmannian_elements_of_given_length(self, k):
EXAMPLES::
- sage: W = WeylGroup(['A',3,1])
- sage: [x.reduced_word() for x in W.affine_grassmannian_elements_of_given_length(3)]
+ sage: W = WeylGroup(['A', 3, 1]) # optional - sage.combinat sage.groups
+ sage: [x.reduced_word() # optional - sage.combinat sage.groups
+ ....: for x in W.affine_grassmannian_elements_of_given_length(3)]
[[2, 1, 0], [3, 1, 0], [2, 3, 0]]
.. SEEALSO::
@@ -136,14 +137,14 @@ def is_affine_grassmannian(self):
EXAMPLES::
- sage: W = WeylGroup(['A',3,1])
- sage: w = W.from_reduced_word([2,1,0])
- sage: w.is_affine_grassmannian()
+ sage: W = WeylGroup(['A', 3, 1]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([2,1,0]) # optional - sage.combinat sage.groups
+ sage: w.is_affine_grassmannian() # optional - sage.combinat sage.groups
True
- sage: w = W.from_reduced_word([2,0])
- sage: w.is_affine_grassmannian()
+ sage: w = W.from_reduced_word([2,0]) # optional - sage.combinat sage.groups
+ sage: w.is_affine_grassmannian() # optional - sage.combinat sage.groups
False
- sage: W.one().is_affine_grassmannian()
+ sage: W.one().is_affine_grassmannian() # optional - sage.combinat sage.groups
True
"""
D = self.descents()
@@ -168,17 +169,17 @@ def affine_grassmannian_to_core(self):
EXAMPLES::
- sage: W = WeylGroup(['A',2,1])
- sage: w = W.from_reduced_word([0,2,1,0])
- sage: la = w.affine_grassmannian_to_core(); la
+ sage: W = WeylGroup(['A', 2, 1]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([0,2,1,0]) # optional - sage.combinat sage.groups
+ sage: la = w.affine_grassmannian_to_core(); la # optional - sage.combinat sage.groups
[4, 2]
- sage: type(la)
+ sage: type(la) # optional - sage.combinat sage.groups
- sage: la.to_grassmannian() == w
+ sage: la.to_grassmannian() == w # optional - sage.combinat sage.groups
True
- sage: w = W.from_reduced_word([0,2,1])
- sage: w.affine_grassmannian_to_core()
+ sage: w = W.from_reduced_word([0,2,1]) # optional - sage.combinat sage.groups
+ sage: w.affine_grassmannian_to_core() # optional - sage.combinat sage.groups
Traceback (most recent call last):
...
ValueError: this only works on type 'A' affine Grassmannian elements
@@ -214,11 +215,11 @@ def affine_grassmannian_to_partition(self):
EXAMPLES::
sage: k = 2
- sage: W = WeylGroup(['A',k,1])
- sage: w = W.from_reduced_word([0,2,1,0])
- sage: la = w.affine_grassmannian_to_partition(); la
+ sage: W = WeylGroup(['A', k, 1]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([0,2,1,0]) # optional - sage.combinat sage.groups
+ sage: la = w.affine_grassmannian_to_partition(); la # optional - sage.combinat sage.groups
[2, 2]
- sage: la.from_kbounded_to_grassmannian(k) == w
+ sage: la.from_kbounded_to_grassmannian(k) == w # optional - sage.combinat sage.groups
True
"""
return self.affine_grassmannian_to_core().to_bounded_partition()
diff --git a/src/sage/categories/algebra_functor.py b/src/sage/categories/algebra_functor.py
index d2c64474d8e..9142a9b6e38 100644
--- a/src/sage/categories/algebra_functor.py
+++ b/src/sage/categories/algebra_functor.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# sage.doctest: optional - sage.groups
r"""
Group algebras and beyond: the Algebra functorial construction
diff --git a/src/sage/categories/algebra_ideals.py b/src/sage/categories/algebra_ideals.py
index 2beecea2ee4..3bea4f66f91 100644
--- a/src/sage/categories/algebra_ideals.py
+++ b/src/sage/categories/algebra_ideals.py
@@ -79,9 +79,10 @@ def super_categories(self):
EXAMPLES::
sage: AlgebraIdeals(QQ['x']).super_categories()
- [Category of algebra modules over Univariate Polynomial Ring in x over Rational Field]
- sage: C = AlgebraIdeals(FreeAlgebra(QQ,2,'a,b'))
- sage: C.super_categories()
+ [Category of algebra modules
+ over Univariate Polynomial Ring in x over Rational Field]
+ sage: C = AlgebraIdeals(FreeAlgebra(QQ, 2, 'a,b')) # optional - sage.combinat sage.modules
+ sage: C.super_categories() # optional - sage.combinat sage.modules
[]
"""
diff --git a/src/sage/categories/algebra_modules.py b/src/sage/categories/algebra_modules.py
index 46698060095..086b834f955 100644
--- a/src/sage/categories/algebra_modules.py
+++ b/src/sage/categories/algebra_modules.py
@@ -39,7 +39,7 @@ def __init__(self, A):
sage: AlgebraModules(QQ['a'])
Category of algebra modules over Univariate Polynomial Ring in a over Rational Field
sage: AlgebraModules(QQ['a,b']) # todo: not implemented (QQ['a,b'] should be in Algebras(QQ))
- sage: AlgebraModules(FreeAlgebra(QQ,2,'a,b'))
+ sage: AlgebraModules(FreeAlgebra(QQ, 2, 'a,b')) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
TypeError: A (=Free Algebra on 2 generators (a, b) over Rational Field) must be a commutative algebra
diff --git a/src/sage/categories/algebras.py b/src/sage/categories/algebras.py
index 253d64a2819..3b808b5d1b7 100644
--- a/src/sage/categories/algebras.py
+++ b/src/sage/categories/algebras.py
@@ -68,7 +68,7 @@ def __contains__(self, x):
sage: QQ['x'] in Algebras(QQ)
True
- sage: QQ^3 in Algebras(QQ)
+ sage: QQ^3 in Algebras(QQ) # optional - sage.modules
False
sage: QQ['x'] in Algebras(CDF)
False
@@ -154,15 +154,15 @@ def _div_(self, y):
EXAMPLES::
- sage: C = AlgebrasWithBasis(QQ).example()
- sage: x = C(2); x
+ sage: C = AlgebrasWithBasis(QQ).example() # optional - sage.combinat
+ sage: x = C(2); x # optional - sage.combinat
2*B[word: ]
- sage: y = C.algebra_generators().first(); y
+ sage: y = C.algebra_generators().first(); y # optional - sage.combinat
B[word: a]
- sage: y._div_(x)
+ sage: y._div_(x) # optional - sage.combinat
1/2*B[word: a]
- sage: x._div_(y)
+ sage: x._div_(y) # optional - sage.combinat
Traceback (most recent call last):
...
ValueError: cannot invert self (= B[word: a])
diff --git a/src/sage/categories/algebras_with_basis.py b/src/sage/categories/algebras_with_basis.py
index d2296873b59..e7762b50f24 100644
--- a/src/sage/categories/algebras_with_basis.py
+++ b/src/sage/categories/algebras_with_basis.py
@@ -33,35 +33,37 @@ class AlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
We construct a typical parent in this category, and do some
computations with it::
- sage: A = C.example(); A
- An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
+ sage: A = C.example(); A # optional - sage.combinat
+ An example of an algebra with basis:
+ the free algebra on the generators ('a', 'b', 'c') over Rational Field
- sage: A.category()
+ sage: A.category() # optional - sage.combinat
Category of algebras with basis over Rational Field
- sage: A.one_basis()
+ sage: A.one_basis() # optional - sage.combinat
word:
- sage: A.one()
+ sage: A.one() # optional - sage.combinat
B[word: ]
- sage: A.base_ring()
+ sage: A.base_ring() # optional - sage.combinat
Rational Field
- sage: A.basis().keys()
+ sage: A.basis().keys() # optional - sage.combinat
Finite words over {'a', 'b', 'c'}
- sage: (a,b,c) = A.algebra_generators()
- sage: a^3, b^2
+ sage: (a,b,c) = A.algebra_generators() # optional - sage.combinat
+ sage: a^3, b^2 # optional - sage.combinat
(B[word: aaa], B[word: bb])
- sage: a*c*b
+ sage: a * c * b # optional - sage.combinat
B[word: acb]
- sage: A.product
+ sage: A.product # optional - sage.combinat
- sage: A.product(a*b,b)
+ An example of an algebra with basis:
+ the free algebra on the generators ('a', 'b', 'c') over Rational Field>
+ sage: A.product(a * b, b) # optional - sage.combinat
B[word: abb]
- sage: TestSuite(A).run(verbose=True)
+ sage: TestSuite(A).run(verbose=True) # optional - sage.combinat
running ._test_additive_associativity() . . . pass
running ._test_an_element() . . . pass
running ._test_associativity() . . . pass
@@ -91,9 +93,9 @@ class AlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
running ._test_prod() . . . pass
running ._test_some_elements() . . . pass
running ._test_zero() . . . pass
- sage: A.__class__
+ sage: A.__class__ # optional - sage.combinat
- sage: A.element_class
+ sage: A.element_class # optional - sage.combinat
Please see the source code of `A` (with ``A??``) for how to
@@ -110,13 +112,15 @@ def example(self, alphabet=('a','b','c')):
EXAMPLES::
- sage: AlgebrasWithBasis(QQ).example()
- An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
+ sage: AlgebrasWithBasis(QQ).example() # optional - sage.combinat
+ An example of an algebra with basis:
+ the free algebra on the generators ('a', 'b', 'c') over Rational Field
An other set of generators can be specified as optional argument::
- sage: AlgebrasWithBasis(QQ).example((1,2,3))
- An example of an algebra with basis: the free algebra on the generators (1, 2, 3) over Rational Field
+ sage: AlgebrasWithBasis(QQ).example((1,2,3)) # optional - sage.combinat
+ An example of an algebra with basis:
+ the free algebra on the generators (1, 2, 3) over Rational Field
"""
from sage.categories.examples.algebras_with_basis import Example
return Example(self.base_ring(), alphabet)
@@ -143,12 +147,12 @@ def hochschild_complex(self, M):
EXAMPLES::
sage: R. = QQ[]
- sage: A = algebras.DifferentialWeyl(R)
- sage: H = A.hochschild_complex(A)
+ sage: A = algebras.DifferentialWeyl(R) # optional - sage.combinat
+ sage: H = A.hochschild_complex(A) # optional - sage.combinat
- sage: SGA = SymmetricGroupAlgebra(QQ, 3)
- sage: T = SGA.trivial_representation()
- sage: H = SGA.hochschild_complex(T)
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3) # optional - sage.combinat
+ sage: T = SGA.trivial_representation() # optional - sage.combinat
+ sage: H = SGA.hochschild_complex(T) # optional - sage.combinat
"""
from sage.homology.hochschild_complex import HochschildComplex
return HochschildComplex(self, M)
@@ -176,14 +180,14 @@ def __invert__(self):
EXAMPLES::
- sage: C = AlgebrasWithBasis(QQ).example()
- sage: x = C(2); x
+ sage: C = AlgebrasWithBasis(QQ).example() # optional - sage.combinat
+ sage: x = C(2); x # optional - sage.combinat
2*B[word: ]
- sage: ~x
+ sage: ~x # optional - sage.combinat
1/2*B[word: ]
- sage: a = C.algebra_generators().first(); a
+ sage: a = C.algebra_generators().first(); a # optional - sage.combinat
B[word: a]
- sage: ~a
+ sage: ~a # optional - sage.combinat
Traceback (most recent call last):
...
ValueError: cannot invert self (= B[word: a])
@@ -237,18 +241,20 @@ def one_from_cartesian_product_of_one_basis(self):
EXAMPLES::
- sage: A = AlgebrasWithBasis(QQ).example(); A
- An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
- sage: A.one_basis()
+ sage: A = AlgebrasWithBasis(QQ).example(); A # optional - sage.combinat
+ An example of an algebra with basis: the free algebra
+ on the generators ('a', 'b', 'c') over Rational Field
+ sage: A.one_basis() # optional - sage.combinat
word:
- sage: B = cartesian_product((A, A, A))
- sage: B.one_from_cartesian_product_of_one_basis()
+ sage: B = cartesian_product((A, A, A)) # optional - sage.combinat
+ sage: B.one_from_cartesian_product_of_one_basis() # optional - sage.combinat
B[(0, word: )] + B[(1, word: )] + B[(2, word: )]
- sage: B.one()
+ sage: B.one() # optional - sage.combinat
B[(0, word: )] + B[(1, word: )] + B[(2, word: )]
- sage: cartesian_product([SymmetricGroupAlgebra(QQ, 3), SymmetricGroupAlgebra(QQ, 4)]).one()
+ sage: cartesian_product([SymmetricGroupAlgebra(QQ, 3), # optional - sage.combinat
+ ....: SymmetricGroupAlgebra(QQ, 4)]).one()
B[(0, [1, 2, 3])] + B[(1, [1, 2, 3, 4])]
"""
return self.sum_of_monomials( zip( self._sets_keys(), (set.one_basis() for set in self._sets)) )
@@ -258,10 +264,11 @@ def one(self):
"""
TESTS::
- sage: A = AlgebrasWithBasis(QQ).example(); A
- An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
- sage: B = cartesian_product((A, A, A))
- sage: B.one()
+ sage: A = AlgebrasWithBasis(QQ).example(); A # optional - sage.combinat
+ An example of an algebra with basis: the free algebra
+ on the generators ('a', 'b', 'c') over Rational Field
+ sage: B = cartesian_product((A, A, A)) # optional - sage.combinat
+ sage: B.one() # optional - sage.combinat
B[(0, word: )] + B[(1, word: )] + B[(2, word: )]
"""
if all(hasattr(module, "one_basis") for module in self._sets):
@@ -310,14 +317,15 @@ def one_basis(self):
EXAMPLES::
- sage: A = AlgebrasWithBasis(QQ).example(); A
- An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
- sage: A.one_basis()
+ sage: A = AlgebrasWithBasis(QQ).example(); A # optional - sage.combinat
+ An example of an algebra with basis: the free algebra
+ on the generators ('a', 'b', 'c') over Rational Field
+ sage: A.one_basis() # optional - sage.combinat
word:
- sage: B = tensor((A, A, A))
- sage: B.one_basis()
+ sage: B = tensor((A, A, A)) # optional - sage.combinat
+ sage: B.one_basis() # optional - sage.combinat
(word: , word: , word: )
- sage: B.one()
+ sage: B.one() # optional - sage.combinat
B[word: ] # B[word: ] # B[word: ]
"""
# FIXME: this method should be conditionally defined,
@@ -335,23 +343,25 @@ def product_on_basis(self, t1, t2):
EXAMPLES::
- sage: A = AlgebrasWithBasis(QQ).example(); A
- An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
- sage: (a,b,c) = A.algebra_generators()
+ sage: A = AlgebrasWithBasis(QQ).example(); A # optional - sage.combinat
+ An example of an algebra with basis: the free algebra
+ on the generators ('a', 'b', 'c') over Rational Field
+ sage: (a,b,c) = A.algebra_generators() # optional - sage.combinat
- sage: x = tensor( (a, b, c) ); x
+ sage: x = tensor((a, b, c)); x # optional - sage.combinat
B[word: a] # B[word: b] # B[word: c]
- sage: y = tensor( (c, b, a) ); y
+ sage: y = tensor((c, b, a)); y # optional - sage.combinat
B[word: c] # B[word: b] # B[word: a]
- sage: x*y
+ sage: x * y # optional - sage.combinat
B[word: ac] # B[word: bb] # B[word: ca]
- sage: x = tensor( ((a+2*b), c) ) ; x
+ sage: x = tensor(((a + 2*b), c)); x # optional - sage.combinat
B[word: a] # B[word: c] + 2*B[word: b] # B[word: c]
- sage: y = tensor( (c, a) ) + 1; y
+ sage: y = tensor((c, a)) + 1; y # optional - sage.combinat
B[word: ] # B[word: ] + B[word: c] # B[word: a]
- sage: x*y
- B[word: a] # B[word: c] + B[word: ac] # B[word: ca] + 2*B[word: b] # B[word: c] + 2*B[word: bc] # B[word: ca]
+ sage: x * y # optional - sage.combinat
+ B[word: a] # B[word: c] + B[word: ac] # B[word: ca]
+ + 2*B[word: b] # B[word: c] + 2*B[word: bc] # B[word: ca]
TODO: optimize this implementation!
diff --git a/src/sage/categories/bialgebras.py b/src/sage/categories/bialgebras.py
index 441d924c964..fa6a7a1a507 100644
--- a/src/sage/categories/bialgebras.py
+++ b/src/sage/categories/bialgebras.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat
r"""
Bialgebras
"""
diff --git a/src/sage/categories/bialgebras_with_basis.py b/src/sage/categories/bialgebras_with_basis.py
index 831bab3f068..067d0b35b8e 100644
--- a/src/sage/categories/bialgebras_with_basis.py
+++ b/src/sage/categories/bialgebras_with_basis.py
@@ -92,32 +92,33 @@ def convolution_product(self, *maps):
with the projection ``Proj2`` on the Hopf algebra of
non-commutative symmetric functions::
- sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon()
- sage: T = R.convolution_product([Id, Id])
- sage: [T(R(comp)) for comp in Compositions(3)]
+ sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon() # optional - sage.combinat
+ sage: T = R.convolution_product([Id, Id]) # optional - sage.combinat
+ sage: [T(R(comp)) for comp in Compositions(3)] # optional - sage.combinat
[4*R[1, 1, 1] + R[1, 2] + R[2, 1],
2*R[1, 1, 1] + 4*R[1, 2] + 2*R[2, 1] + 2*R[3],
2*R[1, 1, 1] + 2*R[1, 2] + 4*R[2, 1] + 2*R[3],
R[1, 2] + R[2, 1] + 4*R[3]]
- sage: T = R.convolution_product(Proj2, Id)
- sage: [T(R([i])) for i in range(1, 5)]
+ sage: T = R.convolution_product(Proj2, Id) # optional - sage.combinat
+ sage: [T(R([i])) for i in range(1, 5)] # optional - sage.combinat
[0, R[2], R[2, 1] + R[3], R[2, 2] + R[4]]
Compute the convolution product of no maps on the Hopf algebra of
symmetric functions in non-commuting variables. This is the
composition of the counit with the unit::
- sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m()
- sage: T = m.convolution_product()
- sage: [T(m(lam)) for lam in SetPartitions(0).list() + SetPartitions(2).list()]
+ sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m() # optional - sage.combinat
+ sage: T = m.convolution_product() # optional - sage.combinat
+ sage: [T(m(lam)) # optional - sage.combinat
+ ....: for lam in SetPartitions(0).list() + SetPartitions(2).list()]
[m{}, 0, 0]
Compute the convolution product of the projection ``Proj2`` with
the identity on the Hopf algebra of symmetric functions in
non-commuting variables::
- sage: T = m.convolution_product(Proj2, Id)
- sage: [T(m(lam)) for lam in SetPartitions(3)]
+ sage: T = m.convolution_product(Proj2, Id) # optional - sage.combinat
+ sage: [T(m(lam)) for lam in SetPartitions(3)] # optional - sage.combinat
[0,
m{{1, 2}, {3}} + m{{1, 2, 3}},
m{{1, 2}, {3}} + m{{1, 2, 3}},
@@ -127,12 +128,15 @@ def convolution_product(self, *maps):
Compute the convolution product of the antipode with itself and the
identity map on group algebra of the symmetric group::
- sage: G = SymmetricGroup(3)
- sage: QG = GroupAlgebra(G, QQ)
- sage: x = QG.sum_of_terms([(p,p.number_of_peaks() + p.number_of_inversions()) for p in Permutations(3)]); x
+ sage: G = SymmetricGroup(3) # optional - sage.groups sage.combinat
+ sage: QG = GroupAlgebra(G, QQ) # optional - sage.groups sage.combinat
+ sage: x = QG.sum_of_terms( # optional - sage.groups sage.combinat
+ ....: [(p, p.number_of_peaks() + p.number_of_inversions())
+ ....: for p in Permutations(3)]
+ ....: ); x
2*[1, 3, 2] + [2, 1, 3] + 3*[2, 3, 1] + 2*[3, 1, 2] + 3*[3, 2, 1]
- sage: T = QG.convolution_product(Antipode, Antipode, Id)
- sage: T(x)
+ sage: T = QG.convolution_product(Antipode, Antipode, Id) # optional - sage.groups sage.combinat
+ sage: T(x) # optional - sage.groups sage.combinat
2*[1, 3, 2] + [2, 1, 3] + 2*[2, 3, 1] + 3*[3, 1, 2] + 3*[3, 2, 1]
"""
onbasis = lambda x: self.term(x).convolution_product(*maps)
@@ -168,31 +172,32 @@ def adams_operator(self, n):
EXAMPLES::
- sage: h = SymmetricFunctions(QQ).h()
- sage: h[5].adams_operator(2)
+ sage: h = SymmetricFunctions(QQ).h() # optional - sage.combinat
+ sage: h[5].adams_operator(2) # optional - sage.combinat
2*h[3, 2] + 2*h[4, 1] + 2*h[5]
- sage: h[5].plethysm(2*h[1])
+ sage: h[5].plethysm(2*h[1]) # optional - sage.combinat
2*h[3, 2] + 2*h[4, 1] + 2*h[5]
- sage: h([]).adams_operator(0)
+ sage: h([]).adams_operator(0) # optional - sage.combinat
h[]
- sage: h([]).adams_operator(1)
+ sage: h([]).adams_operator(1) # optional - sage.combinat
h[]
- sage: h[3,2].adams_operator(0)
+ sage: h[3,2].adams_operator(0) # optional - sage.combinat
0
- sage: h[3,2].adams_operator(1)
+ sage: h[3,2].adams_operator(1) # optional - sage.combinat
h[3, 2]
::
- sage: S = NonCommutativeSymmetricFunctions(QQ).S()
- sage: S[4].adams_operator(5)
- 5*S[1, 1, 1, 1] + 10*S[1, 1, 2] + 10*S[1, 2, 1] + 10*S[1, 3] + 10*S[2, 1, 1] + 10*S[2, 2] + 10*S[3, 1] + 5*S[4]
+ sage: S = NonCommutativeSymmetricFunctions(QQ).S() # optional - sage.combinat
+ sage: S[4].adams_operator(5) # optional - sage.combinat
+ 5*S[1, 1, 1, 1] + 10*S[1, 1, 2] + 10*S[1, 2, 1]
+ + 10*S[1, 3] + 10*S[2, 1, 1] + 10*S[2, 2] + 10*S[3, 1] + 5*S[4]
::
- sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m()
- sage: m[[1,3],[2]].adams_operator(-2)
+ sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m() # optional - sage.combinat
+ sage: m[[1,3],[2]].adams_operator(-2) # optional - sage.combinat
3*m{{1}, {2, 3}} + 3*m{{1, 2}, {3}} + 6*m{{1, 2, 3}} - 2*m{{1, 3}, {2}}
"""
if n < 0:
@@ -254,18 +259,18 @@ def convolution_product(self, *maps):
sage: Id = lambda x: x
sage: Antipode = lambda x: x.antipode()
- sage: s = SymmetricFunctions(QQ).schur()
- sage: s[3].convolution_product(Id, Id)
+ sage: s = SymmetricFunctions(QQ).schur() # optional - sage.combinat
+ sage: s[3].convolution_product(Id, Id) # optional - sage.combinat
2*s[2, 1] + 4*s[3]
- sage: s[3,2].convolution_product(Id) == s[3,2]
+ sage: s[3,2].convolution_product(Id) == s[3,2] # optional - sage.combinat
True
The method accepts multiple arguments, or a single argument
consisting of a list of maps::
- sage: s[3,2].convolution_product(Id, Id)
+ sage: s[3,2].convolution_product(Id, Id) # optional - sage.combinat
2*s[2, 1, 1, 1] + 6*s[2, 2, 1] + 6*s[3, 1, 1] + 12*s[3, 2] + 6*s[4, 1] + 2*s[5]
- sage: s[3,2].convolution_product([Id, Id])
+ sage: s[3,2].convolution_product([Id, Id]) # optional - sage.combinat
2*s[2, 1, 1, 1] + 6*s[2, 2, 1] + 6*s[3, 1, 1] + 12*s[3, 2] + 6*s[4, 1] + 2*s[5]
We test the defining property of the antipode morphism; namely,
@@ -273,28 +278,31 @@ def convolution_product(self, *maps):
convolution algebra whose identity element is the composition of
the counit and unit::
- sage: s[3,2].convolution_product() == s[3,2].convolution_product(Antipode, Id) == s[3,2].convolution_product(Id, Antipode)
+ sage: (s[3,2].convolution_product() # optional - sage.combinat
+ ....: == s[3,2].convolution_product(Antipode, Id)
+ ....: == s[3,2].convolution_product(Id, Antipode))
True
::
- sage: Psi = NonCommutativeSymmetricFunctions(QQ).Psi()
- sage: Psi[2,1].convolution_product(Id, Id, Id)
+ sage: Psi = NonCommutativeSymmetricFunctions(QQ).Psi() # optional - sage.combinat
+ sage: Psi[2,1].convolution_product(Id, Id, Id) # optional - sage.combinat
3*Psi[1, 2] + 6*Psi[2, 1]
- sage: (Psi[5,1] - Psi[1,5]).convolution_product(Id, Id, Id)
+ sage: (Psi[5,1] - Psi[1,5]).convolution_product(Id, Id, Id) # optional - sage.combinat
-3*Psi[1, 5] + 3*Psi[5, 1]
::
- sage: G = SymmetricGroup(3)
- sage: QG = GroupAlgebra(G,QQ)
- sage: x = QG.sum_of_terms([(p,p.length()) for p in Permutations(3)]); x
+ sage: G = SymmetricGroup(3) # optional - sage.combinat
+ sage: QG = GroupAlgebra(G, QQ) # optional - sage.combinat
+ sage: x = QG.sum_of_terms([(p, p.length()) # optional - sage.combinat
+ ....: for p in Permutations(3)]); x
[1, 3, 2] + [2, 1, 3] + 2*[2, 3, 1] + 2*[3, 1, 2] + 3*[3, 2, 1]
- sage: x.convolution_product(Id, Id)
+ sage: x.convolution_product(Id, Id) # optional - sage.combinat
5*[1, 2, 3] + 2*[2, 3, 1] + 2*[3, 1, 2]
- sage: x.convolution_product(Id, Id, Id)
+ sage: x.convolution_product(Id, Id, Id) # optional - sage.combinat
4*[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + 3*[3, 2, 1]
- sage: x.convolution_product([Id]*6)
+ sage: x.convolution_product([Id] * 6) # optional - sage.combinat
9*[1, 2, 3]
TESTS::
@@ -304,57 +312,60 @@ def convolution_product(self, *maps):
::
- sage: h = SymmetricFunctions(QQ).h()
- sage: h[5].convolution_product([Id, Id])
+ sage: h = SymmetricFunctions(QQ).h() # optional - sage.combinat
+ sage: h[5].convolution_product([Id, Id]) # optional - sage.combinat
2*h[3, 2] + 2*h[4, 1] + 2*h[5]
- sage: h.one().convolution_product([Id, Antipode])
+ sage: h.one().convolution_product([Id, Antipode]) # optional - sage.combinat
h[]
- sage: h[3,2].convolution_product([Id, Antipode])
+ sage: h[3,2].convolution_product([Id, Antipode]) # optional - sage.combinat
0
- sage: h.one().convolution_product([Id, Antipode]) == h.one().convolution_product()
+ sage: (h.one().convolution_product([Id, Antipode]) # optional - sage.combinat
+ ....: == h.one().convolution_product())
True
::
- sage: S = NonCommutativeSymmetricFunctions(QQ).S()
- sage: S[4].convolution_product([Id]*5)
+ sage: S = NonCommutativeSymmetricFunctions(QQ).S() # optional - sage.combinat
+ sage: S[4].convolution_product([Id] * 5) # optional - sage.combinat
5*S[1, 1, 1, 1] + 10*S[1, 1, 2] + 10*S[1, 2, 1] + 10*S[1, 3]
+ 10*S[2, 1, 1] + 10*S[2, 2] + 10*S[3, 1] + 5*S[4]
::
- sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m()
- sage: m[[1,3],[2]].convolution_product([Antipode, Antipode])
+ sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m() # optional - sage.combinat
+ sage: m[[1,3],[2]].convolution_product([Antipode, Antipode]) # optional - sage.combinat
3*m{{1}, {2, 3}} + 3*m{{1, 2}, {3}} + 6*m{{1, 2, 3}} - 2*m{{1, 3}, {2}}
- sage: m[[]].convolution_product([])
+ sage: m[[]].convolution_product([]) # optional - sage.combinat
m{}
- sage: m[[1,3],[2]].convolution_product([])
+ sage: m[[1,3],[2]].convolution_product([]) # optional - sage.combinat
0
::
- sage: QS = SymmetricGroupAlgebra(QQ, 5)
- sage: x = QS.sum_of_terms(zip(Permutations(5)[3:6],[1,2,3])); x
+ sage: QS = SymmetricGroupAlgebra(QQ, 5) # optional - sage.combinat
+ sage: x = QS.sum_of_terms(zip(Permutations(5)[3:6], [1,2,3])); x # optional - sage.combinat
[1, 2, 4, 5, 3] + 2*[1, 2, 5, 3, 4] + 3*[1, 2, 5, 4, 3]
- sage: x.convolution_product([Antipode, Id])
+ sage: x.convolution_product([Antipode, Id]) # optional - sage.combinat
6*[1, 2, 3, 4, 5]
- sage: x.convolution_product(Id, Antipode, Antipode, Antipode)
+ sage: x.convolution_product(Id, Antipode, Antipode, Antipode) # optional - sage.combinat
3*[1, 2, 3, 4, 5] + [1, 2, 4, 5, 3] + 2*[1, 2, 5, 3, 4]
::
- sage: G = SymmetricGroup(3)
- sage: QG = GroupAlgebra(G,QQ)
- sage: x = QG.sum_of_terms([(p,p.length()) for p in Permutations(3)]); x
+ sage: G = SymmetricGroup(3) # optional - sage.combinat
+ sage: QG = GroupAlgebra(G, QQ) # optional - sage.combinat
+ sage: x = QG.sum_of_terms([(p, p.length()) # optional - sage.combinat
+ ....: for p in Permutations(3)]); x
[1, 3, 2] + [2, 1, 3] + 2*[2, 3, 1] + 2*[3, 1, 2] + 3*[3, 2, 1]
- sage: x.convolution_product(Antipode, Id)
+ sage: x.convolution_product(Antipode, Id) # optional - sage.combinat
9*[1, 2, 3]
- sage: x.convolution_product([Id, Antipode, Antipode, Antipode])
+ sage: x.convolution_product([Id, Antipode, Antipode, Antipode]) # optional - sage.combinat
5*[1, 2, 3] + 2*[2, 3, 1] + 2*[3, 1, 2]
::
- sage: s[3,2].counit().parent() == s[3,2].convolution_product().parent()
+ sage: (s[3,2].counit().parent() # optional - sage.combinat
+ ....: == s[3,2].convolution_product().parent())
False
"""
# Be flexible on how the maps are entered: accept a list/tuple of
diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
index fe5e22cffd9..83e88ef748a 100644
--- a/src/sage/categories/category.py
+++ b/src/sage/categories/category.py
@@ -22,48 +22,49 @@
sage: Sets()
Category of sets
- sage: GSets(AbelianGroup([2,4,9]))
+ sage: GSets(AbelianGroup([2, 4, 9])) # optional - sage.groups
Category of G-sets for Multiplicative Abelian group isomorphic to C2 x C4 x C9
sage: Semigroups()
Category of semigroups
- sage: VectorSpaces(FiniteField(11))
+ sage: VectorSpaces(FiniteField(11)) # optional - sage.rings.finite_rings
Category of vector spaces over Finite Field of size 11
sage: Ideals(IntegerRing())
Category of ring ideals in Integer Ring
Let's request the category of some objects::
- sage: V = VectorSpace(RationalField(), 3)
- sage: V.category()
+ sage: V = VectorSpace(RationalField(), 3) # optional - sage.modules
+ sage: V.category() # optional - sage.modules
Category of finite dimensional vector spaces with basis
over (number fields and quotient fields and metric spaces)
- sage: G = SymmetricGroup(9)
- sage: G.category()
- Join of Category of finite enumerated permutation groups and
- Category of finite weyl groups and
- Category of well generated finite irreducible complex reflection groups
+ sage: G = SymmetricGroup(9) # optional - sage.groups
+ sage: G.category() # optional - sage.groups
+ Join of
+ Category of finite enumerated permutation groups and
+ Category of finite weyl groups and
+ Category of well generated finite irreducible complex reflection groups
- sage: P = PerfectMatchings(3)
- sage: P.category()
+ sage: P = PerfectMatchings(3) # optional - sage.combinat sage.graphs
+ sage: P.category() # optional - sage.combinat sage.graphs
Category of finite enumerated sets
Let's check some memberships::
- sage: V in VectorSpaces(QQ)
+ sage: V in VectorSpaces(QQ) # optional - sage.modules
True
- sage: V in VectorSpaces(FiniteField(11))
+ sage: V in VectorSpaces(FiniteField(11)) # optional - sage.modules sage.rings.finite_rings
False
- sage: G in Monoids()
+ sage: G in Monoids() # optional - sage.groups
True
- sage: P in Rings()
+ sage: P in Rings() # optional - sage.combinat sage.graphs
False
For parametrized categories one can use the following shorthand::
- sage: V in VectorSpaces
+ sage: V in VectorSpaces # optional - sage.modules
True
- sage: G in VectorSpaces
+ sage: G in VectorSpaces # optional - sage.groups
False
A parent ``P`` is in a category ``C`` if ``P.category()`` is a subcategory of
@@ -83,11 +84,11 @@
True
By default, the category of an element `x` of a parent `P` is the category
- of all objects of `P` (this is dubious an may be deprecated)::
+ of all objects of `P` (this is dubious and may be deprecated)::
- sage: V = VectorSpace(RationalField(), 3)
- sage: v = V.gen(1)
- sage: v.category()
+ sage: V = VectorSpace(RationalField(), 3) # optional - sage.modules
+ sage: v = V.gen(1) # optional - sage.modules
+ sage: v.category() # optional - sage.modules
Category of elements of Vector space of dimension 3 over Rational Field
"""
@@ -308,7 +309,8 @@ class inheritance from ``C.parent_class``.
sage: Ds().parent_class.__bases__
(, )
sage: Ds().parent_class.mro()
- [, , , , <... 'object'>]
+ [, ,
+ , , <... 'object'>]
Note that two categories in the same class need not have the
same ``super_categories``. For example, ``Algebras(QQ)`` has
@@ -325,7 +327,7 @@ class inheritance from ``C.parent_class``.
On the other hand, identical hierarchies of classes are,
preferably, built only once (e.g. for categories over a base ring)::
- sage: Algebras(GF(5)).parent_class is Algebras(GF(7)).parent_class
+ sage: Algebras(GF(5)).parent_class is Algebras(GF(7)).parent_class # optional - sage.rings.finite_rings
True
sage: F = FractionField(ZZ['t'])
sage: Coalgebras(F).parent_class is Coalgebras(FractionField(F['x'])).parent_class
@@ -565,9 +567,11 @@ def an_instance(cls):
sage: Algebras.an_instance()
Category of algebras over Rational Field
sage: Bimodules.an_instance()
- Category of bimodules over Rational Field on the left and Real Field with 53 bits of precision on the right
+ Category of bimodules over Rational Field on the left
+ and Real Field with 53 bits of precision on the right
sage: AlgebraIdeals.an_instance()
- Category of algebra ideals in Univariate Polynomial Ring in x over Rational Field
+ Category of algebra ideals
+ in Univariate Polynomial Ring in x over Rational Field
"""
return cls()
@@ -724,15 +728,15 @@ def __classcontains__(cls, x):
This method makes it easy to test if an object is, say, a
vector space, without having to specify the base ring::
- sage: F = FreeModule(QQ,3)
- sage: F in VectorSpaces
+ sage: F = FreeModule(QQ, 3) # optional - sage.modules
+ sage: F in VectorSpaces # optional - sage.modules
True
- sage: F = FreeModule(ZZ,3)
- sage: F in VectorSpaces
+ sage: F = FreeModule(ZZ, 3) # optional - sage.modules
+ sage: F in VectorSpaces # optional - sage.modules
False
- sage: F in Algebras
+ sage: F in Algebras # optional - sage.modules
False
TESTS:
@@ -798,14 +802,14 @@ def category_graph(self):
EXAMPLES::
sage: C = Algebras(QQ)
- sage: G = C.category_graph()
- sage: G.is_directed_acyclic()
+ sage: G = C.category_graph() # optional - sage.graphs
+ sage: G.is_directed_acyclic() # optional - sage.graphs
True
The girth of a directed acyclic graph is infinite, however,
the girth of the underlying undirected graph is 4 in this case::
- sage: Graph(G).girth()
+ sage: Graph(G).girth() # optional - sage.graphs
4
"""
return category_graph([self])
@@ -928,8 +932,8 @@ def _set_of_super_categories(self):
TESTS::
- sage: C = HopfAlgebrasWithBasis(GF(7))
- sage: C._set_of_super_categories == frozenset(C._all_super_categories_proper)
+ sage: C = HopfAlgebrasWithBasis(GF(7)) # optional - sage.rings.finite_rings
+ sage: C._set_of_super_categories == set(C._all_super_categories_proper) # optional - sage.rings.finite_rings
True
"""
return frozenset(self._all_super_categories_proper)
@@ -1669,7 +1673,7 @@ def parent_class(self):
the category of algebras over a finite field versus algebras
over a non-field::
- sage: Algebras(GF(7)).parent_class is Algebras(GF(5)).parent_class
+ sage: Algebras(GF(7)).parent_class is Algebras(GF(5)).parent_class # optional - sage.rings.finite_rings
True
sage: Algebras(QQ).parent_class is Algebras(ZZ).parent_class
False
@@ -1714,7 +1718,7 @@ def element_class(self):
category of algebras over a field versus algebras over a
non-field::
- sage: Algebras(GF(5)).element_class is Algebras(GF(3)).element_class
+ sage: Algebras(GF(5)).element_class is Algebras(GF(3)).element_class # optional - sage.rings.finite_rings
True
sage: Algebras(QQ).element_class is Algebras(ZZ).element_class
False
@@ -1788,9 +1792,9 @@ def is_subcategory(self, c):
::
- sage: M3 = VectorSpaces(FiniteField(3))
- sage: M9 = VectorSpaces(FiniteField(9, 'a'))
- sage: M3.is_subcategory(M9)
+ sage: M3 = VectorSpaces(FiniteField(3)) # optional - sage.rings.finite_rings sage.modules
+ sage: M9 = VectorSpaces(FiniteField(9, 'a')) # optional - sage.rings.finite_rings sage.modules
+ sage: M3.is_subcategory(M9) # optional - sage.rings.finite_rings sage.modules
False
Join categories are properly handled::
@@ -1801,16 +1805,16 @@ def is_subcategory(self, c):
::
- sage: V3 = VectorSpaces(FiniteField(3))
+ sage: V3 = VectorSpaces(FiniteField(3)) # optional - sage.rings.finite_rings
sage: POSet = PartiallyOrderedSets()
- sage: PoV3 = Category.join((V3, POSet))
- sage: A3 = AlgebrasWithBasis(FiniteField(3))
- sage: PoA3 = Category.join((A3, POSet))
- sage: PoA3.is_subcategory(PoV3)
+ sage: PoV3 = Category.join((V3, POSet)) # optional - sage.rings.finite_rings
+ sage: A3 = AlgebrasWithBasis(FiniteField(3)) # optional - sage.rings.finite_rings
+ sage: PoA3 = Category.join((A3, POSet)) # optional - sage.rings.finite_rings
+ sage: PoA3.is_subcategory(PoV3) # optional - sage.rings.finite_rings
True
- sage: PoV3.is_subcategory(PoV3)
+ sage: PoV3.is_subcategory(PoV3) # optional - sage.rings.finite_rings
True
- sage: PoV3.is_subcategory(PoA3)
+ sage: PoV3.is_subcategory(PoA3) # optional - sage.rings.finite_rings
False
"""
if c is self:
@@ -1852,7 +1856,8 @@ def or_subcategory(self, category=None, join=False):
sage: Monoids().or_subcategory(EnumeratedSets())
Traceback (most recent call last):
...
- ValueError: Subcategory of `Category of monoids` required; got `Category of enumerated sets`
+ ValueError: Subcategory of `Category of monoids` required;
+ got `Category of enumerated sets`
Otherwise, the two categories are joined together::
@@ -2077,7 +2082,8 @@ def _with_axiom(self, axiom):
sage: Magmas().Finite().Commutative().super_categories()
[Category of commutative magmas, Category of finite sets]
- sage: Algebras(QQ).WithBasis().Commutative() is Algebras(QQ).Commutative().WithBasis()
+ sage: C = Algebras(QQ).WithBasis().Commutative()
+ sage: C is Algebras(QQ).Commutative().WithBasis()
True
When ``axiom`` is not defined for ``self``, ``self`` is returned::
@@ -2252,7 +2258,9 @@ def _sort(categories):
Category of commutative magmas,
Category of finite sets,
Category of facade sets)
- sage: Category._sort(Category._flatten_categories([Sets().Finite(), Algebras(QQ).WithBasis(), Semigroups().Finite(), Sets().Facade(),Algebras(QQ).Commutative(), Algebras(QQ).Graded().WithBasis()], sage.categories.category.JoinCategory))
+ sage: Category._sort(Category._flatten_categories([Sets().Finite(), Algebras(QQ).WithBasis(), Semigroups().Finite(),
+ ....: Sets().Facade(), Algebras(QQ).Commutative(), Algebras(QQ).Graded().WithBasis()],
+ ....: sage.categories.category.JoinCategory))
(Category of algebras with basis over Rational Field,
Category of algebras with basis over Rational Field,
Category of graded algebras over Rational Field,
@@ -2597,7 +2605,7 @@ def category_sample():
EXAMPLES::
sage: from sage.categories.category import category_sample
- sage: sorted(category_sample(), key=str)
+ sage: sorted(category_sample(), key=str) # optional - sage.groups
[Category of G-sets for Symmetric group of order 8! as a permutation group,
Category of Hecke modules over Rational Field,
Category of Lie algebras over Rational Field,
@@ -2636,14 +2644,14 @@ def category_graph(categories=None):
EXAMPLES::
- sage: G = sage.categories.category.category_graph(categories = [Groups()])
- sage: G.vertices(sort=True)
+ sage: G = sage.categories.category.category_graph(categories=[Groups()]) # optional - sage.graphs
+ sage: G.vertices(sort=True) # optional - sage.graphs
['groups', 'inverse unital magmas', 'magmas', 'monoids', 'objects',
'semigroups', 'sets', 'sets with partial maps', 'unital magmas']
- sage: G.plot()
+ sage: G.plot() # optional - sage.graphs sage.plot
Graphics object consisting of 20 graphics primitives
- sage: sage.categories.category.category_graph().plot()
+ sage: sage.categories.category.category_graph().plot() # optional - sage.graphs sage.plot
Graphics object consisting of ... graphics primitives
"""
from sage import graphs
@@ -2691,15 +2699,15 @@ class CategoryWithParameters(Category):
EXAMPLES::
- sage: C1 = Algebras(GF(5))
- sage: C2 = Algebras(GF(3))
+ sage: C1 = Algebras(GF(5)) # optional - sage.rings.finite_rings
+ sage: C2 = Algebras(GF(3)) # optional - sage.rings.finite_rings
sage: C3 = Algebras(ZZ)
sage: from sage.categories.category import CategoryWithParameters
- sage: isinstance(C1, CategoryWithParameters)
+ sage: isinstance(C1, CategoryWithParameters) # optional - sage.rings.finite_rings
True
- sage: C1.parent_class is C2.parent_class
+ sage: C1.parent_class is C2.parent_class # optional - sage.rings.finite_rings
True
- sage: C1.parent_class is C3.parent_class
+ sage: C1.parent_class is C3.parent_class # optional - sage.rings.finite_rings
False
.. automethod:: Category._make_named_class
@@ -2744,7 +2752,7 @@ def _make_named_class(self, name, method_provider, cache=False, **options):
The categories of bimodules over the fields ``CC`` or ``RR``
provide the same methods to their parents and elements::
- sage: Bimodules(ZZ,RR).parent_class is Bimodules(ZZ,RDF).parent_class #indirect doctest
+ sage: Bimodules(ZZ,RR).parent_class is Bimodules(ZZ,RDF).parent_class # indirect doctest
True
sage: Bimodules(CC,ZZ).element_class is Bimodules(RR,ZZ).element_class
True
@@ -2918,12 +2926,12 @@ class JoinCategory(CategoryWithParameters):
the underlying implementation is the same for all finite fields,
we have::
- sage: G = SymmetricGroup(10)
- sage: A3 = G.algebra(GF(3))
- sage: A5 = G.algebra(GF(5))
- sage: type(A3.category())
+ sage: G = SymmetricGroup(10) # optional - sage.groups sage.rings.finite_rings
+ sage: A3 = G.algebra(GF(3)) # optional - sage.groups sage.rings.finite_rings
+ sage: A5 = G.algebra(GF(5)) # optional - sage.groups sage.rings.finite_rings
+ sage: type(A3.category()) # optional - sage.groups sage.rings.finite_rings
- sage: type(A3) is type(A5)
+ sage: type(A3) is type(A5) # optional - sage.groups sage.rings.finite_rings
True
.. automethod:: Category._repr_object_names
diff --git a/src/sage/categories/category_types.py b/src/sage/categories/category_types.py
index 4469a57a996..ef0fb9472bb 100644
--- a/src/sage/categories/category_types.py
+++ b/src/sage/categories/category_types.py
@@ -72,14 +72,14 @@ def _call_(self, x):
"""
EXAMPLES::
- sage: V = VectorSpace(QQ,3)
- sage: x = V.0
- sage: C = x.category()
- sage: C
+ sage: V = VectorSpace(QQ, 3) # optional - sage.modules
+ sage: x = V.0 # optional - sage.modules
+ sage: C = x.category() # optional - sage.modules
+ sage: C # optional - sage.modules
Category of elements of Vector space of dimension 3 over Rational Field
- sage: w = C([1,2,3]); w # indirect doctest
+ sage: w = C([1, 2, 3]); w # indirect doctest # optional - sage.modules
(1, 2, 3)
- sage: w.category()
+ sage: w.category() # optional - sage.modules
Category of elements of Vector space of dimension 3 over Rational Field
"""
return self.__object(x)
@@ -129,9 +129,9 @@ def _latex_(self):
r"""
EXAMPLES::
- sage: V = VectorSpace(QQ,3)
- sage: x = V.0
- sage: latex(x.category()) # indirect doctest
+ sage: V = VectorSpace(QQ, 3) # optional - sage.modules
+ sage: x = V.0 # optional - sage.modules
+ sage: latex(x.category()) # indirect doctest # optional - sage.modules
\mathbf{Elt}_{\Bold{Q}^{3}}
"""
return "\\mathbf{Elt}_{%s}"%latex(self.__object)
@@ -153,11 +153,11 @@ class Category_over_base(CategoryWithParameters):
EXAMPLES::
- sage: Algebras(GF(2)).element_class is Algebras(GF(3)).element_class
+ sage: Algebras(GF(2)).element_class is Algebras(GF(3)).element_class # optional - sage.rings.finite_rings
True
- sage: C = GF(2).category()
- sage: Algebras(GF(2)).parent_class is Algebras(C).parent_class
+ sage: C = GF(2).category() # optional - sage.rings.finite_rings
+ sage: Algebras(GF(2)).parent_class is Algebras(C).parent_class # optional - sage.rings.finite_rings
True
sage: C = ZZ.category()
@@ -278,7 +278,7 @@ def _repr_object_names(self):
'algebras over Rational Field'
sage: Algebras(Fields())._repr_object_names()
'algebras over fields'
- sage: Algebras(GF(2).category())._repr_object_names()
+ sage: Algebras(GF(2).category())._repr_object_names() # optional - sage.rings.finite_rings
'algebras over (finite enumerated fields and subquotients of monoids and quotients of semigroups)'
"""
base = self.__base
@@ -338,9 +338,9 @@ def __init__(self, base, name=None):
EXAMPLES::
- sage: C = Algebras(GF(2)); C
+ sage: C = Algebras(GF(2)); C # optional - sage.rings.finite_rings
Category of algebras over Finite Field of size 2
- sage: TestSuite(C).run()
+ sage: TestSuite(C).run() # optional - sage.rings.finite_rings
"""
from sage.categories.rings import Rings
if not (base in Rings() or
@@ -355,8 +355,8 @@ def base_ring(self):
EXAMPLES::
- sage: C = Algebras(GF(2))
- sage: C.base_ring()
+ sage: C = Algebras(GF(2)) # optional - sage.rings.finite_rings
+ sage: C.base_ring() # optional - sage.rings.finite_rings
Finite Field of size 2
"""
return self.base()
@@ -399,11 +399,11 @@ def _subcategory_hook_(self, C):
sage: VectorSpaces(QQ)._subcategory_hook_(VectorSpaces(QQ) & Rings())
Unknown
- sage: Sym = SymmetricFunctions(QQ)
- sage: from sage.combinat.sf.sfa import SymmetricFunctionsBases
- sage: Modules(QQ)._subcategory_hook_(SymmetricFunctionsBases(Sym))
+ sage: Sym = SymmetricFunctions(QQ) # optional - sage.combinat
+ sage: from sage.combinat.sf.sfa import SymmetricFunctionsBases # optional - sage.combinat
+ sage: Modules(QQ)._subcategory_hook_(SymmetricFunctionsBases(Sym)) # optional - sage.combinat
Unknown
- sage: SymmetricFunctionsBases(Sym).is_subcategory(Modules(QQ))
+ sage: SymmetricFunctionsBases(Sym).is_subcategory(Modules(QQ)) # optional - sage.combinat
True
Case 1: the two bases are categories; then the base of ``C``
@@ -411,7 +411,7 @@ def _subcategory_hook_(self, C):
sage: VectorSpaces(Fields())._subcategory_hook_(Algebras(Fields()))
True
- sage: VectorSpaces(Fields())._subcategory_hook_(Algebras(Fields().Finite())) # todo: not implemented
+ sage: VectorSpaces(Fields())._subcategory_hook_(Algebras(Fields().Finite())) # todo: not implemented
True
sage: VectorSpaces(Fields().Finite())._subcategory_hook_(Algebras(Fields()))
False
@@ -419,7 +419,7 @@ def _subcategory_hook_(self, C):
Case 2: the base of ``self`` is a category; then the base of
``C`` shall be a parent in this category::
- sage: VectorSpaces(Fields())._subcategory_hook_(Algebras(QQ)) # todo: not implemented
+ sage: VectorSpaces(Fields())._subcategory_hook_(Algebras(QQ)) # todo: not implemented
True
sage: VectorSpaces(Fields().Finite())._subcategory_hook_(Algebras(QQ))
False
@@ -430,15 +430,17 @@ def _subcategory_hook_(self, C):
True
sage: VectorSpaces(CC)._subcategory_hook_(Algebras(QQ)) # base ring in different categories
False
- sage: VectorSpaces(GF(2))._subcategory_hook_(Algebras(GF(3))) # base ring in the same category
+ sage: VectorSpaces(GF(2))._subcategory_hook_(Algebras(GF(3))) # base ring in the same category # optional - sage.rings.finite_rings
False
Note; we need both previous tests since the distinction is
made respectively using the parent class or the base ring::
- sage: issubclass(Algebras(QQ).parent_class, VectorSpaces(CC).parent_class)
+ sage: issubclass(Algebras(QQ).parent_class, # optional - sage.modules
+ ....: VectorSpaces(CC).parent_class)
False
- sage: issubclass(Algebras(GF(2)).parent_class, VectorSpaces(GF(3)).parent_class)
+ sage: issubclass(Algebras(GF(2)).parent_class, # optional - sage.modules sage.rings.finite_rings
+ ....: VectorSpaces(GF(3)).parent_class)
True
Check that :trac:`16618` is fixed: this `_subcategory_hook_`
diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
index 1c92e587456..a304ff996cd 100644
--- a/src/sage/categories/category_with_axiom.py
+++ b/src/sage/categories/category_with_axiom.py
@@ -182,7 +182,8 @@ class ``Semigroups.Infinite`` inheriting from :class:`CategoryWithAxiom`.
:trac:`15648`), one should pass the option ``as_name`` to
:class:`~sage.misc.lazy_import.LazyImport`::
- Finite = LazyImport('sage.categories.finite_groups', 'FiniteGroups', as_name='Finite')
+ Finite = LazyImport('sage.categories.finite_groups', 'FiniteGroups',
+ as_name='Finite')
in order to prevent ``Groups.Finite`` to keep on reimporting
``FiniteGroups``.
@@ -1730,7 +1731,8 @@ def base_category_class_and_axiom(cls):
(, 'Finite')
sage: base_category_class_and_axiom(FiniteDimensionalHopfAlgebrasWithBasis)
- (, 'FiniteDimensional')
+ (,
+ 'FiniteDimensional')
sage: base_category_class_and_axiom(HopfAlgebrasWithBasis)
(, 'WithBasis')
@@ -1742,7 +1744,9 @@ def base_category_class_and_axiom(cls):
sage: base_category_class_and_axiom(FacadeSemigroups)
Traceback (most recent call last):
...
- AssertionError: Missing (lazy import) link for to for axiom Facade?
+ AssertionError: Missing (lazy import) link
+ for
+ to for axiom Facade?
sage: Semigroups.Facade = FacadeSemigroups
sage: base_category_class_and_axiom(FacadeSemigroups)
@@ -1760,7 +1764,8 @@ def base_category_class_and_axiom(cls):
sage: base_category_class_and_axiom(Sets.Infinite)
Traceback (most recent call last):
...
- TypeError: Could not retrieve the base category class and axiom for .
+ TypeError: Could not retrieve the base category class and axiom
+ for .
...
"""
if "." in cls.__name__:
@@ -1812,7 +1817,8 @@ def axiom_of_nested_class(cls, nested_cls):
sage: from sage.categories.category_with_axiom import TestObjects, axiom_of_nested_class
sage: axiom_of_nested_class(TestObjects, TestObjects.FiniteDimensional)
'FiniteDimensional'
- sage: axiom_of_nested_class(TestObjects.FiniteDimensional, TestObjects.FiniteDimensional.Finite)
+ sage: axiom_of_nested_class(TestObjects.FiniteDimensional,
+ ....: TestObjects.FiniteDimensional.Finite)
'Finite'
sage: axiom_of_nested_class(Sets, FiniteSets)
'Finite'
@@ -2456,9 +2462,9 @@ def axioms(self):
sage: C.axioms()
frozenset({'Finite'})
- sage: C = Modules(GF(5)).FiniteDimensional(); C
+ sage: C = Modules(GF(5)).FiniteDimensional(); C # optional - sage.rings.finite_rings
Category of finite dimensional vector spaces over Finite Field of size 5
- sage: sorted(C.axioms())
+ sage: sorted(C.axioms()) # optional - sage.rings.finite_rings
['AdditiveAssociative', 'AdditiveCommutative', 'AdditiveInverse',
'AdditiveUnital', 'Finite', 'FiniteDimensional']
@@ -2466,7 +2472,7 @@ def axioms(self):
['AdditiveAssociative', 'AdditiveCommutative', 'AdditiveInverse',
'AdditiveUnital', 'Associative', 'Distributive',
'FiniteDimensional', 'Unital', 'WithBasis']
- sage: sorted(FiniteMonoids().Algebras(GF(3)).axioms())
+ sage: sorted(FiniteMonoids().Algebras(GF(3)).axioms()) # optional - sage.rings.finite_rings
['AdditiveAssociative', 'AdditiveCommutative', 'AdditiveInverse',
'AdditiveUnital', 'Associative', 'Distributive', 'Finite',
'FiniteDimensional', 'Unital', 'WithBasis']
@@ -2543,7 +2549,8 @@ class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom):#, Cate
sage: isinstance(C, Category_over_base_ring) # todo: not implemented
True
sage: C.FiniteDimensional()
- Category of finite dimensional connected test objects over base ring over Ring of integers modulo 2
+ Category of finite dimensional connected test objects
+ over base ring over Ring of integers modulo 2
sage: C.Connected()
Category of connected test objects over base ring over Ring of integers modulo 2
"""
@@ -2790,7 +2797,8 @@ def super_categories(self):
Category of unital test objects over base ring over Rational Field
sage: TestObjectsOverBaseRing.FiniteDimensional.Unital.an_instance()
Category of finite dimensional unital test objects over base ring over Rational Field
- sage: TestSuite(TestObjectsOverBaseRing(QQ).FiniteDimensional().Unital().Commutative()).run()
+ sage: C = TestObjectsOverBaseRing(QQ).FiniteDimensional().Unital().Commutative()
+ sage: TestSuite(C).run()
"""
return [TestObjects()]
diff --git a/src/sage/categories/chain_complexes.py b/src/sage/categories/chain_complexes.py
index b1d8c578e60..8ce3e6145bc 100644
--- a/src/sage/categories/chain_complexes.py
+++ b/src/sage/categories/chain_complexes.py
@@ -67,27 +67,27 @@ def homology(self, n=None):
EXAMPLES::
- sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
- sage: C.homology(0)
+ sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}) # optional - sage.modules
+ sage: C.homology(0) # optional - sage.modules
Z x Z
- sage: C.homology(1)
+ sage: C.homology(1) # optional - sage.modules
Z x C3
- sage: C.homology(2)
+ sage: C.homology(2) # optional - sage.modules
0
::
- sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3))
- sage: C = A.cdg_algebra({z: x*y})
- sage: C.homology(0)
+ sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # optional - sage.combinat sage.modules
+ sage: C = A.cdg_algebra({z: x*y}) # optional - sage.combinat sage.modules
+ sage: C.homology(0) # optional - sage.combinat sage.modules
Free module generated by {[1]} over Rational Field
- sage: C.homology(1)
+ sage: C.homology(1) # optional - sage.combinat sage.modules
Free module generated by {} over Rational Field
- sage: C.homology(2)
+ sage: C.homology(2) # optional - sage.combinat sage.modules
Free module generated by {[x], [y]} over Rational Field
- sage: C.homology(3)
+ sage: C.homology(3) # optional - sage.combinat sage.modules
Free module generated by {} over Rational Field
- sage: C.homology(4)
+ sage: C.homology(4) # optional - sage.combinat sage.modules
Free module generated by {[x^2], [y^2]} over Rational Field
"""
@@ -99,17 +99,18 @@ def differential(self, *args, **kwargs):
EXAMPLES::
- sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
- sage: C.differential(0)
+ sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}) # optional - sage.modules
+ sage: C.differential(0) # optional - sage.modules
[3 0 0]
[0 0 0]
::
- sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3))
- sage: C = A.cdg_algebra({z: x*y})
- sage: C.differential()
- Differential of Commutative Differential Graded Algebra with generators ('x', 'y', 'z') in degrees (2, 2, 3) over Rational Field
+ sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # optional - sage.combinat sage.modules
+ sage: C = A.cdg_algebra({z: x*y}) # optional - sage.combinat sage.modules
+ sage: C.differential() # optional - sage.combinat sage.modules
+ Differential of Commutative Differential Graded Algebra with
+ generators ('x', 'y', 'z') in degrees (2, 2, 3) over Rational Field
Defn: x --> 0
y --> 0
z --> x*y
@@ -123,10 +124,10 @@ def lift_from_homology(self, x):
EXAMPLES::
- sage: E3 = EuclideanSpace(3) # optional - sage.symbolic
- sage: C = E3.de_rham_complex() # optional - sage.symbolic
- sage: one = C.homology().one() # optional - sage.symbolic
- sage: C.lift_from_homology(one) # optional - sage.symbolic
+ sage: E3 = EuclideanSpace(3) # optional - sage.symbolic
+ sage: C = E3.de_rham_complex() # optional - sage.symbolic
+ sage: one = C.homology().one() # optional - sage.symbolic
+ sage: C.lift_from_homology(one) # optional - sage.symbolic
Mixed differential form one on the Euclidean space E^3
"""
@@ -143,10 +144,10 @@ def reduce_to_homology(self, x, n=None):
EXAMPLES::
- sage: E3 = EuclideanSpace(3) # optional - sage.symbolic
- sage: C = E3.de_rham_complex() # optional - sage.symbolic
- sage: one = C.one() # optional - sage.symbolic
- sage: C.reduce_to_homology(one) # optional - sage.symbolic
+ sage: E3 = EuclideanSpace(3) # optional - sage.symbolic
+ sage: C = E3.de_rham_complex() # optional - sage.symbolic
+ sage: one = C.one() # optional - sage.symbolic
+ sage: C.reduce_to_homology(one) # optional - sage.symbolic
[one]
"""
try:
@@ -168,35 +169,35 @@ class HomologyFunctor(Functor):
EXAMPLES::
- sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
- sage: H = HomologyFunctor(ChainComplexes(ZZ), 1)
- sage: H(C)
+ sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}) # optional - sage.modules
+ sage: H = HomologyFunctor(ChainComplexes(ZZ), 1) # optional - sage.modules
+ sage: H(C) # optional - sage.modules
Z x C3
::
- sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3))
- sage: C = A.cdg_algebra({z: x*y})
- sage: H = HomologyFunctor(ChainComplexes(QQ), 2)
- sage: H(C)
+ sage: A. = GradedCommutativeAlgebra(QQ, degrees=(2, 2, 3)) # optional - sage.combinat sage.modules
+ sage: C = A.cdg_algebra({z: x*y}) # optional - sage.combinat sage.modules
+ sage: H = HomologyFunctor(ChainComplexes(QQ), 2) # optional - sage.combinat sage.modules
+ sage: H(C) # optional - sage.combinat sage.modules
Free module generated by {[x], [y]} over Rational Field
Applying to a chain map::
- sage: S = simplicial_complexes.Sphere(1); S
+ sage: S = simplicial_complexes.Sphere(1); S # optional - sage.graphs
Minimal triangulation of the 1-sphere
- sage: C = S.chain_complex()
- sage: C.differential()
+ sage: C = S.chain_complex() # optional - sage.graphs sage.modules
+ sage: C.differential() # optional - sage.graphs sage.modules
{0: [], 1: [-1 -1 0]
[ 1 0 -1]
[ 0 1 1], 2: []}
- sage: f = {0:zero_matrix(ZZ,3,3),1:zero_matrix(ZZ,3,3)}
- sage: G = Hom(C,C)
- sage: x = G(f)
- sage: H = HomologyFunctor(ChainComplexes(ZZ), 1)
- sage: H(C)
+ sage: f = {0: zero_matrix(ZZ,3,3), 1: zero_matrix(ZZ,3,3)} # optional - sage.modules
+ sage: G = Hom(C, C) # optional - sage.graphs sage.modules
+ sage: x = G(f) # optional - sage.graphs sage.modules
+ sage: H = HomologyFunctor(ChainComplexes(ZZ), 1) # optional - sage.graphs sage.modules
+ sage: H(C) # optional - sage.graphs sage.modules
Z
- sage: H(x)
+ sage: H(x) # optional - sage.graphs sage.modules
Generic morphism:
From: Z
To: Z
@@ -225,9 +226,9 @@ def _apply_functor(self, x):
TESTS::
- sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])})
- sage: H = HomologyFunctor(ChainComplexes(ZZ), 1)
- sage: H._apply_functor(C)
+ sage: C = ChainComplex({0: matrix(ZZ, 2, 3, [3, 0, 0, 0, 0, 0])}) # optional - sage.modules
+ sage: H = HomologyFunctor(ChainComplexes(ZZ), 1) # optional - sage.modules
+ sage: H._apply_functor(C) # optional - sage.modules
Z x C3
"""
@@ -239,15 +240,15 @@ def _apply_functor_to_morphism(self, f):
TESTS::
- sage: E3 = EuclideanSpace(3) # optional - sage.symbolic
- sage: C = E3.de_rham_complex() # optional - sage.symbolic
- sage: id = Hom(C, C).identity() # optional - sage.symbolic
- sage: H = HomologyFunctor(ChainComplexes(SR)) # optional - sage.symbolic
- sage: id_star = H(id); id_star # optional - sage.symbolic
+ sage: E3 = EuclideanSpace(3) # optional - sage.symbolic
+ sage: C = E3.de_rham_complex() # optional - sage.symbolic
+ sage: id = Hom(C, C).identity() # optional - sage.symbolic
+ sage: H = HomologyFunctor(ChainComplexes(SR)) # optional - sage.symbolic
+ sage: id_star = H(id); id_star # optional - sage.symbolic
Generic endomorphism of De Rham cohomology ring on the
Euclidean space E^3
- sage: one = H(C).one() # optional - sage.symbolic
- sage: id_star(one) # optional - sage.symbolic
+ sage: one = H(C).one() # optional - sage.symbolic
+ sage: id_star(one) # optional - sage.symbolic
[one]
"""
from .morphism import SetMorphism
diff --git a/src/sage/categories/classical_crystals.py b/src/sage/categories/classical_crystals.py
index 581b094f6d8..744b1cb6e44 100644
--- a/src/sage/categories/classical_crystals.py
+++ b/src/sage/categories/classical_crystals.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.graphs, sage.combinat
r"""
Classical Crystals
"""
diff --git a/src/sage/categories/coalgebras.py b/src/sage/categories/coalgebras.py
index ecbf5d15baf..870315dc644 100644
--- a/src/sage/categories/coalgebras.py
+++ b/src/sage/categories/coalgebras.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat
r"""
Coalgebras
"""
diff --git a/src/sage/categories/coalgebras_with_basis.py b/src/sage/categories/coalgebras_with_basis.py
index 5518804d649..844f5e5a294 100644
--- a/src/sage/categories/coalgebras_with_basis.py
+++ b/src/sage/categories/coalgebras_with_basis.py
@@ -61,10 +61,12 @@ def coproduct_on_basis(self, i):
EXAMPLES::
- sage: A = HopfAlgebrasWithBasis(QQ).example(); A
- An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
- sage: (a, b) = A._group.gens()
- sage: A.coproduct_on_basis(a)
+ sage: A = HopfAlgebrasWithBasis(QQ).example(); A # optional - sage.groups sage.modules
+ An example of Hopf algebra with basis:
+ the group algebra of the Dihedral group of order 6
+ as a permutation group over Rational Field
+ sage: (a, b) = A._group.gens() # optional - sage.groups sage.modules
+ sage: A.coproduct_on_basis(a) # optional - sage.groups sage.modules
B[(1,2,3)] # B[(1,2,3)]
"""
@@ -79,12 +81,14 @@ def coproduct(self):
EXAMPLES::
- sage: A = HopfAlgebrasWithBasis(QQ).example(); A
- An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
- sage: [a,b] = A.algebra_generators()
- sage: a, A.coproduct(a)
+ sage: A = HopfAlgebrasWithBasis(QQ).example(); A # optional - sage.groups sage.modules
+ An example of Hopf algebra with basis:
+ the group algebra of the Dihedral group of order 6
+ as a permutation group over Rational Field
+ sage: a, b = A.algebra_generators() # optional - sage.groups sage.modules
+ sage: a, A.coproduct(a) # optional - sage.groups sage.modules
(B[(1,2,3)], B[(1,2,3)] # B[(1,2,3)])
- sage: b, A.coproduct(b)
+ sage: b, A.coproduct(b) # optional - sage.groups sage.modules
(B[(1,3)], B[(1,3)] # B[(1,3)])
"""
@@ -111,10 +115,12 @@ def counit_on_basis(self, i):
EXAMPLES::
- sage: A = HopfAlgebrasWithBasis(QQ).example(); A
- An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
- sage: (a, b) = A._group.gens()
- sage: A.counit_on_basis(a)
+ sage: A = HopfAlgebrasWithBasis(QQ).example(); A # optional - sage.groups sage.modules
+ An example of Hopf algebra with basis:
+ the group algebra of the Dihedral group of order 6
+ as a permutation group over Rational Field
+ sage: (a, b) = A._group.gens() # optional - sage.groups sage.modules
+ sage: A.counit_on_basis(a) # optional - sage.groups sage.modules
1
"""
@@ -127,12 +133,14 @@ def counit(self):
EXAMPLES::
- sage: A = HopfAlgebrasWithBasis(QQ).example(); A
- An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
- sage: [a,b] = A.algebra_generators()
- sage: a, A.counit(a)
+ sage: A = HopfAlgebrasWithBasis(QQ).example(); A # optional - sage.groups sage.modules
+ An example of Hopf algebra with basis:
+ the group algebra of the Dihedral group of order 6
+ as a permutation group over Rational Field
+ sage: a, b = A.algebra_generators() # optional - sage.groups sage.modules
+ sage: a, A.counit(a) # optional - sage.groups sage.modules
(B[(1,2,3)], 1)
- sage: b, A.counit(b)
+ sage: b, A.counit(b) # optional - sage.groups sage.modules
(B[(1,3)], 1)
"""
@@ -152,29 +160,29 @@ def coproduct_iterated(self, n=1):
EXAMPLES::
- sage: Psi = NonCommutativeSymmetricFunctions(QQ).Psi()
- sage: Psi[2,2].coproduct_iterated(0)
+ sage: Psi = NonCommutativeSymmetricFunctions(QQ).Psi() # optional - sage.combinat
+ sage: Psi[2,2].coproduct_iterated(0) # optional - sage.combinat
Psi[2, 2]
- sage: Psi[2,2].coproduct_iterated(2)
+ sage: Psi[2,2].coproduct_iterated(2) # optional - sage.combinat
Psi[] # Psi[] # Psi[2, 2] + 2*Psi[] # Psi[2] # Psi[2]
+ Psi[] # Psi[2, 2] # Psi[] + 2*Psi[2] # Psi[] # Psi[2]
+ 2*Psi[2] # Psi[2] # Psi[] + Psi[2, 2] # Psi[] # Psi[]
TESTS::
- sage: p = SymmetricFunctions(QQ).p()
- sage: p[5,2,2].coproduct_iterated()
+ sage: p = SymmetricFunctions(QQ).p() # optional - sage.combinat
+ sage: p[5,2,2].coproduct_iterated() # optional - sage.combinat
p[] # p[5, 2, 2] + 2*p[2] # p[5, 2] + p[2, 2] # p[5]
+ p[5] # p[2, 2] + 2*p[5, 2] # p[2] + p[5, 2, 2] # p[]
- sage: p([]).coproduct_iterated(3)
+ sage: p([]).coproduct_iterated(3) # optional - sage.combinat
p[] # p[] # p[] # p[]
::
- sage: Psi = NonCommutativeSymmetricFunctions(QQ).Psi()
- sage: Psi[2,2].coproduct_iterated(0)
+ sage: Psi = NonCommutativeSymmetricFunctions(QQ).Psi() # optional - sage.combinat
+ sage: Psi[2,2].coproduct_iterated(0) # optional - sage.combinat
Psi[2, 2]
- sage: Psi[2,2].coproduct_iterated(3)
+ sage: Psi[2,2].coproduct_iterated(3) # optional - sage.combinat
Psi[] # Psi[] # Psi[] # Psi[2, 2] + 2*Psi[] # Psi[] # Psi[2] # Psi[2]
+ Psi[] # Psi[] # Psi[2, 2] # Psi[] + 2*Psi[] # Psi[2] # Psi[] # Psi[2]
+ 2*Psi[] # Psi[2] # Psi[2] # Psi[] + Psi[] # Psi[2, 2] # Psi[] # Psi[]
@@ -183,14 +191,14 @@ def coproduct_iterated(self, n=1):
::
- sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m()
- sage: m[[1,3],[2]].coproduct_iterated(2)
+ sage: m = SymmetricFunctionsNonCommutingVariables(QQ).m() # optional - sage.combinat
+ sage: m[[1,3],[2]].coproduct_iterated(2) # optional - sage.combinat
m{} # m{} # m{{1, 3}, {2}} + m{} # m{{1}} # m{{1, 2}}
+ m{} # m{{1, 2}} # m{{1}} + m{} # m{{1, 3}, {2}} # m{}
+ m{{1}} # m{} # m{{1, 2}} + m{{1}} # m{{1, 2}} # m{}
+ m{{1, 2}} # m{} # m{{1}} + m{{1, 2}} # m{{1}} # m{}
+ m{{1, 3}, {2}} # m{} # m{}
- sage: m[[]].coproduct_iterated(3), m[[1,3],[2]].coproduct_iterated(0)
+ sage: m[[]].coproduct_iterated(3), m[[1,3],[2]].coproduct_iterated(0) # optional - sage.combinat
(m{} # m{} # m{} # m{}, m{{1, 3}, {2}})
"""
if n < 0:
diff --git a/src/sage/categories/commutative_additive_groups.py b/src/sage/categories/commutative_additive_groups.py
index c1383022833..9300f4d6db5 100644
--- a/src/sage/categories/commutative_additive_groups.py
+++ b/src/sage/categories/commutative_additive_groups.py
@@ -79,10 +79,11 @@ def additive_order(self):
sage: G((0,1)).additive_order()
+Infinity
- sage: K = GF(9)
- sage: H = cartesian_product([cartesian_product([Zmod(2),Zmod(9)]), K])
- sage: z = H(((1,2), K.gen()))
- sage: z.additive_order()
+ sage: K = GF(9) # optional - sage.rings.finite_rings
+ sage: H = cartesian_product([ # optional - sage.rings.finite_rings
+ ....: cartesian_product([Zmod(2), Zmod(9)]), K])
+ sage: z = H(((1,2), K.gen())) # optional - sage.rings.finite_rings
+ sage: z.additive_order() # optional - sage.rings.finite_rings
18
"""
from sage.rings.infinity import Infinity
diff --git a/src/sage/categories/commutative_algebra_ideals.py b/src/sage/categories/commutative_algebra_ideals.py
index 15824e09644..e0835848e91 100644
--- a/src/sage/categories/commutative_algebra_ideals.py
+++ b/src/sage/categories/commutative_algebra_ideals.py
@@ -24,14 +24,16 @@ class CommutativeAlgebraIdeals(Category_ideal):
sage: C = CommutativeAlgebraIdeals(QQ['x'])
sage: C
- Category of commutative algebra ideals in Univariate Polynomial Ring in x over Rational Field
+ Category of commutative algebra ideals in
+ Univariate Polynomial Ring in x over Rational Field
"""
def __init__(self, A):
"""
EXAMPLES::
sage: CommutativeAlgebraIdeals(ZZ['x'])
- Category of commutative algebra ideals in Univariate Polynomial Ring in x over Integer Ring
+ Category of commutative algebra ideals in
+ Univariate Polynomial Ring in x over Integer Ring
sage: CommutativeAlgebraIdeals(ZZ)
Traceback (most recent call last):
@@ -43,7 +45,7 @@ def __init__(self, A):
...
TypeError: A (=Ring of integers modulo 4) must be a commutative algebra
- sage: CommutativeAlgebraIdeals(Partitions(4))
+ sage: CommutativeAlgebraIdeals(Partitions(4)) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
TypeError: A (=Partitions of the integer 4) must be a commutative algebra
diff --git a/src/sage/categories/commutative_algebras.py b/src/sage/categories/commutative_algebras.py
index cff24e1298a..bdff573db87 100644
--- a/src/sage/categories/commutative_algebras.py
+++ b/src/sage/categories/commutative_algebras.py
@@ -22,8 +22,8 @@ class CommutativeAlgebras(CategoryWithAxiom_over_base_ring):
EXAMPLES::
- sage: M = CommutativeAlgebras(GF(19))
- sage: M
+ sage: M = CommutativeAlgebras(GF(19)) # optional - sage.rings.finite_rings
+ sage: M # optional - sage.rings.finite_rings
Category of commutative algebras over Finite Field of size 19
sage: CommutativeAlgebras(QQ).super_categories()
[Category of algebras over Rational Field, Category of commutative rings]
@@ -53,7 +53,7 @@ def __contains__(self, A):
True
sage: QQ['a,b'] in CommutativeAlgebras(QQ)
True
- sage: FreeAlgebra(QQ,2,'a,b') in CommutativeAlgebras(QQ)
+ sage: FreeAlgebra(QQ, 2, 'a,b') in CommutativeAlgebras(QQ) # optional - sage.combinat
False
TODO: get rid of this method once all commutative algebras in
@@ -80,12 +80,12 @@ def extra_super_categories(self):
TESTS::
- sage: X = algebras.Shuffle(QQ, 'ab')
- sage: Y = algebras.Shuffle(QQ, 'bc')
- sage: X in Algebras(QQ).Commutative()
+ sage: X = algebras.Shuffle(QQ, 'ab') # optional - sage.combinat
+ sage: Y = algebras.Shuffle(QQ, 'bc') # optional - sage.combinat
+ sage: X in Algebras(QQ).Commutative() # optional - sage.combinat
True
- sage: T = tensor([X, Y])
- sage: T in CommutativeRings()
+ sage: T = tensor([X, Y]) # optional - sage.combinat
+ sage: T in CommutativeRings() # optional - sage.combinat
True
"""
return [CommutativeRings()]
diff --git a/src/sage/categories/commutative_ring_ideals.py b/src/sage/categories/commutative_ring_ideals.py
index 115b79afb80..837f1edf944 100644
--- a/src/sage/categories/commutative_ring_ideals.py
+++ b/src/sage/categories/commutative_ring_ideals.py
@@ -35,7 +35,7 @@ def __init__(self, R):
TESTS::
- sage: CommutativeRingIdeals(Partitions(4))
+ sage: CommutativeRingIdeals(Partitions(4)) # optional - sage.combinat
Traceback (most recent call last):
...
TypeError: R (=Partitions of the integer 4) must be a commutative ring
diff --git a/src/sage/categories/commutative_rings.py b/src/sage/categories/commutative_rings.py
index 71e08a5070d..6219c1070bb 100644
--- a/src/sage/categories/commutative_rings.py
+++ b/src/sage/categories/commutative_rings.py
@@ -35,14 +35,14 @@ class CommutativeRings(CategoryWithAxiom):
sage: QQ['x,y,z'] in CommutativeRings()
True
- sage: GroupAlgebra(DihedralGroup(3), QQ) in CommutativeRings()
+ sage: GroupAlgebra(DihedralGroup(3), QQ) in CommutativeRings() # optional - sage.groups sage.modules
False
- sage: MatrixSpace(QQ,2,2) in CommutativeRings()
+ sage: MatrixSpace(QQ, 2, 2) in CommutativeRings() # optional - sage.modules
False
GroupAlgebra should be fixed::
- sage: GroupAlgebra(CyclicPermutationGroup(3), QQ) in CommutativeRings() # todo: not implemented
+ sage: GroupAlgebra(CyclicPermutationGroup(3), QQ) in CommutativeRings() # todo: not implemented # optional - sage.groups sage.modules
True
"""
@@ -110,92 +110,98 @@ def over(self, base=None, gen=None, gens=None, name=None, names=None):
We construct an extension of finite fields::
- sage: F = GF(5^2)
- sage: k = GF(5^4)
- sage: z4 = k.gen()
+ sage: F = GF(5^2) # optional - sage.rings.finite_rings
+ sage: k = GF(5^4) # optional - sage.rings.finite_rings
+ sage: z4 = k.gen() # optional - sage.rings.finite_rings
- sage: K = k.over(F)
- sage: K
- Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base
+ sage: K = k.over(F) # optional - sage.rings.finite_rings
+ sage: K # optional - sage.rings.finite_rings
+ Field in z4 with defining polynomial
+ x^2 + (4*z2 + 3)*x + z2 over its base
If not explicitly given, the default generator of the top ring
(here k) is used and the same name is kept::
- sage: K.gen()
+ sage: K.gen() # optional - sage.rings.finite_rings
z4
- sage: K(z4)
+ sage: K(z4) # optional - sage.rings.finite_rings
z4
However, it is possible to specify another generator and/or
another name. For example::
- sage: Ka = k.over(F, name='a')
- sage: Ka
- Field in a with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base
- sage: Ka.gen()
+ sage: Ka = k.over(F, name='a') # optional - sage.rings.finite_rings
+ sage: Ka # optional - sage.rings.finite_rings
+ Field in a with defining polynomial
+ x^2 + (4*z2 + 3)*x + z2 over its base
+ sage: Ka.gen() # optional - sage.rings.finite_rings
a
- sage: Ka(z4)
+ sage: Ka(z4) # optional - sage.rings.finite_rings
a
- sage: Kb = k.over(F, gen=-z4+1, name='b')
- sage: Kb
+ sage: Kb = k.over(F, gen=-z4+1, name='b') # optional - sage.rings.finite_rings
+ sage: Kb # optional - sage.rings.finite_rings
Field in b with defining polynomial x^2 + z2*x + 4 over its base
- sage: Kb.gen()
+ sage: Kb.gen() # optional - sage.rings.finite_rings
b
- sage: Kb(-z4+1)
+ sage: Kb(-z4+1) # optional - sage.rings.finite_rings
b
Note that the shortcut ``K.`` is also available::
- sage: KKa. = k.over(F)
- sage: KKa is Ka
+ sage: KKa. = k.over(F) # optional - sage.rings.finite_rings
+ sage: KKa is Ka # optional - sage.rings.finite_rings
True
Building an extension on top of another extension is allowed::
- sage: L = GF(5^12).over(K)
- sage: L
- Field in z12 with defining polynomial x^3 + (1 + (4*z2 + 2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base
- sage: L.base_ring()
- Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base
+ sage: L = GF(5^12).over(K) # optional - sage.rings.finite_rings
+ sage: L # optional - sage.rings.finite_rings
+ Field in z12 with defining polynomial
+ x^3 + (1 + (4*z2 + 2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base
+ sage: L.base_ring() # optional - sage.rings.finite_rings
+ Field in z4 with defining polynomial
+ x^2 + (4*z2 + 3)*x + z2 over its base
The successive bases of an extension are accessible via the
method :meth:`sage.rings.ring_extension.RingExtension_generic.bases`::
- sage: L.bases()
- [Field in z12 with defining polynomial x^3 + (1 + (4*z2 + 2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base,
- Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base,
+ sage: L.bases() # optional - sage.rings.finite_rings
+ [Field in z12 with defining polynomial
+ x^3 + (1 + (4*z2 + 2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base,
+ Field in z4 with defining polynomial
+ x^2 + (4*z2 + 3)*x + z2 over its base,
Finite Field in z2 of size 5^2]
When ``base`` is omitted, the canonical base of the ring is used::
sage: S. = QQ[]
- sage: E = S.over()
- sage: E
+ sage: E = S.over() # optional - sage.modules
+ sage: E # optional - sage.modules
Univariate Polynomial Ring in x over Rational Field over its base
- sage: E.base_ring()
+ sage: E.base_ring() # optional - sage.modules
Rational Field
Here is an example where ``base`` is a defining morphism::
- sage: k. = QQ.extension(x^2 - 2)
- sage: l. = QQ.extension(x^4 - 2)
- sage: f = k.hom([b^2])
- sage: L = l.over(f)
- sage: L
+ sage: k. = QQ.extension(x^2 - 2) # optional - sage.rings.number_field
+ sage: l. = QQ.extension(x^4 - 2) # optional - sage.rings.number_field
+ sage: f = k.hom([b^2]) # optional - sage.rings.number_field
+ sage: L = l.over(f) # optional - sage.rings.number_field
+ sage: L # optional - sage.rings.number_field
Field in b with defining polynomial x^2 - a over its base
- sage: L.base_ring()
+ sage: L.base_ring() # optional - sage.rings.number_field
Number Field in a with defining polynomial x^2 - 2
Similarly, one can create a tower of extensions::
- sage: K = k.over()
- sage: L = l.over(Hom(K,l)(f))
- sage: L
+ sage: K = k.over() # optional - sage.rings.number_field
+ sage: L = l.over(Hom(K, l)(f)) # optional - sage.rings.number_field
+ sage: L # optional - sage.rings.number_field
Field in b with defining polynomial x^2 - a over its base
- sage: L.base_ring()
+ sage: L.base_ring() # optional - sage.rings.number_field
Field in a with defining polynomial x^2 - 2 over its base
- sage: L.bases()
+ sage: L.bases() # optional - sage.rings.number_field
[Field in b with defining polynomial x^2 - a over its base,
Field in a with defining polynomial x^2 - 2 over its base,
Rational Field]
@@ -221,7 +227,8 @@ class Finite(CategoryWithAxiom):
EXAMPLES::
- sage: cartesian_product([Zmod(34), GF(5)]) in Rings().Commutative().Finite()
+ sage: cartesian_product([Zmod(34), # optional - sage.rings.finite_rings
+ ....: GF(5)]) in Rings().Commutative().Finite()
True
"""
class ParentMethods:
@@ -278,34 +285,34 @@ def cyclotomic_cosets(self, q, cosets=None):
cyclic, the set of squares is a particular case of cyclotomic
coset::
- sage: K = GF(25,'z')
- sage: a = K.multiplicative_generator()
- sage: K.cyclotomic_cosets(a**2,cosets=[1])
+ sage: K = GF(25, 'z') # optional - sage.rings.finite_rings
+ sage: a = K.multiplicative_generator() # optional - sage.rings.finite_rings
+ sage: K.cyclotomic_cosets(a**2, cosets=[1]) # optional - sage.rings.finite_rings
[[1, 2, 3, 4, z + 1, z + 3,
2*z + 1, 2*z + 2, 3*z + 3,
3*z + 4, 4*z + 2, 4*z + 4]]
- sage: sorted(b for b in K if not b.is_zero() and b.is_square())
+ sage: sorted(b for b in K if not b.is_zero() and b.is_square()) # optional - sage.rings.finite_rings
[1, 2, 3, 4, z + 1, z + 3,
2*z + 1, 2*z + 2, 3*z + 3,
3*z + 4, 4*z + 2, 4*z + 4]
We compute some examples of minimal polynomials::
- sage: K = GF(27,'z')
- sage: a = K.multiplicative_generator()
- sage: R. = PolynomialRing(K, 'X')
- sage: a.minimal_polynomial('X')
+ sage: K = GF(27, 'z') # optional - sage.rings.finite_rings
+ sage: a = K.multiplicative_generator() # optional - sage.rings.finite_rings
+ sage: R. = PolynomialRing(K, 'X') # optional - sage.rings.finite_rings
+ sage: a.minimal_polynomial('X') # optional - sage.rings.finite_rings
X^3 + 2*X + 1
- sage: cyc3 = Zmod(26).cyclotomic_cosets(3,cosets=[1]); cyc3
+ sage: cyc3 = Zmod(26).cyclotomic_cosets(3, cosets=[1]); cyc3 # optional - sage.rings.finite_rings
[[1, 3, 9]]
- sage: prod(X - a**i for i in cyc3[0])
+ sage: prod(X - a**i for i in cyc3[0]) # optional - sage.rings.finite_rings
X^3 + 2*X + 1
- sage: (a**7).minimal_polynomial('X')
+ sage: (a**7).minimal_polynomial('X') # optional - sage.rings.finite_rings
X^3 + X^2 + 2*X + 1
- sage: cyc7 = Zmod(26).cyclotomic_cosets(3,cosets=[7]); cyc7
+ sage: cyc7 = Zmod(26).cyclotomic_cosets(3, cosets=[7]); cyc7 # optional - sage.rings.finite_rings
[[7, 11, 21]]
- sage: prod(X - a**i for i in cyc7[0])
+ sage: prod(X - a**i for i in cyc7[0]) # optional - sage.rings.finite_rings
X^3 + X^2 + 2*X + 1
Cyclotomic cosets of fields are useful in combinatorial design
@@ -314,26 +321,26 @@ def cyclotomic_cosets(self, q, cosets=None):
:mod:`~sage.combinat.designs.difference_family`). This is
illustrated on the following examples::
- sage: K = GF(5)
- sage: a = K.multiplicative_generator()
- sage: H = K.cyclotomic_cosets(a**2, cosets=[1,2]); H
+ sage: K = GF(5) # optional - sage.rings.finite_rings
+ sage: a = K.multiplicative_generator() # optional - sage.rings.finite_rings
+ sage: H = K.cyclotomic_cosets(a**2, cosets=[1, 2]); H # optional - sage.rings.finite_rings
[[1, 4], [2, 3]]
- sage: sorted(x-y for D in H for x in D for y in D if x != y)
+ sage: sorted(x - y for D in H for x in D for y in D if x != y) # optional - sage.rings.finite_rings
[1, 2, 3, 4]
- sage: K = GF(37)
- sage: a = K.multiplicative_generator()
- sage: H = K.cyclotomic_cosets(a**4, cosets=[1]); H
+ sage: K = GF(37) # optional - sage.rings.finite_rings
+ sage: a = K.multiplicative_generator() # optional - sage.rings.finite_rings
+ sage: H = K.cyclotomic_cosets(a**4, cosets=[1]); H # optional - sage.rings.finite_rings
[[1, 7, 9, 10, 12, 16, 26, 33, 34]]
- sage: sorted(x-y for D in H for x in D for y in D if x != y)
+ sage: sorted(x - y for D in H for x in D for y in D if x != y) # optional - sage.rings.finite_rings
[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, ..., 33, 34, 34, 35, 35, 36, 36]
The method ``cyclotomic_cosets`` works on any finite commutative
ring::
- sage: R = cartesian_product([GF(7), Zmod(14)])
- sage: a = R((3,5))
- sage: R.cyclotomic_cosets((3,5), [(1,1)])
+ sage: R = cartesian_product([GF(7), Zmod(14)]) # optional - sage.rings.finite_rings
+ sage: a = R((3,5)) # optional - sage.rings.finite_rings
+ sage: R.cyclotomic_cosets((3,5), [(1,1)]) # optional - sage.rings.finite_rings
[[(1, 1), (2, 11), (3, 5), (4, 9), (5, 3), (6, 13)]]
"""
q = self(q)
@@ -373,7 +380,8 @@ def extra_super_categories(self):
sage: CommutativeRings().Commutative().CartesianProducts().extra_super_categories()
[Category of commutative rings]
- sage: cartesian_product([ZZ, Zmod(34), QQ, GF(5)]) in CommutativeRings()
+ sage: cartesian_product([ZZ, Zmod(34), # optional - sage.rings.finite_rings
+ ....: QQ, GF(5)]) in CommutativeRings()
True
"""
return [CommutativeRings()]
diff --git a/src/sage/categories/complete_discrete_valuation.py b/src/sage/categories/complete_discrete_valuation.py
index e7bc01ddd28..71c7ec57015 100644
--- a/src/sage/categories/complete_discrete_valuation.py
+++ b/src/sage/categories/complete_discrete_valuation.py
@@ -22,13 +22,13 @@ class CompleteDiscreteValuationRings(Category_singleton):
EXAMPLES::
- sage: Zp(7) in CompleteDiscreteValuationRings()
+ sage: Zp(7) in CompleteDiscreteValuationRings() # optional - sage.rings.padics
True
sage: QQ in CompleteDiscreteValuationRings()
False
sage: QQ[['u']] in CompleteDiscreteValuationRings()
True
- sage: Qp(7) in CompleteDiscreteValuationRings()
+ sage: Qp(7) in CompleteDiscreteValuationRings() # optional - sage.rings.padics
False
sage: TestSuite(CompleteDiscreteValuationRings()).run()
"""
@@ -49,10 +49,10 @@ def valuation(self):
EXAMPLES::
- sage: R = Zp(7)
- sage: x = R(7); x
+ sage: R = Zp(7) # optional - sage.rings.padics
+ sage: x = R(7); x # optional - sage.rings.padics
7 + O(7^21)
- sage: x.valuation()
+ sage: x.valuation() # optional - sage.rings.padics
1
"""
@@ -63,32 +63,32 @@ def denominator(self):
EXAMPLES::
- sage: K = Qp(7)
- sage: x = K(1/21)
- sage: x.denominator()
+ sage: K = Qp(7) # optional - sage.rings.padics
+ sage: x = K(1/21) # optional - sage.rings.padics
+ sage: x.denominator() # optional - sage.rings.padics
7 + O(7^21)
- sage: x = K(7)
- sage: x.denominator()
+ sage: x = K(7) # optional - sage.rings.padics
+ sage: x.denominator() # optional - sage.rings.padics
1 + O(7^20)
Note that the denominator lives in the ring of integers::
- sage: x.denominator().parent()
+ sage: x.denominator().parent() # optional - sage.rings.padics
7-adic Ring with capped relative precision 20
When the denominator is indistinguishable from 0 and the
precision on the input is `O(p^n)`, the return value is `1`
if `n` is nonnegative and `p^(-n)` otherwise::
- sage: x = K(0,5); x
+ sage: x = K(0, 5); x # optional - sage.rings.padics
O(7^5)
- sage: x.denominator()
+ sage: x.denominator() # optional - sage.rings.padics
1 + O(7^20)
- sage: x = K(0,-5); x
+ sage: x = K(0, -5); x # optional - sage.rings.padics
O(7^-5)
- sage: x.denominator()
+ sage: x.denominator() # optional - sage.rings.padics
7^5 + O(7^25)
"""
return self.parent()(1)
@@ -101,26 +101,26 @@ def numerator(self):
EXAMPLES::
- sage: K = Qp(7, 5)
- sage: x = K(1/21)
- sage: x.numerator()
+ sage: K = Qp(7, 5) # optional - sage.rings.padics
+ sage: x = K(1/21) # optional - sage.rings.padics
+ sage: x.numerator() # optional - sage.rings.padics
5 + 4*7 + 4*7^2 + 4*7^3 + 4*7^4 + O(7^5)
- sage: x == x.numerator() / x.denominator()
+ sage: x == x.numerator() / x.denominator() # optional - sage.rings.padics
True
Note that the numerator lives in the ring of integers::
- sage: x.numerator().parent()
+ sage: x.numerator().parent() # optional - sage.rings.padics
7-adic Ring with capped relative precision 5
TESTS::
- sage: x = K(0,-5); x
+ sage: x = K(0, -5); x # optional - sage.rings.padics
O(7^-5)
- sage: x.numerator()
+ sage: x.numerator() # optional - sage.rings.padics
O(7^0)
- sage: x.denominator()
+ sage: x.denominator() # optional - sage.rings.padics
7^5 + O(7^10)
"""
return self
@@ -146,21 +146,22 @@ def lift_to_precision(self, absprec=None):
EXAMPLES::
- sage: R = ZpCA(17)
- sage: R(-1,2).lift_to_precision(10)
+ sage: R = ZpCA(17) # optional - sage.rings.padics
+ sage: R(-1, 2).lift_to_precision(10) # optional - sage.rings.padics
16 + 16*17 + O(17^10)
- sage: R(1,15).lift_to_precision(10)
+ sage: R(1, 15).lift_to_precision(10) # optional - sage.rings.padics
1 + O(17^15)
- sage: R(1,15).lift_to_precision(30)
+ sage: R(1, 15).lift_to_precision(30) # optional - sage.rings.padics
Traceback (most recent call last):
...
PrecisionError: precision higher than allowed by the precision cap
- sage: R(-1,2).lift_to_precision().precision_absolute() == R.precision_cap()
+ sage: (R(-1, 2).lift_to_precision().precision_absolute() # optional - sage.rings.padics
+ ....: == R.precision_cap())
True
- sage: R = Zp(5); c = R(17,3); c.lift_to_precision(8)
+ sage: R = Zp(5); c = R(17, 3); c.lift_to_precision(8) # optional - sage.rings.padics
2 + 3*5 + O(5^8)
- sage: c.lift_to_precision().precision_relative() == R.precision_cap()
+ sage: c.lift_to_precision().precision_relative() == R.precision_cap() # optional - sage.rings.padics
True
"""
@@ -171,13 +172,13 @@ class CompleteDiscreteValuationFields(Category_singleton):
EXAMPLES::
- sage: Zp(7) in CompleteDiscreteValuationFields()
+ sage: Zp(7) in CompleteDiscreteValuationFields() # optional - sage.rings.padics
False
sage: QQ in CompleteDiscreteValuationFields()
False
- sage: LaurentSeriesRing(QQ,'u') in CompleteDiscreteValuationFields()
+ sage: LaurentSeriesRing(QQ, 'u') in CompleteDiscreteValuationFields()
True
- sage: Qp(7) in CompleteDiscreteValuationFields()
+ sage: Qp(7) in CompleteDiscreteValuationFields() # optional - sage.rings.padics
True
sage: TestSuite(CompleteDiscreteValuationFields()).run()
"""
@@ -199,10 +200,10 @@ def valuation(self):
EXAMPLES::
- sage: K = Qp(7)
- sage: x = K(7); x
+ sage: K = Qp(7) # optional - sage.rings.padics
+ sage: x = K(7); x # optional - sage.rings.padics
7 + O(7^21)
- sage: x.valuation()
+ sage: x.valuation() # optional - sage.rings.padics
1
"""
@@ -213,32 +214,32 @@ def denominator(self):
EXAMPLES::
- sage: K = Qp(7)
- sage: x = K(1/21)
- sage: x.denominator()
+ sage: K = Qp(7) # optional - sage.rings.padics
+ sage: x = K(1/21) # optional - sage.rings.padics
+ sage: x.denominator() # optional - sage.rings.padics
7 + O(7^21)
- sage: x = K(7)
- sage: x.denominator()
+ sage: x = K(7) # optional - sage.rings.padics
+ sage: x.denominator() # optional - sage.rings.padics
1 + O(7^20)
Note that the denominator lives in the ring of integers::
- sage: x.denominator().parent()
+ sage: x.denominator().parent() # optional - sage.rings.padics
7-adic Ring with capped relative precision 20
When the denominator is indistinguishable from 0 and the
precision on the input is `O(p^n)`, the return value is `1`
if `n` is nonnegative and `p^(-n)` otherwise::
- sage: x = K(0,5); x
+ sage: x = K(0, 5); x # optional - sage.rings.padics
O(7^5)
- sage: x.denominator()
+ sage: x.denominator() # optional - sage.rings.padics
1 + O(7^20)
- sage: x = K(0,-5); x
+ sage: x = K(0, -5); x # optional - sage.rings.padics
O(7^-5)
- sage: x.denominator()
+ sage: x.denominator() # optional - sage.rings.padics
7^5 + O(7^25)
"""
val = self.valuation()
@@ -256,26 +257,26 @@ def numerator(self):
EXAMPLES::
- sage: K = Qp(7, 5)
- sage: x = K(1/21)
- sage: x.numerator()
+ sage: K = Qp(7, 5) # optional - sage.rings.padics
+ sage: x = K(1/21) # optional - sage.rings.padics
+ sage: x.numerator() # optional - sage.rings.padics
5 + 4*7 + 4*7^2 + 4*7^3 + 4*7^4 + O(7^5)
- sage: x == x.numerator() / x.denominator()
+ sage: x == x.numerator() / x.denominator() # optional - sage.rings.padics
True
Note that the numerator lives in the ring of integers::
- sage: x.numerator().parent()
+ sage: x.numerator().parent() # optional - sage.rings.padics
7-adic Ring with capped relative precision 5
TESTS::
- sage: x = K(0,-5); x
+ sage: x = K(0, -5); x # optional - sage.rings.padics
O(7^-5)
- sage: x.numerator()
+ sage: x.numerator() # optional - sage.rings.padics
O(7^0)
- sage: x.denominator()
+ sage: x.denominator() # optional - sage.rings.padics
7^5 + O(7^10)
"""
R = self.parent().integer_ring()
diff --git a/src/sage/categories/complex_reflection_groups.py b/src/sage/categories/complex_reflection_groups.py
index 5b23c448a96..e55b16eb6a0 100644
--- a/src/sage/categories/complex_reflection_groups.py
+++ b/src/sage/categories/complex_reflection_groups.py
@@ -64,18 +64,18 @@ class ComplexReflectionGroups(Category_singleton):
An example of a reflection group::
- sage: W = ComplexReflectionGroups().example(); W
+ sage: W = ComplexReflectionGroups().example(); W # optional - sage.combinat sage.groups
5-colored permutations of size 3
``W`` is in the category of complex reflection groups::
- sage: W in ComplexReflectionGroups()
+ sage: W in ComplexReflectionGroups() # optional - sage.combinat sage.groups
True
TESTS::
- sage: TestSuite(W).run()
- sage: TestSuite(ComplexReflectionGroups()).run()
+ sage: TestSuite(W).run() # optional - sage.combinat sage.groups
+ sage: TestSuite(ComplexReflectionGroups()).run() # optional - sage.combinat sage.groups
"""
@cached_method
@@ -115,7 +115,7 @@ def example(self):
EXAMPLES::
sage: from sage.categories.complex_reflection_groups import ComplexReflectionGroups
- sage: ComplexReflectionGroups().example()
+ sage: ComplexReflectionGroups().example() # optional - sage.combinat sage.groups
5-colored permutations of size 3
"""
from sage.combinat.colored_permutations import ColoredPermutations
@@ -133,9 +133,9 @@ def rank(self):
EXAMPLES::
- sage: W = CoxeterGroups().example(); W
+ sage: W = CoxeterGroups().example(); W # optional - sage.groups
The symmetric group on {0, ..., 3}
- sage: W.rank()
+ sage: W.rank() # optional - sage.groups
3
"""
diff --git a/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py b/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
index b75cbcb3e5d..3bbe54cefc0 100644
--- a/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
+++ b/src/sage/categories/complex_reflection_or_generalized_coxeter_groups.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# sage.doctest: optional - sage.groups
r"""
Common category for Generalized Coxeter Groups or Complex Reflection Groups
"""
diff --git a/src/sage/categories/covariant_functorial_construction.py b/src/sage/categories/covariant_functorial_construction.py
index ad402bfe09d..90a1c42b1cc 100644
--- a/src/sage/categories/covariant_functorial_construction.py
+++ b/src/sage/categories/covariant_functorial_construction.py
@@ -134,9 +134,10 @@ def category_from_parents(self, parents):
EXAMPLES::
- sage: E = CombinatorialFreeModule(QQ, ["a", "b", "c"])
- sage: tensor.category_from_parents((E, E, E))
- Category of tensor products of finite dimensional vector spaces with basis over Rational Field
+ sage: E = CombinatorialFreeModule(QQ, ["a", "b", "c"]) # optional - sage.modules
+ sage: tensor.category_from_parents((E, E, E)) # optional - sage.modules
+ Category of tensor products of
+ finite dimensional vector spaces with basis over Rational Field
"""
from sage.structure.parent import Parent
assert all(isinstance(parent, Parent) for parent in parents)
@@ -213,8 +214,8 @@ def __call__(self, args, **kwargs):
EXAMPLES::
- sage: E = CombinatorialFreeModule(QQ, ["a", "b", "c"]); E.rename("E")
- sage: tensor((E, E, E))
+ sage: E = CombinatorialFreeModule(QQ, ["a", "b", "c"]); E.rename("E") # optional - sage.modules
+ sage: tensor((E, E, E)) # optional - sage.modules
E # E # E
"""
args = tuple(args) # a bit brute force; let's see if this becomes a bottleneck later
@@ -399,10 +400,12 @@ def category_of(cls, category, *args):
EXAMPLES::
- sage: sage.categories.tensor.TensorProductsCategory.category_of(ModulesWithBasis(QQ))
+ sage: C = sage.categories.tensor.TensorProductsCategory
+ sage: C.category_of(ModulesWithBasis(QQ))
Category of tensor products of vector spaces with basis over Rational Field
- sage: sage.categories.algebra_functor.AlgebrasCategory.category_of(FiniteMonoids(), QQ)
+ sage: C = sage.categories.algebra_functor.AlgebrasCategory
+ sage: C.category_of(FiniteMonoids(), QQ)
Join of Category of finite dimensional algebras with basis over Rational Field
and Category of monoid algebras over Rational Field
and Category of finite set algebras over Rational Field
@@ -540,7 +543,8 @@ def default_super_categories(cls, category, *args):
Bialgebras are both algebras and coalgebras::
sage: Bialgebras(QQ).super_categories()
- [Category of algebras over Rational Field, Category of coalgebras over Rational Field]
+ [Category of algebras over Rational Field,
+ Category of coalgebras over Rational Field]
Hence tensor products of bialgebras are tensor products of
algebras and tensor products of coalgebras::
@@ -551,8 +555,10 @@ def default_super_categories(cls, category, *args):
Here is how :meth:`default_super_categories` was called internally::
- sage: sage.categories.tensor.TensorProductsCategory.default_super_categories(Bialgebras(QQ))
- Join of Category of tensor products of algebras over Rational Field and Category of tensor products of coalgebras over Rational Field
+ sage: C = sage.categories.tensor.TensorProductsCategory
+ sage: C.default_super_categories(Bialgebras(QQ))
+ Join of Category of tensor products of algebras over Rational Field
+ and Category of tensor products of coalgebras over Rational Field
We now show a similar example, with the ``Algebra`` functor
which takes a parameter `\QQ`::
@@ -570,7 +576,8 @@ def default_super_categories(cls, category, *args):
Here is how :meth:`default_super_categories` was called internally::
- sage: sage.categories.algebra_functor.AlgebrasCategory.default_super_categories(FiniteMonoids(), QQ)
+ sage: C = sage.categories.algebra_functor.AlgebrasCategory
+ sage: C.default_super_categories(FiniteMonoids(), QQ)
Join of Category of finite dimensional algebras with basis over Rational Field
and Category of monoid algebras over Rational Field
and Category of finite set algebras over Rational Field
@@ -609,7 +616,8 @@ def is_construction_defined_by_base(self):
sage: Bialgebras(QQ).Graded().is_construction_defined_by_base()
Traceback (most recent call last):
...
- AttributeError: 'JoinCategory_with_category' object has no attribute 'is_construction_defined_by_base'
+ AttributeError: 'JoinCategory_with_category' object has
+ no attribute 'is_construction_defined_by_base'
"""
base = self.base_category()
f = self._functor_category
diff --git a/src/sage/categories/coxeter_group_algebras.py b/src/sage/categories/coxeter_group_algebras.py
index c8a3d935f05..623b1078e60 100644
--- a/src/sage/categories/coxeter_group_algebras.py
+++ b/src/sage/categories/coxeter_group_algebras.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat, sage.groups
r"""
Coxeter Group Algebras
"""
diff --git a/src/sage/categories/coxeter_groups.py b/src/sage/categories/coxeter_groups.py
index 98fe35a0ab3..95c31d20695 100644
--- a/src/sage/categories/coxeter_groups.py
+++ b/src/sage/categories/coxeter_groups.py
@@ -53,21 +53,21 @@ class CoxeterGroups(Category_singleton):
Here are some further examples::
- sage: FiniteCoxeterGroups().example()
+ sage: FiniteCoxeterGroups().example() # optional - sage.combinat sage.groups
The 5-th dihedral group of order 10
- sage: FiniteWeylGroups().example()
+ sage: FiniteWeylGroups().example() # optional - sage.combinat sage.groups
The symmetric group on {0, ..., 3}
- sage: WeylGroup(["B", 3])
+ sage: WeylGroup(["B", 3]) # optional - sage.combinat sage.groups
Weyl Group of type ['B', 3] (as a matrix group acting on the ambient space)
- sage: S4 = SymmetricGroup(4); S4
+ sage: S4 = SymmetricGroup(4); S4 # optional - sage.groups
Symmetric group of order 4! as a permutation group
- sage: S4 in CoxeterGroups().Finite()
+ sage: S4 in CoxeterGroups().Finite() # optional - sage.groups
True
Those will eventually be also in this category::
- sage: DihedralGroup(5)
+ sage: DihedralGroup(5) # optional - sage.groups
Dihedral group of order 10 as a permutation group
.. TODO:: add a demo of usual computations on Coxeter groups.
@@ -97,7 +97,7 @@ class CoxeterGroups(Category_singleton):
TESTS::
sage: W = CoxeterGroups().example()
- sage: TestSuite(W).run()
+ sage: TestSuite(W).run() # optional - sage.combinat
"""
def super_categories(self):
@@ -136,8 +136,8 @@ def coxeter_matrix(self):
EXAMPLES::
- sage: G = WeylGroup(['A',3])
- sage: G.coxeter_matrix()
+ sage: G = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: G.coxeter_matrix() # optional - sage.combinat sage.groups
[1 3 2]
[3 1 3]
[2 3 1]
@@ -150,14 +150,14 @@ def index_set(self):
EXAMPLES::
- sage: W = CoxeterGroup([[1,3],[3,1]])
- sage: W.index_set()
+ sage: W = CoxeterGroup([[1,3],[3,1]]) # optional - sage.combinat sage.groups
+ sage: W.index_set() # optional - sage.combinat sage.groups
(1, 2)
- sage: W = CoxeterGroup([[1,3],[3,1]], index_set=['x', 'y'])
- sage: W.index_set()
+ sage: W = CoxeterGroup([[1,3],[3,1]], index_set=['x', 'y']) # optional - sage.combinat sage.groups
+ sage: W.index_set() # optional - sage.combinat sage.groups
('x', 'y')
- sage: W = CoxeterGroup(['H',3])
- sage: W.index_set()
+ sage: W = CoxeterGroup(['H', 3]) # optional - sage.combinat sage.groups
+ sage: W.index_set() # optional - sage.combinat sage.groups
(1, 2, 3)
"""
return self.coxeter_matrix().index_set()
@@ -168,18 +168,18 @@ def coxeter_diagram(self):
EXAMPLES::
- sage: W = CoxeterGroup(['H',3], implementation="reflection")
- sage: G = W.coxeter_diagram(); G
+ sage: W = CoxeterGroup(['H', 3], implementation="reflection") # optional - sage.combinat sage.groups
+ sage: G = W.coxeter_diagram(); G # optional - sage.combinat sage.groups sage.graphs
Graph on 3 vertices
- sage: G.edges(sort=True)
+ sage: G.edges(sort=True) # optional - sage.combinat sage.groups sage.graphs
[(1, 2, 3), (2, 3, 5)]
- sage: CoxeterGroup(G) is W
+ sage: CoxeterGroup(G) is W # optional - sage.combinat sage.groups sage.graphs
True
- sage: G = Graph([(0, 1, 3), (1, 2, oo)])
- sage: W = CoxeterGroup(G)
- sage: W.coxeter_diagram() == G
+ sage: G = Graph([(0, 1, 3), (1, 2, oo)]) # optional - sage.combinat sage.groups sage.graphs
+ sage: W = CoxeterGroup(G) # optional - sage.combinat sage.groups sage.graphs
+ sage: W.coxeter_diagram() == G # optional - sage.combinat sage.groups sage.graphs
True
- sage: CoxeterGroup(W.coxeter_diagram()) is W
+ sage: CoxeterGroup(W.coxeter_diagram()) is W # optional - sage.combinat sage.groups sage.graphs
True
"""
return self.coxeter_matrix().coxeter_graph()
@@ -190,8 +190,8 @@ def coxeter_type(self):
EXAMPLES::
- sage: W = CoxeterGroup(['H',3])
- sage: W.coxeter_type()
+ sage: W = CoxeterGroup(['H', 3]) # optional - sage.combinat sage.groups
+ sage: W.coxeter_type() # optional - sage.combinat sage.groups
Coxeter type of ['H', 3]
"""
return self.coxeter_matrix().coxeter_type()
@@ -203,12 +203,12 @@ def braid_relations(self):
EXAMPLES::
- sage: W = WeylGroup(["A",2])
- sage: W.braid_relations()
+ sage: W = WeylGroup(["A", 2]) # optional - sage.combinat sage.groups
+ sage: W.braid_relations() # optional - sage.combinat sage.groups
[[[1, 2, 1], [2, 1, 2]]]
- sage: W = WeylGroup(["B",3])
- sage: W.braid_relations()
+ sage: W = WeylGroup(["B", 3]) # optional - sage.combinat sage.groups
+ sage: W.braid_relations() # optional - sage.combinat sage.groups
[[[1, 2, 1], [2, 1, 2]], [[1, 3], [3, 1]], [[2, 3, 2, 3], [3, 2, 3, 2]]]
"""
rels = []
@@ -228,16 +228,16 @@ def braid_group_as_finitely_presented_group(self):
EXAMPLES::
- sage: W = CoxeterGroup(['A',2])
- sage: W.braid_group_as_finitely_presented_group()
+ sage: W = CoxeterGroup(['A', 2]) # optional - sage.combinat sage.groups
+ sage: W.braid_group_as_finitely_presented_group() # optional - sage.combinat sage.groups
Finitely presented group < S1, S2 | S1*S2*S1*S2^-1*S1^-1*S2^-1 >
- sage: W = WeylGroup(['B',2])
- sage: W.braid_group_as_finitely_presented_group()
+ sage: W = WeylGroup(['B', 2]) # optional - sage.combinat sage.groups
+ sage: W.braid_group_as_finitely_presented_group() # optional - sage.combinat sage.groups
Finitely presented group < S1, S2 | (S1*S2)^2*(S1^-1*S2^-1)^2 >
sage: W = ReflectionGroup(['B',3], index_set=["AA","BB","5"]) # optional - gap3
- sage: W.braid_group_as_finitely_presented_group() # optional - gap3
+ sage: W.braid_group_as_finitely_presented_group() # optional - gap3
Finitely presented group < SAA, SBB, S5 |
(SAA*SBB)^2*(SAA^-1*SBB^-1)^2, SAA*S5*SAA^-1*S5^-1,
SBB*S5*SBB*S5^-1*SBB^-1*S5^-1 >
@@ -279,10 +279,10 @@ def braid_orbit(self, word):
sage: word = w.reduced_word(); word
[0, 1, 2, 1]
- sage: sorted(W.braid_orbit(word))
+ sage: sorted(W.braid_orbit(word)) # optional - sage.combinat sage.groups
[[0, 1, 2, 1], [0, 2, 1, 2], [2, 0, 1, 2]]
- sage: sorted(W.braid_orbit([2,1,1,2,1]))
+ sage: sorted(W.braid_orbit([2,1,1,2,1])) # optional - sage.combinat sage.groups
[[1, 2, 1, 1, 2], [2, 1, 1, 2, 1], [2, 1, 2, 1, 2], [2, 2, 1, 2, 2]]
sage: W = ReflectionGroup(['A',3], index_set=["AA","BB","5"]) # optional - gap3
@@ -354,17 +354,17 @@ def __iter__(self):
(2, 1, 2),
(2, 1, 2, 1)]
- sage: W = WeylGroup(["A",2,1])
- sage: g = iter(W)
- sage: next(g)
+ sage: W = WeylGroup(["A", 2, 1]) # optional - sage.combinat sage.groups
+ sage: g = iter(W) # optional - sage.combinat sage.groups
+ sage: next(g) # optional - sage.combinat sage.groups
[1 0 0]
[0 1 0]
[0 0 1]
- sage: next(g)
+ sage: next(g) # optional - sage.combinat sage.groups
[-1 1 1]
[ 0 1 0]
[ 0 0 1]
- sage: next(g)
+ sage: next(g) # optional - sage.combinat sage.groups
[ 1 0 0]
[ 1 -1 1]
[ 0 0 1]
@@ -377,19 +377,19 @@ def _element_constructor_(self, x, **args):
EXAMPLES::
- sage: W1 = WeylGroup("G2",prefix="s")
- sage: W2 = CoxeterGroup("G2")
- sage: W3 = CoxeterGroup("G2", implementation="permutation")
- sage: W1(W2.an_element())
+ sage: W1 = WeylGroup("G2", prefix="s") # optional - sage.combinat sage.groups
+ sage: W2 = CoxeterGroup("G2") # optional - sage.combinat sage.groups
+ sage: W3 = CoxeterGroup("G2", implementation="permutation") # optional - sage.combinat sage.groups
+ sage: W1(W2.an_element()) # optional - sage.combinat sage.groups
s1*s2
- sage: W2(W1.an_element())
+ sage: W2(W1.an_element()) # optional - sage.combinat sage.groups
[ 2 -a]
[ a -1]
- sage: W1(W3.an_element())
+ sage: W1(W3.an_element()) # optional - sage.combinat sage.groups
s1*s2
- sage: s1,s2 = W1.simple_reflections()
- sage: W = CoxeterGroup("A1")
- sage: W(s1*s2)
+ sage: s1, s2 = W1.simple_reflections() # optional - sage.combinat sage.groups
+ sage: W = CoxeterGroup("A1") # optional - sage.combinat sage.groups
+ sage: W(s1 * s2) # optional - sage.combinat sage.groups
Traceback (most recent call last):
...
ValueError: inconsistent number of rows: should be 1 but got 3
@@ -419,7 +419,7 @@ def weak_order_ideal(self, predicate, side="right", category=None):
EXAMPLES::
sage: D6 = FiniteCoxeterGroups().example(5)
- sage: I = D6.weak_order_ideal(predicate = lambda w: w.length() <= 3)
+ sage: I = D6.weak_order_ideal(predicate=lambda w: w.length() <= 3)
sage: I.cardinality()
7
sage: list(I)
@@ -511,17 +511,17 @@ def coxeter_element(self):
EXAMPLES::
- sage: CoxeterGroup(['A', 4]).coxeter_element().reduced_word()
+ sage: CoxeterGroup(['A', 4]).coxeter_element().reduced_word() # optional - sage.combinat sage.groups
[1, 2, 3, 4]
- sage: CoxeterGroup(['B', 4]).coxeter_element().reduced_word()
+ sage: CoxeterGroup(['B', 4]).coxeter_element().reduced_word() # optional - sage.combinat sage.groups
[1, 2, 3, 4]
- sage: CoxeterGroup(['D', 4]).coxeter_element().reduced_word()
+ sage: CoxeterGroup(['D', 4]).coxeter_element().reduced_word() # optional - sage.combinat sage.groups
[1, 2, 4, 3]
- sage: CoxeterGroup(['F', 4]).coxeter_element().reduced_word()
+ sage: CoxeterGroup(['F', 4]).coxeter_element().reduced_word() # optional - sage.combinat sage.groups
[1, 2, 3, 4]
- sage: CoxeterGroup(['E', 8]).coxeter_element().reduced_word()
+ sage: CoxeterGroup(['E', 8]).coxeter_element().reduced_word() # optional - sage.combinat sage.groups
[1, 3, 2, 4, 5, 6, 7, 8]
- sage: CoxeterGroup(['H', 3]).coxeter_element().reduced_word()
+ sage: CoxeterGroup(['H', 3]).coxeter_element().reduced_word() # optional - sage.combinat sage.groups
[1, 2, 3]
This method is also used for well generated finite complex
@@ -545,9 +545,9 @@ def coxeter_element(self):
TESTS::
- sage: WeylGroup(['A', 4]).coxeter_element().reduced_word()
+ sage: WeylGroup(['A', 4]).coxeter_element().reduced_word() # optional - sage.combinat sage.groups
[1, 2, 3, 4]
- sage: SymmetricGroup(3).coxeter_element()
+ sage: SymmetricGroup(3).coxeter_element() # optional - sage.combinat sage.groups
(1,3,2)
"""
return self.prod(self.simple_reflections())
@@ -575,24 +575,24 @@ class is not unique and we only obtain one such class.
TESTS::
- sage: W = SymmetricGroup(3)
- sage: sorted(W.standard_coxeter_elements())
+ sage: W = SymmetricGroup(3) # optional - sage.combinat sage.groups
+ sage: sorted(W.standard_coxeter_elements()) # optional - sage.combinat sage.groups
[(1,2,3), (1,3,2)]
- sage: W = Permutations(3)
- sage: sorted(W.standard_coxeter_elements())
+ sage: W = Permutations(3) # optional - sage.combinat sage.groups
+ sage: sorted(W.standard_coxeter_elements()) # optional - sage.combinat sage.groups
[[2, 3, 1], [3, 1, 2]]
- sage: W = CoxeterGroup(['D',3])
- sage: sorted(W.standard_coxeter_elements())
+ sage: W = CoxeterGroup(['D', 3]) # optional - sage.combinat sage.groups
+ sage: sorted(W.standard_coxeter_elements()) # optional - sage.combinat sage.groups
[
[-1 1 1] [ 0 -1 1] [ 0 1 -1] [ 1 -1 -1]
[-1 0 1] [ 1 -1 0] [ 0 0 -1] [ 1 -1 0]
[-1 1 0], [ 0 -1 0], [ 1 0 -1], [ 1 0 -1]
]
- sage: W = ColoredPermutations(3,2)
- sage: len(W.standard_coxeter_elements())
+ sage: W = ColoredPermutations(3,2) # optional - sage.combinat sage.groups
+ sage: len(W.standard_coxeter_elements()) # optional - sage.combinat sage.groups
2
"""
if not self.is_irreducible() or not self.is_well_generated():
@@ -642,8 +642,9 @@ def fully_commutative_elements(self):
EXAMPLES::
- sage: CoxeterGroup(['A', 3]).fully_commutative_elements()
- Fully commutative elements of Finite Coxeter group over Integer Ring with Coxeter matrix:
+ sage: CoxeterGroup(['A', 3]).fully_commutative_elements() # optional - sage.combinat sage.groups
+ Fully commutative elements of
+ Finite Coxeter group over Integer Ring with Coxeter matrix:
[1 3 2]
[3 1 3]
[2 3 1]
@@ -689,7 +690,7 @@ def simple_projection(self, i, side='right', length_increasing=True):
sage: sigma
(1, 2, 3, 0)
sage: u0 = W.simple_projection(0)
- sage: d0 = W.simple_projection(0,length_increasing=False)
+ sage: d0 = W.simple_projection(0, length_increasing=False)
sage: sigma.length()
3
sage: pi=sigma*s[0]
@@ -738,9 +739,9 @@ def kazhdan_lusztig_cells(self, side='left'):
representation of elements in the output cells but not the method
used for the cell computation::
- sage: W = CoxeterGroup('A2')
- sage: KL_cells = W.kazhdan_lusztig_cells(side='right')
- sage: set([tuple(sorted(C, key=lambda w: w.reduced_word()))
+ sage: W = CoxeterGroup('A2') # optional - sage.combinat sage.groups
+ sage: KL_cells = W.kazhdan_lusztig_cells(side='right') # optional - sage.combinat sage.groups
+ sage: set([tuple(sorted(C, key=lambda w: w.reduced_word())) # optional - sage.combinat sage.groups
....: for C in KL_cells])
{(
[-1 1] [ 0 -1]
@@ -758,11 +759,11 @@ def kazhdan_lusztig_cells(self, side='left'):
[ 1 0] [-1 1]
[ 1 -1], [-1 0]
)}
- sage: len(KL_cells)
+ sage: len(KL_cells) # optional - sage.combinat sage.groups
4
- sage: W = CoxeterGroup('A2', implementation='permutation')
- sage: len(W.kazhdan_lusztig_cells(side='right'))
+ sage: W = CoxeterGroup('A2', implementation='permutation') # optional - sage.combinat sage.groups
+ sage: len(W.kazhdan_lusztig_cells(side='right')) # optional - sage.combinat sage.groups
4
We compute the left cells in the Coxeter group of type `A_3`
@@ -792,11 +793,12 @@ def kazhdan_lusztig_cells(self, side='left'):
Computing the two sided cells in `B_3`::
- sage: W = CoxeterGroup('B3', implementation='coxeter3') # optional - coxeter3
- sage: b3_cells = W.kazhdan_lusztig_cells('two-sided') # optional - coxeter3
- sage: len(b3_cells) # optional - coxeter3
+ sage: W = CoxeterGroup('B3', implementation='coxeter3') # optional - coxeter3
+ sage: b3_cells = W.kazhdan_lusztig_cells('two-sided') # optional - coxeter3
+ sage: len(b3_cells) # optional - coxeter3
6
- sage: set([tuple(sorted(C)) for C in W.kazhdan_lusztig_cells()]) # optional - coxeter3
+ sage: set([tuple(sorted(C)) # optional - coxeter3
+ ....: for C in W.kazhdan_lusztig_cells()])
{([],),
([1], [1, 2, 3, 2, 1], [2, 1], [2, 3, 2, 1], [3, 2, 1]),
([1, 2], [1, 2, 3, 2], [2], [2, 3, 2], [3, 2]),
@@ -825,8 +827,8 @@ def kazhdan_lusztig_cells(self, side='left'):
TESTS::
- sage: W = CoxeterGroup(['A', 2, 1])
- sage: W.kazhdan_lusztig_cells()
+ sage: W = CoxeterGroup(['A', 2, 1]) # optional - sage.combinat sage.groups
+ sage: W.kazhdan_lusztig_cells() # optional - sage.combinat sage.groups
Traceback (most recent call last):
...
ValueError: the Coxeter group must be finite to compute Kazhdan--Lusztig cells
@@ -887,7 +889,9 @@ def simple_projections(self, side='right', length_increasing=True):
sage: sigma = W.an_element(); sigma
(1, 2, 3, 0)
sage: pi = W.simple_projections(); pi
- Finite family {0: at ...>, 1: at ...>, 2: ...>}
+ Finite family {0: at ...>,
+ 1: at ...>,
+ 2: ...>}
sage: pi[1](sigma)
(1, 3, 2, 0)
sage: W.simple_projection(1)(sigma)
@@ -907,9 +911,11 @@ def sign_representation(self, base_ring=None, side="twosided"):
EXAMPLES::
- sage: W = WeylGroup(["A", 1, 1])
- sage: W.sign_representation()
- Sign representation of Weyl Group of type ['A', 1, 1] (as a matrix group acting on the root space) over Integer Ring
+ sage: W = WeylGroup(["A", 1, 1]) # optional - sage.combinat sage.groups
+ sage: W.sign_representation() # optional - sage.combinat sage.groups
+ Sign representation of
+ Weyl Group of type ['A', 1, 1] (as a matrix group acting on the root space)
+ over Integer Ring
"""
if base_ring is None:
@@ -933,18 +939,18 @@ def demazure_product(self, Q):
EXAMPLES::
- sage: W = WeylGroup(['A',2])
- sage: w = W.demazure_product([2,2,1])
- sage: w.reduced_word()
+ sage: W = WeylGroup(['A', 2]) # optional - sage.combinat sage.groups
+ sage: w = W.demazure_product([2,2,1]) # optional - sage.combinat sage.groups
+ sage: w.reduced_word() # optional - sage.combinat sage.groups
[2, 1]
- sage: w = W.demazure_product([2,1,2,1,2])
- sage: w.reduced_word()
+ sage: w = W.demazure_product([2,1,2,1,2]) # optional - sage.combinat sage.groups
+ sage: w.reduced_word() # optional - sage.combinat sage.groups
[1, 2, 1]
- sage: W = WeylGroup(['B',2])
- sage: w = W.demazure_product([2,1,2,1,2])
- sage: w.reduced_word()
+ sage: W = WeylGroup(['B', 2]) # optional - sage.combinat sage.groups
+ sage: w = W.demazure_product([2,1,2,1,2]) # optional - sage.combinat sage.groups
+ sage: w.reduced_word() # optional - sage.combinat sage.groups
[2, 1, 2, 1]
"""
return self.one().apply_demazure_product(Q)
@@ -955,16 +961,16 @@ def bruhat_interval(self, x, y):
EXAMPLES::
- sage: W = WeylGroup("A3", prefix="s")
- sage: [s1,s2,s3] = W.simple_reflections()
- sage: W.bruhat_interval(s2,s1*s3*s2*s1*s3)
+ sage: W = WeylGroup("A3", prefix="s") # optional - sage.combinat sage.groups
+ sage: s1, s2, s3 = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: W.bruhat_interval(s2, s1*s3*s2*s1*s3) # optional - sage.combinat sage.groups
[s1*s2*s3*s2*s1, s2*s3*s2*s1, s3*s1*s2*s1, s1*s2*s3*s1,
s1*s2*s3*s2, s3*s2*s1, s2*s3*s1, s2*s3*s2, s1*s2*s1,
s3*s1*s2, s1*s2*s3, s2*s1, s3*s2, s2*s3, s1*s2, s2]
- sage: W = WeylGroup(['A',2,1], prefix="s")
- sage: [s0,s1,s2] = W.simple_reflections()
- sage: W.bruhat_interval(1,s0*s1*s2)
+ sage: W = WeylGroup(['A', 2, 1], prefix="s") # optional - sage.combinat sage.groups
+ sage: s0, s1, s2 = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: W.bruhat_interval(1, s0*s1*s2) # optional - sage.combinat sage.groups
[s0*s1*s2, s1*s2, s0*s2, s0*s1, s2, s1, s0, 1]
"""
if x == 1:
@@ -994,19 +1000,19 @@ def bruhat_interval_poset(self, x, y, facade=False):
EXAMPLES::
- sage: W = WeylGroup("A3", prefix="s")
- sage: s1,s2,s3 = W.simple_reflections()
- sage: W.bruhat_interval_poset(s2, s1*s3*s2*s1*s3)
+ sage: W = WeylGroup("A3", prefix="s") # optional - sage.combinat sage.groups
+ sage: s1, s2, s3 = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: W.bruhat_interval_poset(s2, s1*s3*s2*s1*s3) # optional - sage.combinat sage.groups
Finite poset containing 16 elements
- sage: W = WeylGroup(['A',2,1], prefix="s")
- sage: s0,s1,s2 = W.simple_reflections()
- sage: W.bruhat_interval_poset(1, s0*s1*s2)
+ sage: W = WeylGroup(['A', 2, 1], prefix="s") # optional - sage.combinat sage.groups
+ sage: s0, s1, s2 = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: W.bruhat_interval_poset(1, s0*s1*s2) # optional - sage.combinat sage.groups
Finite poset containing 8 elements
TESTS::
- sage: W.bruhat_interval_poset(s0*s1*s2, s0*s1*s2)
+ sage: W.bruhat_interval_poset(s0*s1*s2, s0*s1*s2) # optional - sage.combinat sage.groups
Finite poset containing 1 elements
"""
if x == 1:
@@ -1061,27 +1067,27 @@ def bruhat_graph(self, x=None, y=None, edge_labels=False):
EXAMPLES::
- sage: W = CoxeterGroup(['H',3])
- sage: G = W.bruhat_graph(); G
+ sage: W = CoxeterGroup(['H', 3]) # optional - sage.combinat sage.groups sage.graphs
+ sage: G = W.bruhat_graph(); G # optional - sage.combinat sage.groups sage.graphs
Digraph on 120 vertices
- sage: W = CoxeterGroup(['A',2,1])
- sage: s1, s2, s3 = W.simple_reflections()
- sage: W.bruhat_graph(s1, s1*s3*s2*s3)
+ sage: W = CoxeterGroup(['A', 2, 1]) # optional - sage.combinat sage.groups sage.graphs
+ sage: s1, s2, s3 = W.simple_reflections() # optional - sage.combinat sage.groups sage.graphs
+ sage: W.bruhat_graph(s1, s1*s3*s2*s3) # optional - sage.combinat sage.groups sage.graphs
Digraph on 6 vertices
- sage: W.bruhat_graph(s1, s3*s2*s3)
+ sage: W.bruhat_graph(s1, s3*s2*s3) # optional - sage.combinat sage.groups sage.graphs
Digraph on 0 vertices
- sage: W = WeylGroup("A3", prefix="s")
- sage: s1, s2, s3 = W.simple_reflections()
- sage: G = W.bruhat_graph(s1*s3, s1*s2*s3*s2*s1); G
+ sage: W = WeylGroup("A3", prefix="s") # optional - sage.combinat sage.groups sage.graphs
+ sage: s1, s2, s3 = W.simple_reflections() # optional - sage.combinat sage.groups sage.graphs
+ sage: G = W.bruhat_graph(s1*s3, s1*s2*s3*s2*s1); G # optional - sage.combinat sage.groups sage.graphs
Digraph on 10 vertices
Check that the graph has the correct number of edges
(see :trac:`17744`)::
- sage: len(G.edges(sort=False))
+ sage: len(G.edges(sort=False)) # optional - sage.combinat sage.groups sage.graphs
16
"""
if x is None or x == 1:
@@ -1129,8 +1135,8 @@ def canonical_representation(self):
EXAMPLES::
- sage: W = WeylGroup("A3")
- sage: W.canonical_representation()
+ sage: W = WeylGroup("A3") # optional - sage.combinat sage.groups
+ sage: W.canonical_representation() # optional - sage.combinat sage.groups
Finite Coxeter group over Integer Ring with Coxeter matrix:
[1 3 2]
[3 1 3]
@@ -1146,16 +1152,16 @@ def elements_of_length(self, n):
EXAMPLES::
- sage: A = AffinePermutationGroup(['A',2,1])
- sage: [len(list(A.elements_of_length(i))) for i in [0..5]]
+ sage: A = AffinePermutationGroup(['A', 2, 1]) # optional - sage.combinat sage.groups
+ sage: [len(list(A.elements_of_length(i))) for i in [0..5]] # optional - sage.combinat sage.groups
[1, 3, 6, 9, 12, 15]
- sage: W = CoxeterGroup(['H',3])
- sage: [len(list(W.elements_of_length(i))) for i in range(4)]
+ sage: W = CoxeterGroup(['H', 3]) # optional - sage.combinat sage.groups
+ sage: [len(list(W.elements_of_length(i))) for i in range(4)] # optional - sage.combinat sage.groups
[1, 3, 5, 7]
- sage: W = CoxeterGroup(['A',2])
- sage: [len(list(W.elements_of_length(i))) for i in range(6)]
+ sage: W = CoxeterGroup(['A', 2]) # optional - sage.combinat sage.groups
+ sage: [len(list(W.elements_of_length(i))) for i in range(6)] # optional - sage.combinat sage.groups
[1, 2, 2, 1, 0, 0]
"""
I = self.weak_order_ideal(ConstantFunction(True), side='right')
@@ -1173,18 +1179,18 @@ def random_element_of_length(self, n):
EXAMPLES::
- sage: A = AffinePermutationGroup(['A', 7, 1])
- sage: p = A.random_element_of_length(10)
- sage: p in A
+ sage: A = AffinePermutationGroup(['A', 7, 1]) # optional - sage.combinat sage.groups
+ sage: p = A.random_element_of_length(10) # optional - sage.combinat sage.groups
+ sage: p in A # optional - sage.combinat sage.groups
True
- sage: p.length() == 10
+ sage: p.length() == 10 # optional - sage.combinat sage.groups
True
- sage: W = CoxeterGroup(['A', 4])
- sage: p = W.random_element_of_length(5)
- sage: p in W
+ sage: W = CoxeterGroup(['A', 4]) # optional - sage.combinat sage.groups
+ sage: p = W.random_element_of_length(5) # optional - sage.combinat sage.groups
+ sage: p in W # optional - sage.combinat sage.groups
True
- sage: p.length() == 5
+ sage: p.length() == 5 # optional - sage.combinat sage.groups
True
"""
from sage.misc.prandom import randint
@@ -1236,14 +1242,14 @@ def _test_has_descent(self, **options):
sage: W = CoxeterGroups().example()
sage: W._test_has_descent()
- sage: W = Permutations(4)
- sage: W._test_has_descent()
- sage: sage.combinat.permutation.Permutations.options.mult = "r2l"
- sage: W._test_has_descent()
- sage: sage.combinat.permutation.Permutations.options._reset()
+ sage: W = Permutations(4) # optional - sage.combinat sage.groups
+ sage: W._test_has_descent() # optional - sage.combinat sage.groups
+ sage: sage.combinat.permutation.Permutations.options.mult = "r2l" # optional - sage.combinat sage.groups
+ sage: W._test_has_descent() # optional - sage.combinat sage.groups
+ sage: sage.combinat.permutation.Permutations.options._reset() # optional - sage.combinat sage.groups
- sage: W = SignedPermutations(3)
- sage: W._test_has_descent()
+ sage: W = SignedPermutations(3) # optional - sage.combinat sage.groups
+ sage: W._test_has_descent() # optional - sage.combinat sage.groups
"""
tester = self._tester(**options)
s = self.simple_reflections()
@@ -1300,21 +1306,21 @@ def _test_coxeter_relations(self, **options):
TESTS::
- sage: A = AffinePermutationGroup(['A',7,1])
- sage: A._test_coxeter_relations()
+ sage: A = AffinePermutationGroup(['A', 7, 1]) # optional - sage.combinat sage.groups
+ sage: A._test_coxeter_relations() # optional - sage.combinat sage.groups
- sage: cm = CartanMatrix([[2,-5,0],[-2,2,-1],[0,-1,2]])
- sage: W = WeylGroup(cm)
- sage: W._test_coxeter_relations()
+ sage: cm = CartanMatrix([[2,-5,0], [-2,2,-1], [0,-1,2]]) # optional - sage.combinat sage.groups
+ sage: W = WeylGroup(cm) # optional - sage.combinat sage.groups
+ sage: W._test_coxeter_relations() # optional - sage.combinat sage.groups
- sage: W = Permutations(4)
- sage: W._test_coxeter_relations()
- sage: sage.combinat.permutation.Permutations.options.mult = "r2l"
- sage: W._test_coxeter_relations()
- sage: sage.combinat.permutation.Permutations.options._reset()
+ sage: W = Permutations(4) # optional - sage.combinat sage.groups
+ sage: W._test_coxeter_relations() # optional - sage.combinat sage.groups
+ sage: sage.combinat.permutation.Permutations.options.mult = "r2l" # optional - sage.combinat sage.groups
+ sage: W._test_coxeter_relations() # optional - sage.combinat sage.groups
+ sage: sage.combinat.permutation.Permutations.options._reset() # optional - sage.combinat sage.groups
- sage: W = SignedPermutations(3)
- sage: W._test_coxeter_relations()
+ sage: W = SignedPermutations(3) # optional - sage.combinat sage.groups
+ sage: W._test_coxeter_relations() # optional - sage.combinat sage.groups
"""
tester = self._tester(**options)
s = self.simple_reflections()
@@ -1347,7 +1353,7 @@ def has_descent(self, i, side='right', positive=False):
sage: w = s[0] * s[1] * s[2]
sage: w.has_descent(2)
True
- sage: [ w.has_descent(i) for i in [0,1,2] ]
+ sage: [ w.has_descent(i) for i in [0,1,2] ]
[False, False, True]
sage: [ w.has_descent(i, side='left') for i in [0,1,2] ]
[True, False, False]
@@ -1600,17 +1606,18 @@ def reduced_words(self):
sage: W = CoxeterGroups().example()
sage: s = W.simple_reflections()
sage: w = s[0] * s[2]
- sage: sorted(w.reduced_words())
+ sage: sorted(w.reduced_words()) # optional - sage.combinat
[[0, 2], [2, 0]]
- sage: W = WeylGroup(['E',6])
- sage: w = W.from_reduced_word([2,3,4,2])
- sage: sorted(w.reduced_words())
+ sage: W = WeylGroup(['E', 6]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([2,3,4,2]) # optional - sage.combinat sage.groups
+ sage: sorted(w.reduced_words()) # optional - sage.combinat sage.groups
[[2, 3, 4, 2], [3, 2, 4, 2], [3, 4, 2, 4]]
- sage: W = ReflectionGroup(['A',3], index_set=["AA","BB","5"]) # optional - gap3
- sage: w = W.long_element() # optional - gap3
- sage: w.reduced_words() # optional - gap3
+ sage: W = ReflectionGroup(['A',3], # optional - gap3
+ ....: index_set=["AA","BB","5"])
+ sage: w = W.long_element() # optional - gap3
+ sage: w.reduced_words() # optional - gap3
[['BB', '5', 'AA', 'BB', '5', 'AA'],
['5', 'BB', '5', 'AA', 'BB', '5'],
['BB', 'AA', 'BB', '5', 'BB', 'AA'],
@@ -1693,32 +1700,32 @@ def reduced_word_graph(self):
EXAMPLES::
- sage: W = WeylGroup(['A',3], prefix='s')
- sage: w0 = W.long_element()
- sage: G = w0.reduced_word_graph()
- sage: G.num_verts()
+ sage: W = WeylGroup(['A', 3], prefix='s') # optional - sage.combinat sage.groups
+ sage: w0 = W.long_element() # optional - sage.combinat sage.groups
+ sage: G = w0.reduced_word_graph() # optional - sage.combinat sage.groups sage.graphs
+ sage: G.num_verts() # optional - sage.combinat sage.groups sage.graphs
16
- sage: len(w0.reduced_words())
+ sage: len(w0.reduced_words()) # optional - sage.combinat sage.groups sage.graphs
16
- sage: G.num_edges()
+ sage: G.num_edges() # optional - sage.combinat sage.groups sage.graphs
18
- sage: len([e for e in G.edges(sort=False) if e[2] == 2])
+ sage: len([e for e in G.edges(sort=False) if e[2] == 2]) # optional - sage.combinat sage.groups sage.graphs
10
- sage: len([e for e in G.edges(sort=False) if e[2] == 3])
+ sage: len([e for e in G.edges(sort=False) if e[2] == 3]) # optional - sage.combinat sage.groups sage.graphs
8
TESTS::
- sage: p = Permutation([3,2,4,1])
- sage: pp = WeylGroup(['A',3]).from_reduced_word(p.reduced_word())
- sage: pp.reduced_word_graph()
+ sage: p = Permutation([3,2,4,1]) # optional - sage.combinat
+ sage: pp = WeylGroup(['A',3]).from_reduced_word(p.reduced_word()) # optional - sage.combinat sage.groups
+ sage: pp.reduced_word_graph() # optional - sage.combinat sage.groups sage.graphs
Graph on 3 vertices
- sage: w1 = W.one()
- sage: G = w1.reduced_word_graph()
- sage: G.num_verts()
+ sage: w1 = W.one() # optional - sage.combinat sage.groups
+ sage: G = w1.reduced_word_graph() # optional - sage.combinat sage.groups sage.graphs
+ sage: G.num_verts() # optional - sage.combinat sage.groups sage.graphs
1
- sage: G.num_edges()
+ sage: G.num_edges() # optional - sage.combinat sage.groups sage.graphs
0
.. SEEALSO::
@@ -1814,14 +1821,14 @@ def reflection_length(self):
EXAMPLES::
- sage: W = WeylGroup(['A',3])
- sage: s = W.simple_reflections()
- sage: (s[1]*s[2]*s[3]).reflection_length()
+ sage: W = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: (s[1]*s[2]*s[3]).reflection_length() # optional - sage.combinat sage.groups
3
- sage: W = SymmetricGroup(4)
- sage: s = W.simple_reflections()
- sage: (s[3]*s[2]*s[3]).reflection_length()
+ sage: W = SymmetricGroup(4) # optional - sage.combinat sage.groups
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: (s[3]*s[2]*s[3]).reflection_length() # optional - sage.combinat sage.groups
1
"""
@@ -1844,14 +1851,14 @@ def absolute_length(self):
EXAMPLES::
- sage: W = WeylGroup(["A", 3])
- sage: s = W.simple_reflections()
- sage: (s[1]*s[2]*s[3]).absolute_length()
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: (s[1]*s[2]*s[3]).absolute_length() # optional - sage.combinat sage.groups
3
- sage: W = SymmetricGroup(4)
- sage: s = W.simple_reflections()
- sage: (s[3]*s[2]*s[1]).absolute_length()
+ sage: W = SymmetricGroup(4) # optional - sage.combinat sage.groups
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: (s[3]*s[2]*s[1]).absolute_length() # optional - sage.combinat sage.groups
3
"""
M = self.canonical_matrix()
@@ -1876,40 +1883,45 @@ def absolute_le(self, other):
EXAMPLES::
- sage: W = WeylGroup(["A", 3])
- sage: s = W.simple_reflections()
- sage: w0 = s[1]
- sage: w1 = s[1]*s[2]*s[3]
- sage: w0.absolute_le(w1)
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: w0 = s[1] # optional - sage.combinat sage.groups
+ sage: w1 = s[1]*s[2]*s[3] # optional - sage.combinat sage.groups
+ sage: w0.absolute_le(w1) # optional - sage.combinat sage.groups
True
- sage: w1.absolute_le(w0)
+ sage: w1.absolute_le(w0) # optional - sage.combinat sage.groups
False
- sage: w1.absolute_le(w1)
+ sage: w1.absolute_le(w1) # optional - sage.combinat sage.groups
True
TESTS:
Check that this is independent of the implementation of the group, see :trac:`34799`::
- sage: W1 = WeylGroup(['A',2])
- sage: W2 = Permutations(3)
+ sage: W1 = WeylGroup(['A', 2]) # optional - sage.combinat sage.groups
+ sage: W2 = Permutations(3) # optional - sage.combinat sage.groups
sage: P = lambda pi: W2(list(pi.to_permutation()))
- sage: d1 = set((P(w1), P(w2)) for w1 in W1 for w2 in W1 if w1.absolute_le(w2))
- sage: d2 = set((w1, w2) for w1 in W2 for w2 in W2 if w1.absolute_le(w2))
- sage: d1 == d2
+ sage: d1 = set((P(w1), P(w2)) for w1 in W1 for w2 in W1 # optional - sage.combinat sage.groups
+ ....: if w1.absolute_le(w2))
+ sage: d2 = set((w1, w2) for w1 in W2 for w2 in W2 # optional - sage.combinat sage.groups
+ ....: if w1.absolute_le(w2))
+ sage: d1 == d2 # optional - sage.combinat sage.groups
True
- sage: sage.combinat.permutation.Permutations.options.mult = "r2l"
- sage: d3 = set((w1, w2) for w1 in W2 for w2 in W2 if w1.absolute_le(w2))
- sage: d1 == d3
+ sage: sage.combinat.permutation.Permutations.options.mult = "r2l" # optional - sage.combinat sage.groups
+ sage: d3 = set((w1, w2) # optional - sage.combinat sage.groups
+ ....: for w1 in W2 for w2 in W2 if w1.absolute_le(w2))
+ sage: d1 == d3 # optional - sage.combinat sage.groups
True
- sage: sage.combinat.permutation.Permutations.options._reset()
-
- sage: W1 = WeylGroup(['B',2])
- sage: W2 = SignedPermutations(2)
- sage: P = lambda pi: W2(list(pi.to_permutation()))
- sage: d1 = set((P(w1), P(w2)) for w1 in W1 for w2 in W1 if w1.absolute_le(w2))
- sage: d2 = set((w1, w2) for w1 in W2 for w2 in W2 if w1.absolute_le(w2))
- sage: d1 == d2
+ sage: sage.combinat.permutation.Permutations.options._reset() # optional - sage.combinat sage.groups
+
+ sage: W1 = WeylGroup(['B', 2]) # optional - sage.combinat sage.groups
+ sage: W2 = SignedPermutations(2) # optional - sage.combinat sage.groups
+ sage: P = lambda pi: W2(list(pi.to_permutation())) # optional - sage.combinat sage.groups
+ sage: d1 = set((P(w1), P(w2)) # optional - sage.combinat sage.groups
+ ....: for w1 in W1 for w2 in W1 if w1.absolute_le(w2))
+ sage: d2 = set((w1, w2) # optional - sage.combinat sage.groups
+ ....: for w1 in W2 for w2 in W2 if w1.absolute_le(w2))
+ sage: d1 == d2 # optional - sage.combinat sage.groups
True
"""
if self == other:
@@ -1928,11 +1940,11 @@ def absolute_covers(self):
EXAMPLES::
- sage: W = WeylGroup(["A", 3])
- sage: s = W.simple_reflections()
- sage: w0 = s[1]
- sage: w1 = s[1]*s[2]*s[3]
- sage: w0.absolute_covers()
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: w0 = s[1] # optional - sage.combinat sage.groups
+ sage: w1 = s[1]*s[2]*s[3] # optional - sage.combinat sage.groups
+ sage: w0.absolute_covers() # optional - sage.combinat sage.groups
[
[0 0 1 0] [0 1 0 0] [0 1 0 0] [0 0 0 1] [0 1 0 0]
[1 0 0 0] [1 0 0 0] [0 0 1 0] [1 0 0 0] [0 0 0 1]
@@ -1956,9 +1968,9 @@ def canonical_matrix(self):
EXAMPLES::
- sage: W = WeylGroup(["A", 3])
- sage: s = W.simple_reflections()
- sage: (s[1]*s[2]*s[3]).canonical_matrix()
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: (s[1]*s[2]*s[3]).canonical_matrix() # optional - sage.combinat sage.groups
[ 0 0 -1]
[ 1 0 -1]
[ 0 1 -1]
@@ -1988,11 +2000,11 @@ def coset_representative(self, index_set, side='right'):
[2, 3]
sage: w.coset_representative([1,2]).reduced_word()
[2, 3]
- sage: w.coset_representative([1,3] ).reduced_word()
+ sage: w.coset_representative([1,3] ).reduced_word()
[2]
- sage: w.coset_representative([2,3] ).reduced_word()
+ sage: w.coset_representative([2,3] ).reduced_word()
[2, 1]
- sage: w.coset_representative([1,2,3] ).reduced_word()
+ sage: w.coset_representative([1,2,3] ).reduced_word()
[]
sage: w.coset_representative([], side='left').reduced_word()
[2, 3, 1]
@@ -2039,15 +2051,15 @@ def apply_simple_projection(self, i, side='right', length_increasing=True):
(1, 2, 3, 0)
sage: w.apply_simple_projection(2, length_increasing=False)
(1, 2, 0, 3)
- sage: W = WeylGroup(['C',4],prefix="s")
- sage: v = W.from_reduced_word([1,2,3,4,3,1])
- sage: v
+ sage: W = WeylGroup(['C', 4], prefix="s") # optional - sage.combinat sage.groups
+ sage: v = W.from_reduced_word([1,2,3,4,3,1]) # optional - sage.combinat sage.groups
+ sage: v # optional - sage.combinat sage.groups
s1*s2*s3*s4*s3*s1
- sage: v.apply_simple_projection(2)
+ sage: v.apply_simple_projection(2) # optional - sage.combinat sage.groups
s1*s2*s3*s4*s3*s1*s2
- sage: v.apply_simple_projection(2, side='left')
+ sage: v.apply_simple_projection(2, side='left') # optional - sage.combinat sage.groups
s1*s2*s3*s4*s3*s1
- sage: v.apply_simple_projection(1, length_increasing = False)
+ sage: v.apply_simple_projection(1, length_increasing=False) # optional - sage.combinat sage.groups
s1*s2*s3*s4*s3
"""
@@ -2075,44 +2087,50 @@ def binary_factorizations(self, predicate=ConstantFunction(True)):
We construct the set of all factorizations of the maximal
element of the group::
- sage: W = WeylGroup(['A',3])
- sage: s = W.simple_reflections()
- sage: w0 = W.from_reduced_word([1,2,3,1,2,1])
- sage: w0.binary_factorizations().cardinality()
+ sage: W = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: w0 = W.from_reduced_word([1,2,3,1,2,1]) # optional - sage.combinat sage.groups
+ sage: w0.binary_factorizations().cardinality() # optional - sage.combinat sage.groups
24
The same number of factorizations, by bounded length::
- sage: [w0.binary_factorizations(lambda u: u.length() <= l).cardinality() for l in [-1,0,1,2,3,4,5,6]]
+ sage: [w0.binary_factorizations( # optional - sage.combinat sage.groups
+ ....: lambda u: u.length() <= l
+ ....: ).cardinality()
+ ....: for l in [-1,0,1,2,3,4,5,6]]
[0, 1, 4, 9, 15, 20, 23, 24]
The number of factorizations of the elements just below
the maximal element::
- sage: [(s[i]*w0).binary_factorizations().cardinality() for i in [1,2,3]]
+ sage: [(s[i]*w0).binary_factorizations().cardinality() # optional - sage.combinat sage.groups
+ ....: for i in [1,2,3]]
[12, 12, 12]
- sage: w0.binary_factorizations(lambda u: False).cardinality()
+ sage: w0.binary_factorizations(lambda u: False).cardinality() # optional - sage.combinat sage.groups
0
TESTS::
- sage: w0.binary_factorizations().category()
+ sage: w0.binary_factorizations().category() # optional - sage.combinat sage.groups
Category of finite enumerated sets
Check that this is independent of the implementation of the group, see :trac:`34799`::
- sage: W1 = WeylGroup(['A',3])
- sage: W2 = Permutations(4)
- sage: P = lambda pi: W2(list(pi.to_permutation()))
- sage: d1 = {P(pi): set((P(w[0]), P(w[1])) for w in pi.binary_factorizations()) for pi in W1}
- sage: d2 = {pi: set(pi.binary_factorizations()) for pi in W2}
- sage: d1 == d2
+ sage: W1 = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: W2 = Permutations(4) # optional - sage.combinat sage.groups
+ sage: P = lambda pi: W2(list(pi.to_permutation())) # optional - sage.combinat sage.groups
+ sage: d1 = {P(pi): set((P(w[0]), P(w[1])) # optional - sage.combinat sage.groups
+ ....: for w in pi.binary_factorizations())
+ ....: for pi in W1}
+ sage: d2 = {pi: set(pi.binary_factorizations()) for pi in W2} # optional - sage.combinat sage.groups
+ sage: d1 == d2 # optional - sage.combinat sage.groups
True
- sage: sage.combinat.permutation.Permutations.options.mult = "r2l"
- sage: d3 = {pi: set(pi.binary_factorizations()) for pi in W2}
- sage: d1 == d3
+ sage: sage.combinat.permutation.Permutations.options.mult = "r2l" # optional - sage.combinat sage.groups
+ sage: d3 = {pi: set(pi.binary_factorizations()) for pi in W2} # optional - sage.combinat sage.groups
+ sage: d1 == d3 # optional - sage.combinat sage.groups
True
- sage: sage.combinat.permutation.Permutations.options._reset()
+ sage: sage.combinat.permutation.Permutations.options._reset() # optional - sage.combinat sage.groups
"""
from sage.sets.recursively_enumerated_set import RecursivelyEnumeratedSet_forest
W = self.parent()
@@ -2142,35 +2160,38 @@ def bruhat_lower_covers(self):
EXAMPLES::
- sage: W = WeylGroup(["A",3])
- sage: w = W.from_reduced_word([3,2,3])
- sage: print([v.reduced_word() for v in w.bruhat_lower_covers()])
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,2,3]) # optional - sage.combinat sage.groups
+ sage: print([v.reduced_word() for v in w.bruhat_lower_covers()]) # optional - sage.combinat sage.groups
[[3, 2], [2, 3]]
- sage: W = WeylGroup(["A",3])
- sage: print([v.reduced_word() for v in W.simple_reflection(1).bruhat_lower_covers()])
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: print([v.reduced_word() # optional - sage.combinat sage.groups
+ ....: for v in W.simple_reflection(1).bruhat_lower_covers()])
[[]]
- sage: print([v.reduced_word() for v in W.one().bruhat_lower_covers()])
+ sage: print([v.reduced_word() # optional - sage.combinat sage.groups
+ ....: for v in W.one().bruhat_lower_covers()])
[]
- sage: W = WeylGroup(["B",4,1])
- sage: w = W.from_reduced_word([0,2])
- sage: print([v.reduced_word() for v in w.bruhat_lower_covers()])
+ sage: W = WeylGroup(["B", 4, 1]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([0,2]) # optional - sage.combinat sage.groups
+ sage: print([v.reduced_word() for v in w.bruhat_lower_covers()]) # optional - sage.combinat sage.groups
[[2], [0]]
- sage: W = WeylGroup("A3",prefix="s",implementation="permutation")
- sage: [s1,s2,s3]=W.simple_reflections()
- sage: (s1*s2*s3*s1).bruhat_lower_covers()
+ sage: W = WeylGroup("A3", prefix="s", implementation="permutation") # optional - sage.combinat sage.groups
+ sage: s1, s2, s3 = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: (s1*s2*s3*s1).bruhat_lower_covers() # optional - sage.combinat sage.groups
[s2*s1*s3, s1*s2*s1, s1*s2*s3]
We now show how to construct the Bruhat poset::
- sage: W = WeylGroup(["A",3])
- sage: covers = tuple([u, v] for v in W for u in v.bruhat_lower_covers() )
- sage: P = Poset((W, covers), cover_relations = True)
- sage: P.show()
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: covers = tuple([u, v] # optional - sage.combinat sage.groups
+ ....: for v in W for u in v.bruhat_lower_covers())
+ sage: P = Poset((W, covers), cover_relations = True) # optional - sage.combinat sage.groups sage.graphs
+ sage: P.show() # optional - sage.combinat sage.groups sage.graphs
Alternatively, one can just use::
- sage: P = W.bruhat_poset()
+ sage: P = W.bruhat_poset() # optional - sage.combinat sage.groups sage.graphs
The algorithm is taken from Stembridge's 'coxeter/weyl' package for Maple.
"""
@@ -2193,21 +2214,21 @@ def bruhat_upper_covers(self):
EXAMPLES::
- sage: W = WeylGroup(['A',3,1], prefix="s")
- sage: w = W.from_reduced_word([1,2,1])
- sage: w.bruhat_upper_covers()
+ sage: W = WeylGroup(['A', 3, 1], prefix="s") # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([1,2,1]) # optional - sage.combinat sage.groups
+ sage: w.bruhat_upper_covers() # optional - sage.combinat sage.groups
[s1*s2*s1*s0, s1*s2*s0*s1, s0*s1*s2*s1, s3*s1*s2*s1, s2*s3*s1*s2, s1*s2*s3*s1]
- sage: W = WeylGroup(['A',3])
- sage: w = W.long_element()
- sage: w.bruhat_upper_covers()
+ sage: W = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: w = W.long_element() # optional - sage.combinat sage.groups
+ sage: w.bruhat_upper_covers() # optional - sage.combinat sage.groups
[]
- sage: W = WeylGroup(['A',3])
- sage: w = W.from_reduced_word([1,2,1])
- sage: S = [v for v in W if w in v.bruhat_lower_covers()]
- sage: C = w.bruhat_upper_covers()
- sage: set(S) == set(C)
+ sage: W = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([1,2,1]) # optional - sage.combinat sage.groups
+ sage: S = [v for v in W if w in v.bruhat_lower_covers()] # optional - sage.combinat sage.groups
+ sage: C = w.bruhat_upper_covers() # optional - sage.combinat sage.groups
+ sage: set(S) == set(C) # optional - sage.combinat sage.groups
True
"""
Covers = set()
@@ -2231,17 +2252,17 @@ def bruhat_lower_covers_reflections(self):
EXAMPLES::
- sage: W = WeylGroup(['A',3], prefix="s")
- sage: w = W.from_reduced_word([3,1,2,1])
- sage: w.bruhat_lower_covers_reflections()
+ sage: W = WeylGroup(['A', 3], prefix="s") # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,1,2,1]) # optional - sage.combinat sage.groups
+ sage: w.bruhat_lower_covers_reflections() # optional - sage.combinat sage.groups
[(s1*s2*s1, s1*s2*s3*s2*s1), (s3*s2*s1, s2), (s3*s1*s2, s1)]
TESTS:
Check bug discovered in :trac:`32669` is fixed::
- sage: W = CoxeterGroup(['A',3], implementation='permutation')
- sage: W.w0.bruhat_lower_covers_reflections()
+ sage: W = CoxeterGroup(['A', 3], implementation='permutation') # optional - sage.combinat sage.groups
+ sage: W.w0.bruhat_lower_covers_reflections() # optional - sage.combinat sage.groups
[((1,3,7,9)(2,11,6,10)(4,8,5,12), (2,5)(3,9)(4,6)(8,11)(10,12)),
((1,11)(3,10)(4,9)(5,7)(6,12), (1,4)(2,8)(3,5)(7,10)(9,11)),
((1,9,7,3)(2,10,6,11)(4,12,5,8), (1,7)(2,4)(5,6)(8,10)(11,12))]
@@ -2264,11 +2285,11 @@ def lower_cover_reflections(self, side='right'):
EXAMPLES::
- sage: W = WeylGroup(['A',3],prefix="s")
- sage: w = W.from_reduced_word([3,1,2,1])
- sage: w.lower_cover_reflections()
+ sage: W = WeylGroup(['A', 3],prefix="s") # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,1,2,1]) # optional - sage.combinat sage.groups
+ sage: w.lower_cover_reflections() # optional - sage.combinat sage.groups
[s1*s2*s3*s2*s1, s2, s1]
- sage: w.lower_cover_reflections(side='left')
+ sage: w.lower_cover_reflections(side='left') # optional - sage.combinat sage.groups
[s2*s3*s2, s3, s1]
"""
@@ -2287,10 +2308,11 @@ def bruhat_upper_covers_reflections(self):
EXAMPLES::
- sage: W = WeylGroup(['A',4], prefix="s")
- sage: w = W.from_reduced_word([3,1,2,1])
- sage: w.bruhat_upper_covers_reflections()
- [(s1*s2*s3*s2*s1, s3), (s2*s3*s1*s2*s1, s2*s3*s2), (s3*s4*s1*s2*s1, s4), (s4*s3*s1*s2*s1, s1*s2*s3*s4*s3*s2*s1)]
+ sage: W = WeylGroup(['A', 4], prefix="s") # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,1,2,1]) # optional - sage.combinat sage.groups
+ sage: w.bruhat_upper_covers_reflections() # optional - sage.combinat sage.groups
+ [(s1*s2*s3*s2*s1, s3), (s2*s3*s1*s2*s1, s2*s3*s2),
+ (s3*s4*s1*s2*s1, s4), (s4*s3*s1*s2*s1, s1*s2*s3*s4*s3*s2*s1)]
"""
Covers = set()
for i in self.parent().index_set():
@@ -2310,11 +2332,11 @@ def cover_reflections(self, side='right'):
EXAMPLES::
- sage: W = WeylGroup(['A',4], prefix="s")
- sage: w = W.from_reduced_word([3,1,2,1])
- sage: w.cover_reflections()
+ sage: W = WeylGroup(['A', 4], prefix="s") # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,1,2,1]) # optional - sage.combinat sage.groups
+ sage: w.cover_reflections() # optional - sage.combinat sage.groups
[s3, s2*s3*s2, s4, s1*s2*s3*s4*s3*s2*s1]
- sage: w.cover_reflections(side='left')
+ sage: w.cover_reflections(side='left') # optional - sage.combinat sage.groups
[s4, s2, s1*s2*s1, s3*s4*s3]
"""
@@ -2335,19 +2357,19 @@ def bruhat_le(self, other):
EXAMPLES::
- sage: W = WeylGroup(["A",3])
- sage: u = W.from_reduced_word([1,2,1])
- sage: v = W.from_reduced_word([1,2,3,2,1])
- sage: u.bruhat_le(u)
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: u = W.from_reduced_word([1,2,1]) # optional - sage.combinat sage.groups
+ sage: v = W.from_reduced_word([1,2,3,2,1]) # optional - sage.combinat sage.groups
+ sage: u.bruhat_le(u) # optional - sage.combinat sage.groups
True
- sage: u.bruhat_le(v)
+ sage: u.bruhat_le(v) # optional - sage.combinat sage.groups
True
- sage: v.bruhat_le(u)
+ sage: v.bruhat_le(u) # optional - sage.combinat sage.groups
False
- sage: v.bruhat_le(v)
+ sage: v.bruhat_le(v) # optional - sage.combinat sage.groups
True
- sage: s = W.simple_reflections()
- sage: s[1].bruhat_le(W.one())
+ sage: s = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: s[1].bruhat_le(W.one()) # optional - sage.combinat sage.groups
False
The implementation uses the equivalent condition that any
@@ -2368,19 +2390,21 @@ def bruhat_le(self, other):
We now run consistency tests with permutations and
:meth:`bruhat_lower_covers`::
- sage: W = WeylGroup(["A",3])
- sage: P4 = Permutations(4)
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: P4 = Permutations(4) # optional - sage.combinat sage.groups
sage: def P4toW(w): return W.from_reduced_word(w.reduced_word())
- sage: for u in P4:
+ sage: for u in P4: # optional - sage.combinat sage.groups
....: for v in P4:
....: assert u.bruhat_lequal(v) == P4toW(u).bruhat_le(P4toW(v))
- sage: W = WeylGroup(["B",3])
- sage: P = W.bruhat_poset() # This is built from bruhat_lower_covers
- sage: Q = Poset((W, attrcall("bruhat_le"))) # long time (10s)
- sage: all( u.bruhat_le(v) == P.is_lequal(u,v) for u in W for v in W ) # long time (7s)
+ sage: W = WeylGroup(["B", 3]) # optional - sage.combinat sage.groups
+ sage: P = W.bruhat_poset() # This is built from bruhat_lower_covers # optional - sage.combinat sage.groups sage.graphs
+ sage: Q = Poset((W, attrcall("bruhat_le"))) # long time (10s) # optional - sage.combinat sage.groups sage.graphs
+ sage: all(u.bruhat_le(v) == P.is_lequal(u,v) # long time (7s) # optional - sage.combinat sage.groups sage.graphs
+ ....: for u in W for v in W)
True
- sage: all( P.is_lequal(u,v) == Q.is_lequal(u,v) for u in W for v in W) # long time (9s)
+ sage: all(P.is_lequal(u,v) == Q.is_lequal(u,v) # long time (9s) # optional - sage.combinat sage.groups sage.graphs
+ ....: for u in W for v in W)
True
"""
if not have_same_parent(self, other):
@@ -2409,21 +2433,21 @@ def weak_le(self, other, side='right'):
EXAMPLES::
- sage: W = WeylGroup(["A",3])
- sage: u = W.from_reduced_word([1,2])
- sage: v = W.from_reduced_word([1,2,3,2])
- sage: u.weak_le(u)
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: u = W.from_reduced_word([1,2]) # optional - sage.combinat sage.groups
+ sage: v = W.from_reduced_word([1,2,3,2]) # optional - sage.combinat sage.groups
+ sage: u.weak_le(u) # optional - sage.combinat sage.groups
True
- sage: u.weak_le(v)
+ sage: u.weak_le(v) # optional - sage.combinat sage.groups
True
- sage: v.weak_le(u)
+ sage: v.weak_le(u) # optional - sage.combinat sage.groups
False
- sage: v.weak_le(v)
+ sage: v.weak_le(v) # optional - sage.combinat sage.groups
True
Comparison for left weak order is achieved with the option ``side``::
- sage: u.weak_le(v, side='left')
+ sage: u.weak_le(v, side='left') # optional - sage.combinat sage.groups
False
The implementation uses the equivalent condition that any
@@ -2439,10 +2463,10 @@ def weak_le(self, other, side='right'):
We now run consistency tests with permutations::
- sage: W = WeylGroup(["A",3])
- sage: P4 = Permutations(4)
- sage: def P4toW(w): return W.from_reduced_word(w.reduced_word())
- sage: for u in P4: # long time (5s on sage.math, 2011)
+ sage: W = WeylGroup(["A", 3]) # optional - sage.combinat sage.groups
+ sage: P4 = Permutations(4) # optional - sage.combinat sage.groups
+ sage: def P4toW(w): return W.from_reduced_word(w.reduced_word()) # optional - sage.combinat sage.groups
+ sage: for u in P4: # long time (5s on sage.math, 2011) # optional - sage.combinat sage.groups
....: for v in P4:
....: assert u.permutohedron_lequal(v) == P4toW(u).weak_le(P4toW(v))
....: assert u.permutohedron_lequal(v, side='left') == P4toW(u).weak_le(P4toW(v), side='left')
@@ -2475,29 +2499,29 @@ def weak_covers(self, side='right', index_set=None, positive=False):
EXAMPLES::
- sage: W = WeylGroup(['A',3])
- sage: w = W.from_reduced_word([3,2,1])
- sage: [x.reduced_word() for x in w.weak_covers()]
+ sage: W = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,2,1]) # optional - sage.combinat sage.groups
+ sage: [x.reduced_word() for x in w.weak_covers()] # optional - sage.combinat sage.groups
[[3, 2]]
To obtain instead elements that cover self, set ``positive=True``::
- sage: [x.reduced_word() for x in w.weak_covers(positive=True)]
+ sage: [x.reduced_word() for x in w.weak_covers(positive=True)] # optional - sage.combinat sage.groups
[[3, 1, 2, 1], [2, 3, 2, 1]]
To obtain covers for left weak order, set the option side to 'left'::
- sage: [x.reduced_word() for x in w.weak_covers(side='left')]
+ sage: [x.reduced_word() for x in w.weak_covers(side='left')] # optional - sage.combinat sage.groups
[[2, 1]]
- sage: w = W.from_reduced_word([3,2,3,1])
- sage: [x.reduced_word() for x in w.weak_covers()]
+ sage: w = W.from_reduced_word([3,2,3,1]) # optional - sage.combinat sage.groups
+ sage: [x.reduced_word() for x in w.weak_covers()] # optional - sage.combinat sage.groups
[[2, 3, 2], [3, 2, 1]]
- sage: [x.reduced_word() for x in w.weak_covers(side='left')]
+ sage: [x.reduced_word() for x in w.weak_covers(side='left')] # optional - sage.combinat sage.groups
[[3, 2, 1], [2, 3, 1]]
Covers w.r.t. a parabolic subgroup are obtained with the option ``index_set``::
- sage: [x.reduced_word() for x in w.weak_covers(index_set = [1,2])]
+ sage: [x.reduced_word() for x in w.weak_covers(index_set=[1,2])] # optional - sage.combinat sage.groups
[[2, 3, 2]]
"""
return [self.apply_simple_reflection(i, side=side)
@@ -2580,16 +2604,20 @@ def is_coxeter_sortable(self, c, sorting_word=None):
[2, 0, 1, 2, 0]
sage: w.is_coxeter_sortable(c)
True
- sage: W = CoxeterGroup(['A',3])
- sage: c = W.from_reduced_word([1,2,3])
- sage: len([w for w in W if w.is_coxeter_sortable(c)]) # number of c-sortable elements in A_3 (Catalan number)
+
+ sage: W = CoxeterGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: c = W.from_reduced_word([1,2,3]) # optional - sage.combinat sage.groups
+
+ Number of `c`-sortable elements in `A_3` (Catalan number)::
+
+ sage: len([w for w in W if w.is_coxeter_sortable(c)]) # optional - sage.combinat sage.groups
14
TESTS::
- sage: W = SymmetricGroup(3)
- sage: c = Permutation((1,2,3))
- sage: sorted(w for w in W if w.is_coxeter_sortable(c))
+ sage: W = SymmetricGroup(3) # optional - sage.combinat sage.groups
+ sage: c = Permutation((1,2,3)) # optional - sage.combinat sage.groups
+ sage: sorted(w for w in W if w.is_coxeter_sortable(c)) # optional - sage.combinat sage.groups
[(), (2,3), (1,2), (1,3,2), (1,3)]
"""
if hasattr(c, "reduced_word"):
@@ -2640,15 +2668,15 @@ def apply_demazure_product(self, element, side='right',
EXAMPLES::
- sage: W = WeylGroup(['C',4],prefix="s")
- sage: v = W.from_reduced_word([1,2,3,4,3,1])
- sage: v.apply_demazure_product([1,3,4,3,3])
+ sage: W = WeylGroup(['C', 4], prefix="s") # optional - sage.combinat sage.groups
+ sage: v = W.from_reduced_word([1,2,3,4,3,1]) # optional - sage.combinat sage.groups
+ sage: v.apply_demazure_product([1,3,4,3,3]) # optional - sage.combinat sage.groups
s4*s1*s2*s3*s4*s3*s1
- sage: v.apply_demazure_product([1,3,4,3],side='left')
+ sage: v.apply_demazure_product([1,3,4,3], side='left') # optional - sage.combinat sage.groups
s3*s4*s1*s2*s3*s4*s2*s3*s1
- sage: v.apply_demazure_product((1,3,4,3),side='left')
+ sage: v.apply_demazure_product((1,3,4,3), side='left') # optional - sage.combinat sage.groups
s3*s4*s1*s2*s3*s4*s2*s3*s1
- sage: v.apply_demazure_product(v)
+ sage: v.apply_demazure_product(v) # optional - sage.combinat sage.groups
s2*s3*s4*s1*s2*s3*s4*s2*s3*s2*s1
"""
@@ -2683,14 +2711,14 @@ def min_demazure_product_greater(self, element):
EXAMPLES::
- sage: W = WeylGroup(['A',4],prefix="s")
- sage: v = W.from_reduced_word([2,3,4,1,2])
- sage: u = W.from_reduced_word([2,3,2,1])
- sage: v.min_demazure_product_greater(u)
+ sage: W = WeylGroup(['A', 4], prefix="s") # optional - sage.combinat sage.groups
+ sage: v = W.from_reduced_word([2,3,4,1,2]) # optional - sage.combinat sage.groups
+ sage: u = W.from_reduced_word([2,3,2,1]) # optional - sage.combinat sage.groups
+ sage: v.min_demazure_product_greater(u) # optional - sage.combinat sage.groups
s4*s2
- sage: v.min_demazure_product_greater([2,3,2,1])
+ sage: v.min_demazure_product_greater([2,3,2,1]) # optional - sage.combinat sage.groups
s4*s2
- sage: v.min_demazure_product_greater((2,3,2,1))
+ sage: v.min_demazure_product_greater((2,3,2,1)) # optional - sage.combinat sage.groups
s4*s2
"""
@@ -2730,14 +2758,14 @@ def deodhar_factor_element(self, w, index_set):
EXAMPLES::
- sage: W = WeylGroup(['A',5],prefix="s")
- sage: v = W.from_reduced_word([5])
- sage: w = W.from_reduced_word([4,5,2,3,1,2])
- sage: v.deodhar_factor_element(w,[1,3,4])
+ sage: W = WeylGroup(['A', 5], prefix="s") # optional - sage.combinat sage.groups
+ sage: v = W.from_reduced_word([5]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([4,5,2,3,1,2]) # optional - sage.combinat sage.groups
+ sage: v.deodhar_factor_element(w, [1,3,4]) # optional - sage.combinat sage.groups
s3*s1
- sage: W = WeylGroup(['C',2])
- sage: w = W.from_reduced_word([2,1])
- sage: w.deodhar_factor_element(W.from_reduced_word([2]),[1])
+ sage: W = WeylGroup(['C', 2]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([2,1]) # optional - sage.combinat sage.groups
+ sage: w.deodhar_factor_element(W.from_reduced_word([2]),[1]) # optional - sage.combinat sage.groups
Traceback (most recent call last):
...
ValueError: [2, 1] is not of minimum length in its coset for the parabolic subgroup with index set [1]
@@ -2785,10 +2813,10 @@ def deodhar_lift_up(self, w, index_set):
EXAMPLES::
- sage: W = WeylGroup(['A',3],prefix="s")
- sage: v = W.from_reduced_word([1,2,3])
- sage: w = W.from_reduced_word([1,3,2])
- sage: v.deodhar_lift_up(w, [3])
+ sage: W = WeylGroup(['A', 3], prefix="s") # optional - sage.combinat sage.groups
+ sage: v = W.from_reduced_word([1,2,3]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([1,3,2]) # optional - sage.combinat sage.groups
+ sage: v.deodhar_lift_up(w, [3]) # optional - sage.combinat sage.groups
s1*s2*s3*s2
"""
vmin = self.coset_representative(index_set)
@@ -2819,10 +2847,10 @@ def deodhar_lift_down(self, w, index_set):
EXAMPLES::
- sage: W = WeylGroup(['A',3],prefix="s")
- sage: v = W.from_reduced_word([1,2,3,2])
- sage: w = W.from_reduced_word([3,2])
- sage: v.deodhar_lift_down(w, [3])
+ sage: W = WeylGroup(['A', 3], prefix="s") # optional - sage.combinat sage.groups
+ sage: v = W.from_reduced_word([1,2,3,2]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,2]) # optional - sage.combinat sage.groups
+ sage: v.deodhar_lift_down(w, [3]) # optional - sage.combinat sage.groups
s2*s3*s2
"""
@@ -2842,9 +2870,9 @@ def inversions_as_reflections(self):
EXAMPLES::
- sage: W = WeylGroup(['A',3], prefix="s")
- sage: w = W.from_reduced_word([3,1,2,1])
- sage: w.inversions_as_reflections()
+ sage: W = WeylGroup(['A', 3], prefix="s") # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,1,2,1]) # optional - sage.combinat sage.groups
+ sage: w.inversions_as_reflections() # optional - sage.combinat sage.groups
[s1, s1*s2*s1, s2, s1*s2*s3*s2*s1]
"""
i = self.first_descent()
@@ -2859,9 +2887,9 @@ def left_inversions_as_reflections(self):
EXAMPLES::
- sage: W = WeylGroup(['A',3], prefix="s")
- sage: w = W.from_reduced_word([3,1,2,1])
- sage: w.left_inversions_as_reflections()
+ sage: W = WeylGroup(['A', 3], prefix="s") # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,1,2,1]) # optional - sage.combinat sage.groups
+ sage: w.left_inversions_as_reflections() # optional - sage.combinat sage.groups
[s1, s3, s1*s2*s3*s2*s1, s2*s3*s2]
"""
return self.inverse().inversions_as_reflections()
@@ -2872,31 +2900,31 @@ def lower_covers(self, side='right', index_set=None):
INPUT:
- - side -- 'left' or 'right' (default: 'right')
- - index_set -- a list of indices or ``None``
+ - ``side`` -- ``'left'`` or ``'right'`` (default: ``'right'``)
+ - ``index_set`` -- a list of indices or ``None``
OUTPUT: a list
EXAMPLES::
- sage: W = WeylGroup(['A',3])
- sage: w = W.from_reduced_word([3,2,1])
- sage: [x.reduced_word() for x in w.lower_covers()]
+ sage: W = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([3,2,1]) # optional - sage.combinat sage.groups
+ sage: [x.reduced_word() for x in w.lower_covers()] # optional - sage.combinat sage.groups
[[3, 2]]
To obtain covers for left weak order, set the option side to 'left'::
- sage: [x.reduced_word() for x in w.lower_covers(side='left')]
+ sage: [x.reduced_word() for x in w.lower_covers(side='left')] # optional - sage.combinat sage.groups
[[2, 1]]
- sage: w = W.from_reduced_word([3,2,3,1])
- sage: [x.reduced_word() for x in w.lower_covers()]
+ sage: w = W.from_reduced_word([3,2,3,1]) # optional - sage.combinat sage.groups
+ sage: [x.reduced_word() for x in w.lower_covers()] # optional - sage.combinat sage.groups
[[2, 3, 2], [3, 2, 1]]
Covers w.r.t. a parabolic subgroup are obtained with the option ``index_set``::
- sage: [x.reduced_word() for x in w.lower_covers(index_set = [1,2])]
+ sage: [x.reduced_word() for x in w.lower_covers(index_set=[1,2])] # optional - sage.combinat sage.groups
[[2, 3, 2]]
- sage: [x.reduced_word() for x in w.lower_covers(side='left')]
+ sage: [x.reduced_word() for x in w.lower_covers(side='left')] # optional - sage.combinat sage.groups
[[3, 2, 1], [2, 3, 1]]
"""
return self.weak_covers(side=side, index_set=index_set,
@@ -2908,28 +2936,29 @@ def upper_covers(self, side='right', index_set=None):
INPUT:
- - side -- 'left' or 'right' (default: 'right')
- - index_set -- a list of indices or None
+ - ``side`` -- ``'left'`` or ``'right'`` (default: ``'right'``)
+ - ``index_set`` -- a list of indices or ``None``
OUTPUT: a list
EXAMPLES::
- sage: W = WeylGroup(['A',3])
- sage: w = W.from_reduced_word([2,3])
- sage: [x.reduced_word() for x in w.upper_covers()]
+ sage: W = WeylGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: w = W.from_reduced_word([2,3]) # optional - sage.combinat sage.groups
+ sage: [x.reduced_word() for x in w.upper_covers()] # optional - sage.combinat sage.groups
[[2, 3, 1], [2, 3, 2]]
To obtain covers for left weak order, set the option ``side`` to 'left'::
- sage: [x.reduced_word() for x in w.upper_covers(side='left')]
+ sage: [x.reduced_word() for x in w.upper_covers(side='left')] # optional - sage.combinat sage.groups
[[1, 2, 3], [2, 3, 2]]
Covers w.r.t. a parabolic subgroup are obtained with the option ``index_set``::
- sage: [x.reduced_word() for x in w.upper_covers(index_set = [1])]
+ sage: [x.reduced_word() for x in w.upper_covers(index_set=[1])] # optional - sage.combinat sage.groups
[[2, 3, 1]]
- sage: [x.reduced_word() for x in w.upper_covers(side='left', index_set = [1])]
+ sage: [x.reduced_word() # optional - sage.combinat sage.groups
+ ....: for x in w.upper_covers(side='left', index_set=[1])]
[[1, 2, 3]]
"""
return self.weak_covers(side=side, index_set=index_set,
@@ -2972,9 +3001,9 @@ def kazhdan_lusztig_cell(self, side='left'):
choice of implementation affects the representation of elements in
the output cell but not the method used for the cell computation::
- sage: W = CoxeterGroup('A3', implementation='permutation')
- sage: s1,s2,s3 = W.simple_reflections()
- sage: s1.kazhdan_lusztig_cell()
+ sage: W = CoxeterGroup('A3', implementation='permutation') # optional - sage.combinat sage.groups
+ sage: s1, s2, s3 = W.simple_reflections() # optional - sage.combinat sage.groups
+ sage: s1.kazhdan_lusztig_cell() # optional - sage.combinat sage.groups
{(1,2,3,12)(4,5,10,11)(6,7,8,9),
(1,2,10)(3,6,5)(4,7,8)(9,12,11),
(1,7)(2,4)(5,6)(8,10)(11,12)}
diff --git a/src/sage/categories/crystals.py b/src/sage/categories/crystals.py
index f74340cf25d..3ceb16529d6 100644
--- a/src/sage/categories/crystals.py
+++ b/src/sage/categories/crystals.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.graphs sage.combinat
r"""
Crystals
diff --git a/src/sage/categories/discrete_valuation.py b/src/sage/categories/discrete_valuation.py
index 5b68f8b6c12..42829732859 100644
--- a/src/sage/categories/discrete_valuation.py
+++ b/src/sage/categories/discrete_valuation.py
@@ -20,7 +20,7 @@ class DiscreteValuationRings(Category_singleton):
EXAMPLES::
- sage: GF(7)[['x']] in DiscreteValuationRings()
+ sage: GF(7)[['x']] in DiscreteValuationRings() # optional - sage.rings.finite_rings
True
sage: TestSuite(DiscreteValuationRings()).run()
"""
@@ -41,7 +41,7 @@ def uniformizer(self):
EXAMPLES::
- sage: Zp(5).uniformizer()
+ sage: Zp(5).uniformizer() # optional - sage.rings.padics
5 + O(5^21)
sage: K. = QQ[[]]
@@ -56,7 +56,7 @@ def residue_field(self):
EXAMPLES::
- sage: Zp(5).residue_field()
+ sage: Zp(5).residue_field() # optional - sage.rings.padics
Finite Field of size 5
sage: K. = QQ[[]]
@@ -70,38 +70,38 @@ def _matrix_charpoly(self, M, var):
EXAMPLES::
- sage: R. = PowerSeriesRing(GF(5))
- sage: M = matrix(4, 4, [ (t^(i+j)).add_bigoh(10)
- ....: for i in range(4) for j in range(4) ])
- sage: M
+ sage: R. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings
+ sage: M = matrix(4, 4, [(t^(i+j)).add_bigoh(10) # optional - sage.rings.finite_rings
+ ....: for i in range(4) for j in range(4)])
+ sage: M # optional - sage.rings.finite_rings
[ 1 + O(t^10) t + O(t^10) t^2 + O(t^10) t^3 + O(t^10)]
[ t + O(t^10) t^2 + O(t^10) t^3 + O(t^10) t^4 + O(t^10)]
[t^2 + O(t^10) t^3 + O(t^10) t^4 + O(t^10) t^5 + O(t^10)]
[t^3 + O(t^10) t^4 + O(t^10) t^5 + O(t^10) t^6 + O(t^10)]
- sage: M.charpoly() # indirect doctest
+ sage: M.charpoly() # indirect doctest # optional - sage.rings.finite_rings
x^4 + (4 + 4*t^2 + 4*t^4 + 4*t^6 + O(t^10))*x^3
Note that this function uses a Hessenberg-like algorithm
that performs divisions. Hence, truncations may show up
even if the input matrix is exact::
- sage: M = matrix(3, 3, [ 1, t, t^2, 1+t, t^2, t^3, t^2, t^3, t^4 ])
- sage: M
+ sage: M = matrix(3, 3, [ 1, t, t^2, 1+t, t^2, t^3, t^2, t^3, t^4 ]) # optional - sage.rings.finite_rings
+ sage: M # optional - sage.rings.finite_rings
[ 1 t t^2]
[1 + t t^2 t^3]
[ t^2 t^3 t^4]
- sage: M.charpoly()
+ sage: M.charpoly() # optional - sage.rings.finite_rings
x^3 + (4 + 4*t^2 + 4*t^4 + O(t^25))*x^2 + (4*t + O(t^24))*x
Another example over the p-adics::
- sage: R = Zp(5, print_mode="digits", prec=5)
- sage: M = matrix(R, 3, 3, range(9))
- sage: M
+ sage: R = Zp(5, print_mode="digits", prec=5) # optional - sage.rings.padics
+ sage: M = matrix(R, 3, 3, range(9)) # optional - sage.rings.padics
+ sage: M # optional - sage.rings.padics
[ 0 ...00001 ...00002]
[ ...00003 ...00004 ...000010]
[ ...00011 ...00012 ...00013]
- sage: M.charpoly()
+ sage: M.charpoly() # optional - sage.rings.padics
...00001*x^3 + ...44423*x^2 + ...44412*x + ...00000
"""
return M._charpoly_hessenberg(var)
@@ -114,8 +114,8 @@ def valuation(self):
EXAMPLES::
- sage: x = Zp(5)(50)
- sage: x.valuation()
+ sage: x = Zp(5)(50) # optional - sage.rings.padics
+ sage: x.valuation() # optional - sage.rings.padics
2
"""
@@ -125,10 +125,10 @@ def euclidean_degree(self):
TESTS::
- sage: R. = GF(5)[[]]
- sage: (q^3).euclidean_degree()
+ sage: R. = GF(5)[[]] # optional - sage.rings.finite_rings
+ sage: (q^3).euclidean_degree() # optional - sage.rings.finite_rings
3
- sage: R(0).euclidean_degree()
+ sage: R(0).euclidean_degree() # optional - sage.rings.finite_rings
Traceback (most recent call last):
...
ValueError: Euclidean degree of the zero element not defined
@@ -145,12 +145,12 @@ def quo_rem(self, other):
TESTS::
- sage: R. = GF(5)[[]]
- sage: (q^2 + q).quo_rem(q)
+ sage: R. = GF(5)[[]] # optional - sage.rings.finite_rings
+ sage: (q^2 + q).quo_rem(q) # optional - sage.rings.finite_rings
(1 + q, 0)
- sage: (q + 1).quo_rem(q^2)
+ sage: (q + 1).quo_rem(q^2) # optional - sage.rings.finite_rings
(0, 1 + q)
- sage: q.quo_rem(0)
+ sage: q.quo_rem(0) # optional - sage.rings.finite_rings
Traceback (most recent call last):
...
ZeroDivisionError: Euclidean division by the zero element not defined
@@ -170,12 +170,12 @@ def is_unit(self):
EXAMPLES::
- sage: x = Zp(5)(50)
- sage: x.is_unit()
+ sage: x = Zp(5)(50) # optional - sage.rings.padics
+ sage: x.is_unit() # optional - sage.rings.padics
False
- sage: x = Zp(7)(50)
- sage: x.is_unit()
+ sage: x = Zp(7)(50) # optional - sage.rings.padics
+ sage: x.is_unit() # optional - sage.rings.padics
True
"""
return self.valuation() == 0
@@ -213,7 +213,7 @@ class DiscreteValuationFields(Category_singleton):
EXAMPLES::
- sage: Qp(7) in DiscreteValuationFields()
+ sage: Qp(7) in DiscreteValuationFields() # optional - sage.rings.padics
True
sage: TestSuite(DiscreteValuationFields()).run()
"""
@@ -235,7 +235,7 @@ def uniformizer(self):
EXAMPLES::
- sage: Qp(5).uniformizer()
+ sage: Qp(5).uniformizer() # optional - sage.rings.padics
5 + O(5^21)
"""
@@ -247,7 +247,7 @@ def residue_field(self):
EXAMPLES::
- sage: Qp(5).residue_field()
+ sage: Qp(5).residue_field() # optional - sage.rings.padics
Finite Field of size 5
sage: K. = LaurentSeriesRing(QQ)
@@ -261,17 +261,17 @@ def _matrix_hessenbergize(self, H):
EXAMPLES::
- sage: R. = PowerSeriesRing(GF(5))
- sage: K = R.fraction_field()
- sage: H = matrix(K, 4, 4, [ (t^(i+j)).add_bigoh(10)
- ....: for i in range(4) for j in range(4) ])
- sage: H
+ sage: R. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings
+ sage: K = R.fraction_field() # optional - sage.rings.finite_rings
+ sage: H = matrix(K, 4, 4, [(t^(i+j)).add_bigoh(10) # optional - sage.rings.finite_rings
+ ....: for i in range(4) for j in range(4)])
+ sage: H # optional - sage.rings.finite_rings
[ 1 + O(t^10) t + O(t^10) t^2 + O(t^10) t^3 + O(t^10)]
[ t + O(t^10) t^2 + O(t^10) t^3 + O(t^10) t^4 + O(t^10)]
[t^2 + O(t^10) t^3 + O(t^10) t^4 + O(t^10) t^5 + O(t^10)]
[t^3 + O(t^10) t^4 + O(t^10) t^5 + O(t^10) t^6 + O(t^10)]
- sage: H.hessenbergize()
- sage: H
+ sage: H.hessenbergize() # optional - sage.rings.finite_rings
+ sage: H # optional - sage.rings.finite_rings
[ 1 + O(t^10) t + t^3 + t^5 + O(t^10) t^2 + O(t^10) t^3 + O(t^10)]
[ t + O(t^10) t^2 + t^4 + t^6 + O(t^10) t^3 + O(t^10) t^4 + O(t^10)]
[ O(t^10) O(t^10) O(t^10) O(t^10)]
@@ -279,14 +279,14 @@ def _matrix_hessenbergize(self, H):
Another example over the p-adics::
- sage: K = Qp(5, print_mode="digits", prec=5)
- sage: H = matrix(K, 3, 3, range(9))
- sage: H
+ sage: K = Qp(5, print_mode="digits", prec=5) # optional - sage.rings.padics
+ sage: H = matrix(K, 3, 3, range(9)) # optional - sage.rings.padics
+ sage: H # optional - sage.rings.padics
[ 0 ...00001 ...00002]
[ ...00003 ...00004 ...000010]
[ ...00011 ...00012 ...00013]
- sage: H.hessenbergize()
- sage: H
+ sage: H.hessenbergize() # optional - sage.rings.padics
+ sage: H # optional - sage.rings.padics
[ 0 ...00010 ...00002]
[ ...00003 ...00024 ...000010]
[ ...00000 ...44440 ...44443]
@@ -302,7 +302,7 @@ def valuation(self):
EXAMPLES::
- sage: x = Qp(5)(50)
- sage: x.valuation()
+ sage: x = Qp(5)(50) # optional - sage.rings.padics
+ sage: x.valuation() # optional - sage.rings.padics
2
"""
diff --git a/src/sage/categories/domains.py b/src/sage/categories/domains.py
index c40f95ba880..02062390a02 100644
--- a/src/sage/categories/domains.py
+++ b/src/sage/categories/domains.py
@@ -59,21 +59,21 @@ def _test_zero_divisors(self, **options):
not have them in theory. For such inexact rings, these tests
are not performed::
- sage: R = ZpFM(5); R
+ sage: R = ZpFM(5); R # optional - sage.rings.padics
5-adic Ring of fixed modulus 5^20
- sage: R.is_exact()
+ sage: R.is_exact() # optional - sage.rings.padics
False
- sage: a = R(5^19)
- sage: a.is_zero()
+ sage: a = R(5^19) # optional - sage.rings.padics
+ sage: a.is_zero() # optional - sage.rings.padics
False
- sage: (a*a).is_zero()
+ sage: (a * a).is_zero() # optional - sage.rings.padics
True
- sage: R._test_zero_divisors()
+ sage: R._test_zero_divisors() # optional - sage.rings.padics
EXAMPLES::
sage: ZZ._test_zero_divisors()
- sage: ZpFM(5)._test_zero_divisors()
+ sage: ZpFM(5)._test_zero_divisors() # optional - sage.rings.padics
"""
if not self.is_exact():
diff --git a/src/sage/categories/drinfeld_modules.py b/src/sage/categories/drinfeld_modules.py
index 4a4f193bf1c..2ae9eb54173 100644
--- a/src/sage/categories/drinfeld_modules.py
+++ b/src/sage/categories/drinfeld_modules.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.rings.finite_rings
r"""
Drinfeld modules over a base
diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
index 1097a04412a..b58cb646aba 100644
--- a/src/sage/categories/enumerated_sets.py
+++ b/src/sage/categories/enumerated_sets.py
@@ -85,7 +85,8 @@ class EnumeratedSets(CategoryWithAxiom):
sage: EnumeratedSets().super_categories()
[Category of sets]
sage: EnumeratedSets().all_super_categories()
- [Category of enumerated sets, Category of sets, Category of sets with partial maps, Category of objects]
+ [Category of enumerated sets, Category of sets,
+ Category of sets with partial maps, Category of objects]
TESTS::
@@ -277,33 +278,33 @@ def iterator_range(self, start=None, stop=None, step=None):
EXAMPLES::
- sage: P = Partitions()
- sage: list(P.iterator_range(stop=5))
+ sage: P = Partitions() # optional - sage.combinat
+ sage: list(P.iterator_range(stop=5)) # optional - sage.combinat
[[], [1], [2], [1, 1], [3]]
- sage: list(P.iterator_range(0, 5))
+ sage: list(P.iterator_range(0, 5)) # optional - sage.combinat
[[], [1], [2], [1, 1], [3]]
- sage: list(P.iterator_range(3, 5))
+ sage: list(P.iterator_range(3, 5)) # optional - sage.combinat
[[1, 1], [3]]
- sage: list(P.iterator_range(3, 10))
+ sage: list(P.iterator_range(3, 10)) # optional - sage.combinat
[[1, 1], [3], [2, 1], [1, 1, 1], [4], [3, 1], [2, 2]]
- sage: list(P.iterator_range(3, 10, 2))
+ sage: list(P.iterator_range(3, 10, 2)) # optional - sage.combinat
[[1, 1], [2, 1], [4], [2, 2]]
- sage: it = P.iterator_range(3)
- sage: [next(it) for x in range(10)]
+ sage: it = P.iterator_range(3) # optional - sage.combinat
+ sage: [next(it) for x in range(10)] # optional - sage.combinat
[[1, 1],
[3], [2, 1], [1, 1, 1],
[4], [3, 1], [2, 2], [2, 1, 1], [1, 1, 1, 1],
[5]]
- sage: it = P.iterator_range(3, step=2)
- sage: [next(it) for x in range(5)]
+ sage: it = P.iterator_range(3, step=2) # optional - sage.combinat
+ sage: [next(it) for x in range(5)] # optional - sage.combinat
[[1, 1],
[2, 1],
[4], [2, 2], [1, 1, 1, 1]]
- sage: next(P.iterator_range(stop=-3))
+ sage: next(P.iterator_range(stop=-3)) # optional - sage.combinat
Traceback (most recent call last):
...
NotImplementedError: cannot list an infinite set
- sage: next(P.iterator_range(start=-3))
+ sage: next(P.iterator_range(start=-3)) # optional - sage.combinat
Traceback (most recent call last):
...
NotImplementedError: cannot list an infinite set
@@ -356,26 +357,26 @@ def unrank_range(self, start=None, stop=None, step=None):
EXAMPLES::
- sage: P = Partitions()
- sage: P.unrank_range(stop=5)
+ sage: P = Partitions() # optional - sage.combinat
+ sage: P.unrank_range(stop=5) # optional - sage.combinat
[[], [1], [2], [1, 1], [3]]
- sage: P.unrank_range(0, 5)
+ sage: P.unrank_range(0, 5) # optional - sage.combinat
[[], [1], [2], [1, 1], [3]]
- sage: P.unrank_range(3, 5)
+ sage: P.unrank_range(3, 5) # optional - sage.combinat
[[1, 1], [3]]
- sage: P.unrank_range(3, 10)
+ sage: P.unrank_range(3, 10) # optional - sage.combinat
[[1, 1], [3], [2, 1], [1, 1, 1], [4], [3, 1], [2, 2]]
- sage: P.unrank_range(3, 10, 2)
+ sage: P.unrank_range(3, 10, 2) # optional - sage.combinat
[[1, 1], [2, 1], [4], [2, 2]]
- sage: P.unrank_range(3)
+ sage: P.unrank_range(3) # optional - sage.combinat
Traceback (most recent call last):
...
NotImplementedError: cannot list an infinite set
- sage: P.unrank_range(stop=-3)
+ sage: P.unrank_range(stop=-3) # optional - sage.combinat
Traceback (most recent call last):
...
NotImplementedError: cannot list an infinite set
- sage: P.unrank_range(start=-3)
+ sage: P.unrank_range(start=-3) # optional - sage.combinat
Traceback (most recent call last):
...
NotImplementedError: cannot list an infinite set
@@ -409,24 +410,24 @@ def __getitem__(self, i):
EXAMPLES::
- sage: P = Partitions()
- sage: P[:5]
+ sage: P = Partitions() # optional - sage.combinat
+ sage: P[:5] # optional - sage.combinat
[[], [1], [2], [1, 1], [3]]
- sage: P[0:5]
+ sage: P[0:5] # optional - sage.combinat
[[], [1], [2], [1, 1], [3]]
- sage: P[3:5]
+ sage: P[3:5] # optional - sage.combinat
[[1, 1], [3]]
- sage: P[3:10]
+ sage: P[3:10] # optional - sage.combinat
[[1, 1], [3], [2, 1], [1, 1, 1], [4], [3, 1], [2, 2]]
- sage: P[3:10:2]
+ sage: P[3:10:2] # optional - sage.combinat
[[1, 1], [2, 1], [4], [2, 2]]
- sage: P[3:]
+ sage: P[3:] # optional - sage.combinat
Traceback (most recent call last):
...
NotImplementedError: cannot list an infinite set
- sage: P[3]
+ sage: P[3] # optional - sage.combinat
[1, 1]
- sage: P[-1]
+ sage: P[-1] # optional - sage.combinat
Traceback (most recent call last):
...
NotImplementedError: cannot list an infinite set
@@ -467,9 +468,9 @@ def __len__(self):
EXAMPLES::
- sage: len(GF(5))
+ sage: len(GF(5)) # optional - sage.libs.pari
5
- sage: len(MatrixSpace(GF(2), 3, 3))
+ sage: len(MatrixSpace(GF(2), 3, 3)) # optional - sage.libs.pari sage.modules
512
"""
from sage.rings.infinity import Infinity
@@ -494,7 +495,7 @@ def tuple(self):
EXAMPLES::
- sage: (GF(3)^2).tuple()
+ sage: (GF(3)^2).tuple() # optional - sage.libs.pari
((0, 0), (1, 0), (2, 0), (0, 1), (1, 1), (2, 1), (0, 2), (1, 2), (2, 2))
sage: R = Integers(11)
sage: l = R.tuple(); l
@@ -575,7 +576,7 @@ def list(self):
EXAMPLES::
- sage: (GF(3)^2).list()
+ sage: (GF(3)^2).list() # optional - sage.libs.pari
[(0, 0), (1, 0), (2, 0), (0, 1), (1, 1), (2, 1), (0, 2), (1, 2), (2, 2)]
sage: R = Integers(11)
sage: R.list()
@@ -603,7 +604,7 @@ def _list_from_iterator(self):
Trying to list an infinite vector space raises an error
instead of running forever (see :trac:`10470`)::
- sage: (QQ^2).list() # indirect test
+ sage: (QQ^2).list() # indirect test # optional - sage.modules
Traceback (most recent call last):
...
AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
@@ -958,16 +959,16 @@ def map(self, f, name=None, *, is_injective=True):
EXAMPLES::
- sage: R = Compositions(4).map(attrcall('partial_sums')); R
+ sage: R = Compositions(4).map(attrcall('partial_sums')); R # optional - sage.combinat
Image of Compositions of 4 by The map *.partial_sums()
from Compositions of 4
- sage: R.cardinality()
+ sage: R.cardinality() # optional - sage.combinat
8
- sage: R.list()
+ sage: R.list() # optional - sage.combinat
[[1, 2, 3, 4], [1, 2, 4], [1, 3, 4], [1, 4], [2, 3, 4], [2, 4], [3, 4], [4]]
- sage: [r for r in R]
+ sage: [r for r in R] # optional - sage.combinat
[[1, 2, 3, 4], [1, 2, 4], [1, 3, 4], [1, 4], [2, 3, 4], [2, 4], [3, 4], [4]]
- sage: R.category()
+ sage: R.category() # optional - sage.combinat
Category of finite enumerated subobjects of sets
.. WARNING::
@@ -975,20 +976,20 @@ def map(self, f, name=None, *, is_injective=True):
If the function is not injective, then there may be
repeated elements::
- sage: P = Compositions(4)
- sage: P.list()
+ sage: P = Compositions(4) # optional - sage.combinat
+ sage: P.list() # optional - sage.combinat
[[1, 1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 3], [2, 1, 1], [2, 2], [3, 1], [4]]
- sage: P.map(attrcall('major_index')).list()
+ sage: P.map(attrcall('major_index')).list() # optional - sage.combinat
[6, 3, 4, 1, 5, 2, 3, 0]
Pass ``is_injective=False`` to get a correct result in this case::
- sage: P.map(attrcall('major_index'), is_injective=False).list()
+ sage: P.map(attrcall('major_index'), is_injective=False).list() # optional - sage.combinat
[6, 3, 4, 1, 5, 2, 0]
TESTS::
- sage: TestSuite(R).run(skip=['_test_an_element',
+ sage: TestSuite(R).run(skip=['_test_an_element', # optional - sage.combinat
....: '_test_enumerated_set_contains',
....: '_test_some_elements'])
"""
diff --git a/src/sage/categories/examples/algebras_with_basis.py b/src/sage/categories/examples/algebras_with_basis.py
index f1d05839e2a..ccbc3a3a9c0 100644
--- a/src/sage/categories/examples/algebras_with_basis.py
+++ b/src/sage/categories/examples/algebras_with_basis.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat
r"""
Examples of algebras with basis
"""
diff --git a/src/sage/categories/examples/crystals.py b/src/sage/categories/examples/crystals.py
index 02121cd3c02..c38117b3b70 100644
--- a/src/sage/categories/examples/crystals.py
+++ b/src/sage/categories/examples/crystals.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat sage.graphs
r"""
Example of a crystal
"""
diff --git a/src/sage/categories/examples/filtered_modules_with_basis.py b/src/sage/categories/examples/filtered_modules_with_basis.py
index 0b5e9b475eb..3cf9db3f57c 100644
--- a/src/sage/categories/examples/filtered_modules_with_basis.py
+++ b/src/sage/categories/examples/filtered_modules_with_basis.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# sage.doctest: optional - sage.combinat
r"""
Examples of filtered modules with basis
"""
diff --git a/src/sage/categories/examples/finite_coxeter_groups.py b/src/sage/categories/examples/finite_coxeter_groups.py
index c7937688ef8..57ada2a0c2b 100644
--- a/src/sage/categories/examples/finite_coxeter_groups.py
+++ b/src/sage/categories/examples/finite_coxeter_groups.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat sage.groups
r"""
Examples of finite Coxeter groups
"""
diff --git a/src/sage/categories/examples/finite_dimensional_algebras_with_basis.py b/src/sage/categories/examples/finite_dimensional_algebras_with_basis.py
index f51b66c49dd..ac18f69b6ec 100644
--- a/src/sage/categories/examples/finite_dimensional_algebras_with_basis.py
+++ b/src/sage/categories/examples/finite_dimensional_algebras_with_basis.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.modules
r"""
Example of a finite dimensional algebra with basis
"""
diff --git a/src/sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py b/src/sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py
index a975d902e14..db28f48dff7 100644
--- a/src/sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py
+++ b/src/sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.modules
r"""
Examples of a finite dimensional Lie algebra with basis
"""
diff --git a/src/sage/categories/examples/finite_semigroups.py b/src/sage/categories/examples/finite_semigroups.py
index e21a9713815..bf00b415b58 100644
--- a/src/sage/categories/examples/finite_semigroups.py
+++ b/src/sage/categories/examples/finite_semigroups.py
@@ -25,7 +25,8 @@ class LeftRegularBand(UniqueRepresentation, Parent):
EXAMPLES::
sage: S = FiniteSemigroups().example(); S
- An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c', 'd')
+ An example of a finite semigroup:
+ the left regular band generated by ('a', 'b', 'c', 'd')
This is the semigroup generated by::
@@ -69,9 +70,9 @@ class LeftRegularBand(UniqueRepresentation, Parent):
Now, let us look at the structure of the semigroup::
sage: S = FiniteSemigroups().example(alphabet = ('a','b','c'))
- sage: S.cayley_graph(side="left", simple=True).plot()
+ sage: S.cayley_graph(side="left", simple=True).plot() # optional - sage.graphs
Graphics object consisting of 60 graphics primitives
- sage: S.j_transversal_of_idempotents() # random (arbitrary choice)
+ sage: S.j_transversal_of_idempotents() # random (arbitrary choice) # optional - sage.graphs
['acb', 'ac', 'ab', 'bc', 'a', 'c', 'b']
We conclude by running systematic tests on this semigroup::
diff --git a/src/sage/categories/examples/finite_weyl_groups.py b/src/sage/categories/examples/finite_weyl_groups.py
index 535d5101101..b4d6c05a233 100644
--- a/src/sage/categories/examples/finite_weyl_groups.py
+++ b/src/sage/categories/examples/finite_weyl_groups.py
@@ -59,7 +59,7 @@ class SymmetricGroup(UniqueRepresentation, Parent):
24
sage: S.long_element()
(3, 2, 1, 0)
- sage: S.cayley_graph(side = "left").plot()
+ sage: S.cayley_graph(side="left").plot() # optional - sage.graphs sage.plot
Graphics object consisting of 120 graphics primitives
Alternatively, one could have implemented
@@ -69,7 +69,7 @@ class SymmetricGroup(UniqueRepresentation, Parent):
TESTS::
- sage: TestSuite(S).run()
+ sage: TestSuite(S).run() # optional - sage.combinat
"""
def __init__(self, n=4):
@@ -135,7 +135,7 @@ def cartan_type(self):
EXAMPLES::
- sage: FiniteWeylGroups().example().cartan_type()
+ sage: FiniteWeylGroups().example().cartan_type() # optional - sage.combinat
['A', 3] relabelled by {1: 0, 2: 1, 3: 2}
"""
from sage.combinat.root_system.cartan_type import CartanType
diff --git a/src/sage/categories/examples/graded_connected_hopf_algebras_with_basis.py b/src/sage/categories/examples/graded_connected_hopf_algebras_with_basis.py
index b67e01a4b02..2d2a0f71f4b 100644
--- a/src/sage/categories/examples/graded_connected_hopf_algebras_with_basis.py
+++ b/src/sage/categories/examples/graded_connected_hopf_algebras_with_basis.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.modules
r"""
Examples of graded connected Hopf algebras with basis
"""
diff --git a/src/sage/categories/examples/graded_modules_with_basis.py b/src/sage/categories/examples/graded_modules_with_basis.py
index 0be39623fa3..86aa957c404 100644
--- a/src/sage/categories/examples/graded_modules_with_basis.py
+++ b/src/sage/categories/examples/graded_modules_with_basis.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# sage.doctest: optional - sage.combinat
r"""
Examples of graded modules with basis
"""
diff --git a/src/sage/categories/examples/hopf_algebras_with_basis.py b/src/sage/categories/examples/hopf_algebras_with_basis.py
index 35b61f3c085..265ab46836f 100644
--- a/src/sage/categories/examples/hopf_algebras_with_basis.py
+++ b/src/sage/categories/examples/hopf_algebras_with_basis.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.modules
r"""
Examples of Hopf algebras with basis
"""
diff --git a/src/sage/categories/examples/lie_algebras.py b/src/sage/categories/examples/lie_algebras.py
index 135a665cfa3..81c7f8457ab 100644
--- a/src/sage/categories/examples/lie_algebras.py
+++ b/src/sage/categories/examples/lie_algebras.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.modules
r"""
Examples of a Lie algebra
"""
@@ -68,11 +69,11 @@ def __classcall_private__(cls, gens):
EXAMPLES::
- sage: S3 = SymmetricGroupAlgebra(QQ, 3)
- sage: L1 = LieAlgebras(QQ).example()
- sage: gens = list(S3.algebra_generators())
- sage: L2 = LieAlgebras(QQ).example(gens)
- sage: L1 is L2
+ sage: S3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.combinat
+ sage: L1 = LieAlgebras(QQ).example() # optional - sage.combinat
+ sage: gens = list(S3.algebra_generators()) # optional - sage.combinat
+ sage: L2 = LieAlgebras(QQ).example(gens) # optional - sage.combinat
+ sage: L1 is L2 # optional - sage.combinat
True
"""
return super().__classcall__(cls, tuple(gens))
@@ -81,8 +82,8 @@ def __init__(self, gens):
"""
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: TestSuite(L).run()
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat
+ sage: TestSuite(L).run() # optional - sage.combinat
"""
if not gens:
raise ValueError("need at least one generator")
@@ -95,7 +96,7 @@ def _repr_(self):
"""
EXAMPLES::
- sage: LieAlgebras(QQ).example()
+ sage: LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
An example of a Lie algebra: the Lie algebra from the associative algebra
Symmetric group algebra of order 3 over Rational Field
generated by ([2, 1, 3], [2, 3, 1])
@@ -110,10 +111,10 @@ def _element_constructor_(self, value):
EXAMPLES::
- sage: S3 = SymmetricGroupAlgebra(ZZ, 3)
- sage: gens = S3.algebra_generators()
- sage: L = LieAlgebras(QQ).example()
- sage: L(3*gens[0] + gens[1])
+ sage: S3 = SymmetricGroupAlgebra(ZZ, 3) # optional - sage.combinat sage.groups
+ sage: gens = S3.algebra_generators() # optional - sage.combinat sage.groups
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: L(3*gens[0] + gens[1]) # optional - sage.combinat sage.groups
3*[2, 1, 3] + [2, 3, 1]
"""
return self.element_class(self, self._A(value))
@@ -124,8 +125,8 @@ def zero(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: L.zero()
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: L.zero() # optional - sage.combinat sage.groups
0
"""
return self.element_class(self, self._A.zero())
@@ -136,8 +137,8 @@ def lie_algebra_generators(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: L.lie_algebra_generators()
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: L.lie_algebra_generators() # optional - sage.combinat sage.groups
Family ([2, 1, 3], [2, 3, 1])
"""
return Family([self.element_class(self, g) for g in self._gens])
@@ -157,17 +158,17 @@ def __eq__(self, rhs):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: x == x
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.groups
+ sage: x == x # optional - sage.combinat sage.groups
True
- sage: x.bracket(y) == -y.bracket(x)
+ sage: x.bracket(y) == -y.bracket(x) # optional - sage.combinat sage.groups
True
- sage: x == y
+ sage: x == y # optional - sage.combinat sage.groups
False
- sage: x.bracket(x) == L.zero()
+ sage: x.bracket(x) == L.zero() # optional - sage.combinat sage.groups
True
- sage: x.bracket(x) == 0
+ sage: x.bracket(x) == 0 # optional - sage.combinat sage.groups
True
"""
if not isinstance(rhs, LieAlgebraFromAssociative.Element):
@@ -180,15 +181,15 @@ def __ne__(self, rhs):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: x != y
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.groups
+ sage: x != y # optional - sage.combinat sage.groups
True
- sage: x != 0
+ sage: x != 0 # optional - sage.combinat sage.groups
True
- sage: x != x
+ sage: x != x # optional - sage.combinat sage.groups
False
- sage: x.bracket(y) != -y.bracket(x)
+ sage: x.bracket(y) != -y.bracket(x) # optional - sage.combinat sage.groups
False
"""
return not self.__eq__(rhs)
@@ -199,10 +200,10 @@ def __bool__(self) -> bool:
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: bool(sum(L.lie_algebra_generators()))
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: bool(sum(L.lie_algebra_generators())) # optional - sage.combinat sage.groups
True
- sage: bool(L.zero())
+ sage: bool(L.zero()) # optional - sage.combinat sage.groups
False
"""
return bool(self.value)
@@ -213,9 +214,9 @@ def _add_(self, rhs):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: x + y
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.groups
+ sage: x + y # optional - sage.combinat sage.groups
[2, 1, 3] + [2, 3, 1]
"""
return self.__class__(self.parent(), self.value + rhs.value)
@@ -226,9 +227,9 @@ def _sub_(self, rhs):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: x - y
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.groups
+ sage: x - y # optional - sage.combinat sage.groups
[2, 1, 3] - [2, 3, 1]
"""
return self.__class__(self.parent(), self.value - rhs.value)
@@ -239,9 +240,9 @@ def _acted_upon_(self, scalar, self_on_left=False):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: 3 * x
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.groups
+ sage: 3 * x # optional - sage.combinat sage.groups
3*[2, 1, 3]
"""
# This was copied, but IDK if it still applies:
@@ -265,9 +266,9 @@ def __truediv__(self, x, self_on_left=False):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: y / 4
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.groups
+ sage: y / 4 # optional - sage.combinat sage.groups
1/4*[2, 3, 1]
"""
if self_on_left:
@@ -280,9 +281,9 @@ def __neg__(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: -x
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.groups
+ sage: -x # optional - sage.combinat sage.groups
-[2, 1, 3]
"""
return self.__class__(self.parent(), -self.value)
@@ -313,15 +314,15 @@ def _bracket_(self, rhs):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: elt = 2*x - y
- sage: elt.bracket(elt)
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.groups
+ sage: x,y = L.lie_algebra_generators() # optional - sage.combinat sage.groups
+ sage: elt = 2*x - y # optional - sage.combinat sage.groups
+ sage: elt.bracket(elt) # optional - sage.combinat sage.groups
0
- sage: elt.bracket(x)
+ sage: elt.bracket(x) # optional - sage.combinat sage.groups
-[1, 3, 2] + [3, 2, 1]
- sage: elt2 = x.bracket(y) + x
- sage: elt.bracket(elt2)
+ sage: elt2 = x.bracket(y) + x # optional - sage.combinat sage.groups
+ sage: elt.bracket(elt2) # optional - sage.combinat sage.groups
-2*[2, 1, 3] + 4*[2, 3, 1] - 4*[3, 1, 2] + 2*[3, 2, 1]
"""
return self.__class__(self.parent(), self.value * rhs.value - rhs.value * self.value)
diff --git a/src/sage/categories/examples/lie_algebras_with_basis.py b/src/sage/categories/examples/lie_algebras_with_basis.py
index 484e0eee918..e69711ddf03 100644
--- a/src/sage/categories/examples/lie_algebras_with_basis.py
+++ b/src/sage/categories/examples/lie_algebras_with_basis.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.modules
r"""
Examples of a Lie algebra with basis
"""
diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
index 19b1ef29ade..6f358929a72 100644
--- a/src/sage/categories/examples/sets_cat.py
+++ b/src/sage/categories/examples/sets_cat.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.libs.pari
"""
Examples of sets
"""
diff --git a/src/sage/categories/examples/with_realizations.py b/src/sage/categories/examples/with_realizations.py
index 7bc940dd289..627bd2a07c3 100644
--- a/src/sage/categories/examples/with_realizations.py
+++ b/src/sage/categories/examples/with_realizations.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat sage.modules
r"""
Examples of parents endowed with multiple realizations
"""
diff --git a/src/sage/categories/fields.py b/src/sage/categories/fields.py
index 4bbbd08ae95..28a93a314b5 100644
--- a/src/sage/categories/fields.py
+++ b/src/sage/categories/fields.py
@@ -38,7 +38,7 @@ class Fields(CategoryWithAxiom):
sage: K(IntegerRing())
Rational Field
- sage: K(PolynomialRing(GF(3), 'x'))
+ sage: K(PolynomialRing(GF(3), 'x')) # optional - sage.rings.finite_rings
Fraction Field of Univariate Polynomial Ring in x over
Finite Field of size 3
sage: K(RealField())
@@ -64,7 +64,7 @@ def __contains__(self, x):
"""
EXAMPLES::
- sage: GF(4, "a") in Fields()
+ sage: GF(4, "a") in Fields() # optional - sage.rings.finite_rings
True
sage: QQ in Fields()
True
@@ -81,15 +81,15 @@ def __contains__(self, x):
Caveat: this should eventually be fixed::
- sage: gap.Rationals in Fields()
+ sage: gap.Rationals in Fields() # optional - sage.libs.gap
False
typically by implementing the method :meth:`category`
appropriately for Gap objects::
- sage: GR = gap.Rationals
- sage: GR.category = lambda : Fields()
- sage: GR in Fields()
+ sage: GR = gap.Rationals # optional - sage.libs.gap
+ sage: GR.category = lambda: Fields() # optional - sage.libs.gap
+ sage: GR in Fields() # optional - sage.libs.gap
True
The following tests against a memory leak fixed in :trac:`13370`. In order
@@ -101,7 +101,7 @@ def __contains__(self, x):
sage: _ = gc.collect()
sage: permstore = [X for X in gc.get_objects() if isinstance(X, sage.rings.finite_rings.integer_mod_ring.IntegerModRing_generic)]
sage: n = len(permstore)
- sage: for i in prime_range(100):
+ sage: for i in prime_range(100): # optional - sage.libs.pari
....: R = ZZ.quotient(i)
....: t = R in Fields()
@@ -140,16 +140,16 @@ def _contains_helper(cls):
TESTS::
sage: P. = QQ[]
- sage: Q = P.quotient(x^2+2)
- sage: Q.category()
+ sage: Q = P.quotient(x^2 + 2) # optional - sage.libs.pari
+ sage: Q.category() # optional - sage.libs.pari
Category of commutative no zero divisors quotients of algebras
over (number fields and quotient fields and metric spaces)
sage: F = Fields()
- sage: F._contains_helper(Q)
+ sage: F._contains_helper(Q) # optional - sage.libs.pari
False
- sage: Q in F # This changes the category!
+ sage: Q in F # This changes the category! # optional - sage.libs.pari
True
- sage: F._contains_helper(Q)
+ sage: F._contains_helper(Q) # optional - sage.libs.pari
True
"""
@@ -169,7 +169,7 @@ def _call_(self, x):
sage: K(IntegerRing()) # indirect doctest
Rational Field
- sage: K(PolynomialRing(GF(3), 'x')) # indirect doctest
+ sage: K(PolynomialRing(GF(3), 'x')) # indirect doctest # optional - sage.rings.finite_rings
Fraction Field of Univariate Polynomial Ring in x over
Finite Field of size 3
sage: K(RealField())
@@ -207,11 +207,11 @@ def is_integrally_closed(self):
sage: QQ.is_integrally_closed()
True
- sage: QQbar.is_integrally_closed()
+ sage: QQbar.is_integrally_closed() # optional - sage.rings.number_field
True
- sage: Z5 = GF(5); Z5
+ sage: Z5 = GF(5); Z5 # optional - sage.rings.finite_rings
Finite Field of size 5
- sage: Z5.is_integrally_closed()
+ sage: Z5.is_integrally_closed() # optional - sage.rings.finite_rings
True
"""
return True
@@ -231,13 +231,15 @@ def _gcd_univariate_polynomial(self, a, b):
EXAMPLES::
- sage: R. = QQbar[]
- sage: QQbar._gcd_univariate_polynomial(2*x, 2*x^2)
+ sage: R. = QQbar[] # optional - sage.rings.number_field
+ sage: QQbar._gcd_univariate_polynomial(2*x, 2*x^2) # optional - sage.rings.number_field
x
TESTS::
- sage: for A in (RR, CC, QQbar):
+ sage: fields = [RR, CC]
+ sage: fields.append(QQbar) # optional - sage.rings.number_field
+ sage: for A in fields:
....: g = A._gcd_univariate_polynomial
....: R. = A[]
....: z = R.zero()
@@ -330,7 +332,9 @@ def _xgcd_univariate_polynomial(self, a, b):
TESTS::
- sage: for A in (RR, CC, QQbar):
+ sage: fields = [RR, CC]
+ sage: fields.append(QQbar) # optional - sage.rings.number_field
+ sage: for A in fields:
....: g = A._xgcd_univariate_polynomial
....: R. = A[]
....: z, h = R(0), R(1/2)
@@ -388,9 +392,9 @@ def is_perfect(self):
sage: QQ.is_perfect()
True
- sage: GF(2).is_perfect()
+ sage: GF(2).is_perfect() # optional - sage.rings.finite_rings
True
- sage: FunctionField(GF(2), 'x').is_perfect()
+ sage: FunctionField(GF(2), 'x').is_perfect() # optional - sage.rings.finite_rings
False
"""
@@ -464,11 +468,11 @@ def _squarefree_decomposition_univariate_polynomial(self, f):
sage: p = 37 * (x-2/3)^2
sage: p.squarefree_decomposition()
(37) * (x - 2/3)^2
- sage: x = polygen(GF(3))
- sage: x.squarefree_decomposition()
+ sage: x = polygen(GF(3)) # optional - sage.rings.finite_rings
+ sage: x.squarefree_decomposition() # optional - sage.rings.finite_rings
x
- sage: f = QQbar['x'](1)
- sage: f.squarefree_decomposition()
+ sage: f = QQbar['x'](1) # optional - sage.rings.number_field
+ sage: f.squarefree_decomposition() # optional - sage.rings.number_field
1
"""
from sage.structure.factorization import Factorization
@@ -525,10 +529,10 @@ def vector_space(self, *args, **kwds):
EXAMPLES::
- sage: K. = Qq(125) # optional - sage.rings.padics
- sage: V, fr, to = K.vector_space() # optional - sage.rings.padics
- sage: v = V([1, 2, 3]) # optional - sage.rings.padics
- sage: fr(v, 7) # optional - sage.rings.padics
+ sage: K. = Qq(125) # optional - sage.rings.padics
+ sage: V, fr, to = K.vector_space() # optional - sage.rings.padics
+ sage: v = V([1, 2, 3]) # optional - sage.rings.padics
+ sage: fr(v, 7) # optional - sage.rings.padics
(3*a^2 + 2*a + 1) + O(5^7)
"""
return self.free_module(*args, **kwds)
@@ -601,12 +605,13 @@ def gcd(self,other):
EXAMPLES::
- sage: K = GF(5)
- sage: K(2).gcd(K(1))
+ sage: K = GF(5) # optional - sage.rings.finite_rings
+ sage: K(2).gcd(K(1)) # optional - sage.rings.finite_rings
1
- sage: K(0).gcd(K(0))
+ sage: K(0).gcd(K(0)) # optional - sage.rings.finite_rings
0
- sage: all(x.gcd(y) == (0 if x == 0 and y == 0 else 1) for x in K for y in K)
+ sage: all(x.gcd(y) == (0 if x == 0 and y == 0 else 1) # optional - sage.rings.finite_rings
+ ....: for x in K for y in K)
True
For field of characteristic zero, the gcd of integers is considered
@@ -658,9 +663,9 @@ def lcm(self, other):
EXAMPLES::
- sage: GF(2)(1).lcm(GF(2)(0))
+ sage: GF(2)(1).lcm(GF(2)(0)) # optional - sage.rings.finite_rings
0
- sage: GF(2)(1).lcm(GF(2)(1))
+ sage: GF(2)(1).lcm(GF(2)(1)) # optional - sage.rings.finite_rings
1
For field of characteristic zero, the lcm of integers is considered
@@ -721,14 +726,14 @@ def xgcd(self, other):
EXAMPLES::
- sage: K = GF(5)
- sage: K(2).xgcd(K(1))
+ sage: K = GF(5) # optional - sage.rings.finite_rings
+ sage: K(2).xgcd(K(1)) # optional - sage.rings.finite_rings
(1, 3, 0)
- sage: K(0).xgcd(K(4))
+ sage: K(0).xgcd(K(4)) # optional - sage.rings.finite_rings
(1, 0, 4)
- sage: K(1).xgcd(K(1))
+ sage: K(1).xgcd(K(1)) # optional - sage.rings.finite_rings
(1, 1, 0)
- sage: GF(5)(0).xgcd(GF(5)(0))
+ sage: GF(5)(0).xgcd(GF(5)(0)) # optional - sage.rings.finite_rings
(0, 0, 0)
The xgcd of non-zero floating point numbers will be a triple of
@@ -772,8 +777,8 @@ def factor(self):
EXAMPLES::
- sage: x = GF(7)(5)
- sage: x.factor()
+ sage: x = GF(7)(5) # optional - sage.rings.finite_rings
+ sage: x.factor() # optional - sage.rings.finite_rings
5
sage: RR(0).factor()
Traceback (most recent call last):
@@ -791,7 +796,8 @@ def inverse_of_unit(self):
EXAMPLES::
- sage: NumberField(x^7+2,'a')(2).inverse_of_unit()
+ sage: x = polygen(ZZ, 'x')
+ sage: NumberField(x^7+2, 'a')(2).inverse_of_unit() # optional - sage.rings.number_field
1/2
Trying to invert the zero element typically raises a
diff --git a/src/sage/categories/filtered_hopf_algebras_with_basis.py b/src/sage/categories/filtered_hopf_algebras_with_basis.py
index 08888c78313..ca2dc9ac513 100644
--- a/src/sage/categories/filtered_hopf_algebras_with_basis.py
+++ b/src/sage/categories/filtered_hopf_algebras_with_basis.py
@@ -88,14 +88,14 @@ def antipode_on_basis(self, index):
TESTS::
- sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example()
- sage: H.monomial(0).antipode() # indirect doctest
+ sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example() # optional - sage.combinat
+ sage: H.monomial(0).antipode() # indirect doctest # optional - sage.combinat
P0
- sage: H.monomial(1).antipode() # indirect doctest
+ sage: H.monomial(1).antipode() # indirect doctest # optional - sage.combinat
-P1
- sage: H.monomial(2).antipode() # indirect doctest
+ sage: H.monomial(2).antipode() # indirect doctest # optional - sage.combinat
P2
- sage: H.monomial(3).antipode() # indirect doctest
+ sage: H.monomial(3).antipode() # indirect doctest # optional - sage.combinat
-P3
"""
if self.monomial(index) == self.one():
@@ -116,15 +116,15 @@ def antipode(self, elem):
TESTS::
- sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example()
- sage: H.antipode(H.monomial(14))
+ sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example() # optional - sage.combinat
+ sage: H.antipode(H.monomial(14)) # optional - sage.combinat
P14
- sage: H.monomial(0).antipode()
+ sage: H.monomial(0).antipode() # optional - sage.combinat
P0
- sage: H.monomial(2).antipode()
+ sage: H.monomial(2).antipode() # optional - sage.combinat
P2
- sage: (2*H.monomial(1) + 3*H.monomial(4)).antipode()
+ sage: (2*H.monomial(1) + 3*H.monomial(4)).antipode() # optional - sage.combinat
-2*P1 + 3*P4
"""
return self.linear_combination(
diff --git a/src/sage/categories/filtered_modules_with_basis.py b/src/sage/categories/filtered_modules_with_basis.py
index 336c1c326c8..7a9b2684f79 100644
--- a/src/sage/categories/filtered_modules_with_basis.py
+++ b/src/sage/categories/filtered_modules_with_basis.py
@@ -200,8 +200,10 @@ def homogeneous_component_basis(self, d):
sage: A = GradedModulesWithBasis(ZZ).example()
sage: A.homogeneous_component_basis(4)
- Lazy family (Term map from Partitions to An example of a graded module with basis:
- the free module on partitions over Integer Ring(i))_{i in Partitions of the integer 4}
+ Lazy family (Term map
+ from Partitions
+ to An example of a graded module with basis: the free module
+ on partitions over Integer Ring(i))_{i in Partitions of the integer 4}
sage: cat = GradedModulesWithBasis(ZZ)
sage: C = CombinatorialFreeModule(ZZ, ['a', 'b'], category=cat)
@@ -316,12 +318,12 @@ def to_graded_conversion(self):
EXAMPLES::
- sage: A = Modules(QQ).WithBasis().Filtered().example()
- sage: p = -2 * A.an_element(); p
+ sage: A = Modules(QQ).WithBasis().Filtered().example() # optional - sage.combinat
+ sage: p = -2 * A.an_element(); p # optional - sage.combinat
-4*P[] - 4*P[1] - 6*P[2]
- sage: q = A.to_graded_conversion()(p); q
+ sage: q = A.to_graded_conversion()(p); q # optional - sage.combinat
-4*Bbar[[]] - 4*Bbar[[1]] - 6*Bbar[[2]]
- sage: q.parent() is A.graded_algebra()
+ sage: q.parent() is A.graded_algebra() # optional - sage.combinat
True
"""
base_one = self.base_ring().one()
@@ -344,14 +346,14 @@ def from_graded_conversion(self):
EXAMPLES::
- sage: A = Modules(QQ).WithBasis().Filtered().example()
- sage: p = -2 * A.an_element(); p
+ sage: A = Modules(QQ).WithBasis().Filtered().example() # optional - sage.combinat
+ sage: p = -2 * A.an_element(); p # optional - sage.combinat
-4*P[] - 4*P[1] - 6*P[2]
- sage: q = A.to_graded_conversion()(p); q
+ sage: q = A.to_graded_conversion()(p); q # optional - sage.combinat
-4*Bbar[[]] - 4*Bbar[[1]] - 6*Bbar[[2]]
- sage: A.from_graded_conversion()(q) == p
+ sage: A.from_graded_conversion()(q) == p # optional - sage.combinat
True
- sage: q.parent() is A.graded_algebra()
+ sage: q.parent() is A.graded_algebra() # optional - sage.combinat
True
"""
base_one = self.base_ring().one()
@@ -376,14 +378,14 @@ def projection(self, i):
EXAMPLES::
- sage: A = Modules(ZZ).WithBasis().Filtered().example()
- sage: p = -2 * A.an_element(); p
+ sage: A = Modules(ZZ).WithBasis().Filtered().example() # optional - sage.combinat
+ sage: p = -2 * A.an_element(); p # optional - sage.combinat
-4*P[] - 4*P[1] - 6*P[2]
- sage: q = A.projection(2)(p); q
+ sage: q = A.projection(2)(p); q # optional - sage.combinat
-6*Bbar[[2]]
- sage: q.parent() is A.graded_algebra()
+ sage: q.parent() is A.graded_algebra() # optional - sage.combinat
True
- sage: A.projection(3)(p)
+ sage: A.projection(3)(p) # optional - sage.combinat
0
"""
base_zero = self.base_ring().zero()
@@ -437,50 +439,55 @@ def induced_graded_map(self, other, f):
We start with the free `\QQ`-module with basis the set of all
partitions::
- sage: A = Modules(QQ).WithBasis().Filtered().example(); A
+ sage: A = Modules(QQ).WithBasis().Filtered().example(); A # optional - sage.combinat
An example of a filtered module with basis: the free module
on partitions over Rational Field
- sage: M = A.indices(); M
+ sage: M = A.indices(); M # optional - sage.combinat
Partitions
- sage: p1, p2, p21, p321 = [A.basis()[Partition(i)] for i in [[1], [2], [2,1], [3,2,1]]]
+ sage: p1, p2, p21, p321 = [A.basis()[Partition(i)] # optional - sage.combinat
+ ....: for i in [[1], [2], [2,1], [3,2,1]]]
Let us define a map from ``A`` to itself which acts on the
basis by sending every partition `\lambda` to the sum of
the conjugates of all partitions `\mu` for which
`\lambda / \mu` is a horizontal strip::
- sage: def map_on_basis(lam):
- ....: return A.sum_of_monomials([Partition(mu).conjugate() for k in range(sum(lam) + 1)
- ....: for mu in lam.remove_horizontal_border_strip(k)])
- sage: f = A.module_morphism(on_basis=map_on_basis,
+ sage: def map_on_basis(lam): # optional - sage.combinat
+ ....: def mus(k):
+ ....: return lam.remove_horizontal_border_strip(k)
+ ....: return A.sum_of_monomials([Partition(mu).conjugate()
+ ....: for k in range(sum(lam) + 1)
+ ....: for mu in mus(k)])
+ sage: f = A.module_morphism(on_basis=map_on_basis, # optional - sage.combinat
....: codomain=A)
- sage: f(p1)
+ sage: f(p1) # optional - sage.combinat
P[] + P[1]
- sage: f(p2)
+ sage: f(p2) # optional - sage.combinat
P[] + P[1] + P[1, 1]
- sage: f(p21)
+ sage: f(p21) # optional - sage.combinat
P[1] + P[1, 1] + P[2] + P[2, 1]
- sage: f(p21 - p1)
+ sage: f(p21 - p1) # optional - sage.combinat
-P[] + P[1, 1] + P[2] + P[2, 1]
- sage: f(p321)
+ sage: f(p321) # optional - sage.combinat
P[2, 1] + P[2, 1, 1] + P[2, 2] + P[2, 2, 1]
+ P[3, 1] + P[3, 1, 1] + P[3, 2] + P[3, 2, 1]
We now compute `\operatorname{gr} f` ::
- sage: grA = A.graded_algebra(); grA
+ sage: grA = A.graded_algebra(); grA # optional - sage.combinat
Graded Module of An example of a filtered module with basis:
the free module on partitions over Rational Field
- sage: pp1, pp2, pp21, pp321 = [A.to_graded_conversion()(i) for i in [p1, p2, p21, p321]]
- sage: pp2 + 4 * pp21
+ sage: pp1, pp2, pp21, pp321 = [A.to_graded_conversion()(i) # optional - sage.combinat
+ ....: for i in [p1, p2, p21, p321]]
+ sage: pp2 + 4 * pp21 # optional - sage.combinat
Bbar[[2]] + 4*Bbar[[2, 1]]
- sage: grf = A.induced_graded_map(A, f); grf
- Generic endomorphism of Graded Module of An example of a
- filtered module with basis:
- the free module on partitions over Rational Field
- sage: grf(pp1)
+ sage: grf = A.induced_graded_map(A, f); grf # optional - sage.combinat
+ Generic endomorphism of Graded Module of
+ An example of a filtered module with basis:
+ the free module on partitions over Rational Field
+ sage: grf(pp1) # optional - sage.combinat
Bbar[[1]]
- sage: grf(pp2 + 4 * pp21)
+ sage: grf(pp2 + 4 * pp21) # optional - sage.combinat
Bbar[[1, 1]] + 4*Bbar[[2, 1]]
**Example 2.**
@@ -490,45 +497,48 @@ def induced_graded_map(self, other, f):
`f` will lead into a graded algebra already, namely into
the algebra of symmetric functions::
- sage: h = SymmetricFunctions(QQ).h()
- sage: def map_on_basis(lam): # redefining map_on_basis
- ....: return h.sum_of_monomials([Partition(mu).conjugate() for k in range(sum(lam) + 1)
- ....: for mu in lam.remove_horizontal_border_strip(k)])
- sage: f = A.module_morphism(on_basis=map_on_basis,
+ sage: h = SymmetricFunctions(QQ).h() # optional - sage.combinat
+ sage: def map_on_basis(lam): # redefining map_on_basis # optional - sage.combinat
+ ....: def mus(k):
+ ....: return lam.remove_horizontal_border_strip(k)
+ ....: return h.sum_of_monomials([Partition(mu).conjugate()
+ ....: for k in range(sum(lam) + 1)
+ ....: for mu in mus(k)])
+ sage: f = A.module_morphism(on_basis=map_on_basis, # optional - sage.combinat
....: codomain=h) # redefining f
- sage: f(p1)
+ sage: f(p1) # optional - sage.combinat
h[] + h[1]
- sage: f(p2)
+ sage: f(p2) # optional - sage.combinat
h[] + h[1] + h[1, 1]
- sage: f(A.zero())
+ sage: f(A.zero()) # optional - sage.combinat
0
- sage: f(p2 - 3*p1)
+ sage: f(p2 - 3*p1) # optional - sage.combinat
-2*h[] - 2*h[1] + h[1, 1]
The algebra ``h`` of symmetric functions in the `h`-basis
is already graded, so its associated graded algebra is
implemented as itself::
- sage: grh = h.graded_algebra(); grh is h
+ sage: grh = h.graded_algebra(); grh is h # optional - sage.combinat
True
- sage: grf = A.induced_graded_map(h, f); grf
+ sage: grf = A.induced_graded_map(h, f); grf # optional - sage.combinat
Generic morphism:
From: Graded Module of An example of a filtered
module with basis: the free module on partitions
over Rational Field
To: Symmetric Functions over Rational Field
in the homogeneous basis
- sage: grf(pp1)
+ sage: grf(pp1) # optional - sage.combinat
h[1]
- sage: grf(pp2)
+ sage: grf(pp2) # optional - sage.combinat
h[1, 1]
- sage: grf(pp321)
+ sage: grf(pp321) # optional - sage.combinat
h[3, 2, 1]
- sage: grf(pp2 - 3*pp1)
+ sage: grf(pp2 - 3*pp1) # optional - sage.combinat
-3*h[1] + h[1, 1]
- sage: grf(pp21)
+ sage: grf(pp21) # optional - sage.combinat
h[2, 1]
- sage: grf(grA.zero())
+ sage: grf(grA.zero()) # optional - sage.combinat
0
**Example 3.**
@@ -537,42 +547,45 @@ def induced_graded_map(self, other, f):
have one as the domain instead. Our new ``f`` will go from ``h``
to ``A``::
- sage: def map_on_basis(lam): # redefining map_on_basis
- ....: return A.sum_of_monomials([Partition(mu).conjugate() for k in range(sum(lam) + 1)
- ....: for mu in lam.remove_horizontal_border_strip(k)])
- sage: f = h.module_morphism(on_basis=map_on_basis,
+ sage: def map_on_basis(lam): # redefining map_on_basis # optional - sage.combinat
+ ....: def mus(k):
+ ....: return lam.remove_horizontal_border_strip(k)
+ ....: return A.sum_of_monomials([Partition(mu).conjugate()
+ ....: for k in range(sum(lam) + 1)
+ ....: for mu in mus(k)])
+ sage: f = h.module_morphism(on_basis=map_on_basis, # optional - sage.combinat
....: codomain=A) # redefining f
- sage: f(h[1])
+ sage: f(h[1]) # optional - sage.combinat
P[] + P[1]
- sage: f(h[2])
+ sage: f(h[2]) # optional - sage.combinat
P[] + P[1] + P[1, 1]
- sage: f(h[1, 1])
+ sage: f(h[1, 1]) # optional - sage.combinat
P[1] + P[2]
- sage: f(h[2, 2])
+ sage: f(h[2, 2]) # optional - sage.combinat
P[1, 1] + P[2, 1] + P[2, 2]
- sage: f(h[3, 2, 1])
+ sage: f(h[3, 2, 1]) # optional - sage.combinat
P[2, 1] + P[2, 1, 1] + P[2, 2] + P[2, 2, 1]
+ P[3, 1] + P[3, 1, 1] + P[3, 2] + P[3, 2, 1]
- sage: f(h.one())
+ sage: f(h.one()) # optional - sage.combinat
P[]
- sage: grf = h.induced_graded_map(A, f); grf
+ sage: grf = h.induced_graded_map(A, f); grf # optional - sage.combinat
Generic morphism:
From: Symmetric Functions over Rational Field
in the homogeneous basis
To: Graded Module of An example of a filtered
module with basis: the free module on partitions
over Rational Field
- sage: grf(h[1])
+ sage: grf(h[1]) # optional - sage.combinat
Bbar[[1]]
- sage: grf(h[2])
+ sage: grf(h[2]) # optional - sage.combinat
Bbar[[1, 1]]
- sage: grf(h[1, 1])
+ sage: grf(h[1, 1]) # optional - sage.combinat
Bbar[[2]]
- sage: grf(h[2, 2])
+ sage: grf(h[2, 2]) # optional - sage.combinat
Bbar[[2, 2]]
- sage: grf(h[3, 2, 1])
+ sage: grf(h[3, 2, 1]) # optional - sage.combinat
Bbar[[3, 2, 1]]
- sage: grf(h.one())
+ sage: grf(h.one()) # optional - sage.combinat
Bbar[[]]
**Example 4.**
@@ -580,33 +593,36 @@ def induced_graded_map(self, other, f):
The construct `\operatorname{gr} f` also makes sense when `f`
is a filtration-preserving map between graded modules. ::
- sage: def map_on_basis(lam): # redefining map_on_basis
- ....: return h.sum_of_monomials([Partition(mu).conjugate() for k in range(sum(lam) + 1)
- ....: for mu in lam.remove_horizontal_border_strip(k)])
- sage: f = h.module_morphism(on_basis=map_on_basis,
+ sage: def map_on_basis(lam): # redefining map_on_basis # optional - sage.combinat
+ ....: def mus(k):
+ ....: return lam.remove_horizontal_border_strip(k)
+ ....: return h.sum_of_monomials([Partition(mu).conjugate()
+ ....: for k in range(sum(lam) + 1)
+ ....: for mu in mus(k)])
+ sage: f = h.module_morphism(on_basis=map_on_basis, # optional - sage.combinat
....: codomain=h) # redefining f
- sage: f(h[1])
+ sage: f(h[1]) # optional - sage.combinat
h[] + h[1]
- sage: f(h[2])
+ sage: f(h[2]) # optional - sage.combinat
h[] + h[1] + h[1, 1]
- sage: f(h[1, 1])
+ sage: f(h[1, 1]) # optional - sage.combinat
h[1] + h[2]
- sage: f(h[2, 1])
+ sage: f(h[2, 1]) # optional - sage.combinat
h[1] + h[1, 1] + h[2] + h[2, 1]
- sage: f(h.one())
+ sage: f(h.one()) # optional - sage.combinat
h[]
- sage: grf = h.induced_graded_map(h, f); grf
- Generic endomorphism of Symmetric Functions over Rational
- Field in the homogeneous basis
- sage: grf(h[1])
+ sage: grf = h.induced_graded_map(h, f); grf # optional - sage.combinat
+ Generic endomorphism of
+ Symmetric Functions over Rational Field in the homogeneous basis
+ sage: grf(h[1]) # optional - sage.combinat
h[1]
- sage: grf(h[2])
+ sage: grf(h[2]) # optional - sage.combinat
h[1, 1]
- sage: grf(h[1, 1])
+ sage: grf(h[1, 1]) # optional - sage.combinat
h[2]
- sage: grf(h[2, 1])
+ sage: grf(h[2, 1]) # optional - sage.combinat
h[2, 1]
- sage: grf(h.one())
+ sage: grf(h.one()) # optional - sage.combinat
h[]
"""
grA = self.graded_algebra()
@@ -643,26 +659,26 @@ def is_homogeneous(self):
EXAMPLES::
- sage: A = ModulesWithBasis(ZZ).Filtered().example()
- sage: x = A(Partition((3,2,1)))
- sage: y = A(Partition((4,4,1)))
- sage: z = A(Partition((2,2,2)))
- sage: (3*x).is_homogeneous()
+ sage: A = ModulesWithBasis(ZZ).Filtered().example() # optional - sage.combinat
+ sage: x = A(Partition((3,2,1))) # optional - sage.combinat
+ sage: y = A(Partition((4,4,1))) # optional - sage.combinat
+ sage: z = A(Partition((2,2,2))) # optional - sage.combinat
+ sage: (3*x).is_homogeneous() # optional - sage.combinat
True
- sage: (x - y).is_homogeneous()
+ sage: (x - y).is_homogeneous() # optional - sage.combinat
False
- sage: (x+2*z).is_homogeneous()
+ sage: (x+2*z).is_homogeneous() # optional - sage.combinat
True
Here is an example with a graded algebra::
- sage: S = NonCommutativeSymmetricFunctions(QQ).S()
- sage: (x, y) = (S[2], S[3])
- sage: (3*x).is_homogeneous()
+ sage: S = NonCommutativeSymmetricFunctions(QQ).S() # optional - sage.combinat
+ sage: (x, y) = (S[2], S[3]) # optional - sage.combinat
+ sage: (3*x).is_homogeneous() # optional - sage.combinat
True
- sage: (x^3 - y^2).is_homogeneous()
+ sage: (x^3 - y^2).is_homogeneous() # optional - sage.combinat
True
- sage: ((x + y)^2).is_homogeneous()
+ sage: ((x + y)^2).is_homogeneous() # optional - sage.combinat
False
Let us now test a filtered algebra (but remember that the
@@ -701,10 +717,10 @@ def degree_on_basis(self, m):
EXAMPLES::
- sage: A = GradedModulesWithBasis(QQ).example()
- sage: A.degree_on_basis(Partition((2,1)))
+ sage: A = GradedModulesWithBasis(QQ).example() # optional - sage.combinat sage.modules
+ sage: A.degree_on_basis(Partition((2,1))) # optional - sage.combinat sage.modules
3
- sage: A.degree_on_basis(Partition((4,2,1,1,1,1)))
+ sage: A.degree_on_basis(Partition((4,2,1,1,1,1))) # optional - sage.combinat sage.modules
10
"""
@@ -722,28 +738,28 @@ def homogeneous_degree(self):
EXAMPLES::
- sage: A = ModulesWithBasis(ZZ).Filtered().example()
- sage: x = A(Partition((3,2,1)))
- sage: y = A(Partition((4,4,1)))
- sage: z = A(Partition((2,2,2)))
- sage: x.degree()
+ sage: A = ModulesWithBasis(ZZ).Filtered().example() # optional - sage.combinat sage.modules
+ sage: x = A(Partition((3,2,1))) # optional - sage.combinat sage.modules
+ sage: y = A(Partition((4,4,1))) # optional - sage.combinat sage.modules
+ sage: z = A(Partition((2,2,2))) # optional - sage.combinat sage.modules
+ sage: x.degree() # optional - sage.combinat sage.modules
6
- sage: (x + 2*z).degree()
+ sage: (x + 2*z).degree() # optional - sage.combinat sage.modules
6
- sage: (y - x).degree()
+ sage: (y - x).degree() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
ValueError: element is not homogeneous
An example in a graded algebra::
- sage: S = NonCommutativeSymmetricFunctions(QQ).S()
- sage: (x, y) = (S[2], S[3])
- sage: x.homogeneous_degree()
+ sage: S = NonCommutativeSymmetricFunctions(QQ).S() # optional - sage.combinat sage.modules
+ sage: (x, y) = (S[2], S[3]) # optional - sage.combinat sage.modules
+ sage: x.homogeneous_degree() # optional - sage.combinat sage.modules
2
- sage: (x^3 + 4*y^2).homogeneous_degree()
+ sage: (x^3 + 4*y^2).homogeneous_degree() # optional - sage.combinat sage.modules
6
- sage: ((1 + x)^3).homogeneous_degree()
+ sage: ((1 + x)^3).homogeneous_degree() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
ValueError: element is not homogeneous
@@ -765,8 +781,8 @@ def homogeneous_degree(self):
TESTS::
- sage: S = NonCommutativeSymmetricFunctions(QQ).S()
- sage: S.zero().degree()
+ sage: S = NonCommutativeSymmetricFunctions(QQ).S() # optional - sage.combinat sage.modules
+ sage: S.zero().degree() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
ValueError: the zero element does not have a well-defined degree
@@ -793,28 +809,28 @@ def maximal_degree(self):
EXAMPLES::
- sage: A = ModulesWithBasis(ZZ).Filtered().example()
- sage: x = A(Partition((3,2,1)))
- sage: y = A(Partition((4,4,1)))
- sage: z = A(Partition((2,2,2)))
- sage: x.maximal_degree()
+ sage: A = ModulesWithBasis(ZZ).Filtered().example() # optional - sage.combinat
+ sage: x = A(Partition((3,2,1))) # optional - sage.combinat
+ sage: y = A(Partition((4,4,1))) # optional - sage.combinat
+ sage: z = A(Partition((2,2,2))) # optional - sage.combinat
+ sage: x.maximal_degree() # optional - sage.combinat
6
- sage: (x + 2*z).maximal_degree()
+ sage: (x + 2*z).maximal_degree() # optional - sage.combinat
6
- sage: (y - x).maximal_degree()
+ sage: (y - x).maximal_degree() # optional - sage.combinat
9
- sage: (3*z).maximal_degree()
+ sage: (3*z).maximal_degree() # optional - sage.combinat
6
Now, we test this on a graded algebra::
- sage: S = NonCommutativeSymmetricFunctions(QQ).S()
- sage: (x, y) = (S[2], S[3])
- sage: x.maximal_degree()
+ sage: S = NonCommutativeSymmetricFunctions(QQ).S() # optional - sage.combinat
+ sage: (x, y) = (S[2], S[3]) # optional - sage.combinat
+ sage: x.maximal_degree() # optional - sage.combinat
2
- sage: (x^3 + 4*y^2).maximal_degree()
+ sage: (x^3 + 4*y^2).maximal_degree() # optional - sage.combinat
6
- sage: ((1 + x)^3).maximal_degree()
+ sage: ((1 + x)^3).maximal_degree() # optional - sage.combinat
6
Let us now test a filtered algebra::
@@ -836,8 +852,8 @@ def maximal_degree(self):
TESTS::
- sage: S = NonCommutativeSymmetricFunctions(QQ).S()
- sage: S.zero().degree()
+ sage: S = NonCommutativeSymmetricFunctions(QQ).S() # optional - sage.combinat
+ sage: S.zero().degree() # optional - sage.combinat
Traceback (most recent call last):
...
ValueError: the zero element does not have a well-defined degree
@@ -998,16 +1014,16 @@ def degree_on_basis(self, m):
EXAMPLES::
- sage: E. = ExteriorAlgebra(QQ)
- sage: S = E.submodule([x + y, x*y - y*z, y])
- sage: B = S.basis()
- sage: [B[0].lift(), B[1].lift(), B[2].lift()]
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: S = E.submodule([x + y, x*y - y*z, y]) # optional - sage.combinat sage.modules
+ sage: B = S.basis() # optional - sage.combinat sage.modules
+ sage: [B[0].lift(), B[1].lift(), B[2].lift()] # optional - sage.combinat sage.modules
[x, y, x*y - y*z]
- sage: S.degree_on_basis(0)
+ sage: S.degree_on_basis(0) # optional - sage.combinat sage.modules
1
- sage: S.degree_on_basis(1)
+ sage: S.degree_on_basis(1) # optional - sage.combinat sage.modules
1
- sage: S.degree_on_basis(2)
+ sage: S.degree_on_basis(2) # optional - sage.combinat sage.modules
2
"""
return self.basis()[m].lift().degree()
@@ -1019,29 +1035,29 @@ def degree(self):
EXAMPLES::
- sage: E. = ExteriorAlgebra(QQ)
- sage: S = E.submodule([x + y, x*y - y*z, y])
- sage: B = S.basis()
- sage: [B[0].lift(), B[1].lift(), B[2].lift()]
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: S = E.submodule([x + y, x*y - y*z, y]) # optional - sage.combinat sage.modules
+ sage: B = S.basis() # optional - sage.combinat sage.modules
+ sage: [B[0].lift(), B[1].lift(), B[2].lift()] # optional - sage.combinat sage.modules
[x, y, x*y - y*z]
- sage: B[0].degree()
+ sage: B[0].degree() # optional - sage.combinat sage.modules
1
- sage: B[1].degree()
+ sage: B[1].degree() # optional - sage.combinat sage.modules
1
- sage: (B[0] + 3*B[1]).degree()
+ sage: (B[0] + 3*B[1]).degree() # optional - sage.combinat sage.modules
1
The degree of inhomogeneous elements is not defined
(following the behavior of the exterior algebra)::
- sage: (B[0] + B[2]).degree()
+ sage: (B[0] + B[2]).degree() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
ValueError: element is not homogeneous
We can still get the maximal degree::
- sage: (B[0] + B[2]).maximal_degree()
+ sage: (B[0] + B[2]).maximal_degree() # optional - sage.combinat sage.modules
2
"""
return self.lift().degree()
@@ -1059,14 +1075,14 @@ def maximal_degree(self):
EXAMPLES::
- sage: E. = ExteriorAlgebra(QQ)
- sage: F = E.submodule([x + 1, x*y - 1])
- sage: B = F.basis()
- sage: [B[0].lift(), B[1].lift()]
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: F = E.submodule([x + 1, x*y - 1]) # optional - sage.combinat sage.modules
+ sage: B = F.basis() # optional - sage.combinat sage.modules
+ sage: [B[0].lift(), B[1].lift()] # optional - sage.combinat sage.modules
[-x*y + 1, x*y + x]
- sage: B[0].maximal_degree()
+ sage: B[0].maximal_degree() # optional - sage.combinat sage.modules
2
- sage: B[1].maximal_degree()
+ sage: B[1].maximal_degree() # optional - sage.combinat sage.modules
2
"""
return self.lift().maximal_degree()
diff --git a/src/sage/categories/finite_complex_reflection_groups.py b/src/sage/categories/finite_complex_reflection_groups.py
index 8648f89dbc4..f4ab8a943ce 100644
--- a/src/sage/categories/finite_complex_reflection_groups.py
+++ b/src/sage/categories/finite_complex_reflection_groups.py
@@ -56,7 +56,7 @@ class FiniteComplexReflectionGroups(CategoryWithAxiom):
sage: W = ComplexReflectionGroups().Finite().example(); W # optional - gap3
Reducible real reflection group of rank 4 and type A2 x B2
- sage: W.reflections() # optional - gap3
+ sage: W.reflections() # optional - gap3
Finite family {1: (1,8)(2,5)(9,12), 2: (1,5)(2,9)(8,12),
3: (3,10)(4,7)(11,14), 4: (3,6)(4,11)(10,13),
5: (1,9)(2,8)(5,12), 6: (4,14)(6,13)(7,11),
@@ -64,7 +64,7 @@ class FiniteComplexReflectionGroups(CategoryWithAxiom):
``W`` is in the category of complex reflection groups::
- sage: W in ComplexReflectionGroups().Finite() # optional - gap3
+ sage: W in ComplexReflectionGroups().Finite() # optional - gap3
True
"""
def example(self):
@@ -104,14 +104,14 @@ def WellGenerated(self):
Here is an example of a finite well-generated complex
reflection group::
- sage: W = C.example(); W # optional - gap3
+ sage: W = C.example(); W # optional - gap3
Reducible complex reflection group of rank 4 and type A2 x G(3,1,2)
All finite Coxeter groups are well generated::
sage: CoxeterGroups().Finite().is_subcategory(C)
True
- sage: SymmetricGroup(3) in C
+ sage: SymmetricGroup(3) in C # optional - sage.groups
True
.. NOTE::
@@ -124,8 +124,9 @@ def WellGenerated(self):
TESTS::
- sage: TestSuite(W).run() # optional - gap3
- sage: TestSuite(ComplexReflectionGroups().Finite().WellGenerated()).run() # optional - gap3
+ sage: TestSuite(W).run() # optional - gap3
+ sage: C = ComplexReflectionGroups().Finite().WellGenerated()
+ sage: TestSuite(C).run() # optional - gap3
sage: CoxeterGroups().Finite().WellGenerated.__module__
'sage.categories.finite_complex_reflection_groups'
@@ -148,12 +149,12 @@ def degrees(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,4)
- sage: W.degrees()
+ sage: W = ColoredPermutations(1,4) # optional - sage.combinat sage.groups
+ sage: W.degrees() # optional - sage.combinat sage.groups
(2, 3, 4)
- sage: W = ColoredPermutations(3,3)
- sage: W.degrees()
+ sage: W = ColoredPermutations(3,3) # optional - sage.combinat sage.groups
+ sage: W.degrees() # optional - sage.combinat sage.groups
(3, 6, 9)
sage: W = ReflectionGroup(31) # optional - gap3
@@ -170,12 +171,12 @@ def codegrees(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,4)
- sage: W.codegrees()
+ sage: W = ColoredPermutations(1,4) # optional - sage.combinat sage.groups
+ sage: W.codegrees() # optional - sage.combinat sage.groups
(2, 1, 0)
- sage: W = ColoredPermutations(3,3)
- sage: W.codegrees()
+ sage: W = ColoredPermutations(3,3) # optional - sage.combinat sage.groups
+ sage: W.codegrees() # optional - sage.combinat sage.groups
(6, 3, 0)
sage: W = ReflectionGroup(31) # optional - gap3
@@ -198,27 +199,27 @@ def _test_degrees(self, **options):
Reducible real reflection group of rank 4 and type A2 x B2
sage: W._test_degrees() # optional - gap3
- sage: W = SymmetricGroup(5)
- sage: W._test_degrees()
+ sage: W = SymmetricGroup(5) # optional - sage.groups
+ sage: W._test_degrees() # optional - sage.groups
We now break the implementation of W.degrees and check that this is caught::
- sage: W.degrees = lambda: (1/1,5)
- sage: W._test_degrees()
+ sage: W.degrees = lambda: (1/1,5) # optional - sage.groups
+ sage: W._test_degrees() # optional - sage.groups
Traceback (most recent call last):
...
AssertionError: the degrees should be integers
- sage: W.degrees = lambda: (1,2,3)
- sage: W._test_degrees()
+ sage: W.degrees = lambda: (1,2,3) # optional - sage.groups
+ sage: W._test_degrees() # optional - sage.groups
Traceback (most recent call last):
...
AssertionError: the degrees should be larger than 2
We restore W to its normal state::
- sage: del W.degrees
- sage: W._test_degrees()
+ sage: del W.degrees # optional - sage.groups
+ sage: W._test_degrees() # optional - sage.groups
See the documentation for :class:`TestSuite` for more information.
"""
@@ -253,27 +254,27 @@ def _test_codegrees(self, **options):
Reducible real reflection group of rank 4 and type A2 x B2
sage: W._test_codegrees() # optional - gap3
- sage: W = SymmetricGroup(5)
- sage: W._test_codegrees()
+ sage: W = SymmetricGroup(5) # optional - sage.groups
+ sage: W._test_codegrees() # optional - sage.groups
We now break the implementation of W.degrees and check that this is caught::
- sage: W.codegrees = lambda: (1/1,5)
- sage: W._test_codegrees()
+ sage: W.codegrees = lambda: (1/1,5) # optional - sage.groups
+ sage: W._test_codegrees() # optional - sage.groups
Traceback (most recent call last):
...
AssertionError: the codegrees should be integers
- sage: W.codegrees = lambda: (2,1,-1)
- sage: W._test_codegrees()
+ sage: W.codegrees = lambda: (2,1,-1) # optional - sage.groups
+ sage: W._test_codegrees() # optional - sage.groups
Traceback (most recent call last):
...
AssertionError: the codegrees should be nonnegative
We restore W to its normal state::
- sage: del W.codegrees
- sage: W._test_codegrees()
+ sage: del W.codegrees # optional - sage.groups
+ sage: W._test_codegrees() # optional - sage.groups
See the documentation for :class:`TestSuite` for more information.
"""
@@ -310,14 +311,14 @@ def number_of_reflection_hyperplanes(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,3)
- sage: W.number_of_reflection_hyperplanes()
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflection_hyperplanes() # optional - sage.combinat sage.groups
3
- sage: W = ColoredPermutations(2,3)
- sage: W.number_of_reflection_hyperplanes()
+ sage: W = ColoredPermutations(2,3) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflection_hyperplanes() # optional - sage.combinat sage.groups
9
- sage: W = ColoredPermutations(4,3)
- sage: W.number_of_reflection_hyperplanes()
+ sage: W = ColoredPermutations(4,3) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflection_hyperplanes() # optional - sage.combinat sage.groups
15
sage: W = ReflectionGroup((4,2,3)) # optional - gap3
sage: W.number_of_reflection_hyperplanes() # optional - gap3
@@ -341,20 +342,21 @@ def number_of_reflections(self):
EXAMPLES::
- sage: [SymmetricGroup(i).number_of_reflections() for i in range(int(8))]
+ sage: [SymmetricGroup(i).number_of_reflections() # optional - sage.groups
+ ....: for i in range(int(8))]
[0, 0, 1, 3, 6, 10, 15, 21]
- sage: W = ColoredPermutations(1,3)
- sage: W.number_of_reflections()
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflections() # optional - sage.combinat sage.groups
3
- sage: W = ColoredPermutations(2,3)
- sage: W.number_of_reflections()
+ sage: W = ColoredPermutations(2,3) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflections() # optional - sage.combinat sage.groups
9
- sage: W = ColoredPermutations(4,3)
- sage: W.number_of_reflections()
+ sage: W = ColoredPermutations(4,3) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflections() # optional - sage.combinat sage.groups
21
- sage: W = ReflectionGroup((4,2,3)) # optional - gap3
- sage: W.number_of_reflections() # optional - gap3
+ sage: W = ReflectionGroup((4,2,3)) # optional - gap3 # optional - sage.combinat sage.groups
+ sage: W.number_of_reflections() # optional - gap3 # optional - sage.combinat sage.groups
15
"""
from sage.rings.integer_ring import ZZ
@@ -375,17 +377,17 @@ def rank(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,3)
- sage: W.rank()
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: W.rank() # optional - sage.combinat sage.groups
2
- sage: W = ColoredPermutations(2,3)
- sage: W.rank()
+ sage: W = ColoredPermutations(2,3) # optional - sage.combinat sage.groups
+ sage: W.rank() # optional - sage.combinat sage.groups
3
- sage: W = ColoredPermutations(4,3)
- sage: W.rank()
+ sage: W = ColoredPermutations(4,3) # optional - sage.combinat sage.groups
+ sage: W.rank() # optional - sage.combinat sage.groups
3
- sage: W = ReflectionGroup((4,2,3)) # optional - gap3
- sage: W.rank() # optional - gap3
+ sage: W = ReflectionGroup((4,2,3)) # optional - gap3 # optional - sage.combinat sage.groups
+ sage: W.rank() # optional - gap3 # optional - sage.combinat sage.groups
3
"""
return len(self.degrees())
@@ -399,17 +401,17 @@ def cardinality(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,3)
- sage: W.cardinality()
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: W.cardinality() # optional - sage.combinat sage.groups
6
- sage: W = ColoredPermutations(2,3)
- sage: W.cardinality()
+ sage: W = ColoredPermutations(2,3) # optional - sage.combinat sage.groups
+ sage: W.cardinality() # optional - sage.combinat sage.groups
48
- sage: W = ColoredPermutations(4,3)
- sage: W.cardinality()
+ sage: W = ColoredPermutations(4,3) # optional - sage.combinat sage.groups
+ sage: W.cardinality() # optional - sage.combinat sage.groups
384
- sage: W = ReflectionGroup((4,2,3)) # optional - gap3
- sage: W.cardinality() # optional - gap3
+ sage: W = ReflectionGroup((4,2,3)) # optional - gap3 # optional - sage.combinat sage.groups
+ sage: W.cardinality() # optional - gap3 # optional - sage.combinat sage.groups
192
"""
from sage.rings.integer_ring import ZZ
@@ -437,20 +439,20 @@ def is_well_generated(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,3)
- sage: W.is_well_generated()
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: W.is_well_generated() # optional - sage.combinat sage.groups
True
- sage: W = ColoredPermutations(4,3)
- sage: W.is_well_generated()
+ sage: W = ColoredPermutations(4,3) # optional - sage.combinat sage.groups
+ sage: W.is_well_generated() # optional - sage.combinat sage.groups
True
- sage: W = ReflectionGroup((4,2,3)) # optional - gap3
- sage: W.is_well_generated() # optional - gap3
+ sage: W = ReflectionGroup((4,2,3)) # optional - gap3 # optional - sage.combinat sage.groups
+ sage: W.is_well_generated() # optional - gap3 # optional - sage.combinat sage.groups
False
- sage: W = ReflectionGroup((4,4,3)) # optional - gap3
- sage: W.is_well_generated() # optional - gap3
+ sage: W = ReflectionGroup((4,4,3)) # optional - gap3 # optional - sage.combinat sage.groups
+ sage: W.is_well_generated() # optional - gap3 # optional - sage.combinat sage.groups
True
"""
return self.number_of_simple_reflections() == self.rank()
@@ -472,12 +474,12 @@ def is_real(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,3)
- sage: W.is_real()
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: W.is_real() # optional - sage.combinat sage.groups
True
- sage: W = ColoredPermutations(4,3)
- sage: W.is_real()
+ sage: W = ColoredPermutations(4,3) # optional - sage.combinat sage.groups
+ sage: W.is_real() # optional - sage.combinat sage.groups
False
.. TODO::
@@ -501,24 +503,24 @@ def base_change_matrix(self):
EXAMPLES::
- sage: W = ReflectionGroup((1,1,3)) # optional - gap3
- sage: W.base_change_matrix() # optional - gap3
+ sage: W = ReflectionGroup((1,1,3)) # optional - gap3
+ sage: W.base_change_matrix() # optional - gap3
[1 0]
[0 1]
- sage: W = ReflectionGroup(23) # optional - gap3
- sage: W.base_change_matrix() # optional - gap3
+ sage: W = ReflectionGroup(23) # optional - gap3
+ sage: W.base_change_matrix() # optional - gap3
[1 0 0]
[0 1 0]
[0 0 1]
- sage: W = ReflectionGroup((3,1,2)) # optional - gap3
- sage: W.base_change_matrix() # optional - gap3
+ sage: W = ReflectionGroup((3,1,2)) # optional - gap3
+ sage: W.base_change_matrix() # optional - gap3
[1 0]
[1 1]
- sage: W = ReflectionGroup((4,2,2)) # optional - gap3
- sage: W.base_change_matrix() # optional - gap3
+ sage: W = ReflectionGroup((4,2,2)) # optional - gap3
+ sage: W.base_change_matrix() # optional - gap3
[ 1 0]
[E(4) 1]
"""
@@ -542,8 +544,8 @@ def to_matrix(self):
[0 1], [ 0 -1], [ 1 1], [ 1 0], [-1 -1], [-1 0]
]
- sage: W = ColoredPermutations(1,3)
- sage: [t.to_matrix() for t in W]
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: [t.to_matrix() for t in W] # optional - sage.combinat sage.groups
[
[1 0 0] [1 0 0] [0 1 0] [0 0 1] [0 1 0] [0 0 1]
[0 1 0] [0 0 1] [1 0 0] [1 0 0] [0 0 1] [0 1 0]
@@ -553,8 +555,8 @@ def to_matrix(self):
A different representation is given by the
colored permutations::
- sage: W = ColoredPermutations(3, 1)
- sage: [t.to_matrix() for t in W]
+ sage: W = ColoredPermutations(3, 1) # optional - sage.combinat sage.groups
+ sage: [t.to_matrix() for t in W] # optional - sage.combinat sage.groups
[[1], [zeta3], [-zeta3 - 1]]
"""
@@ -580,9 +582,9 @@ def character_value(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,3); W
+ sage: W = ColoredPermutations(1,3); W # optional - sage.combinat sage.groups
1-colored permutations of size 3
- sage: [t.character_value() for t in W]
+ sage: [t.character_value() for t in W] # optional - sage.combinat sage.groups
[3, 1, 1, 0, 0, 1]
Note that this could be a different (faithful)
@@ -594,14 +596,14 @@ def character_value(self):
sage: [t.character_value() for t in W] # optional - gap3
[2, 0, 0, -1, -1, 0]
- sage: W = ColoredPermutations(2,2); W
+ sage: W = ColoredPermutations(2,2); W # optional - sage.combinat sage.groups
2-colored permutations of size 2
- sage: [t.character_value() for t in W]
+ sage: [t.character_value() for t in W] # optional - sage.combinat sage.groups
[2, 0, 0, -2, 0, 0, 0, 0]
- sage: W = ColoredPermutations(3,1); W
+ sage: W = ColoredPermutations(3,1); W # optional - sage.combinat sage.groups
3-colored permutations of size 1
- sage: [t.character_value() for t in W]
+ sage: [t.character_value() for t in W] # optional - sage.combinat sage.groups
[1, zeta3, -zeta3 - 1]
"""
return self.to_matrix().trace()
@@ -622,20 +624,20 @@ def reflection_length(self, in_unitary_group=False):
EXAMPLES::
- sage: W = ReflectionGroup((1,1,3)) # optional - gap3
- sage: sorted([t.reflection_length() for t in W]) # optional - gap3
+ sage: W = ReflectionGroup((1,1,3)) # optional - gap3
+ sage: sorted([t.reflection_length() for t in W]) # optional - gap3
[0, 1, 1, 1, 2, 2]
- sage: W = ReflectionGroup((2,1,2)) # optional - gap3
- sage: sorted([t.reflection_length() for t in W]) # optional - gap3
+ sage: W = ReflectionGroup((2,1,2)) # optional - gap3
+ sage: sorted([t.reflection_length() for t in W]) # optional - gap3
[0, 1, 1, 1, 1, 2, 2, 2]
- sage: W = ReflectionGroup((2,2,2)) # optional - gap3
- sage: sorted([t.reflection_length() for t in W]) # optional - gap3
+ sage: W = ReflectionGroup((2,2,2)) # optional - gap3
+ sage: sorted([t.reflection_length() for t in W]) # optional - gap3
[0, 1, 1, 2]
- sage: W = ReflectionGroup((3,1,2)) # optional - gap3
- sage: sorted([t.reflection_length() for t in W]) # optional - gap3
+ sage: W = ReflectionGroup((3,1,2)) # optional - gap3
+ sage: sorted([t.reflection_length() for t in W]) # optional - gap3
[0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
"""
W = self.parent()
@@ -655,7 +657,8 @@ def example(self):
EXAMPLES::
sage: from sage.categories.complex_reflection_groups import ComplexReflectionGroups
- sage: ComplexReflectionGroups().Finite().Irreducible().example() # optional - gap3
+ sage: C = ComplexReflectionGroups().Finite().Irreducible()
+ sage: C.example() # optional - gap3
Irreducible complex reflection group of rank 3 and type G(4,2,3)
"""
from sage.combinat.root_system.reflection_group_real import ReflectionGroup
@@ -733,23 +736,26 @@ def absolute_order_ideal(self, gens=None,
EXAMPLES::
- sage: W = ReflectionGroup((1,1,3)) # optional - gap3
+ sage: W = ReflectionGroup((1,1,3)) # optional - gap3
- sage: sorted( w.reduced_word() for w in W.absolute_order_ideal() ) # optional - gap3
+ sage: sorted(w.reduced_word() # optional - gap3
+ ....: for w in W.absolute_order_ideal())
[[], [1], [1, 2], [1, 2, 1], [2]]
- sage: sorted( w.reduced_word() for w in W.absolute_order_ideal(W.from_reduced_word([2,1])) ) # optional - gap3
+ sage: sorted(w.reduced_word() # optional - gap3
+ ....: for w in W.absolute_order_ideal(W.from_reduced_word([2,1])))
[[], [1], [1, 2, 1], [2], [2, 1]]
- sage: sorted( w.reduced_word() for w in W.absolute_order_ideal(W.from_reduced_word([2])) ) # optional - gap3
+ sage: sorted(w.reduced_word() # optional - gap3
+ ....: for w in W.absolute_order_ideal(W.from_reduced_word([2])))
[[], [2]]
- sage: W = CoxeterGroup(['A', 3])
- sage: len(list(W.absolute_order_ideal()))
+ sage: W = CoxeterGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: len(list(W.absolute_order_ideal())) # optional - sage.combinat sage.groups
14
- sage: W = CoxeterGroup(['A', 2])
- sage: for (w, l) in W.absolute_order_ideal(return_lengths=True):
+ sage: W = CoxeterGroup(['A', 2]) # optional - sage.combinat sage.groups
+ sage: for (w, l) in W.absolute_order_ideal(return_lengths=True): # optional - sage.combinat sage.groups
....: print(w.reduced_word(), l)
[1, 2] 2
[1, 2, 1] 1
@@ -793,9 +799,10 @@ def elements_below_coxeter_element(self, c=None):
TESTS::
- sage: W = CoxeterGroup(['A', 3])
- sage: len(list(W.elements_below_coxeter_element()))
- doctest:...: DeprecationWarning: The method elements_below_coxeter_element is deprecated. Please use absolute_order_ideal instead.
+ sage: W = CoxeterGroup(['A', 3]) # optional - sage.combinat sage.groups
+ sage: len(list(W.elements_below_coxeter_element())) # optional - sage.combinat sage.groups
+ doctest:...: DeprecationWarning: The method elements_below_coxeter_element
+ is deprecated. Please use absolute_order_ideal instead.
See https://github.com/sagemath/sage/issues/27924 for details.
14
"""
@@ -835,23 +842,28 @@ def noncrossing_partition_lattice(self, c=None, L=None,
EXAMPLES::
- sage: W = SymmetricGroup(4)
- sage: W.noncrossing_partition_lattice()
+ sage: W = SymmetricGroup(4) # optional - sage.combinat sage.groups
+ sage: W.noncrossing_partition_lattice() # optional - sage.combinat sage.groups
Finite lattice containing 14 elements
- sage: W = WeylGroup(['G', 2])
- sage: W.noncrossing_partition_lattice()
+ sage: W = WeylGroup(['G', 2]) # optional - sage.combinat sage.groups
+ sage: W.noncrossing_partition_lattice() # optional - sage.combinat sage.groups
Finite lattice containing 8 elements
- sage: W = ReflectionGroup((1,1,3)) # optional - gap3
+ sage: W = ReflectionGroup((1,1,3)) # optional - gap3
- sage: sorted( w.reduced_word() for w in W.noncrossing_partition_lattice() ) # optional - gap3
+ sage: sorted(w.reduced_word() # optional - gap3
+ ....: for w in W.noncrossing_partition_lattice())
[[], [1], [1, 2], [1, 2, 1], [2]]
- sage: sorted( w.reduced_word() for w in W.noncrossing_partition_lattice(W.from_reduced_word([2,1])) ) # optional - gap3
+ sage: c21 = W.from_reduced_word([2,1]) # optional - gap3
+ sage: sorted(w.reduced_word() # optional - gap3
+ ....: for w in W.noncrossing_partition_lattice(c21))
[[], [1], [1, 2, 1], [2], [2, 1]]
- sage: sorted( w.reduced_word() for w in W.noncrossing_partition_lattice(W.from_reduced_word([2])) ) # optional - gap3
+ sage: c2 = W.from_reduced_word([2]) # optional - gap3
+ sage: sorted(w.reduced_word() # optional - gap3
+ ....: for w in W.noncrossing_partition_lattice(c2))
[[], [2]]
"""
from sage.combinat.posets.posets import Poset
@@ -899,8 +911,9 @@ def generalized_noncrossing_partitions(self, m, c=None, positive=False):
sage: W = ReflectionGroup((1,1,3)) # optional - gap3
+ sage: chains = W.generalized_noncrossing_partitions(2) # optional - gap3
sage: sorted([w.reduced_word() for w in chain] # optional - gap3
- ....: for chain in W.generalized_noncrossing_partitions(2))
+ ....: for chain in chains)
[[[], [], [1, 2]],
[[], [1], [2]],
[[], [1, 2], []],
@@ -914,8 +927,10 @@ def generalized_noncrossing_partitions(self, m, c=None, positive=False):
[[2], [], [1, 2, 1]],
[[2], [1, 2, 1], []]]
+ sage: chains = W.generalized_noncrossing_partitions(2, # optional - gap3
+ ....: positive=True)
sage: sorted([w.reduced_word() for w in chain] # optional - gap3
- ....: for chain in W.generalized_noncrossing_partitions(2, positive=True))
+ ....: for chain in chains)
[[[], [1, 2], []],
[[], [1, 2, 1], [1]],
[[1], [2], []],
@@ -987,14 +1002,14 @@ def absolute_poset(self, in_unitary_group=False):
TESTS::
- sage: W1 = CoxeterGroup(['A',2])
- sage: W2 = WeylGroup(['A',2])
- sage: W3 = SymmetricGroup(3)
- sage: W1.absolute_poset()
+ sage: W1 = CoxeterGroup(['A', 2]) # optional - sage.combinat sage.groups
+ sage: W2 = WeylGroup(['A', 2]) # optional - sage.combinat sage.groups
+ sage: W3 = SymmetricGroup(3) # optional - sage.combinat sage.groups
+ sage: W1.absolute_poset() # optional - sage.combinat sage.groups
Finite poset containing 6 elements
- sage: W2.absolute_poset()
+ sage: W2.absolute_poset() # optional - sage.combinat sage.groups
Finite poset containing 6 elements
- sage: W3.absolute_poset()
+ sage: W3.absolute_poset() # optional - sage.combinat sage.groups
Finite poset containing 6 elements
"""
return self.noncrossing_partition_lattice(L=tuple(self), in_unitary_group=in_unitary_group)
@@ -1008,7 +1023,8 @@ def example(self):
EXAMPLES::
sage: from sage.categories.complex_reflection_groups import ComplexReflectionGroups
- sage: ComplexReflectionGroups().Finite().WellGenerated().example() # optional - gap3
+ sage: C = ComplexReflectionGroups().Finite().WellGenerated()
+ sage: C.example() # optional - gap3
Reducible complex reflection group of rank 4 and type A2 x G(3,1,2)
"""
from sage.combinat.root_system.reflection_group_real import ReflectionGroup
@@ -1062,12 +1078,15 @@ def coxeter_elements(self):
EXAMPLES::
sage: W = ReflectionGroup((1,1,3)) # optional - gap3
- sage: sorted(c.reduced_word() for c in W.coxeter_elements()) # optional - gap3
+ sage: sorted(c.reduced_word() # optional - gap3
+ ....: for c in W.coxeter_elements())
[[1, 2], [2, 1]]
sage: W = ReflectionGroup((1,1,4)) # optional - gap3
- sage: sorted(c.reduced_word() for c in W.coxeter_elements()) # optional - gap3
- [[1, 2, 1, 3, 2], [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 1, 3, 2, 1], [3, 2, 1]]
+ sage: sorted(c.reduced_word() # optional - gap3
+ ....: for c in W.coxeter_elements())
+ [[1, 2, 1, 3, 2], [1, 2, 3], [1, 3, 2],
+ [2, 1, 3], [2, 1, 3, 2, 1], [3, 2, 1]]
"""
return self.coxeter_element().conjugacy_class()
@@ -1084,7 +1103,8 @@ def example(self):
EXAMPLES::
sage: from sage.categories.complex_reflection_groups import ComplexReflectionGroups
- sage: ComplexReflectionGroups().Finite().WellGenerated().Irreducible().example()
+ sage: C = ComplexReflectionGroups().Finite().WellGenerated().Irreducible()
+ sage: C.example() # optional - sage.combinat sage.groups
4-colored permutations of size 3
"""
from sage.combinat.colored_permutations import ColoredPermutations
@@ -1109,12 +1129,12 @@ def coxeter_number(self):
EXAMPLES::
- sage: W = ColoredPermutations(1,3)
- sage: W.coxeter_number()
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: W.coxeter_number() # optional - sage.combinat sage.groups
3
- sage: W = ColoredPermutations(4,3)
- sage: W.coxeter_number()
+ sage: W = ColoredPermutations(4,3) # optional - sage.combinat sage.groups
+ sage: W.coxeter_number() # optional - sage.combinat sage.groups
12
sage: W = ReflectionGroup((4,4,3)) # optional - gap3
@@ -1130,20 +1150,20 @@ def number_of_reflections_of_full_support(self):
EXAMPLES::
- sage: W = Permutations(4)
- sage: W.number_of_reflections_of_full_support()
+ sage: W = Permutations(4) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflections_of_full_support() # optional - sage.combinat sage.groups
1
- sage: W = ColoredPermutations(1,4)
- sage: W.number_of_reflections_of_full_support()
+ sage: W = ColoredPermutations(1,4) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflections_of_full_support() # optional - sage.combinat sage.groups
1
- sage: W = CoxeterGroup("B3")
- sage: W.number_of_reflections_of_full_support()
+ sage: W = CoxeterGroup("B3") # optional - sage.combinat sage.groups
+ sage: W.number_of_reflections_of_full_support() # optional - sage.combinat sage.groups
3
- sage: W = ColoredPermutations(3,3)
- sage: W.number_of_reflections_of_full_support()
+ sage: W = ColoredPermutations(3,3) # optional - sage.combinat sage.groups
+ sage: W.number_of_reflections_of_full_support() # optional - sage.combinat sage.groups
3
"""
n = self.rank()
@@ -1175,18 +1195,18 @@ def rational_catalan_number(self, p, polynomial=False):
EXAMPLES::
- sage: W = ColoredPermutations(1,3)
- sage: [W.rational_catalan_number(p) for p in [5,7,8]]
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: [W.rational_catalan_number(p) for p in [5,7,8]] # optional - sage.combinat sage.groups
[7, 12, 15]
- sage: W = ColoredPermutations(2,2)
- sage: [W.rational_catalan_number(p) for p in [7,9,11]]
+ sage: W = ColoredPermutations(2,2) # optional - sage.combinat sage.groups
+ sage: [W.rational_catalan_number(p) for p in [7,9,11]] # optional - sage.combinat sage.groups
[10, 15, 21]
TESTS::
- sage: W = ColoredPermutations(1,4)
- sage: W.rational_catalan_number(3, polynomial=True)
+ sage: W = ColoredPermutations(1,4) # optional - sage.combinat sage.groups
+ sage: W.rational_catalan_number(3, polynomial=True) # optional - sage.combinat sage.groups
q^6 + q^4 + q^3 + q^2 + 1
"""
from sage.arith.misc import GCD as gcd
@@ -1243,37 +1263,37 @@ def fuss_catalan_number(self, m, positive=False,
EXAMPLES::
- sage: W = ColoredPermutations(1,3)
- sage: [W.fuss_catalan_number(i) for i in [1,2,3]]
+ sage: W = ColoredPermutations(1,3) # optional - sage.combinat sage.groups
+ sage: [W.fuss_catalan_number(i) for i in [1,2,3]] # optional - sage.combinat sage.groups
[5, 12, 22]
- sage: W = ColoredPermutations(1,4)
- sage: [W.fuss_catalan_number(i) for i in [1,2,3]]
+ sage: W = ColoredPermutations(1,4) # optional - sage.combinat sage.groups
+ sage: [W.fuss_catalan_number(i) for i in [1,2,3]] # optional - sage.combinat sage.groups
[14, 55, 140]
- sage: W = ColoredPermutations(1,5)
- sage: [W.fuss_catalan_number(i) for i in [1,2,3]]
+ sage: W = ColoredPermutations(1,5) # optional - sage.combinat sage.groups
+ sage: [W.fuss_catalan_number(i) for i in [1,2,3]] # optional - sage.combinat sage.groups
[42, 273, 969]
- sage: W = ColoredPermutations(2,2)
- sage: [W.fuss_catalan_number(i) for i in [1,2,3]]
+ sage: W = ColoredPermutations(2,2) # optional - sage.combinat sage.groups
+ sage: [W.fuss_catalan_number(i) for i in [1,2,3]] # optional - sage.combinat sage.groups
[6, 15, 28]
- sage: W = ColoredPermutations(2,3)
- sage: [W.fuss_catalan_number(i) for i in [1,2,3]]
+ sage: W = ColoredPermutations(2,3) # optional - sage.combinat sage.groups
+ sage: [W.fuss_catalan_number(i) for i in [1,2,3]] # optional - sage.combinat sage.groups
[20, 84, 220]
- sage: W = ColoredPermutations(2,4)
- sage: [W.fuss_catalan_number(i) for i in [1,2,3]]
+ sage: W = ColoredPermutations(2,4) # optional - sage.combinat sage.groups
+ sage: [W.fuss_catalan_number(i) for i in [1,2,3]] # optional - sage.combinat sage.groups
[70, 495, 1820]
TESTS::
- sage: W = ColoredPermutations(2,4)
- sage: W.fuss_catalan_number(2,positive=True)
+ sage: W = ColoredPermutations(2,4) # optional - sage.combinat sage.groups
+ sage: W.fuss_catalan_number(2, positive=True) # optional - sage.combinat sage.groups
330
- sage: W = ColoredPermutations(2,2)
- sage: W.fuss_catalan_number(2,polynomial=True)
+ sage: W = ColoredPermutations(2,2) # optional - sage.combinat sage.groups
+ sage: W.fuss_catalan_number(2, polynomial=True) # optional - sage.combinat sage.groups
q^16 + q^14 + 2*q^12 + 2*q^10 + 3*q^8 + 2*q^6 +
2*q^4 + q^2 + 1
"""
@@ -1317,22 +1337,25 @@ def catalan_number(self, positive=False, polynomial=False):
EXAMPLES::
- sage: [ColoredPermutations(1,n).catalan_number() for n in [3,4,5]]
+ sage: [ColoredPermutations(1,n).catalan_number() # optional - sage.combinat sage.groups
+ ....: for n in [3,4,5]]
[5, 14, 42]
- sage: [ColoredPermutations(2,n).catalan_number() for n in [3,4,5]]
+ sage: [ColoredPermutations(2,n).catalan_number() # optional - sage.combinat sage.groups
+ ....: for n in [3,4,5]]
[20, 70, 252]
- sage: [ReflectionGroup((2,2,n)).catalan_number() for n in [3,4,5]] # optional - gap3
+ sage: [ReflectionGroup((2,2,n)).catalan_number() # optional - gap3
+ ....: for n in [3,4,5]]
[14, 50, 182]
TESTS::
- sage: W = ColoredPermutations(3,6)
- sage: W.catalan_number(positive=True)
+ sage: W = ColoredPermutations(3,6) # optional - sage.combinat sage.groups
+ sage: W.catalan_number(positive=True) # optional - sage.combinat sage.groups
462
- sage: W = ColoredPermutations(2,2)
- sage: W.catalan_number(polynomial=True)
+ sage: W = ColoredPermutations(2,2) # optional - sage.combinat sage.groups
+ sage: W.catalan_number(polynomial=True) # optional - sage.combinat sage.groups
q^8 + q^6 + 2*q^4 + q^2 + 1
"""
return self.fuss_catalan_number(1, positive=positive,
diff --git a/src/sage/categories/finite_coxeter_groups.py b/src/sage/categories/finite_coxeter_groups.py
index 270341c2262..0ec68ca2b99 100644
--- a/src/sage/categories/finite_coxeter_groups.py
+++ b/src/sage/categories/finite_coxeter_groups.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat sage.groups
r"""
Finite Coxeter Groups
"""
diff --git a/src/sage/categories/finite_crystals.py b/src/sage/categories/finite_crystals.py
index 072df1f9c53..f920da8b877 100644
--- a/src/sage/categories/finite_crystals.py
+++ b/src/sage/categories/finite_crystals.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat sage.graphs
r"""
Finite Crystals
"""
diff --git a/src/sage/categories/finite_dimensional_algebras_with_basis.py b/src/sage/categories/finite_dimensional_algebras_with_basis.py
index 542cf09d425..ec4a65b8db1 100644
--- a/src/sage/categories/finite_dimensional_algebras_with_basis.py
+++ b/src/sage/categories/finite_dimensional_algebras_with_basis.py
@@ -90,29 +90,29 @@ def radical_basis(self):
We construct the group algebra of the Klein Four-Group
over the rationals::
- sage: A = KleinFourGroup().algebra(QQ)
+ sage: A = KleinFourGroup().algebra(QQ) # optional - sage.groups sage.modules
This algebra belongs to the category of finite dimensional
algebras over the rationals::
- sage: A in Algebras(QQ).FiniteDimensional().WithBasis()
+ sage: A in Algebras(QQ).FiniteDimensional().WithBasis() # optional - sage.groups sage.modules
True
Since the field has characteristic `0`, Maschke's Theorem
tells us that the group algebra is semisimple. So its
radical is the zero ideal::
- sage: A in Algebras(QQ).Semisimple()
+ sage: A in Algebras(QQ).Semisimple() # optional - sage.groups sage.modules
True
- sage: A.radical_basis()
+ sage: A.radical_basis() # optional - sage.groups sage.modules
()
Let's work instead over a field of characteristic `2`::
- sage: A = KleinFourGroup().algebra(GF(2))
- sage: A in Algebras(GF(2)).Semisimple()
+ sage: A = KleinFourGroup().algebra(GF(2)) # optional - sage.groups sage.rings.finite_rings sage.modules
+ sage: A in Algebras(GF(2)).Semisimple() # optional - sage.groups sage.rings.finite_rings sage.modules
False
- sage: A.radical_basis()
+ sage: A.radical_basis() # optional - sage.groups sage.rings.finite_rings sage.modules
(() + (1,2)(3,4), (3,4) + (1,2)(3,4), (1,2) + (1,2)(3,4))
We now implement the algebra `A = K[x] / (x^p-1)`, where `K`
@@ -120,7 +120,7 @@ def radical_basis(self):
radical; alas, we currently need to wrap `A` to make it a
proper :class:`ModulesWithBasis`::
- sage: class AnAlgebra(CombinatorialFreeModule):
+ sage: class AnAlgebra(CombinatorialFreeModule): # optional - sage.modules
....: def __init__(self, F):
....: R. = PolynomialRing(F)
....: I = R.ideal(x**F.characteristic()-F.one())
@@ -132,24 +132,24 @@ def radical_basis(self):
....: return self.basis()[self.base_ring().one()]
....: def product_on_basis(self, w1, w2):
....: return self.from_vector(vector(w1*w2))
- sage: AnAlgebra(GF(3)).radical_basis()
+ sage: AnAlgebra(GF(3)).radical_basis() # optional - sage.rings.finite_rings sage.modules
(B[1] + 2*B[xbar^2], B[xbar] + 2*B[xbar^2])
- sage: AnAlgebra(GF(16,'a')).radical_basis()
+ sage: AnAlgebra(GF(16,'a')).radical_basis() # optional - sage.rings.finite_rings sage.modules
(B[1] + B[xbar],)
- sage: AnAlgebra(GF(49,'a')).radical_basis()
+ sage: AnAlgebra(GF(49,'a')).radical_basis() # optional - sage.rings.finite_rings sage.modules
(B[1] + 6*B[xbar^6], B[xbar] + 6*B[xbar^6], B[xbar^2] + 6*B[xbar^6],
B[xbar^3] + 6*B[xbar^6], B[xbar^4] + 6*B[xbar^6], B[xbar^5] + 6*B[xbar^6])
TESTS::
- sage: A = KleinFourGroup().algebra(GF(2))
- sage: A.radical_basis()
+ sage: A = KleinFourGroup().algebra(GF(2)) # optional - sage.groups sage.rings.finite_rings sage.modules
+ sage: A.radical_basis() # optional - sage.groups sage.rings.finite_rings sage.modules
(() + (1,2)(3,4), (3,4) + (1,2)(3,4), (1,2) + (1,2)(3,4))
- sage: A = KleinFourGroup().algebra(QQ, category=Monoids())
- sage: A.radical_basis.__module__
+ sage: A = KleinFourGroup().algebra(QQ, category=Monoids()) # optional - sage.groups sage.modules
+ sage: A.radical_basis.__module__ # optional - sage.groups sage.modules
'sage.categories.finite_dimensional_algebras_with_basis'
- sage: A.radical_basis()
+ sage: A.radical_basis() # optional - sage.groups sage.modules
()
"""
F = self.base_ring()
@@ -292,10 +292,10 @@ def semisimple_quotient(self):
descent algebra of the symmetric group is of dimension the
number of partitions of `n`::
- sage: [ DescentAlgebra(QQ,n).B().semisimple_quotient().dimension()
+ sage: [ DescentAlgebra(QQ,n).B().semisimple_quotient().dimension() # optional - sage.combinat
....: for n in range(6) ]
[1, 1, 2, 3, 5, 7]
- sage: [Partitions(n).cardinality() for n in range(10)]
+ sage: [Partitions(n).cardinality() for n in range(10)] # optional - sage.combinat
[1, 1, 2, 3, 5, 7, 11, 15, 22, 30]
.. TODO::
@@ -365,7 +365,8 @@ def center(self):
The center of a semisimple algebra is semisimple::
- sage: DihedralGroup(6).algebra(QQ).center() in Algebras(QQ).Semisimple()
+ sage: A = DihedralGroup(6).algebra(QQ) # optional - sage.groups sage.modules
+ sage: A.center() in Algebras(QQ).Semisimple() # optional - sage.groups sage.modules
True
.. TODO::
@@ -473,7 +474,7 @@ def orthogonal_idempotents_central_mod_radical(self):
An example of a finite dimensional algebra with basis:
the path algebra of the Kronecker quiver
(containing the arrows a:x->y and b:x->y) over Rational Field
- sage: A.orthogonal_idempotents_central_mod_radical()
+ sage: A.orthogonal_idempotents_central_mod_radical() # optional - sage.rings.number_field
(x, y)
::
@@ -496,7 +497,8 @@ def orthogonal_idempotents_central_mod_radical(self):
True
sage: all(e*e == e for e in idempotents)
True
- sage: all(e*f == 0 and f*e == 0 for e in idempotents for f in idempotents if e != f)
+ sage: all(e*f == 0 and f*e == 0
+ ....: for e in idempotents for f in idempotents if e != f)
True
This is best tested with::
@@ -645,8 +647,8 @@ def cartan_invariants_matrix(self):
in characteristic zero, the Cartan invariants matrix is
the identity::
- sage: A3 = SymmetricGroup(3).algebra(QQ)
- sage: A3.cartan_invariants_matrix()
+ sage: A3 = SymmetricGroup(3).algebra(QQ) # optional - sage.groups sage.modules
+ sage: A3.cartan_invariants_matrix() # optional - sage.groups sage.modules
[1 0 0]
[0 1 0]
[0 0 1]
@@ -655,7 +657,7 @@ def cartan_invariants_matrix(self):
matrix counts the number of paths between two vertices::
sage: A = Algebras(QQ).FiniteDimensional().WithBasis().example()
- sage: A.cartan_invariants_matrix()
+ sage: A.cartan_invariants_matrix() # optional - sage.modules sage.rings.number_field
[1 2]
[0 1]
@@ -663,8 +665,8 @@ def cartan_invariants_matrix(self):
sage: Z12 = Monoids().Finite().example(); Z12
An example of a finite multiplicative monoid: the integers modulo 12
- sage: A = Z12.algebra(QQ)
- sage: A.cartan_invariants_matrix()
+ sage: A = Z12.algebra(QQ) # optional - sage.modules
+ sage: A.cartan_invariants_matrix() # optional - sage.modules
[1 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0]
[0 0 2 0 0 0 0 0 0]
@@ -677,9 +679,9 @@ def cartan_invariants_matrix(self):
With the algebra of the `0`-Hecke monoid::
- sage: from sage.monoids.hecke_monoid import HeckeMonoid
- sage: A = HeckeMonoid(SymmetricGroup(4)).algebra(QQ)
- sage: A.cartan_invariants_matrix()
+ sage: from sage.monoids.hecke_monoid import HeckeMonoid # optional - sage.groups sage.modules
+ sage: A = HeckeMonoid(SymmetricGroup(4)).algebra(QQ) # optional - sage.groups sage.modules
+ sage: A.cartan_invariants_matrix() # optional - sage.groups sage.modules
[1 0 0 0 0 0 0 0]
[0 2 1 0 1 1 0 0]
[0 1 1 0 1 0 0 0]
@@ -739,10 +741,10 @@ def isotypic_projective_modules(self, side='left'):
An example of a finite dimensional algebra with basis:
the path algebra of the Kronecker quiver
(containing the arrows a:x->y and b:x->y) over Rational Field
- sage: Q = A.isotypic_projective_modules(side="left"); Q
+ sage: Q = A.isotypic_projective_modules(side="left"); Q # optional - sage.rings.number_field
[Free module generated by {0} over Rational Field,
Free module generated by {0, 1, 2} over Rational Field]
- sage: [[x.lift() for x in Qi.basis()]
+ sage: [[x.lift() for x in Qi.basis()] # optional - sage.rings.number_field
....: for Qi in Q]
[[x],
[y, a, b]]
@@ -750,7 +752,7 @@ def isotypic_projective_modules(self, side='left'):
We check that the sum of the dimensions of the isotypic
projective modules is the dimension of ``self``::
- sage: sum([Qi.dimension() for Qi in Q]) == A.dimension()
+ sage: sum([Qi.dimension() for Qi in Q]) == A.dimension() # optional - sage.rings.number_field
True
.. SEEALSO::
@@ -782,19 +784,19 @@ def peirce_summand(self, ei, ej):
EXAMPLES::
sage: A = Algebras(QQ).FiniteDimensional().WithBasis().example()
- sage: idemp = A.orthogonal_idempotents_central_mod_radical()
- sage: A.peirce_summand(idemp[0], idemp[1])
+ sage: idemp = A.orthogonal_idempotents_central_mod_radical() # optional - sage.rings.number_field
+ sage: A.peirce_summand(idemp[0], idemp[1]) # optional - sage.rings.number_field
Free module generated by {0, 1} over Rational Field
- sage: A.peirce_summand(idemp[1], idemp[0])
+ sage: A.peirce_summand(idemp[1], idemp[0]) # optional - sage.rings.number_field
Free module generated by {} over Rational Field
We recover the `2\times2` block of `\QQ[S_4]`
corresponding to the unique simple module of dimension `2`
of the symmetric group `S_4`::
- sage: A4 = SymmetricGroup(4).algebra(QQ)
- sage: e = A4.central_orthogonal_idempotents()[2]
- sage: A4.peirce_summand(e, e)
+ sage: A4 = SymmetricGroup(4).algebra(QQ) # optional - sage.groups
+ sage: e = A4.central_orthogonal_idempotents()[2] # optional - sage.groups sage.rings.number_field
+ sage: A4.peirce_summand(e, e) # optional - sage.groups sage.rings.number_field
Free module generated by {0, 1, 2, 3} over Rational Field
TESTS:
@@ -802,11 +804,11 @@ def peirce_summand(self, ei, ej):
We check each idempotent belong to its own Peirce summand
(see :trac:`24687`)::
- sage: from sage.monoids.hecke_monoid import HeckeMonoid
- sage: M = HeckeMonoid(SymmetricGroup(4))
- sage: A = M.algebra(QQ)
- sage: Idms = A.orthogonal_idempotents_central_mod_radical()
- sage: all(A.peirce_summand(e, e).retract(e)
+ sage: from sage.monoids.hecke_monoid import HeckeMonoid # optional - sage.groups
+ sage: M = HeckeMonoid(SymmetricGroup(4)) # optional - sage.groups
+ sage: A = M.algebra(QQ) # optional - sage.groups
+ sage: Idms = A.orthogonal_idempotents_central_mod_radical() # optional - sage.groups sage.rings.number_field
+ sage: all(A.peirce_summand(e, e).retract(e) # optional - sage.groups sage.rings.number_field
....: in A.peirce_summand(e, e) for e in Idms)
True
"""
@@ -863,14 +865,14 @@ def peirce_decomposition(self, idempotents=None, check=True):
An example of a finite dimensional algebra with basis:
the path algebra of the Kronecker quiver
(containing the arrows a:x->y and b:x->y) over Rational Field
- sage: A.orthogonal_idempotents_central_mod_radical()
+ sage: A.orthogonal_idempotents_central_mod_radical() # optional - sage.groups
(x, y)
- sage: decomposition = A.peirce_decomposition(); decomposition
+ sage: decomposition = A.peirce_decomposition(); decomposition # optional - sage.groups sage.modules sage.rings.number_field
[[Free module generated by {0} over Rational Field,
Free module generated by {0, 1} over Rational Field],
[Free module generated by {} over Rational Field,
Free module generated by {0} over Rational Field]]
- sage: [ [[x.lift() for x in decomposition[i][j].basis()]
+ sage: [ [[x.lift() for x in decomposition[i][j].basis()] # optional - sage.groups sage.modules sage.rings.number_field
....: for j in range(2)]
....: for i in range(2)]
[[[x], [a, b]],
@@ -879,9 +881,9 @@ def peirce_decomposition(self, idempotents=None, check=True):
We recover that the group algebra of the symmetric group
`S_4` is a block matrix algebra::
- sage: A = SymmetricGroup(4).algebra(QQ)
- sage: decomposition = A.peirce_decomposition() # long time
- sage: [[decomposition[i][j].dimension() # long time (4s)
+ sage: A = SymmetricGroup(4).algebra(QQ) # optional - sage.groups sage.modules
+ sage: decomposition = A.peirce_decomposition() # long time # optional - sage.groups sage.modules sage.rings.number_field
+ sage: [[decomposition[i][j].dimension() # long time (4s) # optional - sage.groups sage.modules sage.rings.number_field
....: for j in range(len(decomposition))]
....: for i in range(len(decomposition))]
[[9, 0, 0, 0, 0],
@@ -894,7 +896,7 @@ def peirce_decomposition(self, idempotents=None, check=True):
dimension of the corresponding simple module of `S_4`. The
latter are given by::
- sage: [p.standard_tableaux().cardinality() for p in Partitions(4)]
+ sage: [p.standard_tableaux().cardinality() for p in Partitions(4)] # optional - sage.combinat
[1, 3, 2, 3, 1]
"""
if idempotents is None:
@@ -926,9 +928,9 @@ def is_identity_decomposition_into_orthogonal_idempotents(self, l):
sage: A.is_identity_decomposition_into_orthogonal_idempotents([A.one()])
True
- sage: A.is_identity_decomposition_into_orthogonal_idempotents([x,y])
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents([x, y])
True
- sage: A.is_identity_decomposition_into_orthogonal_idempotents([x+a, y-a])
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents([x + a, y - a])
True
Here the idempotents do not sum up to `1`::
@@ -938,15 +940,15 @@ def is_identity_decomposition_into_orthogonal_idempotents(self, l):
Here `1+x` and `-x` are neither idempotent nor orthogonal::
- sage: A.is_identity_decomposition_into_orthogonal_idempotents([1+x,-x])
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents([1 + x, -x])
False
With the algebra of the `0`-Hecke monoid::
- sage: from sage.monoids.hecke_monoid import HeckeMonoid
- sage: A = HeckeMonoid(SymmetricGroup(4)).algebra(QQ)
- sage: idempotents = A.orthogonal_idempotents_central_mod_radical()
- sage: A.is_identity_decomposition_into_orthogonal_idempotents(idempotents)
+ sage: from sage.monoids.hecke_monoid import HeckeMonoid # optional - sage.groups
+ sage: A = HeckeMonoid(SymmetricGroup(4)).algebra(QQ) # optional - sage.groups sage.modules
+ sage: idempotents = A.orthogonal_idempotents_central_mod_radical() # optional - sage.groups sage.modules sage.rings.number_field
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents(idempotents) # optional - sage.groups sage.modules sage.rings.number_field
True
Here are some more counterexamples:
@@ -971,40 +973,40 @@ def is_identity_decomposition_into_orthogonal_idempotents(self, l):
....: def product_on_basis(self, w1, w2):
....: return self.from_vector(vector(w1*w2))
sage: R. = PolynomialRing(QQ)
- sage: A = PQAlgebra(QQ, x**3 - x**2 + x + 1); y = A.x()
- sage: a, b = y, 1-y
- sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, b))
+ sage: A = PQAlgebra(QQ, x**3 - x**2 + x + 1); y = A.x() # optional - sage.libs.pari
+ sage: a, b = y, 1 - y # optional - sage.libs.pari
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, b)) # optional - sage.libs.pari
False
For comparison::
- sage: A = PQAlgebra(QQ, x**2 - x); y = A.x()
- sage: a, b = y, 1-y
- sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, b))
+ sage: A = PQAlgebra(QQ, x**2 - x); y = A.x() # optional - sage.libs.pari
+ sage: a, b = y, 1-y # optional - sage.libs.pari
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, b)) # optional - sage.libs.pari
True
- sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, A.zero(), b))
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, A.zero(), b)) # optional - sage.libs.pari
True
- sage: A = PQAlgebra(QQ, x**3 - x**2 + x - 1); y = A.x()
- sage: a = (y**2 + 1) / 2
- sage: b = 1 - a
- sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, b))
+ sage: A = PQAlgebra(QQ, x**3 - x**2 + x - 1); y = A.x() # optional - sage.libs.pari
+ sage: a = (y**2 + 1) / 2 # optional - sage.libs.pari
+ sage: b = 1 - a # optional - sage.libs.pari
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, b)) # optional - sage.libs.pari
True
2. Some idempotents summing to 1 but not orthogonal::
- sage: R. = PolynomialRing(GF(2))
- sage: A = PQAlgebra(GF(2), x)
- sage: a = A.one()
- sage: A.is_identity_decomposition_into_orthogonal_idempotents((a,))
+ sage: R. = PolynomialRing(GF(2)) # optional - sage.rings.finite_rings
+ sage: A = PQAlgebra(GF(2), x) # optional - sage.rings.finite_rings
+ sage: a = A.one() # optional - sage.rings.finite_rings
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents((a,)) # optional - sage.rings.finite_rings
True
- sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, a, a))
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents((a, a, a)) # optional - sage.rings.finite_rings
False
3. Some orthogonal idempotents not summing to the identity::
- sage: A.is_identity_decomposition_into_orthogonal_idempotents((a,a))
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents((a,a)) # optional - sage.rings.finite_rings
False
- sage: A.is_identity_decomposition_into_orthogonal_idempotents(())
+ sage: A.is_identity_decomposition_into_orthogonal_idempotents(()) # optional - sage.rings.finite_rings
False
"""
return (self.sum(l) == self.one()
@@ -1019,11 +1021,11 @@ def is_commutative(self):
EXAMPLES::
- sage: S4 = SymmetricGroupAlgebra(QQ, 4)
- sage: S4.is_commutative()
+ sage: S4 = SymmetricGroupAlgebra(QQ, 4) # optional - sage.groups sage.modules
+ sage: S4.is_commutative() # optional - sage.groups sage.modules
False
- sage: S2 = SymmetricGroupAlgebra(QQ, 2)
- sage: S2.is_commutative()
+ sage: S2 = SymmetricGroupAlgebra(QQ, 2) # optional - sage.groups sage.modules
+ sage: S2.is_commutative() # optional - sage.groups sage.modules
True
"""
B = list(self.basis())
@@ -1047,23 +1049,23 @@ def to_matrix(self, base_ring=None, action=operator.mul, side='left'):
EXAMPLES::
- sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
- sage: a = QS3([2,1,3])
- sage: a.to_matrix(side='left')
+ sage: QS3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: a = QS3([2,1,3]) # optional - sage.groups sage.modules
+ sage: a.to_matrix(side='left') # optional - sage.groups sage.modules
[0 0 1 0 0 0]
[0 0 0 0 1 0]
[1 0 0 0 0 0]
[0 0 0 0 0 1]
[0 1 0 0 0 0]
[0 0 0 1 0 0]
- sage: a.to_matrix(side='right')
+ sage: a.to_matrix(side='right') # optional - sage.groups sage.modules
[0 0 1 0 0 0]
[0 0 0 1 0 0]
[1 0 0 0 0 0]
[0 1 0 0 0 0]
[0 0 0 0 0 1]
[0 0 0 0 1 0]
- sage: a.to_matrix(base_ring=RDF, side="left")
+ sage: a.to_matrix(base_ring=RDF, side="left") # optional - sage.groups sage.modules
[0.0 0.0 1.0 0.0 0.0 0.0]
[0.0 0.0 0.0 0.0 1.0 0.0]
[1.0 0.0 0.0 0.0 0.0 0.0]
@@ -1100,47 +1102,47 @@ def __invert__(self):
EXAMPLES::
- sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
- sage: P = Permutation
- sage: a = 3 * QS3(P([1,2,3])) + QS3(P([1,3,2])) + QS3(P([2,1,3]))
- sage: b = ~a; b
+ sage: QS3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: P = Permutation # optional - sage.groups sage.modules
+ sage: a = 3 * QS3(P([1,2,3])) + QS3(P([1,3,2])) + QS3(P([2,1,3])) # optional - sage.groups sage.modules
+ sage: b = ~a; b # optional - sage.groups sage.modules
9/20*[1, 2, 3] - 7/40*[1, 3, 2] - 7/40*[2, 1, 3]
+ 3/40*[2, 3, 1] + 3/40*[3, 1, 2] - 1/20*[3, 2, 1]
- sage: a * b
+ sage: a * b # optional - sage.groups sage.modules
[1, 2, 3]
- sage: ~b == a
+ sage: ~b == a # optional - sage.groups sage.modules
True
- sage: a = 3 * QS3.one()
- sage: b = ~a
- sage: b * a == QS3.one()
+ sage: a = 3 * QS3.one() # optional - sage.groups sage.modules
+ sage: b = ~a # optional - sage.groups sage.modules
+ sage: b * a == QS3.one() # optional - sage.groups sage.modules
True
- sage: b == 1/3 * QS3.one()
+ sage: b == 1/3 * QS3.one() # optional - sage.groups sage.modules
True
- sage: ~b == a
+ sage: ~b == a # optional - sage.groups sage.modules
True
sage: R. = QQ[]
- sage: RS3 = SymmetricGroupAlgebra(R, 3)
- sage: a = RS3(P([1,2,3])) - RS3(P([1,3,2])) + RS3(P([2,1,3])); ~a
+ sage: RS3 = SymmetricGroupAlgebra(R, 3) # optional - sage.groups sage.modules
+ sage: a = RS3(P([1,2,3])) - RS3(P([1,3,2])) + RS3(P([2,1,3])); ~a # optional - sage.groups sage.modules
-1/2*[1, 3, 2] + 1/2*[2, 1, 3] + 1/2*[2, 3, 1] + 1/2*[3, 1, 2]
Some examples on elements that do not have an inverse::
- sage: c = 2 * QS3(P([1,2,3])) + QS3(P([1,3,2])) + QS3(P([2,1,3]))
- sage: ~c
+ sage: c = 2 * QS3(P([1,2,3])) + QS3(P([1,3,2])) + QS3(P([2,1,3])) # optional - sage.groups sage.modules
+ sage: ~c # optional - sage.groups sage.modules
Traceback (most recent call last):
...
ValueError: cannot invert self (= 2*[1, 2, 3] + [1, 3, 2] + [2, 1, 3])
- sage: ZS3 = SymmetricGroupAlgebra(ZZ, 3)
- sage: aZ = 3 * ZS3(P([1,2,3])) + ZS3(P([1,3,2])) + ZS3(P([2,1,3]))
- sage: ~aZ
+ sage: ZS3 = SymmetricGroupAlgebra(ZZ, 3) # optional - sage.groups sage.modules
+ sage: aZ = 3 * ZS3(P([1,2,3])) + ZS3(P([1,3,2])) + ZS3(P([2,1,3])) # optional - sage.groups sage.modules
+ sage: ~aZ # optional - sage.groups sage.modules
Traceback (most recent call last):
...
ValueError: cannot invert self (= 3*[1, 2, 3] + [1, 3, 2] + [2, 1, 3])
- sage: x = 2 * ZS3.one()
- sage: ~x
+ sage: x = 2 * ZS3.one() # optional - sage.groups sage.modules
+ sage: ~x # optional - sage.groups sage.modules
Traceback (most recent call last):
...
ValueError: cannot invert self (= 2*[1, 2, 3])
@@ -1149,9 +1151,9 @@ def __invert__(self):
An algebra that does not define ``one_basis()``::
- sage: I = DescentAlgebra(QQ, 3).I()
- sage: a = 3 * I.one()
- sage: ~a == 1/3 * I.one()
+ sage: I = DescentAlgebra(QQ, 3).I() # optional - sage.combinat sage.modules
+ sage: a = 3 * I.one() # optional - sage.combinat sage.modules
+ sage: ~a == 1/3 * I.one() # optional - sage.combinat sage.modules
True
"""
alg = self.parent()
@@ -1239,8 +1241,8 @@ def _test_cellular(self, **options):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 3)
- sage: S._test_cellular()
+ sage: S = SymmetricGroupAlgebra(QQ, 3) # optional - sage.combinat sage.modules
+ sage: S._test_cellular() # optional - sage.combinat sage.modules
"""
tester = self._tester(**options)
cell_basis = self.cellular_basis()
@@ -1273,8 +1275,8 @@ def cell_poset(self):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 4)
- sage: S.cell_poset()
+ sage: S = SymmetricGroupAlgebra(QQ, 4) # optional - sage.groups sage.modules
+ sage: S.cell_poset() # optional - sage.groups sage.modules
Finite poset containing 5 elements
"""
@@ -1288,8 +1290,8 @@ def cell_module_indices(self, mu):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 3)
- sage: S.cell_module_indices([2,1])
+ sage: S = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: S.cell_module_indices([2,1]) # optional - sage.groups sage.modules
Standard tableaux of shape [2, 1]
"""
@@ -1301,8 +1303,8 @@ def _to_cellular_element(self, i):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 3)
- sage: S._to_cellular_element # no implementation currently uses this
+ sage: S = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: S._to_cellular_element # no implementation currently uses this # optional - sage.groups sage.modules
NotImplemented
"""
@@ -1314,13 +1316,12 @@ def _from_cellular_index(self, x):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 3)
- sage: mu = Partition([2,1])
- sage: s = StandardTableau([[1,2],[3]])
- sage: t = StandardTableau([[1,3],[2]])
- sage: S._from_cellular_index((mu, s, t))
- 1/4*[1, 3, 2] - 1/4*[2, 3, 1] + 1/4*[3, 1, 2]
- - 1/4*[3, 2, 1]
+ sage: S = SymmetricGroupAlgebra(QQ, 3) # optional - sage.combinat sage.groups sage.modules
+ sage: mu = Partition([2,1]) # optional - sage.combinat sage.groups sage.modules
+ sage: s = StandardTableau([[1,2],[3]]) # optional - sage.combinat sage.groups sage.modules
+ sage: t = StandardTableau([[1,3],[2]]) # optional - sage.combinat sage.groups sage.modules
+ sage: S._from_cellular_index((mu, s, t)) # optional - sage.combinat sage.groups sage.modules
+ 1/4*[1, 3, 2] - 1/4*[2, 3, 1] + 1/4*[3, 1, 2] - 1/4*[3, 2, 1]
"""
def cellular_involution(self, x):
@@ -1329,8 +1330,8 @@ def cellular_involution(self, x):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 3)
- sage: for b in S.basis(): b, S.cellular_involution(b)
+ sage: S = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: for b in S.basis(): b, S.cellular_involution(b) # optional - sage.groups sage.modules
([1, 2, 3], [1, 2, 3])
([1, 3, 2], 49/48*[1, 3, 2] + 7/48*[2, 3, 1]
- 7/48*[3, 1, 2] - 1/48*[3, 2, 1])
@@ -1356,8 +1357,8 @@ def cells(self):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 3)
- sage: dict(S.cells())
+ sage: S = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: dict(S.cells()) # optional - sage.groups sage.modules
{[1, 1, 1]: Standard tableaux of shape [1, 1, 1],
[2, 1]: Standard tableaux of shape [2, 1],
[3]: Standard tableaux of shape [3]}
@@ -1371,8 +1372,8 @@ def cellular_basis(self):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 3)
- sage: S.cellular_basis()
+ sage: S = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: S.cellular_basis() # optional - sage.groups sage.modules
Cellular basis of Symmetric group algebra of order 3
over Rational Field
"""
@@ -1385,8 +1386,8 @@ def cell_module(self, mu, **kwds):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 3)
- sage: S.cell_module(Partition([2,1]))
+ sage: S = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: S.cell_module(Partition([2,1])) # optional - sage.combinat sage.groups sage.modules
Cell module indexed by [2, 1] of Cellular basis of
Symmetric group algebra of order 3 over Rational Field
"""
@@ -1404,8 +1405,8 @@ def simple_module_parameterization(self):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 4)
- sage: S.simple_module_parameterization()
+ sage: S = SymmetricGroupAlgebra(QQ, 4) # optional - sage.groups sage.modules
+ sage: S.simple_module_parameterization() # optional - sage.groups sage.modules
([4], [3, 1], [2, 2], [2, 1, 1], [1, 1, 1, 1])
"""
return tuple([mu for mu in self.cell_poset()
@@ -1418,12 +1419,12 @@ def cellular_involution(self):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 4)
- sage: elt = S([3,1,2,4])
- sage: ci = elt.cellular_involution(); ci
+ sage: S = SymmetricGroupAlgebra(QQ, 4) # optional - sage.groups sage.modules
+ sage: elt = S([3,1,2,4]) # optional - sage.groups sage.modules
+ sage: ci = elt.cellular_involution(); ci # optional - sage.groups sage.modules
7/48*[1, 3, 2, 4] + 49/48*[2, 3, 1, 4]
- 1/48*[3, 1, 2, 4] - 7/48*[3, 2, 1, 4]
- sage: ci.cellular_involution()
+ sage: ci.cellular_involution() # optional - sage.groups sage.modules
[3, 1, 2, 4]
"""
return self.parent().cellular_involution(self)
@@ -1455,10 +1456,10 @@ def cell_poset(self):
EXAMPLES::
- sage: S2 = SymmetricGroupAlgebra(QQ, 2)
- sage: S3 = SymmetricGroupAlgebra(QQ, 3)
- sage: T = S2.tensor(S3)
- sage: T.cell_poset()
+ sage: S2 = SymmetricGroupAlgebra(QQ, 2) # optional - sage.groups sage.modules
+ sage: S3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: T = S2.tensor(S3) # optional - sage.groups sage.modules
+ sage: T.cell_poset() # optional - sage.combinat sage.graphs sage.groups sage.modules
Finite poset containing 6 elements
"""
ret = self._sets[0].cell_poset()
@@ -1475,10 +1476,10 @@ def cell_module_indices(self, mu):
EXAMPLES::
- sage: S2 = SymmetricGroupAlgebra(QQ, 2)
- sage: S3 = SymmetricGroupAlgebra(QQ, 3)
- sage: T = S2.tensor(S3)
- sage: T.cell_module_indices(([1,1], [2,1]))
+ sage: S2 = SymmetricGroupAlgebra(QQ, 2) # optional - sage.groups sage.modules
+ sage: S3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: T = S2.tensor(S3) # optional - sage.groups sage.modules
+ sage: T.cell_module_indices(([1,1], [2,1])) # optional - sage.groups sage.modules
The Cartesian product of (Standard tableaux of shape [1, 1],
Standard tableaux of shape [2, 1])
"""
@@ -1494,10 +1495,10 @@ def cellular_involution(self):
EXAMPLES::
- sage: S2 = SymmetricGroupAlgebra(QQ, 2)
- sage: S3 = SymmetricGroupAlgebra(QQ, 3)
- sage: T = S2.tensor(S3)
- sage: for b in T.basis(): b, T.cellular_involution(b)
+ sage: S2 = SymmetricGroupAlgebra(QQ, 2) # optional - sage.groups sage.modules
+ sage: S3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: T = S2.tensor(S3) # optional - sage.groups sage.modules
+ sage: for b in T.basis(): b, T.cellular_involution(b) # optional - sage.groups sage.modules
([1, 2] # [1, 2, 3], [1, 2] # [1, 2, 3])
([1, 2] # [1, 3, 2],
49/48*[1, 2] # [1, 3, 2] + 7/48*[1, 2] # [2, 3, 1]
@@ -1547,10 +1548,10 @@ def _to_cellular_element(self, i):
EXAMPLES::
- sage: S2 = SymmetricGroupAlgebra(QQ, 2)
- sage: S3 = SymmetricGroupAlgebra(QQ, 3)
- sage: T = S2.tensor(S3)
- sage: all(T(T._to_cellular_element(k)).leading_support() == k
+ sage: S2 = SymmetricGroupAlgebra(QQ, 2) # optional - sage.groups sage.modules
+ sage: S3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: T = S2.tensor(S3) # optional - sage.groups sage.modules
+ sage: all(T(T._to_cellular_element(k)).leading_support() == k # optional - sage.groups sage.modules
....: for k in T.basis().keys())
True
"""
@@ -1583,11 +1584,11 @@ def _from_cellular_index(self, x):
EXAMPLES::
- sage: S2 = SymmetricGroupAlgebra(QQ, 2)
- sage: S3 = SymmetricGroupAlgebra(QQ, 3)
- sage: T = S2.tensor(S3)
- sage: C = T.cellular_basis()
- sage: all(C(T._from_cellular_index(k)).leading_support() == k
+ sage: S2 = SymmetricGroupAlgebra(QQ, 2) # optional - sage.groups sage.modules
+ sage: S3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: T = S2.tensor(S3) # optional - sage.groups sage.modules
+ sage: C = T.cellular_basis() # optional - sage.groups sage.modules
+ sage: all(C(T._from_cellular_index(k)).leading_support() == k # optional - sage.groups sage.modules
....: for k in C.basis().keys())
True
"""
diff --git a/src/sage/categories/finite_dimensional_graded_lie_algebras_with_basis.py b/src/sage/categories/finite_dimensional_graded_lie_algebras_with_basis.py
index 4bbdf0807b1..e10e30a5846 100644
--- a/src/sage/categories/finite_dimensional_graded_lie_algebras_with_basis.py
+++ b/src/sage/categories/finite_dimensional_graded_lie_algebras_with_basis.py
@@ -55,12 +55,12 @@ def _test_grading(self, **options):
sage: C = LieAlgebras(QQ).WithBasis().Graded()
sage: C = C.FiniteDimensional().Stratified().Nilpotent()
- sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}},
+ sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}}, # optional - sage.combinat sage.modules
....: nilpotent=True, category=C)
- sage: L._test_grading()
- sage: L = LieAlgebra(QQ, {('x','y'): {'x': 1}},
+ sage: L._test_grading() # optional - sage.combinat sage.modules
+ sage: L = LieAlgebra(QQ, {('x','y'): {'x': 1}}, # optional - sage.combinat sage.modules
....: nilpotent=True, category=C)
- sage: L._test_grading()
+ sage: L._test_grading() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
AssertionError: Lie bracket [x, y] has degree 1, not degree 2
@@ -96,9 +96,9 @@ def homogeneous_component_as_submodule(self, d):
sage: C = LieAlgebras(QQ).WithBasis().Graded()
sage: C = C.FiniteDimensional().Stratified().Nilpotent()
- sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}},
+ sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}}, # optional - sage.combinat sage.modules
....: nilpotent=True, category=C)
- sage: L.homogeneous_component_as_submodule(2)
+ sage: L.homogeneous_component_as_submodule(2) # optional - sage.combinat sage.modules
Sparse vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
[0 0 1]
@@ -147,12 +147,12 @@ def _test_generated_by_degree_one(self, **options):
sage: C = LieAlgebras(QQ).WithBasis().Graded()
sage: C = C.FiniteDimensional().Stratified().Nilpotent()
sage: sc = {('x','y'): {'z': 1}}
- sage: L. = LieAlgebra(QQ, sc, nilpotent=True, category=C)
- sage: L._test_generated_by_degree_one()
+ sage: L. = LieAlgebra(QQ, sc, nilpotent=True, category=C) # optional - sage.combinat sage.modules
+ sage: L._test_generated_by_degree_one() # optional - sage.combinat sage.modules
sage: sc = {('x','y'): {'z': 1}, ('a','b'): {'c':1}, ('z','c'): {'m':1}}
- sage: L. = LieAlgebra(QQ, sc, nilpotent=True, category=C)
- sage: L._test_generated_by_degree_one()
+ sage: L. = LieAlgebra(QQ, sc, nilpotent=True, category=C) # optional - sage.combinat sage.modules
+ sage: L._test_generated_by_degree_one() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
AssertionError: [a, b, x, y] does not generate Nilpotent Lie algebra
@@ -199,16 +199,16 @@ def degree_on_basis(self, m):
sage: C = LieAlgebras(QQ).WithBasis().Graded()
sage: C = C.FiniteDimensional().Stratified().Nilpotent()
sage: sc = {('X','Y'): {'Z': 1}}
- sage: L. = LieAlgebra(QQ, sc, nilpotent=True, category=C)
- sage: L.degree_on_basis(X.leading_support())
+ sage: L. = LieAlgebra(QQ, sc, nilpotent=True, category=C) # optional - sage.combinat sage.modules
+ sage: L.degree_on_basis(X.leading_support()) # optional - sage.combinat sage.modules
1
- sage: X.degree()
+ sage: X.degree() # optional - sage.combinat sage.modules
1
- sage: Y.degree()
+ sage: Y.degree() # optional - sage.combinat sage.modules
1
- sage: L[X, Y]
+ sage: L[X, Y] # optional - sage.combinat sage.modules
Z
- sage: Z.degree()
+ sage: Z.degree() # optional - sage.combinat sage.modules
2
"""
if not hasattr(self, '_basis_degrees'):
diff --git a/src/sage/categories/finite_dimensional_lie_algebras_with_basis.py b/src/sage/categories/finite_dimensional_lie_algebras_with_basis.py
index 487924b5748..3637ea46298 100644
--- a/src/sage/categories/finite_dimensional_lie_algebras_with_basis.py
+++ b/src/sage/categories/finite_dimensional_lie_algebras_with_basis.py
@@ -46,13 +46,13 @@ def example(self, n=3):
EXAMPLES::
sage: C = LieAlgebras(QQ).FiniteDimensional().WithBasis()
- sage: C.example()
+ sage: C.example() # optional - sage.modules
An example of a finite dimensional Lie algebra with basis:
the 3-dimensional abelian Lie algebra over Rational Field
Other dimensions can be specified as an optional argument::
- sage: C.example(5)
+ sage: C.example(5) # optional - sage.modules
An example of a finite dimensional Lie algebra with basis:
the 5-dimensional abelian Lie algebra over Rational Field
"""
@@ -70,27 +70,29 @@ def _construct_UEA(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: UEA = L._construct_UEA(); UEA
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules sage.combinat
+ sage: UEA = L._construct_UEA(); UEA # optional - sage.modules sage.combinat
Noncommutative Multivariate Polynomial Ring in b0, b1, b2
over Rational Field, nc-relations: {}
- sage: UEA.relations(add_commutative=True)
+ sage: UEA.relations(add_commutative=True) # optional - sage.modules sage.combinat
{b1*b0: b0*b1, b2*b0: b0*b2, b2*b1: b1*b2}
::
- sage: L. = LieAlgebra(QQ, {('x','y'):{'z':1}, ('y','z'):{'x':1}, ('z','x'):{'y':1}})
- sage: UEA = L._construct_UEA(); UEA
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'z':1}, # optional - sage.modules sage.combinat
+ ....: ('y','z'): {'x':1},
+ ....: ('z','x'):{'y':1}})
+ sage: UEA = L._construct_UEA(); UEA # optional - sage.modules sage.combinat
Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field,
nc-relations: {...}
- sage: sorted(UEA.relations().items(), key=str)
+ sage: sorted(UEA.relations().items(), key=str) # optional - sage.modules sage.combinat
[(y*x, x*y - z), (z*x, x*z + y), (z*y, y*z - x)]
Singular's ``nc_algebra`` does not work over `\ZZ/6\ZZ`,
so we fallback to the PBW basis in this case::
- sage: L = lie_algebras.pwitt(Zmod(6), 6)
- sage: L._construct_UEA()
+ sage: L = lie_algebras.pwitt(Zmod(6), 6) # optional - sage.modules sage.combinat
+ sage: L._construct_UEA() # optional - sage.modules sage.combinat
Universal enveloping algebra of
The 6-Witt Lie algebra over Ring of integers modulo 6
in the Poincare-Birkhoff-Witt basis
@@ -147,8 +149,8 @@ def _basis_ordering(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L._basis_ordering
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules sage.combinat
+ sage: L._basis_ordering # optional - sage.modules sage.combinat
(0, 1, 2)
"""
return tuple(self.basis().keys())
@@ -161,10 +163,10 @@ def _basis_key_inverse(self):
EXAMPLES::
- sage: G = SymmetricGroup(3)
- sage: S = GroupAlgebra(G, QQ)
- sage: L = LieAlgebra(associative=S)
- sage: [L._basis_key_inverse[k] for k in L._basis_ordering]
+ sage: G = SymmetricGroup(3) # optional - sage.groups
+ sage: S = GroupAlgebra(G, QQ) # optional - sage.groups sage.modules
+ sage: L = LieAlgebra(associative=S) # optional - sage.groups sage.modules
+ sage: [L._basis_key_inverse[k] for k in L._basis_ordering] # optional - sage.groups sage.modules
[0, 1, 2, 3, 4, 5]
"""
return {k: i for i,k in enumerate(self._basis_ordering)}
@@ -175,33 +177,34 @@ def _basis_key(self, x):
TESTS::
- sage: L = lie_algebras.three_dimensional_by_rank(QQ, 3, names=['E','F','H'])
- sage: PBW = L.pbw_basis()
- sage: PBW._basis_key('E') < PBW._basis_key('H')
+ sage: L = lie_algebras.three_dimensional_by_rank(QQ, 3, # optional - sage.groups sage.modules
+ ....: names=['E','F','H'])
+ sage: PBW = L.pbw_basis() # optional - sage.groups sage.modules
+ sage: PBW._basis_key('E') < PBW._basis_key('H') # optional - sage.groups sage.modules
True
::
- sage: L = lie_algebras.sl(QQ, 2)
- sage: def neg_key(x):
+ sage: L = lie_algebras.sl(QQ, 2) # optional - sage.groups sage.modules
+ sage: def neg_key(x): # optional - sage.groups sage.modules
....: return -L.basis().keys().index(x)
- sage: PBW = L.pbw_basis(basis_key=neg_key)
- sage: prod(PBW.gens()) # indirect doctest
+ sage: PBW = L.pbw_basis(basis_key=neg_key) # optional - sage.groups sage.modules
+ sage: prod(PBW.gens()) # indirect doctest # optional - sage.groups sage.modules
PBW[-alpha[1]]*PBW[alphacheck[1]]*PBW[alpha[1]]
- 4*PBW[-alpha[1]]*PBW[alpha[1]] + PBW[alphacheck[1]]^2
- 2*PBW[alphacheck[1]]
Check that :trac:`23266` is fixed::
- sage: sl2 = lie_algebras.sl(QQ, 2, 'matrix')
- sage: sl2.indices()
+ sage: sl2 = lie_algebras.sl(QQ, 2, 'matrix') # optional - sage.groups sage.modules
+ sage: sl2.indices() # optional - sage.groups sage.modules
{'e1', 'f1', 'h1'}
- sage: type(sl2.basis().keys())
+ sage: type(sl2.basis().keys()) # optional - sage.groups sage.modules
- sage: Usl2 = sl2.pbw_basis()
- sage: Usl2._basis_key(2)
+ sage: Usl2 = sl2.pbw_basis() # optional - sage.groups sage.modules
+ sage: Usl2._basis_key(2) # optional - sage.groups sage.modules
2
- sage: Usl2._basis_key(3)
+ sage: Usl2._basis_key(3) # optional - sage.groups sage.modules
Traceback (most recent call last):
...
KeyError: 3
@@ -214,8 +217,8 @@ def _dense_free_module(self, R=None):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L._dense_free_module()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: L._dense_free_module() # optional - sage.modules
Vector space of dimension 3 over Rational Field
"""
if R is None:
@@ -237,10 +240,10 @@ def from_vector(self, v, order=None):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: u = L.from_vector(vector(QQ, (1, 0, 0))); u
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: u = L.from_vector(vector(QQ, (1, 0, 0))); u # optional - sage.modules
(1, 0, 0)
- sage: parent(u) is L
+ sage: parent(u) is L # optional - sage.modules
True
"""
if order is None:
@@ -260,17 +263,17 @@ def killing_matrix(self, x, y):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a,b,c = L.lie_algebra_generators()
- sage: L.killing_matrix(a, b)
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.modules
+ sage: L.killing_matrix(a, b) # optional - sage.modules
[0 0 0]
[0 0 0]
[0 0 0]
::
- sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}})
- sage: L.killing_matrix(y, x)
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.killing_matrix(y, x) # optional - sage.combinat sage.modules
[ 0 -1]
[ 0 0]
"""
@@ -291,9 +294,9 @@ def killing_form(self, x, y):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a,b,c = L.lie_algebra_generators()
- sage: L.killing_form(a, b)
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L.killing_form(a, b) # optional - sage.combinat sage.modules
0
"""
return self.killing_matrix(x, y).trace()
@@ -309,16 +312,16 @@ def killing_form_matrix(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.killing_form_matrix()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: L.killing_form_matrix() # optional - sage.modules
[0 0 0]
[0 0 0]
[0 0 0]
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example(0)
- sage: m = L.killing_form_matrix(); m
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example(0) # optional - sage.modules
+ sage: m = L.killing_form_matrix(); m # optional - sage.modules
[]
- sage: parent(m)
+ sage: parent(m) # optional - sage.modules
Full MatrixSpace of 0 by 0 dense matrices over Rational Field
"""
from sage.matrix.constructor import matrix
@@ -347,18 +350,18 @@ def structure_coefficients(self, include_zeros=False):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.structure_coefficients()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: L.structure_coefficients() # optional - sage.modules
Finite family {}
- sage: L.structure_coefficients(True)
+ sage: L.structure_coefficients(True) # optional - sage.modules
Finite family {(0, 1): (0, 0, 0), (0, 2): (0, 0, 0), (1, 2): (0, 0, 0)}
::
- sage: G = SymmetricGroup(3)
- sage: S = GroupAlgebra(G, QQ)
- sage: L = LieAlgebra(associative=S)
- sage: L.structure_coefficients()
+ sage: G = SymmetricGroup(3) # optional - sage.groups
+ sage: S = GroupAlgebra(G, QQ) # optional - sage.groups sage.modules
+ sage: L = LieAlgebra(associative=S) # optional - sage.groups sage.modules sage.combinat
+ sage: L.structure_coefficients() # optional - sage.groups sage.modules sage.combinat
Finite family {((2,3), (1,2)): (1,2,3) - (1,3,2),
((2,3), (1,3)): -(1,2,3) + (1,3,2),
((1,2,3), (2,3)): -(1,2) + (1,3),
@@ -401,23 +404,23 @@ def centralizer_basis(self, S):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a,b,c = L.lie_algebra_generators()
- sage: L.centralizer_basis([a + b, 2*a + c])
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.modules
+ sage: L.centralizer_basis([a + b, 2*a + c]) # optional - sage.modules
[(1, 0, 0), (0, 1, 0), (0, 0, 1)]
- sage: H = lie_algebras.Heisenberg(QQ, 2)
- sage: H.centralizer_basis(H)
+ sage: H = lie_algebras.Heisenberg(QQ, 2) # optional - sage.combinat sage.modules
+ sage: H.centralizer_basis(H) # optional - sage.combinat sage.modules
[z]
- sage: D = DescentAlgebra(QQ, 4).D()
- sage: L = LieAlgebra(associative=D)
- sage: L.centralizer_basis(L)
+ sage: D = DescentAlgebra(QQ, 4).D() # optional - sage.combinat sage.modules
+ sage: L = LieAlgebra(associative=D) # optional - sage.combinat sage.modules
+ sage: L.centralizer_basis(L) # optional - sage.combinat sage.modules
[D{},
D{1} + D{1, 2} + D{2, 3} + D{3},
D{1, 2, 3} + D{1, 3} + D{2}]
- sage: D.center_basis()
+ sage: D.center_basis() # optional - sage.combinat sage.modules
(D{},
D{1} + D{1, 2} + D{2, 3} + D{3},
D{1, 2, 3} + D{1, 3} + D{2})
@@ -465,12 +468,12 @@ def centralizer(self, S):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a,b,c = L.lie_algebra_generators()
- sage: S = L.centralizer([a + b, 2*a + c]); S
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.modules
+ sage: S = L.centralizer([a + b, 2*a + c]); S # optional - sage.modules
An example of a finite dimensional Lie algebra with basis:
the 3-dimensional abelian Lie algebra over Rational Field
- sage: S.basis_matrix()
+ sage: S.basis_matrix() # optional - sage.modules
[1 0 0]
[0 1 0]
[0 0 1]
@@ -483,11 +486,11 @@ def center(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: Z = L.center(); Z
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: Z = L.center(); Z # optional - sage.modules
An example of a finite dimensional Lie algebra with basis: the
3-dimensional abelian Lie algebra over Rational Field
- sage: Z.basis_matrix()
+ sage: Z.basis_matrix() # optional - sage.modules
[1 0 0]
[0 1 0]
[0 0 1]
@@ -514,8 +517,8 @@ def derivations_basis(self):
We construct the derivations of the Heisenberg Lie algebra::
- sage: H = lie_algebras.Heisenberg(QQ, 1)
- sage: H.derivations_basis()
+ sage: H = lie_algebras.Heisenberg(QQ, 1) # optional - sage.combinat sage.modules
+ sage: H.derivations_basis() # optional - sage.combinat sage.modules
(
[1 0 0] [0 1 0] [0 0 0] [0 0 0] [0 0 0] [0 0 0]
[0 0 0] [0 0 0] [1 0 0] [0 1 0] [0 0 0] [0 0 0]
@@ -524,8 +527,8 @@ def derivations_basis(self):
We construct the derivations of `\mathfrak{sl}_2`::
- sage: sl2 = lie_algebras.sl(QQ, 2)
- sage: sl2.derivations_basis()
+ sage: sl2 = lie_algebras.sl(QQ, 2) # optional - sage.combinat sage.modules
+ sage: sl2.derivations_basis() # optional - sage.combinat sage.modules
(
[ 1 0 0] [ 0 1 0] [ 0 0 0]
[ 0 0 0] [ 0 0 -1/2] [ 1 0 0]
@@ -534,9 +537,9 @@ def derivations_basis(self):
We verify these are derivations::
- sage: D = [sl2.module_morphism(matrix=M, codomain=sl2)
+ sage: D = [sl2.module_morphism(matrix=M, codomain=sl2) # optional - sage.combinat sage.modules
....: for M in sl2.derivations_basis()]
- sage: all(d(a.bracket(b)) == d(a).bracket(b) + a.bracket(d(b))
+ sage: all(d(a.bracket(b)) == d(a).bracket(b) + a.bracket(d(b)) # optional - sage.combinat sage.modules
....: for a in sl2.basis() for b in sl2.basis() for d in D)
True
@@ -578,8 +581,8 @@ def inner_derivations_basis(self):
EXAMPLES::
- sage: H = lie_algebras.Heisenberg(QQ, 1)
- sage: H.inner_derivations_basis()
+ sage: H = lie_algebras.Heisenberg(QQ, 1) # optional - sage.combinat sage.modules
+ sage: H.inner_derivations_basis() # optional - sage.combinat sage.modules
(
[0 0 0] [0 0 0]
[0 0 0] [0 0 0]
@@ -606,24 +609,24 @@ def subalgebra(self, *gens, **kwds):
EXAMPLES::
- sage: H = lie_algebras.Heisenberg(QQ, 2)
- sage: p1,p2,q1,q2,z = H.basis()
- sage: S = H.subalgebra([p1, q1])
- sage: S.basis().list()
+ sage: H = lie_algebras.Heisenberg(QQ, 2) # optional - sage.combinat sage.modules
+ sage: p1,p2,q1,q2,z = H.basis() # optional - sage.combinat sage.modules
+ sage: S = H.subalgebra([p1, q1]) # optional - sage.combinat sage.modules
+ sage: S.basis().list() # optional - sage.combinat sage.modules
[p1, q1, z]
- sage: S.basis_matrix()
+ sage: S.basis_matrix() # optional - sage.combinat sage.modules
[1 0 0 0 0]
[0 0 1 0 0]
[0 0 0 0 1]
Passing an extra category to a subalgebra::
- sage: L = LieAlgebra(QQ, 3, step=2)
- sage: x,y,z = L.homogeneous_component_basis(1)
- sage: C = LieAlgebras(QQ).FiniteDimensional().WithBasis()
- sage: C = C.Subobjects().Graded().Stratified()
- sage: S = L.subalgebra([x, y], category=C)
- sage: S.homogeneous_component_basis(2).list()
+ sage: L = LieAlgebra(QQ, 3, step=2) # optional - sage.combinat sage.modules
+ sage: x,y,z = L.homogeneous_component_basis(1) # optional - sage.combinat sage.modules
+ sage: C = LieAlgebras(QQ).FiniteDimensional().WithBasis() # optional - sage.combinat sage.modules
+ sage: C = C.Subobjects().Graded().Stratified() # optional - sage.combinat sage.modules
+ sage: S = L.subalgebra([x, y], category=C) # optional - sage.combinat sage.modules
+ sage: S.homogeneous_component_basis(2).list() # optional - sage.combinat sage.modules
[X_12]
"""
from sage.algebras.lie_algebras.subalgebra import LieSubalgebra_finite_dimensional_with_basis
@@ -645,21 +648,21 @@ def ideal(self, *gens, **kwds):
EXAMPLES::
- sage: H = lie_algebras.Heisenberg(QQ, 2)
- sage: p1,p2,q1,q2,z = H.basis()
- sage: I = H.ideal([p1-p2, q1-q2])
- sage: I.basis().list()
+ sage: H = lie_algebras.Heisenberg(QQ, 2) # optional - sage.combinat sage.modules
+ sage: p1,p2,q1,q2,z = H.basis() # optional - sage.combinat sage.modules
+ sage: I = H.ideal([p1-p2, q1-q2]) # optional - sage.combinat sage.modules
+ sage: I.basis().list() # optional - sage.combinat sage.modules
[-p1 + p2, -q1 + q2, z]
- sage: I.reduce(p1 + p2 + q1 + q2 + z)
+ sage: I.reduce(p1 + p2 + q1 + q2 + z) # optional - sage.combinat sage.modules
2*p1 + 2*q1
Passing an extra category to an ideal::
- sage: L. = LieAlgebra(QQ, abelian=True)
- sage: C = LieAlgebras(QQ).FiniteDimensional().WithBasis()
- sage: C = C.Subobjects().Graded().Stratified()
- sage: I = L.ideal(x, y, category=C)
- sage: I.homogeneous_component_basis(1).list()
+ sage: L. = LieAlgebra(QQ, abelian=True) # optional - sage.combinat sage.modules
+ sage: C = LieAlgebras(QQ).FiniteDimensional().WithBasis() # optional - sage.combinat sage.modules
+ sage: C = C.Subobjects().Graded().Stratified() # optional - sage.combinat sage.modules
+ sage: I = L.ideal(x, y, category=C) # optional - sage.combinat sage.modules
+ sage: I.homogeneous_component_basis(1).list() # optional - sage.combinat sage.modules
[x, y]
"""
from sage.algebras.lie_algebras.subalgebra import LieSubalgebra_finite_dimensional_with_basis
@@ -676,18 +679,18 @@ def is_ideal(self, A):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: I = L.ideal([2*a - c, b + c])
- sage: I.is_ideal(L)
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: I = L.ideal([2*a - c, b + c]) # optional - sage.combinat sage.modules
+ sage: I.is_ideal(L) # optional - sage.combinat sage.modules
True
- sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}})
- sage: L.is_ideal(L)
+ sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.is_ideal(L) # optional - sage.combinat sage.modules
True
- sage: F = LieAlgebra(QQ, 'F', representation='polynomial')
- sage: L.is_ideal(F)
+ sage: F = LieAlgebra(QQ, 'F', representation='polynomial') # optional - sage.combinat sage.modules
+ sage: L.is_ideal(F) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
NotImplementedError: A must be a finite dimensional Lie algebra
@@ -728,26 +731,27 @@ def quotient(self, I, names=None, category=None):
The Engel Lie algebra as a quotient of the free nilpotent Lie algebra
of step 3 with 2 generators::
- sage: L. = LieAlgebra(QQ, 2, step=3)
- sage: E = L.quotient(U); E
- Lie algebra quotient L/I of dimension 4 over Rational Field where
- L: Free Nilpotent Lie algebra on 5 generators (X, Y, Z, W, U) over Rational Field
- I: Ideal (U)
- sage: E.basis().list()
- [X, Y, Z, W]
- sage: E(X).bracket(E(Y))
- Z
- sage: Y.bracket(Z)
- -U
- sage: E(Y).bracket(E(Z))
- 0
- sage: E(U)
- 0
+ sage: L. = LieAlgebra(QQ, 2, step=3) # optional - sage.combinat sage.modules
+ sage: E = L.quotient(U); E # optional - sage.combinat sage.modules
+ Lie algebra quotient L/I of dimension 4 over Rational Field where
+ L: Free Nilpotent Lie algebra on 5 generators (X, Y, Z, W, U)
+ over Rational Field
+ I: Ideal (U)
+ sage: E.basis().list() # optional - sage.combinat sage.modules
+ [X, Y, Z, W]
+ sage: E(X).bracket(E(Y)) # optional - sage.combinat sage.modules
+ Z
+ sage: Y.bracket(Z) # optional - sage.combinat sage.modules
+ -U
+ sage: E(Y).bracket(E(Z)) # optional - sage.combinat sage.modules
+ 0
+ sage: E(U) # optional - sage.combinat sage.modules
+ 0
Quotients when the base ring is not a field are not implemented::
- sage: L = lie_algebras.Heisenberg(ZZ, 1)
- sage: L.quotient(L.an_element())
+ sage: L = lie_algebras.Heisenberg(ZZ, 1) # optional - sage.combinat sage.modules
+ sage: L.quotient(L.an_element()) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
NotImplementedError: quotients over non-fields not implemented
@@ -769,44 +773,46 @@ def product_space(self, L, submodule=False):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a,b,c = L.lie_algebra_generators()
- sage: X = L.subalgebra([a, b+c])
- sage: L.product_space(X)
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a,b,c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: X = L.subalgebra([a, b+c]) # optional - sage.combinat sage.modules
+ sage: L.product_space(X) # optional - sage.combinat sage.modules
An example of a finite dimensional Lie algebra with basis:
the 0-dimensional abelian Lie algebra over Rational Field
- with basis matrix:
- []
- sage: Y = L.subalgebra([a, 2*b-c])
- sage: X.product_space(Y)
+ with basis matrix: []
+ sage: Y = L.subalgebra([a, 2*b-c]) # optional - sage.combinat sage.modules
+ sage: X.product_space(Y) # optional - sage.combinat sage.modules
An example of a finite dimensional Lie algebra with basis:
- the 0-dimensional abelian Lie algebra over Rational
- Field with basis matrix:
- []
+ the 0-dimensional abelian Lie algebra over Rational Field
+ with basis matrix: []
::
- sage: H = lie_algebras.Heisenberg(ZZ, 4)
- sage: Hp = H.product_space(H, submodule=True).basis()
- sage: [H.from_vector(v) for v in Hp]
+ sage: H = lie_algebras.Heisenberg(ZZ, 4) # optional - sage.combinat sage.modules
+ sage: Hp = H.product_space(H, submodule=True).basis() # optional - sage.combinat sage.modules
+ sage: [H.from_vector(v) for v in Hp] # optional - sage.combinat sage.modules
[z]
::
- sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}})
- sage: Lp = L.product_space(L) # todo: not implemented - #17416
- sage: Lp # todo: not implemented - #17416
- Subalgebra generated of Lie algebra on 2 generators (x, y) over Rational Field with basis:
- (x,)
- sage: Lp.product_space(L) # todo: not implemented - #17416
- Subalgebra generated of Lie algebra on 2 generators (x, y) over Rational Field with basis:
- (x,)
- sage: L.product_space(Lp) # todo: not implemented - #17416
- Subalgebra generated of Lie algebra on 2 generators (x, y) over Rational Field with basis:
- (x,)
- sage: Lp.product_space(Lp) # todo: not implemented - #17416
- Subalgebra generated of Lie algebra on 2 generators (x, y) over Rational Field with basis:
- ()
+ sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}}) # optional - sage.combinat sage.modules
+ sage: Lp = L.product_space(L) # todo: not implemented - #17416 # optional - sage.combinat sage.modules
+ sage: Lp # todo: not implemented - #17416 # optional - sage.combinat sage.modules
+ Subalgebra generated of
+ Lie algebra on 2 generators (x, y) over Rational Field
+ with basis: (x,)
+ sage: Lp.product_space(L) # todo: not implemented - #17416 # optional - sage.combinat sage.modules
+ Subalgebra generated of
+ Lie algebra on 2 generators (x, y) over Rational Field
+ with basis: (x,)
+ sage: L.product_space(Lp) # todo: not implemented - #17416 # optional - sage.combinat sage.modules
+ Subalgebra generated of
+ Lie algebra on 2 generators (x, y) over Rational Field
+ with basis: (x,)
+ sage: Lp.product_space(Lp) # todo: not implemented - #17416 # optional - sage.combinat sage.modules
+ Subalgebra generated of
+ Lie algebra on 2 generators (x, y) over Rational Field
+ with basis: ()
"""
from sage.matrix.constructor import matrix
@@ -843,8 +849,8 @@ def derived_subalgebra(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.derived_subalgebra()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.derived_subalgebra() # optional - sage.combinat sage.modules
An example of a finite dimensional Lie algebra with basis:
the 0-dimensional abelian Lie algebra over Rational Field
with basis matrix:
@@ -852,10 +858,10 @@ def derived_subalgebra(self):
If ``self`` is semisimple, then the derived subalgebra is ``self``::
- sage: sl3 = LieAlgebra(QQ, cartan_type=['A',2])
- sage: sl3.derived_subalgebra()
+ sage: sl3 = LieAlgebra(QQ, cartan_type=['A', 2]) # optional - sage.combinat sage.modules
+ sage: sl3.derived_subalgebra() # optional - sage.combinat sage.modules
Lie algebra of ['A', 2] in the Chevalley basis
- sage: sl3 is sl3.derived_subalgebra()
+ sage: sl3 is sl3.derived_subalgebra() # optional - sage.combinat sage.modules
True
"""
@@ -894,24 +900,25 @@ def derived_series(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.derived_series()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.derived_series() # optional - sage.combinat sage.modules
(An example of a finite dimensional Lie algebra with basis:
the 3-dimensional abelian Lie algebra over Rational Field,
An example of a finite dimensional Lie algebra with basis:
the 0-dimensional abelian Lie algebra over Rational Field
- with basis matrix:
- [])
+ with basis matrix: [])
::
- sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}})
- sage: L.derived_series() # todo: not implemented - #17416
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.derived_series() # todo: not implemented - #17416 # optional - sage.combinat sage.modules
(Lie algebra on 2 generators (x, y) over Rational Field,
- Subalgebra generated of Lie algebra on 2 generators (x, y) over Rational Field with basis:
- (x,),
- Subalgebra generated of Lie algebra on 2 generators (x, y) over Rational Field with basis:
- ())
+ Subalgebra generated of
+ Lie algebra on 2 generators (x, y) over Rational Field
+ with basis: (x,),
+ Subalgebra generated of
+ Lie algebra on 2 generators (x, y) over Rational Field
+ with basis: ())
"""
L = [self]
while L[-1].dimension() > 0:
@@ -952,31 +959,30 @@ def lower_central_series(self, submodule=False):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.derived_series()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.derived_series() # optional - sage.combinat sage.modules
(An example of a finite dimensional Lie algebra with basis:
- the 3-dimensional abelian Lie algebra over Rational Field,
+ the 3-dimensional abelian Lie algebra over Rational Field,
An example of a finite dimensional Lie algebra with basis:
- the 0-dimensional abelian Lie algebra over Rational Field
- with basis matrix:
- [])
+ the 0-dimensional abelian Lie algebra over Rational Field
+ with basis matrix: [])
The lower central series as submodules::
- sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}})
- sage: L.lower_central_series(submodule=True)
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.lower_central_series(submodule=True) # optional - sage.combinat sage.modules
(Sparse vector space of dimension 2 over Rational Field,
- Vector space of degree 2 and dimension 1 over Rational Field
- Basis matrix:
- [1 0])
+ Vector space of degree 2 and dimension 1 over Rational Field
+ Basis matrix: [1 0])
::
- sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}})
- sage: L.lower_central_series() # todo: not implemented - #17416
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.lower_central_series() # todo: not implemented - #17416 # optional - sage.combinat sage.modules
(Lie algebra on 2 generators (x, y) over Rational Field,
- Subalgebra generated of Lie algebra on 2 generators (x, y) over Rational Field with basis:
- (x,))
+ Subalgebra generated of
+ Lie algebra on 2 generators (x, y) over Rational Field
+ with basis: (x,))
"""
if submodule:
L = [self.module()]
@@ -995,14 +1001,14 @@ def is_abelian(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.is_abelian()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.is_abelian() # optional - sage.combinat sage.modules
True
::
- sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}})
- sage: L.is_abelian()
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.is_abelian() # optional - sage.combinat sage.modules
False
"""
return len(self.structure_coefficients()) == 0
@@ -1018,14 +1024,14 @@ def is_solvable(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.is_solvable()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.is_solvable() # optional - sage.combinat sage.modules
True
::
- sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}})
- sage: L.is_solvable() # todo: not implemented - #17416
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.is_solvable() # todo: not implemented - #17416 # optional - sage.combinat sage.modules
False
"""
return not self.derived_series()[-1].dimension()
@@ -1039,8 +1045,8 @@ def is_nilpotent(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.is_nilpotent()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.is_nilpotent() # optional - sage.combinat sage.modules
True
"""
return not self.lower_central_series()[-1].dimension()
@@ -1055,8 +1061,8 @@ def is_semisimple(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.is_semisimple()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.is_semisimple() # optional - sage.combinat sage.modules
False
"""
return not self.killing_form_matrix().is_singular()
@@ -1101,24 +1107,24 @@ def chevalley_eilenberg_complex(self, M=None, dual=False, sparse=True, ncpus=Non
EXAMPLES::
- sage: L = lie_algebras.sl(ZZ, 2)
- sage: C = L.chevalley_eilenberg_complex(); C
+ sage: L = lie_algebras.sl(ZZ, 2) # optional - sage.combinat sage.modules
+ sage: C = L.chevalley_eilenberg_complex(); C # optional - sage.combinat sage.modules
Chain complex with at most 4 nonzero terms over Integer Ring
- sage: ascii_art(C)
+ sage: ascii_art(C) # optional - sage.combinat sage.modules
[ 2 0 0] [0]
[ 0 -1 0] [0]
[0 0 0] [ 0 0 2] [0]
0 <-- C_0 <-------- C_1 <----------- C_2 <---- C_3 <-- 0
- sage: L = LieAlgebra(QQ, cartan_type=['C',2])
- sage: C = L.chevalley_eilenberg_complex() # long time
- sage: [C.free_module_rank(i) for i in range(11)] # long time
+ sage: L = LieAlgebra(QQ, cartan_type=['C',2]) # optional - sage.combinat sage.modules
+ sage: C = L.chevalley_eilenberg_complex() # long time # optional - sage.combinat sage.modules
+ sage: [C.free_module_rank(i) for i in range(11)] # long time # optional - sage.combinat sage.modules
[1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1]
- sage: g = lie_algebras.sl(QQ,2)
- sage: E,F,H = g.basis()
- sage: n = g.subalgebra([F,H])
- sage: ascii_art(n.chevalley_eilenberg_complex())
+ sage: g = lie_algebras.sl(QQ, 2) # optional - sage.combinat sage.modules
+ sage: E, F, H = g.basis() # optional - sage.combinat sage.modules
+ sage: n = g.subalgebra([F, H]) # optional - sage.combinat sage.modules
+ sage: ascii_art(n.chevalley_eilenberg_complex()) # optional - sage.combinat sage.modules
[0]
[0 0] [2]
0 <-- C_0 <------ C_1 <---- C_2 <-- 0
@@ -1269,15 +1275,15 @@ def homology(self, deg=None, M=None, sparse=True, ncpus=None):
EXAMPLES::
- sage: L = lie_algebras.cross_product(QQ)
- sage: L.homology()
+ sage: L = lie_algebras.cross_product(QQ) # optional - sage.combinat sage.modules
+ sage: L.homology() # optional - sage.combinat sage.modules
{0: Vector space of dimension 1 over Rational Field,
1: Vector space of dimension 0 over Rational Field,
2: Vector space of dimension 0 over Rational Field,
3: Vector space of dimension 1 over Rational Field}
- sage: L = lie_algebras.pwitt(GF(5), 5)
- sage: L.homology()
+ sage: L = lie_algebras.pwitt(GF(5), 5) # optional - sage.combinat sage.libs.pari sage.modules
+ sage: L.homology() # optional - sage.combinat sage.libs.pari sage.modules
{0: Vector space of dimension 1 over Finite Field of size 5,
1: Vector space of dimension 0 over Finite Field of size 5,
2: Vector space of dimension 1 over Finite Field of size 5,
@@ -1285,9 +1291,9 @@ def homology(self, deg=None, M=None, sparse=True, ncpus=None):
4: Vector space of dimension 0 over Finite Field of size 5,
5: Vector space of dimension 1 over Finite Field of size 5}
- sage: d = {('x', 'y'): {'y': 2}}
- sage: L. = LieAlgebra(ZZ, d)
- sage: L.homology()
+ sage: d = {('x', 'y'): {'y': 2}} # optional - sage.combinat sage.modules
+ sage: L. = LieAlgebra(ZZ, d) # optional - sage.combinat sage.modules
+ sage: L.homology() # optional - sage.combinat sage.modules
{0: Z, 1: Z x C2, 2: 0}
.. SEEALSO::
@@ -1334,8 +1340,8 @@ def cohomology(self, deg=None, M=None, sparse=True, ncpus=None):
EXAMPLES::
- sage: L = lie_algebras.so(QQ, 4)
- sage: L.cohomology()
+ sage: L = lie_algebras.so(QQ, 4) # optional - sage.combinat sage.modules
+ sage: L.cohomology() # optional - sage.combinat sage.modules
{0: Vector space of dimension 1 over Rational Field,
1: Vector space of dimension 0 over Rational Field,
2: Vector space of dimension 0 over Rational Field,
@@ -1344,8 +1350,8 @@ def cohomology(self, deg=None, M=None, sparse=True, ncpus=None):
5: Vector space of dimension 0 over Rational Field,
6: Vector space of dimension 1 over Rational Field}
- sage: L = lie_algebras.Heisenberg(QQ, 2)
- sage: L.cohomology()
+ sage: L = lie_algebras.Heisenberg(QQ, 2) # optional - sage.combinat sage.modules
+ sage: L.cohomology() # optional - sage.combinat sage.modules
{0: Vector space of dimension 1 over Rational Field,
1: Vector space of dimension 4 over Rational Field,
2: Vector space of dimension 5 over Rational Field,
@@ -1353,9 +1359,9 @@ def cohomology(self, deg=None, M=None, sparse=True, ncpus=None):
4: Vector space of dimension 4 over Rational Field,
5: Vector space of dimension 1 over Rational Field}
- sage: d = {('x', 'y'): {'y': 2}}
- sage: L. = LieAlgebra(ZZ, d)
- sage: L.cohomology()
+ sage: d = {('x', 'y'): {'y': 2}} # optional - sage.combinat sage.modules
+ sage: L. = LieAlgebra(ZZ, d) # optional - sage.combinat sage.modules
+ sage: L.cohomology() # optional - sage.combinat sage.modules
{0: Z, 1: Z, 2: C2}
.. SEEALSO::
@@ -1376,13 +1382,13 @@ def as_finite_dimensional_algebra(self):
EXAMPLES::
- sage: L = lie_algebras.cross_product(QQ)
- sage: x,y,z = L.basis()
- sage: F = L.as_finite_dimensional_algebra()
- sage: X,Y,Z = F.basis()
- sage: x.bracket(y)
+ sage: L = lie_algebras.cross_product(QQ) # optional - sage.combinat sage.modules
+ sage: x, y, z = L.basis() # optional - sage.combinat sage.modules
+ sage: F = L.as_finite_dimensional_algebra() # optional - sage.combinat sage.modules
+ sage: X, Y, Z = F.basis() # optional - sage.combinat sage.modules
+ sage: x.bracket(y) # optional - sage.combinat sage.modules
Z
- sage: X * Y
+ sage: X * Y # optional - sage.combinat sage.modules
Z
"""
from sage.matrix.constructor import matrix
@@ -1436,9 +1442,10 @@ def morphism(self, on_generators, codomain=None, base_map=None, check=True):
A quotient type Lie algebra morphism ::
- sage: L. = LieAlgebra(QQ, {('X','Y'): {'Z':1}, ('X','Z'): {'W':1}})
- sage: K. = LieAlgebra(QQ, abelian=True)
- sage: L.morphism({X: A, Y: B})
+ sage: L. = LieAlgebra(QQ, {('X','Y'): {'Z': 1}, # optional - sage.combinat sage.modules
+ ....: ('X','Z'): {'W': 1}})
+ sage: K. = LieAlgebra(QQ, abelian=True) # optional - sage.combinat sage.modules
+ sage: L.morphism({X: A, Y: B}) # optional - sage.combinat sage.modules
Lie algebra morphism:
From: Lie algebra on 4 generators (X, Y, Z, W) over Rational Field
To: Abelian Lie algebra on 2 generators (A, B) over Rational Field
@@ -1450,7 +1457,7 @@ def morphism(self, on_generators, codomain=None, base_map=None, check=True):
The reverse map `A \mapsto X`, `B \mapsto Y` does not define a Lie
algebra morphism, since `[A,B] = 0`, but `[X,Y] \neq 0`::
- sage: K.morphism({A:X, B: Y})
+ sage: K.morphism({A:X, B: Y}) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
ValueError: this does not define a Lie algebra morphism;
@@ -1460,15 +1467,16 @@ def morphism(self, on_generators, codomain=None, base_map=None, check=True):
on the coefficients, even though it's not a Lie algebra morphism
(since it isn't linear)::
- sage: R. = ZZ[]
- sage: K. = NumberField(x^2 + 1)
- sage: cc = K.hom([-i])
- sage: L. = LieAlgebra(K, {('X','Y'): {'Z':1}, ('X','Z'): {'W':1}})
- sage: M. = LieAlgebra(K, abelian=True)
- sage: phi = L.morphism({X: A, Y: B}, base_map=cc)
- sage: phi(X)
+ sage: R. = ZZ[] # optional - sage.combinat sage.modules
+ sage: K. = NumberField(x^2 + 1) # optional - sage.combinat sage.modules sage.rings.number_fields
+ sage: cc = K.hom([-i]) # optional - sage.combinat sage.modules sage.rings.number_fields
+ sage: L. = LieAlgebra(K, {('X','Y'): {'Z': 1}, # optional - sage.combinat sage.modules sage.rings.number_fields
+ ....: ('X','Z'): {'W': 1}})
+ sage: M. = LieAlgebra(K, abelian=True) # optional - sage.combinat sage.modules sage.rings.number_fields
+ sage: phi = L.morphism({X: A, Y: B}, base_map=cc) # optional - sage.combinat sage.modules sage.rings.number_fields
+ sage: phi(X) # optional - sage.combinat sage.modules sage.rings.number_fields
A
- sage: phi(i*X)
+ sage: phi(i*X) # optional - sage.combinat sage.modules sage.rings.number_fields
-i*A
"""
from sage.algebras.lie_algebras.morphism import LieAlgebraMorphism_from_generators
@@ -1497,13 +1505,13 @@ def universal_polynomials(self):
EXAMPLES::
- sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}})
- sage: L.universal_polynomials()
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.universal_polynomials() # optional - sage.combinat sage.modules
Finite family {('x', 'x', 'y'): X01*X10 - X00*X11 + X00,
('y', 'x', 'y'): X10}
- sage: L = LieAlgebra(QQ, cartan_type=['A',1])
- sage: list(L.universal_polynomials())
+ sage: L = LieAlgebra(QQ, cartan_type=['A',1]) # optional - sage.combinat sage.modules
+ sage: list(L.universal_polynomials()) # optional - sage.combinat sage.modules
[-2*X01*X10 + 2*X00*X11 - 2*X00,
-2*X02*X10 + 2*X00*X12 + X01,
-2*X02*X11 + 2*X01*X12 - 2*X02,
@@ -1514,13 +1522,13 @@ def universal_polynomials(self):
-2*X12*X20 + 2*X10*X22 + X21,
-2*X12*X21 + 2*X11*X22 - 2*X22]
- sage: L = LieAlgebra(QQ, cartan_type=['B',2])
- sage: al = RootSystem(['B',2]).root_lattice().simple_roots()
- sage: k = list(L.basis().keys())[0]
- sage: UP = L.universal_polynomials() # long time
- sage: len(UP) # long time
+ sage: L = LieAlgebra(QQ, cartan_type=['B', 2]) # optional - sage.combinat sage.modules
+ sage: al = RootSystem(['B', 2]).root_lattice().simple_roots() # optional - sage.combinat sage.modules
+ sage: k = list(L.basis().keys())[0] # optional - sage.combinat sage.modules
+ sage: UP = L.universal_polynomials() # long time # optional - sage.combinat sage.modules
+ sage: len(UP) # long time # optional - sage.combinat sage.modules
450
- sage: UP[al[2],al[1],-al[1]] # long time
+ sage: UP[al[2], al[1], -al[1]] # long time # optional - sage.combinat sage.modules
X0_7*X4_1 - X0_1*X4_7 - 2*X0_7*X5_1 + 2*X0_1*X5_7 + X2_7*X7_1
- X2_1*X7_7 - X3_7*X8_1 + X3_1*X8_7 + X0_4
"""
@@ -1574,12 +1582,12 @@ def universal_commutative_algebra(self):
EXAMPLES::
- sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}})
- sage: A = L.universal_commutative_algebra()
- sage: a,b,c,d = A.gens()
- sage: (a,b,c,d)
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: A = L.universal_commutative_algebra() # optional - sage.combinat sage.modules
+ sage: a, b, c, d = A.gens() # optional - sage.combinat sage.modules
+ sage: a, b, c, d # optional - sage.combinat sage.modules
(X00bar, X01bar, 0, X11bar)
- sage: a*d - a
+ sage: a*d - a # optional - sage.combinat sage.modules
0
"""
P = list(self.universal_polynomials())
@@ -1593,31 +1601,31 @@ def adjoint_matrix(self, sparse=False): # In #11111 (more or less) by using matr
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.an_element().adjoint_matrix()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.an_element().adjoint_matrix() # optional - sage.combinat sage.modules
[0 0 0]
[0 0 0]
[0 0 0]
- sage: L.an_element().adjoint_matrix(sparse=True).is_sparse()
+ sage: L.an_element().adjoint_matrix(sparse=True).is_sparse() # optional - sage.combinat sage.modules
True
::
- sage: L. = LieAlgebra(QQ, {('x','y'):{'x':1}})
- sage: x.adjoint_matrix()
+ sage: L. = LieAlgebra(QQ, {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: x.adjoint_matrix() # optional - sage.combinat sage.modules
[0 1]
[0 0]
- sage: y.adjoint_matrix()
+ sage: y.adjoint_matrix() # optional - sage.combinat sage.modules
[-1 0]
[ 0 0]
We verify that this forms a representation::
- sage: sl3 = lie_algebras.sl(QQ, 3)
- sage: e1, e2 = sl3.e(1), sl3.e(2)
- sage: e12 = e1.bracket(e2)
- sage: E1, E2 = e1.adjoint_matrix(), e2.adjoint_matrix()
- sage: E1 * E2 - E2 * E1 == e12.adjoint_matrix()
+ sage: sl3 = lie_algebras.sl(QQ, 3) # optional - sage.combinat sage.modules
+ sage: e1, e2 = sl3.e(1), sl3.e(2) # optional - sage.combinat sage.modules
+ sage: e12 = e1.bracket(e2) # optional - sage.combinat sage.modules
+ sage: E1, E2 = e1.adjoint_matrix(), e2.adjoint_matrix() # optional - sage.combinat sage.modules
+ sage: E1 * E2 - E2 * E1 == e12.adjoint_matrix() # optional - sage.combinat sage.modules
True
"""
from sage.matrix.constructor import matrix
@@ -1640,16 +1648,16 @@ def to_vector(self, order=None, sparse=False):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.an_element().to_vector()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.an_element().to_vector() # optional - sage.combinat sage.modules
(0, 0, 0)
- sage: L.an_element().to_vector(sparse=True)
+ sage: L.an_element().to_vector(sparse=True) # optional - sage.combinat sage.modules
(0, 0, 0)
- sage: D = DescentAlgebra(QQ, 4).D()
- sage: L = LieAlgebra(associative=D)
- sage: L.an_element().to_vector()
+ sage: D = DescentAlgebra(QQ, 4).D() # optional - sage.combinat sage.modules
+ sage: L = LieAlgebra(associative=D) # optional - sage.combinat sage.modules
+ sage: L.an_element().to_vector() # optional - sage.combinat sage.modules
(1, 1, 1, 1, 1, 1, 1, 1)
TESTS:
@@ -1657,13 +1665,13 @@ def to_vector(self, order=None, sparse=False):
Check that the error raised agrees with the one
from ``monomial_coefficients()`` (see :trac:`25007`)::
- sage: L = lie_algebras.sp(QQ, 4, representation='matrix')
- sage: x = L.an_element()
- sage: x.monomial_coefficients()
+ sage: L = lie_algebras.sp(QQ, 4, representation='matrix') # optional - sage.combinat sage.modules
+ sage: x = L.an_element() # optional - sage.combinat sage.modules
+ sage: x.monomial_coefficients() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
NotImplementedError: the basis is not defined
- sage: x.to_vector()
+ sage: x.to_vector() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
NotImplementedError: the basis is not defined
@@ -1697,10 +1705,11 @@ def ambient(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: S = L.subalgebra([2*a+b, b + c])
- sage: S.ambient() == L
+ sage: C = LieAlgebras(QQ).FiniteDimensional().WithBasis()
+ sage: L = C.example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: S = L.subalgebra([2*a + b, b + c]) # optional - sage.combinat sage.modules
+ sage: S.ambient() == L # optional - sage.combinat sage.modules
True
"""
@@ -1711,10 +1720,11 @@ def basis_matrix(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: S = L.subalgebra([2*a+b, b + c])
- sage: S.basis_matrix()
+ sage: C = LieAlgebras(QQ).FiniteDimensional().WithBasis()
+ sage: L = C.example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: S = L.subalgebra([2*a + b, b + c]) # optional - sage.combinat sage.modules
+ sage: S.basis_matrix() # optional - sage.combinat sage.modules
[ 1 0 -1/2]
[ 0 1 1]
"""
diff --git a/src/sage/categories/finite_dimensional_modules_with_basis.py b/src/sage/categories/finite_dimensional_modules_with_basis.py
index 0ebca2f2dde..573aec237a1 100644
--- a/src/sage/categories/finite_dimensional_modules_with_basis.py
+++ b/src/sage/categories/finite_dimensional_modules_with_basis.py
@@ -46,8 +46,8 @@ def gens(self):
EXAMPLES::
- sage: F = CombinatorialFreeModule(ZZ, ['a', 'b', 'c'])
- sage: F.gens()
+ sage: F = CombinatorialFreeModule(ZZ, ['a', 'b', 'c']) # optional - sage.modules
+ sage: F.gens() # optional - sage.modules
(B['a'], B['b'], B['c'])
"""
return tuple(self.basis())
@@ -91,35 +91,35 @@ def annihilator(self, S, action=operator.mul, side='right', category=None):
EXAMPLES::
- sage: F = FiniteDimensionalAlgebrasWithBasis(QQ).example(); F
+ sage: F = FiniteDimensionalAlgebrasWithBasis(QQ).example(); F # optional - sage.modules
An example of a finite dimensional algebra with basis:
the path algebra of the Kronecker quiver
(containing the arrows a:x->y and b:x->y) over Rational Field
- sage: x,y,a,b = F.basis()
- sage: A = F.annihilator([a + 3*b + 2*y]); A
+ sage: x, y, a, b = F.basis() # optional - sage.modules
+ sage: A = F.annihilator([a + 3*b + 2*y]); A # optional - sage.modules
Free module generated by {0} over Rational Field
- sage: [b.lift() for b in A.basis()]
+ sage: [b.lift() for b in A.basis()] # optional - sage.modules
[-1/2*a - 3/2*b + x]
The category can be used to specify other properties of
this subspace, like that this is a subalgebra::
- sage: center = F.annihilator(F.basis(), F.bracket,
+ sage: center = F.annihilator(F.basis(), F.bracket, # optional - sage.modules
....: category=Algebras(QQ).Subobjects())
- sage: (e,) = center.basis()
- sage: e.lift()
+ sage: (e,) = center.basis() # optional - sage.modules
+ sage: e.lift() # optional - sage.modules
x + y
- sage: e * e == e
+ sage: e * e == e # optional - sage.modules
True
Taking annihilator is order reversing for inclusion::
- sage: A = F.annihilator([]); A .rename("A")
- sage: Ax = F.annihilator([x]); Ax .rename("Ax")
- sage: Ay = F.annihilator([y]); Ay .rename("Ay")
- sage: Axy = F.annihilator([x,y]); Axy.rename("Axy")
- sage: P = Poset(([A, Ax, Ay, Axy], attrcall("is_submodule")))
- sage: sorted(P.cover_relations(), key=str)
+ sage: A = F.annihilator([]); A .rename("A") # optional - sage.modules
+ sage: Ax = F.annihilator([x]); Ax .rename("Ax") # optional - sage.modules
+ sage: Ay = F.annihilator([y]); Ay .rename("Ay") # optional - sage.modules
+ sage: Axy = F.annihilator([x,y]); Axy.rename("Axy") # optional - sage.modules
+ sage: P = Poset(([A, Ax, Ay, Axy], attrcall("is_submodule"))) # optional - sage.combinat sage.graphs sage.modules
+ sage: sorted(P.cover_relations(), key=str) # optional - sage.combinat sage.graphs sage.modules
[[Ax, A], [Axy, Ax], [Axy, Ay], [Ay, A]]
"""
return self.submodule(self.annihilator_basis(S, action, side),
@@ -204,7 +204,8 @@ def annihilator_basis(self, S, action=operator.mul, side='right'):
compute the orthogonal of a subspace::
sage: x,y,a,b = F.basis()
- sage: def scalar(u,v): return vector([sum(u[i]*v[i] for i in F.basis().keys())])
+ sage: def scalar(u,v):
+ ....: return vector([sum(u[i]*v[i] for i in F.basis().keys())])
sage: F.annihilator_basis([x+y, a+b], scalar)
(x - y, a - b)
@@ -251,13 +252,13 @@ def _dense_free_module(self, base_ring=None):
EXAMPLES::
- sage: C = CombinatorialFreeModule(QQ['x'], ['a','b','c']); C
+ sage: C = CombinatorialFreeModule(QQ['x'], ['a','b','c']); C # optional - sage.modules
Free module generated by {'a', 'b', 'c'} over
Univariate Polynomial Ring in x over Rational Field
- sage: C._dense_free_module()
+ sage: C._dense_free_module() # optional - sage.modules
Ambient free module of rank 3 over the principal ideal domain
Univariate Polynomial Ring in x over Rational Field
- sage: C._dense_free_module(QQ['x,y'])
+ sage: C._dense_free_module(QQ['x,y']) # optional - sage.modules
Ambient free module of rank 3 over the integral domain
Multivariate Polynomial Ring in x, y over Rational Field
"""
@@ -272,11 +273,11 @@ def from_vector(self, vector, order=None, coerce=True):
EXAMPLES::
- sage: p_mult = matrix([[0,0,0],[0,0,-1],[0,0,0]])
- sage: q_mult = matrix([[0,0,1],[0,0,0],[0,0,0]])
- sage: A = algebras.FiniteDimensional(QQ, [p_mult, q_mult, matrix(QQ,3,3)],
- ....: 'p,q,z')
- sage: A.from_vector(vector([1,0,2]))
+ sage: p_mult = matrix([[0,0,0], [0,0,-1], [0,0,0]]) # optional - sage.modules
+ sage: q_mult = matrix([[0,0,1], [0,0,0], [0,0,0]]) # optional - sage.modules
+ sage: A = algebras.FiniteDimensional( # optional - sage.combinat sage.modules
+ ....: QQ, [p_mult, q_mult, matrix(QQ, 3, 3)], 'p,q,z')
+ sage: A.from_vector(vector([1,0,2])) # optional - sage.combinat sage.modules
p + 2*z
"""
if order is None:
@@ -312,42 +313,42 @@ def echelon_form(self, elements, row_reduced=False, order=None):
EXAMPLES::
- sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x")
- sage: x = X.basis()
- sage: V = X.echelon_form([x[0]-x[1], x[0]-x[2],x[1]-x[2]]); V
+ sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x") # optional - sage.modules
+ sage: x = X.basis() # optional - sage.modules
+ sage: V = X.echelon_form([x[0]-x[1], x[0]-x[2], x[1]-x[2]]); V # optional - sage.modules
[x[0] - x[2], x[1] - x[2]]
- sage: matrix(list(map(vector, V)))
+ sage: matrix(list(map(vector, V))) # optional - sage.modules
[ 1 0 -1]
[ 0 1 -1]
::
- sage: F = CombinatorialFreeModule(ZZ, [1,2,3,4])
- sage: B = F.basis()
- sage: elements = [B[1]-17*B[2]+6*B[3], B[1]-17*B[2]+B[4]]
- sage: F.echelon_form(elements)
+ sage: F = CombinatorialFreeModule(ZZ, [1,2,3,4]) # optional - sage.modules
+ sage: B = F.basis() # optional - sage.modules
+ sage: elements = [B[1]-17*B[2]+6*B[3], B[1]-17*B[2]+B[4]] # optional - sage.modules
+ sage: F.echelon_form(elements) # optional - sage.modules
[B[1] - 17*B[2] + B[4], 6*B[3] - B[4]]
::
- sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
- sage: a,b,c = F.basis()
- sage: F.echelon_form([8*a+b+10*c, -3*a+b-c, a-b-c])
+ sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) # optional - sage.modules
+ sage: a,b,c = F.basis() # optional - sage.modules
+ sage: F.echelon_form([8*a+b+10*c, -3*a+b-c, a-b-c]) # optional - sage.modules
[B['a'] + B['c'], B['b'] + 2*B['c']]
::
sage: R. = QQ[]
- sage: C = CombinatorialFreeModule(R, range(3), prefix='x')
- sage: x = C.basis()
- sage: C.echelon_form([x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]])
+ sage: C = CombinatorialFreeModule(R, range(3), prefix='x') # optional - sage.modules
+ sage: x = C.basis() # optional - sage.modules
+ sage: C.echelon_form([x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]) # optional - sage.modules
[x[0] - x[2], x[1] - x[2]]
::
- sage: M = MatrixSpace(QQ, 3, 3)
- sage: A = M([[0, 0, 2], [0, 0, 0], [0, 0, 0]])
- sage: M.echelon_form([A, A])
+ sage: M = MatrixSpace(QQ, 3, 3) # optional - sage.modules
+ sage: A = M([[0, 0, 2], [0, 0, 0], [0, 0, 0]]) # optional - sage.modules
+ sage: M.echelon_form([A, A]) # optional - sage.modules
[
[0 0 1]
[0 0 0]
@@ -358,8 +359,8 @@ def echelon_form(self, elements, row_reduced=False, order=None):
We convert the input elements to ``self``::
- sage: E. = ExteriorAlgebra(QQ)
- sage: E.echelon_form([1, x + 2])
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.modules sage.combinat
+ sage: E.echelon_form([1, x + 2]) # optional - sage.modules sage.combinat
[1, x]
"""
# Make sure elements consists of elements of ``self``
@@ -410,35 +411,37 @@ def invariant_module(self, S, action=operator.mul, action_on_basis=None,
We build the invariant module of the permutation representation
of the symmetric group::
- sage: G = SymmetricGroup(3); G.rename('S3')
- sage: M = FreeModule(ZZ, [1,2,3], prefix='M'); M.rename('M')
+ sage: G = SymmetricGroup(3); G.rename('S3') # optional - sage.groups sage.modules
+ sage: M = FreeModule(ZZ, [1,2,3], prefix='M'); M.rename('M') # optional - sage.groups sage.modules
sage: action = lambda g, x: M.term(g(x))
- sage: I = M.invariant_module(G, action_on_basis=action); I
+ sage: I = M.invariant_module(G, action_on_basis=action); I # optional - sage.groups sage.modules
(S3)-invariant submodule of M
- sage: I.basis()
+ sage: I.basis() # optional - sage.groups sage.modules
Finite family {0: B[0]}
- sage: [I.lift(b) for b in I.basis()]
+ sage: [I.lift(b) for b in I.basis()] # optional - sage.groups sage.modules
[M[1] + M[2] + M[3]]
- sage: G.rename(); M.rename() # reset the names
+ sage: G.rename(); M.rename() # reset the names # optional - sage.groups sage.modules
We can construct the invariant module of any module that has
an action of ``S``. In this example, we consider the dihedral
group `G = D_4` and the subgroup `H < G` of all rotations. We
construct the `H`-invariant module of the group algebra `\QQ[G]`::
- sage: G = groups.permutation.Dihedral(4)
- sage: H = G.subgroup(G.gen(0))
- sage: H
- Subgroup generated by [(1,2,3,4)] of (Dihedral group of order 8 as a permutation group)
- sage: H.cardinality()
+ sage: G = groups.permutation.Dihedral(4) # optional - sage.groups
+ sage: H = G.subgroup(G.gen(0)) # optional - sage.groups
+ sage: H # optional - sage.groups
+ Subgroup generated by [(1,2,3,4)]
+ of (Dihedral group of order 8 as a permutation group)
+ sage: H.cardinality() # optional - sage.groups
4
- sage: A = G.algebra(QQ)
- sage: I = A.invariant_module(H)
- sage: [I.lift(b) for b in I.basis()]
+ sage: A = G.algebra(QQ) # optional - sage.groups sage.modules
+ sage: I = A.invariant_module(H) # optional - sage.groups sage.modules
+ sage: [I.lift(b) for b in I.basis()] # optional - sage.groups sage.modules
[() + (1,2,3,4) + (1,3)(2,4) + (1,4,3,2),
(2,4) + (1,2)(3,4) + (1,3) + (1,4)(2,3)]
- sage: all(h * I.lift(b) == I.lift(b) for b in I.basis() for h in H)
+ sage: all(h * I.lift(b) == I.lift(b) # optional - sage.groups sage.modules
+ ....: for b in I.basis() for h in H)
True
"""
if action_on_basis is not None:
@@ -480,12 +483,13 @@ def twisted_invariant_module(self, G, chi,
EXAMPLES::
- sage: M = CombinatorialFreeModule(QQ, [1,2,3])
- sage: G = SymmetricGroup(3)
- sage: def action(g,x): return(M.term(g(x))) # permute coordinates
- sage: T = M.twisted_invariant_module(G, [2,0,-1], action_on_basis=action)
+ sage: M = CombinatorialFreeModule(QQ, [1,2,3]) # optional - sage.groups sage.modules
+ sage: G = SymmetricGroup(3) # optional - sage.groups
+ sage: def action(g,x): return(M.term(g(x))) # permute coordinates
+ sage: T = M.twisted_invariant_module(G, [2,0,-1], # optional - sage.groups sage.modules
+ ....: action_on_basis=action)
sage: import __main__; __main__.action = action
- sage: TestSuite(T).run()
+ sage: TestSuite(T).run() # optional - sage.groups sage.modules
"""
if action_on_basis is not None:
@@ -514,12 +518,12 @@ def dense_coefficient_list(self, order=None):
EXAMPLES::
- sage: v = vector([0, -1, -3])
- sage: v.dense_coefficient_list()
+ sage: v = vector([0, -1, -3]) # optional - sage.modules
+ sage: v.dense_coefficient_list() # optional - sage.modules
[0, -1, -3]
- sage: v.dense_coefficient_list([2,1,0])
+ sage: v.dense_coefficient_list([2,1,0]) # optional - sage.modules
[-3, -1, 0]
- sage: sorted(v.coefficients())
+ sage: sorted(v.coefficients()) # optional - sage.modules
[-3, -1]
"""
if order is None:
@@ -535,11 +539,11 @@ def _vector_(self, order=None):
EXAMPLES::
- sage: v = vector([0, -1, -3])
- sage: v._vector_()
+ sage: v = vector([0, -1, -3]) # optional - sage.modules
+ sage: v._vector_() # optional - sage.modules
(0, -1, -3)
- sage: C = CombinatorialFreeModule(QQ['x'], ['a','b','c'])
- sage: C.an_element()._vector_()
+ sage: C = CombinatorialFreeModule(QQ['x'], ['a','b','c']) # optional - sage.modules
+ sage: C.an_element()._vector_() # optional - sage.modules
(2, 2, 3)
"""
if order is None:
@@ -577,30 +581,31 @@ def matrix(self, base_ring=None, side="left"):
EXAMPLES::
- sage: X = CombinatorialFreeModule(ZZ, [1,2]); x = X.basis()
- sage: Y = CombinatorialFreeModule(ZZ, [3,4]); y = Y.basis()
- sage: phi = X.module_morphism(on_basis = {1: y[3] + 3*y[4], 2: 2*y[3] + 5*y[4]}.__getitem__,
- ....: codomain = Y)
- sage: phi.matrix()
+ sage: X = CombinatorialFreeModule(ZZ, [1,2]); x = X.basis() # optional - sage.modules
+ sage: Y = CombinatorialFreeModule(ZZ, [3,4]); y = Y.basis() # optional - sage.modules
+ sage: phi = X.module_morphism(on_basis={1: y[3] + 3*y[4], # optional - sage.modules
+ ....: 2: 2*y[3] + 5*y[4]}.__getitem__,
+ ....: codomain=Y)
+ sage: phi.matrix() # optional - sage.modules
[1 2]
[3 5]
- sage: phi.matrix(side="right")
+ sage: phi.matrix(side="right") # optional - sage.modules
[1 3]
[2 5]
- sage: phi.matrix().parent()
+ sage: phi.matrix().parent() # optional - sage.modules
Full MatrixSpace of 2 by 2 dense matrices over Integer Ring
- sage: phi.matrix(QQ).parent()
+ sage: phi.matrix(QQ).parent() # optional - sage.modules
Full MatrixSpace of 2 by 2 dense matrices over Rational Field
The resulting matrix is immutable::
- sage: phi.matrix().is_mutable()
+ sage: phi.matrix().is_mutable() # optional - sage.modules
False
The zero morphism has a zero matrix::
- sage: Hom(X,Y).zero().matrix()
+ sage: Hom(X, Y).zero().matrix() # optional - sage.modules
[0 0]
[0 0]
@@ -609,10 +614,11 @@ def matrix(self, base_ring=None, side="left"):
Add support for morphisms where the codomain has a
different base ring than the domain::
- sage: Y = CombinatorialFreeModule(QQ, [3,4]); y = Y.basis()
- sage: phi = X.module_morphism(on_basis = {1: y[3] + 3*y[4], 2: 2*y[3] + 5/2*y[4]}.__getitem__,
- ....: codomain = Y)
- sage: phi.matrix().parent() # todo: not implemented
+ sage: Y = CombinatorialFreeModule(QQ, [3,4]); y = Y.basis() # optional - sage.modules
+ sage: phi = X.module_morphism(on_basis={1: y[3] + 3*y[4], # optional - sage.modules
+ ....: 2: 2*y[3] + 5/2*y[4]}.__getitem__,
+ ....: codomain=Y)
+ sage: phi.matrix().parent() # todo: not implemented # optional - sage.modules
Full MatrixSpace of 2 by 2 dense matrices over Rational Field
This currently does not work because, in this case,
@@ -620,20 +626,20 @@ def matrix(self, base_ring=None, side="left"):
additive groups (i.e. the intersection of the
categories of modules over `\ZZ` and over `\QQ`)::
- sage: phi.parent().homset_category()
+ sage: phi.parent().homset_category() # optional - sage.modules
Category of commutative additive semigroups
- sage: phi.parent().homset_category() # todo: not implemented
+ sage: phi.parent().homset_category() # todo: not implemented # optional - sage.modules
Category of finite dimensional modules with basis over Integer Ring
TESTS:
Check that :trac:`23216` is fixed::
- sage: X = CombinatorialFreeModule(QQ, [])
- sage: Y = CombinatorialFreeModule(QQ, [1,2,3])
- sage: Hom(X,Y).zero().matrix()
+ sage: X = CombinatorialFreeModule(QQ, []) # optional - sage.modules
+ sage: Y = CombinatorialFreeModule(QQ, [1,2,3]) # optional - sage.modules
+ sage: Hom(X, Y).zero().matrix() # optional - sage.modules
[]
- sage: Hom(X,Y).zero().matrix().parent()
+ sage: Hom(X, Y).zero().matrix().parent() # optional - sage.modules
Full MatrixSpace of 3 by 0 dense matrices over Rational Field
"""
if base_ring is None:
@@ -663,41 +669,41 @@ def __invert__(self):
EXAMPLES::
sage: category = FiniteDimensionalModulesWithBasis(ZZ)
- sage: X = CombinatorialFreeModule(ZZ, [1,2], category = category); X.rename("X"); x = X.basis()
- sage: Y = CombinatorialFreeModule(ZZ, [3,4], category = category); Y.rename("Y"); y = Y.basis()
- sage: phi = X.module_morphism(on_basis = {1: y[3] + 3*y[4], 2: 2*y[3] + 5*y[4]}.__getitem__,
- ....: codomain = Y, category = category)
- sage: psi = ~phi
- sage: psi
+ sage: X = CombinatorialFreeModule(ZZ, [1,2], category=category); X.rename("X"); x = X.basis() # optional - sage.modules
+ sage: Y = CombinatorialFreeModule(ZZ, [3,4], category=category); Y.rename("Y"); y = Y.basis() # optional - sage.modules
+ sage: phi = X.module_morphism(on_basis={1: y[3] + 3*y[4], 2: 2*y[3] + 5*y[4]}.__getitem__, # optional - sage.modules
+ ....: codomain=Y, category=category)
+ sage: psi = ~phi # optional - sage.modules
+ sage: psi # optional - sage.modules
Generic morphism:
From: Y
To: X
- sage: psi.parent()
+ sage: psi.parent() # optional - sage.modules
Set of Morphisms from Y to X in Category of finite dimensional modules with basis over Integer Ring
- sage: psi(y[3])
+ sage: psi(y[3]) # optional - sage.modules
-5*B[1] + 3*B[2]
- sage: psi(y[4])
+ sage: psi(y[4]) # optional - sage.modules
2*B[1] - B[2]
- sage: psi.matrix()
+ sage: psi.matrix() # optional - sage.modules
[-5 2]
[ 3 -1]
- sage: psi(phi(x[1])), psi(phi(x[2]))
+ sage: psi(phi(x[1])), psi(phi(x[2])) # optional - sage.modules
(B[1], B[2])
- sage: phi(psi(y[3])), phi(psi(y[4]))
+ sage: phi(psi(y[3])), phi(psi(y[4])) # optional - sage.modules
(B[3], B[4])
We check that this function complains if the morphism is not invertible::
- sage: phi = X.module_morphism(on_basis = {1: y[3] + y[4], 2: y[3] + y[4]}.__getitem__,
- ....: codomain = Y, category = category)
- sage: ~phi
+ sage: phi = X.module_morphism(on_basis={1: y[3] + y[4], 2: y[3] + y[4]}.__getitem__, # optional - sage.modules
+ ....: codomain=Y, category=category)
+ sage: ~phi # optional - sage.modules
Traceback (most recent call last):
...
RuntimeError: morphism is not invertible
- sage: phi = X.module_morphism(on_basis = {1: y[3] + y[4], 2: y[3] + 5*y[4]}.__getitem__,
- ....: codomain = Y, category = category)
- sage: ~phi
+ sage: phi = X.module_morphism(on_basis={1: y[3] + y[4], 2: y[3] + 5*y[4]}.__getitem__, # optional - sage.modules
+ ....: codomain=Y, category=category)
+ sage: ~phi # optional - sage.modules
Traceback (most recent call last):
...
RuntimeError: morphism is not invertible
@@ -717,9 +723,9 @@ def kernel_basis(self):
EXAMPLES::
- sage: SGA = SymmetricGroupAlgebra(QQ, 3)
- sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA)
- sage: f.kernel_basis()
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA) # optional - sage.groups sage.modules
+ sage: f.kernel_basis() # optional - sage.groups sage.modules
([1, 2, 3] - [3, 2, 1], [1, 3, 2] - [3, 2, 1], [2, 1, 3] - [3, 2, 1])
"""
return tuple(map( self.domain().from_vector,
@@ -731,12 +737,12 @@ def kernel(self):
EXAMPLES::
- sage: SGA = SymmetricGroupAlgebra(QQ, 3)
- sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA)
- sage: K = f.kernel()
- sage: K
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA) # optional - sage.groups sage.modules
+ sage: K = f.kernel() # optional - sage.groups sage.modules
+ sage: K # optional - sage.groups sage.modules
Free module generated by {0, 1, 2} over Rational Field
- sage: K.ambient()
+ sage: K.ambient() # optional - sage.groups sage.modules
Symmetric group algebra of order 3 over Rational Field
"""
D = self.domain()
@@ -749,9 +755,9 @@ def image_basis(self):
EXAMPLES::
- sage: SGA = SymmetricGroupAlgebra(QQ, 3)
- sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA)
- sage: f.image_basis()
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA) # optional - sage.groups sage.modules
+ sage: f.image_basis() # optional - sage.groups sage.modules
([1, 2, 3], [2, 3, 1], [3, 1, 2])
"""
C = self.codomain()
@@ -763,9 +769,9 @@ def image(self):
EXAMPLES::
- sage: SGA = SymmetricGroupAlgebra(QQ, 3)
- sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA)
- sage: f.image()
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups sage.modules
+ sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA) # optional - sage.groups sage.modules
+ sage: f.image() # optional - sage.groups sage.modules
Free module generated by {0, 1, 2} over Rational Field
"""
C = self.codomain()
@@ -781,10 +787,12 @@ def extra_super_categories(self):
EXAMPLES::
- sage: ModulesWithBasis(ZZ).FiniteDimensional().TensorProducts().extra_super_categories()
+ sage: C = ModulesWithBasis(ZZ).FiniteDimensional().TensorProducts()
+ sage: C.extra_super_categories()
[Category of finite dimensional modules with basis over Integer Ring]
- sage: ModulesWithBasis(ZZ).FiniteDimensional().TensorProducts().FiniteDimensional()
- Category of tensor products of finite dimensional modules with basis over Integer Ring
+ sage: C.FiniteDimensional()
+ Category of tensor products of
+ finite dimensional modules with basis over Integer Ring
"""
return [self.base_category()]
diff --git a/src/sage/categories/finite_dimensional_nilpotent_lie_algebras_with_basis.py b/src/sage/categories/finite_dimensional_nilpotent_lie_algebras_with_basis.py
index fe0ad9f3d21..d294ec75fae 100644
--- a/src/sage/categories/finite_dimensional_nilpotent_lie_algebras_with_basis.py
+++ b/src/sage/categories/finite_dimensional_nilpotent_lie_algebras_with_basis.py
@@ -60,16 +60,17 @@ def _test_nilpotency(self, **options):
EXAMPLES::
- sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
- sage: L._test_nilpotency()
- sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}},
- ....: nilpotent=True, step = 3)
- sage: L._test_nilpotency()
+ sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True) # optional - sage.combinat sage.modules
+ sage: L._test_nilpotency() # optional - sage.combinat sage.modules
+ sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, # optional - sage.combinat sage.modules
+ ....: nilpotent=True, step=3)
+ sage: L._test_nilpotency() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
- AssertionError: claimed nilpotency step 3 does not match the actual nilpotency step 2
- sage: L = LieAlgebra(QQ, {('X','Y'): {'X': 1}}, nilpotent=True)
- sage: L._test_nilpotency()
+ AssertionError: claimed nilpotency step 3
+ does not match the actual nilpotency step 2
+ sage: L = LieAlgebra(QQ, {('X','Y'): {'X': 1}}, nilpotent=True) # optional - sage.combinat sage.modules
+ sage: L._test_nilpotency() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
AssertionError: final term of lower central series is non-zero
@@ -100,28 +101,29 @@ def lie_group(self, name='G', **kwds):
We define the Heisenberg group::
- sage: L = lie_algebras.Heisenberg(QQ, 1)
- sage: G = L.lie_group('G'); G # optional - sage.symbolic
+ sage: L = lie_algebras.Heisenberg(QQ, 1) # optional - sage.combinat sage.modules
+ sage: G = L.lie_group('G'); G # optional - sage.combinat sage.modules sage.symbolic
Lie group G of Heisenberg algebra of rank 1 over Rational Field
We test multiplying elements of the group::
- sage: p,q,z = L.basis() # optional - sage.symbolic
- sage: g = G.exp(p); g # optional - sage.symbolic
+ sage: p, q, z = L.basis() # optional - sage.combinat sage.modules sage.symbolic
+ sage: g = G.exp(p); g # optional - sage.combinat sage.modules sage.symbolic
exp(p1)
- sage: h = G.exp(q); h # optional - sage.symbolic
+ sage: h = G.exp(q); h # optional - sage.combinat sage.modules sage.symbolic
exp(q1)
- sage: g*h # optional - sage.symbolic
+ sage: g * h # optional - sage.combinat sage.modules sage.symbolic
exp(p1 + q1 + 1/2*z)
We extend an element of the Lie algebra to a left-invariant
vector field::
- sage: X = G.left_invariant_extension(2*p + 3*q, name='X'); X # optional - sage.symbolic
- Vector field X on the Lie group G of Heisenberg algebra of rank 1 over Rational Field
- sage: X.at(G.one()).display() # optional - sage.symbolic
+ sage: X = G.left_invariant_extension(2*p + 3*q, name='X'); X # optional - sage.combinat sage.modules sage.symbolic
+ Vector field X on the Lie group G of
+ Heisenberg algebra of rank 1 over Rational Field
+ sage: X.at(G.one()).display() # optional - sage.combinat sage.modules sage.symbolic
X = 2 ∂/∂x_0 + 3 ∂/∂x_1
- sage: X.display() # optional - sage.symbolic
+ sage: X.display() # optional - sage.combinat sage.modules sage.symbolic
X = 2 ∂/∂x_0 + 3 ∂/∂x_1 + (3/2*x_0 - x_1) ∂/∂x_2
.. SEEALSO::
@@ -137,11 +139,11 @@ def step(self):
EXAMPLES::
- sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
- sage: L.step()
+ sage: L = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True) # optional - sage.combinat sage.modules
+ sage: L.step() # optional - sage.combinat sage.modules
2
- sage: sc = {('X','Y'): {'Z': 1}, ('X','Z'): {'W': 1}}
- sage: LieAlgebra(QQ, sc, nilpotent=True).step()
+ sage: sc = {('X','Y'): {'Z': 1}, ('X','Z'): {'W': 1}} # optional - sage.combinat sage.modules
+ sage: LieAlgebra(QQ, sc, nilpotent=True).step() # optional - sage.combinat sage.modules
3
"""
if not hasattr(self, '_step'):
@@ -154,8 +156,8 @@ def is_nilpotent(self):
EXAMPLES::
- sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}}, nilpotent=True)
- sage: L.is_nilpotent()
+ sage: L = LieAlgebra(QQ, {('x','y'): {'z': 1}}, nilpotent=True) # optional - sage.combinat sage.modules
+ sage: L.is_nilpotent() # optional - sage.combinat sage.modules
True
"""
return True
diff --git a/src/sage/categories/finite_dimensional_semisimple_algebras_with_basis.py b/src/sage/categories/finite_dimensional_semisimple_algebras_with_basis.py
index 59ab6a9a8ad..56303fc5eb0 100644
--- a/src/sage/categories/finite_dimensional_semisimple_algebras_with_basis.py
+++ b/src/sage/categories/finite_dimensional_semisimple_algebras_with_basis.py
@@ -49,13 +49,13 @@ def radical_basis(self, **keywords):
EXAMPLES::
- sage: A = SymmetricGroup(4).algebra(QQ)
- sage: A.radical_basis()
+ sage: A = SymmetricGroup(4).algebra(QQ) # optional - sage.groups sage.modules
+ sage: A.radical_basis() # optional - sage.groups sage.modules
()
TESTS::
- sage: A.radical_basis.__module__
+ sage: A.radical_basis.__module__ # optional - sage.groups sage.modules
'sage.categories.finite_dimensional_semisimple_algebras_with_basis'
"""
return ()
@@ -81,25 +81,25 @@ def central_orthogonal_idempotents(self):
acts on `V_i` as multiplication by the `i`-th power of a
cube root of unity::
- sage: R = CyclotomicField(3)
- sage: A3 = AlternatingGroup(3).algebra(R)
- sage: idempotents = A3.central_orthogonal_idempotents()
- sage: idempotents
+ sage: R = CyclotomicField(3) # optional - sage.rings.number_field
+ sage: A3 = AlternatingGroup(3).algebra(R) # optional - sage.rings.number_field sage.groups
+ sage: idempotents = A3.central_orthogonal_idempotents() # optional - sage.rings.number_field sage.groups
+ sage: idempotents # optional - sage.rings.number_field sage.groups
(1/3*() + 1/3*(1,2,3) + 1/3*(1,3,2),
1/3*() - (1/3*zeta3+1/3)*(1,2,3) - (-1/3*zeta3)*(1,3,2),
1/3*() - (-1/3*zeta3)*(1,2,3) - (1/3*zeta3+1/3)*(1,3,2))
- sage: A3.is_identity_decomposition_into_orthogonal_idempotents(idempotents)
+ sage: A3.is_identity_decomposition_into_orthogonal_idempotents(idempotents) # optional - sage.rings.number_field sage.groups
True
For the semisimple quotient of a quiver algebra,
we recover the vertices of the quiver::
- sage: A = FiniteDimensionalAlgebrasWithBasis(QQ).example(); A
+ sage: A = FiniteDimensionalAlgebrasWithBasis(QQ).example(); A # optional - sage.combinat
An example of a finite dimensional algebra with basis:
the path algebra of the Kronecker quiver (containing
the arrows a:x->y and b:x->y) over Rational Field
- sage: Aquo = A.semisimple_quotient()
- sage: Aquo.central_orthogonal_idempotents()
+ sage: Aquo = A.semisimple_quotient() # optional - sage.combinat
+ sage: Aquo.central_orthogonal_idempotents() # optional - sage.combinat
(B['x'], B['y'])
"""
return tuple([x.lift()
@@ -157,8 +157,8 @@ def _orthogonal_decomposition(self, generators=None):
center of the algebra of the symmetric group
`S_4`::
- sage: Z4 = SymmetricGroup(4).algebra(QQ).center()
- sage: Z4._orthogonal_decomposition()
+ sage: Z4 = SymmetricGroup(4).algebra(QQ).center() # optional - sage.groups sage.modules
+ sage: Z4._orthogonal_decomposition() # optional - sage.groups sage.modules
(B[0] + B[1] + B[2] + B[3] + B[4],
B[0] + 1/3*B[1] - 1/3*B[2] - 1/3*B[4],
B[0] + B[2] - 1/2*B[3],
@@ -219,10 +219,10 @@ def central_orthogonal_idempotents(self):
EXAMPLES::
- sage: A4 = SymmetricGroup(4).algebra(QQ)
- sage: Z4 = A4.center()
- sage: idempotents = Z4.central_orthogonal_idempotents()
- sage: idempotents
+ sage: A4 = SymmetricGroup(4).algebra(QQ) # optional - sage.groups sage.modules
+ sage: Z4 = A4.center() # optional - sage.groups sage.modules
+ sage: idempotents = Z4.central_orthogonal_idempotents() # optional - sage.groups sage.modules
+ sage: idempotents # optional - sage.groups sage.modules
(1/24*B[0] + 1/24*B[1] + 1/24*B[2] + 1/24*B[3] + 1/24*B[4],
3/8*B[0] + 1/8*B[1] - 1/8*B[2] - 1/8*B[4],
1/6*B[0] + 1/6*B[2] - 1/12*B[3],
@@ -233,7 +233,7 @@ def central_orthogonal_idempotents(self):
recognize among them the sum and alternating
sum of all permutations::
- sage: [e.lift() for e in idempotents]
+ sage: [e.lift() for e in idempotents] # optional - sage.groups sage.modules
[1/24*() + 1/24*(3,4) + 1/24*(2,3) + 1/24*(2,3,4) + 1/24*(2,4,3)
+ 1/24*(2,4) + 1/24*(1,2) + 1/24*(1,2)(3,4) + 1/24*(1,2,3)
+ 1/24*(1,2,3,4) + 1/24*(1,2,4,3) + 1/24*(1,2,4) + 1/24*(1,3,2)
@@ -251,7 +251,7 @@ def central_orthogonal_idempotents(self):
We check that they indeed form a decomposition
of the identity of `Z_4` into orthogonal idempotents::
- sage: Z4.is_identity_decomposition_into_orthogonal_idempotents(idempotents)
+ sage: Z4.is_identity_decomposition_into_orthogonal_idempotents(idempotents) # optional - sage.groups sage.modules
True
"""
return tuple([(e.leading_coefficient()/(e*e).leading_coefficient())*e
diff --git a/src/sage/categories/finite_enumerated_sets.py b/src/sage/categories/finite_enumerated_sets.py
index 4a872cf2fbf..4d90a3cd3f9 100644
--- a/src/sage/categories/finite_enumerated_sets.py
+++ b/src/sage/categories/finite_enumerated_sets.py
@@ -59,9 +59,9 @@ def _call_(self, X):
EXAMPLES::
- sage: FiniteEnumeratedSets()(GF(3))
+ sage: FiniteEnumeratedSets()(GF(3)) # optional - sage.rings.finite_rings
Finite Field of size 3
- sage: Partitions(3)
+ sage: Partitions(3) # optional - sage.combinat
Partitions of the integer 3
For now, lists, tuples, sets, Sets are coerced into finite
@@ -86,9 +86,9 @@ def __len__(self):
EXAMPLES::
- sage: len(GF(5))
+ sage: len(GF(5)) # optional - sage.rings.finite_rings
5
- sage: len(MatrixSpace(GF(2), 3, 3))
+ sage: len(MatrixSpace(GF(2), 3, 3)) # optional - sage.rings.finite_rings sage.modules
512
"""
return int(self.cardinality())
@@ -590,17 +590,17 @@ class ParentMethods:
inherit various methods from `Sets.CartesianProducts`
and not from :class:`EnumeratedSets.Finite`::
- sage: C = cartesian_product([Partitions(10), Permutations(20)])
- sage: C in EnumeratedSets().Finite()
+ sage: C = cartesian_product([Partitions(10), Permutations(20)]) # optional - sage.combinat
+ sage: C in EnumeratedSets().Finite() # optional - sage.combinat
True
- sage: C.random_element.__module__
+ sage: C.random_element.__module__ # optional - sage.combinat
'sage.categories.sets_cat'
- sage: C.cardinality.__module__
+ sage: C.cardinality.__module__ # optional - sage.combinat
'sage.categories.sets_cat'
- sage: C.__iter__.__module__
+ sage: C.__iter__.__module__ # optional - sage.combinat
'sage.categories.sets_cat'
"""
random_element = raw_getattr(Sets.CartesianProducts.ParentMethods, "random_element")
@@ -613,8 +613,9 @@ def last(self):
EXAMPLES::
- sage: C = cartesian_product([Zmod(42), Partitions(10), IntegerRange(5)])
- sage: C.last()
+ sage: C = cartesian_product([Zmod(42), Partitions(10), # optional - sage.combinat
+ ....: IntegerRange(5)])
+ sage: C.last() # optional - sage.combinat
(41, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 4)
"""
return self._cartesian_product_of_elements(
@@ -635,13 +636,13 @@ def rank(self, x):
EXAMPLES::
- sage: C = cartesian_product([GF(2), GF(11), GF(7)])
- sage: C.rank(C((1,2,5)))
+ sage: C = cartesian_product([GF(2), GF(11), GF(7)]) # optional - sage.rings.finite_rings
+ sage: C.rank(C((1,2,5))) # optional - sage.rings.finite_rings
96
- sage: C.rank(C((0,0,0)))
+ sage: C.rank(C((0,0,0))) # optional - sage.rings.finite_rings
0
- sage: for c in C: print(C.rank(c))
+ sage: for c in C: print(C.rank(c)) # optional - sage.rings.finite_rings
0
1
2
@@ -656,12 +657,12 @@ def rank(self, x):
sage: F1 = FiniteEnumeratedSet('abcdefgh')
sage: F2 = IntegerRange(250)
- sage: F3 = Partitions(20)
- sage: C = cartesian_product([F1, F2, F3])
- sage: c = C(('a', 86, [7,5,4,4]))
- sage: C.rank(c)
+ sage: F3 = Partitions(20) # optional - sage.combinat
+ sage: C = cartesian_product([F1, F2, F3]) # optional - sage.combinat
+ sage: c = C(('a', 86, [7,5,4,4])) # optional - sage.combinat
+ sage: C.rank(c) # optional - sage.combinat
54213
- sage: C.unrank(54213)
+ sage: C.unrank(54213) # optional - sage.combinat
('a', 86, [7, 5, 4, 4])
"""
from builtins import zip
@@ -691,18 +692,18 @@ def unrank(self, i):
EXAMPLES::
- sage: C = cartesian_product([GF(3), GF(11), GF(7), GF(5)])
- sage: c = C.unrank(123); c
+ sage: C = cartesian_product([GF(3), GF(11), GF(7), GF(5)]) # optional - sage.rings.finite_rings
+ sage: c = C.unrank(123); c # optional - sage.rings.finite_rings
(0, 3, 3, 3)
- sage: C.rank(c)
+ sage: C.rank(c) # optional - sage.rings.finite_rings
123
- sage: c = C.unrank(857); c
+ sage: c = C.unrank(857); c # optional - sage.rings.finite_rings
(2, 2, 3, 2)
- sage: C.rank(c)
+ sage: C.rank(c) # optional - sage.rings.finite_rings
857
- sage: C.unrank(2500)
+ sage: C.unrank(2500) # optional - sage.rings.finite_rings
Traceback (most recent call last):
...
IndexError: index i (=2) is greater than the cardinality
diff --git a/src/sage/categories/finite_fields.py b/src/sage/categories/finite_fields.py
index 25a93c8b960..b685a249780 100644
--- a/src/sage/categories/finite_fields.py
+++ b/src/sage/categories/finite_fields.py
@@ -34,7 +34,7 @@ class FiniteFields(CategoryWithAxiom):
Some examples of membership testing and coercion::
- sage: FiniteField(17) in K
+ sage: FiniteField(17) in K # optional - sage.rings.finite_rings
True
sage: RationalField() in K
False
@@ -67,7 +67,7 @@ def __contains__(self, x):
"""
EXAMPLES::
- sage: GF(4, "a") in FiniteFields()
+ sage: GF(4, "a") in FiniteFields() # optional - sage.rings.finite_rings
True
sage: QQ in FiniteFields()
False
@@ -82,7 +82,7 @@ def _call_(self, x):
"""
EXAMPLES::
- sage: FiniteFields()(GF(4, "a"))
+ sage: FiniteFields()(GF(4, "a")) # optional - sage.rings.finite_rings
Finite Field in a of size 2^2
sage: FiniteFields()(RationalField()) # indirect doctest
Traceback (most recent call last):
diff --git a/src/sage/categories/finite_groups.py b/src/sage/categories/finite_groups.py
index 42415233567..1d0e7d72357 100644
--- a/src/sage/categories/finite_groups.py
+++ b/src/sage/categories/finite_groups.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.groups
r"""
Finite groups
"""
diff --git a/src/sage/categories/finite_lattice_posets.py b/src/sage/categories/finite_lattice_posets.py
index 4b7f0fb9b28..1bb0de98fad 100644
--- a/src/sage/categories/finite_lattice_posets.py
+++ b/src/sage/categories/finite_lattice_posets.py
@@ -49,8 +49,8 @@ def join_irreducibles(self):
EXAMPLES::
- sage: L = LatticePoset({0:[1,2],1:[3],2:[3,4],3:[5],4:[5]})
- sage: L.join_irreducibles()
+ sage: L = LatticePoset({0:[1,2],1:[3],2:[3,4],3:[5],4:[5]}) # optional - sage.combinat sage.graphs
+ sage: L.join_irreducibles() # optional - sage.combinat sage.graphs
[1, 2, 4]
.. SEEALSO::
@@ -71,8 +71,8 @@ def join_irreducibles_poset(self):
EXAMPLES::
- sage: L = LatticePoset({0:[1,2,3],1:[4],2:[4],3:[4]})
- sage: L.join_irreducibles_poset()
+ sage: L = LatticePoset({0:[1,2,3],1:[4],2:[4],3:[4]}) # optional - sage.combinat sage.graphs
+ sage: L.join_irreducibles_poset() # optional - sage.combinat sage.graphs
Finite poset containing 3 elements
.. SEEALSO::
@@ -92,8 +92,8 @@ def meet_irreducibles(self):
EXAMPLES::
- sage: L = LatticePoset({0:[1,2],1:[3],2:[3,4],3:[5],4:[5]})
- sage: L.meet_irreducibles()
+ sage: L = LatticePoset({0:[1,2],1:[3],2:[3,4],3:[5],4:[5]}) # optional - sage.combinat sage.graphs
+ sage: L.meet_irreducibles() # optional - sage.combinat sage.graphs
[1, 3, 4]
.. SEEALSO::
@@ -114,8 +114,8 @@ def meet_irreducibles_poset(self):
EXAMPLES::
- sage: L = LatticePoset({0:[1,2,3],1:[4],2:[4],3:[4]})
- sage: L.join_irreducibles_poset()
+ sage: L = LatticePoset({0:[1,2,3],1:[4],2:[4],3:[4]}) # optional - sage.combinat sage.graphs
+ sage: L.join_irreducibles_poset() # optional - sage.combinat sage.graphs
Finite poset containing 3 elements
.. SEEALSO::
@@ -143,20 +143,20 @@ def irreducibles_poset(self):
EXAMPLES::
- sage: L = LatticePoset({1: [2, 3, 4], 2: [5, 6], 3: [5],
+ sage: L = LatticePoset({1: [2, 3, 4], 2: [5, 6], 3: [5], # optional - sage.combinat sage.graphs
....: 4: [6], 5: [9, 7], 6: [9, 8], 7: [10],
....: 8: [10], 9: [10], 10: [11]})
- sage: L_ = L.irreducibles_poset()
- sage: sorted(L_)
+ sage: L_ = L.irreducibles_poset() # optional - sage.combinat sage.graphs
+ sage: sorted(L_) # optional - sage.combinat sage.graphs
[2, 3, 4, 7, 8, 9, 10, 11]
- sage: L_.completion_by_cuts().is_isomorphic(L)
+ sage: L_.completion_by_cuts().is_isomorphic(L) # optional - sage.combinat sage.graphs
True
TESTS::
- sage: LatticePoset().irreducibles_poset()
+ sage: LatticePoset().irreducibles_poset() # optional - sage.combinat sage.graphs
Finite poset containing 0 elements
- sage: posets.ChainPoset(1).irreducibles_poset()
+ sage: posets.ChainPoset(1).irreducibles_poset() # optional - sage.combinat sage.graphs
Finite poset containing 1 elements
"""
if self.cardinality() == 1:
@@ -191,35 +191,36 @@ def is_lattice_morphism(self, f, codomain):
lattice of divisors of `60`, and check that the map
`b \mapsto 5 \prod_{x\in b} x` is a morphism of lattices::
- sage: D = LatticePoset((divisors(60), attrcall("divides")))
- sage: B = LatticePoset((Subsets([2,2,3]), attrcall("issubset")))
- sage: def f(b): return D(5*prod(b))
- sage: B.is_lattice_morphism(f, D)
+ sage: D = LatticePoset((divisors(60), attrcall("divides"))) # optional - sage.combinat sage.graphs
+ sage: B = LatticePoset((Subsets([2,2,3]), attrcall("issubset"))) # optional - sage.combinat sage.graphs
+ sage: def f(b): return D(5*prod(b)) # optional - sage.combinat sage.graphs
+ sage: B.is_lattice_morphism(f, D) # optional - sage.combinat sage.graphs
True
We construct the boolean lattice `B_2`::
- sage: B = posets.BooleanLattice(2)
- sage: B.cover_relations()
+ sage: B = posets.BooleanLattice(2) # optional - sage.combinat sage.graphs
+ sage: B.cover_relations() # optional - sage.combinat sage.graphs
[[0, 1], [0, 2], [1, 3], [2, 3]]
And the same lattice with new top and bottom elements
numbered respectively `-1` and `3`::
- sage: L = LatticePoset(DiGraph({-1:[0], 0:[1,2], 1:[3], 2:[3],3:[4]}))
- sage: L.cover_relations()
+ sage: G = DiGraph({-1:[0], 0:[1,2], 1:[3], 2:[3], 3:[4]}) # optional - sage.graphs
+ sage: L = LatticePoset(G) # optional - sage.combinat sage.graphs
+ sage: L.cover_relations() # optional - sage.combinat sage.graphs
[[-1, 0], [0, 1], [0, 2], [1, 3], [2, 3], [3, 4]]
- sage: f = { B(0): L(0), B(1): L(1), B(2): L(2), B(3): L(3) }.__getitem__
- sage: B.is_lattice_morphism(f, L)
+ sage: f = {B(0): L(0), B(1): L(1), B(2): L(2), B(3): L(3)}.__getitem__ # optional - sage.combinat sage.graphs
+ sage: B.is_lattice_morphism(f, L) # optional - sage.combinat sage.graphs
True
- sage: f = { B(0): L(-1),B(1): L(1), B(2): L(2), B(3): L(3) }.__getitem__
- sage: B.is_lattice_morphism(f, L)
+ sage: f = {B(0): L(-1),B(1): L(1), B(2): L(2), B(3): L(3)}.__getitem__ # optional - sage.combinat sage.graphs
+ sage: B.is_lattice_morphism(f, L) # optional - sage.combinat sage.graphs
False
- sage: f = { B(0): L(0), B(1): L(1), B(2): L(2), B(3): L(4) }.__getitem__
- sage: B.is_lattice_morphism(f, L)
+ sage: f = {B(0): L(0), B(1): L(1), B(2): L(2), B(3): L(4)}.__getitem__ # optional - sage.combinat sage.graphs
+ sage: B.is_lattice_morphism(f, L) # optional - sage.combinat sage.graphs
False
.. SEEALSO::
diff --git a/src/sage/categories/finite_monoids.py b/src/sage/categories/finite_monoids.py
index fdf1db47a71..9531b671249 100644
--- a/src/sage/categories/finite_monoids.py
+++ b/src/sage/categories/finite_monoids.py
@@ -72,9 +72,9 @@ def nerve(self):
The nerve (classifying space) of the cyclic group of order
2 is infinite-dimensional real projective space. ::
- sage: Sigma2 = groups.permutation.Cyclic(2)
- sage: BSigma2 = Sigma2.nerve()
- sage: BSigma2.cohomology(4, base_ring=GF(2))
+ sage: Sigma2 = groups.permutation.Cyclic(2) # optional - sage.groups
+ sage: BSigma2 = Sigma2.nerve() # optional - sage.groups
+ sage: BSigma2.cohomology(4, base_ring=GF(2)) # optional - sage.groups sage.modules sage.rings.finite_rings
Vector space of dimension 1 over Finite Field of size 2
The `k`-simplices of the nerve are named after the chains
@@ -83,45 +83,45 @@ def nerve(self):
element) and ``(1,2)`` in Sage. So the 1-cells and 2-cells
in `B\Sigma_2` are::
- sage: BSigma2.n_cells(1)
+ sage: BSigma2.n_cells(1) # optional - sage.groups
[(1,2)]
- sage: BSigma2.n_cells(2)
+ sage: BSigma2.n_cells(2) # optional - sage.groups
[(1,2) * (1,2)]
Another construction of the group, with different names
for its elements::
- sage: C2 = groups.misc.MultiplicativeAbelian([2])
- sage: BC2 = C2.nerve()
- sage: BC2.n_cells(0)
+ sage: C2 = groups.misc.MultiplicativeAbelian([2]) # optional - sage.groups
+ sage: BC2 = C2.nerve() # optional - sage.groups
+ sage: BC2.n_cells(0) # optional - sage.groups
[1]
- sage: BC2.n_cells(1)
+ sage: BC2.n_cells(1) # optional - sage.groups
[f]
- sage: BC2.n_cells(2)
+ sage: BC2.n_cells(2) # optional - sage.groups
[f * f]
With mod `p` coefficients, `B \Sigma_p` should have its
first nonvanishing homology group in dimension `p`::
- sage: Sigma3 = groups.permutation.Symmetric(3)
- sage: BSigma3 = Sigma3.nerve()
- sage: BSigma3.homology(range(4), base_ring=GF(3))
+ sage: Sigma3 = groups.permutation.Symmetric(3) # optional - sage.groups
+ sage: BSigma3 = Sigma3.nerve() # optional - sage.groups
+ sage: BSigma3.homology(range(4), base_ring=GF(3)) # optional - sage.groups sage.rings.finite_rings
{0: Vector space of dimension 0 over Finite Field of size 3,
- 1: Vector space of dimension 0 over Finite Field of size 3,
- 2: Vector space of dimension 0 over Finite Field of size 3,
- 3: Vector space of dimension 1 over Finite Field of size 3}
+ 1: Vector space of dimension 0 over Finite Field of size 3,
+ 2: Vector space of dimension 0 over Finite Field of size 3,
+ 3: Vector space of dimension 1 over Finite Field of size 3}
Note that we can construct the `n`-skeleton for
`B\Sigma_2` for relatively large values of `n`, while for
`B\Sigma_3`, the complexes get large pretty quickly::
- sage: Sigma2.nerve().n_skeleton(14)
+ sage: Sigma2.nerve().n_skeleton(14) # optional - sage.groups
Simplicial set with 15 non-degenerate simplices
- sage: BSigma3 = Sigma3.nerve()
- sage: BSigma3.n_skeleton(3)
+ sage: BSigma3 = Sigma3.nerve() # optional - sage.groups
+ sage: BSigma3.n_skeleton(3) # optional - sage.groups
Simplicial set with 156 non-degenerate simplices
- sage: BSigma3.n_skeleton(4)
+ sage: BSigma3.n_skeleton(4) # optional - sage.groups
Simplicial set with 781 non-degenerate simplices
Finally, note that the classifying space of the order `p`
@@ -129,33 +129,33 @@ def nerve(self):
on `p` letters, and its first homology group appears
earlier::
- sage: C3 = groups.misc.MultiplicativeAbelian([3])
- sage: list(C3)
+ sage: C3 = groups.misc.MultiplicativeAbelian([3]) # optional - sage.groups
+ sage: list(C3) # optional - sage.groups
[1, f, f^2]
- sage: BC3 = C3.nerve()
- sage: BC3.n_cells(1)
+ sage: BC3 = C3.nerve() # optional - sage.groups
+ sage: BC3.n_cells(1) # optional - sage.groups
[f, f^2]
- sage: BC3.n_cells(2)
+ sage: BC3.n_cells(2) # optional - sage.groups
[f * f, f * f^2, f^2 * f, f^2 * f^2]
- sage: len(BSigma3.n_cells(2))
+ sage: len(BSigma3.n_cells(2)) # optional - sage.groups
25
- sage: len(BC3.n_cells(3))
+ sage: len(BC3.n_cells(3)) # optional - sage.groups
8
- sage: len(BSigma3.n_cells(3))
+ sage: len(BSigma3.n_cells(3)) # optional - sage.groups
125
- sage: BC3.homology(range(4), base_ring=GF(3))
+ sage: BC3.homology(range(4), base_ring=GF(3)) # optional - sage.groups sage.rings.finite_rings
{0: Vector space of dimension 0 over Finite Field of size 3,
1: Vector space of dimension 1 over Finite Field of size 3,
2: Vector space of dimension 1 over Finite Field of size 3,
3: Vector space of dimension 1 over Finite Field of size 3}
- sage: BC5 = groups.permutation.Cyclic(5).nerve()
- sage: BC5.homology(range(4), base_ring=GF(5))
+ sage: BC5 = groups.permutation.Cyclic(5).nerve() # optional - sage.groups
+ sage: BC5.homology(range(4), base_ring=GF(5)) # optional - sage.groups sage.rings.finite_rings
{0: Vector space of dimension 0 over Finite Field of size 5,
- 1: Vector space of dimension 1 over Finite Field of size 5,
- 2: Vector space of dimension 1 over Finite Field of size 5,
- 3: Vector space of dimension 1 over Finite Field of size 5}
+ 1: Vector space of dimension 1 over Finite Field of size 5,
+ 2: Vector space of dimension 1 over Finite Field of size 5,
+ 3: Vector space of dimension 1 over Finite Field of size 5}
"""
from sage.topology.simplicial_set_examples import Nerve
return Nerve(self)
@@ -179,20 +179,20 @@ def rhodes_radical_congruence(self, base_ring=None):
EXAMPLES::
sage: M = Monoids().Finite().example()
- sage: M.rhodes_radical_congruence()
+ sage: M.rhodes_radical_congruence() # optional - sage.groups sage.modules
[(0, 6), (2, 8), (4, 10)]
- sage: from sage.monoids.hecke_monoid import HeckeMonoid
- sage: H3 = HeckeMonoid(SymmetricGroup(3))
- sage: H3.repr_element_method(style="reduced")
- sage: H3.rhodes_radical_congruence()
+ sage: from sage.monoids.hecke_monoid import HeckeMonoid # optional - sage.groups sage.modules
+ sage: H3 = HeckeMonoid(SymmetricGroup(3)) # optional - sage.groups sage.modules
+ sage: H3.repr_element_method(style="reduced") # optional - sage.groups sage.modules
+ sage: H3.rhodes_radical_congruence() # optional - sage.groups sage.modules
[([1, 2], [2, 1]), ([1, 2], [1, 2, 1]), ([2, 1], [1, 2, 1])]
By Maschke's theorem, every group algebra over `\QQ`
is semisimple hence the Rhodes radical of a group must be trivial::
- sage: SymmetricGroup(3).rhodes_radical_congruence()
+ sage: SymmetricGroup(3).rhodes_radical_congruence() # optional - sage.groups sage.modules
[]
- sage: DihedralGroup(10).rhodes_radical_congruence()
+ sage: DihedralGroup(10).rhodes_radical_congruence() # optional - sage.groups sage.modules
[]
REFERENCES:
diff --git a/src/sage/categories/finite_permutation_groups.py b/src/sage/categories/finite_permutation_groups.py
index 59c00471e3f..e081d2d4f63 100644
--- a/src/sage/categories/finite_permutation_groups.py
+++ b/src/sage/categories/finite_permutation_groups.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# sage.doctest: optional - sage.groups
r"""
Finite Permutation Groups
"""
diff --git a/src/sage/categories/finite_posets.py b/src/sage/categories/finite_posets.py
index b5422adfd4e..263033a2c9b 100644
--- a/src/sage/categories/finite_posets.py
+++ b/src/sage/categories/finite_posets.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.combinat sage.graphs
r"""
Finite posets
diff --git a/src/sage/categories/finite_semigroups.py b/src/sage/categories/finite_semigroups.py
index a7f9b9a20a1..e9c31e1ad62 100644
--- a/src/sage/categories/finite_semigroups.py
+++ b/src/sage/categories/finite_semigroups.py
@@ -51,7 +51,8 @@ class FiniteSemigroups(CategoryWithAxiom):
sage: sorted(C.axioms())
['Associative', 'Finite']
sage: C.example()
- An example of a finite semigroup: the left regular band generated by ('a', 'b', 'c', 'd')
+ An example of a finite semigroup:
+ the left regular band generated by ('a', 'b', 'c', 'd')
TESTS::
@@ -86,8 +87,9 @@ def j_classes(self):
EXAMPLES::
sage: S = FiniteSemigroups().example(alphabet=('a','b', 'c'))
- sage: sorted(map(sorted, S.j_classes()))
- [['a'], ['ab', 'ba'], ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'], ['ac', 'ca'], ['b'], ['bc', 'cb'], ['c']]
+ sage: sorted(map(sorted, S.j_classes())) # optional - sage.graphs
+ [['a'], ['ab', 'ba'], ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],
+ ['ac', 'ca'], ['b'], ['bc', 'cb'], ['c']]
"""
return self.cayley_graph(side="twosided", simple=True).strongly_connected_components()
@@ -103,8 +105,9 @@ def j_classes_of_idempotents(self):
EXAMPLES::
sage: S = FiniteSemigroups().example(alphabet=('a','b', 'c'))
- sage: sorted(map(sorted, S.j_classes_of_idempotents()))
- [['a'], ['ab', 'ba'], ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'], ['ac', 'ca'], ['b'], ['bc', 'cb'], ['c']]
+ sage: sorted(map(sorted, S.j_classes_of_idempotents())) # optional - sage.graphs
+ [['a'], ['ab', 'ba'], ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],
+ ['ac', 'ca'], ['b'], ['bc', 'cb'], ['c']]
"""
return [l for l in ([x for x in cl if attrcall('is_idempotent')(x)] for cl in self.j_classes()) if len(l) > 0]
@@ -120,7 +123,7 @@ def j_transversal_of_idempotents(self):
The chosen elements depend on the order of each `J`-class,
and that order is random when using Python 3. ::
- sage: sorted(S.j_transversal_of_idempotents()) # random
+ sage: sorted(S.j_transversal_of_idempotents()) # random # optional - sage.graphs
['a', 'ab', 'abc', 'ac', 'b', 'c', 'cb']
"""
def first_idempotent(l):
diff --git a/src/sage/categories/finite_weyl_groups.py b/src/sage/categories/finite_weyl_groups.py
index 4420827c833..1d1d0250c23 100644
--- a/src/sage/categories/finite_weyl_groups.py
+++ b/src/sage/categories/finite_weyl_groups.py
@@ -27,7 +27,7 @@ class FiniteWeylGroups(CategoryWithAxiom):
TESTS::
sage: W = FiniteWeylGroups().example()
- sage: TestSuite(W).run()
+ sage: TestSuite(W).run() # optional - sage.combinat
"""
class ParentMethods:
diff --git a/src/sage/categories/finitely_generated_lambda_bracket_algebras.py b/src/sage/categories/finitely_generated_lambda_bracket_algebras.py
index 8877491e33e..85315805fad 100644
--- a/src/sage/categories/finitely_generated_lambda_bracket_algebras.py
+++ b/src/sage/categories/finitely_generated_lambda_bracket_algebras.py
@@ -27,7 +27,7 @@ class FinitelyGeneratedLambdaBracketAlgebras(CategoryWithAxiom_over_base_ring):
EXAMPLES::
sage: from sage.categories.lambda_bracket_algebras import LambdaBracketAlgebras
- sage: LambdaBracketAlgebras(QQbar).FinitelyGenerated()
+ sage: LambdaBracketAlgebras(QQbar).FinitelyGenerated() # optional - sage.rings.number_field
Category of finitely generated lambda bracket algebras over Algebraic Field
"""
_base_category_class_and_axiom = (LambdaBracketAlgebras, "FinitelyGeneratedAsLambdaBracketAlgebra")
@@ -38,12 +38,12 @@ def ngens(self):
EXAMPLES::
- sage: Vir = lie_conformal_algebras.Virasoro(QQ)
- sage: Vir.ngens()
+ sage: Vir = lie_conformal_algebras.Virasoro(QQ) # optional - sage.combinat sage.modules
+ sage: Vir.ngens() # optional - sage.combinat sage.modules
2
- sage: V = lie_conformal_algebras.Affine(QQ, 'A2')
- sage: V.ngens()
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A2') # optional - sage.combinat sage.modules
+ sage: V.ngens() # optional - sage.combinat sage.modules
9
"""
return len(self.gens())
@@ -54,12 +54,12 @@ def gen(self,i):
EXAMPLES::
- sage: V = lie_conformal_algebras.Affine(QQ, 'A1')
- sage: V.gens()
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A1') # optional - sage.combinat sage.modules
+ sage: V.gens() # optional - sage.combinat sage.modules
(B[alpha[1]], B[alphacheck[1]], B[-alpha[1]], B['K'])
- sage: V.gen(0)
+ sage: V.gen(0) # optional - sage.combinat sage.modules
B[alpha[1]]
- sage: V.1
+ sage: V.1 # optional - sage.combinat sage.modules
B[alphacheck[1]]
"""
return self.gens()[i]
@@ -73,10 +73,11 @@ def some_elements(self):
EXAMPLES::
- sage: V = lie_conformal_algebras.Affine(QQ, 'A1', names=('e', 'h', 'f'))
- sage: V.some_elements()
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A1', # optional - sage.combinat sage.modules
+ ....: names=('e', 'h', 'f'))
+ sage: V.some_elements() # optional - sage.combinat sage.modules
[e, h, f, K, ...]
- sage: all(v.parent() is V for v in V.some_elements())
+ sage: all(v.parent() is V for v in V.some_elements()) # optional - sage.combinat sage.modules
True
"""
S = list(self.gens())
@@ -91,8 +92,9 @@ class Graded(GradedModulesCategory):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).FinitelyGenerated().Graded()
- Category of H-graded finitely generated lie conformal algebras over Algebraic Field
+ sage: LieConformalAlgebras(QQbar).FinitelyGenerated().Graded() # optional - sage.rings.number_field
+ Category of H-graded finitely generated lie conformal algebras
+ over Algebraic Field
"""
def _repr_object_names(self):
"""
@@ -100,7 +102,7 @@ def _repr_object_names(self):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded()
+ sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded() # optional - sage.rings.number_field
Category of H-graded finitely generated Lie conformal algebras with basis over Algebraic Field
"""
return "H-graded {}".format(self.base_category()._repr_object_names())
diff --git a/src/sage/categories/finitely_generated_lie_conformal_algebras.py b/src/sage/categories/finitely_generated_lie_conformal_algebras.py
index 464d1eb7d03..96433749aa4 100644
--- a/src/sage/categories/finitely_generated_lie_conformal_algebras.py
+++ b/src/sage/categories/finitely_generated_lie_conformal_algebras.py
@@ -27,7 +27,7 @@ class FinitelyGeneratedLieConformalAlgebras(CategoryWithAxiom_over_base_ring):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).FinitelyGenerated()
+ sage: LieConformalAlgebras(QQbar).FinitelyGenerated() # optional - sage.rings.number_field
Category of finitely generated lie conformal algebras over Algebraic Field
"""
_base_category_class_and_axiom = (LieConformalAlgebras, "FinitelyGeneratedAsLambdaBracketAlgebra")
@@ -43,10 +43,11 @@ def some_elements(self):
EXAMPLES::
- sage: V = lie_conformal_algebras.Affine(QQ, 'A1', names=('e', 'h', 'f'))
- sage: V.some_elements()
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A1', # optional - sage.combinat sage.modules
+ ....: names=('e', 'h', 'f'))
+ sage: V.some_elements() # optional - sage.combinat sage.modules
[e, h, f, K, ...]
- sage: all(v.parent() is V for v in V.some_elements())
+ sage: all(v.parent() is V for v in V.some_elements()) # optional - sage.combinat sage.modules
True
"""
S = list(self.gens())
@@ -61,8 +62,9 @@ class Super(SuperModulesCategory):
EXAMPLES::
- sage: LieConformalAlgebras(AA).FinitelyGenerated().Super()
- Category of super finitely generated lie conformal algebras over Algebraic Real Field
+ sage: LieConformalAlgebras(AA).FinitelyGenerated().Super() # optional - sage.rings.number_field
+ Category of super finitely generated lie conformal algebras
+ over Algebraic Real Field
"""
class Graded(GradedModulesCategory):
"""
@@ -70,8 +72,9 @@ class Graded(GradedModulesCategory):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).FinitelyGenerated().Super().Graded()
- Category of H-graded super finitely generated lie conformal algebras over Algebraic Field
+ sage: LieConformalAlgebras(QQbar).FinitelyGenerated().Super().Graded() # optional - sage.rings.number_field
+ Category of H-graded super finitely generated lie conformal algebras
+ over Algebraic Field
"""
def _repr_object_names(self):
"""
@@ -79,9 +82,10 @@ def _repr_object_names(self):
EXAMPLES::
- sage: C = LieConformalAlgebras(QQbar).FinitelyGenerated()
- sage: C.Super().Graded()
- Category of H-graded super finitely generated lie conformal algebras over Algebraic Field
+ sage: C = LieConformalAlgebras(QQbar).FinitelyGenerated() # optional - sage.rings.number_field
+ sage: C.Super().Graded() # optional - sage.rings.number_field
+ Category of H-graded super finitely generated
+ lie conformal algebras over Algebraic Field
"""
return "H-graded {}".format(self.base_category()._repr_object_names())
@@ -91,8 +95,9 @@ class Graded(GradedModulesCategory):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).FinitelyGenerated().Graded()
- Category of H-graded finitely generated lie conformal algebras over Algebraic Field
+ sage: LieConformalAlgebras(QQbar).FinitelyGenerated().Graded() # optional - sage.rings.number_field
+ Category of H-graded finitely generated lie conformal algebras
+ over Algebraic Field
"""
def _repr_object_names(self):
"""
@@ -100,7 +105,8 @@ def _repr_object_names(self):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded()
- Category of H-graded finitely generated Lie conformal algebras with basis over Algebraic Field
+ sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded() # optional - sage.rings.number_field
+ Category of H-graded finitely generated Lie conformal algebras with basis
+ over Algebraic Field
"""
return "H-graded {}".format(self.base_category()._repr_object_names())
diff --git a/src/sage/categories/functor.pyx b/src/sage/categories/functor.pyx
index a0e8b42e1bf..58ff4cb21bf 100644
--- a/src/sage/categories/functor.pyx
+++ b/src/sage/categories/functor.pyx
@@ -112,12 +112,12 @@ cdef class Functor(SageObject):
this behaviour. Here we illustrate the default::
sage: from sage.categories.functor import Functor
- sage: F = Functor(Rings(),Fields())
+ sage: F = Functor(Rings(), Fields())
sage: F
Functor from Category of rings to Category of fields
sage: F(ZZ)
Rational Field
- sage: F(GF(2))
+ sage: F(GF(2)) # optional - sage.rings.finite_rings
Finite Field of size 2
Functors are not only about the objects of a category, but also about
@@ -128,7 +128,7 @@ cdef class Functor(SageObject):
sage: R1. = ZZ[]
sage: R2. = QQ[]
- sage: f = R1.hom([a+b],R2)
+ sage: f = R1.hom([a + b], R2)
sage: f
Ring morphism:
From: Univariate Polynomial Ring in x over Integer Ring
@@ -150,8 +150,10 @@ cdef class Functor(SageObject):
Poly[t]
sage: F(f)
Ring morphism:
- From: Univariate Polynomial Ring in t over Univariate Polynomial Ring in x over Integer Ring
- To: Univariate Polynomial Ring in t over Multivariate Polynomial Ring in a, b over Rational Field
+ From: Univariate Polynomial Ring in t
+ over Univariate Polynomial Ring in x over Integer Ring
+ To: Univariate Polynomial Ring in t
+ over Multivariate Polynomial Ring in a, b over Rational Field
Defn: Induced from base ring by
Ring morphism:
From: Univariate Polynomial Ring in x over Integer Ring
@@ -159,7 +161,8 @@ cdef class Functor(SageObject):
Defn: x |--> a + b
sage: p = R1['t']('(-x^2 + x)*t^2 + (x^2 - x)*t - 4*x^2 - x + 1')
sage: F(f)(p)
- (-a^2 - 2*a*b - b^2 + a + b)*t^2 + (a^2 + 2*a*b + b^2 - a - b)*t - 4*a^2 - 8*a*b - 4*b^2 - a - b + 1
+ (-a^2 - 2*a*b - b^2 + a + b)*t^2 + (a^2 + 2*a*b + b^2 - a - b)*t
+ - 4*a^2 - 8*a*b - 4*b^2 - a - b + 1
"""
def __init__(self, domain, codomain):
@@ -167,12 +170,12 @@ cdef class Functor(SageObject):
TESTS::
sage: from sage.categories.functor import Functor
- sage: F = Functor(Rings(),Fields())
+ sage: F = Functor(Rings(), Fields())
sage: F
Functor from Category of rings to Category of fields
sage: F(ZZ)
Rational Field
- sage: F(GF(2))
+ sage: F(GF(2)) # optional - sage.rings.finite_rings
Finite Field of size 2
"""
@@ -228,7 +231,7 @@ cdef class Functor(SageObject):
TESTS::
sage: from sage.categories.functor import Functor
- sage: F = Functor(FiniteFields(),Fields())
+ sage: F = Functor(FiniteFields(), Fields())
sage: F._apply_functor(ZZ)
Rational Field
@@ -248,20 +251,22 @@ cdef class Functor(SageObject):
TESTS::
sage: from sage.categories.functor import Functor
- sage: F = Functor(Rings(),Fields())
- sage: k. = GF(25)
- sage: f = k.hom([-a-4])
- sage: R. = k[]
- sage: fR = R.hom(f,R)
- sage: fF = F(fR) # indirect doctest
- sage: fF
- Ring endomorphism of Fraction Field of Univariate Polynomial Ring in t over Finite Field in a of size 5^2
+ sage: F = Functor(Rings(), Fields())
+ sage: k. = GF(25) # optional - sage.rings.finite_rings
+ sage: f = k.hom([-a - 4]) # optional - sage.rings.finite_rings
+ sage: R. = k[] # optional - sage.rings.finite_rings
+ sage: fR = R.hom(f, R) # optional - sage.rings.finite_rings
+ sage: fF = F(fR) # indirect doctest # optional - sage.rings.finite_rings
+ sage: fF # optional - sage.rings.finite_rings
+ Ring endomorphism of Fraction Field of
+ Univariate Polynomial Ring in t over Finite Field in a of size 5^2
Defn: Induced from base ring by
- Ring endomorphism of Univariate Polynomial Ring in t over Finite Field in a of size 5^2
+ Ring endomorphism of Univariate Polynomial Ring in t
+ over Finite Field in a of size 5^2
Defn: Induced from base ring by
Ring endomorphism of Finite Field in a of size 5^2
Defn: a |--> 4*a + 1
- sage: fF((a^2+a)*t^2/(a*t - a^2))
+ sage: fF((a^2+a)*t^2/(a*t - a^2)) # optional - sage.rings.finite_rings
((4*a + 2)*t^2)/(t + a + 4)
"""
@@ -334,13 +339,13 @@ cdef class Functor(SageObject):
Functor from Category of rings to Category of fields
sage: F(ZZ)
Rational Field
- sage: F(GF(2))
+ sage: F(GF(2)) # optional - sage.rings.finite_rings
Finite Field of size 2
Two subclasses::
- sage: F1 = ForgetfulFunctor(FiniteFields(),Fields())
- sage: F1(GF(5)) #indirect doctest
+ sage: F1 = ForgetfulFunctor(FiniteFields(), Fields())
+ sage: F1(GF(5)) # indirect doctest # optional - sage.rings.finite_rings
Finite Field of size 5
sage: F1(ZZ)
Traceback (most recent call last):
@@ -352,7 +357,8 @@ cdef class Functor(SageObject):
sage: F2(ZZ['x','y'])
Traceback (most recent call last):
...
- TypeError: x (=Multivariate Polynomial Ring in x, y over Integer Ring) is not in Category of fields
+ TypeError: x (=Multivariate Polynomial Ring in x, y over Integer Ring)
+ is not in Category of fields
The last example shows that it is tested whether the result of
applying the functor lies in the functor's codomain. Note that
@@ -360,20 +366,22 @@ cdef class Functor(SageObject):
which was fixed in :trac:`8807`::
sage: class IllFunctor(Functor):
- ....: def __init__(self, m,n):
+ ....: def __init__(self, m, n):
....: self._m = m
....: self._n = n
- ....: Functor.__init__(self,Rings(),Rings())
+ ....: Functor.__init__(self, Rings(), Rings())
....: def _apply_functor(self, R):
- ....: return MatrixSpace(R,self._m,self._n)
- sage: F = IllFunctor(2,2)
- sage: F(QQ)
+ ....: return MatrixSpace(R, self._m, self._n)
+ sage: F = IllFunctor(2, 2)
+ sage: F(QQ) # optional - sage.modules
Full MatrixSpace of 2 by 2 dense matrices over Rational Field
- sage: F = IllFunctor(2,3)
- sage: F(QQ)
+ sage: F = IllFunctor(2, 3)
+ sage: F(QQ) # optional - sage.modules
Traceback (most recent call last):
...
- TypeError: Functor from Category of rings to Category of rings is ill-defined, since it sends x (=Rational Field) to something that is not in Category of rings.
+ TypeError: Functor from Category of rings to Category of rings
+ is ill-defined, since it sends x (=Rational Field) to something
+ that is not in Category of rings.
"""
from sage.categories.morphism import is_Morphism
@@ -390,7 +398,7 @@ cdef class Functor(SageObject):
EXAMPLES::
- sage: F = ForgetfulFunctor(FiniteFields(),Fields())
+ sage: F = ForgetfulFunctor(FiniteFields(), Fields())
sage: F.domain()
Category of finite enumerated fields
@@ -403,7 +411,7 @@ cdef class Functor(SageObject):
EXAMPLES::
- sage: F = ForgetfulFunctor(FiniteFields(),Fields())
+ sage: F = ForgetfulFunctor(FiniteFields(), Fields())
sage: F.codomain()
Category of fields
@@ -456,10 +464,12 @@ class ForgetfulFunctor_generic(Functor):
EXAMPLES::
- sage: F = ForgetfulFunctor(FiniteFields(),Fields()) #indirect doctest
+ sage: F = ForgetfulFunctor(FiniteFields(), Fields()) # indirect doctest
sage: F
- The forgetful functor from Category of finite enumerated fields to Category of fields
- sage: F(GF(3))
+ The forgetful functor
+ from Category of finite enumerated fields
+ to Category of fields
+ sage: F(GF(3)) # optional - sage.rings.finite_rings
Finite Field of size 3
"""
@@ -477,9 +487,10 @@ class ForgetfulFunctor_generic(Functor):
"""
TESTS::
- sage: F = ForgetfulFunctor(FiniteFields(),Fields())
- sage: F #indirect doctest
- The forgetful functor from Category of finite enumerated fields to Category of fields
+ sage: F = ForgetfulFunctor(FiniteFields(), Fields())
+ sage: F # indirect doctest
+ The forgetful functor from Category of finite enumerated fields
+ to Category of fields
"""
return "The forgetful functor from %s to %s" % (self.domain(),
@@ -497,7 +508,7 @@ class ForgetfulFunctor_generic(Functor):
TESTS::
- sage: F1 = ForgetfulFunctor(FiniteFields(),Fields())
+ sage: F1 = ForgetfulFunctor(FiniteFields(), Fields())
This is to test against a bug occurring in a previous version
(see :trac:`8800`)::
@@ -524,7 +535,7 @@ class ForgetfulFunctor_generic(Functor):
EXAMPLES::
- sage: F1 = ForgetfulFunctor(FiniteFields(),Fields())
+ sage: F1 = ForgetfulFunctor(FiniteFields(), Fields())
sage: F1 != F1
False
sage: F1 != QQ
@@ -665,14 +676,17 @@ def ForgetfulFunctor(domain, codomain):
sage: abgrps = CommutativeAdditiveGroups()
sage: F = ForgetfulFunctor(rings, abgrps)
sage: F
- The forgetful functor from Category of rings to Category of commutative additive groups
+ The forgetful functor
+ from Category of rings
+ to Category of commutative additive groups
It would be a mistake to call it in opposite order::
sage: F = ForgetfulFunctor(abgrps, rings)
Traceback (most recent call last):
...
- ValueError: Forgetful functor not supported for domain Category of commutative additive groups
+ ValueError: Forgetful functor not supported for domain
+ Category of commutative additive groups
If both categories are equal, the forgetful functor is the same as the
identity functor::
diff --git a/src/sage/categories/g_sets.py b/src/sage/categories/g_sets.py
index b9447203e42..0f8004ddbf0 100644
--- a/src/sage/categories/g_sets.py
+++ b/src/sage/categories/g_sets.py
@@ -23,8 +23,8 @@ class GSets(Category):
EXAMPLES::
- sage: S = SymmetricGroup(3)
- sage: GSets(S)
+ sage: S = SymmetricGroup(3) # optional - sage.groups
+ sage: GSets(S) # optional - sage.groups
Category of G-sets for Symmetric group of order 3! as a permutation group
TODO: should this derive from Category_over_base?
@@ -33,8 +33,8 @@ def __init__(self, G):
"""
TESTS::
- sage: S8 = SymmetricGroup(8)
- sage: TestSuite(GSets(S8)).run()
+ sage: S8 = SymmetricGroup(8) # optional - sage.groups
+ sage: TestSuite(GSets(S8)).run() # optional - sage.groups
"""
Category.__init__(self)
self.__G = G
@@ -43,7 +43,7 @@ def _repr_object_names(self):
"""
EXAMPLES::
- sage: GSets(SymmetricGroup(8)) # indirect doctests
+ sage: GSets(SymmetricGroup(8)) # indirect doctests # optional - sage.groups
Category of G-sets for Symmetric group of order 8! as a permutation group
"""
return "G-sets for %s"%self.__G
@@ -55,7 +55,7 @@ def super_categories(self):
"""
EXAMPLES::
- sage: GSets(SymmetricGroup(8)).super_categories()
+ sage: GSets(SymmetricGroup(8)).super_categories() # optional - sage.groups
[Category of sets]
"""
return [Sets()]
@@ -67,7 +67,7 @@ def an_instance(cls):
EXAMPLES::
- sage: GSets.an_instance() # indirect doctest
+ sage: GSets.an_instance() # indirect doctest # optional - sage.groups
Category of G-sets for Symmetric group of order 8! as a permutation group
"""
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
diff --git a/src/sage/categories/graded_algebras.py b/src/sage/categories/graded_algebras.py
index 54ce5775c9e..efa1a501192 100644
--- a/src/sage/categories/graded_algebras.py
+++ b/src/sage/categories/graded_algebras.py
@@ -39,8 +39,8 @@ def graded_algebra(self):
EXAMPLES::
- sage: m = SymmetricFunctions(QQ).m()
- sage: m.graded_algebra() is m
+ sage: m = SymmetricFunctions(QQ).m() # optional - sage.combinat
+ sage: m.graded_algebra() is m # optional - sage.combinat
True
"""
return self
diff --git a/src/sage/categories/graded_algebras_with_basis.py b/src/sage/categories/graded_algebras_with_basis.py
index b4df3c3c260..52d80b78b4e 100644
--- a/src/sage/categories/graded_algebras_with_basis.py
+++ b/src/sage/categories/graded_algebras_with_basis.py
@@ -46,8 +46,8 @@ def graded_algebra(self):
EXAMPLES::
- sage: m = SymmetricFunctions(QQ).m()
- sage: m.graded_algebra() is m
+ sage: m = SymmetricFunctions(QQ).m() # optional - sage.combinat
+ sage: m.graded_algebra() is m # optional - sage.combinat sage.modules
True
TESTS:
@@ -57,21 +57,21 @@ def graded_algebra(self):
and :meth:`projection` (which form the interface of the
associated graded algebra) work correctly here::
- sage: to_gr = m.to_graded_conversion()
- sage: from_gr = m.from_graded_conversion()
- sage: m[2] == to_gr(m[2]) == from_gr(m[2])
+ sage: to_gr = m.to_graded_conversion() # optional - sage.combinat sage.modules
+ sage: from_gr = m.from_graded_conversion() # optional - sage.combinat sage.modules
+ sage: m[2] == to_gr(m[2]) == from_gr(m[2]) # optional - sage.combinat sage.modules
True
- sage: u = 3*m[1] - (1/2)*m[3]
- sage: u == to_gr(u) == from_gr(u)
+ sage: u = 3*m[1] - (1/2)*m[3] # optional - sage.combinat sage.modules
+ sage: u == to_gr(u) == from_gr(u) # optional - sage.combinat sage.modules
True
- sage: m.zero() == to_gr(m.zero()) == from_gr(m.zero())
+ sage: m.zero() == to_gr(m.zero()) == from_gr(m.zero()) # optional - sage.combinat sage.modules
True
- sage: p2 = m.projection(2)
- sage: p2(m[2] - 4*m[1,1] + 3*m[1] - 2*m[[]])
+ sage: p2 = m.projection(2) # optional - sage.combinat sage.modules
+ sage: p2(m[2] - 4*m[1,1] + 3*m[1] - 2*m[[]]) # optional - sage.combinat sage.modules
-4*m[1, 1] + m[2]
- sage: p2(4*m[1])
+ sage: p2(4*m[1]) # optional - sage.combinat sage.modules
0
- sage: p2(m.zero()) == m.zero()
+ sage: p2(m.zero()) == m.zero() # optional - sage.combinat sage.modules
True
"""
return self
@@ -111,13 +111,13 @@ def free_graded_module(self, generator_degrees, names=None):
EXAMPLES::
- sage: Q = QuadraticForm(QQ, 3, [1,2,3,4,5,6])
- sage: Cl = CliffordAlgebra(Q)
- sage: M = Cl.free_graded_module((0, 2, 3))
- sage: M.gens()
+ sage: Q = QuadraticForm(QQ, 3, [1,2,3,4,5,6]) # optional - sage.modules
+ sage: Cl = CliffordAlgebra(Q) # optional - sage.combinat sage.modules
+ sage: M = Cl.free_graded_module((0, 2, 3)) # optional - sage.combinat sage.modules
+ sage: M.gens() # optional - sage.combinat sage.modules
(g[0], g[2], g[3])
- sage: N. = Cl.free_graded_module((1, 2))
- sage: N.generators()
+ sage: N. = Cl.free_graded_module((1, 2)) # optional - sage.combinat sage.modules
+ sage: N.generators() # optional - sage.combinat sage.modules
(xy, z)
"""
try:
@@ -134,10 +134,10 @@ def formal_series_ring(self):
EXAMPLES::
- sage: NCSF = NonCommutativeSymmetricFunctions(QQ)
- sage: S = NCSF.Complete()
- sage: L = S.formal_series_ring()
- sage: L
+ sage: NCSF = NonCommutativeSymmetricFunctions(QQ) # optional - sage.combinat
+ sage: S = NCSF.Complete() # optional - sage.combinat
+ sage: L = S.formal_series_ring() # optional - sage.combinat
+ sage: L # optional - sage.combinat
Lazy completion of Non-Commutative Symmetric Functions over
the Rational Field in the Complete basis
"""
@@ -185,13 +185,13 @@ def one_basis(self):
EXAMPLES::
- sage: A. = ExteriorAlgebra(QQ)
- sage: A.one_basis()
+ sage: A. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: A.one_basis() # optional - sage.combinat sage.modules
0
- sage: B = tensor((A, A, A))
- sage: B.one_basis()
+ sage: B = tensor((A, A, A)) # optional - sage.combinat sage.modules
+ sage: B.one_basis() # optional - sage.combinat sage.modules
(0, 0, 0)
- sage: B.one()
+ sage: B.one() # optional - sage.combinat sage.modules
1 # 1 # 1
"""
# FIXME: this method should be conditionally defined,
@@ -211,10 +211,10 @@ def product_on_basis(self, t0, t1):
Test the sign in the super tensor product::
- sage: A = SteenrodAlgebra(3)
- sage: x = A.Q(0)
- sage: y = x.coproduct()
- sage: y^2
+ sage: A = SteenrodAlgebra(3) # optional - sage.combinat sage.modules
+ sage: x = A.Q(0) # optional - sage.combinat sage.modules
+ sage: y = x.coproduct() # optional - sage.combinat sage.modules
+ sage: y^2 # optional - sage.combinat sage.modules
0
TODO: optimize this implementation!
diff --git a/src/sage/categories/graded_hopf_algebras_with_basis.py b/src/sage/categories/graded_hopf_algebras_with_basis.py
index d806597ae0c..204ab23013e 100644
--- a/src/sage/categories/graded_hopf_algebras_with_basis.py
+++ b/src/sage/categories/graded_hopf_algebras_with_basis.py
@@ -44,7 +44,7 @@ def example(self):
TESTS::
- sage: GradedHopfAlgebrasWithBasis(QQ).example()
+ sage: GradedHopfAlgebrasWithBasis(QQ).example() # optional - sage.modules
An example of a graded connected Hopf algebra with basis over Rational Field
"""
from sage.categories.examples.graded_connected_hopf_algebras_with_basis import \
@@ -85,7 +85,7 @@ def example(self):
TESTS::
- sage: GradedHopfAlgebrasWithBasis(QQ).Connected().example()
+ sage: GradedHopfAlgebrasWithBasis(QQ).Connected().example() # optional - sage.modules
An example of a graded connected Hopf algebra with basis over Rational Field
"""
from sage.categories.examples.graded_connected_hopf_algebras_with_basis import \
@@ -114,10 +114,10 @@ def counit_on_basis(self, i):
EXAMPLES::
- sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example()
- sage: H.monomial(4).counit() # indirect doctest
+ sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example() # optional - sage.modules
+ sage: H.monomial(4).counit() # indirect doctest # optional - sage.modules
0
- sage: H.monomial(0).counit() # indirect doctest
+ sage: H.monomial(0).counit() # indirect doctest # optional - sage.modules
1
"""
if i == self.one_basis():
@@ -144,14 +144,14 @@ def antipode_on_basis(self, index):
TESTS::
- sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example()
- sage: H.monomial(0).antipode() # indirect doctest
+ sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example() # optional - sage.modules
+ sage: H.monomial(0).antipode() # indirect doctest # optional - sage.modules
P0
- sage: H.monomial(1).antipode() # indirect doctest
+ sage: H.monomial(1).antipode() # indirect doctest # optional - sage.modules
-P1
- sage: H.monomial(2).antipode() # indirect doctest
+ sage: H.monomial(2).antipode() # indirect doctest # optional - sage.modules
P2
- sage: H.monomial(3).antipode() # indirect doctest
+ sage: H.monomial(3).antipode() # indirect doctest # optional - sage.modules
-P3
"""
if self.monomial(index) == self.one():
diff --git a/src/sage/categories/graded_lie_conformal_algebras.py b/src/sage/categories/graded_lie_conformal_algebras.py
index 66950ecce53..2650492898d 100644
--- a/src/sage/categories/graded_lie_conformal_algebras.py
+++ b/src/sage/categories/graded_lie_conformal_algebras.py
@@ -31,11 +31,11 @@ def Super(self, base_ring=None):
EXAMPLES::
- sage: C = LieConformalAlgebras(QQbar)
- sage: C.Graded().Super() is C.Super().Graded()
+ sage: C = LieConformalAlgebras(QQbar) # optional - sage.rings.number_field
+ sage: C.Graded().Super() is C.Super().Graded() # optional - sage.rings.number_field
True
- sage: Cp = C.WithBasis()
- sage: Cp.Graded().Super() is Cp.Super().Graded()
+ sage: Cp = C.WithBasis() # optional - sage.rings.number_field
+ sage: Cp.Graded().Super() is Cp.Super().Graded() # optional - sage.rings.number_field
True
"""
return self.base_category().Super(base_ring).Graded()
@@ -46,10 +46,10 @@ def _repr_object_names(self):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).Graded()
+ sage: LieConformalAlgebras(QQbar).Graded() # optional - sage.rings.number_field
Category of H-graded Lie conformal algebras over Algebraic Field
- sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded()
+ sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded() # optional - sage.rings.number_field
Category of H-graded finitely generated Lie conformal algebras with basis over Algebraic Field
"""
return "H-graded {}".format(self.base_category()._repr_object_names())
@@ -60,7 +60,7 @@ class GradedLieConformalAlgebras(GradedLieConformalAlgebrasCategory):
EXAMPLES::
- sage: C = LieConformalAlgebras(QQbar).Graded(); C
+ sage: C = LieConformalAlgebras(QQbar).Graded(); C # optional - sage.rings.number_field
Category of H-graded Lie conformal algebras over Algebraic Field
sage: CS = LieConformalAlgebras(QQ).Graded().Super(); CS
diff --git a/src/sage/categories/graded_modules_with_basis.py b/src/sage/categories/graded_modules_with_basis.py
index 1868147bedb..b1185e20352 100644
--- a/src/sage/categories/graded_modules_with_basis.py
+++ b/src/sage/categories/graded_modules_with_basis.py
@@ -46,17 +46,18 @@ def degree_negation(self, element):
EXAMPLES::
- sage: E. = ExteriorAlgebra(QQ)
- sage: E.degree_negation((1 + a) * (1 + b))
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: E.degree_negation((1 + a) * (1 + b)) # optional - sage.combinat sage.modules
a*b - a - b + 1
- sage: E.degree_negation(E.zero())
+ sage: E.degree_negation(E.zero()) # optional - sage.combinat sage.modules
0
- sage: P = GradedModulesWithBasis(ZZ).example(); P
- An example of a graded module with basis: the free module on partitions over Integer Ring
- sage: pbp = lambda x: P.basis()[Partition(list(x))]
- sage: p = pbp([3,1]) - 2 * pbp([2]) + 4 * pbp([1])
- sage: P.degree_negation(p)
+ sage: P = GradedModulesWithBasis(ZZ).example(); P # optional - sage.combinat sage.modules
+ An example of a graded module with basis:
+ the free module on partitions over Integer Ring
+ sage: pbp = lambda x: P.basis()[Partition(list(x))] # optional - sage.combinat sage.modules
+ sage: p = pbp([3,1]) - 2 * pbp([2]) + 4 * pbp([1]) # optional - sage.combinat sage.modules
+ sage: P.degree_negation(p) # optional - sage.combinat sage.modules
-4*P[1] - 2*P[2] + P[3, 1]
"""
base_one = self.base_ring().one()
@@ -114,56 +115,63 @@ def submodule(self, gens, check=True, already_echelonized=False,
A graded submodule of a graded module generated by homogeneous
elements is naturally graded::
- sage: E. = ExteriorAlgebra(QQ)
- sage: S = E.submodule([x + y, x*y - y*z])
- sage: S.category()
- Join of Category of graded vector spaces with basis over Rational Field
- and Category of subobjects of filtered modules with basis over Rational Field
- and Category of finite dimensional vector spaces with basis over Rational Field
- sage: S.basis()[0].degree()
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: S = E.submodule([x + y, x*y - y*z]) # optional - sage.combinat sage.modules
+ sage: S.category() # optional - sage.combinat sage.modules
+ Join of
+ Category of graded vector spaces with basis over Rational Field and
+ Category of subobjects of filtered modules with basis over Rational Field and
+ Category of finite dimensional vector spaces with basis over Rational Field
+ sage: S.basis()[0].degree() # optional - sage.combinat sage.modules
1
- sage: S.basis()[1].degree()
+ sage: S.basis()[1].degree() # optional - sage.combinat sage.modules
2
We check on the echelonized basis::
- sage: Sp = E.submodule([1, x + y + 5, x*y - y*z + x + y - 2])
- sage: Sp.category()
- Join of Category of graded vector spaces with basis over Rational Field
- and Category of subobjects of filtered modules with basis over Rational Field
- and Category of finite dimensional vector spaces with basis over Rational Field
+ sage: Sp = E.submodule([1, x + y + 5, x*y - y*z + x + y - 2]) # optional - sage.combinat sage.modules
+ sage: Sp.category() # optional - sage.combinat sage.modules
+ Join of
+ Category of graded vector spaces with basis over Rational Field and
+ Category of subobjects of filtered modules with basis over Rational Field and
+ Category of finite dimensional vector spaces with basis over Rational Field
If it is generated by inhomogeneous elements, then it is
filtered by default::
- sage: F = E.submodule([x + y*z, x*z + y*x])
- sage: F.category()
- Join of Category of subobjects of filtered modules with basis over Rational Field
- and Category of filtered vector spaces with basis over Rational Field
- and Category of finite dimensional vector spaces with basis over Rational Field
+ sage: F = E.submodule([x + y*z, x*z + y*x]) # optional - sage.combinat sage.modules
+ sage: F.category() # optional - sage.combinat sage.modules
+ Join of
+ Category of subobjects of filtered modules with basis over Rational Field and
+ Category of filtered vector spaces with basis over Rational Field and
+ Category of finite dimensional vector spaces with basis over Rational Field
If ``category`` is specified, then it does not give any extra
structure to the submodule (we can think of this as applying
the forgetful functor)::
- sage: SM = E.submodule([x + y, x*y - y*z], category=ModulesWithBasis(QQ))
- sage: SM.category()
- Join of Category of finite dimensional vector spaces with basis over Rational Field
- and Category of subobjects of sets
- sage: FM = E.submodule([x + 1, x*y - x*y*z], category=ModulesWithBasis(QQ))
- sage: FM.category()
- Join of Category of finite dimensional vector spaces with basis over Rational Field
- and Category of subobjects of sets
+ sage: SM = E.submodule([x + y, x*y - y*z], # optional - sage.combinat sage.modules
+ ....: category=ModulesWithBasis(QQ))
+ sage: SM.category() # optional - sage.combinat sage.modules
+ Join of
+ Category of finite dimensional vector spaces with basis over Rational Field and
+ Category of subobjects of sets
+ sage: FM = E.submodule([x + 1, x*y - x*y*z], # optional - sage.combinat sage.modules
+ ....: category=ModulesWithBasis(QQ))
+ sage: FM.category() # optional - sage.combinat sage.modules
+ Join of
+ Category of finite dimensional vector spaces with basis over Rational Field and
+ Category of subobjects of sets
If we have specified that this is a graded submodule of a graded
module, then the echelonized elements must be homogeneous::
sage: Cat = ModulesWithBasis(QQ).Graded().Subobjects()
- sage: E.submodule([x + y, x*y - 1], category=Cat)
+ sage: E.submodule([x + y, x*y - 1], category=Cat) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
ValueError: all of the generators must be homogeneous
- sage: E.submodule([x + y, x*y - x - y], category=Cat)
+ sage: E.submodule([x + y, x*y - x - y], category=Cat) # optional - sage.combinat sage.modules
Free module generated by {0, 1} over Rational Field
"""
# Make sure gens consists of elements of ``self``
@@ -215,13 +223,14 @@ def quotient_module(self, submodule, check=True, already_echelonized=False, cate
EXAMPLES::
- sage: E. = ExteriorAlgebra(QQ)
- sage: S = E.submodule([x + y, x*y - y*z, y])
- sage: Q = E.quotient_module(S)
- sage: Q.category()
- Join of Category of quotients of graded modules with basis over Rational Field
- and Category of graded vector spaces with basis over Rational Field
- and Category of finite dimensional vector spaces with basis over Rational Field
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: S = E.submodule([x + y, x*y - y*z, y]) # optional - sage.combinat sage.modules
+ sage: Q = E.quotient_module(S) # optional - sage.combinat sage.modules
+ sage: Q.category() # optional - sage.combinat sage.modules
+ Join of
+ Category of quotients of graded modules with basis over Rational Field and
+ Category of graded vector spaces with basis over Rational Field and
+ Category of finite dimensional vector spaces with basis over Rational Field
.. SEEALSO::
@@ -258,17 +267,18 @@ def degree_negation(self):
EXAMPLES::
- sage: E. = ExteriorAlgebra(QQ)
- sage: ((1 + a) * (1 + b)).degree_negation()
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: ((1 + a) * (1 + b)).degree_negation() # optional - sage.combinat sage.modules
a*b - a - b + 1
- sage: E.zero().degree_negation()
+ sage: E.zero().degree_negation() # optional - sage.combinat sage.modules
0
- sage: P = GradedModulesWithBasis(ZZ).example(); P
- An example of a graded module with basis: the free module on partitions over Integer Ring
- sage: pbp = lambda x: P.basis()[Partition(list(x))]
- sage: p = pbp([3,1]) - 2 * pbp([2]) + 4 * pbp([1])
- sage: p.degree_negation()
+ sage: P = GradedModulesWithBasis(ZZ).example(); P # optional - sage.combinat sage.modules
+ An example of a graded module with basis:
+ the free module on partitions over Integer Ring
+ sage: pbp = lambda x: P.basis()[Partition(list(x))] # optional - sage.combinat sage.modules
+ sage: p = pbp([3,1]) - 2 * pbp([2]) + 4 * pbp([1]) # optional - sage.combinat sage.modules
+ sage: p.degree_negation() # optional - sage.combinat sage.modules
-4*P[1] - 2*P[2] + P[3, 1]
"""
return self.parent().degree_negation(self)
@@ -282,13 +292,13 @@ def degree_on_basis(self, m):
EXAMPLES::
- sage: E. = ExteriorAlgebra(QQ)
- sage: S = E.submodule([x + y, x*y - y*z, y])
- sage: Q = E.quotient_module(S)
- sage: B = Q.basis()
- sage: [B[i].lift() for i in Q.indices()]
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: S = E.submodule([x + y, x*y - y*z, y]) # optional - sage.combinat sage.modules
+ sage: Q = E.quotient_module(S) # optional - sage.combinat sage.modules
+ sage: B = Q.basis() # optional - sage.combinat sage.modules
+ sage: [B[i].lift() for i in Q.indices()] # optional - sage.combinat sage.modules
[1, z, x*z, y*z, x*y*z]
- sage: [Q.degree_on_basis(i) for i in Q.indices()]
+ sage: [Q.degree_on_basis(i) for i in Q.indices()] # optional - sage.combinat sage.modules
[0, 1, 2, 2, 3]
"""
return self.basis()[m].lift().degree()
@@ -300,13 +310,13 @@ def degree(self):
EXAMPLES::
- sage: E. = ExteriorAlgebra(QQ)
- sage: S = E.submodule([x + y, x*y - y*z, y])
- sage: Q = E.quotient_module(S)
- sage: B = Q.basis()
- sage: [B[i].lift() for i in Q.indices()]
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: S = E.submodule([x + y, x*y - y*z, y]) # optional - sage.combinat sage.modules
+ sage: Q = E.quotient_module(S) # optional - sage.combinat sage.modules
+ sage: B = Q.basis() # optional - sage.combinat sage.modules
+ sage: [B[i].lift() for i in Q.indices()] # optional - sage.combinat sage.modules
[1, z, x*z, y*z, x*y*z]
- sage: [B[i].degree() for i in Q.indices()]
+ sage: [B[i].degree() for i in Q.indices()] # optional - sage.combinat sage.modules
[0, 1, 2, 2, 3]
"""
return self.lift().degree()
diff --git a/src/sage/categories/group_algebras.py b/src/sage/categories/group_algebras.py
index 0df6bf44165..46e36fd47cf 100644
--- a/src/sage/categories/group_algebras.py
+++ b/src/sage/categories/group_algebras.py
@@ -50,15 +50,16 @@ class GroupAlgebras(AlgebrasCategory):
Here is how to create the group algebra of a group `G`::
- sage: G = DihedralGroup(5)
- sage: QG = G.algebra(QQ); QG
- Algebra of Dihedral group of order 10 as a permutation group over Rational Field
+ sage: G = DihedralGroup(5) # optional - sage.groups
+ sage: QG = G.algebra(QQ); QG # optional - sage.groups sage.modules
+ Algebra of
+ Dihedral group of order 10 as a permutation group over Rational Field
and an example of computation::
- sage: g = G.an_element(); g
+ sage: g = G.an_element(); g # optional - sage.groups sage.modules
(1,4)(2,3)
- sage: (QG.term(g) + 1)**3
+ sage: (QG.term(g) + 1)**3 # optional - sage.groups sage.modules
4*() + 4*(1,4)(2,3)
.. TODO::
@@ -68,14 +69,14 @@ class GroupAlgebras(AlgebrasCategory):
TESTS::
- sage: A = GroupAlgebras(QQ).example(GL(3, GF(11)))
- sage: A.one_basis()
+ sage: A = GroupAlgebras(QQ).example(GL(3, GF(11))) # optional - sage.groups sage.modules sage.rings.finite_rings
+ sage: A.one_basis() # optional - sage.groups sage.modules sage.rings.finite_rings
[1 0 0]
[0 1 0]
[0 0 1]
- sage: A = SymmetricGroupAlgebra(QQ,4)
- sage: x = Permutation([4,3,2,1])
- sage: A.product_on_basis(x,x)
+ sage: A = SymmetricGroupAlgebra(QQ, 4) # optional - sage.groups sage.modules sage.combinat
+ sage: x = Permutation([4,3,2,1]) # optional - sage.groups sage.modules sage.combinat
+ sage: A.product_on_basis(x, x) # optional - sage.groups sage.modules sage.combinat
[1, 2, 3, 4]
sage: C = GroupAlgebras(ZZ)
@@ -104,13 +105,15 @@ def example(self, G=None):
EXAMPLES::
- sage: GroupAlgebras(QQ['x']).example()
- Algebra of Dihedral group of order 8 as a permutation group over Univariate Polynomial Ring in x over Rational Field
+ sage: GroupAlgebras(QQ['x']).example() # optional - sage.groups sage.modules
+ Algebra of Dihedral group of order 8 as a permutation group
+ over Univariate Polynomial Ring in x over Rational Field
An other group can be specified as optional argument::
- sage: GroupAlgebras(QQ).example(AlternatingGroup(4))
- Algebra of Alternating group of order 4!/2 as a permutation group over Rational Field
+ sage: GroupAlgebras(QQ).example(AlternatingGroup(4)) # optional - sage.groups sage.modules
+ Algebra of
+ Alternating group of order 4!/2 as a permutation group over Rational Field
"""
from sage.groups.perm_gps.permgroup_named import DihedralGroup
if G is None:
@@ -124,19 +127,19 @@ def __init_extra__(self):
EXAMPLES::
- sage: A = GroupAlgebra(SymmetricGroup(4), QQ)
- sage: B = GroupAlgebra(SymmetricGroup(3), ZZ)
- sage: A.has_coerce_map_from(B)
+ sage: A = GroupAlgebra(SymmetricGroup(4), QQ) # optional - sage.groups sage.modules
+ sage: B = GroupAlgebra(SymmetricGroup(3), ZZ) # optional - sage.groups sage.modules
+ sage: A.has_coerce_map_from(B) # optional - sage.groups sage.modules
True
- sage: B.has_coerce_map_from(A)
+ sage: B.has_coerce_map_from(A) # optional - sage.groups sage.modules
False
- sage: A.has_coerce_map_from(ZZ)
+ sage: A.has_coerce_map_from(ZZ) # optional - sage.groups sage.modules
True
- sage: A.has_coerce_map_from(CC)
+ sage: A.has_coerce_map_from(CC) # optional - sage.groups sage.modules
False
- sage: A.has_coerce_map_from(SymmetricGroup(5))
+ sage: A.has_coerce_map_from(SymmetricGroup(5)) # optional - sage.groups sage.modules
False
- sage: A.has_coerce_map_from(SymmetricGroup(2))
+ sage: A.has_coerce_map_from(SymmetricGroup(2)) # optional - sage.groups sage.modules
True
"""
if not self.base_ring().has_coerce_map_from(self.group()):
@@ -152,8 +155,8 @@ def _latex_(self):
EXAMPLES::
- sage: A = GroupAlgebra(KleinFourGroup(), ZZ)
- sage: latex(A) # indirect doctest
+ sage: A = GroupAlgebra(KleinFourGroup(), ZZ) # optional - sage.groups sage.modules
+ sage: latex(A) # indirect doctest # optional - sage.groups sage.modules
\Bold{Z}[\langle (3,4), (1,2) \rangle]
"""
from sage.misc.latex import latex
@@ -165,9 +168,9 @@ def group(self):
EXAMPLES::
- sage: GroupAlgebras(QQ).example(GL(3, GF(11))).group()
+ sage: GroupAlgebras(QQ).example(GL(3, GF(11))).group() # optional - sage.groups sage.modules sage.rings.finite_rings
General Linear Group of degree 3 over Finite Field of size 11
- sage: SymmetricGroup(10).algebra(QQ).group()
+ sage: SymmetricGroup(10).algebra(QQ).group() # optional - sage.groups sage.modules
Symmetric group of order 10! as a permutation group
"""
return self.basis().keys()
@@ -195,7 +198,7 @@ def center_basis(self):
EXAMPLES::
- sage: SymmetricGroup(3).algebra(QQ).center_basis()
+ sage: SymmetricGroup(3).algebra(QQ).center_basis() # optional - sage.groups sage.modules
((), (2,3) + (1,2) + (1,3), (1,2,3) + (1,3,2))
.. SEEALSO::
@@ -217,15 +220,16 @@ def coproduct_on_basis(self, g):
EXAMPLES::
- sage: A = CyclicPermutationGroup(6).algebra(ZZ); A
- Algebra of Cyclic group of order 6 as a permutation group over Integer Ring
- sage: g = CyclicPermutationGroup(6).an_element(); g
+ sage: A = CyclicPermutationGroup(6).algebra(ZZ); A # optional - sage.groups sage.modules
+ Algebra of
+ Cyclic group of order 6 as a permutation group over Integer Ring
+ sage: g = CyclicPermutationGroup(6).an_element(); g # optional - sage.groups sage.modules
(1,2,3,4,5,6)
- sage: A.coproduct_on_basis(g)
+ sage: A.coproduct_on_basis(g) # optional - sage.groups sage.modules
(1,2,3,4,5,6) # (1,2,3,4,5,6)
- sage: a = A.an_element(); a
+ sage: a = A.an_element(); a # optional - sage.groups sage.modules
() + 3*(1,2,3,4,5,6) + 3*(1,3,5)(2,4,6)
- sage: a.coproduct()
+ sage: a.coproduct() # optional - sage.groups sage.modules
() # () + 3*(1,2,3,4,5,6) # (1,2,3,4,5,6) + 3*(1,3,5)(2,4,6) # (1,3,5)(2,4,6)
"""
from sage.categories.tensor import tensor
@@ -242,15 +246,16 @@ def antipode_on_basis(self,g):
EXAMPLES::
- sage: A = CyclicPermutationGroup(6).algebra(ZZ); A
- Algebra of Cyclic group of order 6 as a permutation group over Integer Ring
- sage: g = CyclicPermutationGroup(6).an_element();g
+ sage: A = CyclicPermutationGroup(6).algebra(ZZ); A # optional - sage.groups sage.modules
+ Algebra of
+ Cyclic group of order 6 as a permutation group over Integer Ring
+ sage: g = CyclicPermutationGroup(6).an_element(); g # optional - sage.groups sage.modules
(1,2,3,4,5,6)
- sage: A.antipode_on_basis(g)
+ sage: A.antipode_on_basis(g) # optional - sage.groups sage.modules
(1,6,5,4,3,2)
- sage: a = A.an_element(); a
+ sage: a = A.an_element(); a # optional - sage.groups sage.modules
() + 3*(1,2,3,4,5,6) + 3*(1,3,5)(2,4,6)
- sage: a.antipode()
+ sage: a.antipode() # optional - sage.groups sage.modules
() + 3*(1,5,3)(2,6,4) + 3*(1,6,5,4,3,2)
"""
return self.term(~g)
@@ -265,11 +270,12 @@ def counit_on_basis(self,g):
EXAMPLES::
- sage: A = CyclicPermutationGroup(6).algebra(ZZ);A
- Algebra of Cyclic group of order 6 as a permutation group over Integer Ring
- sage: g = CyclicPermutationGroup(6).an_element();g
+ sage: A = CyclicPermutationGroup(6).algebra(ZZ); A # optional - sage.groups sage.modules
+ Algebra of
+ Cyclic group of order 6 as a permutation group over Integer Ring
+ sage: g = CyclicPermutationGroup(6).an_element(); g # optional - sage.groups sage.modules
(1,2,3,4,5,6)
- sage: A.counit_on_basis(g)
+ sage: A.counit_on_basis(g) # optional - sage.groups sage.modules
1
"""
return self.base_ring().one()
@@ -284,11 +290,12 @@ def counit(self,x):
EXAMPLES::
- sage: A = CyclicPermutationGroup(6).algebra(ZZ); A
- Algebra of Cyclic group of order 6 as a permutation group over Integer Ring
- sage: a = A.an_element(); a
+ sage: A = CyclicPermutationGroup(6).algebra(ZZ); A # optional - sage.groups sage.modules
+ Algebra of
+ Cyclic group of order 6 as a permutation group over Integer Ring
+ sage: a = A.an_element(); a # optional - sage.groups sage.modules
() + 3*(1,2,3,4,5,6) + 3*(1,3,5)(2,4,6)
- sage: a.counit()
+ sage: a.counit() # optional - sage.groups sage.modules
7
"""
return self.base_ring().sum(x.coefficients())
@@ -305,17 +312,19 @@ def is_integral_domain(self, proof=True):
EXAMPLES::
- sage: GroupAlgebra(SymmetricGroup(2)).is_integral_domain()
+ sage: S2 = SymmetricGroup(2) # optional - sage.groups
+ sage: GroupAlgebra(S2).is_integral_domain() # optional - sage.groups sage.modules
False
- sage: GroupAlgebra(SymmetricGroup(1)).is_integral_domain()
+ sage: S1 = SymmetricGroup(1)
+ sage: GroupAlgebra(S1).is_integral_domain() # optional - sage.groups sage.modules
True
- sage: GroupAlgebra(SymmetricGroup(1), IntegerModRing(4)).is_integral_domain()
+ sage: GroupAlgebra(S1, IntegerModRing(4)).is_integral_domain() # optional - sage.groups sage.modules
False
- sage: GroupAlgebra(AbelianGroup(1)).is_integral_domain()
+ sage: GroupAlgebra(AbelianGroup(1)).is_integral_domain() # optional - sage.groups sage.modules
True
- sage: GroupAlgebra(AbelianGroup(2, [0,2])).is_integral_domain()
+ sage: GroupAlgebra(AbelianGroup(2, [0,2])).is_integral_domain() # optional - sage.groups sage.modules
False
- sage: GroupAlgebra(GL(2, ZZ)).is_integral_domain() # not implemented
+ sage: GroupAlgebra(GL(2, ZZ)).is_integral_domain() # not implemented # optional - sage.groups sage.modules
False
"""
from sage.sets.set import Set
@@ -385,22 +394,24 @@ def central_form(self):
EXAMPLES::
- sage: QS3 = SymmetricGroup(3).algebra(QQ)
- sage: A = QS3([2,3,1]) + QS3([3,1,2])
- sage: A.central_form()
+ sage: QS3 = SymmetricGroup(3).algebra(QQ) # optional - sage.groups sage.modules
+ sage: A = QS3([2,3,1]) + QS3([3,1,2]) # optional - sage.groups sage.modules
+ sage: A.central_form() # optional - sage.groups sage.modules
B[(1,2,3)]
- sage: QS4 = SymmetricGroup(4).algebra(QQ)
- sage: B = sum(len(s.cycle_type())*QS4(s) for s in Permutations(4))
- sage: B.central_form()
+ sage: QS4 = SymmetricGroup(4).algebra(QQ) # optional - sage.groups sage.modules
+ sage: B = sum(len(s.cycle_type()) * QS4(s) for s in Permutations(4)) # optional - sage.groups sage.modules
+ sage: B.central_form() # optional - sage.groups sage.modules
4*B[()] + 3*B[(1,2)] + 2*B[(1,2)(3,4)] + 2*B[(1,2,3)] + B[(1,2,3,4)]
The following test fails due to a bug involving combinatorial free modules and
the coercion system (see :trac:`28544`)::
- sage: QG = GroupAlgebras(QQ).example(PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]))
- sage: s = sum(i for i in QG.basis())
- sage: s.central_form() # not tested
- B[()] + B[(4,5)] + B[(3,4,5)] + B[(2,3)(4,5)] + B[(2,3,4,5)] + B[(1,2)(3,4,5)] + B[(1,2,3,4,5)]
+ sage: G = PermutationGroup([[(1,2,3),(4,5)], [(3,4)]]) # optional - sage.groups sage.modules
+ sage: QG = GroupAlgebras(QQ).example(G) # optional - sage.groups sage.modules
+ sage: s = sum(i for i in QG.basis()) # optional - sage.groups sage.modules
+ sage: s.central_form() # not tested # optional - sage.groups sage.modules
+ B[()] + B[(4,5)] + B[(3,4,5)] + B[(2,3)(4,5)]
+ + B[(2,3,4,5)] + B[(1,2)(3,4,5)] + B[(1,2,3,4,5)]
.. SEEALSO::
diff --git a/src/sage/categories/groupoid.py b/src/sage/categories/groupoid.py
index 4c6e3ae6042..9eee3750655 100644
--- a/src/sage/categories/groupoid.py
+++ b/src/sage/categories/groupoid.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.groups
r"""
Groupoid
"""
diff --git a/src/sage/categories/groups.py b/src/sage/categories/groups.py
index 97d57799f8c..569cfc0d36d 100644
--- a/src/sage/categories/groups.py
+++ b/src/sage/categories/groups.py
@@ -42,7 +42,7 @@ def example(self):
"""
EXAMPLES::
- sage: Groups().example()
+ sage: Groups().example() # optional - sage.groups
General Linear Group of degree 4 over Rational Field
"""
from sage.rings.rational_field import QQ
@@ -69,13 +69,13 @@ def free(index_set=None, names=None, **kwds):
EXAMPLES::
- sage: Groups.free(index_set=ZZ)
+ sage: Groups.free(index_set=ZZ) # optional - sage.groups
Free group indexed by Integer Ring
- sage: Groups().free(ZZ)
+ sage: Groups().free(ZZ) # optional - sage.groups
Free group indexed by Integer Ring
- sage: Groups().free(5)
+ sage: Groups().free(5) # optional - sage.groups
Free Group on generators {x0, x1, x2, x3, x4}
- sage: F. = Groups().free(); F
+ sage: F. = Groups().free(); F # optional - sage.groups
Free Group on generators {x, y, z}
"""
from sage.rings.integer_ring import ZZ
@@ -99,8 +99,8 @@ def group_generators(self):
EXAMPLES::
- sage: A = AlternatingGroup(4)
- sage: A.group_generators()
+ sage: A = AlternatingGroup(4) # optional - sage.groups
+ sage: A.group_generators() # optional - sage.groups
Family ((2,3,4), (1,2,3))
"""
from sage.sets.family import Family
@@ -120,11 +120,11 @@ def monoid_generators(self):
EXAMPLES::
- sage: A = AlternatingGroup(4)
- sage: A.monoid_generators()
+ sage: A = AlternatingGroup(4) # optional - sage.groups
+ sage: A.monoid_generators() # optional - sage.groups
Family ((2,3,4), (1,2,3))
- sage: F. = FreeGroup()
- sage: F.monoid_generators()
+ sage: F. = FreeGroup() # optional - sage.groups
+ sage: F.monoid_generators() # optional - sage.groups
Family (x, y, x^-1, y^-1)
"""
G = self.group_generators()
@@ -142,8 +142,8 @@ def _test_inverse(self, **options):
EXAMPLES::
- sage: G = SymmetricGroup(3)
- sage: G._test_inverse()
+ sage: G = SymmetricGroup(3) # optional - sage.groups
+ sage: G._test_inverse() # optional - sage.groups
"""
tester = self._tester(**options)
for x in tester.some_elements():
@@ -156,11 +156,13 @@ def semidirect_product(self, N, mapping, check=True):
EXAMPLES::
- sage: G = Groups().example()
- sage: G.semidirect_product(G,Morphism(G,G))
+ sage: G = Groups().example() # optional - sage.groups
+ sage: G.semidirect_product(G, Morphism(G, G)) # optional - sage.groups
Traceback (most recent call last):
...
- NotImplementedError: semidirect product of General Linear Group of degree 4 over Rational Field and General Linear Group of degree 4 over Rational Field not yet implemented
+ NotImplementedError: semidirect product of General Linear Group of degree 4
+ over Rational Field and General Linear Group of degree 4 over Rational Field
+ not yet implemented
"""
raise NotImplementedError("semidirect product of %s and %s not yet implemented" % (self, N))
@@ -176,11 +178,12 @@ def holomorph(self):
EXAMPLES::
- sage: G = Groups().example()
- sage: G.holomorph()
+ sage: G = Groups().example() # optional - sage.groups
+ sage: G.holomorph() # optional - sage.groups
Traceback (most recent call last):
...
- NotImplementedError: holomorph of General Linear Group of degree 4 over Rational Field not yet implemented
+ NotImplementedError: holomorph of General Linear Group of degree 4
+ over Rational Field not yet implemented
"""
raise NotImplementedError("holomorph of %s not yet implemented"%self)
@@ -243,11 +246,11 @@ def cayley_table(self, names='letters', elements=None):
Permutation groups, matrix groups and abelian groups
can all compute their multiplication tables. ::
- sage: G = DiCyclicGroup(3)
- sage: T = G.cayley_table()
- sage: T.column_keys()
+ sage: G = DiCyclicGroup(3) # optional - sage.groups
+ sage: T = G.cayley_table() # optional - sage.groups
+ sage: T.column_keys() # optional - sage.groups
((), (5,6,7), ..., (1,4,2,3)(5,7))
- sage: T
+ sage: T # optional - sage.groups
* a b c d e f g h i j k l
+------------------------
a| a b c d e f g h i j k l
@@ -265,8 +268,8 @@ def cayley_table(self, names='letters', elements=None):
::
- sage: M = SL(2, 2)
- sage: M.cayley_table()
+ sage: M = SL(2, 2) # optional - sage.groups
+ sage: M.cayley_table() # optional - sage.groups
* a b c d e f
+------------
a| a b c d e f
@@ -279,8 +282,8 @@ def cayley_table(self, names='letters', elements=None):
::
- sage: A = AbelianGroup([2, 3])
- sage: A.cayley_table()
+ sage: A = AbelianGroup([2, 3]) # optional - sage.groups
+ sage: A.cayley_table() # optional - sage.groups
* a b c d e f
+------------
a| a b c d e f
@@ -298,8 +301,8 @@ def cayley_table(self, names='letters', elements=None):
you can choose to just use the string representations
of the elements themselves. ::
- sage: C = CyclicPermutationGroup(11)
- sage: C.cayley_table(names='digits')
+ sage: C = CyclicPermutationGroup(11) # optional - sage.groups
+ sage: C.cayley_table(names='digits') # optional - sage.groups
* 00 01 02 03 04 05 06 07 08 09 10
+---------------------------------
00| 00 01 02 03 04 05 06 07 08 09 10
@@ -316,9 +319,9 @@ def cayley_table(self, names='letters', elements=None):
::
- sage: G = QuaternionGroup()
- sage: names = ['1', 'I', '-1', '-I', 'J', '-K', '-J', 'K']
- sage: G.cayley_table(names=names)
+ sage: G = QuaternionGroup() # optional - sage.groups
+ sage: names = ['1', 'I', '-1', '-I', 'J', '-K', '-J', 'K'] # optional - sage.groups
+ sage: G.cayley_table(names=names) # optional - sage.groups
* 1 I -1 -I J -K -J K
+------------------------
1| 1 I -1 -I J -K -J K
@@ -332,8 +335,8 @@ def cayley_table(self, names='letters', elements=None):
::
- sage: A = AbelianGroup([2,2])
- sage: A.cayley_table(names='elements')
+ sage: A = AbelianGroup([2, 2]) # optional - sage.groups
+ sage: A.cayley_table(names='elements') # optional - sage.groups
* 1 f1 f0 f0*f1
+------------------------
1| 1 f1 f0 f0*f1
@@ -345,10 +348,10 @@ def cayley_table(self, names='letters', elements=None):
routine behaves similarly, but changes an existing table "in-place."
::
- sage: G = AlternatingGroup(3)
- sage: T = G.cayley_table()
- sage: T.change_names('digits')
- sage: T
+ sage: G = AlternatingGroup(3) # optional - sage.groups
+ sage: T = G.cayley_table() # optional - sage.groups
+ sage: T.change_names('digits') # optional - sage.groups
+ sage: T # optional - sage.groups
* 0 1 2
+------
0| 0 1 2
@@ -360,11 +363,11 @@ def cayley_table(self, names='letters', elements=None):
Elements will be coerced into the group as part of setting
up the table. ::
- sage: G = SL(2,ZZ)
- sage: G
+ sage: G = SL(2,ZZ) # optional - sage.groups
+ sage: G # optional - sage.groups
Special Linear Group of degree 2 over Integer Ring
- sage: identity = matrix(ZZ, [[1,0], [0,1]])
- sage: G.cayley_table(elements=[identity, -identity])
+ sage: identity = matrix(ZZ, [[1,0], [0,1]]) # optional - sage.groups
+ sage: G.cayley_table(elements=[identity, -identity]) # optional - sage.groups
* a b
+----
a| a b
@@ -381,11 +384,11 @@ class provides even greater flexibility, including changing
confirms that they form a closed subset in the group.
::
- sage: from sage.matrix.operation_table import OperationTable
- sage: G = DiCyclicGroup(3)
- sage: commutator = lambda x, y: x*y*x^-1*y^-1
- sage: T = OperationTable(G, commutator)
- sage: T
+ sage: from sage.matrix.operation_table import OperationTable # optional - sage.groups
+ sage: G = DiCyclicGroup(3) # optional - sage.groups
+ sage: commutator = lambda x, y: x*y*x^-1*y^-1 # optional - sage.groups
+ sage: T = OperationTable(G, commutator) # optional - sage.groups
+ sage: T # optional - sage.groups
. a b c d e f g h i j k l
+------------------------
a| a a a a a a a a a a a a
@@ -401,12 +404,12 @@ class provides even greater flexibility, including changing
k| a b c a b c b a c b a c
l| a b c a b c c b a c b a
- sage: trans = T.translation()
- sage: comm = [trans['a'], trans['b'], trans['c']]
- sage: comm
+ sage: trans = T.translation() # optional - sage.groups
+ sage: comm = [trans['a'], trans['b'], trans['c']] # optional - sage.groups
+ sage: comm # optional - sage.groups
[(), (5,6,7), (5,7,6)]
- sage: P = G.cayley_table(elements=comm)
- sage: P
+ sage: P = G.cayley_table(elements=comm) # optional - sage.groups
+ sage: P # optional - sage.groups
* a b c
+------
a| a b c
@@ -437,9 +440,9 @@ def conjugacy_class(self, g):
EXAMPLES::
- sage: A = AbelianGroup([2,2])
- sage: c = A.conjugacy_class(A.an_element())
- sage: type(c)
+ sage: A = AbelianGroup([2, 2]) # optional - sage.groups
+ sage: c = A.conjugacy_class(A.an_element()) # optional - sage.groups
+ sage: type(c) # optional - sage.groups
"""
from sage.groups.conjugacy_classes import ConjugacyClass
@@ -452,29 +455,32 @@ def conjugacy_class(self):
EXAMPLES::
- sage: D = DihedralGroup(5)
- sage: g = D((1,3,5,2,4))
- sage: g.conjugacy_class()
- Conjugacy class of (1,3,5,2,4) in Dihedral group of order 10 as a permutation group
+ sage: D = DihedralGroup(5) # optional - sage.groups
+ sage: g = D((1,3,5,2,4)) # optional - sage.groups
+ sage: g.conjugacy_class() # optional - sage.groups
+ Conjugacy class of (1,3,5,2,4)
+ in Dihedral group of order 10 as a permutation group
- sage: H = MatrixGroup([matrix(GF(5),2,[1,2, -1, 1]), matrix(GF(5),2, [1,1, 0,1])])
- sage: h = H(matrix(GF(5),2,[1,2, -1, 1]))
- sage: h.conjugacy_class()
+ sage: H = MatrixGroup([matrix(GF(5), 2, [1,2, -1,1]), # optional - sage.groups sage.rings.finite_rings sage.modules
+ ....: matrix(GF(5), 2, [1,1, 0,1])])
+ sage: h = H(matrix(GF(5), 2, [1,2, -1,1])) # optional - sage.groups sage.rings.finite_rings sage.modules
+ sage: h.conjugacy_class() # optional - sage.groups sage.rings.finite_rings sage.modules
Conjugacy class of [1 2]
- [4 1] in Matrix group over Finite Field of size 5 with 2 generators (
+ [4 1]
+ in Matrix group over Finite Field of size 5 with 2 generators (
[1 2] [1 1]
[4 1], [0 1]
)
- sage: G = SL(2, GF(2))
- sage: g = G.gens()[0]
- sage: g.conjugacy_class()
+ sage: G = SL(2, GF(2)) # optional - sage.groups sage.rings.finite_rings sage.modules
+ sage: g = G.gens()[0] # optional - sage.groups sage.rings.finite_rings sage.modules
+ sage: g.conjugacy_class() # optional - sage.groups sage.rings.finite_rings sage.modules
Conjugacy class of [1 1]
[0 1] in Special Linear Group of degree 2 over Finite Field of size 2
- sage: G = SL(2, QQ)
- sage: g = G([[1,1],[0,1]])
- sage: g.conjugacy_class()
+ sage: G = SL(2, QQ) # optional - sage.groups sage.modules
+ sage: g = G([[1,1], [0,1]]) # optional - sage.groups sage.modules
+ sage: g.conjugacy_class() # optional - sage.groups sage.modules
Conjugacy class of [1 1]
[0 1] in Special Linear Group of degree 2 over Rational Field
"""
@@ -505,13 +511,13 @@ def free(index_set=None, names=None, **kwds):
EXAMPLES::
- sage: Groups.Commutative.free(index_set=ZZ)
+ sage: Groups.Commutative.free(index_set=ZZ) # optional - sage.groups
Free abelian group indexed by Integer Ring
- sage: Groups().Commutative().free(ZZ)
+ sage: Groups().Commutative().free(ZZ) # optional - sage.groups
Free abelian group indexed by Integer Ring
- sage: Groups().Commutative().free(5)
+ sage: Groups().Commutative().free(5) # optional - sage.groups
Multiplicative Abelian group isomorphic to Z x Z x Z x Z x Z
- sage: F. = Groups().Commutative().free(); F
+ sage: F. = Groups().Commutative().free(); F # optional - sage.groups
Multiplicative Abelian group isomorphic to Z x Z x Z
"""
from sage.rings.integer_ring import ZZ
@@ -568,11 +574,11 @@ def group_generators(self):
EXAMPLES::
- sage: C5 = CyclicPermutationGroup(5)
- sage: C4 = CyclicPermutationGroup(4)
- sage: S4 = SymmetricGroup(3)
- sage: C = cartesian_product([C5, C4, S4])
- sage: C.group_generators()
+ sage: C5 = CyclicPermutationGroup(5) # optional - sage.groups
+ sage: C4 = CyclicPermutationGroup(4) # optional - sage.groups
+ sage: S4 = SymmetricGroup(3) # optional - sage.groups
+ sage: C = cartesian_product([C5, C4, S4]) # optional - sage.groups
+ sage: C.group_generators() # optional - sage.groups
Family (((1,2,3,4,5), (), ()),
((), (1,2,3,4), ()),
((), (), (1,2)),
@@ -580,16 +586,16 @@ def group_generators(self):
We check the other portion of :trac:`16718` is fixed::
- sage: len(C.j_classes())
+ sage: len(C.j_classes()) # optional - sage.groups
1
An example with an infinitely generated group (a better output
is needed)::
- sage: G = Groups.free([1,2])
- sage: H = Groups.free(ZZ)
- sage: C = cartesian_product([G, H])
- sage: C.monoid_generators()
+ sage: G = Groups.free([1,2]) # optional - sage.groups
+ sage: H = Groups.free(ZZ) # optional - sage.groups
+ sage: C = cartesian_product([G, H]) # optional - sage.groups
+ sage: C.monoid_generators() # optional - sage.groups
Lazy family (gen(i))_{i in The Cartesian product of (...)}
"""
F = self.cartesian_factors()
@@ -622,13 +628,13 @@ def order(self):
EXAMPLES::
- sage: C = cartesian_product([SymmetricGroup(10), SL(2,GF(3))])
- sage: C.order()
+ sage: C = cartesian_product([SymmetricGroup(10), SL(2, GF(3))]) # optional - sage.groups sage.rings.finite_rings
+ sage: C.order() # optional - sage.groups sage.rings.finite_rings
87091200
TESTS::
- sage: C.order.__module__
+ sage: C.order.__module__ # optional - sage.groups sage.rings.finite_rings
'sage.categories.groups'
.. TODO::
diff --git a/src/sage/categories/hecke_modules.py b/src/sage/categories/hecke_modules.py
index 6b593d4fb3a..9372e88c54b 100644
--- a/src/sage/categories/hecke_modules.py
+++ b/src/sage/categories/hecke_modules.py
@@ -46,7 +46,7 @@ class HeckeModules(Category_module):
sage: HeckeModules(IntegerRing())
Category of Hecke modules over Integer Ring
- sage: HeckeModules(FiniteField(5))
+ sage: HeckeModules(FiniteField(5)) # optional - sage.rings.finite_rings
Category of Hecke modules over Finite Field of size 5
The base ring doesn't have to be a principal ideal domain::
@@ -64,7 +64,7 @@ def __init__(self, R):
sage: TestSuite(HeckeModules(ZZ)).run()
- sage: HeckeModules(Partitions(3)).run()
+ sage: HeckeModules(Partitions(3)).run() # optional - sage.combinat
Traceback (most recent call last):
...
TypeError: R (=Partitions of the integer 3) must be a commutative ring
@@ -123,7 +123,10 @@ def _Hom_(self, Y, category):
sage: M = ModularForms(Gamma0(7), 4)
sage: H = M._Hom_(M, category = HeckeModules(QQ)); H
- Set of Morphisms from Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) of weight 4 over Rational Field to Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) of weight 4 over Rational Field in Category of Hecke modules over Rational Field
+ Set of Morphisms
+ from Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) of weight 4 over Rational Field
+ to Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(7) of weight 4 over Rational Field
+ in Category of Hecke modules over Rational Field
sage: H.__class__
sage: TestSuite(H).run(skip=["_test_elements", "_test_an_element", "_test_elements_eq",
@@ -142,7 +145,8 @@ def _Hom_(self, Y, category):
sage: H = M._Hom_(M, category = HeckeModules(GF(5))); H
Traceback (most recent call last):
...
- TypeError: Category of Hecke modules over Finite Field of size 5 is not a subcategory of Category of Hecke modules over Rational Field
+ TypeError: Category of Hecke modules over Finite Field of size 5
+ is not a subcategory of Category of Hecke modules over Rational Field
"""
# TODO: double check that it's the correct HeckeModules category below:
if category is not None and not category.is_subcategory(HeckeModules(self.base_ring())):
diff --git a/src/sage/categories/highest_weight_crystals.py b/src/sage/categories/highest_weight_crystals.py
index b8afdee2117..226d310eb35 100644
--- a/src/sage/categories/highest_weight_crystals.py
+++ b/src/sage/categories/highest_weight_crystals.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.graphs, sage.combinat
r"""
Highest Weight Crystals
"""
@@ -128,7 +129,8 @@ def highest_weight_vectors(self):
::
sage: C = crystals.Letters(['A',2])
- sage: T = crystals.TensorProduct(C,C,C,generators=[[C(2),C(1),C(1)],[C(1),C(2),C(1)]])
+ sage: T = crystals.TensorProduct(C, C, C, generators=[[C(2),C(1),C(1)],
+ ....: [C(1),C(2),C(1)]])
sage: T.highest_weight_vectors()
([2, 1, 1], [1, 2, 1])
"""
@@ -174,7 +176,8 @@ def lowest_weight_vectors(self):
::
sage: C = crystals.Letters(['A',2])
- sage: T = crystals.TensorProduct(C,C,C,generators=[[C(2),C(1),C(1)],[C(1),C(2),C(1)]])
+ sage: T = crystals.TensorProduct(C, C, C,generators=[[C(2),C(1),C(1)],
+ ....: [C(1),C(2),C(1)]])
sage: T.lowest_weight_vectors()
([3, 2, 3], [3, 3, 2])
"""
diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
index 88b162c5845..6554c895ff4 100644
--- a/src/sage/categories/homset.py
+++ b/src/sage/categories/homset.py
@@ -11,26 +11,26 @@
In the following, the :class:`Hom` object is indeed cached::
- sage: K = GF(17)
- sage: H = Hom(ZZ, K)
- sage: H
+ sage: K = GF(17) # optional - sage.rings.finite_rings
+ sage: H = Hom(ZZ, K) # optional - sage.rings.finite_rings
+ sage: H # optional - sage.rings.finite_rings
Set of Homomorphisms from Integer Ring to Finite Field of size 17
- sage: H is Hom(ZZ, K)
+ sage: H is Hom(ZZ, K) # optional - sage.rings.finite_rings
True
Nonetheless, garbage collection occurs when the original references are
overwritten::
- sage: for p in prime_range(200):
+ sage: for p in prime_range(200): # optional - sage.rings.finite_rings
....: K = GF(p)
....: H = Hom(ZZ, K)
sage: import gc
sage: _ = gc.collect()
- sage: from sage.rings.finite_rings.finite_field_prime_modn import FiniteField_prime_modn as FF
- sage: L = [x for x in gc.get_objects() if isinstance(x, FF)]
- sage: len(L)
+ sage: from sage.rings.finite_rings.finite_field_prime_modn import FiniteField_prime_modn as FF # optional - sage.rings.finite_rings
+ sage: L = [x for x in gc.get_objects() if isinstance(x, FF)] # optional - sage.rings.finite_rings
+ sage: len(L) # optional - sage.rings.finite_rings
1
- sage: L
+ sage: L # optional - sage.rings.finite_rings
[Finite Field of size 199]
AUTHORS:
@@ -104,34 +104,43 @@ def Hom(X, Y, category=None, check=True):
EXAMPLES::
- sage: V = VectorSpace(QQ,3)
- sage: Hom(V, V)
+ sage: V = VectorSpace(QQ, 3) # optional - sage.modules
+ sage: Hom(V, V) # optional - sage.modules
Set of Morphisms (Linear Transformations) from
Vector space of dimension 3 over Rational Field to
Vector space of dimension 3 over Rational Field
- sage: G = AlternatingGroup(3)
- sage: Hom(G, G)
- Set of Morphisms from Alternating group of order 3!/2 as a permutation group to Alternating group of order 3!/2 as a permutation group in Category of finite enumerated permutation groups
- sage: Hom(ZZ, QQ, Sets())
+ sage: G = AlternatingGroup(3) # optional - sage.groups
+ sage: Hom(G, G) # optional - sage.groups
+ Set of Morphisms
+ from Alternating group of order 3!/2 as a permutation group
+ to Alternating group of order 3!/2 as a permutation group
+ in Category of finite enumerated permutation groups
+ sage: Hom(ZZ, QQ, Sets()) # optional - sage.groups
Set of Morphisms from Integer Ring to Rational Field in Category of sets
- sage: Hom(FreeModule(ZZ,1), FreeModule(QQ,1))
- Set of Morphisms from Ambient free module of rank 1 over the principal ideal domain Integer Ring to Vector space of dimension 1 over Rational Field in Category of commutative additive groups
- sage: Hom(FreeModule(QQ,1), FreeModule(ZZ,1))
- Set of Morphisms from Vector space of dimension 1 over Rational Field to Ambient free module of rank 1 over the principal ideal domain Integer Ring in Category of commutative additive groups
+ sage: Hom(FreeModule(ZZ, 1), FreeModule(QQ, 1)) # optional - sage.modules
+ Set of Morphisms
+ from Ambient free module of rank 1 over the principal ideal domain Integer Ring
+ to Vector space of dimension 1 over Rational Field
+ in Category of commutative additive groups
+ sage: Hom(FreeModule(QQ, 1), FreeModule(ZZ, 1)) # optional - sage.modules
+ Set of Morphisms
+ from Vector space of dimension 1 over Rational Field
+ to Ambient free module of rank 1 over the principal ideal domain Integer Ring
+ in Category of commutative additive groups
Here, we test against a memory leak that has been fixed at :trac:`11521` by
using a weak cache::
- sage: for p in prime_range(10^3):
+ sage: for p in prime_range(10^3): # optional - sage.rings.finite_rings
....: K = GF(p)
....: a = K(0)
sage: import gc
sage: gc.collect() # random
624
- sage: from sage.rings.finite_rings.finite_field_prime_modn import FiniteField_prime_modn as FF
- sage: L = [x for x in gc.get_objects() if isinstance(x, FF)]
- sage: len(L), L[0]
+ sage: from sage.rings.finite_rings.finite_field_prime_modn import FiniteField_prime_modn as FF # optional - sage.rings.finite_rings
+ sage: L = [x for x in gc.get_objects() if isinstance(x, FF)] # optional - sage.rings.finite_rings
+ sage: len(L), L[0] # optional - sage.rings.finite_rings
(1, Finite Field of size 997)
To illustrate the choice of the category, we consider the
@@ -139,13 +148,13 @@ def Hom(X, Y, category=None, check=True):
sage: X = ZZ; X
Integer Ring
- sage: Y = SymmetricGroup(3); Y
+ sage: Y = SymmetricGroup(3); Y # optional - sage.groups
Symmetric group of order 3! as a permutation group
By default, the smallest category containing both ``X`` and ``Y``,
is used::
- sage: Hom(X, Y)
+ sage: Hom(X, Y) # optional - sage.groups
Set of Morphisms from Integer Ring
to Symmetric group of order 3! as a permutation group
in Category of enumerated monoids
@@ -153,10 +162,13 @@ def Hom(X, Y, category=None, check=True):
Otherwise, if ``category`` is specified, then ``category`` is used,
after checking that ``X`` and ``Y`` are indeed in ``category``::
- sage: Hom(X, Y, Magmas())
- Set of Morphisms from Integer Ring to Symmetric group of order 3! as a permutation group in Category of magmas
+ sage: Hom(X, Y, Magmas()) # optional - sage.groups
+ Set of Morphisms
+ from Integer Ring
+ to Symmetric group of order 3! as a permutation group
+ in Category of magmas
- sage: Hom(X, Y, Groups())
+ sage: Hom(X, Y, Groups()) # optional - sage.groups
Traceback (most recent call last):
...
ValueError: Integer Ring is not in Category of groups
@@ -183,10 +195,10 @@ def Hom(X, Y, category=None, check=True):
Homset are unique parents::
- sage: k = GF(5)
- sage: H1 = Hom(k,k)
- sage: H2 = Hom(k,k)
- sage: H1 is H2
+ sage: k = GF(5) # optional - sage.rings.finite_rings
+ sage: H1 = Hom(k, k) # optional - sage.rings.finite_rings
+ sage: H2 = Hom(k, k) # optional - sage.rings.finite_rings
+ sage: H1 is H2 # optional - sage.rings.finite_rings
True
Moreover, if no category is provided, then the result is identical
@@ -231,16 +243,16 @@ def Hom(X, Y, category=None, check=True):
Variation on the theme::
- sage: U1 = FreeModule(ZZ,2)
- sage: U2 = FreeModule(ZZ,2,inner_product_matrix=matrix([[1,0],[0,-1]]))
- sage: U1 == U2, U1 is U2
+ sage: U1 = FreeModule(ZZ, 2) # optional - sage.modules
+ sage: U2 = FreeModule(ZZ, 2, inner_product_matrix=matrix([[1,0], [0,-1]])) # optional - sage.modules
+ sage: U1 == U2, U1 is U2 # optional - sage.modules
(False, False)
- sage: V = ZZ^3
- sage: H1 = Hom(U1, V); H2 = Hom(U2, V)
- sage: H1 == H2, H1 is H2
+ sage: V = ZZ^3 # optional - sage.modules
+ sage: H1 = Hom(U1, V); H2 = Hom(U2, V) # optional - sage.modules
+ sage: H1 == H2, H1 is H2 # optional - sage.modules
(False, False)
- sage: H1 = Hom(V, U1); H2 = Hom(V, U2)
- sage: H1 == H2, H1 is H2
+ sage: H1 = Hom(V, U1); H2 = Hom(V, U2) # optional - sage.modules
+ sage: H1 == H2, H1 is H2 # optional - sage.modules
(False, False)
Since :trac:`11900`, the meet of the categories of the given arguments is
@@ -249,12 +261,18 @@ def Hom(X, Y, category=None, check=True):
sage: PA = Parent(category=Algebras(QQ))
sage: PJ = Parent(category=Rings() & Modules(QQ))
- sage: Hom(PA,PJ)
- Set of Homomorphisms from to
- sage: Hom(PA,PJ).category()
- Category of homsets of unital magmas and right modules over Rational Field and left modules over Rational Field
- sage: Hom(PA,PJ, Rngs())
- Set of Morphisms from to in Category of rngs
+ sage: Hom(PA, PJ)
+ Set of Homomorphisms
+ from
+ to
+ sage: Hom(PA, PJ).category()
+ Category of homsets of
+ unital magmas and right modules over Rational Field
+ and left modules over Rational Field
+ sage: Hom(PA, PJ, Rngs())
+ Set of Morphisms
+ from
+ to in Category of rngs
.. TODO::
@@ -280,17 +298,17 @@ def Hom(X, Y, category=None, check=True):
Checks that the domain and codomain are in the specified
category. Case of a non parent::
- sage: S = SimplicialComplex([[1,2], [1,4]]); S.rename("S")
- sage: Hom(S, S, SimplicialComplexes())
+ sage: S = SimplicialComplex([[1,2], [1,4]]); S.rename("S") # optional - sage.graphs
+ sage: Hom(S, S, SimplicialComplexes()) # optional - sage.graphs
Set of Morphisms from S to S in Category of finite simplicial complexes
- sage: Hom(Set(), S, Sets())
+ sage: Hom(Set(), S, Sets()) # optional - sage.graphs
Set of Morphisms from {} to S in Category of sets
- sage: Hom(S, Set(), Sets())
+ sage: Hom(S, Set(), Sets()) # optional - sage.graphs
Set of Morphisms from S to {} in Category of sets
- sage: H = Hom(S, S, ChainComplexes(QQ))
+ sage: H = Hom(S, S, ChainComplexes(QQ)) # optional - sage.graphs
Traceback (most recent call last):
...
ValueError: S is not in Category of chain complexes over Rational Field
@@ -303,11 +321,11 @@ def Hom(X, Y, category=None, check=True):
....: def super_categories(self): return [Objects()]
....: def __contains__(self, X): return True
sage: C = PermissiveCategory(); C.rename("Permissive category")
- sage: S.category().is_subcategory(C)
+ sage: S.category().is_subcategory(C) # optional - sage.graphs
False
- sage: S in C
+ sage: S in C # optional - sage.graphs
True
- sage: Hom(S, S, C)
+ sage: Hom(S, S, C) # optional - sage.graphs
Set of Morphisms from S to S in Permissive category
With ``check=False``, uninitialized parents, as can appear upon
@@ -331,16 +349,16 @@ def Hom(X, Y, category=None, check=True):
uninitialized parent::
sage: P. = QQ['x,y']
- sage: Q = P.quotient([x^2-1,y^2-1])
- sage: q = Q.an_element()
- sage: explain_pickle(dumps(Q))
+ sage: Q = P.quotient([x^2-1, y^2-1]) # optional - sage.libs.singular
+ sage: q = Q.an_element() # optional - sage.libs.singular
+ sage: explain_pickle(dumps(Q)) # optional - sage.libs.singular
pg_...
... = pg_dynamic_class('QuotientRing_generic_with_category', (pg_QuotientRing_generic, pg_getattr(..., 'parent_class')), None, None, pg_QuotientRing_generic)
si... = unpickle_newobj(..., ())
...
si... = pg_unpickle_MPolynomialRing_libsingular(..., ('x', 'y'), ...)
si... = ... pg_Hom(si..., si..., ...) ...
- sage: Q == loads(dumps(Q))
+ sage: Q == loads(dumps(Q)) # optional - sage.libs.singular
True
Check that the ``_Hom_`` method of the ``category`` input is used::
@@ -486,21 +504,24 @@ def End(X, category=None):
EXAMPLES::
- sage: V = VectorSpace(QQ, 3)
- sage: End(V)
- Set of Morphisms (Linear Transformations) from
- Vector space of dimension 3 over Rational Field to
- Vector space of dimension 3 over Rational Field
+ sage: V = VectorSpace(QQ, 3) # optional - sage.modules
+ sage: End(V) # optional - sage.modules
+ Set of Morphisms (Linear Transformations)
+ from Vector space of dimension 3 over Rational Field
+ to Vector space of dimension 3 over Rational Field
::
- sage: G = AlternatingGroup(3)
- sage: S = End(G); S
- Set of Morphisms from Alternating group of order 3!/2 as a permutation group to Alternating group of order 3!/2 as a permutation group in Category of finite enumerated permutation groups
+ sage: G = AlternatingGroup(3) # optional - sage.groups
+ sage: S = End(G); S # optional - sage.groups
+ Set of Morphisms
+ from Alternating group of order 3!/2 as a permutation group
+ to Alternating group of order 3!/2 as a permutation group
+ in Category of finite enumerated permutation groups
sage: from sage.categories.homset import is_Endset
- sage: is_Endset(S)
+ sage: is_Endset(S) # optional - sage.groups
True
- sage: S.domain()
+ sage: S.domain() # optional - sage.groups
Alternating group of order 3!/2 as a permutation group
To avoid creating superfluous categories, a homset in a category
@@ -512,13 +533,13 @@ def End(X, category=None):
groups currently implement nothing more than unital magmas about
their homsets, we have::
- sage: G = GL(3,3)
- sage: G.category()
+ sage: G = GL(3, 3) # optional - sage.groups
+ sage: G.category() # optional - sage.groups
Category of finite groups
- sage: H = Hom(G,G)
- sage: H.homset_category()
+ sage: H = Hom(G, G) # optional - sage.groups
+ sage: H.homset_category() # optional - sage.groups
Category of finite groups
- sage: H.category()
+ sage: H.category() # optional - sage.groups
Category of endsets of unital magmas
Similarly, a ring morphism just needs to preserve addition,
@@ -557,8 +578,8 @@ class Homset(Set_generic):
EXAMPLES::
- sage: H = Hom(QQ^2, QQ^3)
- sage: loads(H.dumps()) is H
+ sage: H = Hom(QQ^2, QQ^3) # optional - sage.modules
+ sage: loads(H.dumps()) is H # optional - sage.modules
True
Homsets of unique parents are unique as well::
@@ -571,10 +592,11 @@ class Homset(Set_generic):
Conversely, homsets of non-unique parents are non-unique::
- sage: H = End(ProductProjectiveSpaces(QQ, [1, 1]))
- sage: loads(dumps(ProductProjectiveSpaces(QQ, [1, 1]))) is ProductProjectiveSpaces(QQ, [1, 1])
+ sage: P11 = ProductProjectiveSpaces(QQ, [1, 1])
+ sage: H = End(P11)
+ sage: loads(dumps(P11)) is ProductProjectiveSpaces(QQ, [1, 1])
False
- sage: loads(dumps(ProductProjectiveSpaces(QQ, [1, 1]))) == ProductProjectiveSpaces(QQ, [1, 1])
+ sage: loads(dumps(P11)) == ProductProjectiveSpaces(QQ, [1, 1])
True
sage: loads(dumps(H)) is H
False
@@ -621,12 +643,12 @@ def __init__(self, X, Y, category=None, base=None, check=True):
sage: Hom(R, R, category=Sets()).base_ring()
sage: Hom(R, R, category=Modules(QQ)).base_ring()
Rational Field
- sage: Hom(QQ^3, QQ^3, category=Modules(QQ)).base_ring()
+ sage: Hom(QQ^3, QQ^3, category=Modules(QQ)).base_ring() # optional - sage.modules
Rational Field
For whatever it's worth, the ``base`` arguments takes precedence::
- sage: MyHomset(ZZ^3, ZZ^3, base = QQ).base_ring()
+ sage: MyHomset(ZZ^3, ZZ^3, base=QQ).base_ring() # optional - sage.modules
Rational Field
"""
self._domain = X
@@ -679,8 +701,8 @@ def __reduce__(self):
EXAMPLES::
- sage: H = Hom(QQ^2, QQ^3)
- sage: H.__reduce__()
+ sage: H = Hom(QQ^2, QQ^3) # optional - sage.modules
+ sage: H.__reduce__() # optional - sage.modules
(,
(Vector space of dimension 2 over Rational Field,
Vector space of dimension 3 over Rational Field,
@@ -690,18 +712,18 @@ def __reduce__(self):
TESTS::
- sage: loads(H.dumps()) is H
+ sage: loads(H.dumps()) is H # optional - sage.modules
True
Homsets of non-unique parents are non-unique as well::
- sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]])
- sage: G is loads(dumps(G))
+ sage: G = PermutationGroup([[(1, 2, 3), (4, 5)], [(3, 4)]]) # optional - sage.groups
+ sage: G is loads(dumps(G)) # optional - sage.groups
False
- sage: H = Hom(G,G)
- sage: H is loads(dumps(H))
+ sage: H = Hom(G, G) # optional - sage.groups
+ sage: H is loads(dumps(H)) # optional - sage.groups
False
- sage: H == loads(dumps(H))
+ sage: H == loads(dumps(H)) # optional - sage.groups
True
"""
return Hom, (self._domain, self._codomain, self.__category, False)
@@ -710,7 +732,7 @@ def _repr_(self):
"""
TESTS::
- sage: Hom(ZZ^2, QQ, category=Sets())._repr_()
+ sage: Hom(ZZ^2, QQ, category=Sets())._repr_() # optional - sage.modules
'Set of Morphisms from Ambient free module of rank 2 over the principal ideal domain Integer Ring to Rational Field in Category of sets'
"""
return "Set of Morphisms from {} to {} in {}".format(self._domain,
@@ -727,10 +749,10 @@ def __hash__(self):
sage: hash(Hom(QQ, ZZ)) == hash((QQ, ZZ, QQ))
True
- sage: E = EllipticCurve('37a') # optional - sage.symbolic
- sage: H = E(0).parent(); H # optional - sage.symbolic
+ sage: E = EllipticCurve('37a') # optional - sage.symbolic
+ sage: H = E(0).parent(); H # optional - sage.symbolic
Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
- sage: hash(H) == hash((H.domain(), H.codomain(), H.base()))
+ sage: hash(H) == hash((H.domain(), H.codomain(), H.base())) # optional - sage.symbolic
True
"""
return hash((self._domain, self._codomain, self.base()))
@@ -751,8 +773,8 @@ def homset_category(self):
EXAMPLES::
- sage: H = Hom(AlternatingGroup(4), AlternatingGroup(7))
- sage: H.homset_category()
+ sage: H = Hom(AlternatingGroup(4), AlternatingGroup(7)) # optional - sage.groups
+ sage: H.homset_category() # optional - sage.groups
Category of finite enumerated permutation groups
"""
return self.__category
@@ -763,9 +785,9 @@ def _element_constructor_(self, x, check=None, **options):
EXAMPLES::
- sage: H = Hom(SymmetricGroup(4), SymmetricGroup(7))
- sage: phi = Hom(SymmetricGroup(5), SymmetricGroup(6)).natural_map()
- sage: phi
+ sage: H = Hom(SymmetricGroup(4), SymmetricGroup(7)) # optional - sage.groups
+ sage: phi = Hom(SymmetricGroup(5), SymmetricGroup(6)).natural_map() # optional - sage.groups
+ sage: phi # optional - sage.groups
Coercion morphism:
From: Symmetric group of order 5! as a permutation group
To: Symmetric group of order 6! as a permutation group
@@ -777,7 +799,7 @@ def _element_constructor_(self, x, check=None, **options):
collection, if there is a strong reference to its domain (which is the
case here)::
- sage: H(phi)
+ sage: H(phi) # optional - sage.groups
Composite map:
From: Symmetric group of order 4! as a permutation group
To: Symmetric group of order 7! as a permutation group
@@ -798,7 +820,7 @@ def _element_constructor_(self, x, check=None, **options):
Also note that making a copy of the resulting map will automatically
make strengthened copies of the composed maps::
- sage: copy(H(phi))
+ sage: copy(H(phi)) # optional - sage.groups
Composite map:
From: Symmetric group of order 4! as a permutation group
To: Symmetric group of order 7! as a permutation group
@@ -825,7 +847,7 @@ def _element_constructor_(self, x, check=None, **options):
(2, 3, 4)
sage: H = Hom(Set([1,2,3]), Set([1,2,3]))
- sage: f = H( lambda x: 4-x )
+ sage: f = H(lambda x: 4 - x)
sage: f.parent()
Set of Morphisms from {1, 2, 3} to {1, 2, 3} in Category of finite enumerated sets
sage: f(1), f(2), f(3) # todo: not implemented
@@ -884,24 +906,24 @@ def _element_constructor_(self, x, check=None, **options):
TESTS::
- sage: G. = FreeGroup()
- sage: H = Hom(G, G)
- sage: H(H.identity())
+ sage: G. = FreeGroup() # optional - sage.groups
+ sage: H = Hom(G, G) # optional - sage.groups
+ sage: H(H.identity()) # optional - sage.groups
Identity endomorphism of Free Group on generators {x, y, z}
- sage: H()
+ sage: H() # optional - sage.groups
Traceback (most recent call last):
...
TypeError: unable to convert 0 to an element of
Set of Morphisms from Free Group on generators {x, y, z}
to Free Group on generators {x, y, z} in Category of infinite groups
- sage: H("whatever")
+ sage: H("whatever") # optional - sage.groups
Traceback (most recent call last):
...
TypeError: unable to convert 'whatever' to an element of
Set of Morphisms from Free Group on generators {x, y, z}
to Free Group on generators {x, y, z} in Category of infinite groups
- sage: HH = Hom(H, H)
- sage: HH(HH.identity(), foo="bar")
+ sage: HH = Hom(H, H) # optional - sage.groups
+ sage: HH(HH.identity(), foo="bar") # optional - sage.groups
Traceback (most recent call last):
...
NotImplementedError: no keywords are implemented for
@@ -982,41 +1004,41 @@ class of ``C`` will be inherited by *all* subcategories of
this point this is the simplest one to create (gosh)::
sage: cat = Groups().Finite().Commutative()
- sage: C3 = PermutationGroup([(1,2,3)])
- sage: C3._refine_category_(cat)
- sage: C2 = PermutationGroup([(1,2)])
- sage: C2._refine_category_(cat)
- sage: H = Hom(C3, C2, cat)
- sage: H.homset_category()
+ sage: C3 = PermutationGroup([(1,2,3)]) # optional - sage.groups
+ sage: C3._refine_category_(cat) # optional - sage.groups
+ sage: C2 = PermutationGroup([(1,2)]) # optional - sage.groups
+ sage: C2._refine_category_(cat) # optional - sage.groups
+ sage: H = Hom(C3, C2, cat) # optional - sage.groups
+ sage: H.homset_category() # optional - sage.groups
Category of finite commutative groups
- sage: H.category()
+ sage: H.category() # optional - sage.groups
Category of homsets of unital magmas
- sage: cls = H._abstract_element_class; cls
+ sage: cls = H._abstract_element_class; cls # optional - sage.groups
- sage: cls.__bases__ == (H.category().element_class, H.homset_category().morphism_class)
+ sage: cls.__bases__ == (H.category().element_class, H.homset_category().morphism_class) # optional - sage.groups
True
A morphism of finite commutative semigroups is also a morphism
of semigroups, of magmas, ...; it thus inherits code from all
those categories::
- sage: issubclass(cls, Semigroups().Finite().morphism_class)
+ sage: issubclass(cls, Semigroups().Finite().morphism_class) # optional - sage.groups
True
- sage: issubclass(cls, Semigroups().morphism_class)
+ sage: issubclass(cls, Semigroups().morphism_class) # optional - sage.groups
True
- sage: issubclass(cls, Magmas().Commutative().morphism_class)
+ sage: issubclass(cls, Magmas().Commutative().morphism_class) # optional - sage.groups
True
- sage: issubclass(cls, Magmas().morphism_class)
+ sage: issubclass(cls, Magmas().morphism_class) # optional - sage.groups
True
- sage: issubclass(cls, Sets().morphism_class)
+ sage: issubclass(cls, Sets().morphism_class) # optional - sage.groups
True
Recall that FiniteMonoids() is a full subcategory of
``Monoids()``, but not of ``FiniteSemigroups()``. Thus::
- sage: issubclass(cls, Monoids().Finite().Homsets().element_class)
+ sage: issubclass(cls, Monoids().Finite().Homsets().element_class) # optional - sage.groups
True
- sage: issubclass(cls, Semigroups().Finite().Homsets().element_class)
+ sage: issubclass(cls, Semigroups().Finite().Homsets().element_class) # optional - sage.groups
False
"""
class_name = "%s._abstract_element_class"%self.__class__.__name__
@@ -1117,11 +1139,13 @@ def natural_map(self):
Coercion morphism:
From: Univariate Polynomial Ring in t over Integer Ring
To: Univariate Polynomial Ring in t over Rational Field
- sage: H = Hom(QQ['t'],GF(3)['t'])
- sage: H.natural_map()
+ sage: H = Hom(QQ['t'], GF(3)['t']) # optional - sage.rings.finite_rings
+ sage: H.natural_map() # optional - sage.rings.finite_rings
Traceback (most recent call last):
...
- TypeError: natural coercion morphism from Univariate Polynomial Ring in t over Rational Field to Univariate Polynomial Ring in t over Finite Field of size 3 not defined
+ TypeError: natural coercion morphism
+ from Univariate Polynomial Ring in t over Rational Field
+ to Univariate Polynomial Ring in t over Finite Field of size 3 not defined
"""
return morphism.FormalCoercionMorphism(self) # good default in many cases
@@ -1162,9 +1186,10 @@ def one(self):
EXAMPLES::
- sage: K = GaussianIntegers()
- sage: End(K).one()
- Identity endomorphism of Gaussian Integers in Number Field in I with defining polynomial x^2 + 1 with I = 1*I
+ sage: K = GaussianIntegers() # optional - sage.rings.number_field
+ sage: End(K).one() # optional - sage.rings.number_field
+ Identity endomorphism of Gaussian Integers in Number Field in I
+ with defining polynomial x^2 + 1 with I = 1*I
"""
return self.identity()
@@ -1205,21 +1230,21 @@ def reversed(self):
EXAMPLES::
- sage: H = Hom(ZZ^2, ZZ^3); H
+ sage: H = Hom(ZZ^2, ZZ^3); H # optional - sage.modules
Set of Morphisms from Ambient free module of rank 2 over
the principal ideal domain Integer Ring to Ambient free module
of rank 3 over the principal ideal domain Integer Ring in
Category of finite dimensional modules with basis over (euclidean
domains and infinite enumerated sets and metric spaces)
- sage: type(H)
+ sage: type(H) # optional - sage.modules
- sage: H.reversed()
+ sage: H.reversed() # optional - sage.modules
Set of Morphisms from Ambient free module of rank 3 over
the principal ideal domain Integer Ring to Ambient free module
of rank 2 over the principal ideal domain Integer Ring in
Category of finite dimensional modules with basis over (euclidean
domains and infinite enumerated sets and metric spaces)
- sage: type(H.reversed())
+ sage: type(H.reversed()) # optional - sage.modules
"""
return Hom(self.codomain(), self.domain(),
diff --git a/src/sage/categories/hopf_algebras.py b/src/sage/categories/hopf_algebras.py
index 84858c7c5bf..ecff3fd58cc 100644
--- a/src/sage/categories/hopf_algebras.py
+++ b/src/sage/categories/hopf_algebras.py
@@ -67,17 +67,18 @@ def antipode(self):
EXAMPLES::
- sage: A = HopfAlgebrasWithBasis(QQ).example(); A
- An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
- sage: [a,b] = A.algebra_generators()
- sage: a, a.antipode()
+ sage: A = HopfAlgebrasWithBasis(QQ).example(); A # optional - sage.groups
+ An example of Hopf algebra with basis: the group algebra of the
+ Dihedral group of order 6 as a permutation group over Rational Field
+ sage: [a,b] = A.algebra_generators() # optional - sage.groups
+ sage: a, a.antipode() # optional - sage.groups
(B[(1,2,3)], B[(1,3,2)])
- sage: b, b.antipode()
+ sage: b, b.antipode() # optional - sage.groups
(B[(1,3)], B[(1,3)])
TESTS::
- sage: all(x.antipode() * x == A.one() for x in A.basis())
+ sage: all(x.antipode() * x == A.one() for x in A.basis()) # optional - sage.groups
True
"""
return self.parent().antipode(self)
@@ -135,9 +136,9 @@ def antipode(self):
EXAMPLES::
- sage: A = SteenrodAlgebra(3)
- sage: a = A.an_element()
- sage: a, a.antipode()
+ sage: A = SteenrodAlgebra(3) # optional - sage.combinat sage.modules
+ sage: a = A.an_element() # optional - sage.combinat sage.modules
+ sage: a, a.antipode() # optional - sage.combinat sage.modules
(2 Q_1 Q_3 P(2,1), Q_1 Q_3 P(2,1))
"""
return self.parent().antipode(self)
@@ -204,11 +205,11 @@ def antipode_by_coercion(self, x):
EXAMPLES::
- sage: N = NonCommutativeSymmetricFunctions(QQ)
- sage: R = N.ribbon()
- sage: R.antipode_by_coercion.__module__
+ sage: N = NonCommutativeSymmetricFunctions(QQ) # optional - sage.combinat
+ sage: R = N.ribbon() # optional - sage.combinat
+ sage: R.antipode_by_coercion.__module__ # optional - sage.combinat
'sage.categories.hopf_algebras'
- sage: R.antipode_by_coercion(R[1,3,1])
+ sage: R.antipode_by_coercion(R[1,3,1]) # optional - sage.combinat
-R[2, 1, 2]
"""
R = self.realization_of().a_realization()
diff --git a/src/sage/categories/hopf_algebras_with_basis.py b/src/sage/categories/hopf_algebras_with_basis.py
index 79a0b69ce14..ea401896ca0 100644
--- a/src/sage/categories/hopf_algebras_with_basis.py
+++ b/src/sage/categories/hopf_algebras_with_basis.py
@@ -33,43 +33,44 @@ class HopfAlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
We now show how to use a simple Hopf algebra, namely the group algebra of the dihedral group
(see also AlgebrasWithBasis)::
- sage: A = C.example(); A
- An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Rational Field
- sage: A.__custom_name = "A"
- sage: A.category()
+ sage: A = C.example(); A # optional - sage.groups
+ An example of Hopf algebra with basis: the group algebra of the
+ Dihedral group of order 6 as a permutation group over Rational Field
+ sage: A.__custom_name = "A" # optional - sage.groups
+ sage: A.category() # optional - sage.groups
Category of finite dimensional hopf algebras with basis over Rational Field
- sage: A.one_basis()
+ sage: A.one_basis() # optional - sage.groups
()
- sage: A.one()
+ sage: A.one() # optional - sage.groups
B[()]
- sage: A.base_ring()
+ sage: A.base_ring() # optional - sage.groups
Rational Field
- sage: A.basis().keys()
+ sage: A.basis().keys() # optional - sage.groups
Dihedral group of order 6 as a permutation group
- sage: [a,b] = A.algebra_generators()
- sage: a, b
+ sage: [a,b] = A.algebra_generators() # optional - sage.groups
+ sage: a, b # optional - sage.groups
(B[(1,2,3)], B[(1,3)])
- sage: a^3, b^2
+ sage: a^3, b^2 # optional - sage.groups
(B[()], B[()])
- sage: a*b
+ sage: a*b # optional - sage.groups
B[(1,2)]
- sage: A.product # todo: not quite ...
+ sage: A.product # todo: not quite ... # optional - sage.groups
- sage: A.product(b,b)
+ sage: A.product(b, b) # optional - sage.groups
B[()]
- sage: A.zero().coproduct()
+ sage: A.zero().coproduct() # optional - sage.groups
0
- sage: A.zero().coproduct().parent()
+ sage: A.zero().coproduct().parent() # optional - sage.groups
A # A
- sage: a.coproduct()
+ sage: a.coproduct() # optional - sage.groups
B[(1,2,3)] # B[(1,2,3)]
- sage: TestSuite(A).run(verbose=True)
+ sage: TestSuite(A).run(verbose=True) # optional - sage.groups
running ._test_additive_associativity() . . . pass
running ._test_an_element() . . . pass
running ._test_antipode() . . . pass
@@ -100,32 +101,35 @@ class HopfAlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
running ._test_prod() . . . pass
running ._test_some_elements() . . . pass
running ._test_zero() . . . pass
- sage: A.__class__
+ sage: A.__class__ # optional - sage.groups
- sage: A.element_class
+ sage: A.element_class # optional - sage.groups
Let us look at the code for implementing A::
- sage: A?? # todo: not implemented
+ sage: A?? # todo: not implemented # optional - sage.groups
TESTS::
- sage: TestSuite(A).run()
- sage: TestSuite(C).run()
+ sage: TestSuite(A).run() # optional - sage.groups
+ sage: TestSuite(C).run() # optional - sage.groups
"""
def example(self, G=None):
"""
Returns an example of algebra with basis::
- sage: HopfAlgebrasWithBasis(QQ['x']).example()
- An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Univariate Polynomial Ring in x over Rational Field
+ sage: HopfAlgebrasWithBasis(QQ['x']).example() # optional - sage.groups
+ An example of Hopf algebra with basis: the group algebra of the
+ Dihedral group of order 6 as a permutation group
+ over Univariate Polynomial Ring in x over Rational Field
An other group can be specified as optional argument::
- sage: HopfAlgebrasWithBasis(QQ).example(SymmetricGroup(4))
- An example of Hopf algebra with basis: the group algebra of the Symmetric group of order 4! as a permutation group over Rational Field
+ sage: HopfAlgebrasWithBasis(QQ).example(SymmetricGroup(4)) # optional - sage.groups
+ An example of Hopf algebra with basis: the group algebra of the
+ Symmetric group of order 4! as a permutation group over Rational Field
"""
from sage.categories.examples.hopf_algebras_with_basis import MyGroupAlgebra
from sage.groups.perm_gps.permgroup_named import DihedralGroup
@@ -175,12 +179,12 @@ def antipode_on_basis(self, x):
EXAMPLES::
- sage: A = HopfAlgebrasWithBasis(QQ).example()
- sage: W = A.basis().keys(); W
+ sage: A = HopfAlgebrasWithBasis(QQ).example() # optional - sage.groups
+ sage: W = A.basis().keys(); W # optional - sage.groups
Dihedral group of order 6 as a permutation group
- sage: w = W.gen(0); w
+ sage: w = W.gen(0); w # optional - sage.groups
(1,2,3)
- sage: A.antipode_on_basis(w)
+ sage: A.antipode_on_basis(w) # optional - sage.groups
B[(1,3,2)]
"""
@@ -196,18 +200,19 @@ def antipode(self):
EXAMPLES::
- sage: A = HopfAlgebrasWithBasis(ZZ).example(); A
- An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Integer Ring
- sage: A = HopfAlgebrasWithBasis(QQ).example()
- sage: [a,b] = A.algebra_generators()
- sage: a, A.antipode(a)
+ sage: A = HopfAlgebrasWithBasis(ZZ).example(); A # optional - sage.groups
+ An example of Hopf algebra with basis: the group algebra of the
+ Dihedral group of order 6 as a permutation group over Integer Ring
+ sage: A = HopfAlgebrasWithBasis(QQ).example() # optional - sage.groups
+ sage: [a,b] = A.algebra_generators() # optional - sage.groups
+ sage: a, A.antipode(a) # optional - sage.groups
(B[(1,2,3)], B[(1,3,2)])
- sage: b, A.antipode(b)
+ sage: b, A.antipode(b) # optional - sage.groups
(B[(1,3)], B[(1,3)])
TESTS::
- sage: all(A.antipode(x) * x == A.one() for x in A.basis())
+ sage: all(A.antipode(x) * x == A.one() for x in A.basis()) # optional - sage.groups
True
"""
if self.antipode_on_basis is not NotImplemented:
@@ -239,13 +244,13 @@ def _test_antipode(self, **options):
TESTS::
- sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon()
- sage: R._test_antipode()
+ sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon() # optional - sage.combinat
+ sage: R._test_antipode() # optional - sage.combinat
::
- sage: s = SymmetricFunctions(QQ).schur()
- sage: s._test_antipode()
+ sage: s = SymmetricFunctions(QQ).schur() # optional - sage.combinat
+ sage: s._test_antipode() # optional - sage.combinat
"""
tester = self._tester(**options)
diff --git a/src/sage/categories/integral_domains.py b/src/sage/categories/integral_domains.py
index 2d5d7730693..ca910a16e60 100644
--- a/src/sage/categories/integral_domains.py
+++ b/src/sage/categories/integral_domains.py
@@ -45,7 +45,7 @@ def __contains__(self, x):
"""
EXAMPLES::
- sage: GF(4, "a") in IntegralDomains()
+ sage: GF(4, "a") in IntegralDomains() # optional - sage.rings.finite_rings
True
sage: QQ in IntegralDomains()
True
@@ -108,10 +108,10 @@ def is_integral_domain(self, proof=True):
sage: Parent(QQ, category=IntegralDomains()).is_integral_domain()
True
- sage: L. = LazyLaurentSeriesRing(QQ)
- sage: L.is_integral_domain()
+ sage: L. = LazyLaurentSeriesRing(QQ) # optional - sage.combinat
+ sage: L.is_integral_domain() # optional - sage.combinat
True
- sage: L.is_integral_domain(proof=True)
+ sage: L.is_integral_domain(proof=True) # optional - sage.combinat
True
"""
return True
@@ -129,7 +129,7 @@ def _test_fraction_field(self, **options):
tester = self._tester(**options)
try:
fraction_field = self.fraction_field()
- except AttributeError:
+ except (AttributeError, ImportError):
# some integral domains do not implement fraction_field() yet
if self in Fields():
raise
diff --git a/src/sage/categories/kac_moody_algebras.py b/src/sage/categories/kac_moody_algebras.py
index cd7af55333d..040387a3325 100644
--- a/src/sage/categories/kac_moody_algebras.py
+++ b/src/sage/categories/kac_moody_algebras.py
@@ -43,12 +43,12 @@ def example(self, n=2):
EXAMPLES::
sage: from sage.categories.kac_moody_algebras import KacMoodyAlgebras
- sage: KacMoodyAlgebras(QQ).example()
+ sage: KacMoodyAlgebras(QQ).example() # optional - sage.combinat sage.modules
Lie algebra of ['A', 2] in the Chevalley basis
We can specify the rank of the example::
- sage: KacMoodyAlgebras(QQ).example(4)
+ sage: KacMoodyAlgebras(QQ).example(4) # optional - sage.combinat sage.modules
Lie algebra of ['A', 4] in the Chevalley basis
"""
from sage.algebras.lie_algebras.classical_lie_algebra import LieAlgebraChevalleyBasis
@@ -61,8 +61,8 @@ def cartan_type(self):
EXAMPLES::
- sage: L = LieAlgebra(QQ, cartan_type=['A', 2])
- sage: L.cartan_type()
+ sage: L = LieAlgebra(QQ, cartan_type=['A', 2]) # optional - sage.combinat sage.modules
+ sage: L.cartan_type() # optional - sage.combinat sage.modules
['A', 2]
"""
return self._cartan_type
@@ -73,8 +73,8 @@ def weyl_group(self):
EXAMPLES::
- sage: L = LieAlgebra(QQ, cartan_type=['A', 2])
- sage: L.weyl_group()
+ sage: L = LieAlgebra(QQ, cartan_type=['A', 2]) # optional - sage.combinat sage.modules
+ sage: L.weyl_group() # optional - sage.combinat sage.modules
Weyl Group of type ['A', 2] (as a matrix group acting on the ambient space)
"""
from sage.combinat.root_system.weyl_group import WeylGroup
diff --git a/src/sage/categories/lambda_bracket_algebras.py b/src/sage/categories/lambda_bracket_algebras.py
index 531cfb826b1..8818c0a918a 100644
--- a/src/sage/categories/lambda_bracket_algebras.py
+++ b/src/sage/categories/lambda_bracket_algebras.py
@@ -45,9 +45,10 @@ def __classcall_private__(cls, R, check=True):
EXAMPLES::
- sage: LieConformalAlgebras(QuaternionAlgebra(2))
+ sage: LieConformalAlgebras(QuaternionAlgebra(2)) # optional - sage.combinat sage.modules
Traceback (most recent call last):
- ValueError: base must be a commutative ring got Quaternion Algebra (-1, -1) with base ring Rational Field
+ ValueError: base must be a commutative ring
+ got Quaternion Algebra (-1, -1) with base ring Rational Field
sage: LieConformalAlgebras(ZZ)
Category of Lie conformal algebras over Integer Ring
"""
@@ -117,8 +118,8 @@ def ideal(self, *gens, **kwds):
EXAMPLES::
- sage: Vir = lie_conformal_algebras.Virasoro(QQ)
- sage: Vir.ideal()
+ sage: Vir = lie_conformal_algebras.Virasoro(QQ) # optional - sage.combinat sage.modules
+ sage: Vir.ideal() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
NotImplementedError: ideals of Lie Conformal algebras are not implemented yet
@@ -136,21 +137,21 @@ def bracket(self, rhs):
The brackets of the Virasoro Lie conformal algebra::
- sage: Vir = lie_conformal_algebras.Virasoro(QQ); L = Vir.0
- sage: L.bracket(L)
+ sage: Vir = lie_conformal_algebras.Virasoro(QQ); L = Vir.0 # optional - sage.combinat sage.modules
+ sage: L.bracket(L) # optional - sage.combinat sage.modules
{0: TL, 1: 2*L, 3: 1/2*C}
- sage: L.bracket(L.T())
+ sage: L.bracket(L.T()) # optional - sage.combinat sage.modules
{0: 2*T^(2)L, 1: 3*TL, 2: 4*L, 4: 2*C}
Now with a current algebra::
- sage: V = lie_conformal_algebras.Affine(QQ, 'A1')
- sage: V.gens()
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A1') # optional - sage.combinat sage.modules
+ sage: V.gens() # optional - sage.combinat sage.modules
(B[alpha[1]], B[alphacheck[1]], B[-alpha[1]], B['K'])
- sage: E = V.0; H = V.1; F = V.2;
- sage: H.bracket(H)
+ sage: E = V.0; H = V.1; F = V.2 # optional - sage.combinat sage.modules
+ sage: H.bracket(H) # optional - sage.combinat sage.modules
{1: 2*B['K']}
- sage: E.bracket(F)
+ sage: E.bracket(F) # optional - sage.combinat sage.modules
{0: B[alphacheck[1]], 1: B['K']}
"""
return self._bracket_(rhs)
@@ -169,21 +170,21 @@ def _bracket_(self, rhs):
The brackets of the Virasoro Lie conformal Algebra::
- sage: Vir = lie_conformal_algebras.Virasoro(QQ); L = Vir.0
- sage: L._bracket_(L)
+ sage: Vir = lie_conformal_algebras.Virasoro(QQ); L = Vir.0 # optional - sage.combinat sage.modules
+ sage: L._bracket_(L) # optional - sage.combinat sage.modules
{0: TL, 1: 2*L, 3: 1/2*C}
- sage: L._bracket_(L.T())
+ sage: L._bracket_(L.T()) # optional - sage.combinat sage.modules
{0: 2*T^(2)L, 1: 3*TL, 2: 4*L, 4: 2*C}
Now with a current algebra::
- sage: V = lie_conformal_algebras.Affine(QQ, 'A1')
- sage: V.gens()
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A1') # optional - sage.combinat sage.modules
+ sage: V.gens() # optional - sage.combinat sage.modules
(B[alpha[1]], B[alphacheck[1]], B[-alpha[1]], B['K'])
- sage: E = V.0; H = V.1; F = V.2;
- sage: H._bracket_(H)
+ sage: E = V.0; H = V.1; F = V.2 # optional - sage.combinat sage.modules
+ sage: H._bracket_(H) # optional - sage.combinat sage.modules
{1: 2*B['K']}
- sage: E._bracket_(F)
+ sage: E._bracket_(F) # optional - sage.combinat sage.modules
{0: B[alphacheck[1]], 1: B['K']}
"""
@@ -194,16 +195,16 @@ def nproduct(self, rhs, n):
EXAMPLES::
- sage: Vir = lie_conformal_algebras.Virasoro(QQ); L = Vir.0
- sage: L.nproduct(L, 3)
+ sage: Vir = lie_conformal_algebras.Virasoro(QQ); L = Vir.0 # optional - sage.combinat sage.modules
+ sage: L.nproduct(L, 3) # optional - sage.combinat sage.modules
1/2*C
- sage: L.nproduct(L.T(), 0)
+ sage: L.nproduct(L.T(), 0) # optional - sage.combinat sage.modules
2*T^(2)L
- sage: V = lie_conformal_algebras.Affine(QQ, 'A1')
- sage: E = V.0; H = V.1; F = V.2;
- sage: E.nproduct(H, 0) == - 2*E
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A1') # optional - sage.combinat sage.modules
+ sage: E = V.0; H = V.1; F = V.2 # optional - sage.combinat sage.modules
+ sage: E.nproduct(H, 0) == - 2*E # optional - sage.combinat sage.modules
True
- sage: E.nproduct(F, 1)
+ sage: E.nproduct(F, 1) # optional - sage.combinat sage.modules
B['K']
"""
return self._nproduct_(rhs,n)
@@ -219,16 +220,16 @@ def _nproduct_(self, rhs, n):
EXAMPLES::
- sage: Vir = lie_conformal_algebras.Virasoro(QQ); L = Vir.0
- sage: L._nproduct_(L,3)
+ sage: Vir = lie_conformal_algebras.Virasoro(QQ); L = Vir.0 # optional - sage.combinat sage.modules
+ sage: L._nproduct_(L, 3) # optional - sage.combinat sage.modules
1/2*C
- sage: L._nproduct_(L.T(),0)
+ sage: L._nproduct_(L.T(), 0) # optional - sage.combinat sage.modules
2*T^(2)L
- sage: V = lie_conformal_algebras.Affine(QQ, 'A1')
- sage: E = V.0; H = V.1; F = V.2;
- sage: E._nproduct_(H,0) == - 2*E
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A1') # optional - sage.combinat sage.modules
+ sage: E = V.0; H = V.1; F = V.2 # optional - sage.combinat sage.modules
+ sage: E._nproduct_(H, 0) == - 2*E # optional - sage.combinat sage.modules
True
- sage: E._nproduct_(F,1)
+ sage: E._nproduct_(F, 1) # optional - sage.combinat sage.modules
B['K']
"""
if n >= 0:
@@ -253,14 +254,14 @@ def T(self, n=1):
EXAMPLES::
- sage: Vir = lie_conformal_algebras.Virasoro(QQ)
- sage: Vir.inject_variables()
+ sage: Vir = lie_conformal_algebras.Virasoro(QQ) # optional - sage.combinat sage.modules
+ sage: Vir.inject_variables() # optional - sage.combinat sage.modules
Defining L, C
- sage: L.T()
+ sage: L.T() # optional - sage.combinat sage.modules
TL
- sage: L.T(3)
+ sage: L.T(3) # optional - sage.combinat sage.modules
6*T^(3)L
- sage: C.T()
+ sage: C.T() # optional - sage.combinat sage.modules
0
"""
diff --git a/src/sage/categories/lambda_bracket_algebras_with_basis.py b/src/sage/categories/lambda_bracket_algebras_with_basis.py
index 9b48ba34615..bb0e30908b4 100644
--- a/src/sage/categories/lambda_bracket_algebras_with_basis.py
+++ b/src/sage/categories/lambda_bracket_algebras_with_basis.py
@@ -25,7 +25,7 @@ class LambdaBracketAlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).WithBasis()
+ sage: LieConformalAlgebras(QQbar).WithBasis() # optional - sage.rings.number_field
Category of Lie conformal algebras with basis over Algebraic Field
"""
class ElementMethods:
@@ -36,14 +36,14 @@ def index(self):
EXAMPLES::
- sage: V = lie_conformal_algebras.NeveuSchwarz(QQ)
- sage: V.inject_variables()
+ sage: V = lie_conformal_algebras.NeveuSchwarz(QQ) # optional - sage.combinat sage.modules
+ sage: V.inject_variables() # optional - sage.combinat sage.modules
Defining L, G, C
- sage: G.T(3).index()
+ sage: G.T(3).index() # optional - sage.combinat sage.modules
('G', 3)
- sage: v = V.an_element(); v
+ sage: v = V.an_element(); v # optional - sage.combinat sage.modules
L + G + C
- sage: v.index()
+ sage: v.index() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
ValueError: index can only be computed for monomials, got L + G + C
@@ -63,10 +63,14 @@ class FinitelyGeneratedAsLambdaBracketAlgebra(CategoryWithAxiom_over_base_ring):
EXAMPLES::
- sage: C = LieConformalAlgebras(QQbar)
- sage: C.WithBasis().FinitelyGenerated()
- Category of finitely generated Lie conformal algebras with basis over Algebraic Field
- sage: C.WithBasis().FinitelyGenerated() is C.FinitelyGenerated().WithBasis()
+ sage: C = LieConformalAlgebras(QQbar) # optional - sage.rings.number_field
+ sage: C1 = C.WithBasis().FinitelyGenerated(); C1 # optional - sage.rings.number_field
+ Category of finitely generated Lie conformal algebras with basis
+ over Algebraic Field
+ sage: C2 = C.FinitelyGenerated().WithBasis(); C2 # optional - sage.rings.number_field
+ Category of finitely generated Lie conformal algebras with basis
+ over Algebraic Field
+ sage: C1 is C2 # optional - sage.rings.number_field
True
"""
class Graded(GradedModulesCategory):
@@ -76,8 +80,10 @@ class Graded(GradedModulesCategory):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded()
- Category of H-graded finitely generated Lie conformal algebras with basis over Algebraic Field
+ sage: C = LieConformalAlgebras(QQbar) # optional - sage.rings.number_field
+ sage: C.WithBasis().FinitelyGenerated().Graded() # optional - sage.rings.number_field
+ Category of H-graded finitely generated Lie conformal algebras
+ with basis over Algebraic Field
"""
class ParentMethods:
@@ -88,8 +94,8 @@ def degree_on_basis(self, m):
EXAMPLES::
- sage: V = lie_conformal_algebras.Virasoro(QQ)
- sage: V.degree_on_basis(('L',2))
+ sage: V = lie_conformal_algebras.Virasoro(QQ) # optional - sage.combinat sage.modules
+ sage: V.degree_on_basis(('L', 2)) # optional - sage.combinat sage.modules
4
"""
if m[0] in self._central_elements:
diff --git a/src/sage/categories/lattice_posets.py b/src/sage/categories/lattice_posets.py
index d29635f078e..3872ca9b51f 100644
--- a/src/sage/categories/lattice_posets.py
+++ b/src/sage/categories/lattice_posets.py
@@ -66,8 +66,8 @@ def meet(self, x, y):
EXAMPLES::
- sage: D = LatticePoset((divisors(30), attrcall("divides")))
- sage: D.meet( D(6), D(15) )
+ sage: D = LatticePoset((divisors(30), attrcall("divides"))) # optional - sage.combinat
+ sage: D.meet( D(6), D(15) ) # optional - sage.combinat
3
"""
@@ -82,7 +82,7 @@ def join(self, x, y):
EXAMPLES::
- sage: D = LatticePoset((divisors(60), attrcall("divides")))
- sage: D.join( D(6), D(10) )
+ sage: D = LatticePoset((divisors(60), attrcall("divides"))) # optional - sage.combinat
+ sage: D.join( D(6), D(10) ) # optional - sage.combinat
30
"""
diff --git a/src/sage/categories/lie_algebras.py b/src/sage/categories/lie_algebras.py
index 269ca3dabbe..04597de0308 100644
--- a/src/sage/categories/lie_algebras.py
+++ b/src/sage/categories/lie_algebras.py
@@ -45,24 +45,24 @@ class LieAlgebras(Category_over_base_ring):
We construct a typical parent in this category, and do some
computations with it::
- sage: A = C.example(); A
+ sage: A = C.example(); A # optional - sage.groups sage.modules
An example of a Lie algebra: the Lie algebra from the associative
algebra Symmetric group algebra of order 3 over Rational Field
generated by ([2, 1, 3], [2, 3, 1])
- sage: A.category()
+ sage: A.category() # optional - sage.groups sage.modules
Category of Lie algebras over Rational Field
- sage: A.base_ring()
+ sage: A.base_ring() # optional - sage.groups sage.modules
Rational Field
- sage: a,b = A.lie_algebra_generators()
- sage: a.bracket(b)
+ sage: a, b = A.lie_algebra_generators() # optional - sage.groups sage.modules
+ sage: a.bracket(b) # optional - sage.groups sage.modules
-[1, 3, 2] + [3, 2, 1]
- sage: b.bracket(2*a + b)
+ sage: b.bracket(2*a + b) # optional - sage.groups sage.modules
2*[1, 3, 2] - 2*[3, 2, 1]
- sage: A.bracket(a, b)
+ sage: A.bracket(a, b) # optional - sage.groups sage.modules
-[1, 3, 2] + [3, 2, 1]
Please see the source code of `A` (with ``A??``) for how to
@@ -70,9 +70,9 @@ class LieAlgebras(Category_over_base_ring):
TESTS::
- sage: C = LieAlgebras(QQ)
- sage: TestSuite(C).run()
- sage: TestSuite(C.example()).run()
+ sage: C = LieAlgebras(QQ) # optional - sage.combinat sage.modules
+ sage: TestSuite(C).run() # optional - sage.combinat sage.modules
+ sage: TestSuite(C.example()).run() # optional - sage.combinat sage.modules
.. TODO::
@@ -151,15 +151,15 @@ def example(self, gens=None):
EXAMPLES::
- sage: LieAlgebras(QQ).example()
+ sage: LieAlgebras(QQ).example() # optional - sage.groups sage.modules
An example of a Lie algebra: the Lie algebra from the associative algebra
Symmetric group algebra of order 3 over Rational Field
generated by ([2, 1, 3], [2, 3, 1])
Another set of generators can be specified as an optional argument::
- sage: F. = FreeAlgebra(QQ)
- sage: LieAlgebras(QQ).example(F.gens())
+ sage: F. = FreeAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: LieAlgebras(QQ).example(F.gens()) # optional - sage.combinat sage.modules
An example of a Lie algebra: the Lie algebra from the associative algebra
Free Algebra on 3 generators (x, y, z) over Rational Field
generated by (x, y, z)
@@ -189,11 +189,14 @@ def extra_super_categories(self):
[Category of finite sets]
sage: LieAlgebras(ZZ).FiniteDimensional().extra_super_categories()
[]
- sage: LieAlgebras(GF(5)).FiniteDimensional().is_subcategory(Sets().Finite())
+ sage: C = LieAlgebras(GF(5)).FiniteDimensional() # optional - sage.rings.finite_rings
+ sage: C.is_subcategory(Sets().Finite()) # optional - sage.rings.finite_rings
True
- sage: LieAlgebras(ZZ).FiniteDimensional().is_subcategory(Sets().Finite())
+ sage: C = LieAlgebras(ZZ).FiniteDimensional()
+ sage: C.is_subcategory(Sets().Finite())
False
- sage: LieAlgebras(GF(5)).WithBasis().FiniteDimensional().is_subcategory(Sets().Finite())
+ sage: C = LieAlgebras(GF(5)).WithBasis().FiniteDimensional() # optional - sage.rings.finite_rings
+ sage: C.is_subcategory(Sets().Finite()) # optional - sage.rings.finite_rings
True
"""
if self.base_ring() in Sets().Finite():
@@ -206,8 +209,8 @@ class Nilpotent(CategoryWithAxiom_over_base_ring):
TESTS::
- sage: C = LieAlgebras(QQ).Nilpotent()
- sage: TestSuite(C).run()
+ sage: C = LieAlgebras(QQ).Nilpotent() # optional - sage.combinat sage.modules
+ sage: TestSuite(C).run() # optional - sage.combinat sage.modules
"""
class ParentMethods:
@abstract_method
@@ -217,8 +220,8 @@ def step(self):
EXAMPLES::
- sage: h = lie_algebras.Heisenberg(ZZ, oo)
- sage: h.step()
+ sage: h = lie_algebras.Heisenberg(ZZ, oo) # optional - sage.combinat sage.modules
+ sage: h.step() # optional - sage.combinat sage.modules
2
"""
@@ -228,8 +231,8 @@ def is_nilpotent(self):
EXAMPLES::
- sage: h = lie_algebras.Heisenberg(ZZ, oo)
- sage: h.is_nilpotent()
+ sage: h = lie_algebras.Heisenberg(ZZ, oo) # optional - sage.combinat sage.modules
+ sage: h.is_nilpotent() # optional - sage.combinat sage.modules
True
"""
return True
@@ -254,30 +257,30 @@ def bracket(self, lhs, rhs):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: L.bracket(x, x + y)
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L.bracket(x, x + y) # optional - sage.combinat sage.modules
-[1, 3, 2] + [3, 2, 1]
- sage: L.bracket(x, 0)
+ sage: L.bracket(x, 0) # optional - sage.combinat sage.modules
0
- sage: L.bracket(0, x)
+ sage: L.bracket(0, x) # optional - sage.combinat sage.modules
0
Constructing the product space::
- sage: L = lie_algebras.Heisenberg(QQ, 1)
- sage: Z = L.bracket(L, L); Z
+ sage: L = lie_algebras.Heisenberg(QQ, 1) # optional - sage.combinat sage.modules
+ sage: Z = L.bracket(L, L); Z # optional - sage.combinat sage.modules
Ideal (z) of Heisenberg algebra of rank 1 over Rational Field
- sage: L.bracket(L, Z)
+ sage: L.bracket(L, Z) # optional - sage.combinat sage.modules
Ideal () of Heisenberg algebra of rank 1 over Rational Field
Constructing ideals::
- sage: p,q,z = L.basis(); (p,q,z)
+ sage: p, q, z = L.basis(); p, q, z # optional - sage.combinat sage.modules
(p1, q1, z)
- sage: L.bracket(3*p, L)
+ sage: L.bracket(3*p, L) # optional - sage.combinat sage.modules
Ideal (3*p1) of Heisenberg algebra of rank 1 over Rational Field
- sage: L.bracket(L, q+p)
+ sage: L.bracket(L, q + p) # optional - sage.combinat sage.modules
Ideal (p1 + q1) of Heisenberg algebra of rank 1 over Rational Field
"""
if lhs in LieAlgebras:
@@ -297,15 +300,15 @@ def universal_enveloping_algebra(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.universal_enveloping_algebra()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.universal_enveloping_algebra() # optional - sage.combinat sage.modules
Noncommutative Multivariate Polynomial Ring in b0, b1, b2
over Rational Field, nc-relations: {}
::
- sage: L = LieAlgebra(QQ, 3, 'x', abelian=True)
- sage: L.universal_enveloping_algebra()
+ sage: L = LieAlgebra(QQ, 3, 'x', abelian=True) # optional - sage.combinat sage.modules
+ sage: L.universal_enveloping_algebra() # optional - sage.combinat sage.modules
Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
.. SEEALSO::
@@ -330,15 +333,15 @@ def _construct_UEA(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L._construct_UEA()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L._construct_UEA() # optional - sage.combinat sage.modules
Noncommutative Multivariate Polynomial Ring in b0, b1, b2
over Rational Field, nc-relations: {}
::
- sage: L = LieAlgebra(QQ, 3, 'x', abelian=True)
- sage: L.universal_enveloping_algebra() # indirect doctest
+ sage: L = LieAlgebra(QQ, 3, 'x', abelian=True) # optional - sage.combinat sage.modules
+ sage: L.universal_enveloping_algebra() # indirect doctest # optional - sage.combinat sage.modules
Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
"""
@@ -394,8 +397,8 @@ def module(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.module()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.module() # optional - sage.combinat sage.modules
Vector space of dimension 3 over Rational Field
"""
@@ -410,10 +413,10 @@ def from_vector(self, v, order=None, coerce=False):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: u = L.from_vector(vector(QQ, (1, 0, 0))); u
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: u = L.from_vector(vector(QQ, (1, 0, 0))); u # optional - sage.combinat sage.modules
(1, 0, 0)
- sage: parent(u) is L
+ sage: parent(u) is L # optional - sage.combinat sage.modules
True
"""
@@ -430,11 +433,11 @@ def lift(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: lifted = L.lift(2*a + b - c); lifted
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: lifted = L.lift(2*a + b - c); lifted # optional - sage.combinat sage.modules
2*b0 + b1 - b2
- sage: lifted.parent() is L.universal_enveloping_algebra()
+ sage: lifted.parent() is L.universal_enveloping_algebra() # optional - sage.combinat sage.modules
True
"""
M = LiftMorphism(self, self._construct_UEA())
@@ -447,9 +450,9 @@ def subalgebra(self, gens, names=None, index_set=None, category=None):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: L.subalgebra([2*a - c, b + c])
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L.subalgebra([2*a - c, b + c]) # optional - sage.combinat sage.modules
An example of a finite dimensional Lie algebra with basis:
the 2-dimensional abelian Lie algebra over Rational Field
with basis matrix:
@@ -458,9 +461,9 @@ def subalgebra(self, gens, names=None, index_set=None, category=None):
::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: L.subalgebra([x + y])
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: x,y = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L.subalgebra([x + y]) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
NotImplementedError: subalgebras not yet implemented: see #17416
@@ -475,9 +478,9 @@ def ideal(self, *gens, **kwds):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: L.ideal([2*a - c, b + c])
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L.ideal([2*a - c, b + c]) # optional - sage.combinat sage.modules
An example of a finite dimensional Lie algebra with basis:
the 2-dimensional abelian Lie algebra over Rational Field
with basis matrix:
@@ -486,9 +489,9 @@ def ideal(self, *gens, **kwds):
::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: L.ideal([x + y])
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: x, y = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L.ideal([x + y]) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
NotImplementedError: ideals not yet implemented: see #16824
@@ -508,8 +511,8 @@ def is_ideal(self, A):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: L.is_ideal(L)
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: L.is_ideal(L) # optional - sage.combinat sage.modules
True
"""
if A == self:
@@ -525,9 +528,9 @@ def killing_form(self, x, y):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: L.killing_form(a, b+c)
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L.killing_form(a, b + c) # optional - sage.combinat sage.modules
0
"""
@@ -540,21 +543,21 @@ def is_abelian(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: L.is_abelian()
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: L.is_abelian() # optional - sage.combinat sage.modules
False
- sage: R = QQ['x,y']
- sage: L = LieAlgebras(QQ).example(R.gens())
- sage: L.is_abelian()
+ sage: R = QQ['x,y'] # optional - sage.combinat sage.modules
+ sage: L = LieAlgebras(QQ).example(R.gens()) # optional - sage.combinat sage.modules
+ sage: L.is_abelian() # optional - sage.combinat sage.modules
True
::
- sage: L. = LieAlgebra(QQ,1) # todo: not implemented - #16823
- sage: L.is_abelian() # todo: not implemented - #16823
+ sage: L. = LieAlgebra(QQ, 1) # todo: not implemented - #16823 # optional - sage.combinat sage.modules
+ sage: L.is_abelian() # todo: not implemented - #16823 # optional - sage.combinat sage.modules
True
- sage: L. = LieAlgebra(QQ,2) # todo: not implemented - #16823
- sage: L.is_abelian() # todo: not implemented - #16823
+ sage: L. = LieAlgebra(QQ, 2) # todo: not implemented - #16823 # optional - sage.combinat sage.modules
+ sage: L.is_abelian() # todo: not implemented - #16823 # optional - sage.combinat sage.modules
False
"""
G = self.lie_algebra_generators()
@@ -570,14 +573,14 @@ def is_commutative(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: L.is_commutative()
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: L.is_commutative() # optional - sage.combinat sage.modules
False
::
- sage: L. = LieAlgebra(QQ, 1) # todo: not implemented - #16823
- sage: L.is_commutative() # todo: not implemented - #16823
+ sage: L. = LieAlgebra(QQ, 1) # todo: not implemented - #16823 # optional - sage.combinat sage.modules
+ sage: L.is_commutative() # todo: not implemented - #16823 # optional - sage.combinat sage.modules
True
"""
return self.is_abelian()
@@ -589,8 +592,8 @@ def is_solvable(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.is_solvable()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.is_solvable() # optional - sage.combinat sage.modules
True
"""
@@ -601,8 +604,8 @@ def is_nilpotent(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.is_nilpotent()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: L.is_nilpotent() # optional - sage.combinat sage.modules
True
"""
@@ -627,37 +630,40 @@ def bch(self, X, Y, prec=None):
The BCH formula for the generators of a free nilpotent Lie
algebra of step 4::
- sage: L = LieAlgebra(QQ, 2, step=4)
- sage: L.inject_variables()
+ sage: L = LieAlgebra(QQ, 2, step=4) # optional - sage.combinat sage.modules
+ sage: L.inject_variables() # optional - sage.combinat sage.modules
Defining X_1, X_2, X_12, X_112, X_122, X_1112, X_1122, X_1222
- sage: L.bch(X_1, X_2)
+ sage: L.bch(X_1, X_2) # optional - sage.combinat sage.modules
X_1 + X_2 + 1/2*X_12 + 1/12*X_112 + 1/12*X_122 + 1/24*X_1122
An example of the BCH formula in a quotient::
- sage: Q = L.quotient(X_112 + X_122)
- sage: x, y = Q.basis().list()[:2]
- sage: Q.bch(x, y)
+ sage: Q = L.quotient(X_112 + X_122) # optional - sage.combinat sage.modules
+ sage: x, y = Q.basis().list()[:2] # optional - sage.combinat sage.modules
+ sage: Q.bch(x, y) # optional - sage.combinat sage.modules
X_1 + X_2 + 1/2*X_12 - 1/24*X_1112
The BCH formula for a non-nilpotent Lie algebra requires the
precision to be explicitly stated::
- sage: L. = LieAlgebra(QQ)
- sage: L.bch(X, Y)
+ sage: L. = LieAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: L.bch(X, Y) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
- ValueError: the Lie algebra is not known to be nilpotent, so you must specify the precision
- sage: L.bch(X, Y, 4)
- X + 1/12*[X, [X, Y]] + 1/24*[X, [[X, Y], Y]] + 1/2*[X, Y] + 1/12*[[X, Y], Y] + Y
+ ValueError: the Lie algebra is not known to be nilpotent,
+ so you must specify the precision
+ sage: L.bch(X, Y, 4) # optional - sage.combinat sage.modules
+ X + 1/12*[X, [X, Y]] + 1/24*[X, [[X, Y], Y]]
+ + 1/2*[X, Y] + 1/12*[[X, Y], Y] + Y
The BCH formula requires a coercion from the rationals::
- sage: L. = LieAlgebra(ZZ, 2, step=2)
- sage: L.bch(X, Y)
+ sage: L. = LieAlgebra(ZZ, 2, step=2) # optional - sage.combinat sage.modules
+ sage: L.bch(X, Y) # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
- TypeError: the BCH formula is not well defined since Integer Ring has no coercion from Rational Field
+ TypeError: the BCH formula is not well defined
+ since Integer Ring has no coercion from Rational Field
"""
if self not in LieAlgebras.Nilpotent and prec is None:
raise ValueError("the Lie algebra is not known to be nilpotent,"
@@ -682,8 +688,8 @@ def lie_group(self, name='G', **kwds):
EXAMPLES::
- sage: L = lie_algebras.Heisenberg(QQ, 1)
- sage: G = L.lie_group('G'); G # optional - sage.symbolic
+ sage: L = lie_algebras.Heisenberg(QQ, 1) # optional - sage.combinat sage.modules
+ sage: G = L.lie_group('G'); G # optional - sage.combinat sage.modules sage.symbolic
Lie group G of Heisenberg algebra of rank 1 over Rational Field
"""
@@ -701,15 +707,15 @@ def _test_jacobi_identity(self, **options):
By default, this method runs the tests only on the
elements returned by ``self.some_elements()``::
- sage: L = LieAlgebras(QQ).example()
- sage: L._test_jacobi_identity()
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: L._test_jacobi_identity() # optional - sage.combinat sage.modules
However, the elements tested can be customized with the
``elements`` keyword argument::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: L._test_jacobi_identity(elements=[x+y, x, 2*y, x.bracket(y)])
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: x,y = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L._test_jacobi_identity(elements=[x + y, x, 2*y, x.bracket(y)]) # optional - sage.combinat sage.modules
See the documentation for :class:`TestSuite` for more information.
"""
@@ -740,15 +746,15 @@ def _test_antisymmetry(self, **options):
By default, this method runs the tests only on the
elements returned by ``self.some_elements()``::
- sage: L = LieAlgebras(QQ).example()
- sage: L._test_antisymmetry()
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: L._test_antisymmetry() # optional - sage.combinat sage.modules
However, the elements tested can be customized with the
``elements`` keyword argument::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: L._test_antisymmetry(elements=[x+y, x, 2*y, x.bracket(y)])
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: x,y = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L._test_antisymmetry(elements=[x + y, x, 2*y, x.bracket(y)]) # optional - sage.combinat sage.modules
See the documentation for :class:`TestSuite` for more information.
"""
@@ -769,27 +775,27 @@ def _test_distributivity(self, **options):
TESTS::
- sage: L = LieAlgebras(QQ).example()
- sage: L._test_distributivity()
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: L._test_distributivity() # optional - sage.combinat sage.modules
EXAMPLES:
By default, this method runs the tests only on the
elements returned by ``self.some_elements()``::
- sage: L = LieAlgebra(QQ, 3, 'x,y,z', representation="polynomial")
- sage: L.some_elements()
+ sage: L = LieAlgebra(QQ, 3, 'x,y,z', representation="polynomial") # optional - sage.combinat sage.modules
+ sage: L.some_elements() # optional - sage.combinat sage.modules
[x + y + z]
- sage: L._test_distributivity()
+ sage: L._test_distributivity() # optional - sage.combinat sage.modules
However, the elements tested can be customized with the
``elements`` keyword argument::
- sage: L = LieAlgebra(QQ, cartan_type=['A', 2]) # todo: not implemented - #16821
- sage: h1 = L.gen(0) # todo: not implemented - #16821
- sage: h2 = L.gen(1) # todo: not implemented - #16821
- sage: e2 = L.gen(3) # todo: not implemented - #16821
- sage: L._test_distributivity(elements=[h1, h2, e2]) # todo: not implemented - #16821
+ sage: L = LieAlgebra(QQ, cartan_type=['A', 2]) # todo: not implemented - #16821 # optional - sage.combinat sage.modules
+ sage: h1 = L.gen(0) # todo: not implemented - #16821 # optional - sage.combinat sage.modules
+ sage: h2 = L.gen(1) # todo: not implemented - #16821 # optional - sage.combinat sage.modules
+ sage: e2 = L.gen(3) # todo: not implemented - #16821 # optional - sage.combinat sage.modules
+ sage: L._test_distributivity(elements=[h1, h2, e2]) # todo: not implemented - #16821 # optional - sage.combinat sage.modules
See the documentation for :class:`TestSuite` for more information.
"""
@@ -812,11 +818,11 @@ def bracket(self, rhs):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: x.bracket(y)
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: x,y = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: x.bracket(y) # optional - sage.combinat sage.modules
-[1, 3, 2] + [3, 2, 1]
- sage: x.bracket(0)
+ sage: x.bracket(0) # optional - sage.combinat sage.modules
0
"""
return self._bracket_(rhs)
@@ -831,13 +837,13 @@ def _bracket_(self, y):
EXAMPLES::
- sage: L = LieAlgebras(QQ).example()
- sage: x,y = L.lie_algebra_generators()
- sage: x._bracket_(y)
+ sage: L = LieAlgebras(QQ).example() # optional - sage.combinat sage.modules
+ sage: x,y = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: x._bracket_(y) # optional - sage.combinat sage.modules
-[1, 3, 2] + [3, 2, 1]
- sage: y._bracket_(x)
+ sage: y._bracket_(x) # optional - sage.combinat sage.modules
[1, 3, 2] - [3, 2, 1]
- sage: x._bracket_(x)
+ sage: x._bracket_(x) # optional - sage.combinat sage.modules
0
"""
@@ -853,10 +859,10 @@ def to_vector(self, order=None):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: u = L((1, 0, 0)).to_vector(); u
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: u = L((1, 0, 0)).to_vector(); u # optional - sage.combinat sage.modules
(1, 0, 0)
- sage: parent(u)
+ sage: parent(u) # optional - sage.combinat sage.modules
Vector space of dimension 3 over Rational Field
"""
@@ -868,16 +874,16 @@ def lift(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: elt = 3*a + b - c
- sage: elt.lift()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: elt = 3*a + b - c # optional - sage.combinat sage.modules
+ sage: elt.lift() # optional - sage.combinat sage.modules
3*b0 + b1 - b2
::
- sage: L. = LieAlgebra(QQ, abelian=True)
- sage: x.lift()
+ sage: L. = LieAlgebra(QQ, abelian=True) # optional - sage.combinat sage.modules
+ sage: x.lift() # optional - sage.combinat sage.modules
x
"""
@@ -887,9 +893,9 @@ def killing_form(self, x):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: a.killing_form(b)
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: a.killing_form(b) # optional - sage.combinat sage.modules
0
"""
return self.parent().killing_form(self, x)
@@ -906,24 +912,26 @@ def exp(self, lie_group=None):
EXAMPLES::
- sage: L. = LieAlgebra(QQ, 2, step=2)
- sage: g = (X + Y + Z).exp(); g # optional - sage.symbolic
+ sage: L. = LieAlgebra(QQ, 2, step=2) # optional - sage.combinat sage.modules
+ sage: g = (X + Y + Z).exp(); g # optional - sage.combinat sage.modules sage.symbolic
exp(X + Y + Z)
- sage: h = X.exp(); h # optional - sage.symbolic
+ sage: h = X.exp(); h # optional - sage.combinat sage.modules sage.symbolic
exp(X)
- sage: g.parent() # optional - sage.symbolic
- Lie group G of Free Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
- sage: g.parent() is h.parent() # optional - sage.symbolic
+ sage: g.parent() # optional - sage.combinat sage.modules sage.symbolic
+ Lie group G of Free Nilpotent Lie algebra on 3 generators (X, Y, Z)
+ over Rational Field
+ sage: g.parent() is h.parent() # optional - sage.combinat sage.modules sage.symbolic
True
The Lie group can be specified explicitly::
- sage: H = L.lie_group('H') # optional - sage.symbolic
- sage: k = Z.exp(lie_group=H); k # optional - sage.symbolic
+ sage: H = L.lie_group('H') # optional - sage.combinat sage.modules sage.symbolic
+ sage: k = Z.exp(lie_group=H); k # optional - sage.combinat sage.modules sage.symbolic
exp(Z)
- sage: k.parent() # optional - sage.symbolic
- Lie group H of Free Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
- sage: g.parent() == k.parent() # optional - sage.symbolic
+ sage: k.parent() # optional - sage.combinat sage.modules sage.symbolic
+ Lie group H of Free Nilpotent Lie algebra on 3 generators (X, Y, Z)
+ over Rational Field
+ sage: g.parent() == k.parent() # optional - sage.combinat sage.modules sage.symbolic
False
"""
if lie_group is None:
@@ -941,13 +949,13 @@ def __init__(self, domain, codomain):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: f = L.lift
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: f = L.lift # optional - sage.combinat sage.modules
We skip the category test since this is currently not an element of
a homspace::
- sage: TestSuite(f).run(skip="_test_category")
+ sage: TestSuite(f).run(skip="_test_category") # optional - sage.combinat sage.modules
"""
Morphism.__init__(self, Hom(domain, codomain))
@@ -957,9 +965,9 @@ def _call_(self, x):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: a, b, c = L.lie_algebra_generators()
- sage: L.lift(3*a + b - c)
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat sage.modules
+ sage: a, b, c = L.lie_algebra_generators() # optional - sage.combinat sage.modules
+ sage: L.lift(3*a + b - c) # optional - sage.combinat sage.modules
3*b0 + b1 - b2
"""
return x.lift()
diff --git a/src/sage/categories/lie_algebras_with_basis.py b/src/sage/categories/lie_algebras_with_basis.py
index 71916e3d6ad..4f6cf394651 100644
--- a/src/sage/categories/lie_algebras_with_basis.py
+++ b/src/sage/categories/lie_algebras_with_basis.py
@@ -34,13 +34,13 @@ def example(self, gens=None):
EXAMPLES::
- sage: LieAlgebras(QQ).WithBasis().example()
+ sage: LieAlgebras(QQ).WithBasis().example() # optional - sage.combinat
An example of a Lie algebra: the abelian Lie algebra on the
generators indexed by Partitions over Rational Field
Another set of generators can be specified as an optional argument::
- sage: LieAlgebras(QQ).WithBasis().example(Compositions())
+ sage: LieAlgebras(QQ).WithBasis().example(Compositions()) # optional - sage.combinat
An example of a Lie algebra: the abelian Lie algebra on the
generators indexed by Compositions of non-negative integers
over Rational Field
@@ -64,8 +64,8 @@ def _basis_key(self, x):
TESTS::
- sage: L = LieAlgebras(QQ).WithBasis().example()
- sage: L._basis_key(Partition([3,1]))
+ sage: L = LieAlgebras(QQ).WithBasis().example() # optional - sage.combinat
+ sage: L._basis_key(Partition([3,1])) # optional - sage.combinat
[3, 1]
"""
return x
@@ -79,8 +79,8 @@ def bracket_on_basis(self, x, y):
EXAMPLES::
- sage: L = LieAlgebras(QQ).WithBasis().example()
- sage: L.bracket_on_basis(Partition([3,1]), Partition([2,2,1,1]))
+ sage: L = LieAlgebras(QQ).WithBasis().example() # optional - sage.combinat
+ sage: L.bracket_on_basis(Partition([3,1]), Partition([2,2,1,1])) # optional - sage.combinat
0
"""
@@ -95,8 +95,8 @@ def module(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).WithBasis().example()
- sage: L.module()
+ sage: L = LieAlgebras(QQ).WithBasis().example() # optional - sage.combinat
+ sage: L.module() # optional - sage.combinat
Free module generated by Partitions over Rational Field
"""
from sage.combinat.free_module import CombinatorialFreeModule
@@ -119,10 +119,10 @@ def from_vector(self, v, order=None, coerce=False):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: u = L.from_vector(vector(QQ, (1, 0, 0))); u
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat
+ sage: u = L.from_vector(vector(QQ, (1, 0, 0))); u # optional - sage.combinat
(1, 0, 0)
- sage: parent(u) is L
+ sage: parent(u) is L # optional - sage.combinat
True
"""
B = self.basis()
@@ -135,14 +135,14 @@ def dimension(self):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.dimension()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.combinat
+ sage: L.dimension() # optional - sage.combinat
3
::
- sage: L = LieAlgebra(QQ, 'x,y', {('x','y'): {'x':1}})
- sage: L.dimension()
+ sage: L = LieAlgebra(QQ, 'x,y', {('x','y'): {'x':1}}) # optional - sage.combinat sage.modules
+ sage: L.dimension() # optional - sage.combinat sage.modules
2
"""
return self.basis().cardinality()
@@ -154,8 +154,8 @@ def pbw_basis(self, basis_key=None, **kwds):
EXAMPLES::
- sage: L = lie_algebras.sl(QQ, 2)
- sage: PBW = L.pbw_basis()
+ sage: L = lie_algebras.sl(QQ, 2) # optional - sage.combinat sage.modules
+ sage: PBW = L.pbw_basis() # optional - sage.combinat sage.modules
"""
from sage.algebras.lie_algebras.poincare_birkhoff_witt \
import PoincareBirkhoffWittBasis
@@ -173,11 +173,11 @@ def _bracket_(self, y):
EXAMPLES::
- sage: L = LieAlgebras(QQ).WithBasis().example()
- sage: G = L.lie_algebra_generators()
- sage: x = G[Partition([4,3,3,1])]
- sage: y = G[Partition([6,1])]
- sage: x.bracket(y)
+ sage: L = LieAlgebras(QQ).WithBasis().example() # optional - sage.combinat
+ sage: G = L.lie_algebra_generators() # optional - sage.combinat
+ sage: x = G[Partition([4,3,3,1])] # optional - sage.combinat
+ sage: y = G[Partition([6,1])] # optional - sage.combinat
+ sage: x.bracket(y) # optional - sage.combinat
0
"""
P = self.parent()
@@ -206,8 +206,8 @@ def to_vector(self, order=None):
EXAMPLES::
- sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
- sage: L.an_element().to_vector()
+ sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example() # optional - sage.modules
+ sage: L.an_element().to_vector() # optional - sage.modules
(0, 0, 0)
.. TODO::
@@ -224,15 +224,15 @@ def lift(self):
EXAMPLES::
- sage: S = SymmetricGroup(3).algebra(QQ)
- sage: L = LieAlgebra(associative=S)
- sage: x = L.gen(3)
- sage: y = L.gen(1)
- sage: x.lift()
+ sage: S = SymmetricGroup(3).algebra(QQ) # optional - sage.groups
+ sage: L = LieAlgebra(associative=S) # optional - sage.groups
+ sage: x = L.gen(3) # optional - sage.groups
+ sage: y = L.gen(1) # optional - sage.groups
+ sage: x.lift() # optional - sage.groups
b3
- sage: y.lift()
+ sage: y.lift() # optional - sage.groups
b1
- sage: x * y
+ sage: x * y # optional - sage.groups
b1*b3 + b4 - b5
"""
P = self.parent()
diff --git a/src/sage/categories/lie_conformal_algebras.py b/src/sage/categories/lie_conformal_algebras.py
index 54e3956c283..4e59d4758b0 100644
--- a/src/sage/categories/lie_conformal_algebras.py
+++ b/src/sage/categories/lie_conformal_algebras.py
@@ -152,15 +152,16 @@ class LieConformalAlgebras(Category_over_base_ring):
Some subcategories::
- sage: LieConformalAlgebras(QQbar).FinitelyGenerated().WithBasis()
- Category of finitely generated Lie conformal algebras with basis over Algebraic Field
+ sage: LieConformalAlgebras(QQbar).FinitelyGenerated().WithBasis() # optional - sage.rings.number_field
+ Category of finitely generated Lie conformal algebras with basis
+ over Algebraic Field
In addition we support functorial constructions ``Graded`` and
``Super``. These functors commute::
- sage: LieConformalAlgebras(AA).Graded().Super()
+ sage: CGS = LieConformalAlgebras(AA).Graded().Super(); CGS # optional - sage.rings.number_field
Category of H-graded super Lie conformal algebras over Algebraic Real Field
- sage: LieConformalAlgebras(AA).Graded().Super() is LieConformalAlgebras(AA).Super().Graded()
+ sage: CGS is LieConformalAlgebras(AA).Super().Graded() # optional - sage.rings.number_field
True
That is, we only consider gradings on super Lie conformal algebras
@@ -168,9 +169,10 @@ class LieConformalAlgebras(Category_over_base_ring):
The base ring needs to be a commutative ring::
- sage: LieConformalAlgebras(QuaternionAlgebra(2))
+ sage: LieConformalAlgebras(QuaternionAlgebra(2)) # optional - sage.combinat sage.modules
Traceback (most recent call last):
- ValueError: base must be a commutative ring got Quaternion Algebra (-1, -1) with base ring Rational Field
+ ValueError: base must be a commutative ring
+ got Quaternion Algebra (-1, -1) with base ring Rational Field
"""
@cached_method
def super_categories(self):
@@ -219,7 +221,7 @@ def example(self):
EXAMPLES::
- sage: LieConformalAlgebras(QQ).example()
+ sage: LieConformalAlgebras(QQ).example() # optional - sage.combinat sage.modules
The Virasoro Lie conformal algebra over Rational Field
"""
from sage.algebras.lie_conformal_algebras.virasoro_lie_conformal_algebra\
@@ -252,27 +254,27 @@ def _test_jacobi(self, **options):
By default, this method tests only the elements returned by
``self.some_elements()``::
- sage: V = lie_conformal_algebras.Affine(QQ, 'B2')
- sage: V._test_jacobi() # long time (6 seconds)
+ sage: V = lie_conformal_algebras.Affine(QQ, 'B2') # optional - sage.combinat sage.modules
+ sage: V._test_jacobi() # long time (6 seconds) # optional - sage.combinat sage.modules
It works for super Lie conformal algebras too::
- sage: V = lie_conformal_algebras.NeveuSchwarz(QQ)
- sage: V._test_jacobi()
+ sage: V = lie_conformal_algebras.NeveuSchwarz(QQ) # optional - sage.combinat sage.modules
+ sage: V._test_jacobi() # optional - sage.combinat sage.modules
We can use specific elements by passing the ``elements``
keyword argument::
- sage: V = lie_conformal_algebras.Affine(QQ, 'A1', names=('e', 'h', 'f'))
- sage: V.inject_variables()
+ sage: V = lie_conformal_algebras.Affine(QQ, 'A1', names=('e', 'h', 'f')) # optional - sage.combinat sage.modules
+ sage: V.inject_variables() # optional - sage.combinat sage.modules
Defining e, h, f, K
- sage: V._test_jacobi(elements=(e, 2*f+h, 3*h))
+ sage: V._test_jacobi(elements=(e, 2*f+h, 3*h)) # optional - sage.combinat sage.modules
TESTS::
sage: wrongdict = {('a', 'a'): {0: {('b', 0): 1}}, ('b', 'a'): {0: {('a', 0): 1}}}
- sage: V = LieConformalAlgebra(QQ, wrongdict, names=('a', 'b'), parity=(1, 0))
- sage: V._test_jacobi()
+ sage: V = LieConformalAlgebra(QQ, wrongdict, names=('a', 'b'), parity=(1, 0)) # optional - sage.combinat sage.modules
+ sage: V._test_jacobi() # optional - sage.combinat sage.modules
Traceback (most recent call last):
...
AssertionError: {(0, 0): -3*a} != {}
@@ -323,10 +325,10 @@ def is_even_odd(self):
EXAMPLES::
- sage: R = lie_conformal_algebras.NeveuSchwarz(QQ);
- sage: R.inject_variables()
+ sage: R = lie_conformal_algebras.NeveuSchwarz(QQ) # optional - sage.combinat sage.modules
+ sage: R.inject_variables() # optional - sage.combinat sage.modules
Defining L, G, C
- sage: G.is_even_odd()
+ sage: G.is_even_odd() # optional - sage.combinat sage.modules
1
"""
return 0
diff --git a/src/sage/categories/lie_conformal_algebras_with_basis.py b/src/sage/categories/lie_conformal_algebras_with_basis.py
index 50f67d2a970..6f31b6b4cca 100644
--- a/src/sage/categories/lie_conformal_algebras_with_basis.py
+++ b/src/sage/categories/lie_conformal_algebras_with_basis.py
@@ -27,7 +27,7 @@ class LieConformalAlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).WithBasis()
+ sage: LieConformalAlgebras(QQbar).WithBasis() # optional - sage.rings.number_field
Category of Lie conformal algebras with basis over Algebraic Field
"""
class Super(SuperModulesCategory):
@@ -36,8 +36,9 @@ class Super(SuperModulesCategory):
EXAMPLES::
- sage: LieConformalAlgebras(AA).WithBasis().Super()
- Category of super Lie conformal algebras with basis over Algebraic Real Field
+ sage: LieConformalAlgebras(AA).WithBasis().Super() # optional - sage.rings.number_field
+ Category of super Lie conformal algebras with basis
+ over Algebraic Real Field
"""
class ParentMethods:
@@ -52,9 +53,9 @@ def _even_odd_on_basis(self, m):
EXAMPLES::
- sage: V = lie_conformal_algebras.NeveuSchwarz(QQ)
- sage: B = V._indices
- sage: V._even_odd_on_basis(B(('G',1)))
+ sage: V = lie_conformal_algebras.NeveuSchwarz(QQ) # optional - sage.combinat sage.modules
+ sage: B = V._indices # optional - sage.combinat sage.modules
+ sage: V._even_odd_on_basis(B(('G', 1))) # optional - sage.combinat sage.modules
1
"""
return self._parity[self.monomial((m[0],0))]
@@ -65,8 +66,9 @@ class Graded(GradedLieConformalAlgebrasCategory):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).WithBasis().Super().Graded()
- Category of H-graded super Lie conformal algebras with basis over Algebraic Field
+ sage: LieConformalAlgebras(QQbar).WithBasis().Super().Graded() # optional - sage.rings.number_field
+ Category of H-graded super Lie conformal algebras with basis
+ over Algebraic Field
"""
class Graded(GradedLieConformalAlgebrasCategory):
@@ -75,7 +77,7 @@ class Graded(GradedLieConformalAlgebrasCategory):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).WithBasis().Graded()
+ sage: LieConformalAlgebras(QQbar).WithBasis().Graded() # optional - sage.rings.number_field
Category of H-graded Lie conformal algebras with basis over Algebraic Field
"""
@@ -86,10 +88,11 @@ class FinitelyGeneratedAsLambdaBracketAlgebra(CategoryWithAxiom_over_base_ring):
EXAMPLES::
- sage: C = LieConformalAlgebras(QQbar)
- sage: C.WithBasis().FinitelyGenerated()
- Category of finitely generated Lie conformal algebras with basis over Algebraic Field
- sage: C.WithBasis().FinitelyGenerated() is C.FinitelyGenerated().WithBasis()
+ sage: C = LieConformalAlgebras(QQbar) # optional - sage.rings.number_field
+ sage: CWF = C.WithBasis().FinitelyGenerated(); CWF # optional - sage.rings.number_field
+ Category of finitely generated Lie conformal algebras with basis
+ over Algebraic Field
+ sage: CWF is C.FinitelyGenerated().WithBasis() # optional - sage.rings.number_field
True
"""
class Super(SuperModulesCategory):
@@ -99,8 +102,9 @@ class Super(SuperModulesCategory):
EXAMPLES::
- sage: LieConformalAlgebras(AA).WithBasis().FinitelyGenerated().Super()
- Category of super finitely generated Lie conformal algebras with basis over Algebraic Real Field
+ sage: LieConformalAlgebras(AA).WithBasis().FinitelyGenerated().Super() # optional - sage.rings.number_field
+ Category of super finitely generated Lie conformal algebras with basis
+ over Algebraic Real Field
"""
class Graded(GradedModulesCategory):
"""
@@ -109,10 +113,11 @@ class Graded(GradedModulesCategory):
EXAMPLES::
- sage: C = LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated()
- sage: C.Graded().Super()
- Category of H-graded super finitely generated Lie conformal algebras with basis over Algebraic Field
- sage: C.Graded().Super() is C.Super().Graded()
+ sage: C = LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated() # optional - sage.rings.number_field
+ sage: C.Graded().Super() # optional - sage.rings.number_field
+ Category of H-graded super finitely generated Lie conformal algebras
+ with basis over Algebraic Field
+ sage: C.Graded().Super() is C.Super().Graded() # optional - sage.rings.number_field
True
"""
def _repr_object_names(self):
@@ -121,8 +126,8 @@ def _repr_object_names(self):
EXAMPLES::
- sage: C = LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated()
- sage: C.Super().Graded()
+ sage: C = LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated() # optional - sage.rings.number_field
+ sage: C.Super().Graded() # optional - sage.rings.number_field
Category of H-graded super finitely generated Lie conformal algebras with basis over Algebraic Field
"""
return "H-graded {}".format(self.base_category()._repr_object_names())
@@ -134,6 +139,7 @@ class Graded(GradedLieConformalAlgebrasCategory):
EXAMPLES::
- sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded()
- Category of H-graded finitely generated Lie conformal algebras with basis over Algebraic Field
+ sage: LieConformalAlgebras(QQbar).WithBasis().FinitelyGenerated().Graded() # optional - sage.rings.number_field
+ Category of H-graded finitely generated Lie conformal algebras with basis
+ over Algebraic Field
"""
diff --git a/src/sage/categories/loop_crystals.py b/src/sage/categories/loop_crystals.py
index 415d8c308f7..b7dbd37a3c6 100644
--- a/src/sage/categories/loop_crystals.py
+++ b/src/sage/categories/loop_crystals.py
@@ -1,3 +1,4 @@
+# sage.doctest: optional - sage.graphs sage.combinat
r"""
Loop Crystals
"""
@@ -390,11 +391,17 @@ def R_matrix(self, K):
sage: K2 = crystals.KirillovReshetikhin(['A',2,1],2,1)
sage: T1 = crystals.TensorProduct(K1,K2)
sage: T2 = crystals.TensorProduct(K2,K1)
- sage: T1.digraph().is_isomorphic(T2.digraph(), edge_labels=True, certificate=True) #todo: not implemented (see #10904 and #10549)
- (True, {[[[1]], [[2], [3]]]: [[[1], [3]], [[2]]], [[[3]], [[2], [3]]]: [[[2], [3]], [[3]]],
- [[[3]], [[1], [3]]]: [[[1], [3]], [[3]]], [[[1]], [[1], [3]]]: [[[1], [3]], [[1]]], [[[1]],
- [[1], [2]]]: [[[1], [2]], [[1]]], [[[2]], [[1], [2]]]: [[[1], [2]], [[2]]], [[[3]],
- [[1], [2]]]: [[[2], [3]], [[1]]], [[[2]], [[1], [3]]]: [[[1], [2]], [[3]]], [[[2]], [[2], [3]]]: [[[2], [3]], [[2]]]})
+ sage: T1.digraph().is_isomorphic(T2.digraph(), edge_labels=True, # todo: not implemented (see #10904 and #10549)
+ ....: certificate=True)
+ (True, {[[[1]], [[2], [3]]]: [[[1], [3]], [[2]]],
+ [[[3]], [[2], [3]]]: [[[2], [3]], [[3]]],
+ [[[3]], [[1], [3]]]: [[[1], [3]], [[3]]],
+ [[[1]], [[1], [3]]]: [[[1], [3]], [[1]]], [[[1]],
+ [[1], [2]]]: [[[1], [2]], [[1]]],
+ [[[2]], [[1], [2]]]: [[[1], [2]], [[2]]], [[[3]],
+ [[1], [2]]]: [[[2], [3]], [[1]]],
+ [[[2]], [[1], [3]]]: [[[1], [2]], [[3]]],
+ [[[2]], [[2], [3]]]: [[[2], [3]], [[2]]]})
"""
from sage.combinat.crystals.tensor_product import TensorProductOfCrystals
T1 = TensorProductOfCrystals(self, K)
@@ -514,7 +521,7 @@ def is_perfect(self, ell=None):
sage: K.is_perfect()
True
- sage: K = crystals.KirillovReshetikhin(['E',6,1], 1,3)
+ sage: K = crystals.KirillovReshetikhin(['E',6,1], 1, 3)
sage: K.is_perfect()
True
@@ -523,7 +530,7 @@ def is_perfect(self, ell=None):
Check that this works correctly for `B^{n,s}`
of type `A_{2n}^{(2)\dagger}` (:trac:`24364`)::
- sage: K = crystals.KirillovReshetikhin(CartanType(['A',6,2]).dual(), 3,1)
+ sage: K = crystals.KirillovReshetikhin(CartanType(['A',6,2]).dual(), 3, 1)
sage: K.is_perfect()
True
sage: K.is_perfect(1)
@@ -835,7 +842,8 @@ def one_dimensional_configuration_sum(self, q=None, group_components=True):
sage: R = RootSystem(['A',2,1])
sage: La = R.weight_space().basis()
sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1])
- sage: LS.one_dimensional_configuration_sum() == T.one_dimensional_configuration_sum() # long time
+ sage: (LS.one_dimensional_configuration_sum() # long time
+ ....: == T.one_dimensional_configuration_sum())
True
TESTS::
diff --git a/src/sage/categories/magmas.py b/src/sage/categories/magmas.py
index 33dc2bb973a..e80088548a9 100644
--- a/src/sage/categories/magmas.py
+++ b/src/sage/categories/magmas.py
@@ -296,11 +296,13 @@ def Distributive(self):
sage: Magmas().Distributive()
Traceback (most recent call last):
...
- ValueError: The distributive axiom only makes sense on a magma which is simultaneously an additive magma
+ ValueError: The distributive axiom only makes sense on a magma
+ which is simultaneously an additive magma
sage: Semigroups().Distributive()
Traceback (most recent call last):
...
- ValueError: The distributive axiom only makes sense on a magma which is simultaneously an additive magma
+ ValueError: The distributive axiom only makes sense on a magma
+ which is simultaneously an additive magma
TESTS::
@@ -331,7 +333,8 @@ def JTrivial(self):
sage: Magmas().JTrivial()
Category of j trivial magmas
- sage: (Semigroups().RTrivial() & Semigroups().LTrivial()) is Semigroups().JTrivial()
+ sage: C = Semigroups().RTrivial() & Semigroups().LTrivial()
+ sage: C is Semigroups().JTrivial()
True
"""
return self._with_axiom('JTrivial')
@@ -349,19 +352,22 @@ def extra_super_categories(self):
"""
EXAMPLES::
- sage: Magmas().Commutative().Algebras(QQ).extra_super_categories()
+ sage: MCA = Magmas().Commutative().Algebras(QQ)
+ sage: MCA.extra_super_categories()
[Category of commutative magmas]
This implements the fact that the algebra of a commutative
magma is commutative::
- sage: Magmas().Commutative().Algebras(QQ).super_categories()
- [Category of magma algebras over Rational Field, Category of commutative magmas]
+ sage: MCA.super_categories()
+ [Category of magma algebras over Rational Field,
+ Category of commutative magmas]
In particular, commutative monoid algebras are
commutative algebras::
- sage: Monoids().Commutative().Algebras(QQ).is_subcategory(Algebras(QQ).Commutative())
+ sage: MoCA = Monoids().Commutative().Algebras(QQ)
+ sage: MoCA.is_subcategory(Algebras(QQ).Commutative())
True
"""
from sage.categories.magmatic_algebras import MagmaticAlgebras
@@ -377,11 +383,11 @@ def is_field(self, proof=True):
EXAMPLES::
- sage: SymmetricGroup(1).algebra(QQ).is_field()
+ sage: SymmetricGroup(1).algebra(QQ).is_field() # optional - sage.groups
True
- sage: SymmetricGroup(1).algebra(ZZ).is_field()
+ sage: SymmetricGroup(1).algebra(ZZ).is_field() # optional - sage.groups
False
- sage: SymmetricGroup(2).algebra(QQ).is_field()
+ sage: SymmetricGroup(2).algebra(QQ).is_field() # optional - sage.groups
False
"""
if not self.base_ring().is_field(proof):
@@ -397,7 +403,7 @@ def is_commutative(self):
EXAMPLES::
- sage: Parent(QQ,category=CommutativeRings()).is_commutative()
+ sage: Parent(QQ, category=CommutativeRings()).is_commutative()
True
"""
return True
@@ -408,20 +414,22 @@ def extra_super_categories(self):
"""
EXAMPLES::
- sage: Magmas().Commutative().Algebras(QQ).extra_super_categories()
+ sage: MCA = Magmas().Commutative().Algebras(QQ)
+ sage: MCA.extra_super_categories()
[Category of commutative magmas]
This implements the fact that the algebra of a commutative
magma is commutative::
- sage: Magmas().Commutative().Algebras(QQ).super_categories()
+ sage: MCA.super_categories()
[Category of magma algebras over Rational Field,
Category of commutative magmas]
In particular, commutative monoid algebras are
commutative algebras::
- sage: Monoids().Commutative().Algebras(QQ).is_subcategory(Algebras(QQ).Commutative())
+ sage: MoCA = Monoids().Commutative().Algebras(QQ)
+ sage: MoCA.is_subcategory(Algebras(QQ).Commutative())
True
"""
return [Magmas().Commutative()]
@@ -480,7 +488,8 @@ def one(self):
EXAMPLES::
sage: M = Monoids().example(); M
- An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd')
+ An example of a monoid:
+ the free monoid generated by ('a', 'b', 'c', 'd')
sage: M.one()
''
"""
@@ -531,8 +540,8 @@ def is_empty(self):
EXAMPLES::
- sage: S = SymmetricGroup(2)
- sage: S.is_empty()
+ sage: S = SymmetricGroup(2) # optional - sage.groups
+ sage: S.is_empty() # optional - sage.groups
False
sage: M = Monoids().example()
@@ -541,7 +550,7 @@ def is_empty(self):
TESTS::
- sage: S.is_empty.__module__
+ sage: S.is_empty.__module__ # optional - sage.groups
'sage.categories.magmas'
sage: M.is_empty.__module__
'sage.categories.magmas'
@@ -656,21 +665,21 @@ def __invert__(self):
EXAMPLES::
- sage: C = cartesian_product([QQ, ZZ, RR, GF(5)])
- sage: c = C([2,-1,2,2]); c
+ sage: C = cartesian_product([QQ, ZZ, RR, GF(5)]) # optional - sage.rings.finite_rings
+ sage: c = C([2,-1,2,2]); c # optional - sage.rings.finite_rings
(2, -1, 2.00000000000000, 2)
- sage: ~c
+ sage: ~c # optional - sage.rings.finite_rings
(1/2, -1, 0.500000000000000, 3)
This fails as soon as one of the entries is not
invertible::
- sage: ~C([0,2,2,2])
+ sage: ~C([0,2,2,2]) # optional - sage.rings.finite_rings
Traceback (most recent call last):
...
ZeroDivisionError: rational division by zero
- sage: ~C([2,2,2,2])
+ sage: ~C([2,2,2,2]) # optional - sage.rings.finite_rings
(1/2, 1/2, 0.500000000000000, 3)
"""
# variant without coercion:
@@ -684,20 +693,22 @@ def extra_super_categories(self):
"""
EXAMPLES::
- sage: Magmas().Commutative().Algebras(QQ).extra_super_categories()
+ sage: MCA = Magmas().Commutative().Algebras(QQ)
+ sage: MCA.extra_super_categories()
[Category of commutative magmas]
This implements the fact that the algebra of a
commutative magma is commutative::
- sage: Magmas().Commutative().Algebras(QQ).super_categories()
+ sage: MCA.super_categories()
[Category of magma algebras over Rational Field,
Category of commutative magmas]
In particular, commutative monoid algebras are
commutative algebras::
- sage: Monoids().Commutative().Algebras(QQ).is_subcategory(Algebras(QQ).Commutative())
+ sage: MoCA = Monoids().Commutative().Algebras(QQ)
+ sage: MoCA.is_subcategory(Algebras(QQ).Commutative())
True
"""
return [Magmas().Unital()]
@@ -713,11 +724,11 @@ def one(self):
EXAMPLES::
- sage: from sage.combinat.root_system.extended_affine_weyl_group import ExtendedAffineWeylGroup
- sage: PvW0 = ExtendedAffineWeylGroup(['A',2,1]).PvW0()
- sage: PvW0 in Magmas().Unital().Realizations()
+ sage: from sage.combinat.root_system.extended_affine_weyl_group import ExtendedAffineWeylGroup # optional - sage.combinat sage.groups
+ sage: PvW0 = ExtendedAffineWeylGroup(['A',2,1]).PvW0() # optional - sage.combinat sage.groups
+ sage: PvW0 in Magmas().Unital().Realizations() # optional - sage.combinat sage.groups
True
- sage: PvW0.one()
+ sage: PvW0.one() # optional - sage.combinat sage.groups
1
"""
return self(self.realization_of().a_realization().one())
@@ -758,7 +769,8 @@ def product(self, x, y):
Currently, ``S.product`` is just a bound method::
sage: bin
-
+
When Sage will support multivariate morphisms, it will be
possible, and in fact recommended, to enrich ``S.product``
@@ -872,8 +884,8 @@ def multiplication_table(self, names='letters', elements=None):
The default is to represent elements as lowercase
ASCII letters. ::
- sage: G = CyclicPermutationGroup(5)
- sage: G.multiplication_table()
+ sage: G = CyclicPermutationGroup(5) # optional - sage.groups
+ sage: G.multiplication_table() # optional - sage.groups
* a b c d e
+----------
a| a b c d e
@@ -890,10 +902,10 @@ def multiplication_table(self, names='letters', elements=None):
sage: from sage.categories.examples.finite_semigroups import LeftRegularBand
sage: L = LeftRegularBand(('a', 'b'))
- sage: T = L.multiplication_table(names='digits')
- sage: T.column_keys()
+ sage: T = L.multiplication_table(names='digits') # optional - sage.matrix
+ sage: T.column_keys() # optional - sage.matrix
('a', 'ab', 'b', 'ba')
- sage: T
+ sage: T # optional - sage.matrix
* 0 1 2 3
+--------
0| 0 1 1 1
@@ -906,7 +918,7 @@ def multiplication_table(self, names='letters', elements=None):
sage: L = LeftRegularBand(('a', 'b', 'c'))
sage: elts = sorted(L.list())
- sage: L.multiplication_table(elements=elts)
+ sage: L.multiplication_table(elements=elts) # optional - sage.matrix
* a b c d e f g h i j k l m n o
+------------------------------
a| a b c d e b b c c c d d e e e
@@ -935,7 +947,7 @@ def multiplication_table(self, names='letters', elements=None):
sage: L = LeftRegularBand(('a','b','c'))
sage: elts=['a', 'c', 'ac', 'ca']
- sage: L.multiplication_table(names='elements', elements=elts)
+ sage: L.multiplication_table(names='elements', elements=elts) # optional - sage.matrix
* 'a' 'c' 'ac' 'ca'
+--------------------
'a'| 'a' 'ac' 'ac' 'ac'
@@ -948,16 +960,16 @@ def multiplication_table(self, names='letters', elements=None):
:class:`~sage.matrix.operation_table.OperationTable` for more
comprehensive documentation. ::
- sage: G = AlternatingGroup(3)
- sage: T = G.multiplication_table()
- sage: T.column_keys()
+ sage: G = AlternatingGroup(3) # optional - sage.groups
+ sage: T = G.multiplication_table() # optional - sage.groups sage.matrix
+ sage: T.column_keys() # optional - sage.groups sage.matrix
((), (1,2,3), (1,3,2))
- sage: T.translation()
+ sage: T.translation() # optional - sage.groups sage.matrix
{'a': (), 'b': (1,2,3), 'c': (1,3,2)}
- sage: T.change_names(['x', 'y', 'z'])
- sage: T.translation()
+ sage: T.change_names(['x', 'y', 'z']) # optional - sage.groups sage.matrix
+ sage: T.translation() # optional - sage.groups sage.matrix
{'x': (), 'y': (1,2,3), 'z': (1,3,2)}
- sage: T
+ sage: T # optional - sage.groups sage.matrix
* x y z
+------
x| x y z
@@ -999,7 +1011,8 @@ def is_idempotent(self):
EXAMPLES::
sage: S = Semigroups().example("free"); S
- An example of a semigroup: the free semigroup generated by ('a', 'b', 'c', 'd')
+ An example of a semigroup:
+ the free semigroup generated by ('a', 'b', 'c', 'd')
sage: a = S('a')
sage: a^2
'aa'
@@ -1071,12 +1084,12 @@ def product(self, left, right):
sage: x * x
(1/4, 1, 1)
- sage: A = SymmetricGroupAlgebra(QQ, 3)
- sage: x = cartesian_product([A([1,3,2]), A([2,3,1])])
- sage: y = cartesian_product([A([1,3,2]), A([2,3,1])])
- sage: cartesian_product([A,A]).product(x,y)
+ sage: A = SymmetricGroupAlgebra(QQ, 3) # optional - sage.groups
+ sage: x = cartesian_product([A([1,3,2]), A([2,3,1])]) # optional - sage.groups
+ sage: y = cartesian_product([A([1,3,2]), A([2,3,1])]) # optional - sage.groups
+ sage: cartesian_product([A,A]).product(x,y) # optional - sage.groups
B[(0, [1, 2, 3])] + B[(1, [3, 1, 2])]
- sage: x*y
+ sage: x*y # optional - sage.groups
B[(0, [1, 2, 3])] + B[(1, [3, 1, 2])]
"""
prods = ((a * b) for a, b in zip(left.cartesian_factors(),
@@ -1125,9 +1138,9 @@ def product(self, x, y):
Here is a more elaborate example involving a sub algebra::
- sage: Z = SymmetricGroup(5).algebra(QQ).center()
- sage: B = Z.basis()
- sage: B[3] * B[2]
+ sage: Z = SymmetricGroup(5).algebra(QQ).center() # optional - sage.groups
+ sage: B = Z.basis() # optional - sage.groups
+ sage: B[3] * B[2] # optional - sage.groups
4*B[2] + 6*B[3] + 5*B[6]
"""
assert x in self
@@ -1149,15 +1162,18 @@ def product_by_coercion(self, left, right):
EXAMPLES::
- sage: Out = Sets().WithRealizations().example().Out(); Out
- The subset algebra of {1, 2, 3} over Rational Field in the Out basis
- sage: Out.product
-
- sage: Out.product.__module__
+ sage: Out = Sets().WithRealizations().example().Out(); Out # optional - sage.combinat sage.modules
+ The subset algebra of {1, 2, 3} over Rational Field
+ in the Out basis
+ sage: Out.product # optional - sage.combinat sage.modules
+
+ sage: Out.product.__module__ # optional - sage.combinat sage.modules
'sage.categories.magmas'
- sage: x = Out.an_element()
- sage: y = Out.an_element()
- sage: Out.product(x, y)
+ sage: x = Out.an_element() # optional - sage.combinat sage.modules
+ sage: y = Out.an_element() # optional - sage.combinat sage.modules
+ sage: Out.product(x, y) # optional - sage.combinat sage.modules
Out[{}] + 4*Out[{1}] + 9*Out[{2}] + Out[{1, 2}]
"""
diff --git a/src/sage/categories/magmatic_algebras.py b/src/sage/categories/magmatic_algebras.py
index ef82ba4319b..171f564534e 100644
--- a/src/sage/categories/magmatic_algebras.py
+++ b/src/sage/categories/magmatic_algebras.py
@@ -40,7 +40,8 @@ class MagmaticAlgebras(Category_over_base_ring):
sage: C = MagmaticAlgebras(ZZ); C
Category of magmatic algebras over Integer Ring
sage: C.super_categories()
- [Category of additive commutative additive associative additive unital distributive magmas and additive magmas,
+ [Category of additive commutative additive associative additive
+ unital distributive magmas and additive magmas,
Category of modules over Integer Ring]
TESTS::
@@ -54,11 +55,14 @@ def super_categories(self):
EXAMPLES::
sage: from sage.categories.magmatic_algebras import MagmaticAlgebras
- sage: MagmaticAlgebras(ZZ).super_categories()
- [Category of additive commutative additive associative additive unital distributive magmas and additive magmas, Category of modules over Integer Ring]
+ sage: MA = MagmaticAlgebras(ZZ)
+ sage: MA.super_categories()
+ [Category of additive commutative additive associative additive
+ unital distributive magmas and additive magmas,
+ Category of modules over Integer Ring]
sage: from sage.categories.additive_semigroups import AdditiveSemigroups
- sage: MagmaticAlgebras(ZZ).is_subcategory((AdditiveSemigroups() & Magmas()).Distributive())
+ sage: MA.is_subcategory((AdditiveSemigroups() & Magmas()).Distributive())
True
"""
@@ -106,9 +110,10 @@ def algebra_generators(self):
EXAMPLES::
- sage: F = AlgebrasWithBasis(QQ).example(); F
- An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
- sage: F.algebra_generators()
+ sage: F = AlgebrasWithBasis(QQ).example(); F # optional - sage.combinat sage.modules
+ An example of an algebra with basis:
+ the free algebra on the generators ('a', 'b', 'c') over Rational Field
+ sage: F.algebra_generators() # optional - sage.combinat sage.modules
Family (B[word: a], B[word: b], B[word: c])
"""
@@ -131,16 +136,18 @@ def algebra_generators(self):
EXAMPLES::
- sage: D4 = DescentAlgebra(QQ, 4).B()
- sage: D4.algebra_generators()
+ sage: D4 = DescentAlgebra(QQ, 4).B() # optional - sage.combinat sage.modules
+ sage: D4.algebra_generators() # optional - sage.combinat sage.modules
Lazy family (...)_{i in Compositions of 4}
sage: R. = ZZ[]
- sage: P = PartitionAlgebra(1, x, R)
- sage: P.algebra_generators()
- Lazy family (Term map from Partition diagrams of order 1 to
- Partition Algebra of rank 1 with parameter x over Univariate Polynomial Ring in x
- over Integer Ring(i))_{i in Partition diagrams of order 1}
+ sage: P = PartitionAlgebra(1, x, R) # optional - sage.combinat sage.modules
+ sage: P.algebra_generators() # optional - sage.combinat sage.modules
+ Lazy family (Term map
+ from Partition diagrams of order 1
+ to Partition Algebra of rank 1 with parameter x
+ over Univariate Polynomial Ring in x
+ over Integer Ring(i))_{i in Partition diagrams of order 1}
"""
return self.basis()
@@ -162,9 +169,9 @@ def product_on_basis(self, i, j):
EXAMPLES::
- sage: A = AlgebrasWithBasis(QQ).example()
- sage: Word = A.basis().keys()
- sage: A.product_on_basis(Word("abc"),Word("cba"))
+ sage: A = AlgebrasWithBasis(QQ).example() # optional - sage.combinat sage.modules
+ sage: Word = A.basis().keys() # optional - sage.combinat sage.modules
+ sage: A.product_on_basis(Word("abc"), Word("cba")) # optional - sage.combinat sage.modules
B[word: abccba]
"""
@@ -183,9 +190,9 @@ def product(self):
EXAMPLES::
- sage: A = AlgebrasWithBasis(QQ).example()
- sage: a, b, c = A.algebra_generators()
- sage: A.product(a + 2*b, 3*c)
+ sage: A = AlgebrasWithBasis(QQ).example() # optional - sage.combinat sage.modules
+ sage: a, b, c = A.algebra_generators() # optional - sage.combinat sage.modules
+ sage: A.product(a + 2*b, 3*c) # optional - sage.combinat sage.modules
3*B[word: ac] + 6*B[word: bc]
"""
if self.product_on_basis is not NotImplemented:
@@ -205,10 +212,11 @@ def _product_from_product_on_basis_multiply( self, left, right ):
EXAMPLES::
- sage: A = AlgebrasWithBasis(QQ).example(); A
- An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
- sage: (a,b,c) = A.algebra_generators()
- sage: A._product_from_product_on_basis_multiply(a*b + 2*c, a - b)
+ sage: A = AlgebrasWithBasis(QQ).example(); A # optional - sage.combinat sage.modules
+ An example of an algebra with basis:
+ the free algebra on the generators ('a', 'b', 'c') over Rational Field
+ sage: a, b, c = A.algebra_generators() # optional - sage.combinat sage.modules
+ sage: A._product_from_product_on_basis_multiply(a*b + 2*c, a - b) # optional - sage.combinat sage.modules
B[word: aba] - B[word: abb] + 2*B[word: ca] - 2*B[word: cb]
"""
@@ -239,17 +247,17 @@ def derivations_basis(self):
We construct the Heisenberg Lie algebra as a
multiplicative algebra::
- sage: p_mult = matrix([[0,0,0],[0,0,-1],[0,0,0]])
- sage: q_mult = matrix([[0,0,1],[0,0,0],[0,0,0]])
- sage: A = algebras.FiniteDimensional(QQ,
- ....: [p_mult,q_mult,matrix(QQ,3,3)], 'p,q,z')
- sage: A.inject_variables()
+ sage: p_mult = matrix([[0,0,0], [0,0,-1], [0,0,0]]) # optional - sage.combinat sage.modules
+ sage: q_mult = matrix([[0,0,1], [0,0,0], [0,0,0]]) # optional - sage.combinat sage.modules
+ sage: A = algebras.FiniteDimensional(QQ, # optional - sage.combinat sage.modules
+ ....: [p_mult, q_mult, matrix(QQ, 3, 3)], 'p,q,z')
+ sage: A.inject_variables() # optional - sage.combinat sage.modules
Defining p, q, z
- sage: p*q
+ sage: p * q # optional - sage.combinat sage.modules
z
- sage: q*p
+ sage: q * p # optional - sage.combinat sage.modules
-z
- sage: A.derivations_basis()
+ sage: A.derivations_basis() # optional - sage.combinat sage.modules
(
[1 0 0] [0 1 0] [0 0 0] [0 0 0] [0 0 0] [0 0 0]
[0 0 0] [0 0 0] [1 0 0] [0 1 0] [0 0 0] [0 0 0]
@@ -259,15 +267,16 @@ def derivations_basis(self):
We construct another example using the exterior algebra
and verify we obtain a derivation::
- sage: A = algebras.Exterior(QQ, 1)
- sage: A.derivations_basis()
+ sage: A = algebras.Exterior(QQ, 1) # optional - sage.combinat sage.modules
+ sage: A.derivations_basis() # optional - sage.combinat sage.modules
(
[0 0]
[0 1]
)
- sage: D = A.module_morphism(matrix=A.derivations_basis()[0], codomain=A)
- sage: one, e = A.basis()
- sage: all(D(a*b) == D(a) * b + a * D(b)
+ sage: D = A.module_morphism(matrix=A.derivations_basis()[0], # optional - sage.combinat sage.modules
+ ....: codomain=A)
+ sage: one, e = A.basis() # optional - sage.combinat sage.modules
+ sage: all(D(a*b) == D(a) * b + a * D(b) # optional - sage.combinat sage.modules
....: for a in A.basis() for b in A.basis())
True
diff --git a/src/sage/categories/map.pyx b/src/sage/categories/map.pyx
index 5a7445913bb..39d37acc2ae 100644
--- a/src/sage/categories/map.pyx
+++ b/src/sage/categories/map.pyx
@@ -115,7 +115,7 @@ cdef class Map(Element):
Using domain and codomain::
- sage: Map(QQ['x'], SymmetricGroup(6))
+ sage: Map(QQ['x'], SymmetricGroup(6)) # optional - sage.groups
Generic map:
From: Univariate Polynomial Ring in x over Rational Field
To: Symmetric group of order 6! as a permutation group
@@ -196,34 +196,44 @@ cdef class Map(Element):
EXAMPLES::
- sage: Q = QuadraticField(-5)
- sage: phi = CDF._internal_convert_map_from(Q)
- sage: print(phi.parent())
- Set of field embeddings from Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I to Complex Double Field
+ sage: Q = QuadraticField(-5) # optional - sage.rings.number_field
+ sage: phi = CDF._internal_convert_map_from(Q) # optional - sage.rings.number_field
+ sage: print(phi.parent()) # optional - sage.rings.number_field
+ Set of field embeddings
+ from Number Field in a with defining polynomial x^2 + 5
+ with a = 2.236067977499790?*I
+ to Complex Double Field
We now demonstrate that the reference to the coercion map `\phi` does
not prevent `Q` from being garbage collected::
sage: import gc
- sage: del Q
+ sage: del Q # optional - sage.rings.number_field
sage: _ = gc.collect()
- sage: phi.parent()
+ sage: phi.parent() # optional - sage.rings.number_field
Traceback (most recent call last):
...
- ValueError: This map is in an invalid state, the domain has been garbage collected
+ ValueError: This map is in an invalid state,
+ the domain has been garbage collected
You can still obtain copies of the maps used by the coercion system with
strong references::
- sage: Q = QuadraticField(-5)
- sage: phi = CDF.convert_map_from(Q)
- sage: print(phi.parent())
- Set of field embeddings from Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I to Complex Double Field
+ sage: Q = QuadraticField(-5) # optional - sage.rings.number_field
+ sage: phi = CDF.convert_map_from(Q) # optional - sage.rings.number_field
+ sage: print(phi.parent()) # optional - sage.rings.number_field
+ Set of field embeddings
+ from Number Field in a with defining polynomial x^2 + 5
+ with a = 2.236067977499790?*I
+ to Complex Double Field
sage: import gc
- sage: del Q
+ sage: del Q # optional - sage.rings.number_field
sage: _ = gc.collect()
- sage: phi.parent()
- Set of field embeddings from Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I to Complex Double Field
+ sage: phi.parent() # optional - sage.rings.number_field
+ Set of field embeddings
+ from Number Field in a with defining polynomial x^2 + 5
+ with a = 2.236067977499790?*I
+ to Complex Double Field
"""
if self._parent is None:
D = self.domain()
@@ -250,28 +260,31 @@ cdef class Map(Element):
EXAMPLES::
- sage: Q = QuadraticField(-5)
- sage: phi = CDF._internal_convert_map_from(Q)
+ sage: Q = QuadraticField(-5) # optional - sage.rings.number_field
+ sage: phi = CDF._internal_convert_map_from(Q) # optional - sage.rings.number_field
By :trac:`14711`, maps used in the coercion and conversion system
use *weak* references to domain and codomain, in contrast to other
maps::
- sage: phi.domain
+ sage: phi.domain # optional - sage.rings.number_field
- sage: phi._make_strong_references()
- sage: print(phi.domain)
- The constant function (...) -> Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
+ sage: phi._make_strong_references() # optional - sage.rings.number_field
+ sage: print(phi.domain) # optional - sage.rings.number_field
+ The constant function (...) -> Number Field in a
+ with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
Now, as there is a strong reference, `Q` cannot be garbage collected::
sage: import gc
sage: _ = gc.collect()
- sage: C = Q.__class__.__base__
- sage: numberQuadFields = len([x for x in gc.get_objects() if isinstance(x, C)])
- sage: del Q, x
+ sage: C = Q.__class__.__base__ # optional - sage.rings.number_field
+ sage: numberQuadFields = len([x for x in gc.get_objects() # optional - sage.rings.number_field
+ ....: if isinstance(x, C)])
+ sage: del Q, x # optional - sage.rings.number_field
sage: _ = gc.collect()
- sage: numberQuadFields == len([x for x in gc.get_objects() if isinstance(x, C)])
+ sage: numberQuadFields == len([x for x in gc.get_objects() # optional - sage.rings.number_field
+ ....: if isinstance(x, C)])
True
However, if we now make the references weak again, the number field can
@@ -279,11 +292,12 @@ cdef class Map(Element):
invalid. This is why :meth:`_make_weak_references` should only be used
if one really knows what one is doing::
- sage: phi._make_weak_references()
+ sage: phi._make_weak_references() # optional - sage.rings.number_field
sage: _ = gc.collect()
- sage: numberQuadFields == len([x for x in gc.get_objects() if isinstance(x, C)]) + 1
+ sage: numberQuadFields == len([x for x in gc.get_objects() # optional - sage.rings.number_field
+ ....: if isinstance(x, C)]) + 1
True
- sage: phi
+ sage: phi # optional - sage.rings.number_field
Defunct map
"""
if not isinstance(self.domain, ConstantFunction):
@@ -311,28 +325,31 @@ cdef class Map(Element):
EXAMPLES::
- sage: Q = QuadraticField(-5)
- sage: phi = CDF._internal_convert_map_from(Q)
+ sage: Q = QuadraticField(-5) # optional - sage.rings.number_field
+ sage: phi = CDF._internal_convert_map_from(Q) # optional - sage.rings.number_field
By :trac:`14711`, maps used in the coercion and conversion system
use *weak* references to domain and codomain, in contrast to other
maps::
- sage: phi.domain
+ sage: phi.domain # optional - sage.rings.number_field
- sage: phi._make_strong_references()
- sage: print(phi.domain)
- The constant function (...) -> Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
+ sage: phi._make_strong_references() # optional - sage.rings.number_field
+ sage: print(phi.domain) # optional - sage.rings.number_field
+ The constant function (...) -> Number Field in a
+ with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
Now, as there is a strong reference, `Q` cannot be garbage collected::
sage: import gc
sage: _ = gc.collect()
- sage: C = Q.__class__.__base__
- sage: numberQuadFields = len([x for x in gc.get_objects() if isinstance(x, C)])
- sage: del Q, x
+ sage: C = Q.__class__.__base__ # optional - sage.rings.number_field
+ sage: numberQuadFields = len([x for x in gc.get_objects() # optional - sage.rings.number_field
+ ....: if isinstance(x, C)])
+ sage: del Q, x # optional - sage.rings.number_field
sage: _ = gc.collect()
- sage: numberQuadFields == len([x for x in gc.get_objects() if isinstance(x, C)])
+ sage: numberQuadFields == len([x for x in gc.get_objects() # optional - sage.rings.number_field
+ ....: if isinstance(x, C)])
True
However, if we now make the references weak again, the number field can
@@ -340,17 +357,18 @@ cdef class Map(Element):
invalid. This is why :meth:`_make_weak_references` should only be used
if one really knows what one is doing::
- sage: phi._make_weak_references()
+ sage: phi._make_weak_references() # optional - sage.rings.number_field
sage: _ = gc.collect()
- sage: numberQuadFields == len([x for x in gc.get_objects() if isinstance(x, C)]) + 1
+ sage: numberQuadFields == len([x for x in gc.get_objects() # optional - sage.rings.number_field
+ ....: if isinstance(x, C)]) + 1
True
- sage: phi
+ sage: phi # optional - sage.rings.number_field
Defunct map
- sage: phi._make_strong_references()
+ sage: phi._make_strong_references() # optional - sage.rings.number_field
Traceback (most recent call last):
...
RuntimeError: The domain of this map became garbage collected
- sage: phi.parent()
+ sage: phi.parent() # optional - sage.rings.number_field
Traceback (most recent call last):
...
ValueError: This map is in an invalid state, the domain has been garbage collected
@@ -544,16 +562,16 @@ cdef class Map(Element):
TESTS::
- sage: Q = QuadraticField(-5)
- sage: phi = CDF._internal_coerce_map_from(Q); phi
+ sage: Q = QuadraticField(-5) # optional - sage.rings.number_field
+ sage: phi = CDF._internal_coerce_map_from(Q); phi # optional - sage.rings.number_field
(map internal to coercion system -- copy before use)
Composite map:
From: Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
To: Complex Double Field
- sage: del Q
+ sage: del Q # optional - sage.rings.number_field
sage: import gc
sage: _ = gc.collect()
- sage: phi
+ sage: phi # optional - sage.rings.number_field
Defunct map
"""
D = self.domain()
@@ -704,7 +722,8 @@ cdef class Map(Element):
sage: f(1/2)
Traceback (most recent call last):
...
- TypeError: 1/2 fails to convert into the map's domain Integer Ring, but a `pushforward` method is not properly implemented
+ TypeError: 1/2 fails to convert into the map's domain Integer Ring,
+ but a `pushforward` method is not properly implemented
We test that the default call method really works as described
above (that was fixed in :trac:`10496`)::
@@ -746,11 +765,11 @@ cdef class Map(Element):
``pushforward`` fails, ``_call_`` is tried after conversion::
sage: g = FOO(QQ, ZZ)
- sage: g(SR(3)) # optional - sage.symbolic
+ sage: g(SR(3)) # optional - sage.symbolic
pushforward Symbolic Ring
_call_ Rational Field
3
- sage: g(SR(3), exponent=2) # optional - sage.symbolic
+ sage: g(SR(3), exponent=2) # optional - sage.symbolic
pushforward Symbolic Ring
_call_with_args Rational Field
9
@@ -761,7 +780,8 @@ cdef class Map(Element):
sage: h(2/3)
Traceback (most recent call last):
...
- TypeError: 2/3 fails to convert into the map's domain Integer Ring, but a `pushforward` method is not properly implemented
+ TypeError: 2/3 fails to convert into the map's domain Integer Ring,
+ but a `pushforward` method is not properly implemented
"""
P = parent(x)
cdef Parent D = self.domain()
@@ -1122,7 +1142,8 @@ cdef class Map(Element):
sage: mor.extend_domain(ZZ['x'])
Traceback (most recent call last):
...
- TypeError: No coercion from Univariate Polynomial Ring in x over Integer Ring to Real Double Field
+ TypeError: No coercion from Univariate Polynomial Ring in x over Integer Ring
+ to Real Double Field
"""
D = self.domain()
if D is None:
@@ -1162,7 +1183,7 @@ cdef class Map(Element):
Native morphism:
From: Rational Field
To: Real Double Field
- sage: mor.extend_codomain(GF(7))
+ sage: mor.extend_codomain(GF(7)) # optional - sage.rings.finite_rings
Traceback (most recent call last):
...
TypeError: No coercion from Rational Field to Finite Field of size 7
@@ -1217,14 +1238,14 @@ cdef class Map(Element):
...
TypeError: self must be an endomorphism
- sage: K. = NumberField(x^4 - 5*x + 5)
- sage: C5. = CyclotomicField(5)
- sage: tau = K.hom([z - z^2]); tau
+ sage: K. = NumberField(x^4 - 5*x + 5) # optional - sage.rings.number_field
+ sage: C5. = CyclotomicField(5) # optional - sage.rings.number_field
+ sage: tau = K.hom([z - z^2]); tau # optional - sage.rings.number_field
Ring morphism:
From: Number Field in a with defining polynomial x^4 - 5*x + 5
To: Cyclotomic Field of order 5 and degree 4
Defn: a |--> -z^2 + z
- sage: tau^-1
+ sage: tau^-1 # optional - sage.rings.number_field
Ring morphism:
From: Cyclotomic Field of order 5 and degree 4
To: Number Field in a with defining polynomial x^4 - 5*x + 5
@@ -1851,24 +1872,26 @@ cdef class FormalCompositeMap(Map):
EXAMPLES::
- sage: V1 = QQ^2
- sage: V2 = QQ^3
- sage: phi1 = (QQ^1).hom(Matrix([[1, 1]]), V1)
- sage: phi2 = V1.hom(Matrix([[1, 2, 3], [4, 5, 6]]), V2)
+ sage: V1 = QQ^2 # optional - sage.modules
+ sage: V2 = QQ^3 # optional - sage.modules
+ sage: phi1 = (QQ^1).hom(Matrix([[1, 1]]), V1) # optional - sage.modules
+ sage: phi2 = V1.hom(Matrix([[1, 2, 3], [4, 5, 6]]), V2) # optional - sage.modules
If both constituents are injective, the composition is injective::
sage: from sage.categories.map import FormalCompositeMap
- sage: c1 = FormalCompositeMap(Hom(QQ^1, V2, phi1.category_for()), phi1, phi2)
- sage: c1.is_injective()
+ sage: c1 = FormalCompositeMap(Hom(QQ^1, V2, phi1.category_for()), # optional - sage.modules
+ ....: phi1, phi2)
+ sage: c1.is_injective() # optional - sage.modules
True
If it cannot be determined whether the composition is injective,
an error is raised::
- sage: psi1 = V2.hom(Matrix([[1, 2], [3, 4], [5, 6]]), V1)
- sage: c2 = FormalCompositeMap(Hom(V1, V1, phi2.category_for()), phi2, psi1)
- sage: c2.is_injective()
+ sage: psi1 = V2.hom(Matrix([[1, 2], [3, 4], [5, 6]]), V1) # optional - sage.modules
+ sage: c2 = FormalCompositeMap(Hom(V1, V1, phi2.category_for()), # optional - sage.modules
+ ....: phi2, psi1)
+ sage: c2.is_injective() # optional - sage.modules
Traceback (most recent call last):
...
NotImplementedError: not enough information to deduce injectivity
@@ -1876,17 +1899,18 @@ cdef class FormalCompositeMap(Map):
If the first map is surjective and the second map is not injective,
then the composition is not injective::
- sage: psi2 = V1.hom([[1], [1]], QQ^1)
- sage: c3 = FormalCompositeMap(Hom(V2, QQ^1, phi2.category_for()), psi2, psi1)
- sage: c3.is_injective()
+ sage: psi2 = V1.hom([[1], [1]], QQ^1) # optional - sage.modules
+ sage: c3 = FormalCompositeMap(Hom(V2, QQ^1, phi2.category_for()), # optional - sage.modules
+ ....: psi2, psi1)
+ sage: c3.is_injective() # optional - sage.modules
False
TESTS:
Check that :trac:`23205` has been resolved::
- sage: f = QQ.hom(QQbar)*ZZ.hom(QQ)
- sage: f.is_injective()
+ sage: f = QQ.hom(QQbar) * ZZ.hom(QQ) # optional - sage.rings.number_field
+ sage: f.is_injective() # optional - sage.rings.number_field
True
"""
@@ -1923,33 +1947,38 @@ cdef class FormalCompositeMap(Map):
EXAMPLES::
sage: from sage.categories.map import FormalCompositeMap
- sage: V3 = QQ^3
- sage: V2 = QQ^2
- sage: V1 = QQ^1
+ sage: V3 = QQ^3 # optional - sage.modules
+ sage: V2 = QQ^2 # optional - sage.modules
+ sage: V1 = QQ^1 # optional - sage.modules
If both maps are surjective, the composition is surjective::
- sage: phi32 = V3.hom(Matrix([[1, 2], [3, 4], [5, 6]]), V2)
- sage: phi21 = V2.hom(Matrix([[1], [1]]), V1)
- sage: c_phi = FormalCompositeMap(Hom(V3, V1, phi32.category_for()), phi32, phi21)
- sage: c_phi.is_surjective()
+ sage: phi32 = V3.hom(Matrix([[1, 2], [3, 4], [5, 6]]), V2) # optional - sage.modules
+ sage: phi21 = V2.hom(Matrix([[1], [1]]), V1) # optional - sage.modules
+ sage: c_phi = FormalCompositeMap(Hom(V3, V1, phi32.category_for()), # optional - sage.modules
+ ....: phi32, phi21)
+ sage: c_phi.is_surjective() # optional - sage.modules
True
If the second map is not surjective, the composition is not
surjective::
- sage: FormalCompositeMap(Hom(V3, V1, phi32.category_for()), phi32, V2.hom(Matrix([[0], [0]]), V1)).is_surjective()
+ sage: FormalCompositeMap(Hom(V3, V1, phi32.category_for()), # optional - sage.modules
+ ....: phi32,
+ ....: V2.hom(Matrix([[0], [0]]), V1)).is_surjective()
False
If the second map is an isomorphism and the first map is not
surjective, then the composition is not surjective::
- sage: FormalCompositeMap(Hom(V2, V1, phi32.category_for()), V2.hom(Matrix([[0], [0]]), V1), V1.hom(Matrix([[1]]), V1)).is_surjective()
+ sage: FormalCompositeMap(Hom(V2, V1, phi32.category_for()), # optional - sage.modules
+ ....: V2.hom(Matrix([[0], [0]]), V1),
+ ....: V1.hom(Matrix([[1]]), V1)).is_surjective()
False
Otherwise, surjectivity of the composition cannot be determined::
- sage: FormalCompositeMap(Hom(V2, V1, phi32.category_for()),
+ sage: FormalCompositeMap(Hom(V2, V1, phi32.category_for()), # optional - sage.modules
....: V2.hom(Matrix([[1, 1], [1, 1]]), V2),
....: V2.hom(Matrix([[1], [1]]), V1)).is_surjective()
Traceback (most recent call last):
@@ -1991,8 +2020,8 @@ cdef class FormalCompositeMap(Map):
EXAMPLES::
sage: f = QQ.coerce_map_from(ZZ)
- sage: g = MatrixSpace(QQ, 2, 2).coerce_map_from(QQ)
- sage: list((g*f).domains())
+ sage: g = MatrixSpace(QQ, 2, 2).coerce_map_from(QQ) # optional - sage.modules
+ sage: list((g * f).domains()) # optional - sage.modules
[Integer Ring, Rational Field]
"""
for f in self.__list:
@@ -2026,9 +2055,9 @@ cdef class FormalCompositeMap(Map):
of :class:`sage.rings.polynomial.polynomial_element.Polynomial`
before (see comment there)::
- sage: k = GF(47)
- sage: R. = PolynomialRing(k)
- sage: R.coerce_map_from(ZZ).section()
+ sage: k = GF(47) # optional - sage.rings.finite_rings
+ sage: R. = PolynomialRing(k) # optional - sage.rings.finite_rings
+ sage: R.coerce_map_from(ZZ).section() # optional - sage.rings.finite_rings
Composite map:
From: Univariate Polynomial Ring in x over Finite Field of size 47
To: Integer Ring
@@ -2039,9 +2068,9 @@ cdef class FormalCompositeMap(Map):
Lifting map:
From: Finite Field of size 47
To: Integer Ring
- sage: ZZ(R(45)) # indirect doctest
+ sage: ZZ(R(45)) # indirect doctest # optional - sage.rings.finite_rings
45
- sage: ZZ(3*x + 45) # indirect doctest
+ sage: ZZ(3*x + 45) # indirect doctest # optional - sage.rings.finite_rings
Traceback (most recent call last):
...
TypeError: not a constant polynomial
diff --git a/src/sage/categories/modules.py b/src/sage/categories/modules.py
index cb878f1c6f2..81f6df6f51f 100644
--- a/src/sage/categories/modules.py
+++ b/src/sage/categories/modules.py
@@ -72,10 +72,12 @@ class Modules(Category_module):
Category of modules over Ring of integers modulo 9
sage: Modules(Integers(9)).super_categories()
- [Category of bimodules over Ring of integers modulo 9 on the left and Ring of integers modulo 9 on the right]
+ [Category of bimodules over Ring of integers modulo 9 on the left
+ and Ring of integers modulo 9 on the right]
sage: Modules(ZZ).super_categories()
- [Category of bimodules over Integer Ring on the left and Integer Ring on the right]
+ [Category of bimodules over Integer Ring on the left
+ and Integer Ring on the right]
sage: Modules == RingModules
True
@@ -162,7 +164,8 @@ def super_categories(self):
EXAMPLES::
sage: Modules(ZZ).super_categories()
- [Category of bimodules over Integer Ring on the left and Integer Ring on the right]
+ [Category of bimodules over Integer Ring on the left
+ and Integer Ring on the right]
Nota bene::
@@ -204,7 +207,8 @@ def base_ring(self):
EXAMPLES::
sage: C = Modules(QQ) & Semigroups(); C
- Join of Category of semigroups and Category of vector spaces over Rational Field
+ Join of Category of semigroups
+ and Category of vector spaces over Rational Field
sage: C.base_ring()
Rational Field
sage: C.base_ring.__module__
@@ -217,16 +221,16 @@ def base_ring(self):
sage: C.base_ring.__module__
'sage.categories.modules'
- sage: C = DescentAlgebra(QQ,3).B().category()
- sage: C.base_ring.__module__
+ sage: C = DescentAlgebra(QQ,3).B().category() # optional - sage.combinat sage.modules
+ sage: C.base_ring.__module__ # optional - sage.combinat sage.modules
'sage.categories.modules'
- sage: C.base_ring()
+ sage: C.base_ring() # optional - sage.combinat sage.modules
Rational Field
- sage: C = QuasiSymmetricFunctions(QQ).F().category()
- sage: C.base_ring.__module__
+ sage: C = QuasiSymmetricFunctions(QQ).F().category() # optional - sage.combinat sage.modules
+ sage: C.base_ring.__module__ # optional - sage.combinat sage.modules
'sage.categories.modules'
- sage: C.base_ring()
+ sage: C.base_ring() # optional - sage.combinat sage.modules
Rational Field
"""
for C in self.super_categories():
@@ -361,10 +365,11 @@ def FinitelyPresented(self):
sage: Modules(ZZ).FinitelyPresented()
Category of finitely presented modules over Integer Ring
- sage: A = SteenrodAlgebra(2)
- sage: from sage.modules.fp_graded.module import FPModule
- sage: FPModule(A, [0, 1], [[Sq(2), Sq(1)]]).category()
- Category of finitely presented graded modules over mod 2 Steenrod algebra, milnor basis
+ sage: A = SteenrodAlgebra(2) # optional - sage.combinat sage.modules
+ sage: from sage.modules.fp_graded.module import FPModule # optional - sage.combinat sage.modules
+ sage: FPModule(A, [0, 1], [[Sq(2), Sq(1)]]).category() # optional - sage.combinat sage.modules
+ Category of finitely presented graded modules
+ over mod 2 Steenrod algebra, milnor basis
TESTS::
@@ -516,7 +521,7 @@ def extra_super_categories(self):
[Category of finite sets]
sage: Modules(ZZ).FiniteDimensional().extra_super_categories()
[]
- sage: Modules(GF(5)).FiniteDimensional().is_subcategory(Sets().Finite())
+ sage: Modules(GF(5)).FiniteDimensional().is_subcategory(Sets().Finite()) # optional - sage.rings.finite_rings
True
sage: Modules(ZZ).FiniteDimensional().is_subcategory(Sets().Finite())
False
@@ -547,7 +552,8 @@ def extra_super_categories(self):
sage: Modules(ZZ).FiniteDimensional().TensorProducts().extra_super_categories()
[Category of finite dimensional modules over Integer Ring]
sage: Modules(QQ).FiniteDimensional().TensorProducts().FiniteDimensional()
- Category of tensor products of finite dimensional vector spaces over Rational Field
+ Category of tensor products of finite dimensional vector spaces
+ over Rational Field
"""
return [self.base_category()]
@@ -565,7 +571,7 @@ def extra_super_categories(self):
[Category of finite sets]
sage: Modules(ZZ).FiniteDimensional().extra_super_categories()
[]
- sage: Modules(GF(5)).FiniteDimensional().is_subcategory(Sets().Finite())
+ sage: Modules(GF(5)).FiniteDimensional().is_subcategory(Sets().Finite()) # optional - sage.rings.finite_rings
True
sage: Modules(ZZ).FiniteDimensional().is_subcategory(Sets().Finite())
False
@@ -612,9 +618,9 @@ def linear_combination(self, iter_of_elements_coeff, factor_on_left=True):
EXAMPLES::
- sage: m = matrix([[0,1],[1,1]])
- sage: J. = JordanAlgebra(m)
- sage: J.linear_combination(((a+b, 1), (-2*b + c, -1)))
+ sage: m = matrix([[0,1], [1,1]]) # optional - sage.modules
+ sage: J. = JordanAlgebra(m) # optional - sage.combinat sage.modules
+ sage: J.linear_combination(((a+b, 1), (-2*b + c, -1))) # optional - sage.combinat sage.modules
1 + (3, -1)
"""
if factor_on_left:
@@ -631,8 +637,8 @@ def tensor_square(self):
EXAMPLES::
- sage: A = HopfAlgebrasWithBasis(QQ).example()
- sage: A.tensor_square()
+ sage: A = HopfAlgebrasWithBasis(QQ).example() # optional - sage.groups sage.modules
+ sage: A.tensor_square() # optional - sage.groups sage.modules
An example of Hopf algebra with basis:
the group algebra of the Dihedral group of order 6
as a permutation group over Rational Field # An example
@@ -661,12 +667,14 @@ def module_morphism(self, *, function, category=None, codomain, **keywords):
EXAMPLES::
- sage: V = FiniteRankFreeModule(QQ, 2)
- sage: e = V.basis('e'); e
- Basis (e_0,e_1) on the 2-dimensional vector space over the Rational Field
- sage: neg = V.module_morphism(function=operator.neg, codomain=V); neg
- Generic endomorphism of 2-dimensional vector space over the Rational Field
- sage: neg(e[0])
+ sage: V = FiniteRankFreeModule(QQ, 2) # optional - sage.modules
+ sage: e = V.basis('e'); e # optional - sage.modules
+ Basis (e_0,e_1) on the
+ 2-dimensional vector space over the Rational Field
+ sage: neg = V.module_morphism(function=operator.neg, codomain=V); neg # optional - sage.modules
+ Generic endomorphism of
+ 2-dimensional vector space over the Rational Field
+ sage: neg(e[0]) # optional - sage.modules
Element -e_0 of the 2-dimensional vector space over the Rational Field
"""
@@ -698,11 +706,12 @@ def quotient(self, submodule, check=True, **kwds):
EXAMPLES::
- sage: C = CombinatorialFreeModule(QQ, ['a','b','c'])
- sage: TA = TensorAlgebra(C)
- sage: TA.quotient
+ sage: C = CombinatorialFreeModule(QQ, ['a','b','c']) # optional - sage.modules
+ sage: TA = TensorAlgebra(C) # optional - sage.modules
+ sage: TA.quotient # optional - sage.modules
+ Tensor Algebra of Free module generated by {'a', 'b', 'c'}
+ over Rational Field>
"""
return self.quotient_module(submodule, check=check, **kwds)
@@ -748,21 +757,21 @@ def base_ring(self):
EXAMPLES::
- sage: E = CombinatorialFreeModule(ZZ, [1,2,3])
- sage: F = CombinatorialFreeModule(ZZ, [2,3,4])
- sage: H = Hom(E, F)
- sage: H.base_ring()
+ sage: E = CombinatorialFreeModule(ZZ, [1,2,3]) # optional - sage.modules
+ sage: F = CombinatorialFreeModule(ZZ, [2,3,4]) # optional - sage.modules
+ sage: H = Hom(E, F) # optional - sage.modules
+ sage: H.base_ring() # optional - sage.modules
Integer Ring
This ``base_ring`` method is actually overridden by
:meth:`sage.structure.category_object.CategoryObject.base_ring`::
- sage: H.base_ring.__module__
+ sage: H.base_ring.__module__ # optional - sage.modules
Here we call it directly::
- sage: method = H.category().parent_class.base_ring
- sage: method.__get__(H)()
+ sage: method = H.category().parent_class.base_ring # optional - sage.modules
+ sage: method.__get__(H)() # optional - sage.modules
Integer Ring
"""
return self.domain().base_ring()
@@ -772,24 +781,24 @@ def zero(self):
"""
EXAMPLES::
- sage: E = CombinatorialFreeModule(ZZ, [1,2,3])
- sage: F = CombinatorialFreeModule(ZZ, [2,3,4])
- sage: H = Hom(E, F)
- sage: f = H.zero()
- sage: f
+ sage: E = CombinatorialFreeModule(ZZ, [1,2,3]) # optional - sage.modules
+ sage: F = CombinatorialFreeModule(ZZ, [2,3,4]) # optional - sage.modules
+ sage: H = Hom(E, F) # optional - sage.modules
+ sage: f = H.zero() # optional - sage.modules
+ sage: f # optional - sage.modules
Generic morphism:
From: Free module generated by {1, 2, 3} over Integer Ring
To: Free module generated by {2, 3, 4} over Integer Ring
- sage: f(E.monomial(2))
+ sage: f(E.monomial(2)) # optional - sage.modules
0
- sage: f(E.monomial(3)) == F.zero()
+ sage: f(E.monomial(3)) == F.zero() # optional - sage.modules
True
TESTS:
We check that ``H.zero()`` is picklable::
- sage: loads(dumps(f.parent().zero()))
+ sage: loads(dumps(f.parent().zero())) # optional - sage.modules
Generic morphism:
From: Free module generated by {1, 2, 3} over Integer Ring
To: Free module generated by {2, 3, 4} over Integer Ring
@@ -813,7 +822,7 @@ def extra_super_categories(self):
sage: Modules(ZZ).Endsets().extra_super_categories()
[Category of magmatic algebras over Integer Ring]
- sage: End(ZZ^3) in Algebras(ZZ)
+ sage: End(ZZ^3) in Algebras(ZZ) # optional - sage.modules
True
"""
from .magmatic_algebras import MagmaticAlgebras
@@ -852,38 +861,46 @@ def __init_extra__(self):
EXAMPLES::
- sage: E = CombinatorialFreeModule(ZZ, [1,2,3])
- sage: F = CombinatorialFreeModule(ZZ, [2,3,4])
- sage: C = cartesian_product([E, F]); C
+ sage: E = CombinatorialFreeModule(ZZ, [1,2,3]) # optional - sage.modules
+ sage: F = CombinatorialFreeModule(ZZ, [2,3,4]) # optional - sage.modules
+ sage: C = cartesian_product([E, F]); C # optional - sage.modules
Free module generated by {1, 2, 3} over Integer Ring (+)
Free module generated by {2, 3, 4} over Integer Ring
- sage: C.base_ring()
+ sage: C.base_ring() # optional - sage.modules
Integer Ring
Check that :trac:`29225` is fixed::
- sage: M = cartesian_product((ZZ^2, ZZ^3)); M
- The Cartesian product of (Ambient free module of rank 2 over the principal ideal domain Integer Ring, Ambient free module of rank 3 over the principal ideal domain Integer Ring)
- sage: M.category()
- Category of Cartesian products of modules with basis over (euclidean domains and infinite enumerated sets and metric spaces)
- sage: M.base_ring()
+ sage: M = cartesian_product((ZZ^2, ZZ^3)); M # optional - sage.modules
+ The Cartesian product of
+ (Ambient free module of rank 2 over the principal ideal domain Integer Ring,
+ Ambient free module of rank 3 over the principal ideal domain Integer Ring)
+ sage: M.category() # optional - sage.modules
+ Category of Cartesian products of modules with basis
+ over (euclidean domains and infinite enumerated sets and metric spaces)
+ sage: M.base_ring() # optional - sage.modules
Integer Ring
- sage: A = cartesian_product((QQ^2, QQ['x'])); A
- The Cartesian product of (Vector space of dimension 2 over Rational Field, Univariate Polynomial Ring in x over Rational Field)
- sage: A.category()
- Category of Cartesian products of vector spaces over (number fields and quotient fields and metric spaces)
- sage: A.base_ring()
+ sage: A = cartesian_product((QQ^2, QQ['x'])); A # optional - sage.modules
+ The Cartesian product of
+ (Vector space of dimension 2 over Rational Field,
+ Univariate Polynomial Ring in x over Rational Field)
+ sage: A.category() # optional - sage.modules
+ Category of Cartesian products of vector spaces
+ over (number fields and quotient fields and metric spaces)
+ sage: A.base_ring() # optional - sage.modules
Rational Field
This currently only works if all factors have the same
base ring::
- sage: B = cartesian_product((ZZ['x'], QQ^3)); B
- The Cartesian product of (Univariate Polynomial Ring in x over Integer Ring, Vector space of dimension 3 over Rational Field)
- sage: B.category()
+ sage: B = cartesian_product((ZZ['x'], QQ^3)); B # optional - sage.modules
+ The Cartesian product of
+ (Univariate Polynomial Ring in x over Integer Ring,
+ Vector space of dimension 3 over Rational Field)
+ sage: B.category() # optional - sage.modules
Category of Cartesian products of commutative additive groups
- sage: B.base_ring()
+ sage: B.base_ring() # optional - sage.modules
"""
factors = self._sets
if factors:
@@ -899,10 +916,12 @@ def _lmul_(self, x):
EXAMPLES::
- sage: A = FreeModule(ZZ, 2)
- sage: B = cartesian_product([A, A]); B
- The Cartesian product of (Ambient free module of rank 2 over the principal ideal domain Integer Ring, Ambient free module of rank 2 over the principal ideal domain Integer Ring)
- sage: 5*B(([1, 2], [3, 4]))
+ sage: A = FreeModule(ZZ, 2) # optional - sage.modules
+ sage: B = cartesian_product([A, A]); B # optional - sage.modules
+ The Cartesian product of
+ (Ambient free module of rank 2 over the principal ideal domain Integer Ring,
+ Ambient free module of rank 2 over the principal ideal domain Integer Ring)
+ sage: 5*B(([1, 2], [3, 4])) # optional - sage.modules
((5, 10), (15, 20))
"""
return self.parent()._cartesian_product_of_elements(
@@ -934,9 +953,9 @@ def construction(self):
EXAMPLES::
- sage: A = algebras.Free(QQ,2)
- sage: T = A.tensor(A)
- sage: T.construction()
+ sage: A = algebras.Free(QQ, 2) # optional - sage.combinat sage.modules
+ sage: T = A.tensor(A) # optional - sage.combinat sage.modules
+ sage: T.construction() # optional - sage.combinat sage.modules
(The tensor functorial construction,
(Free Algebra on 2 generators (None0, None1) over Rational Field,
Free Algebra on 2 generators (None0, None1) over Rational Field))
@@ -957,20 +976,20 @@ def tensor_factors(self):
EXAMPLES::
- sage: F = CombinatorialFreeModule(ZZ, [1,2])
- sage: F.rename("F")
- sage: G = CombinatorialFreeModule(ZZ, [3,4])
- sage: G.rename("G")
- sage: T = tensor([F, G]); T
+ sage: F = CombinatorialFreeModule(ZZ, [1,2]) # optional - sage.modules
+ sage: F.rename("F") # optional - sage.modules
+ sage: G = CombinatorialFreeModule(ZZ, [3,4]) # optional - sage.modules
+ sage: G.rename("G") # optional - sage.modules
+ sage: T = tensor([F, G]); T # optional - sage.modules
F # G
- sage: T.tensor_factors()
+ sage: T.tensor_factors() # optional - sage.modules
(F, G)
TESTS::
- sage: M = CombinatorialFreeModule(ZZ, ((1, 1), (1, 2), (2, 1), (2, 2)),
- ....: category=ModulesWithBasis(ZZ).FiniteDimensional().TensorProducts())
- sage: M.construction()
+ sage: Cat = ModulesWithBasis(ZZ).FiniteDimensional().TensorProducts() # optional - sage.modules
+ sage: M = CombinatorialFreeModule(ZZ, ((1, 1), (1, 2), (2, 1), (2, 2)), category=Cat) # optional - sage.modules
+ sage: M.construction() # optional - sage.modules
doctest:warning...
DeprecationWarning: implementations of Modules().TensorProducts() now must define the method tensor_factors
See https://github.com/sagemath/sage/issues/34393 for details.
diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
index 99b57ff8c8e..9f31917cf22 100644
--- a/src/sage/categories/modules_with_basis.py
+++ b/src/sage/categories/modules_with_basis.py
@@ -66,22 +66,23 @@ class ModulesWithBasis(CategoryWithAxiom_over_base_ring):
Let `X` and `Y` be two modules with basis. We can build `Hom(X,Y)`::
- sage: X = CombinatorialFreeModule(QQ, [1,2]); X.__custom_name = "X"
- sage: Y = CombinatorialFreeModule(QQ, [3,4]); Y.__custom_name = "Y"
- sage: H = Hom(X, Y); H
- Set of Morphisms from X to Y in Category of finite dimensional vector spaces with basis over Rational Field
+ sage: X = CombinatorialFreeModule(QQ, [1,2]); X.__custom_name = "X" # optional - sage.modules
+ sage: Y = CombinatorialFreeModule(QQ, [3,4]); Y.__custom_name = "Y" # optional - sage.modules
+ sage: H = Hom(X, Y); H # optional - sage.modules
+ Set of Morphisms from X to Y
+ in Category of finite dimensional vector spaces with basis over Rational Field
The simplest morphism is the zero map::
- sage: H.zero() # todo: move this test into module once we have an example
+ sage: H.zero() # todo: move this test into module once we have an example # optional - sage.modules
Generic morphism:
From: X
To: Y
which we can apply to elements of `X`::
- sage: x = X.monomial(1) + 3 * X.monomial(2)
- sage: H.zero()(x)
+ sage: x = X.monomial(1) + 3 * X.monomial(2) # optional - sage.modules
+ sage: H.zero()(x) # optional - sage.modules
0
EXAMPLES:
@@ -89,17 +90,17 @@ class ModulesWithBasis(CategoryWithAxiom_over_base_ring):
We now construct a more interesting morphism by extending a
function by linearity::
- sage: phi = H(on_basis = lambda i: Y.monomial(i+2)); phi
+ sage: phi = H(on_basis=lambda i: Y.monomial(i + 2)); phi # optional - sage.modules
Generic morphism:
From: X
To: Y
- sage: phi(x)
+ sage: phi(x) # optional - sage.modules
B[3] + 3*B[4]
We can retrieve the function acting on indices of the basis::
- sage: f = phi.on_basis()
- sage: f(1), f(2)
+ sage: f = phi.on_basis() # optional - sage.modules
+ sage: f(1), f(2) # optional - sage.modules
(B[3], B[4])
`Hom(X,Y)` has a natural module structure (except for the zero,
@@ -108,14 +109,14 @@ class ModulesWithBasis(CategoryWithAxiom_over_base_ring):
basis; but see :class:`FiniteDimensionalModulesWithBasis` and
:class:`GradedModulesWithBasis`::
- sage: H in ModulesWithBasis(QQ), H in Modules(QQ)
+ sage: H in ModulesWithBasis(QQ), H in Modules(QQ) # optional - sage.modules
(False, True)
Some more playing around with categories and higher order homsets::
- sage: H.category()
+ sage: H.category() # optional - sage.modules
Category of homsets of modules with basis over Rational Field
- sage: Hom(H, H).category()
+ sage: Hom(H, H).category() # optional - sage.modules
Category of endsets of homsets of modules with basis over Rational Field
.. TODO:: ``End(X)`` is an algebra.
@@ -128,10 +129,10 @@ class ModulesWithBasis(CategoryWithAxiom_over_base_ring):
TESTS::
- sage: f = H.zero().on_basis()
- sage: f(1)
+ sage: f = H.zero().on_basis() # optional - sage.modules
+ sage: f(1) # optional - sage.modules
0
- sage: f(2)
+ sage: f(2) # optional - sage.modules
0
sage: TestSuite(ModulesWithBasis(ZZ)).run()
@@ -151,20 +152,20 @@ def _call_(self, x):
``x`` is returned unchanged if it is already in this category::
- sage: CZ(CombinatorialFreeModule(ZZ, ('a','b','c')))
+ sage: CZ(CombinatorialFreeModule(ZZ, ('a', 'b', 'c'))) # optional - sage.modules
Free module generated by {'a', 'b', 'c'} over Integer Ring
- sage: CZ(ZZ^3)
+ sage: CZ(ZZ^3) # optional - sage.modules
Ambient free module of rank 3 over the principal ideal domain Integer Ring
If needed (and possible) the base ring is changed appropriately::
- sage: CQ(ZZ^3) # indirect doctest
+ sage: CQ(ZZ^3) # indirect doctest # optional - sage.modules
Vector space of dimension 3 over Rational Field
If ``x`` itself is not a module with basis, but there is a
canonical one associated to it, the latter is returned::
- sage: CQ(AbelianVariety(Gamma0(37))) # indirect doctest
+ sage: CQ(AbelianVariety(Gamma0(37))) # indirect doctest # optional - sage.modules
Vector space of dimension 4 over Rational Field
"""
try:
@@ -209,14 +210,14 @@ def basis(self):
EXAMPLES::
- sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
- sage: F.basis()
+ sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # optional - sage.modules
+ sage: F.basis() # optional - sage.modules
Finite family {'a': B['a'], 'b': B['b'], 'c': B['c']}
::
- sage: QS3 = SymmetricGroupAlgebra(QQ,3)
- sage: list(QS3.basis())
+ sage: QS3 = SymmetricGroupAlgebra(QQ, 3) # optional - sage.group sage.modules
+ sage: list(QS3.basis()) # optional - sage.group sage.modules
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
"""
from sage.sets.family import Family
@@ -297,14 +298,16 @@ def module_morphism(self, on_basis=None, matrix=None, function=None,
::
- sage: X = CombinatorialFreeModule(QQ, [1,2,3]); X.rename("X")
- sage: Y = CombinatorialFreeModule(QQ, [1,2,3,4]); Y.rename("Y")
- sage: phi = X.module_morphism(lambda i: Y.monomial(i) + 2*Y.monomial(i+1), codomain = Y)
- sage: x = X.basis(); y = Y.basis()
- sage: phi(x[1] + x[3])
+ sage: X = CombinatorialFreeModule(QQ, [1,2,3]); X.rename("X") # optional - sage.modules
+ sage: Y = CombinatorialFreeModule(QQ, [1,2,3,4]); Y.rename("Y") # optional - sage.modules
+ sage: def f(i):
+ ....: return Y.monomial(i) + 2*Y.monomial(i+1)
+ sage: phi = X.module_morphism(f, codomain=Y) # optional - sage.modules
+ sage: x = X.basis(); y = Y.basis() # optional - sage.modules
+ sage: phi(x[1] + x[3]) # optional - sage.modules
B[1] + 2*B[2] + B[3] + 2*B[4]
- sage: phi
+ sage: phi # optional - sage.modules
Generic morphism:
From: X
To: Y
@@ -315,101 +318,105 @@ def module_morphism(self, on_basis=None, matrix=None, function=None,
``CommutativeAdditiveMonoids()`` that contains both the
domain and the codomain::
- sage: phi.category_for()
- Category of finite dimensional vector spaces with basis over Rational Field
+ sage: phi.category_for() # optional - sage.modules
+ Category of finite dimensional vector spaces with basis
+ over Rational Field
With the ``zero`` argument, one can define affine morphisms::
- sage: phi = X.module_morphism(lambda i: Y.monomial(i) + 2*Y.monomial(i+1),
- ....: codomain = Y, zero = 10*y[1])
- sage: phi(x[1] + x[3])
+ sage: def f(i):
+ ....: return Y.monomial(i) + 2*Y.monomial(i+1)
+ sage: phi = X.module_morphism(f, codomain=Y, zero=10*y[1]) # optional - sage.modules
+ sage: phi(x[1] + x[3]) # optional - sage.modules
11*B[1] + 2*B[2] + B[3] + 2*B[4]
In this special case, the default category is ``Sets()``::
- sage: phi.category_for()
+ sage: phi.category_for() # optional - sage.modules
Category of sets
One can construct morphisms with the base ring as codomain::
- sage: X = CombinatorialFreeModule(ZZ,[1,-1])
- sage: phi = X.module_morphism( on_basis=lambda i: i, codomain=ZZ )
- sage: phi( 2 * X.monomial(1) + 3 * X.monomial(-1) )
+ sage: X = CombinatorialFreeModule(ZZ, [1, -1]) # optional - sage.modules
+ sage: phi = X.module_morphism(on_basis=lambda i: i, codomain=ZZ) # optional - sage.modules
+ sage: phi(2 * X.monomial(1) + 3 * X.monomial(-1)) # optional - sage.modules
-1
- sage: phi.category_for()
+ sage: phi.category_for() # optional - sage.modules
Category of commutative additive semigroups
- sage: phi.category_for() # todo: not implemented (ZZ is currently not in Modules(ZZ))
+ sage: phi.category_for() # todo: not implemented (ZZ is currently not in Modules(ZZ)) # optional - sage.modules
Category of modules over Integer Ring
Or more generally any ring admitting a coercion map from
the base ring::
- sage: phi = X.module_morphism(on_basis=lambda i: i, codomain=RR )
- sage: phi( 2 * X.monomial(1) + 3 * X.monomial(-1) )
+ sage: phi = X.module_morphism(on_basis=lambda i: i, codomain=RR) # optional - sage.modules
+ sage: phi(2 * X.monomial(1) + 3 * X.monomial(-1)) # optional - sage.modules
-1.00000000000000
- sage: phi.category_for()
+ sage: phi.category_for() # optional - sage.modules
Category of commutative additive semigroups
- sage: phi.category_for() # todo: not implemented (RR is currently not in Modules(ZZ))
+ sage: phi.category_for() # todo: not implemented (RR is currently not in Modules(ZZ)) # optional - sage.modules
Category of modules over Integer Ring
- sage: phi = X.module_morphism(on_basis=lambda i: i, codomain=Zmod(4) )
- sage: phi( 2 * X.monomial(1) + 3 * X.monomial(-1) )
+ sage: phi = X.module_morphism(on_basis=lambda i: i, codomain=Zmod(4)) # optional - sage.modules
+ sage: phi(2 * X.monomial(1) + 3 * X.monomial(-1)) # optional - sage.modules
3
- sage: phi = Y.module_morphism(on_basis=lambda i: i, codomain=Zmod(4) )
+ sage: phi = Y.module_morphism(on_basis=lambda i: i, codomain=Zmod(4)) # optional - sage.modules
Traceback (most recent call last):
...
- ValueError: codomain(=Ring of integers modulo 4) should be a module over the base ring of the domain(=Y)
+ ValueError: codomain(=Ring of integers modulo 4) should be a module
+ over the base ring of the domain(=Y)
On can also define module morphisms between free modules
over different base rings; here we implement the natural
map from `X = \RR^2` to `Y = \CC`::
- sage: X = CombinatorialFreeModule(RR,['x','y'])
- sage: Y = CombinatorialFreeModule(CC,['z'])
- sage: x = X.monomial('x')
- sage: y = X.monomial('y')
- sage: z = Y.monomial('z')
- sage: def on_basis( a ):
+ sage: X = CombinatorialFreeModule(RR, ['x', 'y']) # optional - sage.modules
+ sage: Y = CombinatorialFreeModule(CC, ['z']) # optional - sage.modules
+ sage: x = X.monomial('x') # optional - sage.modules
+ sage: y = X.monomial('y') # optional - sage.modules
+ sage: z = Y.monomial('z') # optional - sage.modules
+ sage: def on_basis(a): # optional - sage.modules
....: if a == 'x':
....: return CC(1) * z
....: elif a == 'y':
....: return CC(I) * z
- sage: phi = X.module_morphism( on_basis=on_basis, codomain=Y )
- sage: v = 3 * x + 2 * y; v
+ sage: phi = X.module_morphism(on_basis=on_basis, codomain=Y) # optional - sage.modules
+ sage: v = 3 * x + 2 * y; v # optional - sage.modules
3.00000000000000*B['x'] + 2.00000000000000*B['y']
- sage: phi(v)
+ sage: phi(v) # optional - sage.modules
(3.00000000000000+2.00000000000000*I)*B['z']
- sage: phi.category_for()
+ sage: phi.category_for() # optional - sage.modules
Category of commutative additive semigroups
- sage: phi.category_for() # todo: not implemented (CC is currently not in Modules(RR)!)
+ sage: phi.category_for() # todo: not implemented (CC is currently not in Modules(RR)!) # optional - sage.modules
Category of vector spaces over Real Field with 53 bits of precision
- sage: Y = CombinatorialFreeModule(CC['q'],['z'])
- sage: z = Y.monomial('z')
- sage: phi = X.module_morphism( on_basis=on_basis, codomain=Y )
- sage: phi(v)
+ sage: Y = CombinatorialFreeModule(CC['q'], ['z']) # optional - sage.modules
+ sage: z = Y.monomial('z') # optional - sage.modules
+ sage: phi = X.module_morphism(on_basis=on_basis, codomain=Y) # optional - sage.modules
+ sage: phi(v) # optional - sage.modules
(3.00000000000000+2.00000000000000*I)*B['z']
Of course, there should be a coercion between the
respective base rings of the domain and the codomain for
this to be meaningful::
- sage: Y = CombinatorialFreeModule(QQ,['z'])
- sage: phi = X.module_morphism( on_basis=on_basis, codomain=Y )
+ sage: Y = CombinatorialFreeModule(QQ, ['z']) # optional - sage.modules
+ sage: phi = X.module_morphism(on_basis=on_basis, codomain=Y) # optional - sage.modules
Traceback (most recent call last):
...
ValueError: codomain(=Free module generated by {'z'} over Rational Field)
- should be a module over the base ring of the
- domain(=Free module generated by {'x', 'y'} over Real Field with 53 bits of precision)
+ should be a module over the base ring of the domain(=Free module
+ generated by {'x', 'y'} over Real Field with 53 bits of precision)
- sage: Y = CombinatorialFreeModule(RR['q'],['z'])
- sage: phi = Y.module_morphism( on_basis=on_basis, codomain=X )
+ sage: Y = CombinatorialFreeModule(RR['q'], ['z']) # optional - sage.modules
+ sage: phi = Y.module_morphism(on_basis=on_basis, codomain=X) # optional - sage.modules
Traceback (most recent call last):
...
- ValueError: codomain(=Free module generated by {'x', 'y'} over Real Field with 53 bits of precision)
- should be a module over the base ring of the
- domain(=Free module generated by {'z'} over Univariate Polynomial Ring in q over Real Field with 53 bits of precision)
+ ValueError: codomain(=Free module generated by {'x', 'y'}
+ over Real Field with 53 bits of precision) should be a module over
+ the base ring of the domain(=Free module generated by {'z'} over
+ Univariate Polynomial Ring in q over Real Field with 53 bits of precision)
With the ``diagonal=d`` argument, this constructs the
@@ -422,11 +429,11 @@ def module_morphism(self, on_basis=None, matrix=None, function=None,
This assumes that the respective bases `x` and `y` of `X`
and `Y` have the same index set `I`::
- sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X")
- sage: from sage.arith.misc import factorial
- sage: phi = X.module_morphism(diagonal=factorial, codomain=X)
- sage: x = X.basis()
- sage: phi(x[1]), phi(x[2]), phi(x[3])
+ sage: X = CombinatorialFreeModule(ZZ, [1, 2, 3]); X.rename("X") # optional - sage.modules
+ sage: from sage.arith.misc import factorial # optional - sage.modules
+ sage: phi = X.module_morphism(diagonal=factorial, codomain=X) # optional - sage.modules
+ sage: x = X.basis() # optional - sage.modules
+ sage: phi(x[1]), phi(x[2]), phi(x[3]) # optional - sage.modules
(B[1], 2*B[2], 6*B[3])
See also: :class:`sage.modules.with_basis.morphism.DiagonalModuleMorphism`.
@@ -435,13 +442,15 @@ def module_morphism(self, on_basis=None, matrix=None, function=None,
morphism whose matrix in the distinguished basis of `X`
and `Y` is `m`::
- sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X"); x = X.basis()
- sage: Y = CombinatorialFreeModule(ZZ, [3,4]); Y.rename("Y"); y = Y.basis()
- sage: m = matrix([[0,1,2],[3,5,0]])
- sage: phi = X.module_morphism(matrix=m, codomain=Y)
- sage: phi(x[1])
+ sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X") # optional - sage.modules
+ sage: x = X.basis() # optional - sage.modules
+ sage: Y = CombinatorialFreeModule(ZZ, [3,4]); Y.rename("Y") # optional - sage.modules
+ sage: y = Y.basis() # optional - sage.modules
+ sage: m = matrix([[0,1,2], [3,5,0]]) # optional - sage.modules
+ sage: phi = X.module_morphism(matrix=m, codomain=Y) # optional - sage.modules
+ sage: phi(x[1]) # optional - sage.modules
3*B[4]
- sage: phi(x[2])
+ sage: phi(x[2]) # optional - sage.modules
B[3] + 5*B[4]
@@ -454,35 +463,36 @@ def module_morphism(self, on_basis=None, matrix=None, function=None,
preimages and to invert the morphism::
sage: I = list(range(1, 200))
- sage: X = CombinatorialFreeModule(QQ, I); X.rename("X"); x = X.basis()
- sage: Y = CombinatorialFreeModule(QQ, I); Y.rename("Y"); y = Y.basis()
- sage: f = Y.sum_of_monomials * divisors
- sage: phi = X.module_morphism(f, triangular="upper", codomain = Y)
- sage: phi(x[2])
+ sage: X = CombinatorialFreeModule(QQ, I); X.rename("X"); x = X.basis() # optional - sage.modules
+ sage: Y = CombinatorialFreeModule(QQ, I); Y.rename("Y"); y = Y.basis() # optional - sage.modules
+ sage: f = Y.sum_of_monomials * divisors # optional - sage.modules
+ sage: phi = X.module_morphism(f, triangular="upper", codomain=Y) # optional - sage.modules
+ sage: phi(x[2]) # optional - sage.modules
B[1] + B[2]
- sage: phi(x[6])
+ sage: phi(x[6]) # optional - sage.modules
B[1] + B[2] + B[3] + B[6]
- sage: phi(x[30])
+ sage: phi(x[30]) # optional - sage.modules
B[1] + B[2] + B[3] + B[5] + B[6] + B[10] + B[15] + B[30]
- sage: phi.preimage(y[2])
+ sage: phi.preimage(y[2]) # optional - sage.modules
-B[1] + B[2]
- sage: phi.preimage(y[6])
+ sage: phi.preimage(y[6]) # optional - sage.modules
B[1] - B[2] - B[3] + B[6]
- sage: phi.preimage(y[30])
+ sage: phi.preimage(y[30]) # optional - sage.modules
-B[1] + B[2] + B[3] + B[5] - B[6] - B[10] - B[15] + B[30]
- sage: (phi^-1)(y[30])
+ sage: (phi^-1)(y[30]) # optional - sage.modules
-B[1] + B[2] + B[3] + B[5] - B[6] - B[10] - B[15] + B[30]
Since :trac:`8678`, one can also define a triangular
morphism from a function::
- sage: X = CombinatorialFreeModule(QQ, [0,1,2,3,4]); x = X.basis()
- sage: from sage.modules.with_basis.morphism import TriangularModuleMorphismFromFunction
- sage: def f(x): return x + X.term(0, sum(x.coefficients()))
- sage: phi = X.module_morphism(function=f, codomain=X, triangular="upper")
- sage: phi(x[2] + 3*x[4])
+ sage: X = CombinatorialFreeModule(QQ, [0,1,2,3,4]); x = X.basis() # optional - sage.modules
+ sage: from sage.modules.with_basis.morphism import TriangularModuleMorphismFromFunction # optional - sage.modules
+ sage: def f(x): return x + X.term(0, sum(x.coefficients())) # optional - sage.modules
+ sage: phi = X.module_morphism(function=f, codomain=X, # optional - sage.modules
+ ....: triangular="upper")
+ sage: phi(x[2] + 3*x[4]) # optional - sage.modules
4*B[0] + B[2] + 3*B[4]
- sage: phi.preimage(_)
+ sage: phi.preimage(_) # optional - sage.modules
B[2] + 3*B[4]
For details and further optional arguments, see
@@ -505,8 +515,8 @@ def module_morphism(self, on_basis=None, matrix=None, function=None,
TESTS::
- sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X")
- sage: phi = X.module_morphism(codomain=X)
+ sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X") # optional - sage.modules
+ sage: phi = X.module_morphism(codomain=X) # optional - sage.modules
Traceback (most recent call last):
...
ValueError: module_morphism() takes exactly one option
@@ -514,8 +524,9 @@ def module_morphism(self, on_basis=None, matrix=None, function=None,
::
- sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X")
- sage: phi = X.module_morphism(diagonal=factorial, matrix=matrix(), codomain=X)
+ sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X") # optional - sage.modules
+ sage: phi = X.module_morphism(diagonal=factorial, matrix=matrix(), # optional - sage.modules
+ ....: codomain=X)
Traceback (most recent call last):
...
ValueError: module_morphism() takes exactly one option
@@ -523,16 +534,16 @@ def module_morphism(self, on_basis=None, matrix=None, function=None,
::
- sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X")
- sage: phi = X.module_morphism(matrix=factorial, codomain=X)
+ sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X") # optional - sage.modules
+ sage: phi = X.module_morphism(matrix=factorial, codomain=X) # optional - sage.modules
Traceback (most recent call last):
...
ValueError: matrix (=...factorial...) should be a matrix
::
- sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X")
- sage: phi = X.module_morphism(diagonal=3, codomain=X)
+ sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename("X") # optional - sage.modules
+ sage: phi = X.module_morphism(diagonal=3, codomain=X) # optional - sage.modules
Traceback (most recent call last):
...
ValueError: diagonal (=3) should be a function
@@ -571,20 +582,20 @@ def _repr_(self):
"""
EXAMPLES::
- sage: class FooBar(CombinatorialFreeModule): pass
- sage: C = FooBar(QQ, (1,2,3)); C # indirect doctest
+ sage: class FooBar(CombinatorialFreeModule): pass # optional - sage.modules
+ sage: C = FooBar(QQ, (1,2,3)); C # indirect doctest # optional - sage.modules
Free module generated by {1, 2, 3} over Rational Field
- sage: C._name = "foobar"; C
+ sage: C._name = "foobar"; C # optional - sage.modules
foobar over Rational Field
- sage: C.rename("barfoo"); C
+ sage: C.rename("barfoo"); C # optional - sage.modules
barfoo
sage: class FooBar(Parent):
- ....: def basis(self): return Family({1:"foo", 2:"bar"})
+ ....: def basis(self): return Family({1: "foo", 2: "bar"})
....: def base_ring(self): return QQ
- sage: FooBar(category = ModulesWithBasis(QQ))
+ sage: FooBar(category=ModulesWithBasis(QQ))
Free module generated by [1, 2] over Rational Field
"""
if hasattr(self, "_name"):
@@ -608,26 +619,28 @@ def _compute_support_order(self, elements, support_order=None):
A finite dimensional module::
- sage: V = CombinatorialFreeModule(QQ, range(10), prefix='x')
- sage: B = V.basis()
- sage: elts = [B[0] - 2*B[3], B[5] + 2*B[0], B[2], B[3], B[1] + B[2] + B[8]]
- sage: V._compute_support_order(elts)
+ sage: V = CombinatorialFreeModule(QQ, range(10), prefix='x') # optional - sage.modules
+ sage: B = V.basis() # optional - sage.modules
+ sage: elts = [B[0] - 2*B[3], B[5] + 2*B[0], # optional - sage.modules
+ ....: B[2], B[3], B[1] + B[2] + B[8]]
+ sage: V._compute_support_order(elts) # optional - sage.modules
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
- sage: V._compute_support_order(elts, [1,2,0,4,3,5,9,8,7,6])
+ sage: V._compute_support_order(elts, [1,2,0,4,3,5,9,8,7,6]) # optional - sage.modules
(1, 2, 0, 4, 3, 5, 9, 8, 7, 6)
- sage: V._compute_support_order(elts, lambda x: -x)
+ sage: V._compute_support_order(elts, lambda x: -x) # optional - sage.modules
(8, 5, 3, 2, 1, 0)
An infinite dimensional module::
- sage: V = CombinatorialFreeModule(QQ, ZZ, prefix='z')
- sage: B = V.basis()
- sage: elts = [B[0] - 2*B[3], B[5] + 2*B[0], B[2], B[3], B[1] + B[2] + B[8]]
- sage: V._compute_support_order(elts)
+ sage: V = CombinatorialFreeModule(QQ, ZZ, prefix='z') # optional - sage.modules
+ sage: B = V.basis() # optional - sage.modules
+ sage: elts = [B[0] - 2*B[3], B[5] + 2*B[0], # optional - sage.modules
+ ....: B[2], B[3], B[1] + B[2] + B[8]]
+ sage: V._compute_support_order(elts) # optional - sage.modules
(0, 1, 2, 3, 5, 8)
- sage: V._compute_support_order(elts, [1,2,0,4,3,5,9,8,7,6])
+ sage: V._compute_support_order(elts, [1,2,0,4,3,5,9,8,7,6]) # optional - sage.modules
(1, 2, 0, 4, 3, 5, 9, 8, 7, 6)
- sage: V._compute_support_order(elts, lambda x: -x)
+ sage: V._compute_support_order(elts, lambda x: -x) # optional - sage.modules
(8, 5, 3, 2, 1, 0)
"""
if support_order is None:
@@ -672,17 +685,17 @@ def echelon_form(self, elements, row_reduced=False, order=None):
EXAMPLES::
sage: R. = QQ[]
- sage: C = CombinatorialFreeModule(R, ZZ, prefix='z')
- sage: z = C.basis()
- sage: C.echelon_form([z[0] - z[1], 2*z[1] - 2*z[2], z[0] - z[2]])
+ sage: C = CombinatorialFreeModule(R, ZZ, prefix='z') # optional - sage.modules
+ sage: z = C.basis() # optional - sage.modules
+ sage: C.echelon_form([z[0] - z[1], 2*z[1] - 2*z[2], z[0] - z[2]]) # optional - sage.modules
[z[0] - z[2], z[1] - z[2]]
TESTS:
We convert the input elements to ``self``::
- sage: s = SymmetricFunctions(QQ).s()
- sage: s.echelon_form([1, s[1] + 5])
+ sage: s = SymmetricFunctions(QQ).s() # optional - sage.combinat sage.modules
+ sage: s.echelon_form([1, s[1] + 5]) # optional - sage.combinat sage.modules
[s[], s[1]]
"""
# Make sure elements consists of elements of ``self``
@@ -751,21 +764,21 @@ def submodule(self, gens, check=True, already_echelonized=False,
`x_0, x_1, x_2`. The submodule is spanned by `y_0 = x_0 - x_1` and
`y_1 - x_1 - x_2`, and its basis elements are indexed by `0` and `1`::
- sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x")
- sage: x = X.basis()
- sage: gens = [x[0] - x[1], x[1] - x[2]]; gens
+ sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x") # optional - sage.modules
+ sage: x = X.basis() # optional - sage.modules
+ sage: gens = [x[0] - x[1], x[1] - x[2]]; gens # optional - sage.modules
[x[0] - x[1], x[1] - x[2]]
- sage: Y = X.submodule(gens, already_echelonized=True)
- sage: Y.print_options(prefix='y'); Y
+ sage: Y = X.submodule(gens, already_echelonized=True) # optional - sage.modules
+ sage: Y.print_options(prefix='y'); Y # optional - sage.modules
Free module generated by {0, 1} over Rational Field
- sage: y = Y.basis()
- sage: y[1]
+ sage: y = Y.basis() # optional - sage.modules
+ sage: y[1] # optional - sage.modules
y[1]
- sage: y[1].lift()
+ sage: y[1].lift() # optional - sage.modules
x[1] - x[2]
- sage: Y.retract(x[0]-x[2])
+ sage: Y.retract(x[0] - x[2]) # optional - sage.modules
y[0] + y[1]
- sage: Y.retract(x[0])
+ sage: Y.retract(x[0]) # optional - sage.modules
Traceback (most recent call last):
...
ValueError: x[0] is not in the image
@@ -773,23 +786,23 @@ def submodule(self, gens, check=True, already_echelonized=False,
By using a family to specify a basis of the submodule, we obtain a
submodule whose index set coincides with the index set of the family::
- sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x")
- sage: x = X.basis()
- sage: gens = Family({1 : x[0] - x[1], 3: x[1] - x[2]}); gens
+ sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x") # optional - sage.modules
+ sage: x = X.basis() # optional - sage.modules
+ sage: gens = Family({1: x[0] - x[1], 3: x[1] - x[2]}); gens # optional - sage.modules
Finite family {1: x[0] - x[1], 3: x[1] - x[2]}
- sage: Y = X.submodule(gens, already_echelonized=True)
- sage: Y.print_options(prefix='y'); Y
+ sage: Y = X.submodule(gens, already_echelonized=True) # optional - sage.modules
+ sage: Y.print_options(prefix='y'); Y # optional - sage.modules
Free module generated by {1, 3} over Rational Field
- sage: y = Y.basis()
- sage: y[1]
+ sage: y = Y.basis() # optional - sage.modules
+ sage: y[1] # optional - sage.modules
y[1]
- sage: y[1].lift()
+ sage: y[1].lift() # optional - sage.modules
x[0] - x[1]
- sage: y[3].lift()
+ sage: y[3].lift() # optional - sage.modules
x[1] - x[2]
- sage: Y.retract(x[0]-x[2])
+ sage: Y.retract(x[0] - x[2]) # optional - sage.modules
y[1] + y[3]
- sage: Y.retract(x[0])
+ sage: Y.retract(x[0]) # optional - sage.modules
Traceback (most recent call last):
...
ValueError: x[0] is not in the image
@@ -797,55 +810,56 @@ def submodule(self, gens, check=True, already_echelonized=False,
It is not necessary that the generators of the submodule form
a basis (an explicit basis will be computed)::
- sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x")
- sage: x = X.basis()
- sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]; gens
+ sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x") # optional - sage.modules
+ sage: x = X.basis() # optional - sage.modules
+ sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]; gens # optional - sage.modules
[x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]
- sage: Y = X.submodule(gens, already_echelonized=False)
- sage: Y.print_options(prefix='y')
- sage: Y
+ sage: Y = X.submodule(gens, already_echelonized=False) # optional - sage.modules
+ sage: Y.print_options(prefix='y') # optional - sage.modules
+ sage: Y # optional - sage.modules
Free module generated by {0, 1} over Rational Field
- sage: [b.lift() for b in Y.basis()]
+ sage: [b.lift() for b in Y.basis()] # optional - sage.modules
[x[0] - x[2], x[1] - x[2]]
We now implement by hand the center of the algebra of the
symmetric group `S_3`::
- sage: S3 = SymmetricGroup(3)
- sage: S3A = S3.algebra(QQ)
- sage: basis = S3A.annihilator_basis(S3A.algebra_generators(), S3A.bracket)
- sage: basis
+ sage: S3 = SymmetricGroup(3) # optional - sage.groups sage.modules
+ sage: S3A = S3.algebra(QQ) # optional - sage.groups sage.modules
+ sage: basis = S3A.annihilator_basis(S3A.algebra_generators(), # optional - sage.groups sage.modules
+ ....: S3A.bracket)
+ sage: basis # optional - sage.groups sage.modules
((), (1,2,3) + (1,3,2), (2,3) + (1,2) + (1,3))
- sage: center = S3A.submodule(basis,
- ....: category=AlgebrasWithBasis(QQ).Subobjects(),
- ....: already_echelonized=True)
- sage: center
+ sage: center = S3A.submodule(basis, # optional - sage.groups sage.modules
+ ....: category=AlgebrasWithBasis(QQ).Subobjects(),
+ ....: already_echelonized=True)
+ sage: center # optional - sage.groups sage.modules
Free module generated by {0, 1, 2} over Rational Field
- sage: center in Algebras
+ sage: center in Algebras # optional - sage.groups sage.modules
True
- sage: center.print_options(prefix='c')
- sage: c = center.basis()
- sage: c[1].lift()
+ sage: center.print_options(prefix='c') # optional - sage.groups sage.modules
+ sage: c = center.basis() # optional - sage.groups sage.modules
+ sage: c[1].lift() # optional - sage.groups sage.modules
(1,2,3) + (1,3,2)
- sage: c[0]^2
+ sage: c[0]^2 # optional - sage.groups sage.modules
c[0]
- sage: e = 1/6*(c[0]+c[1]+c[2])
- sage: e.is_idempotent()
+ sage: e = 1/6 * (c[0]+c[1]+c[2]) # optional - sage.groups sage.modules
+ sage: e.is_idempotent() # optional - sage.groups sage.modules
True
Of course, this center is best constructed using::
- sage: center = S3A.center()
+ sage: center = S3A.center() # optional - sage.groups sage.modules
We can also automatically construct a basis such that
the lift morphism is (lower) unitriangular::
sage: R. = QQ[]
- sage: C = CombinatorialFreeModule(R, range(3), prefix='x')
- sage: x = C.basis()
- sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]
- sage: Y = C.submodule(gens, unitriangular=True)
- sage: Y.lift.matrix()
+ sage: C = CombinatorialFreeModule(R, range(3), prefix='x') # optional - sage.modules
+ sage: x = C.basis() # optional - sage.modules
+ sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]] # optional - sage.modules
+ sage: Y = C.submodule(gens, unitriangular=True) # optional - sage.modules
+ sage: Y.lift.matrix() # optional - sage.modules
[ 1 0]
[ 0 1]
[-1 -1]
@@ -853,17 +867,17 @@ def submodule(self, gens, check=True, already_echelonized=False,
We now construct a (finite-dimensional) submodule of an
infinite dimensional free module::
- sage: C = CombinatorialFreeModule(QQ, ZZ, prefix='z')
- sage: z = C.basis()
- sage: gens = [z[0] - z[1], 2*z[1] - 2*z[2], z[0] - z[2]]
- sage: Y = C.submodule(gens)
- sage: [Y.lift(b) for b in Y.basis()]
+ sage: C = CombinatorialFreeModule(QQ, ZZ, prefix='z') # optional - sage.modules
+ sage: z = C.basis() # optional - sage.modules
+ sage: gens = [z[0] - z[1], 2*z[1] - 2*z[2], z[0] - z[2]] # optional - sage.modules
+ sage: Y = C.submodule(gens) # optional - sage.modules
+ sage: [Y.lift(b) for b in Y.basis()] # optional - sage.modules
[z[0] - z[2], z[1] - z[2]]
TESTS::
- sage: TestSuite(Y).run()
- sage: TestSuite(center).run()
+ sage: TestSuite(Y).run() # optional - sage.modules
+ sage: TestSuite(center).run() # optional - sage.groups sage.modules
"""
# Make sure gens consists of elements of ``self``
from sage.sets.family import Family, AbstractFamily
@@ -906,24 +920,25 @@ def quotient_module(self, submodule, check=True, already_echelonized=False, cate
EXAMPLES::
- sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x")
- sage: x = X.basis()
- sage: Y = X.quotient_module([x[0]-x[1], x[1]-x[2]], already_echelonized=True)
- sage: Y.print_options(prefix='y'); Y
+ sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x") # optional - sage.modules
+ sage: x = X.basis() # optional - sage.modules
+ sage: Y = X.quotient_module([x[0] - x[1], x[1] - x[2]], # optional - sage.modules
+ ....: already_echelonized=True)
+ sage: Y.print_options(prefix='y'); Y # optional - sage.modules
Free module generated by {2} over Rational Field
- sage: y = Y.basis()
- sage: y[2]
+ sage: y = Y.basis() # optional - sage.modules
+ sage: y[2] # optional - sage.modules
y[2]
- sage: y[2].lift()
+ sage: y[2].lift() # optional - sage.modules
x[2]
- sage: Y.retract(x[0]+2*x[1])
+ sage: Y.retract(x[0] + 2*x[1]) # optional - sage.modules
3*y[2]
sage: R. = QQ[]
- sage: C = CombinatorialFreeModule(R, range(3), prefix='x')
- sage: x = C.basis()
- sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]
- sage: Y = C.quotient_module(gens)
+ sage: C = CombinatorialFreeModule(R, range(3), prefix='x') # optional - sage.modules
+ sage: x = C.basis() # optional - sage.modules
+ sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]] # optional - sage.modules
+ sage: Y = C.quotient_module(gens) # optional - sage.modules
.. SEEALSO::
@@ -945,10 +960,10 @@ def tensor(*parents, **kwargs):
EXAMPLES::
sage: C = AlgebrasWithBasis(QQ)
- sage: A = C.example(); A.rename("A")
- sage: A.tensor(A,A)
+ sage: A = C.example(); A.rename("A") # optional - sage.combinat sage.modules
+ sage: A.tensor(A, A) # optional - sage.combinat sage.modules
A # A # A
- sage: A.rename(None)
+ sage: A.rename(None) # optional - sage.combinat sage.modules
"""
constructor = kwargs.pop('constructor', tensor)
cat = constructor.category_from_parents(parents)
@@ -960,24 +975,24 @@ def cardinality(self):
EXAMPLES::
- sage: S = SymmetricGroupAlgebra(QQ, 4)
- sage: S.cardinality()
+ sage: S = SymmetricGroupAlgebra(QQ, 4) # optional - sage.groups sage.modules
+ sage: S.cardinality() # optional - sage.groups sage.modules
+Infinity
- sage: S = SymmetricGroupAlgebra(GF(2), 4) # not tested -- MRO bug trac #15475
- sage: S.cardinality() # not tested -- MRO bug trac #15475
+ sage: S = SymmetricGroupAlgebra(GF(2), 4) # not tested -- MRO bug trac #15475 # optional - sage.groups sage.rings.finite_rings sage.modules
+ sage: S.cardinality() # not tested -- MRO bug trac #15475 # optional - sage.groups sage.rings.finite_rings sage.modules
16777216
- sage: S.cardinality().factor() # not tested -- MRO bug trac #15475
+ sage: S.cardinality().factor() # not tested -- MRO bug trac #15475 # optional - sage.groups sage.rings.finite_rings sage.modules
2^24
- sage: E. = ExteriorAlgebra(QQ)
- sage: E.cardinality()
+ sage: E. = ExteriorAlgebra(QQ) # optional - sage.combinat sage.modules
+ sage: E.cardinality() # optional - sage.combinat sage.modules
+Infinity
- sage: E. = ExteriorAlgebra(GF(3))
- sage: E.cardinality()
+ sage: E. = ExteriorAlgebra(GF(3)) # optional - sage.combinat sage.rings.finite_rings sage.modules
+ sage: E.cardinality() # optional - sage.combinat sage.rings.finite_rings sage.modules
81
- sage: s = SymmetricFunctions(GF(2)).s()
- sage: s.cardinality()
+ sage: s = SymmetricFunctions(GF(2)).s() # optional - sage.combinat sage.rings.finite_rings sage.modules
+ sage: s.cardinality() # optional - sage.combinat sage.rings.finite_rings sage.modules
+Infinity
"""
from sage.rings.infinity import Infinity
@@ -994,11 +1009,11 @@ def is_finite(self):
EXAMPLES::
- sage: GroupAlgebra(SymmetricGroup(2), IntegerModRing(10)).is_finite()
+ sage: GroupAlgebra(SymmetricGroup(2), IntegerModRing(10)).is_finite() # optional - sage.groups sage.modules
True
- sage: GroupAlgebra(SymmetricGroup(2)).is_finite()
+ sage: GroupAlgebra(SymmetricGroup(2)).is_finite() # optional - sage.groups sage.modules
False
- sage: GroupAlgebra(AbelianGroup(1), IntegerModRing(10)).is_finite()
+ sage: GroupAlgebra(AbelianGroup(1), IntegerModRing(10)).is_finite() # optional - sage.groups sage.modules
False
"""
return (self.base_ring().is_finite() and self.group().is_finite())
@@ -1013,14 +1028,15 @@ def monomial(self, i):
EXAMPLES::
- sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c'])
- sage: F.monomial('a')
+ sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # optional - sage.modules
+ sage: F.monomial('a') # optional - sage.modules
B['a']
``F.monomial`` is in fact (almost) a map::
- sage: F.monomial
- Term map from {'a', 'b', 'c'} to Free module generated by {'a', 'b', 'c'} over Rational Field
+ sage: F.monomial # optional - sage.modules
+ Term map from {'a', 'b', 'c'}
+ to Free module generated by {'a', 'b', 'c'} over Rational Field
"""
return self.basis()[i]
@@ -1029,8 +1045,8 @@ def _sum_of_monomials(self, indices):
TESTS::
sage: R. = QQ[]
- sage: W = DifferentialWeylAlgebra(R)
- sage: W._sum_of_monomials([((1,0), (1,0)), ((0,0), (0,1))])
+ sage: W = DifferentialWeylAlgebra(R) # optional - sage.combinat sage.modules
+ sage: W._sum_of_monomials([((1,0), (1,0)), ((0,0), (0,1))]) # optional - sage.combinat sage.modules
dy + x*dx
"""
# This is the generic implementation. When implementing a
@@ -1051,16 +1067,16 @@ def sum_of_monomials(self):
EXAMPLES::
- sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c'])
- sage: F.sum_of_monomials(['a', 'b'])
+ sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # optional - sage.modules
+ sage: F.sum_of_monomials(['a', 'b']) # optional - sage.modules
B['a'] + B['b']
- sage: F.sum_of_monomials(['a', 'b', 'a'])
+ sage: F.sum_of_monomials(['a', 'b', 'a']) # optional - sage.modules
2*B['a'] + B['b']
``F.sum_of_monomials`` is in fact (almost) a map::
- sage: F.sum_of_monomials
+ sage: F.sum_of_monomials # optional - sage.modules
A map to Free module generated by {'a', 'b', 'c'} over Rational Field
"""
# domain = iterables of basis indices of self.
@@ -1070,10 +1086,10 @@ def monomial_or_zero_if_none(self, i):
"""
EXAMPLES::
- sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c'])
- sage: F.monomial_or_zero_if_none('a')
+ sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # optional - sage.modules
+ sage: F.monomial_or_zero_if_none('a') # optional - sage.modules
B['a']
- sage: F.monomial_or_zero_if_none(None)
+ sage: F.monomial_or_zero_if_none(None) # optional - sage.modules
0
"""
if i is None:
@@ -1095,9 +1111,9 @@ def term(self, index, coeff=None):
EXAMPLES::
- sage: m = matrix([[0,1],[1,1]])
- sage: J.