diff --git a/.github/workflows/ci-conda.yml b/.github/workflows/ci-conda.yml index 2048d9c43ae..49236dd7270 100644 --- a/.github/workflows/ci-conda.yml +++ b/.github/workflows/ci-conda.yml @@ -8,6 +8,11 @@ on: - 'public/build/**-runci' pull_request: types: + # Defaults + - opened + - synchronize + - reopened + # When a CI label is added - labeled workflow_dispatch: # Allow to run manually @@ -21,13 +26,18 @@ jobs: test: name: Conda runs-on: ${{ matrix.os }} - - # Run on push, workflow dispatch and when certain labels are added + + # Run on push, workflow dispatch and when certain labels are added or are present if: | - github.event.action != 'labeled' || - github.event.label.name == 'c: packages: optional' || - github.event.label.name == 'c: packages: standard' || - github.event.label.name == 's: run conda ci' + github.event_name != 'pull_request' || + ((github.event.action != 'labeled' && + (contains(github.event.pull_request.labels.*.name, 'c: packages: standard') || + contains(github.event.pull_request.labels.*.name, 'c: packages: optional') || + contains(github.event.pull_request.labels.*.name, 's: run conda ci'))) || + (github.event.action == 'labeled' && + (github.event.label.name == 'c: packages: optional' || + github.event.label.name == 'c: packages: standard' || + github.event.label.name == 's: run conda ci'))) strategy: fail-fast: false diff --git a/.github/workflows/ci-linux-incremental.yml b/.github/workflows/ci-linux-incremental.yml new file mode 100644 index 00000000000..d0a802d3b5c --- /dev/null +++ b/.github/workflows/ci-linux-incremental.yml @@ -0,0 +1,97 @@ +name: CI Linux incremental + +## This GitHub Actions workflow runs SAGE_ROOT/tox.ini with select environments, +## whenever a GitHub pull request is opened or synchronized in a repository +## where GitHub Actions are enabled. +## +## It builds and checks some sage spkgs as defined in TARGETS. +## +## A job succeeds if there is no error. +## +## The build is run with "make V=0", so the build logs of individual packages are suppressed. +## +## At the end, all package build logs that contain an error are printed out. +## +## After all jobs have finished (or are canceled) and a short delay, +## tar files of all logs are made available as "build artifacts". + +on: + pull_request: + types: + # Defaults + - opened + - synchronize + - reopened + # When a CI label is added + - labeled + workflow_dispatch: + +concurrency: + # Cancel previous runs of this workflow for the same branch + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + packages: write + +jobs: + + changed_files: + runs-on: ubuntu-latest + name: List changed packages + outputs: + uninstall_targets: ${{ steps.build-targets.outputs.uninstall_targets }} + build_targets: ${{ steps.build-targets.outputs.build_targets }} + steps: + - uses: actions/checkout@v3 + - name: Get all packages that have changed + id: changed-packages + uses: tj-actions/changed-files@v38 + with: + files_yaml: | + configures: + - 'build/pkgs/*/spkg-configure.m4' + pkgs: + - 'build/pkgs/**' + - 'pkgs/**' + - name: Determine targets to build + id: build-targets + run: | + echo "uninstall_targets=$(echo $(for a in '' ${{ steps.changed-packages.outputs.configures_all_changed_files }}; do echo $a | sed -E 's,build/pkgs/([_.a-z0-9]*)/spkg-configure[.]m4 *,\1-uninstall,'; done | sort -u))" >> $GITHUB_OUTPUT + echo "build_targets=$(echo $(for a in '' ${{ steps.changed-packages.outputs.pkgs_all_changed_files }}; do echo $a | sed -E 's,-,_,g;s,(build/)?pkgs/([-_.a-z0-9]*)/[^ ]* *,\2-ensure,;'; done | sort -u))" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT + minimal: + needs: [changed_files] + if: | + github.event_name != 'pull_request' || + ((github.event.action != 'labeled' && + (contains(github.event.pull_request.labels.*.name, 'c: packages: standard') || + contains(github.event.pull_request.labels.*.name, 'c: packages: optional'))) || + (github.event.action == 'labeled' && + (github.event.label.name == 'c: packages: optional' || + github.event.label.name == 'c: packages: standard'))) + uses: ./.github/workflows/docker.yml + with: + # Build incrementally from published Docker image + incremental: true + free_disk_space: true + from_docker_repository: ghcr.io/sagemath/sage/ + from_docker_target: "with-targets" + from_docker_tag: "dev" + docker_targets: "with-targets" + targets: "${{needs.changed_files.outputs.uninstall_targets}} ${{needs.changed_files.outputs.build_targets}} build doc-html ptest" + tox_system_factors: >- + ["ubuntu-focal", + "ubuntu-jammy", + "ubuntu-mantic, + "debian-bullseye", + "debian-bookworm", + "ubuntu-mantic, + "fedora-30", + "fedora-38", + "gentoo-python3.11", + "debian-bullseye-i386"] + tox_packages_factors: >- + ["standard", + "minimal"] + docker_push_repository: ghcr.io/${{ github.repository }}/ diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 5f049741eab..6f598521a37 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -63,6 +63,56 @@ jobs: ["standard"] docker_push_repository: ghcr.io/${{ github.repository }}/ + standard-sitepackages: + if: ${{ success() || failure() }} + needs: [standard-pre] + uses: ./.github/workflows/docker.yml + with: + # Build incrementally from previous stage (pre) + incremental: true + free_disk_space: true + from_docker_repository: ghcr.io/${{ github.repository }}/ + from_docker_target: "with-targets-pre" + docker_targets: "with-targets with-targets-optional" + # FIXME: duplicated from env.TARGETS + targets: build doc-html + targets_optional: ptest + tox_packages_factors: >- + ["standard-sitepackages"] + # Only test systems with a usable system python (>= 3.9) + tox_system_factors: >- + ["ubuntu-jammy", + "ubuntu-kinetic", + "ubuntu-lunar", + "ubuntu-mantic", + "debian-bullseye", + "debian-bookworm", + "debian-trixie", + "debian-sid", + "linuxmint-21", + "linuxmint-21.1", + "linuxmint-21.2", + "fedora-33", + "fedora-34", + "fedora-35", + "fedora-36", + "fedora-37", + "fedora-38", + "fedora-39", + "centos-stream-8-python3.9", + "centos-stream-9-python3.9", + "almalinux-8-python3.9", + "gentoo-python3.10", + "gentoo-python3.11", + "archlinux-latest", + "opensuse-15.4-gcc_11-python3.10", + "opensuse-15.5-gcc_11-python3.11", + "opensuse-tumbleweed-python3.10", + "opensuse-tumbleweed", + "debian-bullseye-i386"] + docker_push_repository: ghcr.io/${{ github.repository }}/ + max_parallel: 10 + minimal-pre: if: ${{ success() || failure() }} # It does not really "need" it. diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3dc4b8a4627..e6104c4a7cb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -18,6 +18,7 @@ on: default: >- ["ubuntu-trusty-toolchain-gcc_9", "ubuntu-xenial-toolchain-gcc_9", + "ubuntu-bionic-gcc_8", "ubuntu-focal", "ubuntu-jammy", "ubuntu-kinetic", @@ -56,6 +57,7 @@ on: "opensuse-15.4-gcc_11-python3.10", "opensuse-15.5-gcc_11-python3.11", "opensuse-tumbleweed-python3.10", + "opensuse-tumbleweed", "conda-forge", "ubuntu-bionic-gcc_8-i386", "debian-bullseye-i386", diff --git a/.vscode/settings.json b/.vscode/settings.json index 77dcb2ce188..b3079a7c4ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -27,7 +27,7 @@ "python.linting.enabled": true, // The following pycodestyle arguments are the same as the pycodestyle-minimal // tox environnment, see the file SAGE_ROOT/src/tox.ini - "python.linting.pycodestyleArgs": ["--select= E111,E21,E222,E227,E25,E271,E303,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605"], + "python.linting.pycodestyleArgs": ["--select= E111,E21,E222,E227,E25,E271,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605"], "cSpell.words": [ "furo", "Conda", diff --git a/CITATION.cff b/CITATION.cff index 33f35797f06..1559f9ee0c1 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -4,8 +4,8 @@ title: SageMath abstract: SageMath is a free open-source mathematics software system. authors: - name: "The SageMath Developers" -version: 10.2.beta1 +version: 10.2.beta2 doi: 10.5281/zenodo.593563 -date-released: 2023-09-01 +date-released: 2023-09-10 repository-code: "https://github.com/sagemath/sage" url: "https://www.sagemath.org/" diff --git a/VERSION.txt b/VERSION.txt index b3bbedfc466..a97d473cd7f 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -SageMath version 10.2.beta1, Release Date: 2023-09-01 +SageMath version 10.2.beta2, Release Date: 2023-09-10 diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index b00fd2a3f99..7d6cd113bf9 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -53,9 +53,13 @@ export SAGE_PARI_CFG="@SAGE_PARI_CFG@" export SAGE_GLPK_PREFIX="@SAGE_GLPK_PREFIX@" export SAGE_FREETYPE_PREFIX="@SAGE_FREETYPE_PREFIX@" +export SAGE_PIP_INSTALL_FLAGS="@SAGE_PIP_INSTALL_FLAGS@" export SAGE_SUITESPARSE_PREFIX="@SAGE_SUITESPARSE_PREFIX@" export SAGE_CONFIGURE_FFLAS_FFPACK="@SAGE_CONFIGURE_FFLAS_FFPACK@" export CONFIGURED_SAGE_EDITABLE="@SAGE_EDITABLE@" export CONFIGURED_SAGE_WHEELS="@SAGE_WHEELS@" + +export ENABLE_SYSTEM_SITE_PACKAGES="@ENABLE_SYSTEM_SITE_PACKAGES@" +export PYTHON_MINOR="@PYTHON_MINOR@" diff --git a/build/bin/sage-dist-helpers b/build/bin/sage-dist-helpers index 4eac9626ffa..67a2201d31f 100644 --- a/build/bin/sage-dist-helpers +++ b/build/bin/sage-dist-helpers @@ -325,7 +325,11 @@ sdh_store_wheel() { } sdh_store_and_pip_install_wheel() { - local pip_options="" + # The $SAGE_PIP_INSTALL_FLAGS variable is set by sage-build-env-config. + # We skip sanity checking its contents since you should either let sage + # decide what it contains, or really know what you are doing. + local pip_options="${SAGE_PIP_INSTALL_FLAGS}" + while [ $# -gt 0 ]; do case $1 in -*) pip_options="$pip_options $1" diff --git a/build/bin/sage-get-system-packages b/build/bin/sage-get-system-packages index c51c36ceab9..c8b9314c3fe 100755 --- a/build/bin/sage-get-system-packages +++ b/build/bin/sage-get-system-packages @@ -1,4 +1,5 @@ #!/bin/sh + SYSTEM=$1 if [ -z "$SYSTEM" ]; then echo >&2 "usage: $0 {auto|debian|arch|conda|pip|...} SPKGS..." @@ -10,6 +11,7 @@ SPKGS="$*" if [ -z "$SAGE_ROOT" ]; then SAGE_ROOT=`pwd` fi + case "$SYSTEM" in install-requires) # Collect install-requires.txt (falling back to requirements.txt) and output it in the format @@ -44,6 +46,18 @@ case "$SYSTEM" in ;; esac for PKG_BASE in $SPKGS; do + + # Skip this package if it uses the SAGE_PYTHON_PACKAGE_CHECK + # macro and if --enable-system-site-packages was NOT passed + # to ./configure (or if ./configure has not yet been run). + SPKG_CONFIGURE="${SAGE_ROOT}/build/pkgs/${PKG_BASE}/spkg-configure.m4" + if [ -z "${ENABLE_SYSTEM_SITE_PACKAGES}" ]; then + if grep -q SAGE_PYTHON_PACKAGE_CHECK "${SPKG_CONFIGURE}" 2>/dev/null; + then + continue; + fi + fi + for NAME in $SYSTEM_PACKAGES_FILE_NAMES; do SYSTEM_PACKAGES_FILE="$SAGE_ROOT"/build/pkgs/$PKG_BASE/$NAME if [ -f $SYSTEM_PACKAGES_FILE ]; then diff --git a/build/bin/sage-spkg-info b/build/bin/sage-spkg-info index d02b3ac347f..e43e516dc5b 100755 --- a/build/bin/sage-spkg-info +++ b/build/bin/sage-spkg-info @@ -110,17 +110,19 @@ if [ -z "$system" ]; then echo "(none known)" else echo - if [ -f "$PKG_SCRIPTS"/spkg-configure.m4 ]; then - echo "If the system package is installed, ./configure will check whether it can be used." - else - echo "However, these system packages will not be used for building Sage" - if [ -f "$PKG_SCRIPTS"/install-requires.txt ]; then - echo "because using Python site-packages is not supported by the Sage distribution;" - echo "see https://github.com/sagemath/sage/issues/29023" + SPKG_CONFIGURE="${PKG_SCRIPTS}/spkg-configure.m4" + if [ -f "${SPKG_CONFIGURE}" ]; then + if grep -q SAGE_PYTHON_PACKAGE_CHECK "${SPKG_CONFIGURE}"; then + echo "If the system package is installed and if the (experimental) option" + echo "--enable-system-site-packages is passed to ./configure, then ./configure" + echo "will check if the system package can be used." else - echo "because spkg-configure.m4 has not been written for this package;" - echo "see https://github.com/sagemath/sage/issues/27330" + echo "If the system package is installed, ./configure will check if it can be used." fi + else + echo "However, these system packages will not be used for building Sage" + echo "because spkg-configure.m4 has not been written for this package;" + echo "see https://github.com/sagemath/sage/issues/27330" fi fi echo diff --git a/build/bin/write-dockerfile.sh b/build/bin/write-dockerfile.sh index 14cbaf786eb..6980f6b6e4b 100755 --- a/build/bin/write-dockerfile.sh +++ b/build/bin/write-dockerfile.sh @@ -5,7 +5,7 @@ set -e SYSTEM="${1:-debian}" shopt -s extglob -SAGE_PACKAGE_LIST_ARGS="${2:- --has-file=spkg-configure.m4 :standard:}" +SAGE_PACKAGE_LIST_ARGS="${2:-:standard:}" WITH_SYSTEM_SPKG="${3:-yes}" IGNORE_MISSING_SYSTEM_PACKAGES="${4:-no}" EXTRA_SAGE_PACKAGES="${5:-_bootstrap}" @@ -15,17 +15,13 @@ SAGE_ROOT=. export PATH="$SAGE_ROOT"/build/bin:$PATH SYSTEM_PACKAGES=$EXTRA_SYSTEM_PACKAGES CONFIGURE_ARGS="--enable-option-checking " -for PKG_BASE in $(sage-package list --has-file=distros/$SYSTEM.txt $SAGE_PACKAGE_LIST_ARGS) $EXTRA_SAGE_PACKAGES; do - PKG_SCRIPTS="$SAGE_ROOT"/build/pkgs/$PKG_BASE - if [ -d $PKG_SCRIPTS ]; then - SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/distros/$SYSTEM.txt - PKG_SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} $SYSTEM_PACKAGES_FILE)) - if [ -n "PKG_SYSTEM_PACKAGES" ]; then - SYSTEM_PACKAGES+=" $PKG_SYSTEM_PACKAGES" - if [ -f $PKG_SCRIPTS/spkg-configure.m4 ]; then - CONFIGURE_ARGS+="--with-system-$PKG_BASE=${WITH_SYSTEM_SPKG} " - fi - fi +for SPKG in $(sage-package list --has-file=spkg-configure.m4 $SAGE_PACKAGE_LIST_ARGS) $EXTRA_SAGE_PACKAGES; do + SYSTEM_PACKAGE=$(sage-get-system-packages $SYSTEM $SPKG | sed 's/${PYTHON_MINOR}/'${PYTHON_MINOR}'/g') + if [ -n "${SYSTEM_PACKAGE}" ]; then + # SYSTEM_PACKAGE can be empty if, for example, the environment + # variable ENABLE_SYSTEM_SITE_PACKAGES is empty. + SYSTEM_PACKAGES+=" ${SYSTEM_PACKAGE}" + CONFIGURE_ARGS+="--with-system-${SPKG}=${WITH_SYSTEM_SPKG} " fi done echo "# Automatically generated by SAGE_ROOT/build/bin/write-dockerfile.sh" diff --git a/build/make/Makefile.in b/build/make/Makefile.in index b6858173362..cc004d08c3c 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -227,11 +227,13 @@ SAGE_I_TARGETS = sagelib doc python3_venv _clean-broken-gcc PYTHON_FOR_VENV = @PYTHON_FOR_VENV@ +PYTHON_MINOR = @PYTHON_MINOR@ +SAGE_VENV_FLAGS = @SAGE_VENV_FLAGS@ ifneq ($(PYTHON_FOR_VENV),) # Special rule for making the Python virtualenv from the system Python (Python # 3 only). $(PYTHON) is set in Makefile to python3_venv. -# Thus $(inst_python3_venv) will be the dependency of every Python package. +# Thus $(inst_python3_venv) will an (order-only) dependency of every Python package. # # TODO: If we reconfigure to build our own Python after having used the system # Python, files installed to create the virtualenv should be *removed*. That @@ -239,10 +241,15 @@ ifneq ($(PYTHON_FOR_VENV),) ifeq ($(PYTHON),python3) PYTHON = python3_venv endif -inst_python3_venv = $(SAGE_VENV)/pyvenv.cfg +inst_python3_venv = $(SAGE_VENV)/$(SPKG_INST_RELDIR)/python3_venv-3.$(PYTHON_MINOR)-$(subst /,-,$(PYTHON_FOR_VENV))$(findstring --system-site-packages,$(SAGE_VENV_FLAGS)) -$(inst_python3_venv): - $(PYTHON_FOR_VENV) $(SAGE_ROOT)/build/bin/sage-venv "$(SAGE_VENV)" +$(SAGE_VENV)/$(SPKG_INST_RELDIR): + mkdir -p "$@" + +$(inst_python3_venv): | $(SAGE_VENV)/$(SPKG_INST_RELDIR) + $(PYTHON_FOR_VENV) $(SAGE_ROOT)/build/bin/sage-venv $(SAGE_VENV_FLAGS) "$(SAGE_VENV)" + rm -f "$(SAGE_VENV)/$(SPKG_INST_RELDIR)"/python3_venv-* + touch "$@" endif # Build everything and start Sage. @@ -591,6 +598,8 @@ $$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2): $(3) $(1): $$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2) +$(1)-ensure: $(inst_$(1)) + $(1)-$(4)-no-deps: +@if [ -z '$$($(4))' ]; then \ echo "Error: The installation tree $(4) has been disabled" 2>&1; \ @@ -649,6 +658,8 @@ $(1)-build-deps: $(2) $(1): $(2) +$(MAKE_REC) $(1)-no-deps +$(1)-ensure: $(inst_$(1)) + $(1)-no-deps: $(AM_V_at)sage-logger -p 'sage --pip install -r "$$(SAGE_ROOT)/build/pkgs/$(1)/requirements.txt"' '$$(SAGE_LOGS)/$(1).log' @@ -705,6 +716,8 @@ $$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2): $(3) $(1): $$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2) +$(1)-ensure: $(inst_$(1)) + $(1)-$(4)-no-deps: $(PLUS)@if [ -z '$$($(4))' ]; then \ echo "Error: The installation tree $(4) has been disabled" 2>&1; \ diff --git a/build/pkgs/admcycles/dependencies b/build/pkgs/admcycles/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/admcycles/dependencies +++ b/build/pkgs/admcycles/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/alabaster/dependencies b/build/pkgs/alabaster/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/alabaster/dependencies +++ b/build/pkgs/alabaster/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/alabaster/distros/gentoo.txt b/build/pkgs/alabaster/distros/gentoo.txt new file mode 100644 index 00000000000..cffece61b27 --- /dev/null +++ b/build/pkgs/alabaster/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/alabaster diff --git a/build/pkgs/alabaster/distros/opensuse.txt b/build/pkgs/alabaster/distros/opensuse.txt index dcc39f9e849..debe990ce19 100644 --- a/build/pkgs/alabaster/distros/opensuse.txt +++ b/build/pkgs/alabaster/distros/opensuse.txt @@ -1 +1 @@ -python3-alabaster +python3${PYTHON_MINOR}-alabaster diff --git a/build/pkgs/alabaster/spkg-configure.m4 b/build/pkgs/alabaster/spkg-configure.m4 new file mode 100644 index 00000000000..4eca6e05a5f --- /dev/null +++ b/build/pkgs/alabaster/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([alabaster], [SAGE_PYTHON_PACKAGE_CHECK([alabaster])]) diff --git a/build/pkgs/appdirs/dependencies b/build/pkgs/appdirs/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/appdirs/dependencies +++ b/build/pkgs/appdirs/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/appnope/dependencies b/build/pkgs/appnope/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/appnope/dependencies +++ b/build/pkgs/appnope/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/argon2_cffi/dependencies b/build/pkgs/argon2_cffi/dependencies index d1b259926f8..920046ab33d 100644 --- a/build/pkgs/argon2_cffi/dependencies +++ b/build/pkgs/argon2_cffi/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) argon2_cffi_bindings | $(PYTHON_TOOLCHAIN) flit_core + argon2_cffi_bindings | $(PYTHON_TOOLCHAIN) flit_core $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/argon2_cffi/distros/gentoo.txt b/build/pkgs/argon2_cffi/distros/gentoo.txt new file mode 100644 index 00000000000..2f12ca869e4 --- /dev/null +++ b/build/pkgs/argon2_cffi/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/argon2-cffi diff --git a/build/pkgs/argon2_cffi/spkg-configure.m4 b/build/pkgs/argon2_cffi/spkg-configure.m4 new file mode 100644 index 00000000000..03ebc634492 --- /dev/null +++ b/build/pkgs/argon2_cffi/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([argon2_cffi], [SAGE_PYTHON_PACKAGE_CHECK([argon2_cffi])]) diff --git a/build/pkgs/argon2_cffi_bindings/dependencies b/build/pkgs/argon2_cffi_bindings/dependencies index 0d815c35f4b..4b9d24ccf44 100644 --- a/build/pkgs/argon2_cffi_bindings/dependencies +++ b/build/pkgs/argon2_cffi_bindings/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) cffi setuptools_scm + | $(PYTHON_TOOLCHAIN) cffi setuptools_scm $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/asttokens/dependencies b/build/pkgs/asttokens/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/asttokens/dependencies +++ b/build/pkgs/asttokens/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/attrs/dependencies b/build/pkgs/attrs/dependencies index 4361e46ddaf..9be6b4aab7c 100644 --- a/build/pkgs/attrs/dependencies +++ b/build/pkgs/attrs/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) vcversioner | $(PYTHON_TOOLCHAIN) + vcversioner | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/attrs/distros/gentoo.txt b/build/pkgs/attrs/distros/gentoo.txt new file mode 100644 index 00000000000..3b906facd3a --- /dev/null +++ b/build/pkgs/attrs/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/attrs diff --git a/build/pkgs/attrs/spkg-configure.m4 b/build/pkgs/attrs/spkg-configure.m4 new file mode 100644 index 00000000000..ba6a9b71efa --- /dev/null +++ b/build/pkgs/attrs/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([attrs], [SAGE_PYTHON_PACKAGE_CHECK([attrs])]) diff --git a/build/pkgs/auditwheel_or_delocate/dependencies b/build/pkgs/auditwheel_or_delocate/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/auditwheel_or_delocate/dependencies +++ b/build/pkgs/auditwheel_or_delocate/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/awali/dependencies b/build/pkgs/awali/dependencies index b125e2ded92..09b60167a34 100644 --- a/build/pkgs/awali/dependencies +++ b/build/pkgs/awali/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cmake cython nbconvert ncurses + cmake cython nbconvert ncurses | $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/babel/dependencies b/build/pkgs/babel/dependencies index 41462907c20..802e470da86 100644 --- a/build/pkgs/babel/dependencies +++ b/build/pkgs/babel/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) pytz + | $(PYTHON_TOOLCHAIN) pytz $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/babel/distros/arch.txt b/build/pkgs/babel/distros/arch.txt new file mode 100644 index 00000000000..f2d828ccc5c --- /dev/null +++ b/build/pkgs/babel/distros/arch.txt @@ -0,0 +1 @@ +python-babel diff --git a/build/pkgs/babel/distros/debian.txt b/build/pkgs/babel/distros/debian.txt new file mode 100644 index 00000000000..e623eb68a31 --- /dev/null +++ b/build/pkgs/babel/distros/debian.txt @@ -0,0 +1 @@ +python3-babel diff --git a/build/pkgs/babel/distros/fedora.txt b/build/pkgs/babel/distros/fedora.txt new file mode 100644 index 00000000000..98f65931c4c --- /dev/null +++ b/build/pkgs/babel/distros/fedora.txt @@ -0,0 +1 @@ +babel diff --git a/build/pkgs/babel/distros/gentoo.txt b/build/pkgs/babel/distros/gentoo.txt new file mode 100644 index 00000000000..2d2c34fb697 --- /dev/null +++ b/build/pkgs/babel/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/Babel diff --git a/build/pkgs/babel/distros/opensuse.txt b/build/pkgs/babel/distros/opensuse.txt index 70bb05b1327..6372e2e77da 100644 --- a/build/pkgs/babel/distros/opensuse.txt +++ b/build/pkgs/babel/distros/opensuse.txt @@ -1 +1 @@ -python3-Babel +python3${PYTHON_MINOR}-Babel diff --git a/build/pkgs/babel/install-requires.txt b/build/pkgs/babel/install-requires.txt index 1d0d6191bb9..b4db5e907f3 100644 --- a/build/pkgs/babel/install-requires.txt +++ b/build/pkgs/babel/install-requires.txt @@ -1 +1 @@ -babel >=2.6.0 +babel >=2.11.0 diff --git a/build/pkgs/babel/spkg-configure.m4 b/build/pkgs/babel/spkg-configure.m4 new file mode 100644 index 00000000000..d7b9a71c811 --- /dev/null +++ b/build/pkgs/babel/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([babel], [SAGE_PYTHON_PACKAGE_CHECK([babel])]) diff --git a/build/pkgs/backcall/dependencies b/build/pkgs/backcall/dependencies index 902a5feed13..4fedbe70cd1 100644 --- a/build/pkgs/backcall/dependencies +++ b/build/pkgs/backcall/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) flit_core tomli + | $(PYTHON_TOOLCHAIN) flit_core tomli $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/backcall/distros/gentoo.txt b/build/pkgs/backcall/distros/gentoo.txt new file mode 100644 index 00000000000..266a222c558 --- /dev/null +++ b/build/pkgs/backcall/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/backcall diff --git a/build/pkgs/backcall/spkg-configure.m4 b/build/pkgs/backcall/spkg-configure.m4 new file mode 100644 index 00000000000..d6b11c49884 --- /dev/null +++ b/build/pkgs/backcall/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([backcall], [SAGE_PYTHON_PACKAGE_CHECK([backcall])]) diff --git a/build/pkgs/beautifulsoup4/dependencies b/build/pkgs/beautifulsoup4/dependencies index 01af7f65566..c9982dd1882 100644 --- a/build/pkgs/beautifulsoup4/dependencies +++ b/build/pkgs/beautifulsoup4/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) soupsieve | $(PYTHON_TOOLCHAIN) + soupsieve | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/beniget/dependencies b/build/pkgs/beniget/dependencies index d792a85db72..96da9efd5ac 100644 --- a/build/pkgs/beniget/dependencies +++ b/build/pkgs/beniget/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) gast | $(PYTHON_TOOLCHAIN) + gast | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/beniget/distros/gentoo.txt b/build/pkgs/beniget/distros/gentoo.txt new file mode 100644 index 00000000000..1a5972cd23f --- /dev/null +++ b/build/pkgs/beniget/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/beniget diff --git a/build/pkgs/beniget/spkg-configure.m4 b/build/pkgs/beniget/spkg-configure.m4 new file mode 100644 index 00000000000..8ae6101333e --- /dev/null +++ b/build/pkgs/beniget/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([beniget], [SAGE_PYTHON_PACKAGE_CHECK([beniget])]) diff --git a/build/pkgs/bleach/dependencies b/build/pkgs/bleach/dependencies index 4a74f9bfd68..c7ac2e8b3e7 100644 --- a/build/pkgs/bleach/dependencies +++ b/build/pkgs/bleach/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) packaging six webencodings | $(PYTHON_TOOLCHAIN) + packaging six webencodings | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/bleach/distros/arch.txt b/build/pkgs/bleach/distros/arch.txt new file mode 100644 index 00000000000..c5422ccff0c --- /dev/null +++ b/build/pkgs/bleach/distros/arch.txt @@ -0,0 +1 @@ +python-bleach diff --git a/build/pkgs/bleach/distros/debian.txt b/build/pkgs/bleach/distros/debian.txt new file mode 100644 index 00000000000..6d37c4c79f0 --- /dev/null +++ b/build/pkgs/bleach/distros/debian.txt @@ -0,0 +1 @@ +python3-bleach diff --git a/build/pkgs/bleach/distros/fedora.txt b/build/pkgs/bleach/distros/fedora.txt new file mode 100644 index 00000000000..c5422ccff0c --- /dev/null +++ b/build/pkgs/bleach/distros/fedora.txt @@ -0,0 +1 @@ +python-bleach diff --git a/build/pkgs/bleach/distros/gentoo.txt b/build/pkgs/bleach/distros/gentoo.txt new file mode 100644 index 00000000000..b4f9744eee9 --- /dev/null +++ b/build/pkgs/bleach/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/bleach diff --git a/build/pkgs/bleach/distros/opensuse.txt b/build/pkgs/bleach/distros/opensuse.txt new file mode 100644 index 00000000000..0e329f6dd62 --- /dev/null +++ b/build/pkgs/bleach/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-bleach diff --git a/build/pkgs/bleach/spkg-configure.m4 b/build/pkgs/bleach/spkg-configure.m4 new file mode 100644 index 00000000000..3c9bb26bb05 --- /dev/null +++ b/build/pkgs/bleach/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([bleach], [SAGE_PYTHON_PACKAGE_CHECK([bleach])]) diff --git a/build/pkgs/certifi/dependencies b/build/pkgs/certifi/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/certifi/dependencies +++ b/build/pkgs/certifi/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/certifi/distros/arch.txt b/build/pkgs/certifi/distros/arch.txt new file mode 100644 index 00000000000..be421c8b4b2 --- /dev/null +++ b/build/pkgs/certifi/distros/arch.txt @@ -0,0 +1 @@ +python-certifi diff --git a/build/pkgs/certifi/distros/debian.txt b/build/pkgs/certifi/distros/debian.txt new file mode 100644 index 00000000000..f585a823bf3 --- /dev/null +++ b/build/pkgs/certifi/distros/debian.txt @@ -0,0 +1 @@ +python3-certifi diff --git a/build/pkgs/certifi/distros/fedora.txt b/build/pkgs/certifi/distros/fedora.txt new file mode 100644 index 00000000000..be421c8b4b2 --- /dev/null +++ b/build/pkgs/certifi/distros/fedora.txt @@ -0,0 +1 @@ +python-certifi diff --git a/build/pkgs/certifi/distros/gentoo.txt b/build/pkgs/certifi/distros/gentoo.txt new file mode 100644 index 00000000000..72e2e91c6ae --- /dev/null +++ b/build/pkgs/certifi/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/certifi diff --git a/build/pkgs/certifi/distros/opensuse.txt b/build/pkgs/certifi/distros/opensuse.txt index f585a823bf3..9f7a6b5c964 100644 --- a/build/pkgs/certifi/distros/opensuse.txt +++ b/build/pkgs/certifi/distros/opensuse.txt @@ -1 +1 @@ -python3-certifi +python3${PYTHON_MINOR}-certifi diff --git a/build/pkgs/certifi/spkg-configure.m4 b/build/pkgs/certifi/spkg-configure.m4 new file mode 100644 index 00000000000..ddd40613514 --- /dev/null +++ b/build/pkgs/certifi/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([certifi], [SAGE_PYTHON_PACKAGE_CHECK([certifi])]) diff --git a/build/pkgs/cffi/dependencies b/build/pkgs/cffi/dependencies index 9e4c266ad69..9af7c6ed3db 100644 --- a/build/pkgs/cffi/dependencies +++ b/build/pkgs/cffi/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) pycparser + | $(PYTHON_TOOLCHAIN) pycparser $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cffi/distros/gentoo.txt b/build/pkgs/cffi/distros/gentoo.txt new file mode 100644 index 00000000000..81eeb8108c7 --- /dev/null +++ b/build/pkgs/cffi/distros/gentoo.txt @@ -0,0 +1 @@ +virtual/python-cffi diff --git a/build/pkgs/cffi/distros/opensuse.txt b/build/pkgs/cffi/distros/opensuse.txt index 68ec4dda5ba..6bce4cd18b5 100644 --- a/build/pkgs/cffi/distros/opensuse.txt +++ b/build/pkgs/cffi/distros/opensuse.txt @@ -1 +1 @@ -python3-cffi +python3${PYTHON_MINOR}-cffi diff --git a/build/pkgs/cffi/spkg-configure.m4 b/build/pkgs/cffi/spkg-configure.m4 new file mode 100644 index 00000000000..dc81875927f --- /dev/null +++ b/build/pkgs/cffi/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([cffi], [SAGE_PYTHON_PACKAGE_CHECK([cffi])]) diff --git a/build/pkgs/charset_normalizer/dependencies b/build/pkgs/charset_normalizer/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/charset_normalizer/dependencies +++ b/build/pkgs/charset_normalizer/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/charset_normalizer/distros/gentoo.txt b/build/pkgs/charset_normalizer/distros/gentoo.txt new file mode 100644 index 00000000000..eefeb89e31e --- /dev/null +++ b/build/pkgs/charset_normalizer/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/charset_normalizer diff --git a/build/pkgs/charset_normalizer/spkg-configure.m4 b/build/pkgs/charset_normalizer/spkg-configure.m4 new file mode 100644 index 00000000000..18b18cf32b4 --- /dev/null +++ b/build/pkgs/charset_normalizer/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([charset_normalizer], [ + SAGE_PYTHON_PACKAGE_CHECK([charset_normalizer]) +]) diff --git a/build/pkgs/cmake/checksums.ini b/build/pkgs/cmake/checksums.ini index c89abdf4277..a145b30dfb4 100644 --- a/build/pkgs/cmake/checksums.ini +++ b/build/pkgs/cmake/checksums.ini @@ -1,5 +1,5 @@ tarball=cmake-VERSION.tar.gz -sha1=256d6a57a57fa6ceaacd6a2daf708baefd33850c -md5=226dd564164372f9f7d1e21e38e6e8c5 -cksum=2080281918 +sha1=3e9b980bfb16974f57ca02b5e2b403a2ef2d4eca +md5=7228f5fcc8a858fdeac27e29bda0c144 +cksum=2027526722 upstream_url=https://github.com/Kitware/CMake/releases/download/vVERSION/cmake-VERSION.tar.gz diff --git a/build/pkgs/cmake/package-version.txt b/build/pkgs/cmake/package-version.txt index 693bd59e3e6..a155471fc06 100644 --- a/build/pkgs/cmake/package-version.txt +++ b/build/pkgs/cmake/package-version.txt @@ -1 +1 @@ -3.24.3 +3.27.3 diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index d1cae70f15b..657a407ed04 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,4 +1,4 @@ tarball=configure-VERSION.tar.gz -sha1=80ee52a3b6855149693204f0816bd0690947e7ae -md5=4292c175bba9299bd057980cec7060fd -cksum=3914108326 +sha1=0842a677c09b550b0c091037c63d141cf709595b +md5=615976ca4d2fcbf9b0559b809e5bf645 +cksum=792467397 diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index 3af414421cc..731312f1e86 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -57852a89c5c274ec6dbdd9269042972c7343e3ec +f9609a075a93ad4c6d270f129c6c33f4945e4bdc diff --git a/build/pkgs/contourpy/dependencies b/build/pkgs/contourpy/dependencies index 0740ab1d4a7..d12b50bf33c 100644 --- a/build/pkgs/contourpy/dependencies +++ b/build/pkgs/contourpy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) numpy | $(PYTHON_TOOLCHAIN) pybind11 + numpy | $(PYTHON_TOOLCHAIN) pybind11 $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/conway_polynomials/dependencies b/build/pkgs/conway_polynomials/dependencies index 1700e743d59..6b134137610 100644 --- a/build/pkgs/conway_polynomials/dependencies +++ b/build/pkgs/conway_polynomials/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) +| $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cppy/dependencies b/build/pkgs/cppy/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/cppy/dependencies +++ b/build/pkgs/cppy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cppy/install-requires.txt b/build/pkgs/cppy/install-requires.txt index 9d2b4aaeee0..42667a30148 100644 --- a/build/pkgs/cppy/install-requires.txt +++ b/build/pkgs/cppy/install-requires.txt @@ -1 +1 @@ -cppy +cppy >=1.2.0 diff --git a/build/pkgs/cryptominisat/dependencies b/build/pkgs/cryptominisat/dependencies index 15e88888b6d..e30473e40f6 100644 --- a/build/pkgs/cryptominisat/dependencies +++ b/build/pkgs/cryptominisat/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) m4ri zlib libpng | cmake boost_cropped + m4ri zlib libpng | cmake boost_cropped $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cvxopt/dependencies b/build/pkgs/cvxopt/dependencies index d47ae01f215..33055fe8bf4 100644 --- a/build/pkgs/cvxopt/dependencies +++ b/build/pkgs/cvxopt/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) numpy $(BLAS) gsl glpk suitesparse | $(PYTHON_TOOLCHAIN) pkgconfig + numpy $(BLAS) gsl glpk suitesparse | $(PYTHON_TOOLCHAIN) pkgconfig $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cvxopt/distros/arch.txt b/build/pkgs/cvxopt/distros/arch.txt new file mode 100644 index 00000000000..f15770f0506 --- /dev/null +++ b/build/pkgs/cvxopt/distros/arch.txt @@ -0,0 +1 @@ +python-cvxopt diff --git a/build/pkgs/cvxopt/distros/debian.txt b/build/pkgs/cvxopt/distros/debian.txt new file mode 100644 index 00000000000..2bb6ad1e834 --- /dev/null +++ b/build/pkgs/cvxopt/distros/debian.txt @@ -0,0 +1 @@ +python3-cvxopt diff --git a/build/pkgs/cvxopt/distros/fedora.txt b/build/pkgs/cvxopt/distros/fedora.txt new file mode 100644 index 00000000000..f15770f0506 --- /dev/null +++ b/build/pkgs/cvxopt/distros/fedora.txt @@ -0,0 +1 @@ +python-cvxopt diff --git a/build/pkgs/cvxopt/distros/gentoo.txt b/build/pkgs/cvxopt/distros/gentoo.txt new file mode 100644 index 00000000000..b3123912bbe --- /dev/null +++ b/build/pkgs/cvxopt/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/cvxopt diff --git a/build/pkgs/cvxopt/distros/opensuse.txt b/build/pkgs/cvxopt/distros/opensuse.txt new file mode 100644 index 00000000000..e254c198706 --- /dev/null +++ b/build/pkgs/cvxopt/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-cvxopt diff --git a/build/pkgs/cvxopt/spkg-configure.m4 b/build/pkgs/cvxopt/spkg-configure.m4 new file mode 100644 index 00000000000..c4aa6198edb --- /dev/null +++ b/build/pkgs/cvxopt/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([cvxopt], [ + SAGE_SPKG_DEPCHECK([gsl glpk suitesparse], [ + SAGE_PYTHON_PACKAGE_CHECK([cvxopt]) + ]) +]) diff --git a/build/pkgs/cvxpy/dependencies b/build/pkgs/cvxpy/dependencies index 540b44ff0f2..42cfab890cc 100644 --- a/build/pkgs/cvxpy/dependencies +++ b/build/pkgs/cvxpy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) numpy scipy glpk cvxopt osqp_python ecos_python scs | $(PYTHON_TOOLCHAIN) + numpy scipy glpk cvxopt osqp_python ecos_python scs | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cycler/dependencies b/build/pkgs/cycler/dependencies index 730af09b339..2218ed812dd 100644 --- a/build/pkgs/cycler/dependencies +++ b/build/pkgs/cycler/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) six | $(PYTHON_TOOLCHAIN) + six | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cycler/distros/arch.txt b/build/pkgs/cycler/distros/arch.txt new file mode 100644 index 00000000000..5727259aca6 --- /dev/null +++ b/build/pkgs/cycler/distros/arch.txt @@ -0,0 +1 @@ +python-cycler diff --git a/build/pkgs/cycler/distros/debian.txt b/build/pkgs/cycler/distros/debian.txt new file mode 100644 index 00000000000..c77685dd417 --- /dev/null +++ b/build/pkgs/cycler/distros/debian.txt @@ -0,0 +1 @@ +python3-cycler diff --git a/build/pkgs/cycler/distros/fedora.txt b/build/pkgs/cycler/distros/fedora.txt new file mode 100644 index 00000000000..5727259aca6 --- /dev/null +++ b/build/pkgs/cycler/distros/fedora.txt @@ -0,0 +1 @@ +python-cycler diff --git a/build/pkgs/cycler/distros/freebsd.txt b/build/pkgs/cycler/distros/freebsd.txt new file mode 100644 index 00000000000..6da1dabb333 --- /dev/null +++ b/build/pkgs/cycler/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-cycler diff --git a/build/pkgs/cycler/distros/gentoo.txt b/build/pkgs/cycler/distros/gentoo.txt new file mode 100644 index 00000000000..4b215438e8f --- /dev/null +++ b/build/pkgs/cycler/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/cycler diff --git a/build/pkgs/cycler/distros/opensuse.txt b/build/pkgs/cycler/distros/opensuse.txt new file mode 100644 index 00000000000..6aab7454acb --- /dev/null +++ b/build/pkgs/cycler/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-Cycler diff --git a/build/pkgs/cycler/spkg-configure.m4 b/build/pkgs/cycler/spkg-configure.m4 new file mode 100644 index 00000000000..239571a0f10 --- /dev/null +++ b/build/pkgs/cycler/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([cycler], [SAGE_PYTHON_PACKAGE_CHECK([cycler])]) diff --git a/build/pkgs/cylp/dependencies b/build/pkgs/cylp/dependencies index 3c541129eb9..d2c6405119d 100644 --- a/build/pkgs/cylp/dependencies +++ b/build/pkgs/cylp/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) numpy scipy cbc | $(PYTHON_TOOLCHAIN) cython + numpy scipy cbc | $(PYTHON_TOOLCHAIN) cython $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cypari/dependencies b/build/pkgs/cypari/dependencies index 72b5af7ad81..69dfe7e7d8a 100644 --- a/build/pkgs/cypari/dependencies +++ b/build/pkgs/cypari/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cython pari cysignals | $(PYTHON_TOOLCHAIN) + cython pari cysignals | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cysignals/dependencies b/build/pkgs/cysignals/dependencies index d3225d480f1..cd45ae2076c 100644 --- a/build/pkgs/cysignals/dependencies +++ b/build/pkgs/cysignals/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cython pari | $(PYTHON_TOOLCHAIN) + cython pari | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cython/dependencies b/build/pkgs/cython/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/cython/dependencies +++ b/build/pkgs/cython/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cython/distros/arch.txt b/build/pkgs/cython/distros/arch.txt new file mode 100644 index 00000000000..f6629e02456 --- /dev/null +++ b/build/pkgs/cython/distros/arch.txt @@ -0,0 +1 @@ +cython diff --git a/build/pkgs/cython/distros/debian.txt b/build/pkgs/cython/distros/debian.txt new file mode 100644 index 00000000000..f6629e02456 --- /dev/null +++ b/build/pkgs/cython/distros/debian.txt @@ -0,0 +1 @@ +cython diff --git a/build/pkgs/cython/distros/fedora.txt b/build/pkgs/cython/distros/fedora.txt new file mode 100644 index 00000000000..002d1b93c6f --- /dev/null +++ b/build/pkgs/cython/distros/fedora.txt @@ -0,0 +1 @@ +Cython diff --git a/build/pkgs/cython/distros/gentoo.txt b/build/pkgs/cython/distros/gentoo.txt new file mode 100644 index 00000000000..bb1512a15ba --- /dev/null +++ b/build/pkgs/cython/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/cython diff --git a/build/pkgs/cython/distros/opensuse.txt b/build/pkgs/cython/distros/opensuse.txt new file mode 100644 index 00000000000..09d8844feaf --- /dev/null +++ b/build/pkgs/cython/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-Cython diff --git a/build/pkgs/database_cubic_hecke/dependencies b/build/pkgs/database_cubic_hecke/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/database_cubic_hecke/dependencies +++ b/build/pkgs/database_cubic_hecke/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/database_knotinfo/dependencies b/build/pkgs/database_knotinfo/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/database_knotinfo/dependencies +++ b/build/pkgs/database_knotinfo/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/dateutil/dependencies b/build/pkgs/dateutil/dependencies index 7a972de985e..a90844872ae 100644 --- a/build/pkgs/dateutil/dependencies +++ b/build/pkgs/dateutil/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) six | $(PYTHON_TOOLCHAIN) + six | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/dateutil/distros/arch.txt b/build/pkgs/dateutil/distros/arch.txt new file mode 100644 index 00000000000..0f08daace31 --- /dev/null +++ b/build/pkgs/dateutil/distros/arch.txt @@ -0,0 +1 @@ +python-dateutil diff --git a/build/pkgs/dateutil/distros/debian.txt b/build/pkgs/dateutil/distros/debian.txt new file mode 100644 index 00000000000..2f46170765c --- /dev/null +++ b/build/pkgs/dateutil/distros/debian.txt @@ -0,0 +1 @@ +python3-dateutil diff --git a/build/pkgs/dateutil/distros/fedora.txt b/build/pkgs/dateutil/distros/fedora.txt new file mode 100644 index 00000000000..0f08daace31 --- /dev/null +++ b/build/pkgs/dateutil/distros/fedora.txt @@ -0,0 +1 @@ +python-dateutil diff --git a/build/pkgs/dateutil/distros/freebsd.txt b/build/pkgs/dateutil/distros/freebsd.txt new file mode 100644 index 00000000000..c336f5e0b1d --- /dev/null +++ b/build/pkgs/dateutil/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-dateutil diff --git a/build/pkgs/dateutil/distros/gentoo.txt b/build/pkgs/dateutil/distros/gentoo.txt new file mode 100644 index 00000000000..e129df768dc --- /dev/null +++ b/build/pkgs/dateutil/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/python-dateutil diff --git a/build/pkgs/dateutil/distros/opensuse.txt b/build/pkgs/dateutil/distros/opensuse.txt new file mode 100644 index 00000000000..ba37df671e5 --- /dev/null +++ b/build/pkgs/dateutil/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-python-dateutil diff --git a/build/pkgs/dateutil/install-requires.txt b/build/pkgs/dateutil/install-requires.txt index 0ae93da485e..face537605d 100644 --- a/build/pkgs/dateutil/install-requires.txt +++ b/build/pkgs/dateutil/install-requires.txt @@ -1 +1 @@ -dateutil >=2.8.1 +python-dateutil >=2.8.1 diff --git a/build/pkgs/dateutil/spkg-configure.m4 b/build/pkgs/dateutil/spkg-configure.m4 new file mode 100644 index 00000000000..fdcd1273975 --- /dev/null +++ b/build/pkgs/dateutil/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([dateutil], [SAGE_PYTHON_PACKAGE_CHECK([dateutil])]) diff --git a/build/pkgs/debugpy/dependencies b/build/pkgs/debugpy/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/debugpy/dependencies +++ b/build/pkgs/debugpy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/debugpy/distros/gentoo.txt b/build/pkgs/debugpy/distros/gentoo.txt new file mode 100644 index 00000000000..8b797ce715f --- /dev/null +++ b/build/pkgs/debugpy/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/debugpy diff --git a/build/pkgs/debugpy/spkg-configure.m4 b/build/pkgs/debugpy/spkg-configure.m4 new file mode 100644 index 00000000000..db605ff03c8 --- /dev/null +++ b/build/pkgs/debugpy/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([debugpy], [SAGE_PYTHON_PACKAGE_CHECK([debugpy])]) diff --git a/build/pkgs/decorator/dependencies b/build/pkgs/decorator/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/decorator/dependencies +++ b/build/pkgs/decorator/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/decorator/distros/arch.txt b/build/pkgs/decorator/distros/arch.txt new file mode 100644 index 00000000000..079560412f1 --- /dev/null +++ b/build/pkgs/decorator/distros/arch.txt @@ -0,0 +1 @@ +python-decorator diff --git a/build/pkgs/decorator/distros/debian.txt b/build/pkgs/decorator/distros/debian.txt new file mode 100644 index 00000000000..46c478e1513 --- /dev/null +++ b/build/pkgs/decorator/distros/debian.txt @@ -0,0 +1 @@ +python3-decorator diff --git a/build/pkgs/decorator/distros/fedora.txt b/build/pkgs/decorator/distros/fedora.txt new file mode 100644 index 00000000000..079560412f1 --- /dev/null +++ b/build/pkgs/decorator/distros/fedora.txt @@ -0,0 +1 @@ +python-decorator diff --git a/build/pkgs/decorator/distros/gentoo.txt b/build/pkgs/decorator/distros/gentoo.txt new file mode 100644 index 00000000000..fea5a67ac9e --- /dev/null +++ b/build/pkgs/decorator/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/decorator diff --git a/build/pkgs/decorator/distros/opensuse.txt b/build/pkgs/decorator/distros/opensuse.txt index 46c478e1513..4b9085da296 100644 --- a/build/pkgs/decorator/distros/opensuse.txt +++ b/build/pkgs/decorator/distros/opensuse.txt @@ -1 +1 @@ -python3-decorator +python3${PYTHON_MINOR}-decorator diff --git a/build/pkgs/decorator/spkg-configure.m4 b/build/pkgs/decorator/spkg-configure.m4 new file mode 100644 index 00000000000..e062778d6db --- /dev/null +++ b/build/pkgs/decorator/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([decorator], [SAGE_PYTHON_PACKAGE_CHECK([decorator])]) diff --git a/build/pkgs/defusedxml/dependencies b/build/pkgs/defusedxml/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/defusedxml/dependencies +++ b/build/pkgs/defusedxml/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/defusedxml/distros/gentoo.txt b/build/pkgs/defusedxml/distros/gentoo.txt new file mode 100644 index 00000000000..2804214449e --- /dev/null +++ b/build/pkgs/defusedxml/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/defusedxml diff --git a/build/pkgs/defusedxml/spkg-configure.m4 b/build/pkgs/defusedxml/spkg-configure.m4 new file mode 100644 index 00000000000..e02f34524ce --- /dev/null +++ b/build/pkgs/defusedxml/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([defusedxml], [SAGE_PYTHON_PACKAGE_CHECK([defusedxml])]) diff --git a/build/pkgs/deprecation/dependencies b/build/pkgs/deprecation/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/deprecation/dependencies +++ b/build/pkgs/deprecation/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/distlib/dependencies b/build/pkgs/distlib/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/distlib/dependencies +++ b/build/pkgs/distlib/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/docutils/dependencies b/build/pkgs/docutils/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/docutils/dependencies +++ b/build/pkgs/docutils/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/docutils/distros/gentoo.txt b/build/pkgs/docutils/distros/gentoo.txt new file mode 100644 index 00000000000..fe4a4524cbb --- /dev/null +++ b/build/pkgs/docutils/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/docutils diff --git a/build/pkgs/docutils/distros/opensuse.txt b/build/pkgs/docutils/distros/opensuse.txt index a4bb792a5a4..a7fcdac14ef 100644 --- a/build/pkgs/docutils/distros/opensuse.txt +++ b/build/pkgs/docutils/distros/opensuse.txt @@ -1 +1 @@ -python3-docutils +python3${PYTHON_MINOR}-docutils diff --git a/build/pkgs/docutils/spkg-configure.m4 b/build/pkgs/docutils/spkg-configure.m4 new file mode 100644 index 00000000000..3584e4513c6 --- /dev/null +++ b/build/pkgs/docutils/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([docutils], [SAGE_PYTHON_PACKAGE_CHECK([docutils])]) diff --git a/build/pkgs/dot2tex/dependencies b/build/pkgs/dot2tex/dependencies index c1925d16b73..75d8c64edb5 100644 --- a/build/pkgs/dot2tex/dependencies +++ b/build/pkgs/dot2tex/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) pyparsing + | $(PYTHON_TOOLCHAIN) pyparsing $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ecos_python/dependencies b/build/pkgs/ecos_python/dependencies index ecd3af7675b..aaf3b261709 100644 --- a/build/pkgs/ecos_python/dependencies +++ b/build/pkgs/ecos_python/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) numpy scipy | $(PYTHON_TOOLCHAIN) + numpy scipy | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/editables/dependencies b/build/pkgs/editables/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/editables/dependencies +++ b/build/pkgs/editables/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/elliptic_curves/dependencies b/build/pkgs/elliptic_curves/dependencies index 6b134137610..3518086ab84 100644 --- a/build/pkgs/elliptic_curves/dependencies +++ b/build/pkgs/elliptic_curves/dependencies @@ -1,4 +1,4 @@ -| $(PYTHON) +| $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/entrypoints/dependencies b/build/pkgs/entrypoints/dependencies index 902a5feed13..4fedbe70cd1 100644 --- a/build/pkgs/entrypoints/dependencies +++ b/build/pkgs/entrypoints/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) flit_core tomli + | $(PYTHON_TOOLCHAIN) flit_core tomli $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/entrypoints/distros/gentoo.txt b/build/pkgs/entrypoints/distros/gentoo.txt new file mode 100644 index 00000000000..684ddd036ee --- /dev/null +++ b/build/pkgs/entrypoints/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/entrypoints diff --git a/build/pkgs/entrypoints/spkg-configure.m4 b/build/pkgs/entrypoints/spkg-configure.m4 new file mode 100644 index 00000000000..caed658b69a --- /dev/null +++ b/build/pkgs/entrypoints/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([entrypoints], [SAGE_PYTHON_PACKAGE_CHECK([entrypoints])]) diff --git a/build/pkgs/executing/dependencies b/build/pkgs/executing/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/executing/dependencies +++ b/build/pkgs/executing/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/fastjsonschema/dependencies b/build/pkgs/fastjsonschema/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/fastjsonschema/dependencies +++ b/build/pkgs/fastjsonschema/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/filelock/dependencies b/build/pkgs/filelock/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/filelock/dependencies +++ b/build/pkgs/filelock/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/flit_core/dependencies b/build/pkgs/flit_core/dependencies index 93c460228b4..644ad35f773 100644 --- a/build/pkgs/flit_core/dependencies +++ b/build/pkgs/flit_core/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | pip + | pip $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/flit_core/distros/gentoo.txt b/build/pkgs/flit_core/distros/gentoo.txt new file mode 100644 index 00000000000..fe6bea92362 --- /dev/null +++ b/build/pkgs/flit_core/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/flit_core diff --git a/build/pkgs/flit_core/install-requires.txt b/build/pkgs/flit_core/install-requires.txt index 14ccfd92035..88b912bf11a 100644 --- a/build/pkgs/flit_core/install-requires.txt +++ b/build/pkgs/flit_core/install-requires.txt @@ -1 +1 @@ -flit-core +flit-core >= 3.7.1 diff --git a/build/pkgs/flit_core/spkg-configure.m4 b/build/pkgs/flit_core/spkg-configure.m4 new file mode 100644 index 00000000000..ee67557024f --- /dev/null +++ b/build/pkgs/flit_core/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([flit_core], [SAGE_PYTHON_PACKAGE_CHECK([flit_core])]) diff --git a/build/pkgs/fonttools/dependencies b/build/pkgs/fonttools/dependencies index 9c736669d9a..909380550a2 100644 --- a/build/pkgs/fonttools/dependencies +++ b/build/pkgs/fonttools/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) cython + | $(PYTHON_TOOLCHAIN) cython $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/fpylll/dependencies b/build/pkgs/fpylll/dependencies index 4b4fb1b44fb..4837249bcfa 100644 --- a/build/pkgs/fpylll/dependencies +++ b/build/pkgs/fpylll/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cython cysignals numpy fplll + cython cysignals numpy fplll | $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/furo/dependencies b/build/pkgs/furo/dependencies index fec067b2058..07434099dee 100644 --- a/build/pkgs/furo/dependencies +++ b/build/pkgs/furo/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) beautifulsoup4 sphinx pygments sphinx_basic_ng | $(PYTHON_TOOLCHAIN) + beautifulsoup4 sphinx pygments sphinx_basic_ng | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/gambit/dependencies b/build/pkgs/gambit/dependencies index 1f00cbf5321..e026bfaacf9 100644 --- a/build/pkgs/gambit/dependencies +++ b/build/pkgs/gambit/dependencies @@ -1,4 +1,4 @@ -cython | $(PYTHON_TOOLCHAIN) +cython | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/gap_jupyter/dependencies b/build/pkgs/gap_jupyter/dependencies index 41133c3ff0a..89f9b88dd92 100644 --- a/build/pkgs/gap_jupyter/dependencies +++ b/build/pkgs/gap_jupyter/dependencies @@ -1 +1 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) ipython gap + | $(PYTHON_TOOLCHAIN) ipython gap $(PYTHON) diff --git a/build/pkgs/gast/checksums.ini b/build/pkgs/gast/checksums.ini index 1aa653229f2..57bc0736a13 100644 --- a/build/pkgs/gast/checksums.ini +++ b/build/pkgs/gast/checksums.ini @@ -1,5 +1,5 @@ tarball=gast-VERSION.tar.gz -sha1=a84811eedebc5bca94b4eae978aab5f2c805b106 -md5=fdff900805e03e9dd76d377eb4cbaed7 -cksum=387443419 +sha1=6c113cf8d33cc654d33210335103485ab41d3dbb +md5=907c689e3fdbc7a48cc010e665195baa +cksum=218846575 upstream_url=https://pypi.io/packages/source/g/gast/gast-VERSION.tar.gz diff --git a/build/pkgs/gast/dependencies b/build/pkgs/gast/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/gast/dependencies +++ b/build/pkgs/gast/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/gast/distros/gentoo.txt b/build/pkgs/gast/distros/gentoo.txt new file mode 100644 index 00000000000..3be5e7e785c --- /dev/null +++ b/build/pkgs/gast/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/gast diff --git a/build/pkgs/gast/package-version.txt b/build/pkgs/gast/package-version.txt index be14282b7ff..7d8568351b4 100644 --- a/build/pkgs/gast/package-version.txt +++ b/build/pkgs/gast/package-version.txt @@ -1 +1 @@ -0.5.3 +0.5.4 diff --git a/build/pkgs/gast/spkg-configure.m4 b/build/pkgs/gast/spkg-configure.m4 new file mode 100644 index 00000000000..26ec59feaee --- /dev/null +++ b/build/pkgs/gast/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([gast], [SAGE_PYTHON_PACKAGE_CHECK([gast])]) diff --git a/build/pkgs/gdb/dependencies b/build/pkgs/gdb/dependencies index bdf81f77180..cf6822bb92e 100644 --- a/build/pkgs/gdb/dependencies +++ b/build/pkgs/gdb/dependencies @@ -1,4 +1,4 @@ -mpfr zlib ncurses $(PYTHON) xz +mpfr zlib ncurses xz | $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/gitpython/dependencies b/build/pkgs/gitpython/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/gitpython/dependencies +++ b/build/pkgs/gitpython/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/gmpy2/dependencies b/build/pkgs/gmpy2/dependencies index 98c6065dc87..b1f92b9241d 100644 --- a/build/pkgs/gmpy2/dependencies +++ b/build/pkgs/gmpy2/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) $(MP_LIBRARY) mpfr mpc | $(PYTHON_TOOLCHAIN) + $(MP_LIBRARY) mpfr mpc | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/gmpy2/distros/arch.txt b/build/pkgs/gmpy2/distros/arch.txt new file mode 100644 index 00000000000..d4464a5ce2c --- /dev/null +++ b/build/pkgs/gmpy2/distros/arch.txt @@ -0,0 +1 @@ +python-gmpy2 diff --git a/build/pkgs/gmpy2/distros/debian.txt b/build/pkgs/gmpy2/distros/debian.txt new file mode 100644 index 00000000000..afdd6281722 --- /dev/null +++ b/build/pkgs/gmpy2/distros/debian.txt @@ -0,0 +1 @@ +python3-gmpy2 diff --git a/build/pkgs/gmpy2/distros/fedora.txt b/build/pkgs/gmpy2/distros/fedora.txt new file mode 100644 index 00000000000..d4464a5ce2c --- /dev/null +++ b/build/pkgs/gmpy2/distros/fedora.txt @@ -0,0 +1 @@ +python-gmpy2 diff --git a/build/pkgs/gmpy2/distros/freebsd.txt b/build/pkgs/gmpy2/distros/freebsd.txt new file mode 100644 index 00000000000..0d9d2c435a6 --- /dev/null +++ b/build/pkgs/gmpy2/distros/freebsd.txt @@ -0,0 +1 @@ +math/py-gmpy2 diff --git a/build/pkgs/gmpy2/distros/gentoo.txt b/build/pkgs/gmpy2/distros/gentoo.txt new file mode 100644 index 00000000000..519f9d8729a --- /dev/null +++ b/build/pkgs/gmpy2/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/gmpy diff --git a/build/pkgs/gmpy2/distros/opensuse.txt b/build/pkgs/gmpy2/distros/opensuse.txt new file mode 100644 index 00000000000..36d52b88ba6 --- /dev/null +++ b/build/pkgs/gmpy2/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-gmpy2 diff --git a/build/pkgs/hatch_fancy_pypi_readme/dependencies b/build/pkgs/hatch_fancy_pypi_readme/dependencies index 8cd44d06682..cfb7c484697 100644 --- a/build/pkgs/hatch_fancy_pypi_readme/dependencies +++ b/build/pkgs/hatch_fancy_pypi_readme/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) hatchling + | $(PYTHON_TOOLCHAIN) hatchling $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/hatch_nodejs_version/dependencies b/build/pkgs/hatch_nodejs_version/dependencies index e9293f104ca..85e8893f785 100644 --- a/build/pkgs/hatch_nodejs_version/dependencies +++ b/build/pkgs/hatch_nodejs_version/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) hatchling | $(PYTHON_TOOLCHAIN) + hatchling | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/hatch_vcs/dependencies b/build/pkgs/hatch_vcs/dependencies index 8cd44d06682..cfb7c484697 100644 --- a/build/pkgs/hatch_vcs/dependencies +++ b/build/pkgs/hatch_vcs/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) hatchling + | $(PYTHON_TOOLCHAIN) hatchling $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/hatchling/dependencies b/build/pkgs/hatchling/dependencies index 84b5ea48ccc..4c10ae56e2e 100644 --- a/build/pkgs/hatchling/dependencies +++ b/build/pkgs/hatchling/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pathspec tomli editables pluggy packaging | $(PYTHON_TOOLCHAIN) + pathspec tomli editables pluggy packaging | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/html5lib/dependencies b/build/pkgs/html5lib/dependencies index 89200065387..7ebee8487db 100644 --- a/build/pkgs/html5lib/dependencies +++ b/build/pkgs/html5lib/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) webencodings | $(PYTHON_TOOLCHAIN) + webencodings | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/html5lib/distros/arch.txt b/build/pkgs/html5lib/distros/arch.txt new file mode 100644 index 00000000000..b821491e116 --- /dev/null +++ b/build/pkgs/html5lib/distros/arch.txt @@ -0,0 +1 @@ +python-html5lib diff --git a/build/pkgs/html5lib/distros/debian.txt b/build/pkgs/html5lib/distros/debian.txt new file mode 100644 index 00000000000..6d7b8dfb001 --- /dev/null +++ b/build/pkgs/html5lib/distros/debian.txt @@ -0,0 +1 @@ +python3-html5lib diff --git a/build/pkgs/html5lib/distros/fedora.txt b/build/pkgs/html5lib/distros/fedora.txt new file mode 100644 index 00000000000..b821491e116 --- /dev/null +++ b/build/pkgs/html5lib/distros/fedora.txt @@ -0,0 +1 @@ +python-html5lib diff --git a/build/pkgs/html5lib/distros/gentoo.txt b/build/pkgs/html5lib/distros/gentoo.txt new file mode 100644 index 00000000000..6c2be76429c --- /dev/null +++ b/build/pkgs/html5lib/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/html5lib diff --git a/build/pkgs/html5lib/distros/opensuse.txt b/build/pkgs/html5lib/distros/opensuse.txt new file mode 100644 index 00000000000..99d5afb4a02 --- /dev/null +++ b/build/pkgs/html5lib/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-html5lib diff --git a/build/pkgs/html5lib/spkg-configure.m4 b/build/pkgs/html5lib/spkg-configure.m4 new file mode 100644 index 00000000000..f421b7e87db --- /dev/null +++ b/build/pkgs/html5lib/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([html5lib], [SAGE_PYTHON_PACKAGE_CHECK([html5lib])]) diff --git a/build/pkgs/idna/dependencies b/build/pkgs/idna/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/idna/dependencies +++ b/build/pkgs/idna/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/idna/distros/arch.txt b/build/pkgs/idna/distros/arch.txt new file mode 100644 index 00000000000..a73e70cade0 --- /dev/null +++ b/build/pkgs/idna/distros/arch.txt @@ -0,0 +1 @@ +python-idna diff --git a/build/pkgs/idna/distros/debian.txt b/build/pkgs/idna/distros/debian.txt new file mode 100644 index 00000000000..de48e70887b --- /dev/null +++ b/build/pkgs/idna/distros/debian.txt @@ -0,0 +1 @@ +python3-idna diff --git a/build/pkgs/idna/distros/fedora.txt b/build/pkgs/idna/distros/fedora.txt new file mode 100644 index 00000000000..a73e70cade0 --- /dev/null +++ b/build/pkgs/idna/distros/fedora.txt @@ -0,0 +1 @@ +python-idna diff --git a/build/pkgs/idna/distros/gentoo.txt b/build/pkgs/idna/distros/gentoo.txt new file mode 100644 index 00000000000..68ef51c453e --- /dev/null +++ b/build/pkgs/idna/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/idna diff --git a/build/pkgs/idna/distros/opensuse.txt b/build/pkgs/idna/distros/opensuse.txt new file mode 100644 index 00000000000..ea8400fa563 --- /dev/null +++ b/build/pkgs/idna/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-idna diff --git a/build/pkgs/idna/spkg-configure.m4 b/build/pkgs/idna/spkg-configure.m4 new file mode 100644 index 00000000000..9d363f212e6 --- /dev/null +++ b/build/pkgs/idna/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([idna], [SAGE_PYTHON_PACKAGE_CHECK([idna])]) diff --git a/build/pkgs/imagesize/dependencies b/build/pkgs/imagesize/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/imagesize/dependencies +++ b/build/pkgs/imagesize/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/imagesize/distros/gentoo.txt b/build/pkgs/imagesize/distros/gentoo.txt new file mode 100644 index 00000000000..54350ba2642 --- /dev/null +++ b/build/pkgs/imagesize/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/imagesize diff --git a/build/pkgs/imagesize/spkg-configure.m4 b/build/pkgs/imagesize/spkg-configure.m4 new file mode 100644 index 00000000000..20210eff2f0 --- /dev/null +++ b/build/pkgs/imagesize/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([imagesize], [SAGE_PYTHON_PACKAGE_CHECK([imagesize])]) diff --git a/build/pkgs/importlib_metadata/dependencies b/build/pkgs/importlib_metadata/dependencies index 77aa2a42f93..3c8d3aeb24e 100644 --- a/build/pkgs/importlib_metadata/dependencies +++ b/build/pkgs/importlib_metadata/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) zipp typing_extensions | $(PYTHON_TOOLCHAIN) tomli + zipp typing_extensions | $(PYTHON_TOOLCHAIN) tomli $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/importlib_metadata/distros/arch.txt b/build/pkgs/importlib_metadata/distros/arch.txt new file mode 100644 index 00000000000..b3c206287ec --- /dev/null +++ b/build/pkgs/importlib_metadata/distros/arch.txt @@ -0,0 +1 @@ +python-importlib-metadata diff --git a/build/pkgs/importlib_metadata/distros/debian.txt b/build/pkgs/importlib_metadata/distros/debian.txt new file mode 100644 index 00000000000..c005bf38793 --- /dev/null +++ b/build/pkgs/importlib_metadata/distros/debian.txt @@ -0,0 +1 @@ +python3-importlib-metadata diff --git a/build/pkgs/importlib_metadata/distros/fedora.txt b/build/pkgs/importlib_metadata/distros/fedora.txt new file mode 100644 index 00000000000..b3c206287ec --- /dev/null +++ b/build/pkgs/importlib_metadata/distros/fedora.txt @@ -0,0 +1 @@ +python-importlib-metadata diff --git a/build/pkgs/importlib_metadata/distros/freebsd.txt b/build/pkgs/importlib_metadata/distros/freebsd.txt new file mode 100644 index 00000000000..23518da7cff --- /dev/null +++ b/build/pkgs/importlib_metadata/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-importlib-metadata diff --git a/build/pkgs/importlib_metadata/distros/gentoo.txt b/build/pkgs/importlib_metadata/distros/gentoo.txt new file mode 100644 index 00000000000..4f927864c2b --- /dev/null +++ b/build/pkgs/importlib_metadata/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/importlib_metadata diff --git a/build/pkgs/importlib_metadata/distros/opensuse.txt b/build/pkgs/importlib_metadata/distros/opensuse.txt new file mode 100644 index 00000000000..7a665131cd4 --- /dev/null +++ b/build/pkgs/importlib_metadata/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-importlib-metadata diff --git a/build/pkgs/importlib_metadata/spkg-configure.m4 b/build/pkgs/importlib_metadata/spkg-configure.m4 new file mode 100644 index 00000000000..0554e522252 --- /dev/null +++ b/build/pkgs/importlib_metadata/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([importlib_metadata], [ + SAGE_PYTHON_PACKAGE_CHECK([importlib_metadata]) +]) diff --git a/build/pkgs/importlib_resources/dependencies b/build/pkgs/importlib_resources/dependencies index 58927ab6f75..655283898b7 100644 --- a/build/pkgs/importlib_resources/dependencies +++ b/build/pkgs/importlib_resources/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) zipp | $(PYTHON_TOOLCHAIN) + zipp | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/importlib_resources/distros/gentoo.txt b/build/pkgs/importlib_resources/distros/gentoo.txt new file mode 100644 index 00000000000..d5e1f2cf6a8 --- /dev/null +++ b/build/pkgs/importlib_resources/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/importlib_resources diff --git a/build/pkgs/importlib_resources/spkg-configure.m4 b/build/pkgs/importlib_resources/spkg-configure.m4 new file mode 100644 index 00000000000..50df55b4643 --- /dev/null +++ b/build/pkgs/importlib_resources/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([importlib_resources], [ + SAGE_PYTHON_PACKAGE_CHECK([importlib_resources]) +]) diff --git a/build/pkgs/ipykernel/dependencies b/build/pkgs/ipykernel/dependencies index 792c3e70634..7e153a0cb46 100644 --- a/build/pkgs/ipykernel/dependencies +++ b/build/pkgs/ipykernel/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) ipython_genutils importlib_metadata matplotlib_inline ipython jupyter_client tornado appnope traitlets executing | $(PYTHON_TOOLCHAIN) + ipython_genutils importlib_metadata matplotlib_inline ipython jupyter_client tornado appnope traitlets executing | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ipykernel/distros/arch.txt b/build/pkgs/ipykernel/distros/arch.txt new file mode 100644 index 00000000000..286458797f7 --- /dev/null +++ b/build/pkgs/ipykernel/distros/arch.txt @@ -0,0 +1 @@ +python-ipykernel diff --git a/build/pkgs/ipykernel/distros/debian.txt b/build/pkgs/ipykernel/distros/debian.txt new file mode 100644 index 00000000000..d919f6f3190 --- /dev/null +++ b/build/pkgs/ipykernel/distros/debian.txt @@ -0,0 +1 @@ +ipykernel diff --git a/build/pkgs/ipykernel/distros/fedora.txt b/build/pkgs/ipykernel/distros/fedora.txt new file mode 100644 index 00000000000..286458797f7 --- /dev/null +++ b/build/pkgs/ipykernel/distros/fedora.txt @@ -0,0 +1 @@ +python-ipykernel diff --git a/build/pkgs/ipykernel/distros/freebsd.txt b/build/pkgs/ipykernel/distros/freebsd.txt new file mode 100644 index 00000000000..92235f132be --- /dev/null +++ b/build/pkgs/ipykernel/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-ipykernel diff --git a/build/pkgs/ipykernel/distros/gentoo.txt b/build/pkgs/ipykernel/distros/gentoo.txt new file mode 100644 index 00000000000..88aab61ef39 --- /dev/null +++ b/build/pkgs/ipykernel/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/ipykernel diff --git a/build/pkgs/ipykernel/distros/opensuse.txt b/build/pkgs/ipykernel/distros/opensuse.txt new file mode 100644 index 00000000000..1485db27e0d --- /dev/null +++ b/build/pkgs/ipykernel/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-ipykernel diff --git a/build/pkgs/ipykernel/spkg-configure.m4 b/build/pkgs/ipykernel/spkg-configure.m4 new file mode 100644 index 00000000000..94ecc2dcc4e --- /dev/null +++ b/build/pkgs/ipykernel/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([ipykernel], [SAGE_PYTHON_PACKAGE_CHECK([ipykernel])]) diff --git a/build/pkgs/ipympl/dependencies b/build/pkgs/ipympl/dependencies index 05d47407b15..90b85bcfdbc 100644 --- a/build/pkgs/ipympl/dependencies +++ b/build/pkgs/ipympl/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) ipywidgets matplotlib ipykernel | $(PYTHON_TOOLCHAIN) jupyter_packaging + ipywidgets matplotlib ipykernel | $(PYTHON_TOOLCHAIN) jupyter_packaging $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ipython/dependencies b/build/pkgs/ipython/dependencies index 38dad7b80ee..48ad216441c 100644 --- a/build/pkgs/ipython/dependencies +++ b/build/pkgs/ipython/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) jinja2 tornado pyzmq pickleshare simplegeneric traitlets decorator wcwidth prompt_toolkit pygments pexpect appnope backcall jedi stack_data | $(PYTHON_TOOLCHAIN) + jinja2 tornado pyzmq pickleshare simplegeneric traitlets decorator wcwidth prompt_toolkit pygments pexpect appnope backcall jedi stack_data | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ipython/distros/arch.txt b/build/pkgs/ipython/distros/arch.txt new file mode 100644 index 00000000000..49a7ffe2a95 --- /dev/null +++ b/build/pkgs/ipython/distros/arch.txt @@ -0,0 +1 @@ +ipython diff --git a/build/pkgs/ipython/distros/debian.txt b/build/pkgs/ipython/distros/debian.txt new file mode 100644 index 00000000000..c32c6b449cf --- /dev/null +++ b/build/pkgs/ipython/distros/debian.txt @@ -0,0 +1 @@ +python3-ipython diff --git a/build/pkgs/ipython/distros/fedora.txt b/build/pkgs/ipython/distros/fedora.txt new file mode 100644 index 00000000000..49a7ffe2a95 --- /dev/null +++ b/build/pkgs/ipython/distros/fedora.txt @@ -0,0 +1 @@ +ipython diff --git a/build/pkgs/ipython/distros/freebsd.txt b/build/pkgs/ipython/distros/freebsd.txt new file mode 100644 index 00000000000..3252ee7fbc1 --- /dev/null +++ b/build/pkgs/ipython/distros/freebsd.txt @@ -0,0 +1 @@ +devel/ipython diff --git a/build/pkgs/ipython/distros/gentoo.txt b/build/pkgs/ipython/distros/gentoo.txt new file mode 100644 index 00000000000..8b76f186ff8 --- /dev/null +++ b/build/pkgs/ipython/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/ipython diff --git a/build/pkgs/ipython/distros/opensuse.txt b/build/pkgs/ipython/distros/opensuse.txt index c32c6b449cf..32aac30ae1e 100644 --- a/build/pkgs/ipython/distros/opensuse.txt +++ b/build/pkgs/ipython/distros/opensuse.txt @@ -1 +1 @@ -python3-ipython +python3${PYTHON_MINOR}-ipython diff --git a/build/pkgs/ipython/install-requires.txt b/build/pkgs/ipython/install-requires.txt index a52df49c421..03d4a4f3413 100644 --- a/build/pkgs/ipython/install-requires.txt +++ b/build/pkgs/ipython/install-requires.txt @@ -1 +1,2 @@ -ipython >=7.13.0 +ipython >=7.13.0, <8.9.0 +# ipython >= 8.9.0 requires prompt_toolkit too new for Sage diff --git a/build/pkgs/ipython/spkg-configure.m4 b/build/pkgs/ipython/spkg-configure.m4 new file mode 100644 index 00000000000..02ab89f5193 --- /dev/null +++ b/build/pkgs/ipython/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([ipython], [SAGE_PYTHON_PACKAGE_CHECK([ipython])]) diff --git a/build/pkgs/ipython_genutils/dependencies b/build/pkgs/ipython_genutils/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/ipython_genutils/dependencies +++ b/build/pkgs/ipython_genutils/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ipython_genutils/distros/gentoo.txt b/build/pkgs/ipython_genutils/distros/gentoo.txt new file mode 100644 index 00000000000..01bc49d4e1a --- /dev/null +++ b/build/pkgs/ipython_genutils/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/ipython_genutils diff --git a/build/pkgs/ipython_genutils/spkg-configure.m4 b/build/pkgs/ipython_genutils/spkg-configure.m4 new file mode 100644 index 00000000000..b0ba86ac7a3 --- /dev/null +++ b/build/pkgs/ipython_genutils/spkg-configure.m4 @@ -0,0 +1,4 @@ +SAGE_SPKG_CONFIGURE( + [ipython_genutils], + [SAGE_PYTHON_PACKAGE_CHECK([ipython_genutils])] +) diff --git a/build/pkgs/ipywidgets/dependencies b/build/pkgs/ipywidgets/dependencies index 64f5151c754..bcb4e030b7d 100644 --- a/build/pkgs/ipywidgets/dependencies +++ b/build/pkgs/ipywidgets/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) widgetsnbextension jupyterlab_widgets | $(PYTHON_TOOLCHAIN) ipykernel ipython traitlets + widgetsnbextension jupyterlab_widgets | $(PYTHON_TOOLCHAIN) ipykernel ipython traitlets $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ipywidgets/distros/gentoo.txt b/build/pkgs/ipywidgets/distros/gentoo.txt new file mode 100644 index 00000000000..7c76967c65b --- /dev/null +++ b/build/pkgs/ipywidgets/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/ipywidgets diff --git a/build/pkgs/ipywidgets/spkg-configure.m4 b/build/pkgs/ipywidgets/spkg-configure.m4 new file mode 100644 index 00000000000..51ca9be74db --- /dev/null +++ b/build/pkgs/ipywidgets/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([ipywidgets], [SAGE_PYTHON_PACKAGE_CHECK([ipywidgets])]) diff --git a/build/pkgs/jedi/dependencies b/build/pkgs/jedi/dependencies index 60b5f820a37..0e2212bd149 100644 --- a/build/pkgs/jedi/dependencies +++ b/build/pkgs/jedi/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) parso | $(PYTHON_TOOLCHAIN) + parso | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jedi/distros/gentoo.txt b/build/pkgs/jedi/distros/gentoo.txt new file mode 100644 index 00000000000..6c85a46cfcb --- /dev/null +++ b/build/pkgs/jedi/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/jedi diff --git a/build/pkgs/jedi/spkg-configure.m4 b/build/pkgs/jedi/spkg-configure.m4 new file mode 100644 index 00000000000..a37dbcc92db --- /dev/null +++ b/build/pkgs/jedi/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([jedi], [SAGE_PYTHON_PACKAGE_CHECK([jedi])]) diff --git a/build/pkgs/jinja2/dependencies b/build/pkgs/jinja2/dependencies index 6947978ec42..151ae9767d1 100644 --- a/build/pkgs/jinja2/dependencies +++ b/build/pkgs/jinja2/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) markupsafe docutils | $(PYTHON_TOOLCHAIN) + markupsafe docutils | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jinja2/distros/debian.txt b/build/pkgs/jinja2/distros/debian.txt new file mode 100644 index 00000000000..f2db865ab36 --- /dev/null +++ b/build/pkgs/jinja2/distros/debian.txt @@ -0,0 +1 @@ +python3-jinja2 diff --git a/build/pkgs/jinja2/distros/fedora.txt b/build/pkgs/jinja2/distros/fedora.txt new file mode 100644 index 00000000000..f5f3caf99cc --- /dev/null +++ b/build/pkgs/jinja2/distros/fedora.txt @@ -0,0 +1 @@ +python-jinja2 diff --git a/build/pkgs/jinja2/distros/gentoo.txt b/build/pkgs/jinja2/distros/gentoo.txt new file mode 100644 index 00000000000..15a27aecd44 --- /dev/null +++ b/build/pkgs/jinja2/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/jinja diff --git a/build/pkgs/jinja2/distros/opensuse.txt b/build/pkgs/jinja2/distros/opensuse.txt index 5d90a223f55..8ad585a7ef3 100644 --- a/build/pkgs/jinja2/distros/opensuse.txt +++ b/build/pkgs/jinja2/distros/opensuse.txt @@ -1 +1 @@ -python3-Jinja2 +python3${PYTHON_MINOR}-jinja2 diff --git a/build/pkgs/jinja2/install-requires.txt b/build/pkgs/jinja2/install-requires.txt index 99d8e6ecd6e..829d4c266d3 100644 --- a/build/pkgs/jinja2/install-requires.txt +++ b/build/pkgs/jinja2/install-requires.txt @@ -1 +1,2 @@ -jinja2 >=2.11.2 +jinja2 >=3.0 +# for sphinx diff --git a/build/pkgs/jinja2/spkg-configure.m4 b/build/pkgs/jinja2/spkg-configure.m4 new file mode 100644 index 00000000000..0970d1c8bea --- /dev/null +++ b/build/pkgs/jinja2/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([jinja2], [SAGE_PYTHON_PACKAGE_CHECK([jinja2])]) diff --git a/build/pkgs/jsonschema/dependencies b/build/pkgs/jsonschema/dependencies index 51698156cf0..d0211604157 100644 --- a/build/pkgs/jsonschema/dependencies +++ b/build/pkgs/jsonschema/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) vcversioner attrs importlib_metadata pyrsistent | $(PYTHON_TOOLCHAIN) hatchling hatch_vcs hatch_fancy_pypi_readme + vcversioner attrs importlib_metadata pyrsistent | $(PYTHON_TOOLCHAIN) hatchling hatch_vcs hatch_fancy_pypi_readme $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jsonschema/distros/arch.txt b/build/pkgs/jsonschema/distros/arch.txt new file mode 100644 index 00000000000..8943c30f9ed --- /dev/null +++ b/build/pkgs/jsonschema/distros/arch.txt @@ -0,0 +1 @@ +python-jsonschema diff --git a/build/pkgs/jsonschema/distros/debian.txt b/build/pkgs/jsonschema/distros/debian.txt new file mode 100644 index 00000000000..047e6cc5d1d --- /dev/null +++ b/build/pkgs/jsonschema/distros/debian.txt @@ -0,0 +1 @@ +python3-jsonschema diff --git a/build/pkgs/jsonschema/distros/fedora.txt b/build/pkgs/jsonschema/distros/fedora.txt new file mode 100644 index 00000000000..8943c30f9ed --- /dev/null +++ b/build/pkgs/jsonschema/distros/fedora.txt @@ -0,0 +1 @@ +python-jsonschema diff --git a/build/pkgs/jsonschema/distros/gentoo.txt b/build/pkgs/jsonschema/distros/gentoo.txt new file mode 100644 index 00000000000..d708e4c9990 --- /dev/null +++ b/build/pkgs/jsonschema/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/jsonschema diff --git a/build/pkgs/jsonschema/distros/opensuse.txt b/build/pkgs/jsonschema/distros/opensuse.txt index 047e6cc5d1d..2a587a55946 100644 --- a/build/pkgs/jsonschema/distros/opensuse.txt +++ b/build/pkgs/jsonschema/distros/opensuse.txt @@ -1 +1 @@ -python3-jsonschema +python3${PYTHON_MINOR}-jsonschema diff --git a/build/pkgs/jsonschema/spkg-configure.m4 b/build/pkgs/jsonschema/spkg-configure.m4 new file mode 100644 index 00000000000..b9e5e216a3b --- /dev/null +++ b/build/pkgs/jsonschema/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([jsonschema], [SAGE_PYTHON_PACKAGE_CHECK([jsonschema])]) diff --git a/build/pkgs/jupymake/dependencies b/build/pkgs/jupymake/dependencies index c8ed956ad6a..aa714006aae 100644 --- a/build/pkgs/jupymake/dependencies +++ b/build/pkgs/jupymake/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) polymake | $(PYTHON_TOOLCHAIN) + polymake | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyter_client/dependencies b/build/pkgs/jupyter_client/dependencies index 29d5d3b6bf3..dcc8c256fad 100644 --- a/build/pkgs/jupyter_client/dependencies +++ b/build/pkgs/jupyter_client/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) jupyter_core | $(PYTHON_TOOLCHAIN) pyzmq dateutil nest_asyncio tornado traitlets entrypoints hatchling + jupyter_core | $(PYTHON_TOOLCHAIN) pyzmq dateutil nest_asyncio tornado traitlets entrypoints hatchling $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyter_client/distros/gentoo.txt b/build/pkgs/jupyter_client/distros/gentoo.txt new file mode 100644 index 00000000000..4f1de883ca1 --- /dev/null +++ b/build/pkgs/jupyter_client/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/jupyter_client diff --git a/build/pkgs/jupyter_client/distros/opensuse.txt b/build/pkgs/jupyter_client/distros/opensuse.txt index 0159b2d7b90..a1e21956a79 100644 --- a/build/pkgs/jupyter_client/distros/opensuse.txt +++ b/build/pkgs/jupyter_client/distros/opensuse.txt @@ -1 +1 @@ -python3-jupyter-client +python3${PYTHON_MINOR}-jupyter-client diff --git a/build/pkgs/jupyter_client/spkg-configure.m4 b/build/pkgs/jupyter_client/spkg-configure.m4 new file mode 100644 index 00000000000..fbd34982c14 --- /dev/null +++ b/build/pkgs/jupyter_client/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([jupyter_client], [ + SAGE_PYTHON_PACKAGE_CHECK([jupyter_client]) +]) diff --git a/build/pkgs/jupyter_core/dependencies b/build/pkgs/jupyter_core/dependencies index 6aeda10f20d..a312196cbed 100644 --- a/build/pkgs/jupyter_core/dependencies +++ b/build/pkgs/jupyter_core/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) traitlets + traitlets | $(PYTHON_TOOLCHAIN) hatchling $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyter_core/distros/gentoo.txt b/build/pkgs/jupyter_core/distros/gentoo.txt new file mode 100644 index 00000000000..f168c5ad7ad --- /dev/null +++ b/build/pkgs/jupyter_core/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/jupyter_core diff --git a/build/pkgs/jupyter_core/distros/opensuse.txt b/build/pkgs/jupyter_core/distros/opensuse.txt index 2f316f2ee07..2c677674477 100644 --- a/build/pkgs/jupyter_core/distros/opensuse.txt +++ b/build/pkgs/jupyter_core/distros/opensuse.txt @@ -1 +1 @@ -python3-jupyter-core +python3${PYTHON_MINOR}-jupyter-core diff --git a/build/pkgs/jupyter_core/spkg-configure.m4 b/build/pkgs/jupyter_core/spkg-configure.m4 new file mode 100644 index 00000000000..67df9c38b5b --- /dev/null +++ b/build/pkgs/jupyter_core/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([jupyter_core], [ + SAGE_PYTHON_PACKAGE_CHECK([jupyter_core]) +]) diff --git a/build/pkgs/jupyter_jsmol/SPKG.rst b/build/pkgs/jupyter_jsmol/SPKG.rst index e318a86c7b1..64458e86b2d 100644 --- a/build/pkgs/jupyter_jsmol/SPKG.rst +++ b/build/pkgs/jupyter_jsmol/SPKG.rst @@ -9,7 +9,7 @@ JSmol viewer widget for Jupyter License ------- -BSD +MIT Upstream Contact ---------------- diff --git a/build/pkgs/jupyter_jsmol/checksums.ini b/build/pkgs/jupyter_jsmol/checksums.ini index 0ac16d6e78c..9ac2c41a8e4 100644 --- a/build/pkgs/jupyter_jsmol/checksums.ini +++ b/build/pkgs/jupyter_jsmol/checksums.ini @@ -1,5 +1,5 @@ -tarball=jupyter_jsmol-VERSION.tar.gz -sha1=6ba59de9d1df15b2a09a57f6bdf10f48f13af9ac -md5=90e9490414e7fbecc6013b4b051b06d7 -cksum=917919116 -upstream_url=https://pypi.io/packages/source/j/jupyter-jsmol/jupyter_jsmol-VERSION.tar.gz +tarball=jupyter_jsmol-VERSION-py2.py3-none-any.whl +sha1=b00f1ca76aaa906c7c0a43e36baf608183f3d552 +md5=dd786877513296a36a08518ad64ace47 +cksum=2135042898 +upstream_url=https://pypi.io/packages/py2.py3/j/jupyter_jsmol/jupyter_jsmol-VERSION-py2.py3-none-any.whl diff --git a/build/pkgs/jupyter_jsmol/dependencies b/build/pkgs/jupyter_jsmol/dependencies index a6d87526311..2c7683a6111 100644 --- a/build/pkgs/jupyter_jsmol/dependencies +++ b/build/pkgs/jupyter_jsmol/dependencies @@ -1,4 +1,4 @@ -ipywidgets jupyter_packaging $(PYTHON) | $(PYTHON_TOOLCHAIN) +ipywidgets | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyter_jsmol/install-requires.txt b/build/pkgs/jupyter_jsmol/install-requires.txt index 2df501ec9a8..9465bfb8e0c 100644 --- a/build/pkgs/jupyter_jsmol/install-requires.txt +++ b/build/pkgs/jupyter_jsmol/install-requires.txt @@ -1 +1 @@ -jupyter-jsmol >=2022.1.0 +jupyter-jsmol diff --git a/build/pkgs/jupyter_jsmol/spkg-install.in b/build/pkgs/jupyter_jsmol/spkg-install.in deleted file mode 100644 index 72d65dde8d5..00000000000 --- a/build/pkgs/jupyter_jsmol/spkg-install.in +++ /dev/null @@ -1,3 +0,0 @@ -cd src -# Use --no-build-isolation because we have a different version of jupyter_packaging -eval sdh_pip_install --no-build-isolation --config-settings "--global-option=--skip-npm" . diff --git a/build/pkgs/jupyter_packaging/dependencies b/build/pkgs/jupyter_packaging/dependencies index 838afe13edf..11e420a0a7b 100644 --- a/build/pkgs/jupyter_packaging/dependencies +++ b/build/pkgs/jupyter_packaging/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) packaging deprecation tomlkit | $(PYTHON_TOOLCHAIN) hatchling + packaging deprecation tomlkit | $(PYTHON_TOOLCHAIN) hatchling $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyter_sphinx/dependencies b/build/pkgs/jupyter_sphinx/dependencies index 785929f6ea8..37476f7a572 100644 --- a/build/pkgs/jupyter_sphinx/dependencies +++ b/build/pkgs/jupyter_sphinx/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) sphinx ipywidgets ipython nbconvert nbformat | $(PYTHON_TOOLCHAIN) + sphinx ipywidgets ipython nbconvert nbformat | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyterlab/dependencies b/build/pkgs/jupyterlab/dependencies index 98ad2e94050..059006650e1 100644 --- a/build/pkgs/jupyterlab/dependencies +++ b/build/pkgs/jupyterlab/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) vcversioner jupyter_core jupyter_client jinja2 tornado ipython packaging terminado traitlets nbconvert send2trash nbformat prometheus_client ipython_genutils argon2_cffi pyzmq idna requests jsonschema babel notebook | $(PYTHON_TOOLCHAIN) + vcversioner jupyter_core jupyter_client jinja2 tornado ipython packaging terminado traitlets nbconvert send2trash nbformat prometheus_client ipython_genutils argon2_cffi pyzmq idna requests jsonschema babel notebook | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyterlab_pygments/dependencies b/build/pkgs/jupyterlab_pygments/dependencies index a59532cdda1..fd3f15b7aa3 100644 --- a/build/pkgs/jupyterlab_pygments/dependencies +++ b/build/pkgs/jupyterlab_pygments/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pygments | $(PYTHON_TOOLCHAIN) + pygments | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyterlab_pygments/distros/gentoo.txt b/build/pkgs/jupyterlab_pygments/distros/gentoo.txt new file mode 100644 index 00000000000..c57b4f13403 --- /dev/null +++ b/build/pkgs/jupyterlab_pygments/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/jupyterlab_pygments diff --git a/build/pkgs/jupyterlab_pygments/spkg-configure.m4 b/build/pkgs/jupyterlab_pygments/spkg-configure.m4 new file mode 100644 index 00000000000..e46e21f461e --- /dev/null +++ b/build/pkgs/jupyterlab_pygments/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([jupyterlab_pygments], [ + SAGE_PYTHON_PACKAGE_CHECK([jupyterlab_pygments]) +]) diff --git a/build/pkgs/jupyterlab_widgets/dependencies b/build/pkgs/jupyterlab_widgets/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/jupyterlab_widgets/dependencies +++ b/build/pkgs/jupyterlab_widgets/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/jupyterlab_widgets/distros/arch.txt b/build/pkgs/jupyterlab_widgets/distros/arch.txt new file mode 100644 index 00000000000..0800dc09838 --- /dev/null +++ b/build/pkgs/jupyterlab_widgets/distros/arch.txt @@ -0,0 +1 @@ +jupyterlab-widgets diff --git a/build/pkgs/jupyterlab_widgets/distros/freebsd.txt b/build/pkgs/jupyterlab_widgets/distros/freebsd.txt new file mode 100644 index 00000000000..6fc98fe86a0 --- /dev/null +++ b/build/pkgs/jupyterlab_widgets/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-jupyterlab-widgets diff --git a/build/pkgs/jupyterlab_widgets/distros/opensuse.txt b/build/pkgs/jupyterlab_widgets/distros/opensuse.txt new file mode 100644 index 00000000000..04706eee600 --- /dev/null +++ b/build/pkgs/jupyterlab_widgets/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-jupyterlab-widgets diff --git a/build/pkgs/kissat/checksums.ini b/build/pkgs/kissat/checksums.ini index 66b187bb599..85929110253 100644 --- a/build/pkgs/kissat/checksums.ini +++ b/build/pkgs/kissat/checksums.ini @@ -1,5 +1,5 @@ tarball=kissat-rel-VERSION.tar.gz -sha1=abfd971d5f560ed76281ed3ed7b75e20cb445618 -md5=6ef4b2efcc60c95a32581bfe59720154 -cksum=1532123399 +sha1=49972324939761306ee50cfa3df93cd3cd530256 +md5=1d0fa246c5451e3592910f2c9a5f3476 +cksum=2570717921 upstream_url=https://github.com/arminbiere/kissat/archive/refs/tags/rel-VERSION.tar.gz diff --git a/build/pkgs/kissat/package-version.txt b/build/pkgs/kissat/package-version.txt index 4a36342fcab..fd2a01863fd 100644 --- a/build/pkgs/kissat/package-version.txt +++ b/build/pkgs/kissat/package-version.txt @@ -1 +1 @@ -3.0.0 +3.1.0 diff --git a/build/pkgs/kiwisolver/dependencies b/build/pkgs/kiwisolver/dependencies index 5df13094620..1ba038a9b7a 100644 --- a/build/pkgs/kiwisolver/dependencies +++ b/build/pkgs/kiwisolver/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cppy | $(PYTHON_TOOLCHAIN) + cppy | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/kiwisolver/distros/gentoo.txt b/build/pkgs/kiwisolver/distros/gentoo.txt new file mode 100644 index 00000000000..7b30c9540ec --- /dev/null +++ b/build/pkgs/kiwisolver/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/kiwisolver diff --git a/build/pkgs/kiwisolver/spkg-configure.m4 b/build/pkgs/kiwisolver/spkg-configure.m4 new file mode 100644 index 00000000000..4e7ac97b57d --- /dev/null +++ b/build/pkgs/kiwisolver/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([kiwisolver], [SAGE_PYTHON_PACKAGE_CHECK([kiwisolver])]) diff --git a/build/pkgs/libbraiding/package-version.txt b/build/pkgs/libbraiding/package-version.txt index 9459d4ba2a0..5625e59da88 100644 --- a/build/pkgs/libbraiding/package-version.txt +++ b/build/pkgs/libbraiding/package-version.txt @@ -1 +1 @@ -1.1 +1.2 diff --git a/build/pkgs/lrcalc_python/dependencies b/build/pkgs/lrcalc_python/dependencies index 27c96045586..d7e0cec0534 100644 --- a/build/pkgs/lrcalc_python/dependencies +++ b/build/pkgs/lrcalc_python/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) lrcalc | $(PYTHON_TOOLCHAIN) cython + lrcalc | $(PYTHON_TOOLCHAIN) cython $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/markupsafe/dependencies b/build/pkgs/markupsafe/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/markupsafe/dependencies +++ b/build/pkgs/markupsafe/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/markupsafe/distros/gentoo.txt b/build/pkgs/markupsafe/distros/gentoo.txt new file mode 100644 index 00000000000..9654e3531b6 --- /dev/null +++ b/build/pkgs/markupsafe/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/markupsafe diff --git a/build/pkgs/markupsafe/distros/opensuse.txt b/build/pkgs/markupsafe/distros/opensuse.txt index 483c7ee1e18..8c103c6b5e5 100644 --- a/build/pkgs/markupsafe/distros/opensuse.txt +++ b/build/pkgs/markupsafe/distros/opensuse.txt @@ -1 +1 @@ -python3-MarkupSafe +python3${PYTHON_MINOR}-MarkupSafe diff --git a/build/pkgs/markupsafe/install-requires.txt b/build/pkgs/markupsafe/install-requires.txt index 331f488e6a0..7d44bce10e1 100644 --- a/build/pkgs/markupsafe/install-requires.txt +++ b/build/pkgs/markupsafe/install-requires.txt @@ -1 +1 @@ -markupsafe >=1.1.0 +markupsafe >=2.0 diff --git a/build/pkgs/markupsafe/spkg-configure.m4 b/build/pkgs/markupsafe/spkg-configure.m4 new file mode 100644 index 00000000000..79eb8dba6f1 --- /dev/null +++ b/build/pkgs/markupsafe/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([markupsafe], [SAGE_PYTHON_PACKAGE_CHECK([markupsafe])]) diff --git a/build/pkgs/mathics/dependencies b/build/pkgs/mathics/dependencies index ac723a5ac26..11d5626d8c7 100644 --- a/build/pkgs/mathics/dependencies +++ b/build/pkgs/mathics/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) pint palettable mathics_scanner + | $(PYTHON_TOOLCHAIN) pint palettable mathics_scanner $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/mathics_scanner/dependencies b/build/pkgs/mathics_scanner/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/mathics_scanner/dependencies +++ b/build/pkgs/mathics_scanner/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/matplotlib/dependencies b/build/pkgs/matplotlib/dependencies index cfcf3edda7e..a2592fe7c6d 100644 --- a/build/pkgs/matplotlib/dependencies +++ b/build/pkgs/matplotlib/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) numpy freetype pillow dateutil pyparsing tornado six cycler qhull fonttools contourpy | $(PYTHON_TOOLCHAIN) kiwisolver certifi setuptools_scm_git_archive + numpy freetype pillow dateutil pyparsing tornado six cycler qhull fonttools contourpy | $(PYTHON_TOOLCHAIN) kiwisolver certifi setuptools_scm_git_archive $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/matplotlib/distros/arch.txt b/build/pkgs/matplotlib/distros/arch.txt new file mode 100644 index 00000000000..f6d856e585c --- /dev/null +++ b/build/pkgs/matplotlib/distros/arch.txt @@ -0,0 +1 @@ +python-matplotlib diff --git a/build/pkgs/matplotlib/distros/debian.txt b/build/pkgs/matplotlib/distros/debian.txt new file mode 100644 index 00000000000..13743297213 --- /dev/null +++ b/build/pkgs/matplotlib/distros/debian.txt @@ -0,0 +1 @@ +python3-matplotlib diff --git a/build/pkgs/matplotlib/distros/fedora.txt b/build/pkgs/matplotlib/distros/fedora.txt new file mode 100644 index 00000000000..f6d856e585c --- /dev/null +++ b/build/pkgs/matplotlib/distros/fedora.txt @@ -0,0 +1 @@ +python-matplotlib diff --git a/build/pkgs/matplotlib/distros/gentoo.txt b/build/pkgs/matplotlib/distros/gentoo.txt new file mode 100644 index 00000000000..bcfefb5fcc4 --- /dev/null +++ b/build/pkgs/matplotlib/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/matplotlib diff --git a/build/pkgs/matplotlib/distros/opensuse.txt b/build/pkgs/matplotlib/distros/opensuse.txt index 13743297213..40f1130ec6f 100644 --- a/build/pkgs/matplotlib/distros/opensuse.txt +++ b/build/pkgs/matplotlib/distros/opensuse.txt @@ -1 +1 @@ -python3-matplotlib +python3${PYTHON_MINOR}-matplotlib diff --git a/build/pkgs/matplotlib/spkg-configure.m4 b/build/pkgs/matplotlib/spkg-configure.m4 new file mode 100644 index 00000000000..39c2d2901d0 --- /dev/null +++ b/build/pkgs/matplotlib/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([matplotlib], [ + SAGE_SPKG_DEPCHECK([bzip2 freetype libpng qhull], [ + SAGE_PYTHON_PACKAGE_CHECK([matplotlib]) + ]) +]) diff --git a/build/pkgs/matplotlib_inline/dependencies b/build/pkgs/matplotlib_inline/dependencies index 1da34eeae60..a1a8daa948c 100644 --- a/build/pkgs/matplotlib_inline/dependencies +++ b/build/pkgs/matplotlib_inline/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) traitlets | $(PYTHON_TOOLCHAIN) + traitlets | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/matplotlib_inline/distros/gentoo.txt b/build/pkgs/matplotlib_inline/distros/gentoo.txt new file mode 100644 index 00000000000..6a5859ca074 --- /dev/null +++ b/build/pkgs/matplotlib_inline/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/matplotlib-inline diff --git a/build/pkgs/matplotlib_inline/spkg-configure.m4 b/build/pkgs/matplotlib_inline/spkg-configure.m4 new file mode 100644 index 00000000000..e59658ff159 --- /dev/null +++ b/build/pkgs/matplotlib_inline/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([matplotlib_inline], [ + SAGE_PYTHON_PACKAGE_CHECK([matplotlib_inline]) +]) diff --git a/build/pkgs/memory_allocator/dependencies b/build/pkgs/memory_allocator/dependencies index 296a2bebad3..1db13c07e43 100644 --- a/build/pkgs/memory_allocator/dependencies +++ b/build/pkgs/memory_allocator/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cython | $(PYTHON_TOOLCHAIN) + cython | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/meson/checksums.ini b/build/pkgs/meson/checksums.ini index d3dbb277dba..ef8b1ec0b21 100644 --- a/build/pkgs/meson/checksums.ini +++ b/build/pkgs/meson/checksums.ini @@ -1,5 +1,5 @@ tarball=meson-VERSION.tar.gz -sha1=a2d102eb6a37307c9b67283e9764ed57cf286223 -md5=843ba549bb2a199d9e04092116a7e749 -cksum=2108460988 +sha1=087da0ecbc065bb40361ba683b55c20cb42a948a +md5=e3cc846536189aacd7d01858a45ca9af +cksum=4011973902 upstream_url=https://pypi.io/packages/source/m/meson/meson-VERSION.tar.gz diff --git a/build/pkgs/meson/dependencies b/build/pkgs/meson/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/meson/dependencies +++ b/build/pkgs/meson/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/meson/package-version.txt b/build/pkgs/meson/package-version.txt index 7dea76edb3d..6085e946503 100644 --- a/build/pkgs/meson/package-version.txt +++ b/build/pkgs/meson/package-version.txt @@ -1 +1 @@ -1.0.1 +1.2.1 diff --git a/build/pkgs/meson/spkg-configure.m4 b/build/pkgs/meson/spkg-configure.m4 index efe863664f7..dbc575650fc 100644 --- a/build/pkgs/meson/spkg-configure.m4 +++ b/build/pkgs/meson/spkg-configure.m4 @@ -1,10 +1,11 @@ SAGE_SPKG_CONFIGURE( [meson], [ - AC_CACHE_CHECK([for meson >= 0.64], [ac_cv_path_MESON], [ + dnl scipy 1.11.2 needs meson >= 1.1.0 + AC_CACHE_CHECK([for meson >= 1.1.0], [ac_cv_path_MESON], [ AC_PATH_PROGS_FEATURE_CHECK([MESON], [meson], [ meson_version=`$ac_path_MESON --version 2>&1` AS_IF([test -n "$meson_version"], [ - AX_COMPARE_VERSION([$meson_version], [ge], [0.64], [ + AX_COMPARE_VERSION([$meson_version], [ge], [1.1.0], [ ac_cv_path_MESON="$ac_path_MESON" ac_path_MESON_found=: ]) diff --git a/build/pkgs/meson_python/checksums.ini b/build/pkgs/meson_python/checksums.ini index 0e1c77874b7..da59c9577aa 100644 --- a/build/pkgs/meson_python/checksums.ini +++ b/build/pkgs/meson_python/checksums.ini @@ -1,5 +1,5 @@ tarball=meson_python-VERSION.tar.gz -sha1=bdaf002dc1ef314c32e2be76f3b2872f1282c4cc -md5=39be4f0b7f036e1d5db4a76fdb031355 -cksum=2636510839 +sha1=e52e84fcd84ea7dd8c11f464390786686a1be8e6 +md5=0db4483e30df43dbd465254be9c7db8a +cksum=1452585711 upstream_url=https://pypi.io/packages/source/m/meson_python/meson_python-VERSION.tar.gz diff --git a/build/pkgs/meson_python/dependencies b/build/pkgs/meson_python/dependencies index 160adbf36c9..01b5cb597b0 100644 --- a/build/pkgs/meson_python/dependencies +++ b/build/pkgs/meson_python/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) meson pyproject_metadata tomli ninja_build patchelf | $(PYTHON_TOOLCHAIN) + meson pyproject_metadata tomli ninja_build patchelf | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/meson_python/package-version.txt b/build/pkgs/meson_python/package-version.txt index 34a83616bb5..9beb74d490b 100644 --- a/build/pkgs/meson_python/package-version.txt +++ b/build/pkgs/meson_python/package-version.txt @@ -1 +1 @@ -0.12.1 +0.13.2 diff --git a/build/pkgs/meson_python/patches/ARCHFLAGS_empty.patch b/build/pkgs/meson_python/patches/ARCHFLAGS_empty.patch deleted file mode 100644 index 8857629f080..00000000000 --- a/build/pkgs/meson_python/patches/ARCHFLAGS_empty.patch +++ /dev/null @@ -1,21 +0,0 @@ -commit caa435144b1b4fa40c51558f15fd8dae2c0b5868 -Author: Matthias Koeppe -Date: Sat Mar 11 10:16:56 2023 -0800 - - BUG: handle ARCHFLAGS set to the empty string - -diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py -index e312059..d798f4c 100644 ---- a/mesonpy/__init__.py -+++ b/mesonpy/__init__.py -@@ -686,8 +686,8 @@ class Project(): - - # setuptools-like ARCHFLAGS environment variable support - if sysconfig.get_platform().startswith('macosx-'): -- archflags = self._env.get('ARCHFLAGS') -- if archflags is not None: -+ archflags = self._env.get('ARCHFLAGS', '').strip() -+ if archflags: - arch, *other = filter(None, (x.strip() for x in archflags.split('-arch'))) - if other: - raise ConfigError(f'Multi-architecture builds are not supported but $ARCHFLAGS={archflags!r}') diff --git a/build/pkgs/mistune/dependencies b/build/pkgs/mistune/dependencies index 296a2bebad3..1db13c07e43 100644 --- a/build/pkgs/mistune/dependencies +++ b/build/pkgs/mistune/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cython | $(PYTHON_TOOLCHAIN) + cython | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/mistune/distros/gentoo.txt b/build/pkgs/mistune/distros/gentoo.txt new file mode 100644 index 00000000000..56f0a4ebced --- /dev/null +++ b/build/pkgs/mistune/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/mistune diff --git a/build/pkgs/mistune/spkg-configure.m4 b/build/pkgs/mistune/spkg-configure.m4 new file mode 100644 index 00000000000..972f33d086b --- /dev/null +++ b/build/pkgs/mistune/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([mistune], [SAGE_PYTHON_PACKAGE_CHECK([mistune])]) diff --git a/build/pkgs/mpmath/dependencies b/build/pkgs/mpmath/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/mpmath/dependencies +++ b/build/pkgs/mpmath/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/mpmath/distros/arch.txt b/build/pkgs/mpmath/distros/arch.txt new file mode 100644 index 00000000000..a7dc8d568f3 --- /dev/null +++ b/build/pkgs/mpmath/distros/arch.txt @@ -0,0 +1 @@ +python-mpmath diff --git a/build/pkgs/mpmath/distros/debian.txt b/build/pkgs/mpmath/distros/debian.txt new file mode 100644 index 00000000000..fbc82a97e07 --- /dev/null +++ b/build/pkgs/mpmath/distros/debian.txt @@ -0,0 +1 @@ +python3-mpmath diff --git a/build/pkgs/mpmath/distros/fedora.txt b/build/pkgs/mpmath/distros/fedora.txt new file mode 100644 index 00000000000..a7dc8d568f3 --- /dev/null +++ b/build/pkgs/mpmath/distros/fedora.txt @@ -0,0 +1 @@ +python-mpmath diff --git a/build/pkgs/mpmath/distros/gentoo.txt b/build/pkgs/mpmath/distros/gentoo.txt new file mode 100644 index 00000000000..946c62d9e1a --- /dev/null +++ b/build/pkgs/mpmath/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/mpmath diff --git a/build/pkgs/mpmath/distros/opensuse.txt b/build/pkgs/mpmath/distros/opensuse.txt new file mode 100644 index 00000000000..8b65d97862d --- /dev/null +++ b/build/pkgs/mpmath/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-mpmath diff --git a/build/pkgs/mpmath/spkg-configure.m4 b/build/pkgs/mpmath/spkg-configure.m4 new file mode 100644 index 00000000000..f43c8388264 --- /dev/null +++ b/build/pkgs/mpmath/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([mpmath], [SAGE_PYTHON_PACKAGE_CHECK([mpmath])]) diff --git a/build/pkgs/nbclient/dependencies b/build/pkgs/nbclient/dependencies index e21070fd3af..acec3fadace 100644 --- a/build/pkgs/nbclient/dependencies +++ b/build/pkgs/nbclient/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) jupyter_client nbformat | $(PYTHON_TOOLCHAIN) + jupyter_client nbformat | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/nbclient/distros/gentoo.txt b/build/pkgs/nbclient/distros/gentoo.txt new file mode 100644 index 00000000000..06ff18d206a --- /dev/null +++ b/build/pkgs/nbclient/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/nbclient diff --git a/build/pkgs/nbclient/spkg-configure.m4 b/build/pkgs/nbclient/spkg-configure.m4 new file mode 100644 index 00000000000..14178b793d2 --- /dev/null +++ b/build/pkgs/nbclient/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([nbclient], [SAGE_PYTHON_PACKAGE_CHECK([nbclient])]) diff --git a/build/pkgs/nbconvert/dependencies b/build/pkgs/nbconvert/dependencies index b423493e603..09dfbf42cb8 100644 --- a/build/pkgs/nbconvert/dependencies +++ b/build/pkgs/nbconvert/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) mistune jinja2 pygments traitlets jupyter_core nbformat entrypoints bleach pandocfilters defusedxml jupyter_client jupyterlab_pygments nbclient beautifulsoup4 markupsafe | $(PYTHON_TOOLCHAIN) + mistune jinja2 pygments traitlets jupyter_core nbformat entrypoints bleach pandocfilters defusedxml jupyter_client jupyterlab_pygments nbclient beautifulsoup4 markupsafe | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/nbconvert/distros/gentoo.txt b/build/pkgs/nbconvert/distros/gentoo.txt new file mode 100644 index 00000000000..6c45a107368 --- /dev/null +++ b/build/pkgs/nbconvert/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/nbconvert diff --git a/build/pkgs/nbconvert/spkg-configure.m4 b/build/pkgs/nbconvert/spkg-configure.m4 new file mode 100644 index 00000000000..9b5dee3b8b5 --- /dev/null +++ b/build/pkgs/nbconvert/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([nbconvert], [SAGE_PYTHON_PACKAGE_CHECK([nbconvert])]) diff --git a/build/pkgs/nbformat/dependencies b/build/pkgs/nbformat/dependencies index 6c8921f1382..a6f9cc5f425 100644 --- a/build/pkgs/nbformat/dependencies +++ b/build/pkgs/nbformat/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) jsonschema fastjsonschema jupyter_core traitlets | $(PYTHON_TOOLCHAIN) hatchling hatch_nodejs_version + jsonschema fastjsonschema jupyter_core traitlets | $(PYTHON_TOOLCHAIN) hatchling hatch_nodejs_version $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/nbformat/distros/gentoo.txt b/build/pkgs/nbformat/distros/gentoo.txt new file mode 100644 index 00000000000..006b1f2fc6d --- /dev/null +++ b/build/pkgs/nbformat/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/nbformat diff --git a/build/pkgs/nbformat/spkg-configure.m4 b/build/pkgs/nbformat/spkg-configure.m4 new file mode 100644 index 00000000000..5a7f8c4ccec --- /dev/null +++ b/build/pkgs/nbformat/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([nbformat], [SAGE_PYTHON_PACKAGE_CHECK([nbformat])]) diff --git a/build/pkgs/nest_asyncio/dependencies b/build/pkgs/nest_asyncio/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/nest_asyncio/dependencies +++ b/build/pkgs/nest_asyncio/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/nest_asyncio/distros/gentoo.txt b/build/pkgs/nest_asyncio/distros/gentoo.txt new file mode 100644 index 00000000000..ab742d2b0bd --- /dev/null +++ b/build/pkgs/nest_asyncio/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/nest_asyncio diff --git a/build/pkgs/nest_asyncio/spkg-configure.m4 b/build/pkgs/nest_asyncio/spkg-configure.m4 new file mode 100644 index 00000000000..4d815276dfb --- /dev/null +++ b/build/pkgs/nest_asyncio/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([nest_asyncio], [SAGE_PYTHON_PACKAGE_CHECK([nest_asyncio])]) diff --git a/build/pkgs/networkx/dependencies b/build/pkgs/networkx/dependencies index 8eb6920e25d..fdba548c01a 100644 --- a/build/pkgs/networkx/dependencies +++ b/build/pkgs/networkx/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) decorator | $(PYTHON_TOOLCHAIN) scipy + decorator | $(PYTHON_TOOLCHAIN) scipy $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/networkx/distros/arch.txt b/build/pkgs/networkx/distros/arch.txt new file mode 100644 index 00000000000..293f943529a --- /dev/null +++ b/build/pkgs/networkx/distros/arch.txt @@ -0,0 +1 @@ +python-networkx diff --git a/build/pkgs/networkx/distros/debian.txt b/build/pkgs/networkx/distros/debian.txt new file mode 100644 index 00000000000..67790667af2 --- /dev/null +++ b/build/pkgs/networkx/distros/debian.txt @@ -0,0 +1 @@ +python3-networkx diff --git a/build/pkgs/networkx/distros/fedora.txt b/build/pkgs/networkx/distros/fedora.txt new file mode 100644 index 00000000000..293f943529a --- /dev/null +++ b/build/pkgs/networkx/distros/fedora.txt @@ -0,0 +1 @@ +python-networkx diff --git a/build/pkgs/networkx/distros/gentoo.txt b/build/pkgs/networkx/distros/gentoo.txt new file mode 100644 index 00000000000..dd97742cff8 --- /dev/null +++ b/build/pkgs/networkx/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/networkx diff --git a/build/pkgs/networkx/distros/opensuse.txt b/build/pkgs/networkx/distros/opensuse.txt index 67790667af2..7c421f08d48 100644 --- a/build/pkgs/networkx/distros/opensuse.txt +++ b/build/pkgs/networkx/distros/opensuse.txt @@ -1 +1 @@ -python3-networkx +python3${PYTHON_MINOR}-networkx diff --git a/build/pkgs/networkx/spkg-configure.m4 b/build/pkgs/networkx/spkg-configure.m4 new file mode 100644 index 00000000000..926671e166e --- /dev/null +++ b/build/pkgs/networkx/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([networkx], [SAGE_PYTHON_PACKAGE_CHECK([networkx])]) diff --git a/build/pkgs/nibabel/distros/opensuse.txt b/build/pkgs/nibabel/distros/opensuse.txt index 19df029d93f..1a7f1fd31f7 100644 --- a/build/pkgs/nibabel/distros/opensuse.txt +++ b/build/pkgs/nibabel/distros/opensuse.txt @@ -1 +1 @@ -python3-nibabel +python3${PYTHON_MINOR}-nibabel diff --git a/build/pkgs/ninja_build/checksums.ini b/build/pkgs/ninja_build/checksums.ini index d3914da794a..43ddbfd6334 100644 --- a/build/pkgs/ninja_build/checksums.ini +++ b/build/pkgs/ninja_build/checksums.ini @@ -1,5 +1,5 @@ tarball=ninja_build-VERSION.tar.gz -sha1=f8c9279bdd4efc63b1a6be3b8c5a5031699af9ac -md5=7d1a1a2f5cdc06795b3054df5c17d5ef -cksum=3142198237 +sha1=938723cdfc7a6f7c8f84c83b9a2cecdf1e5e1ad3 +md5=32151c08211d7ca3c1d832064f6939b0 +cksum=4040304461 upstream_url=https://github.com/ninja-build/ninja/archive/refs/tags/vVERSION.tar.gz diff --git a/build/pkgs/ninja_build/dependencies b/build/pkgs/ninja_build/dependencies index 6b134137610..3518086ab84 100644 --- a/build/pkgs/ninja_build/dependencies +++ b/build/pkgs/ninja_build/dependencies @@ -1,4 +1,4 @@ -| $(PYTHON) +| $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ninja_build/package-version.txt b/build/pkgs/ninja_build/package-version.txt index 1cac385c6cb..720c7384c61 100644 --- a/build/pkgs/ninja_build/package-version.txt +++ b/build/pkgs/ninja_build/package-version.txt @@ -1 +1 @@ -1.11.0 +1.11.1 diff --git a/build/pkgs/nodeenv/dependencies b/build/pkgs/nodeenv/dependencies index 16df46f57ee..04eff0c842c 100644 --- a/build/pkgs/nodeenv/dependencies +++ b/build/pkgs/nodeenv/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) certifi + | $(PYTHON_TOOLCHAIN) certifi $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/notebook/dependencies b/build/pkgs/notebook/dependencies index 9f5cb330ae2..9e6cbf4b36d 100644 --- a/build/pkgs/notebook/dependencies +++ b/build/pkgs/notebook/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) ipython jupyter_client ipykernel nbconvert nbformat jinja2 tornado terminado send2trash prometheus_client argon2_cffi + | $(PYTHON_TOOLCHAIN) ipython jupyter_client ipykernel nbconvert nbformat jinja2 tornado terminado send2trash prometheus_client argon2_cffi $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/notebook/distros/gentoo.txt b/build/pkgs/notebook/distros/gentoo.txt new file mode 100644 index 00000000000..6475d72541e --- /dev/null +++ b/build/pkgs/notebook/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/notebook diff --git a/build/pkgs/notebook/spkg-configure.m4 b/build/pkgs/notebook/spkg-configure.m4 new file mode 100644 index 00000000000..a17ba95eac6 --- /dev/null +++ b/build/pkgs/notebook/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([notebook], [SAGE_PYTHON_PACKAGE_CHECK([notebook])]) diff --git a/build/pkgs/notedown/dependencies b/build/pkgs/notedown/dependencies index ea77eefc7f4..3dcb5b1900f 100644 --- a/build/pkgs/notedown/dependencies +++ b/build/pkgs/notedown/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) $(PYTHON_TOOLCHAIN) | pip nbformat nbconvert six pandoc_attributes + $(PYTHON_TOOLCHAIN) | pip nbformat nbconvert six pandoc_attributes $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/numpy/dependencies b/build/pkgs/numpy/dependencies index d3c0f0055e4..63faafe335a 100644 --- a/build/pkgs/numpy/dependencies +++ b/build/pkgs/numpy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) $(BLAS) gfortran | $(PYTHON_TOOLCHAIN) pkgconfig cython + $(BLAS) gfortran | $(PYTHON_TOOLCHAIN) pkgconfig cython $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/numpy/distros/arch.txt b/build/pkgs/numpy/distros/arch.txt new file mode 100644 index 00000000000..c8722b9f663 --- /dev/null +++ b/build/pkgs/numpy/distros/arch.txt @@ -0,0 +1 @@ +python-numpy diff --git a/build/pkgs/numpy/distros/debian.txt b/build/pkgs/numpy/distros/debian.txt new file mode 100644 index 00000000000..79d5c5a1429 --- /dev/null +++ b/build/pkgs/numpy/distros/debian.txt @@ -0,0 +1 @@ +python3-numpy diff --git a/build/pkgs/numpy/distros/fedora.txt b/build/pkgs/numpy/distros/fedora.txt new file mode 100644 index 00000000000..c8722b9f663 --- /dev/null +++ b/build/pkgs/numpy/distros/fedora.txt @@ -0,0 +1 @@ +python-numpy diff --git a/build/pkgs/numpy/distros/gentoo.txt b/build/pkgs/numpy/distros/gentoo.txt new file mode 100644 index 00000000000..d2179d43851 --- /dev/null +++ b/build/pkgs/numpy/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/numpy diff --git a/build/pkgs/numpy/distros/opensuse.txt b/build/pkgs/numpy/distros/opensuse.txt new file mode 100644 index 00000000000..2e278515236 --- /dev/null +++ b/build/pkgs/numpy/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-numpy diff --git a/build/pkgs/numpy/spkg-configure.m4 b/build/pkgs/numpy/spkg-configure.m4 new file mode 100644 index 00000000000..16f9a90fad2 --- /dev/null +++ b/build/pkgs/numpy/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([numpy], [ + SAGE_SPKG_DEPCHECK([openblas], [ + SAGE_PYTHON_PACKAGE_CHECK([numpy]) + ]) +]) diff --git a/build/pkgs/ore_algebra/dependencies b/build/pkgs/ore_algebra/dependencies index 05ba0d8954b..126e8ceee06 100644 --- a/build/pkgs/ore_algebra/dependencies +++ b/build/pkgs/ore_algebra/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) $(SAGERUNTIME) + | $(PYTHON_TOOLCHAIN) $(SAGERUNTIME) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/osqp_python/dependencies b/build/pkgs/osqp_python/dependencies index 4f344bba626..6cc50626d1d 100644 --- a/build/pkgs/osqp_python/dependencies +++ b/build/pkgs/osqp_python/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) qdldl_python numpy scipy | $(PYTHON_TOOLCHAIN) cmake + qdldl_python numpy scipy | $(PYTHON_TOOLCHAIN) cmake $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/p_group_cohomology/dependencies b/build/pkgs/p_group_cohomology/dependencies index a9d113183c5..57ea7e0dd94 100644 --- a/build/pkgs/p_group_cohomology/dependencies +++ b/build/pkgs/p_group_cohomology/dependencies @@ -1 +1 @@ -$(PYTHON) cython cysignals singular meataxe modular_resolution $(SAGE_SRC)/sage/matrix/matrix_gfpn_dense.pxd $(SAGE_SRC)/sage/structure/element.pxd $(SAGE_SRC)/sage/matrix/matrix_gfpn_dense.pxd $(SAGE_SRC)/sage/matrix/matrix0.pxd $(SAGE_SRC)/sage/libs/meataxe.pxd $(SAGE_SRC)/sage/rings/morphism.pxd | $(PYTHON_TOOLCHAIN) matplotlib gap xz $(SAGERUNTIME) ipywidgets + cython cysignals singular meataxe modular_resolution $(SAGE_SRC)/sage/matrix/matrix_gfpn_dense.pxd $(SAGE_SRC)/sage/structure/element.pxd $(SAGE_SRC)/sage/matrix/matrix_gfpn_dense.pxd $(SAGE_SRC)/sage/matrix/matrix0.pxd $(SAGE_SRC)/sage/libs/meataxe.pxd $(SAGE_SRC)/sage/rings/morphism.pxd | $(PYTHON_TOOLCHAIN) matplotlib gap xz $(SAGERUNTIME) ipywidgets $(PYTHON) diff --git a/build/pkgs/packaging/dependencies b/build/pkgs/packaging/dependencies index 2323f9df04a..17220ffcc37 100644 --- a/build/pkgs/packaging/dependencies +++ b/build/pkgs/packaging/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | setuptools pip wheel pyparsing setuptools_wheel + | setuptools pip wheel pyparsing setuptools_wheel $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/packaging/distros/arch.txt b/build/pkgs/packaging/distros/arch.txt new file mode 100644 index 00000000000..02ad855da9a --- /dev/null +++ b/build/pkgs/packaging/distros/arch.txt @@ -0,0 +1 @@ +python-packaging diff --git a/build/pkgs/packaging/distros/debian.txt b/build/pkgs/packaging/distros/debian.txt new file mode 100644 index 00000000000..8f1c0ffc29f --- /dev/null +++ b/build/pkgs/packaging/distros/debian.txt @@ -0,0 +1 @@ +python3-packaging diff --git a/build/pkgs/packaging/distros/fedora.txt b/build/pkgs/packaging/distros/fedora.txt new file mode 100644 index 00000000000..02ad855da9a --- /dev/null +++ b/build/pkgs/packaging/distros/fedora.txt @@ -0,0 +1 @@ +python-packaging diff --git a/build/pkgs/packaging/distros/gentoo.txt b/build/pkgs/packaging/distros/gentoo.txt new file mode 100644 index 00000000000..e5309ed2b25 --- /dev/null +++ b/build/pkgs/packaging/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/packaging diff --git a/build/pkgs/packaging/distros/opensuse.txt b/build/pkgs/packaging/distros/opensuse.txt new file mode 100644 index 00000000000..bec5186f923 --- /dev/null +++ b/build/pkgs/packaging/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-packaging diff --git a/build/pkgs/packaging/install-requires.txt b/build/pkgs/packaging/install-requires.txt index cb98c369e84..637d00eff2f 100644 --- a/build/pkgs/packaging/install-requires.txt +++ b/build/pkgs/packaging/install-requires.txt @@ -1,2 +1,3 @@ -packaging >=18.0 +packaging >=21.0 # Trac #30975: packaging 20.5 is known to work but we have to silence "DeprecationWarning: Creating a LegacyVersion" +# Sphinx needs >= 21 diff --git a/build/pkgs/packaging/spkg-configure.m4 b/build/pkgs/packaging/spkg-configure.m4 new file mode 100644 index 00000000000..398f9e13cd3 --- /dev/null +++ b/build/pkgs/packaging/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([packaging], [SAGE_PYTHON_PACKAGE_CHECK([packaging])]) diff --git a/build/pkgs/palettable/dependencies b/build/pkgs/palettable/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/palettable/dependencies +++ b/build/pkgs/palettable/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pandoc_attributes/dependencies b/build/pkgs/pandoc_attributes/dependencies index 64f88253c78..cc9d4970706 100644 --- a/build/pkgs/pandoc_attributes/dependencies +++ b/build/pkgs/pandoc_attributes/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) $(PYTHON_TOOLCHAIN) | pip pandocfilters + $(PYTHON_TOOLCHAIN) | pip pandocfilters $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pandocfilters/dependencies b/build/pkgs/pandocfilters/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pandocfilters/dependencies +++ b/build/pkgs/pandocfilters/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pandocfilters/distros/arch.txt b/build/pkgs/pandocfilters/distros/arch.txt new file mode 100644 index 00000000000..e7a86d0373c --- /dev/null +++ b/build/pkgs/pandocfilters/distros/arch.txt @@ -0,0 +1 @@ +python-pandocfilters diff --git a/build/pkgs/pandocfilters/distros/debian.txt b/build/pkgs/pandocfilters/distros/debian.txt new file mode 100644 index 00000000000..d0d4c24e15e --- /dev/null +++ b/build/pkgs/pandocfilters/distros/debian.txt @@ -0,0 +1 @@ +python3-pandocfilters diff --git a/build/pkgs/pandocfilters/distros/fedora.txt b/build/pkgs/pandocfilters/distros/fedora.txt new file mode 100644 index 00000000000..e7a86d0373c --- /dev/null +++ b/build/pkgs/pandocfilters/distros/fedora.txt @@ -0,0 +1 @@ +python-pandocfilters diff --git a/build/pkgs/pandocfilters/distros/gentoo.txt b/build/pkgs/pandocfilters/distros/gentoo.txt new file mode 100644 index 00000000000..a726fda2817 --- /dev/null +++ b/build/pkgs/pandocfilters/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pandocfilters diff --git a/build/pkgs/pandocfilters/distros/opensuse.txt b/build/pkgs/pandocfilters/distros/opensuse.txt new file mode 100644 index 00000000000..843b3c1b32b --- /dev/null +++ b/build/pkgs/pandocfilters/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-pandocfilters diff --git a/build/pkgs/pandocfilters/spkg-configure.m4 b/build/pkgs/pandocfilters/spkg-configure.m4 new file mode 100644 index 00000000000..3e9537f818c --- /dev/null +++ b/build/pkgs/pandocfilters/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([pandocfilters], [ + SAGE_PYTHON_PACKAGE_CHECK([pandocfilters]) +]) diff --git a/build/pkgs/pari_jupyter/dependencies b/build/pkgs/pari_jupyter/dependencies index 44eaa153cc2..f7f0020c13b 100644 --- a/build/pkgs/pari_jupyter/dependencies +++ b/build/pkgs/pari_jupyter/dependencies @@ -1 +1 @@ -$(PYTHON) pari | $(PYTHON_TOOLCHAIN) cython notebook jupyter_core + pari | $(PYTHON_TOOLCHAIN) cython notebook jupyter_core $(PYTHON) diff --git a/build/pkgs/parso/dependencies b/build/pkgs/parso/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/parso/dependencies +++ b/build/pkgs/parso/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/parso/distros/gentoo.txt b/build/pkgs/parso/distros/gentoo.txt new file mode 100644 index 00000000000..f9ce4c7f2f2 --- /dev/null +++ b/build/pkgs/parso/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/parso diff --git a/build/pkgs/parso/spkg-configure.m4 b/build/pkgs/parso/spkg-configure.m4 new file mode 100644 index 00000000000..1ca6f1b909d --- /dev/null +++ b/build/pkgs/parso/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([parso], [SAGE_PYTHON_PACKAGE_CHECK([parso])]) diff --git a/build/pkgs/pathspec/dependencies b/build/pkgs/pathspec/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pathspec/dependencies +++ b/build/pkgs/pathspec/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pexpect/dependencies b/build/pkgs/pexpect/dependencies index 4a942502496..d3f8eced66f 100644 --- a/build/pkgs/pexpect/dependencies +++ b/build/pkgs/pexpect/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) ptyprocess | $(PYTHON_TOOLCHAIN) + ptyprocess | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pexpect/distros/arch.txt b/build/pkgs/pexpect/distros/arch.txt new file mode 100644 index 00000000000..74d08141569 --- /dev/null +++ b/build/pkgs/pexpect/distros/arch.txt @@ -0,0 +1 @@ +python-pexpect diff --git a/build/pkgs/pexpect/distros/fedora.txt b/build/pkgs/pexpect/distros/fedora.txt new file mode 100644 index 00000000000..74d08141569 --- /dev/null +++ b/build/pkgs/pexpect/distros/fedora.txt @@ -0,0 +1 @@ +python-pexpect diff --git a/build/pkgs/pexpect/distros/freebsd.txt b/build/pkgs/pexpect/distros/freebsd.txt new file mode 100644 index 00000000000..767fd38a2fa --- /dev/null +++ b/build/pkgs/pexpect/distros/freebsd.txt @@ -0,0 +1 @@ +misc/py-pexpect diff --git a/build/pkgs/pexpect/distros/gentoo.txt b/build/pkgs/pexpect/distros/gentoo.txt new file mode 100644 index 00000000000..30c4b60d014 --- /dev/null +++ b/build/pkgs/pexpect/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pexpect diff --git a/build/pkgs/pexpect/distros/opensuse.txt b/build/pkgs/pexpect/distros/opensuse.txt index 8d745ee4a07..f8cc97d1599 100644 --- a/build/pkgs/pexpect/distros/opensuse.txt +++ b/build/pkgs/pexpect/distros/opensuse.txt @@ -1 +1 @@ -python3-pexpect +python3${PYTHON_MINOR}-pexpect diff --git a/build/pkgs/pexpect/spkg-configure.m4 b/build/pkgs/pexpect/spkg-configure.m4 new file mode 100644 index 00000000000..6520856fbb5 --- /dev/null +++ b/build/pkgs/pexpect/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pexpect], [SAGE_PYTHON_PACKAGE_CHECK([pexpect])]) diff --git a/build/pkgs/phitigra/dependencies b/build/pkgs/phitigra/dependencies index 7aeb0c77c74..61dca76d6bc 100644 --- a/build/pkgs/phitigra/dependencies +++ b/build/pkgs/phitigra/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) ipywidgets pillow numpy | $(PYTHON_TOOLCHAIN) + ipywidgets pillow numpy | $(PYTHON_TOOLCHAIN) $(PYTHON) These dependencies include the install-requires of ipycanvas. ---------- diff --git a/build/pkgs/pickleshare/dependencies b/build/pkgs/pickleshare/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pickleshare/dependencies +++ b/build/pkgs/pickleshare/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pickleshare/distros/arch.txt b/build/pkgs/pickleshare/distros/arch.txt new file mode 100644 index 00000000000..6d991a27d41 --- /dev/null +++ b/build/pkgs/pickleshare/distros/arch.txt @@ -0,0 +1 @@ +python-pickleshare diff --git a/build/pkgs/pickleshare/distros/debian.txt b/build/pkgs/pickleshare/distros/debian.txt new file mode 100644 index 00000000000..a00907d167b --- /dev/null +++ b/build/pkgs/pickleshare/distros/debian.txt @@ -0,0 +1 @@ +python3-pickleshare diff --git a/build/pkgs/pickleshare/distros/fedora.txt b/build/pkgs/pickleshare/distros/fedora.txt new file mode 100644 index 00000000000..6d991a27d41 --- /dev/null +++ b/build/pkgs/pickleshare/distros/fedora.txt @@ -0,0 +1 @@ +python-pickleshare diff --git a/build/pkgs/pickleshare/distros/gentoo.txt b/build/pkgs/pickleshare/distros/gentoo.txt new file mode 100644 index 00000000000..14fad0fa428 --- /dev/null +++ b/build/pkgs/pickleshare/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pickleshare diff --git a/build/pkgs/pickleshare/distros/opensuse.txt b/build/pkgs/pickleshare/distros/opensuse.txt index a00907d167b..260701493fc 100644 --- a/build/pkgs/pickleshare/distros/opensuse.txt +++ b/build/pkgs/pickleshare/distros/opensuse.txt @@ -1 +1 @@ -python3-pickleshare +python3${PYTHON_MINOR}-pickleshare diff --git a/build/pkgs/pickleshare/spkg-configure.m4 b/build/pkgs/pickleshare/spkg-configure.m4 new file mode 100644 index 00000000000..80e9b7ccba9 --- /dev/null +++ b/build/pkgs/pickleshare/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pickleshare], [SAGE_PYTHON_PACKAGE_CHECK([pickleshare])]) diff --git a/build/pkgs/pillow/dependencies b/build/pkgs/pillow/dependencies index 2ece64e58e8..f2500281136 100644 --- a/build/pkgs/pillow/dependencies +++ b/build/pkgs/pillow/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) zlib freetype | $(PYTHON_TOOLCHAIN) pkgconf + zlib freetype | $(PYTHON_TOOLCHAIN) pkgconf $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pillow/distros/arch.txt b/build/pkgs/pillow/distros/arch.txt new file mode 100644 index 00000000000..86dbb1d13b8 --- /dev/null +++ b/build/pkgs/pillow/distros/arch.txt @@ -0,0 +1 @@ +python-pillow diff --git a/build/pkgs/pillow/distros/debian.txt b/build/pkgs/pillow/distros/debian.txt new file mode 100644 index 00000000000..3319fcd7e0f --- /dev/null +++ b/build/pkgs/pillow/distros/debian.txt @@ -0,0 +1 @@ +python3-pillow diff --git a/build/pkgs/pillow/distros/fedora.txt b/build/pkgs/pillow/distros/fedora.txt new file mode 100644 index 00000000000..86dbb1d13b8 --- /dev/null +++ b/build/pkgs/pillow/distros/fedora.txt @@ -0,0 +1 @@ +python-pillow diff --git a/build/pkgs/pillow/distros/gentoo.txt b/build/pkgs/pillow/distros/gentoo.txt new file mode 100644 index 00000000000..12436496ed4 --- /dev/null +++ b/build/pkgs/pillow/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pillow diff --git a/build/pkgs/pillow/distros/opensuse.txt b/build/pkgs/pillow/distros/opensuse.txt index 88283bea6d9..8261b108af6 100644 --- a/build/pkgs/pillow/distros/opensuse.txt +++ b/build/pkgs/pillow/distros/opensuse.txt @@ -1 +1 @@ -python3-Pillow +python3${PYTHON_MINOR}-Pillow diff --git a/build/pkgs/pillow/spkg-configure.m4 b/build/pkgs/pillow/spkg-configure.m4 new file mode 100644 index 00000000000..f2e68e230ac --- /dev/null +++ b/build/pkgs/pillow/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([pillow], [ + SAGE_SPKG_DEPCHECK([bzip2 freetype libpng zlib], [ + SAGE_PYTHON_PACKAGE_CHECK([pillow]) + ]) +]) diff --git a/build/pkgs/pint/dependencies b/build/pkgs/pint/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pint/dependencies +++ b/build/pkgs/pint/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pip/dependencies b/build/pkgs/pip/dependencies index 618d627629a..dac3579f7e3 100644 --- a/build/pkgs/pip/dependencies +++ b/build/pkgs/pip/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) setuptools wheel + setuptools wheel | $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pip/distros/debian.txt b/build/pkgs/pip/distros/debian.txt new file mode 100644 index 00000000000..39bd9fc5097 --- /dev/null +++ b/build/pkgs/pip/distros/debian.txt @@ -0,0 +1 @@ +python3-pip diff --git a/build/pkgs/pip/distros/fedora.txt b/build/pkgs/pip/distros/fedora.txt new file mode 100644 index 00000000000..311c1b821ca --- /dev/null +++ b/build/pkgs/pip/distros/fedora.txt @@ -0,0 +1 @@ +python-pip diff --git a/build/pkgs/pip/distros/freebsd.txt b/build/pkgs/pip/distros/freebsd.txt new file mode 100644 index 00000000000..7b125c1bfa4 --- /dev/null +++ b/build/pkgs/pip/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-pip diff --git a/build/pkgs/pip/distros/gentoo.txt b/build/pkgs/pip/distros/gentoo.txt new file mode 100644 index 00000000000..793fb731829 --- /dev/null +++ b/build/pkgs/pip/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pip diff --git a/build/pkgs/pip/distros/opensuse.txt b/build/pkgs/pip/distros/opensuse.txt index 39bd9fc5097..eb4aa7ea9f1 100644 --- a/build/pkgs/pip/distros/opensuse.txt +++ b/build/pkgs/pip/distros/opensuse.txt @@ -1 +1 @@ -python3-pip +python3${PYTHON_MINOR}-pip diff --git a/build/pkgs/pip/install-requires.txt b/build/pkgs/pip/install-requires.txt index 7af2e246633..5e76a10f694 100644 --- a/build/pkgs/pip/install-requires.txt +++ b/build/pkgs/pip/install-requires.txt @@ -1,2 +1,3 @@ -pip >=21.3 +pip >=22.1 # for use of the "in-tree-build" feature, default since 21.3, by the Sage distribution +# for use of --config-settings, 22.1 diff --git a/build/pkgs/pip/spkg-configure.m4 b/build/pkgs/pip/spkg-configure.m4 new file mode 100644 index 00000000000..c7a55621f48 --- /dev/null +++ b/build/pkgs/pip/spkg-configure.m4 @@ -0,0 +1,12 @@ +SAGE_SPKG_CONFIGURE([pip], [ + dnl always run this macro because it changes the default value of + dnl the --with-system- option. + SAGE_PYTHON_PACKAGE_CHECK([pip]) + + dnl if we might not install the spkg, make sure that "pip" is in + dnl the user's PATH, too. + AS_IF([test "x$sage_spkg_install_pip" != "xyes"], [ + AC_CHECK_PROG(HAVE_PIP, pip, yes, no) + AS_IF([test "x$HAVE_PIP" = "xno"], [sage_spkg_install_pip=yes]) + ]) +]) diff --git a/build/pkgs/pkgconfig/dependencies b/build/pkgs/pkgconfig/dependencies index 6dfe046e55e..b52668ccb01 100644 --- a/build/pkgs/pkgconfig/dependencies +++ b/build/pkgs/pkgconfig/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) pkgconf poetry_core + | $(PYTHON_TOOLCHAIN) pkgconf poetry_core $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pkgconfig/distros/arch.txt b/build/pkgs/pkgconfig/distros/arch.txt new file mode 100644 index 00000000000..38a18b3565f --- /dev/null +++ b/build/pkgs/pkgconfig/distros/arch.txt @@ -0,0 +1 @@ +python-pkgconfig diff --git a/build/pkgs/pkgconfig/distros/debian.txt b/build/pkgs/pkgconfig/distros/debian.txt new file mode 100644 index 00000000000..38e5106dd74 --- /dev/null +++ b/build/pkgs/pkgconfig/distros/debian.txt @@ -0,0 +1 @@ +python3-pkgconfig diff --git a/build/pkgs/pkgconfig/distros/fedora.txt b/build/pkgs/pkgconfig/distros/fedora.txt new file mode 100644 index 00000000000..38a18b3565f --- /dev/null +++ b/build/pkgs/pkgconfig/distros/fedora.txt @@ -0,0 +1 @@ +python-pkgconfig diff --git a/build/pkgs/pkgconfig/distros/freebsd.txt b/build/pkgs/pkgconfig/distros/freebsd.txt new file mode 100644 index 00000000000..d26a4e96787 --- /dev/null +++ b/build/pkgs/pkgconfig/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-pkgconfig diff --git a/build/pkgs/pkgconfig/distros/gentoo.txt b/build/pkgs/pkgconfig/distros/gentoo.txt new file mode 100644 index 00000000000..32e86187155 --- /dev/null +++ b/build/pkgs/pkgconfig/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pkgconfig diff --git a/build/pkgs/pkgconfig/spkg-configure.m4 b/build/pkgs/pkgconfig/spkg-configure.m4 new file mode 100644 index 00000000000..67082934525 --- /dev/null +++ b/build/pkgs/pkgconfig/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pkgconfig], [SAGE_PYTHON_PACKAGE_CHECK([pkgconfig])]) diff --git a/build/pkgs/platformdirs/dependencies b/build/pkgs/platformdirs/dependencies index 5b4aec583a4..952ebfb66cd 100644 --- a/build/pkgs/platformdirs/dependencies +++ b/build/pkgs/platformdirs/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) setuptools_scm | $(PYTHON_TOOLCHAIN) hatchling hatch_vcs + setuptools_scm | $(PYTHON_TOOLCHAIN) hatchling hatch_vcs $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pluggy/dependencies b/build/pkgs/pluggy/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pluggy/dependencies +++ b/build/pkgs/pluggy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pluggy/distros/arch.txt b/build/pkgs/pluggy/distros/arch.txt new file mode 100644 index 00000000000..c869e54c551 --- /dev/null +++ b/build/pkgs/pluggy/distros/arch.txt @@ -0,0 +1 @@ +python-pluggy diff --git a/build/pkgs/pluggy/distros/debian.txt b/build/pkgs/pluggy/distros/debian.txt new file mode 100644 index 00000000000..43a3acf0462 --- /dev/null +++ b/build/pkgs/pluggy/distros/debian.txt @@ -0,0 +1 @@ +python3-pluggy diff --git a/build/pkgs/pluggy/distros/fedora.txt b/build/pkgs/pluggy/distros/fedora.txt new file mode 100644 index 00000000000..c869e54c551 --- /dev/null +++ b/build/pkgs/pluggy/distros/fedora.txt @@ -0,0 +1 @@ +python-pluggy diff --git a/build/pkgs/pluggy/distros/gentoo.txt b/build/pkgs/pluggy/distros/gentoo.txt new file mode 100644 index 00000000000..7b338764374 --- /dev/null +++ b/build/pkgs/pluggy/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pluggy diff --git a/build/pkgs/pluggy/distros/opensuse.txt b/build/pkgs/pluggy/distros/opensuse.txt new file mode 100644 index 00000000000..42720b43944 --- /dev/null +++ b/build/pkgs/pluggy/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-pluggy diff --git a/build/pkgs/pluggy/spkg-configure.m4 b/build/pkgs/pluggy/spkg-configure.m4 new file mode 100644 index 00000000000..11b1fce4f94 --- /dev/null +++ b/build/pkgs/pluggy/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pluggy], [SAGE_PYTHON_PACKAGE_CHECK([pluggy])]) diff --git a/build/pkgs/ply/dependencies b/build/pkgs/ply/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/ply/dependencies +++ b/build/pkgs/ply/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ply/distros/gentoo.txt b/build/pkgs/ply/distros/gentoo.txt new file mode 100644 index 00000000000..c8b16309b09 --- /dev/null +++ b/build/pkgs/ply/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/ply diff --git a/build/pkgs/ply/spkg-configure.m4 b/build/pkgs/ply/spkg-configure.m4 new file mode 100644 index 00000000000..ffb0030d013 --- /dev/null +++ b/build/pkgs/ply/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([ply], [SAGE_PYTHON_PACKAGE_CHECK([ply])]) diff --git a/build/pkgs/poetry_core/dependencies b/build/pkgs/poetry_core/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/poetry_core/dependencies +++ b/build/pkgs/poetry_core/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pplpy/dependencies b/build/pkgs/pplpy/dependencies index 84d4fbab430..f61061ddefe 100644 --- a/build/pkgs/pplpy/dependencies +++ b/build/pkgs/pplpy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) $(MP_LIBRARY) gmpy2 cysignals mpfr mpc ppl | $(PYTHON_TOOLCHAIN) sphinx + $(MP_LIBRARY) gmpy2 cysignals mpfr mpc ppl | $(PYTHON_TOOLCHAIN) sphinx $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pplpy/distros/arch.txt b/build/pkgs/pplpy/distros/arch.txt new file mode 100644 index 00000000000..579bdb042f6 --- /dev/null +++ b/build/pkgs/pplpy/distros/arch.txt @@ -0,0 +1 @@ +python-pplpy diff --git a/build/pkgs/pplpy/distros/fedora.txt b/build/pkgs/pplpy/distros/fedora.txt new file mode 100644 index 00000000000..579bdb042f6 --- /dev/null +++ b/build/pkgs/pplpy/distros/fedora.txt @@ -0,0 +1 @@ +python-pplpy diff --git a/build/pkgs/pplpy/distros/freebsd.txt b/build/pkgs/pplpy/distros/freebsd.txt new file mode 100644 index 00000000000..2006f870646 --- /dev/null +++ b/build/pkgs/pplpy/distros/freebsd.txt @@ -0,0 +1 @@ +math/py-pplpy diff --git a/build/pkgs/pplpy/distros/void.txt b/build/pkgs/pplpy/distros/void.txt new file mode 100644 index 00000000000..f39eaff76ae --- /dev/null +++ b/build/pkgs/pplpy/distros/void.txt @@ -0,0 +1 @@ +python3-pplpy diff --git a/build/pkgs/primecountpy/dependencies b/build/pkgs/primecountpy/dependencies index c141a1d7c2f..ce1374b2a0e 100644 --- a/build/pkgs/primecountpy/dependencies +++ b/build/pkgs/primecountpy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) primecount cysignals | $(PYTHON_TOOLCHAIN) cython + primecount cysignals | $(PYTHON_TOOLCHAIN) cython $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/prometheus_client/dependencies b/build/pkgs/prometheus_client/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/prometheus_client/dependencies +++ b/build/pkgs/prometheus_client/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/prometheus_client/distros/gentoo.txt b/build/pkgs/prometheus_client/distros/gentoo.txt new file mode 100644 index 00000000000..aa2889c913e --- /dev/null +++ b/build/pkgs/prometheus_client/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/prometheus_client diff --git a/build/pkgs/prometheus_client/distros/opensuse.txt b/build/pkgs/prometheus_client/distros/opensuse.txt index 4d7723ec37e..c061661b6e6 100644 --- a/build/pkgs/prometheus_client/distros/opensuse.txt +++ b/build/pkgs/prometheus_client/distros/opensuse.txt @@ -1 +1 @@ -python3-prometheus_client +python3${PYTHON_MINOR}-prometheus_client diff --git a/build/pkgs/prometheus_client/spkg-configure.m4 b/build/pkgs/prometheus_client/spkg-configure.m4 new file mode 100644 index 00000000000..b4945889131 --- /dev/null +++ b/build/pkgs/prometheus_client/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([prometheus_client], [ + SAGE_PYTHON_PACKAGE_CHECK([prometheus_client]) +]) diff --git a/build/pkgs/prompt_toolkit/dependencies b/build/pkgs/prompt_toolkit/dependencies index 57465daf937..2bdb6af86bc 100644 --- a/build/pkgs/prompt_toolkit/dependencies +++ b/build/pkgs/prompt_toolkit/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) six wcwidth | $(PYTHON_TOOLCHAIN) + six wcwidth | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/prompt_toolkit/distros/arch.txt b/build/pkgs/prompt_toolkit/distros/arch.txt new file mode 100644 index 00000000000..89b0ac83a9b --- /dev/null +++ b/build/pkgs/prompt_toolkit/distros/arch.txt @@ -0,0 +1 @@ +python-importlib_resources diff --git a/build/pkgs/prompt_toolkit/distros/debian.txt b/build/pkgs/prompt_toolkit/distros/debian.txt new file mode 100644 index 00000000000..2b0146fc669 --- /dev/null +++ b/build/pkgs/prompt_toolkit/distros/debian.txt @@ -0,0 +1 @@ +importlib-resources diff --git a/build/pkgs/prompt_toolkit/distros/fedora.txt b/build/pkgs/prompt_toolkit/distros/fedora.txt new file mode 100644 index 00000000000..967f8570d4f --- /dev/null +++ b/build/pkgs/prompt_toolkit/distros/fedora.txt @@ -0,0 +1 @@ +python-prompt-toolkit diff --git a/build/pkgs/prompt_toolkit/distros/freebsd.txt b/build/pkgs/prompt_toolkit/distros/freebsd.txt new file mode 100644 index 00000000000..a2f0c05129b --- /dev/null +++ b/build/pkgs/prompt_toolkit/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-importlib-resources diff --git a/build/pkgs/prompt_toolkit/distros/gentoo.txt b/build/pkgs/prompt_toolkit/distros/gentoo.txt new file mode 100644 index 00000000000..6902484e74c --- /dev/null +++ b/build/pkgs/prompt_toolkit/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/prompt_toolkit diff --git a/build/pkgs/prompt_toolkit/distros/opensuse.txt b/build/pkgs/prompt_toolkit/distros/opensuse.txt index 424253f1340..3c48b809bc1 100644 --- a/build/pkgs/prompt_toolkit/distros/opensuse.txt +++ b/build/pkgs/prompt_toolkit/distros/opensuse.txt @@ -1 +1 @@ -python3-prompt_toolkit +python3${PYTHON_MINOR}-importlib_resources diff --git a/build/pkgs/prompt_toolkit/spkg-configure.m4 b/build/pkgs/prompt_toolkit/spkg-configure.m4 new file mode 100644 index 00000000000..fd8c1a67015 --- /dev/null +++ b/build/pkgs/prompt_toolkit/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([prompt_toolkit], [ + SAGE_PYTHON_PACKAGE_CHECK([prompt_toolkit]) +]) diff --git a/build/pkgs/ptyprocess/dependencies b/build/pkgs/ptyprocess/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/ptyprocess/dependencies +++ b/build/pkgs/ptyprocess/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/ptyprocess/distros/arch.txt b/build/pkgs/ptyprocess/distros/arch.txt new file mode 100644 index 00000000000..911a22468fc --- /dev/null +++ b/build/pkgs/ptyprocess/distros/arch.txt @@ -0,0 +1 @@ +python-ptyprocess diff --git a/build/pkgs/ptyprocess/distros/fedora.txt b/build/pkgs/ptyprocess/distros/fedora.txt new file mode 100644 index 00000000000..911a22468fc --- /dev/null +++ b/build/pkgs/ptyprocess/distros/fedora.txt @@ -0,0 +1 @@ +python-ptyprocess diff --git a/build/pkgs/ptyprocess/distros/freebsd.txt b/build/pkgs/ptyprocess/distros/freebsd.txt new file mode 100644 index 00000000000..bc587f2e5fc --- /dev/null +++ b/build/pkgs/ptyprocess/distros/freebsd.txt @@ -0,0 +1 @@ +sysutils/py-ptyprocess diff --git a/build/pkgs/ptyprocess/distros/gentoo.txt b/build/pkgs/ptyprocess/distros/gentoo.txt new file mode 100644 index 00000000000..571a851d976 --- /dev/null +++ b/build/pkgs/ptyprocess/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/ptyprocess diff --git a/build/pkgs/ptyprocess/distros/opensuse.txt b/build/pkgs/ptyprocess/distros/opensuse.txt index ad4f6db1ca7..846495a86e8 100644 --- a/build/pkgs/ptyprocess/distros/opensuse.txt +++ b/build/pkgs/ptyprocess/distros/opensuse.txt @@ -1 +1 @@ -python3-ptyprocess +python3${PYTHON_MINOR}-ptyprocess diff --git a/build/pkgs/ptyprocess/spkg-configure.m4 b/build/pkgs/ptyprocess/spkg-configure.m4 new file mode 100644 index 00000000000..bfacbaed935 --- /dev/null +++ b/build/pkgs/ptyprocess/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([ptyprocess], [SAGE_PYTHON_PACKAGE_CHECK([ptyprocess])]) diff --git a/build/pkgs/pure_eval/dependencies b/build/pkgs/pure_eval/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pure_eval/dependencies +++ b/build/pkgs/pure_eval/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/py/dependencies b/build/pkgs/py/dependencies index 14a312e5dee..995ddecb8f4 100644 --- a/build/pkgs/py/dependencies +++ b/build/pkgs/py/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) setuptools_scm + | $(PYTHON_TOOLCHAIN) setuptools_scm $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/py/distros/arch.txt b/build/pkgs/py/distros/arch.txt new file mode 100644 index 00000000000..b348d395fbd --- /dev/null +++ b/build/pkgs/py/distros/arch.txt @@ -0,0 +1 @@ +python-py diff --git a/build/pkgs/py/distros/debian.txt b/build/pkgs/py/distros/debian.txt new file mode 100644 index 00000000000..81fefe60903 --- /dev/null +++ b/build/pkgs/py/distros/debian.txt @@ -0,0 +1 @@ +python3-py diff --git a/build/pkgs/py/distros/fedora.txt b/build/pkgs/py/distros/fedora.txt new file mode 100644 index 00000000000..b348d395fbd --- /dev/null +++ b/build/pkgs/py/distros/fedora.txt @@ -0,0 +1 @@ +python-py diff --git a/build/pkgs/py/distros/opensuse.txt b/build/pkgs/py/distros/opensuse.txt new file mode 100644 index 00000000000..c03de61a449 --- /dev/null +++ b/build/pkgs/py/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-py diff --git a/build/pkgs/py/spkg-configure.m4 b/build/pkgs/py/spkg-configure.m4 new file mode 100644 index 00000000000..ded70343090 --- /dev/null +++ b/build/pkgs/py/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([py], [SAGE_PYTHON_PACKAGE_CHECK([py])]) diff --git a/build/pkgs/pybind11/checksums.ini b/build/pkgs/pybind11/checksums.ini index 1cc6d36c174..c8b9c661568 100644 --- a/build/pkgs/pybind11/checksums.ini +++ b/build/pkgs/pybind11/checksums.ini @@ -1,5 +1,5 @@ tarball=pybind11-VERSION.tar.gz -sha1=d0e6e22c2ce36fad4bb60dbac4d6d498ceb464df -md5=0b181dbb44c3cc632e724cef5081cae1 -cksum=4287838207 +sha1=3c75333a9056f0be18eb612803cd46a2bb0c87fc +md5=67c58224e41c442e47fa84e7789c2c39 +cksum=419587142 upstream_url=https://pypi.io/packages/source/p/pybind11/pybind11-VERSION.tar.gz diff --git a/build/pkgs/pybind11/dependencies b/build/pkgs/pybind11/dependencies index da2b0925acd..ca33204bd52 100644 --- a/build/pkgs/pybind11/dependencies +++ b/build/pkgs/pybind11/dependencies @@ -1 +1 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) diff --git a/build/pkgs/pybind11/distros/gentoo.txt b/build/pkgs/pybind11/distros/gentoo.txt new file mode 100644 index 00000000000..0c500b3c84d --- /dev/null +++ b/build/pkgs/pybind11/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pybind11 diff --git a/build/pkgs/pybind11/install-requires.txt b/build/pkgs/pybind11/install-requires.txt index 7f37917011f..6c44c4bd07e 100644 --- a/build/pkgs/pybind11/install-requires.txt +++ b/build/pkgs/pybind11/install-requires.txt @@ -1 +1 @@ -pybind11 >=2.5.0 +pybind11 >=2.6 diff --git a/build/pkgs/pybind11/package-version.txt b/build/pkgs/pybind11/package-version.txt index 8bbb6e406a7..6ceb272eecd 100644 --- a/build/pkgs/pybind11/package-version.txt +++ b/build/pkgs/pybind11/package-version.txt @@ -1 +1 @@ -2.10.1 +2.11.1 diff --git a/build/pkgs/pybind11/spkg-configure.m4 b/build/pkgs/pybind11/spkg-configure.m4 new file mode 100644 index 00000000000..cce1cf5cff8 --- /dev/null +++ b/build/pkgs/pybind11/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pybind11], [SAGE_PYTHON_PACKAGE_CHECK([pybind11])]) diff --git a/build/pkgs/pybtex/distros/opensuse.txt b/build/pkgs/pybtex/distros/opensuse.txt index bdd39a48fde..e482a1bfea0 100644 --- a/build/pkgs/pybtex/distros/opensuse.txt +++ b/build/pkgs/pybtex/distros/opensuse.txt @@ -1 +1 @@ -python3-pybtex +python3${PYTHON_MINOR}-pybtex diff --git a/build/pkgs/pycosat/dependencies b/build/pkgs/pycosat/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pycosat/dependencies +++ b/build/pkgs/pycosat/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pycosat/distros/alpine.txt b/build/pkgs/pycosat/distros/alpine.txt new file mode 100644 index 00000000000..7eb034d6713 --- /dev/null +++ b/build/pkgs/pycosat/distros/alpine.txt @@ -0,0 +1 @@ +py3-pycosat diff --git a/build/pkgs/pycosat/distros/arch.txt b/build/pkgs/pycosat/distros/arch.txt new file mode 100644 index 00000000000..dab3122ef4c --- /dev/null +++ b/build/pkgs/pycosat/distros/arch.txt @@ -0,0 +1 @@ +python-pycosat diff --git a/build/pkgs/pycosat/distros/fedora.txt b/build/pkgs/pycosat/distros/fedora.txt new file mode 100644 index 00000000000..dab3122ef4c --- /dev/null +++ b/build/pkgs/pycosat/distros/fedora.txt @@ -0,0 +1 @@ +python-pycosat diff --git a/build/pkgs/pycosat/distros/freebsd.txt b/build/pkgs/pycosat/distros/freebsd.txt new file mode 100644 index 00000000000..35e4e7730cc --- /dev/null +++ b/build/pkgs/pycosat/distros/freebsd.txt @@ -0,0 +1 @@ +math/py-pycosat diff --git a/build/pkgs/pycparser/dependencies b/build/pkgs/pycparser/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pycparser/dependencies +++ b/build/pkgs/pycparser/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pycparser/distros/gentoo.txt b/build/pkgs/pycparser/distros/gentoo.txt new file mode 100644 index 00000000000..5e87307c4b9 --- /dev/null +++ b/build/pkgs/pycparser/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pycparser diff --git a/build/pkgs/pycparser/distros/opensuse.txt b/build/pkgs/pycparser/distros/opensuse.txt index 0ba4f8b19f5..503e7c176d1 100644 --- a/build/pkgs/pycparser/distros/opensuse.txt +++ b/build/pkgs/pycparser/distros/opensuse.txt @@ -1 +1 @@ -python3-pycparser +python3${PYTHON_MINOR}-pycparser diff --git a/build/pkgs/pycparser/spkg-configure.m4 b/build/pkgs/pycparser/spkg-configure.m4 new file mode 100644 index 00000000000..4b9b90079a9 --- /dev/null +++ b/build/pkgs/pycparser/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pycparser], [SAGE_PYTHON_PACKAGE_CHECK([pycparser])]) diff --git a/build/pkgs/pycryptosat/dependencies b/build/pkgs/pycryptosat/dependencies index b897ff72eae..c51735427aa 100644 --- a/build/pkgs/pycryptosat/dependencies +++ b/build/pkgs/pycryptosat/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) m4ri zlib libpng cryptominisat | cmake boost_cropped $(PYTHON_TOOLCHAIN) + m4ri zlib libpng cryptominisat | cmake boost_cropped $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pycygwin/dependencies b/build/pkgs/pycygwin/dependencies index 296a2bebad3..1db13c07e43 100644 --- a/build/pkgs/pycygwin/dependencies +++ b/build/pkgs/pycygwin/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cython | $(PYTHON_TOOLCHAIN) + cython | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pygments/dependencies b/build/pkgs/pygments/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pygments/dependencies +++ b/build/pkgs/pygments/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pygments/distros/arch.txt b/build/pkgs/pygments/distros/arch.txt new file mode 100644 index 00000000000..f3e72a89c38 --- /dev/null +++ b/build/pkgs/pygments/distros/arch.txt @@ -0,0 +1 @@ +python-pygments diff --git a/build/pkgs/pygments/distros/debian.txt b/build/pkgs/pygments/distros/debian.txt new file mode 100644 index 00000000000..3ab37929b2c --- /dev/null +++ b/build/pkgs/pygments/distros/debian.txt @@ -0,0 +1 @@ +python3-pygments diff --git a/build/pkgs/pygments/distros/fedora.txt b/build/pkgs/pygments/distros/fedora.txt new file mode 100644 index 00000000000..f3e72a89c38 --- /dev/null +++ b/build/pkgs/pygments/distros/fedora.txt @@ -0,0 +1 @@ +python-pygments diff --git a/build/pkgs/pygments/distros/gentoo.txt b/build/pkgs/pygments/distros/gentoo.txt new file mode 100644 index 00000000000..a584f321e71 --- /dev/null +++ b/build/pkgs/pygments/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pygments diff --git a/build/pkgs/pygments/distros/opensuse.txt b/build/pkgs/pygments/distros/opensuse.txt index 9ff5740e79c..ef63366ff27 100644 --- a/build/pkgs/pygments/distros/opensuse.txt +++ b/build/pkgs/pygments/distros/opensuse.txt @@ -1 +1 @@ -python3-Pygments +python3${PYTHON_MINOR}-pygments diff --git a/build/pkgs/pygments/install-requires.txt b/build/pkgs/pygments/install-requires.txt index 0d0dc97d523..337e5bbad8b 100644 --- a/build/pkgs/pygments/install-requires.txt +++ b/build/pkgs/pygments/install-requires.txt @@ -1 +1 @@ -pygments >=2.3.1 +pygments >=2.12 diff --git a/build/pkgs/pygments/spkg-configure.m4 b/build/pkgs/pygments/spkg-configure.m4 new file mode 100644 index 00000000000..99f29e3c9b3 --- /dev/null +++ b/build/pkgs/pygments/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pygments], [SAGE_PYTHON_PACKAGE_CHECK([pygments])]) diff --git a/build/pkgs/pygraphviz/dependencies b/build/pkgs/pygraphviz/dependencies index 232dc205925..a723707e09c 100644 --- a/build/pkgs/pygraphviz/dependencies +++ b/build/pkgs/pygraphviz/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) libgraphviz | $(PYTHON_TOOLCHAIN) + libgraphviz | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pynormaliz/dependencies b/build/pkgs/pynormaliz/dependencies index 76200c19d23..1fca858579e 100644 --- a/build/pkgs/pynormaliz/dependencies +++ b/build/pkgs/pynormaliz/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) normaliz | $(PYTHON_TOOLCHAIN) + normaliz | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pyparsing/dependencies b/build/pkgs/pyparsing/dependencies index 2471ffdf59d..22915b3da68 100644 --- a/build/pkgs/pyparsing/dependencies +++ b/build/pkgs/pyparsing/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | pip wheel flit_core tomli + | pip wheel flit_core tomli $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pyparsing/distros/arch.txt b/build/pkgs/pyparsing/distros/arch.txt new file mode 100644 index 00000000000..428820c215f --- /dev/null +++ b/build/pkgs/pyparsing/distros/arch.txt @@ -0,0 +1 @@ +python-pyparsing diff --git a/build/pkgs/pyparsing/distros/freebsd.txt b/build/pkgs/pyparsing/distros/freebsd.txt new file mode 100644 index 00000000000..39fdc921fd0 --- /dev/null +++ b/build/pkgs/pyparsing/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-pyparsing diff --git a/build/pkgs/pyparsing/distros/gentoo.txt b/build/pkgs/pyparsing/distros/gentoo.txt new file mode 100644 index 00000000000..ef0419f9cbc --- /dev/null +++ b/build/pkgs/pyparsing/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pyparsing diff --git a/build/pkgs/pyparsing/distros/opensuse.txt b/build/pkgs/pyparsing/distros/opensuse.txt index 492a7ce0a69..2a91a003cf9 100644 --- a/build/pkgs/pyparsing/distros/opensuse.txt +++ b/build/pkgs/pyparsing/distros/opensuse.txt @@ -1 +1 @@ -python3-pyparsing +python3${PYTHON_MINOR}-pyparsing diff --git a/build/pkgs/pyparsing/spkg-configure.m4 b/build/pkgs/pyparsing/spkg-configure.m4 new file mode 100644 index 00000000000..d2b4c0055e4 --- /dev/null +++ b/build/pkgs/pyparsing/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pyparsing], [SAGE_PYTHON_PACKAGE_CHECK([pyparsing])]) diff --git a/build/pkgs/pyppeteer/dependencies b/build/pkgs/pyppeteer/dependencies index 1c2d4afb8d4..7d9ec36f9c7 100644 --- a/build/pkgs/pyppeteer/dependencies +++ b/build/pkgs/pyppeteer/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) appdirs importlib_metadata urllib3 certifi | $(PYTHON_TOOLCHAIN) + appdirs importlib_metadata urllib3 certifi | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pyproject_metadata/checksums.ini b/build/pkgs/pyproject_metadata/checksums.ini index 4fcc0ec49c2..6fb14a63679 100644 --- a/build/pkgs/pyproject_metadata/checksums.ini +++ b/build/pkgs/pyproject_metadata/checksums.ini @@ -1,5 +1,5 @@ tarball=pyproject-metadata-VERSION.tar.gz -sha1=c2b7679b1e56a341aa00c186c0d1a6bbd7bd5c2c -md5=e13b11cb723da96f8397addddca963cc -cksum=2246727402 +sha1=41fba5c33917d77b9364fadb76e590e86789634d +md5=ca5e9527cff96153a976e14530b53746 +cksum=2053869519 upstream_url=https://pypi.io/packages/source/p/pyproject_metadata/pyproject-metadata-VERSION.tar.gz diff --git a/build/pkgs/pyproject_metadata/dependencies b/build/pkgs/pyproject_metadata/dependencies index 6d5368db738..3df264eee42 100644 --- a/build/pkgs/pyproject_metadata/dependencies +++ b/build/pkgs/pyproject_metadata/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) packaging pyparsing | $(PYTHON_TOOLCHAIN) + packaging pyparsing | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pyproject_metadata/package-version.txt b/build/pkgs/pyproject_metadata/package-version.txt index ee6cdce3c29..39e898a4f95 100644 --- a/build/pkgs/pyproject_metadata/package-version.txt +++ b/build/pkgs/pyproject_metadata/package-version.txt @@ -1 +1 @@ -0.6.1 +0.7.1 diff --git a/build/pkgs/pyrsistent/dependencies b/build/pkgs/pyrsistent/dependencies index 4361e46ddaf..9be6b4aab7c 100644 --- a/build/pkgs/pyrsistent/dependencies +++ b/build/pkgs/pyrsistent/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) vcversioner | $(PYTHON_TOOLCHAIN) + vcversioner | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pyrsistent/distros/gentoo.txt b/build/pkgs/pyrsistent/distros/gentoo.txt new file mode 100644 index 00000000000..83439cebfe4 --- /dev/null +++ b/build/pkgs/pyrsistent/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pyrsistent diff --git a/build/pkgs/pyrsistent/spkg-configure.m4 b/build/pkgs/pyrsistent/spkg-configure.m4 new file mode 100644 index 00000000000..f7ca75dbac5 --- /dev/null +++ b/build/pkgs/pyrsistent/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pyrsistent], [SAGE_PYTHON_PACKAGE_CHECK([pyrsistent])]) diff --git a/build/pkgs/pyscipopt/dependencies b/build/pkgs/pyscipopt/dependencies index 66f72c29e1a..3c4a108db0f 100644 --- a/build/pkgs/pyscipopt/dependencies +++ b/build/pkgs/pyscipopt/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) scip | $(PYTHON_TOOLCHAIN) cython + scip | $(PYTHON_TOOLCHAIN) cython $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pysingular/dependencies b/build/pkgs/pysingular/dependencies index bd58b826630..075bad15831 100644 --- a/build/pkgs/pysingular/dependencies +++ b/build/pkgs/pysingular/dependencies @@ -1 +1 @@ -$(PYTHON) singular | $(PYTHON_TOOLCHAIN) + singular | $(PYTHON_TOOLCHAIN) $(PYTHON) diff --git a/build/pkgs/pytest/dependencies b/build/pkgs/pytest/dependencies index 7e5a90a20bd..af3334a7daf 100644 --- a/build/pkgs/pytest/dependencies +++ b/build/pkgs/pytest/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pluggy packaging attrs py pyparsing importlib_metadata tomli | $(PYTHON_TOOLCHAIN) + pluggy packaging attrs py pyparsing importlib_metadata tomli | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pytest_mock/dependencies b/build/pkgs/pytest_mock/dependencies index 37ea60eb442..720c11ec214 100644 --- a/build/pkgs/pytest_mock/dependencies +++ b/build/pkgs/pytest_mock/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pytest packaging attrs pluggy tomli py pyparsing | $(PYTHON_TOOLCHAIN) + pytest packaging attrs pluggy tomli py pyparsing | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pytest_xdist/dependencies b/build/pkgs/pytest_xdist/dependencies index aa8c608f663..19d8b032667 100644 --- a/build/pkgs/pytest_xdist/dependencies +++ b/build/pkgs/pytest_xdist/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pytest | $(PYTHON_TOOLCHAIN) + pytest | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/python3/distros/opensuse.txt b/build/pkgs/python3/distros/opensuse.txt index 07358a92e89..760ddd76f2c 100644 --- a/build/pkgs/python3/distros/opensuse.txt +++ b/build/pkgs/python3/distros/opensuse.txt @@ -1 +1 @@ -python3-devel +python3${PYTHON_MINOR}-devel diff --git a/build/pkgs/python3/spkg-configure.m4 b/build/pkgs/python3/spkg-configure.m4 index 5a0aa955633..d57aa416e3a 100644 --- a/build/pkgs/python3/spkg-configure.m4 +++ b/build/pkgs/python3/spkg-configure.m4 @@ -130,17 +130,17 @@ To build Sage with a different system python, use ./configure --with-python=/pat ]) AC_SUBST([PYTHON_FOR_VENV]) + AS_IF([test -n "$PYTHON_FOR_VENV"], + [PYTHON_VERSION=$("$PYTHON_FOR_VENV" -c "import sysconfig; print(sysconfig.get_python_version())")], + [PYTHON_VERSION=$(echo $(cat build/pkgs/python3/package-version.txt))]) + AC_SUBST([PYTHON_MINOR], [$(echo $PYTHON_VERSION | cut -d. -f2)]) + export PYTHON_MINOR # for sage-get-system-packages + AS_VAR_IF([SAGE_VENV], [auto], [SAGE_VENV=$SAGE_VENV_AUTO]) AS_CASE([$SAGE_VENV], [no], [SAGE_VENV='${SAGE_LOCAL}'],dnl Quoted so that it is resolved at build time by shell/Makefile - [yes], [AS_IF([test -n "$PYTHON_FOR_VENV"], [ - PYTHON_VERSION=$("$PYTHON_FOR_VENV" -c "import sysconfig; print(sysconfig.get_python_version())") - ], [ - PYTHON_VERSION=$(echo $(cat build/pkgs/python3/package-version.txt)) - ]) - SAGE_VENV='${SAGE_LOCAL}'/var/lib/sage/venv-python$PYTHON_VERSION] + [yes], [SAGE_VENV='${SAGE_LOCAL}'/var/lib/sage/venv-python$PYTHON_VERSION] ) - dnl These temporary directories are created by the check above dnl and need to be cleaned up to prevent the "rm -f conftest*" dnl (that a bunch of other checks do) from emitting warnings about diff --git a/build/pkgs/python_build/dependencies b/build/pkgs/python_build/dependencies index 769e08a8c26..b72a6d1c776 100644 --- a/build/pkgs/python_build/dependencies +++ b/build/pkgs/python_build/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pyparsing tomli packaging | $(PYTHON_TOOLCHAIN) + pyparsing tomli packaging | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/python_igraph/dependencies b/build/pkgs/python_igraph/dependencies index 67ed15160f4..dde58706323 100644 --- a/build/pkgs/python_igraph/dependencies +++ b/build/pkgs/python_igraph/dependencies @@ -1,4 +1,4 @@ -igraph texttable $(PYTHON) | $(PYTHON_TOOLCHAIN) +igraph texttable | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/python_igraph/distros/arch.txt b/build/pkgs/python_igraph/distros/arch.txt new file mode 100644 index 00000000000..03f8142066f --- /dev/null +++ b/build/pkgs/python_igraph/distros/arch.txt @@ -0,0 +1 @@ +python-igraph diff --git a/build/pkgs/python_igraph/distros/debian.txt b/build/pkgs/python_igraph/distros/debian.txt new file mode 100644 index 00000000000..218ba998007 --- /dev/null +++ b/build/pkgs/python_igraph/distros/debian.txt @@ -0,0 +1 @@ +python3-igraph diff --git a/build/pkgs/python_igraph/distros/fedora.txt b/build/pkgs/python_igraph/distros/fedora.txt new file mode 100644 index 00000000000..03f8142066f --- /dev/null +++ b/build/pkgs/python_igraph/distros/fedora.txt @@ -0,0 +1 @@ +python-igraph diff --git a/build/pkgs/python_igraph/distros/freebsd.txt b/build/pkgs/python_igraph/distros/freebsd.txt new file mode 100644 index 00000000000..d86a516f3ed --- /dev/null +++ b/build/pkgs/python_igraph/distros/freebsd.txt @@ -0,0 +1 @@ +math/py-igraph diff --git a/build/pkgs/pythran/checksums.ini b/build/pkgs/pythran/checksums.ini index cb4704c4bc4..dc9beccf6b6 100644 --- a/build/pkgs/pythran/checksums.ini +++ b/build/pkgs/pythran/checksums.ini @@ -1,5 +1,5 @@ tarball=pythran-VERSION.tar.gz -sha1=71bc7c868cf011d184a013211f4195d8f9c606a2 -md5=168c31e8d108f26440b663b44cd99379 -cksum=2086161839 +sha1=dd675e9ccc93379b529687328ca558d5617eb1c6 +md5=3090288af50566af75cb058d1878aaad +cksum=3968085663 upstream_url=https://pypi.io/packages/source/p/pythran/pythran-VERSION.tar.gz diff --git a/build/pkgs/pythran/dependencies b/build/pkgs/pythran/dependencies index 8a64589c0bc..3845adb7a2c 100644 --- a/build/pkgs/pythran/dependencies +++ b/build/pkgs/pythran/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) beniget gast ply numpy | $(PYTHON_TOOLCHAIN) + beniget gast ply numpy | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pythran/distros/gentoo.txt b/build/pkgs/pythran/distros/gentoo.txt new file mode 100644 index 00000000000..1bb7cdcd4eb --- /dev/null +++ b/build/pkgs/pythran/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pythran diff --git a/build/pkgs/pythran/install-requires.txt b/build/pkgs/pythran/install-requires.txt index 86d056b339f..f365e5f4971 100644 --- a/build/pkgs/pythran/install-requires.txt +++ b/build/pkgs/pythran/install-requires.txt @@ -1 +1 @@ -pythran +pythran >=0.12.1 diff --git a/build/pkgs/pythran/package-version.txt b/build/pkgs/pythran/package-version.txt index 34a83616bb5..c317a91891f 100644 --- a/build/pkgs/pythran/package-version.txt +++ b/build/pkgs/pythran/package-version.txt @@ -1 +1 @@ -0.12.1 +0.13.1 diff --git a/build/pkgs/pythran/spkg-configure.m4 b/build/pkgs/pythran/spkg-configure.m4 new file mode 100644 index 00000000000..592e95bcb3d --- /dev/null +++ b/build/pkgs/pythran/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pythran], [SAGE_PYTHON_PACKAGE_CHECK([pythran])]) diff --git a/build/pkgs/pytz/dependencies b/build/pkgs/pytz/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/pytz/dependencies +++ b/build/pkgs/pytz/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pytz/distros/arch.txt b/build/pkgs/pytz/distros/arch.txt new file mode 100644 index 00000000000..2cccc9e61ec --- /dev/null +++ b/build/pkgs/pytz/distros/arch.txt @@ -0,0 +1 @@ +python-pytz diff --git a/build/pkgs/pytz/distros/debian.txt b/build/pkgs/pytz/distros/debian.txt new file mode 100644 index 00000000000..db209080161 --- /dev/null +++ b/build/pkgs/pytz/distros/debian.txt @@ -0,0 +1 @@ +python3-tz diff --git a/build/pkgs/pytz/distros/fedora.txt b/build/pkgs/pytz/distros/fedora.txt new file mode 100644 index 00000000000..2cccc9e61ec --- /dev/null +++ b/build/pkgs/pytz/distros/fedora.txt @@ -0,0 +1 @@ +python-pytz diff --git a/build/pkgs/pytz/distros/gentoo.txt b/build/pkgs/pytz/distros/gentoo.txt new file mode 100644 index 00000000000..902a18bf73e --- /dev/null +++ b/build/pkgs/pytz/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pytz diff --git a/build/pkgs/pytz/distros/opensuse.txt b/build/pkgs/pytz/distros/opensuse.txt index 1b20e1dbb77..232b99a6d04 100644 --- a/build/pkgs/pytz/distros/opensuse.txt +++ b/build/pkgs/pytz/distros/opensuse.txt @@ -1 +1 @@ -python3-pytz +python3${PYTHON_MINOR}-pytz diff --git a/build/pkgs/pytz/spkg-configure.m4 b/build/pkgs/pytz/spkg-configure.m4 new file mode 100644 index 00000000000..366521be957 --- /dev/null +++ b/build/pkgs/pytz/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([pytz], [SAGE_PYTHON_PACKAGE_CHECK([pytz])]) diff --git a/build/pkgs/pytz_deprecation_shim/dependencies b/build/pkgs/pytz_deprecation_shim/dependencies index 232fe6c0554..2ea28ad2718 100644 --- a/build/pkgs/pytz_deprecation_shim/dependencies +++ b/build/pkgs/pytz_deprecation_shim/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) tzdata | $(PYTHON_TOOLCHAIN) + tzdata | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pyx/distros/opensuse.txt b/build/pkgs/pyx/distros/opensuse.txt index 03265558e86..f7dd2365b82 100644 --- a/build/pkgs/pyx/distros/opensuse.txt +++ b/build/pkgs/pyx/distros/opensuse.txt @@ -1 +1 @@ -python3-PyX +python3${PYTHON_MINOR}-PyX diff --git a/build/pkgs/pyzmq/dependencies b/build/pkgs/pyzmq/dependencies index c72b3d23340..5031d872d13 100644 --- a/build/pkgs/pyzmq/dependencies +++ b/build/pkgs/pyzmq/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cython zeromq | $(PYTHON_TOOLCHAIN) + cython zeromq | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pyzmq/distros/arch.txt b/build/pkgs/pyzmq/distros/arch.txt new file mode 100644 index 00000000000..23f64d1f1a3 --- /dev/null +++ b/build/pkgs/pyzmq/distros/arch.txt @@ -0,0 +1 @@ +python-pyzmq diff --git a/build/pkgs/pyzmq/distros/fedora.txt b/build/pkgs/pyzmq/distros/fedora.txt new file mode 100644 index 00000000000..23f64d1f1a3 --- /dev/null +++ b/build/pkgs/pyzmq/distros/fedora.txt @@ -0,0 +1 @@ +python-pyzmq diff --git a/build/pkgs/pyzmq/distros/gentoo.txt b/build/pkgs/pyzmq/distros/gentoo.txt new file mode 100644 index 00000000000..77c24295bd0 --- /dev/null +++ b/build/pkgs/pyzmq/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/pyzmq diff --git a/build/pkgs/pyzmq/distros/opensuse.txt b/build/pkgs/pyzmq/distros/opensuse.txt index 265a272130e..fe243347c49 100644 --- a/build/pkgs/pyzmq/distros/opensuse.txt +++ b/build/pkgs/pyzmq/distros/opensuse.txt @@ -1 +1 @@ -python3-pyzmq +python3${PYTHON_MINOR}-pyzmq diff --git a/build/pkgs/pyzmq/spkg-configure.m4 b/build/pkgs/pyzmq/spkg-configure.m4 new file mode 100644 index 00000000000..ae2b126efb1 --- /dev/null +++ b/build/pkgs/pyzmq/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([pyzmq], [ + SAGE_SPKG_DEPCHECK([zeromq], [ + SAGE_PYTHON_PACKAGE_CHECK([pyzmq]) + ]) +]) diff --git a/build/pkgs/qdldl_python/dependencies b/build/pkgs/qdldl_python/dependencies index 48c2586b9f4..757104fcba0 100644 --- a/build/pkgs/qdldl_python/dependencies +++ b/build/pkgs/qdldl_python/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pybind11 numpy scipy | $(PYTHON_TOOLCHAIN) cmake + pybind11 numpy scipy | $(PYTHON_TOOLCHAIN) cmake $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/requests/dependencies b/build/pkgs/requests/dependencies index b896dbc3cac..668fe014f12 100644 --- a/build/pkgs/requests/dependencies +++ b/build/pkgs/requests/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) idna urllib3 certifi charset_normalizer + | $(PYTHON_TOOLCHAIN) idna urllib3 certifi charset_normalizer $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/requests/distros/arch.txt b/build/pkgs/requests/distros/arch.txt new file mode 100644 index 00000000000..93a7bc19b60 --- /dev/null +++ b/build/pkgs/requests/distros/arch.txt @@ -0,0 +1 @@ +python-requests diff --git a/build/pkgs/requests/distros/debian.txt b/build/pkgs/requests/distros/debian.txt new file mode 100644 index 00000000000..43147b2be74 --- /dev/null +++ b/build/pkgs/requests/distros/debian.txt @@ -0,0 +1 @@ +python3-requests diff --git a/build/pkgs/requests/distros/fedora.txt b/build/pkgs/requests/distros/fedora.txt new file mode 100644 index 00000000000..93a7bc19b60 --- /dev/null +++ b/build/pkgs/requests/distros/fedora.txt @@ -0,0 +1 @@ +python-requests diff --git a/build/pkgs/requests/distros/gentoo.txt b/build/pkgs/requests/distros/gentoo.txt new file mode 100644 index 00000000000..d3dc9415e3d --- /dev/null +++ b/build/pkgs/requests/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/requests diff --git a/build/pkgs/requests/distros/opensuse.txt b/build/pkgs/requests/distros/opensuse.txt index 43147b2be74..c1581ad8a95 100644 --- a/build/pkgs/requests/distros/opensuse.txt +++ b/build/pkgs/requests/distros/opensuse.txt @@ -1 +1 @@ -python3-requests +python3${PYTHON_MINOR}-requests diff --git a/build/pkgs/requests/spkg-configure.m4 b/build/pkgs/requests/spkg-configure.m4 new file mode 100644 index 00000000000..f50a66cdee3 --- /dev/null +++ b/build/pkgs/requests/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([requests], [SAGE_PYTHON_PACKAGE_CHECK([requests])]) diff --git a/build/pkgs/retrolab/dependencies b/build/pkgs/retrolab/dependencies index 531f28310be..58027d3558c 100644 --- a/build/pkgs/retrolab/dependencies +++ b/build/pkgs/retrolab/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) jupyterlab | $(PYTHON_TOOLCHAIN) + jupyterlab | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/rpy2/dependencies b/build/pkgs/rpy2/dependencies index b8937d88769..b88615716d4 100644 --- a/build/pkgs/rpy2/dependencies +++ b/build/pkgs/rpy2/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) r cffi tzlocal pytz jinja2 | $(PYTHON_TOOLCHAIN) pycparser + r cffi tzlocal pytz jinja2 | $(PYTHON_TOOLCHAIN) pycparser $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/rpy2/distros/arch.txt b/build/pkgs/rpy2/distros/arch.txt new file mode 100644 index 00000000000..9748535a285 --- /dev/null +++ b/build/pkgs/rpy2/distros/arch.txt @@ -0,0 +1 @@ +python-rpy2 diff --git a/build/pkgs/rpy2/distros/debian.txt b/build/pkgs/rpy2/distros/debian.txt new file mode 100644 index 00000000000..8f389862688 --- /dev/null +++ b/build/pkgs/rpy2/distros/debian.txt @@ -0,0 +1 @@ +rpy2 diff --git a/build/pkgs/rpy2/distros/freebsd.txt b/build/pkgs/rpy2/distros/freebsd.txt new file mode 100644 index 00000000000..21caa8b9edd --- /dev/null +++ b/build/pkgs/rpy2/distros/freebsd.txt @@ -0,0 +1 @@ +math/py-rpy2 diff --git a/build/pkgs/rpy2/distros/macports.txt b/build/pkgs/rpy2/distros/macports.txt new file mode 100644 index 00000000000..71f03850a9b --- /dev/null +++ b/build/pkgs/rpy2/distros/macports.txt @@ -0,0 +1 @@ +py-rpy2 diff --git a/build/pkgs/rpy2/distros/opensuse.txt b/build/pkgs/rpy2/distros/opensuse.txt new file mode 100644 index 00000000000..5b9c1542845 --- /dev/null +++ b/build/pkgs/rpy2/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-rpy2 diff --git a/build/pkgs/rst2ipynb/dependencies b/build/pkgs/rst2ipynb/dependencies index 7fcda2181e1..d828daf957d 100644 --- a/build/pkgs/rst2ipynb/dependencies +++ b/build/pkgs/rst2ipynb/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pandoc | $(PYTHON_TOOLCHAIN) notedown + pandoc | $(PYTHON_TOOLCHAIN) notedown $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sage_conf/dependencies b/build/pkgs/sage_conf/dependencies index 0479fd1d280..f2bd00aaf0d 100644 --- a/build/pkgs/sage_conf/dependencies +++ b/build/pkgs/sage_conf/dependencies @@ -1 +1 @@ -$(PYTHON) $(SAGE_ROOT)/pkgs/sage-conf/_sage_conf/_conf.py $(SAGE_ROOT)/pkgs/sage-conf/setup.cfg $(SAGE_ROOT)/pkgs/sage-conf/bin/sage-env-config | $(PYTHON_TOOLCHAIN) + $(SAGE_ROOT)/pkgs/sage-conf/_sage_conf/_conf.py $(SAGE_ROOT)/pkgs/sage-conf/setup.cfg $(SAGE_ROOT)/pkgs/sage-conf/bin/sage-env-config | $(PYTHON_TOOLCHAIN) $(PYTHON) diff --git a/build/pkgs/sage_conf/install-requires.txt b/build/pkgs/sage_conf/install-requires.txt index 22f995d5ba6..06f170ad9c5 100644 --- a/build/pkgs/sage_conf/install-requires.txt +++ b/build/pkgs/sage_conf/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-conf ~= 10.2b1 +sage-conf ~= 10.2b2 diff --git a/build/pkgs/sage_docbuild/dependencies b/build/pkgs/sage_docbuild/dependencies index 376ad09772a..c21e4b287e3 100644 --- a/build/pkgs/sage_docbuild/dependencies +++ b/build/pkgs/sage_docbuild/dependencies @@ -1 +1 @@ -$(PYTHON) sphinx $(SAGE_ROOT)/pkgs/sage-docbuild/sage_docbuild/*.py $(SAGE_ROOT)/pkgs/sage-docbuild/sage_docbuild/ext/*.py | $(PYTHON_TOOLCHAIN) sagelib + sphinx $(SAGE_ROOT)/pkgs/sage-docbuild/sage_docbuild/*.py $(SAGE_ROOT)/pkgs/sage-docbuild/sage_docbuild/ext/*.py | $(PYTHON_TOOLCHAIN) sagelib $(PYTHON) diff --git a/build/pkgs/sage_docbuild/install-requires.txt b/build/pkgs/sage_docbuild/install-requires.txt index eddd7bf2c86..7b518e173dd 100644 --- a/build/pkgs/sage_docbuild/install-requires.txt +++ b/build/pkgs/sage_docbuild/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-docbuild ~= 10.2b1 +sage-docbuild ~= 10.2b2 diff --git a/build/pkgs/sage_flatsurf/dependencies b/build/pkgs/sage_flatsurf/dependencies index 4c62fdd4fef..c706908baa7 100644 --- a/build/pkgs/sage_flatsurf/dependencies +++ b/build/pkgs/sage_flatsurf/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) surface_dynamics $(SAGERUNTIME) + | $(PYTHON_TOOLCHAIN) surface_dynamics $(SAGERUNTIME) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sage_numerical_backends_coin/dependencies b/build/pkgs/sage_numerical_backends_coin/dependencies index 4cbde1164f2..0448728cea5 100644 --- a/build/pkgs/sage_numerical_backends_coin/dependencies +++ b/build/pkgs/sage_numerical_backends_coin/dependencies @@ -1,4 +1,4 @@ -cbc cysignals $(SAGE_SRC)/sage/numerical/backends/generic_backend.pxd $(SAGE_SRC)/sage/cpython/string.pxd $(SAGE_SRC)/sage/cpython/string_impl.h | $(SAGERUNTIME) $(PYTHON_TOOLCHAIN) cython ipywidgets +cbc cysignals $(SAGE_SRC)/sage/numerical/backends/generic_backend.pxd $(SAGE_SRC)/sage/cpython/string.pxd $(SAGE_SRC)/sage/cpython/string_impl.h | $(SAGERUNTIME) $(PYTHON_TOOLCHAIN) cython ipywidgets $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sage_numerical_backends_cplex/dependencies b/build/pkgs/sage_numerical_backends_cplex/dependencies index 0b35afa3540..840bdcabd34 100644 --- a/build/pkgs/sage_numerical_backends_cplex/dependencies +++ b/build/pkgs/sage_numerical_backends_cplex/dependencies @@ -1,4 +1,4 @@ -cysignals $(SAGE_SRC)/sage/numerical/backends/generic_backend.pxd $(SAGE_SRC)/sage/cpython/string.pxd $(SAGE_SRC)/sage/cpython/string_impl.h | $(SAGERUNTIME) $(PYTHON_TOOLCHAIN) cython ipywidgets +cysignals $(SAGE_SRC)/sage/numerical/backends/generic_backend.pxd $(SAGE_SRC)/sage/cpython/string.pxd $(SAGE_SRC)/sage/cpython/string_impl.h | $(SAGERUNTIME) $(PYTHON_TOOLCHAIN) cython ipywidgets $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sage_numerical_backends_gurobi/dependencies b/build/pkgs/sage_numerical_backends_gurobi/dependencies index 0b35afa3540..840bdcabd34 100644 --- a/build/pkgs/sage_numerical_backends_gurobi/dependencies +++ b/build/pkgs/sage_numerical_backends_gurobi/dependencies @@ -1,4 +1,4 @@ -cysignals $(SAGE_SRC)/sage/numerical/backends/generic_backend.pxd $(SAGE_SRC)/sage/cpython/string.pxd $(SAGE_SRC)/sage/cpython/string_impl.h | $(SAGERUNTIME) $(PYTHON_TOOLCHAIN) cython ipywidgets +cysignals $(SAGE_SRC)/sage/numerical/backends/generic_backend.pxd $(SAGE_SRC)/sage/cpython/string.pxd $(SAGE_SRC)/sage/cpython/string_impl.h | $(SAGERUNTIME) $(PYTHON_TOOLCHAIN) cython ipywidgets $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sage_setup/dependencies b/build/pkgs/sage_setup/dependencies index 8c2e218f49a..cae3faf9049 100644 --- a/build/pkgs/sage_setup/dependencies +++ b/build/pkgs/sage_setup/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cython pkgconfig jinja2 $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/*.py $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/autogen/interpreters/specs/*.py $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/command/*.py | $(PYTHON_TOOLCHAIN) + cython pkgconfig jinja2 $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/*.py $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/autogen/interpreters/specs/*.py $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/command/*.py | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sage_setup/install-requires.txt b/build/pkgs/sage_setup/install-requires.txt index bd2318c8a43..8db908c6944 100644 --- a/build/pkgs/sage_setup/install-requires.txt +++ b/build/pkgs/sage_setup/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-setup ~= 10.2b1 +sage-setup ~= 10.2b2 diff --git a/build/pkgs/sage_sws2rst/dependencies b/build/pkgs/sage_sws2rst/dependencies index 5ca5e27df75..f32c4fc594d 100644 --- a/build/pkgs/sage_sws2rst/dependencies +++ b/build/pkgs/sage_sws2rst/dependencies @@ -1 +1 @@ -$(PYTHON) beautifulsoup4 $(SAGE_ROOT)/pkgs/sage-sws2rst/*.py | $(PYTHON_TOOLCHAIN) + beautifulsoup4 $(SAGE_ROOT)/pkgs/sage-sws2rst/*.py | $(PYTHON_TOOLCHAIN) $(PYTHON) diff --git a/build/pkgs/sage_sws2rst/install-requires.txt b/build/pkgs/sage_sws2rst/install-requires.txt index 919f61d9a57..1ca0ff7a241 100644 --- a/build/pkgs/sage_sws2rst/install-requires.txt +++ b/build/pkgs/sage_sws2rst/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-sws2rst ~= 10.2b1 +sage-sws2rst ~= 10.2b2 diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies index 9b8c062d3c3..5f1ed036f8e 100644 --- a/build/pkgs/sagelib/dependencies +++ b/build/pkgs/sagelib/dependencies @@ -1,4 +1,4 @@ -FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources 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 typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup +FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources 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 typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sagelib/install-requires.txt b/build/pkgs/sagelib/install-requires.txt index 2e2ccc4f6b8..aef7517b907 100644 --- a/build/pkgs/sagelib/install-requires.txt +++ b/build/pkgs/sagelib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-standard ~= 10.2b1 +sagemath-standard ~= 10.2b2 diff --git a/build/pkgs/sagemath_bliss/dependencies b/build/pkgs/sagemath_bliss/dependencies index 279e79ace91..a7915e316b9 100644 --- a/build/pkgs/sagemath_bliss/dependencies +++ b/build/pkgs/sagemath_bliss/dependencies @@ -1 +1 @@ -$(PYTHON) bliss cysignals | $(PYTHON_TOOLCHAIN) sage_setup sage_conf sagemath_environment cython pkgconfig + bliss cysignals | $(PYTHON_TOOLCHAIN) sage_setup sage_conf sagemath_environment cython pkgconfig $(PYTHON) diff --git a/build/pkgs/sagemath_bliss/install-requires.txt b/build/pkgs/sagemath_bliss/install-requires.txt index 381f802e2dd..31f2105dc48 100644 --- a/build/pkgs/sagemath_bliss/install-requires.txt +++ b/build/pkgs/sagemath_bliss/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-bliss ~= 10.2b1 +sagemath-bliss ~= 10.2b2 diff --git a/build/pkgs/sagemath_categories/dependencies b/build/pkgs/sagemath_categories/dependencies index d8b6bdbd4a7..9fa43a64aae 100644 --- a/build/pkgs/sagemath_categories/dependencies +++ b/build/pkgs/sagemath_categories/dependencies @@ -1 +1 @@ -$(PYTHON) sagemath_objects | $(PYTHON_TOOLCHAIN) sagemath_environment sage_setup cython pkgconfig python_build + sagemath_objects | $(PYTHON_TOOLCHAIN) sagemath_environment sage_setup cython pkgconfig python_build $(PYTHON) diff --git a/build/pkgs/sagemath_categories/install-requires.txt b/build/pkgs/sagemath_categories/install-requires.txt index 9b709a38980..7165a331015 100644 --- a/build/pkgs/sagemath_categories/install-requires.txt +++ b/build/pkgs/sagemath_categories/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-categories ~= 10.2b1 +sagemath-categories ~= 10.2b2 diff --git a/build/pkgs/sagemath_coxeter3/dependencies b/build/pkgs/sagemath_coxeter3/dependencies index 615392ca427..ada45656089 100644 --- a/build/pkgs/sagemath_coxeter3/dependencies +++ b/build/pkgs/sagemath_coxeter3/dependencies @@ -1 +1 @@ -$(PYTHON) coxeter3 | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig + coxeter3 | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig $(PYTHON) diff --git a/build/pkgs/sagemath_coxeter3/install-requires.txt b/build/pkgs/sagemath_coxeter3/install-requires.txt index a8c94946f02..b83f60f73f9 100644 --- a/build/pkgs/sagemath_coxeter3/install-requires.txt +++ b/build/pkgs/sagemath_coxeter3/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-coxeter3 ~= 10.2b1 +sagemath-coxeter3 ~= 10.2b2 diff --git a/build/pkgs/sagemath_environment/dependencies b/build/pkgs/sagemath_environment/dependencies index 605611e7a21..0f36ec317e6 100644 --- a/build/pkgs/sagemath_environment/dependencies +++ b/build/pkgs/sagemath_environment/dependencies @@ -1 +1 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) python_build + | $(PYTHON_TOOLCHAIN) python_build $(PYTHON) diff --git a/build/pkgs/sagemath_environment/install-requires.txt b/build/pkgs/sagemath_environment/install-requires.txt index b4cd1a51029..8ff3d48b4e8 100644 --- a/build/pkgs/sagemath_environment/install-requires.txt +++ b/build/pkgs/sagemath_environment/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-environment ~= 10.2b1 +sagemath-environment ~= 10.2b2 diff --git a/build/pkgs/sagemath_mcqd/dependencies b/build/pkgs/sagemath_mcqd/dependencies index e383df7dafa..9896fdaccfc 100644 --- a/build/pkgs/sagemath_mcqd/dependencies +++ b/build/pkgs/sagemath_mcqd/dependencies @@ -1 +1 @@ -$(PYTHON) mcqd memory_allocator cysignals | $(PYTHON_TOOLCHAIN) sage_setup cython pkgconfig + mcqd memory_allocator cysignals | $(PYTHON_TOOLCHAIN) sage_setup cython pkgconfig $(PYTHON) diff --git a/build/pkgs/sagemath_mcqd/install-requires.txt b/build/pkgs/sagemath_mcqd/install-requires.txt index 126c44af66e..04b2463b7c2 100644 --- a/build/pkgs/sagemath_mcqd/install-requires.txt +++ b/build/pkgs/sagemath_mcqd/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-mcqd ~= 10.2b1 +sagemath-mcqd ~= 10.2b2 diff --git a/build/pkgs/sagemath_meataxe/dependencies b/build/pkgs/sagemath_meataxe/dependencies index f100932802a..c333fcc61db 100644 --- a/build/pkgs/sagemath_meataxe/dependencies +++ b/build/pkgs/sagemath_meataxe/dependencies @@ -1 +1 @@ -$(PYTHON) meataxe | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig + meataxe | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig $(PYTHON) diff --git a/build/pkgs/sagemath_meataxe/install-requires.txt b/build/pkgs/sagemath_meataxe/install-requires.txt index 2bb80c9af82..124bbb008a7 100644 --- a/build/pkgs/sagemath_meataxe/install-requires.txt +++ b/build/pkgs/sagemath_meataxe/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-meataxe ~= 10.2b1 +sagemath-meataxe ~= 10.2b2 diff --git a/build/pkgs/sagemath_objects/dependencies b/build/pkgs/sagemath_objects/dependencies index 807b8b17215..ffc14bb6ba6 100644 --- a/build/pkgs/sagemath_objects/dependencies +++ b/build/pkgs/sagemath_objects/dependencies @@ -1,3 +1,3 @@ -FORCE $(PYTHON) cysignals gmpy2 | $(PYTHON_TOOLCHAIN) sagemath_environment sage_setup cython pkgconfig python_build +FORCE cysignals gmpy2 | $(PYTHON_TOOLCHAIN) sagemath_environment sage_setup cython pkgconfig python_build $(PYTHON) # FORCE: Always run the spkg-install script diff --git a/build/pkgs/sagemath_objects/install-requires.txt b/build/pkgs/sagemath_objects/install-requires.txt index 5f66e9fdf39..c99a73ae10a 100644 --- a/build/pkgs/sagemath_objects/install-requires.txt +++ b/build/pkgs/sagemath_objects/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-objects ~= 10.2b1 +sagemath-objects ~= 10.2b2 diff --git a/build/pkgs/sagemath_repl/dependencies b/build/pkgs/sagemath_repl/dependencies index ebc253dac5b..7d7ba20c5dd 100644 --- a/build/pkgs/sagemath_repl/dependencies +++ b/build/pkgs/sagemath_repl/dependencies @@ -1 +1 @@ -$(PYTHON) sagemath_objects sagemath_environment ipython ipywidgets | $(PYTHON_TOOLCHAIN) python_build + sagemath_objects sagemath_environment ipython ipywidgets | $(PYTHON_TOOLCHAIN) python_build $(PYTHON) diff --git a/build/pkgs/sagemath_repl/install-requires.txt b/build/pkgs/sagemath_repl/install-requires.txt index a84a407a137..92d2e7260fc 100644 --- a/build/pkgs/sagemath_repl/install-requires.txt +++ b/build/pkgs/sagemath_repl/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-repl ~= 10.2b1 +sagemath-repl ~= 10.2b2 diff --git a/build/pkgs/sagemath_sirocco/dependencies b/build/pkgs/sagemath_sirocco/dependencies index b923f34d7eb..4f47049ec4b 100644 --- a/build/pkgs/sagemath_sirocco/dependencies +++ b/build/pkgs/sagemath_sirocco/dependencies @@ -1 +1 @@ -$(PYTHON) sirocco cypari cysignals mpfr | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig + sirocco cypari cysignals mpfr | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig $(PYTHON) diff --git a/build/pkgs/sagemath_sirocco/install-requires.txt b/build/pkgs/sagemath_sirocco/install-requires.txt index 2a4dc502cd2..8ced9ae5f03 100644 --- a/build/pkgs/sagemath_sirocco/install-requires.txt +++ b/build/pkgs/sagemath_sirocco/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-sirocco ~= 10.2b1 +sagemath-sirocco ~= 10.2b2 diff --git a/build/pkgs/sagemath_tdlib/dependencies b/build/pkgs/sagemath_tdlib/dependencies index 5c7ecd31f2f..b22ab6c52a7 100644 --- a/build/pkgs/sagemath_tdlib/dependencies +++ b/build/pkgs/sagemath_tdlib/dependencies @@ -1 +1 @@ -$(PYTHON) tdlib cysignals | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig + tdlib cysignals | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig $(PYTHON) diff --git a/build/pkgs/sagemath_tdlib/install-requires.txt b/build/pkgs/sagemath_tdlib/install-requires.txt index e76350bceef..192e1609862 100644 --- a/build/pkgs/sagemath_tdlib/install-requires.txt +++ b/build/pkgs/sagemath_tdlib/install-requires.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-tdlib ~= 10.2b1 +sagemath-tdlib ~= 10.2b2 diff --git a/build/pkgs/sagenb_export/dependencies b/build/pkgs/sagenb_export/dependencies index 26033350f88..f9a2f2adbb9 100644 --- a/build/pkgs/sagenb_export/dependencies +++ b/build/pkgs/sagenb_export/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) notebook nbconvert ipython six | $(PYTHON_TOOLCHAIN) + notebook nbconvert ipython six | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sagetex/dependencies b/build/pkgs/sagetex/dependencies index 6090d5dc3ac..af9b5f370fb 100644 --- a/build/pkgs/sagetex/dependencies +++ b/build/pkgs/sagetex/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) maxima scipy matplotlib pillow tachyon pyparsing + maxima scipy matplotlib pillow tachyon pyparsing | $(PYTHON) To build SageTeX, you just need Python and pyparsing, but to test (SAGE_CHECK=yes) SageTeX, you actually need to run Sage, produce plots,... diff --git a/build/pkgs/scipy/checksums.ini b/build/pkgs/scipy/checksums.ini index e56c56745e3..7015206d1e7 100644 --- a/build/pkgs/scipy/checksums.ini +++ b/build/pkgs/scipy/checksums.ini @@ -1,5 +1,5 @@ tarball=scipy-VERSION.tar.gz -sha1=ff83163396a70276c0441b541befc485b471b27b -md5=de3db61d840456634ba37f2b5816e049 -cksum=3826133895 +sha1=856f8ac8498751b72d678ef64b88e436d04a957d +md5=27baf613b6cf3f9600a05161f132151c +cksum=1656738318 upstream_url=https://pypi.io/packages/source/s/scipy/scipy-VERSION.tar.gz diff --git a/build/pkgs/scipy/dependencies b/build/pkgs/scipy/dependencies index 5d42789eb10..82fa8e0c0d7 100644 --- a/build/pkgs/scipy/dependencies +++ b/build/pkgs/scipy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) $(BLAS) gfortran numpy pybind11 cython pythran | $(PYTHON_TOOLCHAIN) meson_python + $(BLAS) gfortran numpy pybind11 cython pythran | $(PYTHON_TOOLCHAIN) meson_python $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/scipy/distros/arch.txt b/build/pkgs/scipy/distros/arch.txt new file mode 100644 index 00000000000..7ff2882c1bf --- /dev/null +++ b/build/pkgs/scipy/distros/arch.txt @@ -0,0 +1 @@ +python-scipy diff --git a/build/pkgs/scipy/distros/debian.txt b/build/pkgs/scipy/distros/debian.txt new file mode 100644 index 00000000000..12b366666d6 --- /dev/null +++ b/build/pkgs/scipy/distros/debian.txt @@ -0,0 +1 @@ +python3-scipy diff --git a/build/pkgs/scipy/distros/fedora.txt b/build/pkgs/scipy/distros/fedora.txt new file mode 100644 index 00000000000..7ff2882c1bf --- /dev/null +++ b/build/pkgs/scipy/distros/fedora.txt @@ -0,0 +1 @@ +python-scipy diff --git a/build/pkgs/scipy/distros/gentoo.txt b/build/pkgs/scipy/distros/gentoo.txt new file mode 100644 index 00000000000..11dabd2830f --- /dev/null +++ b/build/pkgs/scipy/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/scipy diff --git a/build/pkgs/scipy/distros/opensuse.txt b/build/pkgs/scipy/distros/opensuse.txt index 12b366666d6..d2bc2a30a85 100644 --- a/build/pkgs/scipy/distros/opensuse.txt +++ b/build/pkgs/scipy/distros/opensuse.txt @@ -1 +1 @@ -python3-scipy +python3${PYTHON_MINOR}-scipy diff --git a/build/pkgs/scipy/install-requires.txt b/build/pkgs/scipy/install-requires.txt index 16d57fdb9b0..dd975a870e3 100644 --- a/build/pkgs/scipy/install-requires.txt +++ b/build/pkgs/scipy/install-requires.txt @@ -4,4 +4,4 @@ # deprecations cannot be introduced in micro releases. # SciPy devs wait "at least 6 months", "in practice two (minor) releases" # from deprecation to removal of a feature. -scipy >=1.5, <1.11 +scipy >=1.5, <1.12 diff --git a/build/pkgs/scipy/package-version.txt b/build/pkgs/scipy/package-version.txt index 4dae2985b58..ca7176690dd 100644 --- a/build/pkgs/scipy/package-version.txt +++ b/build/pkgs/scipy/package-version.txt @@ -1 +1 @@ -1.10.1 +1.11.2 diff --git a/build/pkgs/scipy/spkg-configure.m4 b/build/pkgs/scipy/spkg-configure.m4 new file mode 100644 index 00000000000..0b7294a02e8 --- /dev/null +++ b/build/pkgs/scipy/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([scipy], [ + SAGE_SPKG_DEPCHECK([openblas], [ + SAGE_PYTHON_PACKAGE_CHECK([scipy]) + ]) +]) diff --git a/build/pkgs/scs/dependencies b/build/pkgs/scs/dependencies index 56c3c7a111c..a736df74ec5 100644 --- a/build/pkgs/scs/dependencies +++ b/build/pkgs/scs/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) numpy | $(PYTHON_TOOLCHAIN) cmake + numpy | $(PYTHON_TOOLCHAIN) cmake $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/send2trash/dependencies b/build/pkgs/send2trash/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/send2trash/dependencies +++ b/build/pkgs/send2trash/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/send2trash/distros/gentoo.txt b/build/pkgs/send2trash/distros/gentoo.txt new file mode 100644 index 00000000000..a89b1798476 --- /dev/null +++ b/build/pkgs/send2trash/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/send2trash diff --git a/build/pkgs/send2trash/distros/opensuse.txt b/build/pkgs/send2trash/distros/opensuse.txt index 404e2bd3580..8d3c81fa23c 100644 --- a/build/pkgs/send2trash/distros/opensuse.txt +++ b/build/pkgs/send2trash/distros/opensuse.txt @@ -1 +1 @@ -python3-Send2Trash +python3${PYTHON_MINOR}-Send2Trash diff --git a/build/pkgs/send2trash/spkg-configure.m4 b/build/pkgs/send2trash/spkg-configure.m4 new file mode 100644 index 00000000000..3bbb727e430 --- /dev/null +++ b/build/pkgs/send2trash/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([send2trash], [SAGE_PYTHON_PACKAGE_CHECK([send2trash])]) diff --git a/build/pkgs/setuptools/dependencies b/build/pkgs/setuptools/dependencies index 1700e743d59..d45a397db36 100644 --- a/build/pkgs/setuptools/dependencies +++ b/build/pkgs/setuptools/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) + | $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/setuptools/distros/arch.txt b/build/pkgs/setuptools/distros/arch.txt new file mode 100644 index 00000000000..e1ad17860cd --- /dev/null +++ b/build/pkgs/setuptools/distros/arch.txt @@ -0,0 +1 @@ +python-setuptools diff --git a/build/pkgs/setuptools/distros/debian.txt b/build/pkgs/setuptools/distros/debian.txt new file mode 100644 index 00000000000..1c0901c0374 --- /dev/null +++ b/build/pkgs/setuptools/distros/debian.txt @@ -0,0 +1 @@ +python3-setuptools diff --git a/build/pkgs/setuptools/distros/fedora.txt b/build/pkgs/setuptools/distros/fedora.txt new file mode 100644 index 00000000000..e1ad17860cd --- /dev/null +++ b/build/pkgs/setuptools/distros/fedora.txt @@ -0,0 +1 @@ +python-setuptools diff --git a/build/pkgs/setuptools/distros/gentoo.txt b/build/pkgs/setuptools/distros/gentoo.txt new file mode 100644 index 00000000000..3a4fa34a57f --- /dev/null +++ b/build/pkgs/setuptools/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/setuptools diff --git a/build/pkgs/setuptools/distros/opensuse.txt b/build/pkgs/setuptools/distros/opensuse.txt index 1c0901c0374..b2d8de78f80 100644 --- a/build/pkgs/setuptools/distros/opensuse.txt +++ b/build/pkgs/setuptools/distros/opensuse.txt @@ -1 +1 @@ -python3-setuptools +python3${PYTHON_MINOR}-setuptools diff --git a/build/pkgs/setuptools/install-requires.txt b/build/pkgs/setuptools/install-requires.txt index 0810ca37277..e0cf7c9b5dc 100644 --- a/build/pkgs/setuptools/install-requires.txt +++ b/build/pkgs/setuptools/install-requires.txt @@ -1 +1 @@ -setuptools >=49.6.0 +setuptools >=49.6.0, <64 diff --git a/build/pkgs/setuptools/spkg-configure.m4 b/build/pkgs/setuptools/spkg-configure.m4 new file mode 100644 index 00000000000..a2ad8119063 --- /dev/null +++ b/build/pkgs/setuptools/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([setuptools], [SAGE_PYTHON_PACKAGE_CHECK([setuptools])]) diff --git a/build/pkgs/setuptools_scm/dependencies b/build/pkgs/setuptools_scm/dependencies index f3662a5c829..7dd3b6e8f6e 100644 --- a/build/pkgs/setuptools_scm/dependencies +++ b/build/pkgs/setuptools_scm/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) typing_extensions | setuptools pip wheel tomli packaging + typing_extensions | setuptools pip wheel tomli packaging $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/setuptools_scm/distros/arch.txt b/build/pkgs/setuptools_scm/distros/arch.txt new file mode 100644 index 00000000000..2b97444decf --- /dev/null +++ b/build/pkgs/setuptools_scm/distros/arch.txt @@ -0,0 +1 @@ +python-setuptools-scm diff --git a/build/pkgs/setuptools_scm/distros/debian.txt b/build/pkgs/setuptools_scm/distros/debian.txt new file mode 100644 index 00000000000..bcfdd6ebcdd --- /dev/null +++ b/build/pkgs/setuptools_scm/distros/debian.txt @@ -0,0 +1 @@ +setuptools-scm diff --git a/build/pkgs/setuptools_scm/distros/fedora.txt b/build/pkgs/setuptools_scm/distros/fedora.txt new file mode 100644 index 00000000000..720fd2897be --- /dev/null +++ b/build/pkgs/setuptools_scm/distros/fedora.txt @@ -0,0 +1 @@ +python-setuptools_scm diff --git a/build/pkgs/setuptools_scm/distros/freebsd.txt b/build/pkgs/setuptools_scm/distros/freebsd.txt new file mode 100644 index 00000000000..ba714681e0a --- /dev/null +++ b/build/pkgs/setuptools_scm/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-setuptools_scm diff --git a/build/pkgs/setuptools_scm/distros/gentoo.txt b/build/pkgs/setuptools_scm/distros/gentoo.txt new file mode 100644 index 00000000000..46efc2bdeb4 --- /dev/null +++ b/build/pkgs/setuptools_scm/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/setuptools-scm diff --git a/build/pkgs/setuptools_scm/distros/opensuse.txt b/build/pkgs/setuptools_scm/distros/opensuse.txt index 2aa5ca12cba..cacb303c566 100644 --- a/build/pkgs/setuptools_scm/distros/opensuse.txt +++ b/build/pkgs/setuptools_scm/distros/opensuse.txt @@ -1 +1 @@ -python3-setuptools_scm +python3${PYTHON_MINOR}-setuptools_scm diff --git a/build/pkgs/setuptools_scm/install-requires.txt b/build/pkgs/setuptools_scm/install-requires.txt index ee00ef62d52..34188327a0f 100644 --- a/build/pkgs/setuptools_scm/install-requires.txt +++ b/build/pkgs/setuptools_scm/install-requires.txt @@ -1 +1,2 @@ -setuptools_scm >=4.1.2 +# matplotlib-3.6.2 needs >= 7 +setuptools_scm >=7 diff --git a/build/pkgs/setuptools_scm/spkg-configure.m4 b/build/pkgs/setuptools_scm/spkg-configure.m4 new file mode 100644 index 00000000000..437148c2a8f --- /dev/null +++ b/build/pkgs/setuptools_scm/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([setuptools_scm], [ + SAGE_PYTHON_PACKAGE_CHECK([setuptools_scm]) +]) diff --git a/build/pkgs/setuptools_scm_git_archive/dependencies b/build/pkgs/setuptools_scm_git_archive/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/setuptools_scm_git_archive/dependencies +++ b/build/pkgs/setuptools_scm_git_archive/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/setuptools_wheel/dependencies b/build/pkgs/setuptools_wheel/dependencies index 618d627629a..dac3579f7e3 100644 --- a/build/pkgs/setuptools_wheel/dependencies +++ b/build/pkgs/setuptools_wheel/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) setuptools wheel + setuptools wheel | $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/simplegeneric/dependencies b/build/pkgs/simplegeneric/dependencies index 703d0ec7ba3..1169eb4105f 100644 --- a/build/pkgs/simplegeneric/dependencies +++ b/build/pkgs/simplegeneric/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) # simplegeneric does not strictly require setuptools, but it does try # to use setuptools if it is available. However, there is a problem diff --git a/build/pkgs/simplegeneric/distros/gentoo.txt b/build/pkgs/simplegeneric/distros/gentoo.txt new file mode 100644 index 00000000000..a86e90d96ec --- /dev/null +++ b/build/pkgs/simplegeneric/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/simplegeneric diff --git a/build/pkgs/simplegeneric/distros/opensuse.txt b/build/pkgs/simplegeneric/distros/opensuse.txt index d788a7233a7..ddc1661a230 100644 --- a/build/pkgs/simplegeneric/distros/opensuse.txt +++ b/build/pkgs/simplegeneric/distros/opensuse.txt @@ -1 +1 @@ -python3-simplegeneric +python3${PYTHON_MINOR}-simplegeneric diff --git a/build/pkgs/simplegeneric/spkg-configure.m4 b/build/pkgs/simplegeneric/spkg-configure.m4 new file mode 100644 index 00000000000..13715ab5f2b --- /dev/null +++ b/build/pkgs/simplegeneric/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([simplegeneric], [SAGE_PYTHON_PACKAGE_CHECK([simplegeneric])]) diff --git a/build/pkgs/singular_jupyter/dependencies b/build/pkgs/singular_jupyter/dependencies index 14dc06f7076..dc15abb82c7 100644 --- a/build/pkgs/singular_jupyter/dependencies +++ b/build/pkgs/singular_jupyter/dependencies @@ -1 +1 @@ -$(PYTHON) jupyter_client | $(PYTHON_TOOLCHAIN) pysingular ipython ipywidgets + jupyter_client | $(PYTHON_TOOLCHAIN) pysingular ipython ipywidgets $(PYTHON) diff --git a/build/pkgs/six/dependencies b/build/pkgs/six/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/six/dependencies +++ b/build/pkgs/six/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/six/distros/arch.txt b/build/pkgs/six/distros/arch.txt new file mode 100644 index 00000000000..787c5308ea4 --- /dev/null +++ b/build/pkgs/six/distros/arch.txt @@ -0,0 +1 @@ +python-six diff --git a/build/pkgs/six/distros/debian.txt b/build/pkgs/six/distros/debian.txt new file mode 100644 index 00000000000..68ff8595d0b --- /dev/null +++ b/build/pkgs/six/distros/debian.txt @@ -0,0 +1 @@ +python3-six diff --git a/build/pkgs/six/distros/fedora.txt b/build/pkgs/six/distros/fedora.txt new file mode 100644 index 00000000000..787c5308ea4 --- /dev/null +++ b/build/pkgs/six/distros/fedora.txt @@ -0,0 +1 @@ +python-six diff --git a/build/pkgs/six/distros/gentoo.txt b/build/pkgs/six/distros/gentoo.txt new file mode 100644 index 00000000000..f73f648ff75 --- /dev/null +++ b/build/pkgs/six/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/six diff --git a/build/pkgs/six/distros/opensuse.txt b/build/pkgs/six/distros/opensuse.txt index 68ff8595d0b..127cfc6a26a 100644 --- a/build/pkgs/six/distros/opensuse.txt +++ b/build/pkgs/six/distros/opensuse.txt @@ -1 +1 @@ -python3-six +python3${PYTHON_MINOR}-six diff --git a/build/pkgs/six/spkg-configure.m4 b/build/pkgs/six/spkg-configure.m4 new file mode 100644 index 00000000000..a382b81a3dd --- /dev/null +++ b/build/pkgs/six/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([six], [SAGE_PYTHON_PACKAGE_CHECK([six])]) diff --git a/build/pkgs/slabbe/dependencies b/build/pkgs/slabbe/dependencies index 05ba0d8954b..126e8ceee06 100644 --- a/build/pkgs/slabbe/dependencies +++ b/build/pkgs/slabbe/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) $(SAGERUNTIME) + | $(PYTHON_TOOLCHAIN) $(SAGERUNTIME) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/snappy/dependencies b/build/pkgs/snappy/dependencies index db96ccc42e0..ceaf757887e 100644 --- a/build/pkgs/snappy/dependencies +++ b/build/pkgs/snappy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) decorator ipython cypari | $(PYTHON_TOOLCHAIN) sagelib + decorator ipython cypari | $(PYTHON_TOOLCHAIN) sagelib $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/snowballstemmer/dependencies b/build/pkgs/snowballstemmer/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/snowballstemmer/dependencies +++ b/build/pkgs/snowballstemmer/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/snowballstemmer/distros/gentoo.txt b/build/pkgs/snowballstemmer/distros/gentoo.txt new file mode 100644 index 00000000000..63fd8513221 --- /dev/null +++ b/build/pkgs/snowballstemmer/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/snowballstemmer diff --git a/build/pkgs/snowballstemmer/distros/opensuse.txt b/build/pkgs/snowballstemmer/distros/opensuse.txt index 09b2636df60..a21cc876a24 100644 --- a/build/pkgs/snowballstemmer/distros/opensuse.txt +++ b/build/pkgs/snowballstemmer/distros/opensuse.txt @@ -1 +1 @@ -python3-snowballstemmer +python3${PYTHON_MINOR}-snowballstemmer diff --git a/build/pkgs/snowballstemmer/spkg-configure.m4 b/build/pkgs/snowballstemmer/spkg-configure.m4 new file mode 100644 index 00000000000..6aa08825d39 --- /dev/null +++ b/build/pkgs/snowballstemmer/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([snowballstemmer], [ + SAGE_PYTHON_PACKAGE_CHECK([snowballstemmer]) +]) diff --git a/build/pkgs/soupsieve/dependencies b/build/pkgs/soupsieve/dependencies index 8cd44d06682..cfb7c484697 100644 --- a/build/pkgs/soupsieve/dependencies +++ b/build/pkgs/soupsieve/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) hatchling + | $(PYTHON_TOOLCHAIN) hatchling $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinx/dependencies b/build/pkgs/sphinx/dependencies index 75c668d9c23..9b7505c9aec 100644 --- a/build/pkgs/sphinx/dependencies +++ b/build/pkgs/sphinx/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) docutils jinja2 pygments snowballstemmer imagesize babel alabaster requests sphinxcontrib_websupport sphinxcontrib_applehelp sphinxcontrib_devhelp sphinxcontrib_htmlhelp sphinxcontrib_jsmath sphinxcontrib_qthelp sphinxcontrib_serializinghtml packaging importlib_metadata + | $(PYTHON_TOOLCHAIN) docutils jinja2 pygments snowballstemmer imagesize babel alabaster requests sphinxcontrib_websupport sphinxcontrib_applehelp sphinxcontrib_devhelp sphinxcontrib_htmlhelp sphinxcontrib_jsmath sphinxcontrib_qthelp sphinxcontrib_serializinghtml packaging importlib_metadata $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinx/distros/arch.txt b/build/pkgs/sphinx/distros/arch.txt new file mode 100644 index 00000000000..db9f745da4c --- /dev/null +++ b/build/pkgs/sphinx/distros/arch.txt @@ -0,0 +1 @@ +python-sphinx diff --git a/build/pkgs/sphinx/distros/debian.txt b/build/pkgs/sphinx/distros/debian.txt new file mode 100644 index 00000000000..6966869c705 --- /dev/null +++ b/build/pkgs/sphinx/distros/debian.txt @@ -0,0 +1 @@ +sphinx diff --git a/build/pkgs/sphinx/distros/fedora.txt b/build/pkgs/sphinx/distros/fedora.txt new file mode 100644 index 00000000000..db9f745da4c --- /dev/null +++ b/build/pkgs/sphinx/distros/fedora.txt @@ -0,0 +1 @@ +python-sphinx diff --git a/build/pkgs/sphinx/distros/freebsd.txt b/build/pkgs/sphinx/distros/freebsd.txt new file mode 100644 index 00000000000..f7f30dba25f --- /dev/null +++ b/build/pkgs/sphinx/distros/freebsd.txt @@ -0,0 +1 @@ +textproc/py-sphinx diff --git a/build/pkgs/sphinx/distros/opensuse.txt b/build/pkgs/sphinx/distros/opensuse.txt index bc54d0bd553..0aa0566b066 100644 --- a/build/pkgs/sphinx/distros/opensuse.txt +++ b/build/pkgs/sphinx/distros/opensuse.txt @@ -1 +1 @@ -python3-Sphinx +python3${PYTHON_MINOR}-Sphinx diff --git a/build/pkgs/sphinx_basic_ng/dependencies b/build/pkgs/sphinx_basic_ng/dependencies index 175a793ecbc..ac849c62bf6 100644 --- a/build/pkgs/sphinx_basic_ng/dependencies +++ b/build/pkgs/sphinx_basic_ng/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) sphinx | $(PYTHON_TOOLCHAIN) + sphinx | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinx_copybutton/dependencies b/build/pkgs/sphinx_copybutton/dependencies index 175a793ecbc..ac849c62bf6 100644 --- a/build/pkgs/sphinx_copybutton/dependencies +++ b/build/pkgs/sphinx_copybutton/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) sphinx | $(PYTHON_TOOLCHAIN) + sphinx | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinxcontrib_applehelp/dependencies b/build/pkgs/sphinxcontrib_applehelp/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/sphinxcontrib_applehelp/dependencies +++ b/build/pkgs/sphinxcontrib_applehelp/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinxcontrib_applehelp/distros/arch.txt b/build/pkgs/sphinxcontrib_applehelp/distros/arch.txt new file mode 100644 index 00000000000..3754baa21f5 --- /dev/null +++ b/build/pkgs/sphinxcontrib_applehelp/distros/arch.txt @@ -0,0 +1 @@ +python-sphinxcontrib-applehelp diff --git a/build/pkgs/sphinxcontrib_applehelp/distros/fedora.txt b/build/pkgs/sphinxcontrib_applehelp/distros/fedora.txt new file mode 100644 index 00000000000..3754baa21f5 --- /dev/null +++ b/build/pkgs/sphinxcontrib_applehelp/distros/fedora.txt @@ -0,0 +1 @@ +python-sphinxcontrib-applehelp diff --git a/build/pkgs/sphinxcontrib_applehelp/distros/freebsd.txt b/build/pkgs/sphinxcontrib_applehelp/distros/freebsd.txt new file mode 100644 index 00000000000..73fbc3bf7ad --- /dev/null +++ b/build/pkgs/sphinxcontrib_applehelp/distros/freebsd.txt @@ -0,0 +1 @@ +textproc/py-sphinxcontrib-applehelp diff --git a/build/pkgs/sphinxcontrib_applehelp/distros/gentoo.txt b/build/pkgs/sphinxcontrib_applehelp/distros/gentoo.txt new file mode 100644 index 00000000000..66ac8da7340 --- /dev/null +++ b/build/pkgs/sphinxcontrib_applehelp/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/sphinxcontrib-applehelp diff --git a/build/pkgs/sphinxcontrib_applehelp/distros/opensuse.txt b/build/pkgs/sphinxcontrib_applehelp/distros/opensuse.txt index adedbd455f8..9d71e79f307 100644 --- a/build/pkgs/sphinxcontrib_applehelp/distros/opensuse.txt +++ b/build/pkgs/sphinxcontrib_applehelp/distros/opensuse.txt @@ -1 +1 @@ -python3-sphinxcontrib-applehelp +python3${PYTHON_MINOR}-sphinxcontrib-applehelp diff --git a/build/pkgs/sphinxcontrib_applehelp/spkg-configure.m4 b/build/pkgs/sphinxcontrib_applehelp/spkg-configure.m4 new file mode 100644 index 00000000000..e834aed8fd8 --- /dev/null +++ b/build/pkgs/sphinxcontrib_applehelp/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([sphinxcontrib_applehelp], [ + SAGE_PYTHON_PACKAGE_CHECK([sphinxcontrib_applehelp]) +]) diff --git a/build/pkgs/sphinxcontrib_devhelp/dependencies b/build/pkgs/sphinxcontrib_devhelp/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/sphinxcontrib_devhelp/dependencies +++ b/build/pkgs/sphinxcontrib_devhelp/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinxcontrib_devhelp/distros/arch.txt b/build/pkgs/sphinxcontrib_devhelp/distros/arch.txt new file mode 100644 index 00000000000..0b1b3e44a6b --- /dev/null +++ b/build/pkgs/sphinxcontrib_devhelp/distros/arch.txt @@ -0,0 +1 @@ +python-sphinxcontrib-devhelp diff --git a/build/pkgs/sphinxcontrib_devhelp/distros/fedora.txt b/build/pkgs/sphinxcontrib_devhelp/distros/fedora.txt new file mode 100644 index 00000000000..0b1b3e44a6b --- /dev/null +++ b/build/pkgs/sphinxcontrib_devhelp/distros/fedora.txt @@ -0,0 +1 @@ +python-sphinxcontrib-devhelp diff --git a/build/pkgs/sphinxcontrib_devhelp/distros/freebsd.txt b/build/pkgs/sphinxcontrib_devhelp/distros/freebsd.txt new file mode 100644 index 00000000000..86982bcbd27 --- /dev/null +++ b/build/pkgs/sphinxcontrib_devhelp/distros/freebsd.txt @@ -0,0 +1 @@ +textproc/py-sphinxcontrib-devhelp diff --git a/build/pkgs/sphinxcontrib_devhelp/distros/gentoo.txt b/build/pkgs/sphinxcontrib_devhelp/distros/gentoo.txt new file mode 100644 index 00000000000..9b5c899a706 --- /dev/null +++ b/build/pkgs/sphinxcontrib_devhelp/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/sphinxcontrib-devhelp diff --git a/build/pkgs/sphinxcontrib_devhelp/distros/opensuse.txt b/build/pkgs/sphinxcontrib_devhelp/distros/opensuse.txt new file mode 100644 index 00000000000..95012c2425d --- /dev/null +++ b/build/pkgs/sphinxcontrib_devhelp/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-sphinxcontrib-devhelp diff --git a/build/pkgs/sphinxcontrib_devhelp/spkg-configure.m4 b/build/pkgs/sphinxcontrib_devhelp/spkg-configure.m4 new file mode 100644 index 00000000000..8728136e92e --- /dev/null +++ b/build/pkgs/sphinxcontrib_devhelp/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([sphinxcontrib_devhelp], [ + SAGE_PYTHON_PACKAGE_CHECK([sphinxcontrib_devhelp]) +]) diff --git a/build/pkgs/sphinxcontrib_htmlhelp/dependencies b/build/pkgs/sphinxcontrib_htmlhelp/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/sphinxcontrib_htmlhelp/dependencies +++ b/build/pkgs/sphinxcontrib_htmlhelp/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinxcontrib_htmlhelp/distros/arch.txt b/build/pkgs/sphinxcontrib_htmlhelp/distros/arch.txt new file mode 100644 index 00000000000..81390fd522f --- /dev/null +++ b/build/pkgs/sphinxcontrib_htmlhelp/distros/arch.txt @@ -0,0 +1 @@ +python-sphinxcontrib-htmlhelp diff --git a/build/pkgs/sphinxcontrib_htmlhelp/distros/fedora.txt b/build/pkgs/sphinxcontrib_htmlhelp/distros/fedora.txt new file mode 100644 index 00000000000..81390fd522f --- /dev/null +++ b/build/pkgs/sphinxcontrib_htmlhelp/distros/fedora.txt @@ -0,0 +1 @@ +python-sphinxcontrib-htmlhelp diff --git a/build/pkgs/sphinxcontrib_htmlhelp/distros/freebsd.txt b/build/pkgs/sphinxcontrib_htmlhelp/distros/freebsd.txt new file mode 100644 index 00000000000..9b97c55996b --- /dev/null +++ b/build/pkgs/sphinxcontrib_htmlhelp/distros/freebsd.txt @@ -0,0 +1 @@ +textproc/py-sphinxcontrib-htmlhelp diff --git a/build/pkgs/sphinxcontrib_htmlhelp/distros/gentoo.txt b/build/pkgs/sphinxcontrib_htmlhelp/distros/gentoo.txt new file mode 100644 index 00000000000..e080bacf8ba --- /dev/null +++ b/build/pkgs/sphinxcontrib_htmlhelp/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/sphinxcontrib-htmlhelp diff --git a/build/pkgs/sphinxcontrib_htmlhelp/distros/opensuse.txt b/build/pkgs/sphinxcontrib_htmlhelp/distros/opensuse.txt new file mode 100644 index 00000000000..5859fe855bb --- /dev/null +++ b/build/pkgs/sphinxcontrib_htmlhelp/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-sphinxcontrib-htmlhelp diff --git a/build/pkgs/sphinxcontrib_htmlhelp/spkg-configure.m4 b/build/pkgs/sphinxcontrib_htmlhelp/spkg-configure.m4 new file mode 100644 index 00000000000..c77b003dc37 --- /dev/null +++ b/build/pkgs/sphinxcontrib_htmlhelp/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([sphinxcontrib_htmlhelp], [ + SAGE_PYTHON_PACKAGE_CHECK([sphinxcontrib_htmlhelp]) +]) diff --git a/build/pkgs/sphinxcontrib_jsmath/dependencies b/build/pkgs/sphinxcontrib_jsmath/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/sphinxcontrib_jsmath/dependencies +++ b/build/pkgs/sphinxcontrib_jsmath/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinxcontrib_jsmath/distros/arch.txt b/build/pkgs/sphinxcontrib_jsmath/distros/arch.txt new file mode 100644 index 00000000000..2b4927832ac --- /dev/null +++ b/build/pkgs/sphinxcontrib_jsmath/distros/arch.txt @@ -0,0 +1 @@ +python-sphinxcontrib-jsmath diff --git a/build/pkgs/sphinxcontrib_jsmath/distros/fedora.txt b/build/pkgs/sphinxcontrib_jsmath/distros/fedora.txt new file mode 100644 index 00000000000..2b4927832ac --- /dev/null +++ b/build/pkgs/sphinxcontrib_jsmath/distros/fedora.txt @@ -0,0 +1 @@ +python-sphinxcontrib-jsmath diff --git a/build/pkgs/sphinxcontrib_jsmath/distros/freebsd.txt b/build/pkgs/sphinxcontrib_jsmath/distros/freebsd.txt new file mode 100644 index 00000000000..78aa428cb13 --- /dev/null +++ b/build/pkgs/sphinxcontrib_jsmath/distros/freebsd.txt @@ -0,0 +1 @@ +textproc/py-sphinxcontrib-jsmath diff --git a/build/pkgs/sphinxcontrib_jsmath/distros/gentoo.txt b/build/pkgs/sphinxcontrib_jsmath/distros/gentoo.txt new file mode 100644 index 00000000000..041a4710e66 --- /dev/null +++ b/build/pkgs/sphinxcontrib_jsmath/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/sphinxcontrib-jsmath diff --git a/build/pkgs/sphinxcontrib_jsmath/distros/opensuse.txt b/build/pkgs/sphinxcontrib_jsmath/distros/opensuse.txt new file mode 100644 index 00000000000..dbe478264db --- /dev/null +++ b/build/pkgs/sphinxcontrib_jsmath/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-sphinxcontrib-jsmath diff --git a/build/pkgs/sphinxcontrib_jsmath/spkg-configure.m4 b/build/pkgs/sphinxcontrib_jsmath/spkg-configure.m4 new file mode 100644 index 00000000000..e46bde2bd9d --- /dev/null +++ b/build/pkgs/sphinxcontrib_jsmath/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([sphinxcontrib_jsmath], [ + SAGE_PYTHON_PACKAGE_CHECK([sphinxcontrib_jsmath]) +]) diff --git a/build/pkgs/sphinxcontrib_qthelp/dependencies b/build/pkgs/sphinxcontrib_qthelp/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/sphinxcontrib_qthelp/dependencies +++ b/build/pkgs/sphinxcontrib_qthelp/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinxcontrib_qthelp/distros/arch.txt b/build/pkgs/sphinxcontrib_qthelp/distros/arch.txt new file mode 100644 index 00000000000..2c11924a5df --- /dev/null +++ b/build/pkgs/sphinxcontrib_qthelp/distros/arch.txt @@ -0,0 +1 @@ +python-sphinxcontrib-qthelp diff --git a/build/pkgs/sphinxcontrib_qthelp/distros/fedora.txt b/build/pkgs/sphinxcontrib_qthelp/distros/fedora.txt new file mode 100644 index 00000000000..2c11924a5df --- /dev/null +++ b/build/pkgs/sphinxcontrib_qthelp/distros/fedora.txt @@ -0,0 +1 @@ +python-sphinxcontrib-qthelp diff --git a/build/pkgs/sphinxcontrib_qthelp/distros/freebsd.txt b/build/pkgs/sphinxcontrib_qthelp/distros/freebsd.txt new file mode 100644 index 00000000000..77ff8756694 --- /dev/null +++ b/build/pkgs/sphinxcontrib_qthelp/distros/freebsd.txt @@ -0,0 +1 @@ +textproc/py-sphinxcontrib-qthelp diff --git a/build/pkgs/sphinxcontrib_qthelp/distros/gentoo.txt b/build/pkgs/sphinxcontrib_qthelp/distros/gentoo.txt new file mode 100644 index 00000000000..7210099b087 --- /dev/null +++ b/build/pkgs/sphinxcontrib_qthelp/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/sphinxcontrib-qthelp diff --git a/build/pkgs/sphinxcontrib_qthelp/distros/opensuse.txt b/build/pkgs/sphinxcontrib_qthelp/distros/opensuse.txt new file mode 100644 index 00000000000..9462502bae5 --- /dev/null +++ b/build/pkgs/sphinxcontrib_qthelp/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-sphinxcontrib-qthelp diff --git a/build/pkgs/sphinxcontrib_qthelp/spkg-configure.m4 b/build/pkgs/sphinxcontrib_qthelp/spkg-configure.m4 new file mode 100644 index 00000000000..81ea5e1269f --- /dev/null +++ b/build/pkgs/sphinxcontrib_qthelp/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([sphinxcontrib_qthelp], [ + SAGE_PYTHON_PACKAGE_CHECK([sphinxcontrib_qthelp]) +]) diff --git a/build/pkgs/sphinxcontrib_serializinghtml/dependencies b/build/pkgs/sphinxcontrib_serializinghtml/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/sphinxcontrib_serializinghtml/dependencies +++ b/build/pkgs/sphinxcontrib_serializinghtml/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinxcontrib_serializinghtml/distros/arch.txt b/build/pkgs/sphinxcontrib_serializinghtml/distros/arch.txt new file mode 100644 index 00000000000..46d22be403f --- /dev/null +++ b/build/pkgs/sphinxcontrib_serializinghtml/distros/arch.txt @@ -0,0 +1 @@ +python-sphinxcontrib-serializinghtml diff --git a/build/pkgs/sphinxcontrib_serializinghtml/distros/fedora.txt b/build/pkgs/sphinxcontrib_serializinghtml/distros/fedora.txt new file mode 100644 index 00000000000..46d22be403f --- /dev/null +++ b/build/pkgs/sphinxcontrib_serializinghtml/distros/fedora.txt @@ -0,0 +1 @@ +python-sphinxcontrib-serializinghtml diff --git a/build/pkgs/sphinxcontrib_serializinghtml/distros/freebsd.txt b/build/pkgs/sphinxcontrib_serializinghtml/distros/freebsd.txt new file mode 100644 index 00000000000..de7f59bad6e --- /dev/null +++ b/build/pkgs/sphinxcontrib_serializinghtml/distros/freebsd.txt @@ -0,0 +1 @@ +textproc/py-sphinxcontrib-serializinghtml diff --git a/build/pkgs/sphinxcontrib_serializinghtml/distros/gentoo.txt b/build/pkgs/sphinxcontrib_serializinghtml/distros/gentoo.txt new file mode 100644 index 00000000000..38bca8f1dcb --- /dev/null +++ b/build/pkgs/sphinxcontrib_serializinghtml/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/sphinxcontrib-serializinghtml diff --git a/build/pkgs/sphinxcontrib_serializinghtml/distros/opensuse.txt b/build/pkgs/sphinxcontrib_serializinghtml/distros/opensuse.txt index 1a8ea8424a7..7a647e3e36a 100644 --- a/build/pkgs/sphinxcontrib_serializinghtml/distros/opensuse.txt +++ b/build/pkgs/sphinxcontrib_serializinghtml/distros/opensuse.txt @@ -1 +1 @@ -python3-sphinxcontrib-serializinghtml +python3${PYTHON_MINOR}-sphinxcontrib-serializinghtml diff --git a/build/pkgs/sphinxcontrib_serializinghtml/install-requires.txt b/build/pkgs/sphinxcontrib_serializinghtml/install-requires.txt index 98fc0654928..584fc77c6b2 100644 --- a/build/pkgs/sphinxcontrib_serializinghtml/install-requires.txt +++ b/build/pkgs/sphinxcontrib_serializinghtml/install-requires.txt @@ -1 +1 @@ -sphinxcontrib_serializinghtml >=1.1.4 +sphinxcontrib_serializinghtml >=1.1.5 diff --git a/build/pkgs/sphinxcontrib_serializinghtml/spkg-configure.m4 b/build/pkgs/sphinxcontrib_serializinghtml/spkg-configure.m4 new file mode 100644 index 00000000000..be8e62555ac --- /dev/null +++ b/build/pkgs/sphinxcontrib_serializinghtml/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([sphinxcontrib_serializinghtml], [ + SAGE_PYTHON_PACKAGE_CHECK([sphinxcontrib_serializinghtml]) +]) diff --git a/build/pkgs/sphinxcontrib_websupport/dependencies b/build/pkgs/sphinxcontrib_websupport/dependencies index dabbd0f750d..52be4a5ba53 100644 --- a/build/pkgs/sphinxcontrib_websupport/dependencies +++ b/build/pkgs/sphinxcontrib_websupport/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) sphinxcontrib_serializinghtml | $(PYTHON_TOOLCHAIN) + sphinxcontrib_serializinghtml | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sphinxcontrib_websupport/distros/arch.txt b/build/pkgs/sphinxcontrib_websupport/distros/arch.txt new file mode 100644 index 00000000000..a9a5a1a1727 --- /dev/null +++ b/build/pkgs/sphinxcontrib_websupport/distros/arch.txt @@ -0,0 +1 @@ +python-sphinxcontrib-websupport diff --git a/build/pkgs/sphinxcontrib_websupport/distros/fedora.txt b/build/pkgs/sphinxcontrib_websupport/distros/fedora.txt new file mode 100644 index 00000000000..a9a5a1a1727 --- /dev/null +++ b/build/pkgs/sphinxcontrib_websupport/distros/fedora.txt @@ -0,0 +1 @@ +python-sphinxcontrib-websupport diff --git a/build/pkgs/sphinxcontrib_websupport/distros/freebsd.txt b/build/pkgs/sphinxcontrib_websupport/distros/freebsd.txt new file mode 100644 index 00000000000..b8911943237 --- /dev/null +++ b/build/pkgs/sphinxcontrib_websupport/distros/freebsd.txt @@ -0,0 +1 @@ +textproc/py-sphinxcontrib-websupport diff --git a/build/pkgs/sphinxcontrib_websupport/distros/opensuse.txt b/build/pkgs/sphinxcontrib_websupport/distros/opensuse.txt index 2c8e8e8d34d..d01c76bd534 100644 --- a/build/pkgs/sphinxcontrib_websupport/distros/opensuse.txt +++ b/build/pkgs/sphinxcontrib_websupport/distros/opensuse.txt @@ -1 +1 @@ -python3-sphinxcontrib-websupport +python3${PYTHON_MINOR}-sphinxcontrib-websupport diff --git a/build/pkgs/sqlalchemy/distros/opensuse.txt b/build/pkgs/sqlalchemy/distros/opensuse.txt index 023e06b7468..0a1757fd5b3 100644 --- a/build/pkgs/sqlalchemy/distros/opensuse.txt +++ b/build/pkgs/sqlalchemy/distros/opensuse.txt @@ -1 +1 @@ -python3-SQLAlchemy +python3${PYTHON_MINOR}-SQLAlchemy diff --git a/build/pkgs/stack_data/dependencies b/build/pkgs/stack_data/dependencies index cf6aae43990..52b3edda4b5 100644 --- a/build/pkgs/stack_data/dependencies +++ b/build/pkgs/stack_data/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) executing asttokens pure_eval | $(PYTHON_TOOLCHAIN) + executing asttokens pure_eval | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/surface_dynamics/dependencies b/build/pkgs/surface_dynamics/dependencies index 936121d388d..d8bc8524dbb 100644 --- a/build/pkgs/surface_dynamics/dependencies +++ b/build/pkgs/surface_dynamics/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) cysignals pplpy $(SAGE_SRC)/sage/rings/integer.pxd $(SAGE_SRC)/sage/ext/stdsage.pxd | $(PYTHON_TOOLCHAIN) $(SAGERUNTIME) + cysignals pplpy $(SAGE_SRC)/sage/rings/integer.pxd $(SAGE_SRC)/sage/ext/stdsage.pxd | $(PYTHON_TOOLCHAIN) $(SAGERUNTIME) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/symengine_py/dependencies b/build/pkgs/symengine_py/dependencies index 0b94df79ab9..c48bcedf69c 100644 --- a/build/pkgs/symengine_py/dependencies +++ b/build/pkgs/symengine_py/dependencies @@ -1,4 +1,4 @@ -symengine $(PYTHON) | cmake cython $(PYTHON_TOOLCHAIN) +symengine | cmake cython $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sympy/dependencies b/build/pkgs/sympy/dependencies index 24e1585f16e..6480ac46289 100644 --- a/build/pkgs/sympy/dependencies +++ b/build/pkgs/sympy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) mpmath | $(PYTHON_TOOLCHAIN) + mpmath | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sympy/distros/arch.txt b/build/pkgs/sympy/distros/arch.txt new file mode 100644 index 00000000000..126c88afd85 --- /dev/null +++ b/build/pkgs/sympy/distros/arch.txt @@ -0,0 +1 @@ +python-sympy diff --git a/build/pkgs/sympy/distros/debian.txt b/build/pkgs/sympy/distros/debian.txt new file mode 100644 index 00000000000..db423c87ba7 --- /dev/null +++ b/build/pkgs/sympy/distros/debian.txt @@ -0,0 +1 @@ +python3-sympy diff --git a/build/pkgs/sympy/distros/fedora.txt b/build/pkgs/sympy/distros/fedora.txt new file mode 100644 index 00000000000..126c88afd85 --- /dev/null +++ b/build/pkgs/sympy/distros/fedora.txt @@ -0,0 +1 @@ +python-sympy diff --git a/build/pkgs/sympy/distros/gentoo.txt b/build/pkgs/sympy/distros/gentoo.txt new file mode 100644 index 00000000000..b5a5034c731 --- /dev/null +++ b/build/pkgs/sympy/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/sympy diff --git a/build/pkgs/sympy/distros/opensuse.txt b/build/pkgs/sympy/distros/opensuse.txt new file mode 100644 index 00000000000..bea17da35b4 --- /dev/null +++ b/build/pkgs/sympy/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-sympy diff --git a/build/pkgs/sympy/spkg-configure.m4 b/build/pkgs/sympy/spkg-configure.m4 new file mode 100644 index 00000000000..fa0f1f54311 --- /dev/null +++ b/build/pkgs/sympy/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([sympy], [SAGE_PYTHON_PACKAGE_CHECK([sympy])]) diff --git a/build/pkgs/terminado/dependencies b/build/pkgs/terminado/dependencies index 54ec1c7c229..2138b7ccbe8 100644 --- a/build/pkgs/terminado/dependencies +++ b/build/pkgs/terminado/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) ptyprocess tornado | $(PYTHON_TOOLCHAIN) hatchling + ptyprocess tornado | $(PYTHON_TOOLCHAIN) hatchling $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/terminado/distros/gentoo.txt b/build/pkgs/terminado/distros/gentoo.txt new file mode 100644 index 00000000000..1df16f18abb --- /dev/null +++ b/build/pkgs/terminado/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/terminado diff --git a/build/pkgs/terminado/spkg-configure.m4 b/build/pkgs/terminado/spkg-configure.m4 new file mode 100644 index 00000000000..5defc2ff877 --- /dev/null +++ b/build/pkgs/terminado/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([terminado], [SAGE_PYTHON_PACKAGE_CHECK([terminado])]) diff --git a/build/pkgs/texttable/dependencies b/build/pkgs/texttable/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/texttable/dependencies +++ b/build/pkgs/texttable/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/texttable/distros/arch.txt b/build/pkgs/texttable/distros/arch.txt new file mode 100644 index 00000000000..8d1ccec8c7d --- /dev/null +++ b/build/pkgs/texttable/distros/arch.txt @@ -0,0 +1 @@ +python-texttable diff --git a/build/pkgs/texttable/distros/debian.txt b/build/pkgs/texttable/distros/debian.txt new file mode 100644 index 00000000000..8f8e7e29d7a --- /dev/null +++ b/build/pkgs/texttable/distros/debian.txt @@ -0,0 +1 @@ +python3-texttable diff --git a/build/pkgs/texttable/distros/fedora.txt b/build/pkgs/texttable/distros/fedora.txt new file mode 100644 index 00000000000..8d1ccec8c7d --- /dev/null +++ b/build/pkgs/texttable/distros/fedora.txt @@ -0,0 +1 @@ +python-texttable diff --git a/build/pkgs/texttable/distros/gentoo.txt b/build/pkgs/texttable/distros/gentoo.txt new file mode 100644 index 00000000000..b33a7a75d50 --- /dev/null +++ b/build/pkgs/texttable/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/texttable diff --git a/build/pkgs/texttable/distros/opensuse.txt b/build/pkgs/texttable/distros/opensuse.txt new file mode 100644 index 00000000000..d4959328e94 --- /dev/null +++ b/build/pkgs/texttable/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-texttable diff --git a/build/pkgs/texttable/spkg-configure.m4 b/build/pkgs/texttable/spkg-configure.m4 new file mode 100644 index 00000000000..42a3de105b5 --- /dev/null +++ b/build/pkgs/texttable/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([texttable], [SAGE_PYTHON_PACKAGE_CHECK([texttable])]) diff --git a/build/pkgs/tinycss2/dependencies b/build/pkgs/tinycss2/dependencies index 89200065387..7ebee8487db 100644 --- a/build/pkgs/tinycss2/dependencies +++ b/build/pkgs/tinycss2/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) webencodings | $(PYTHON_TOOLCHAIN) + webencodings | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/toml/dependencies b/build/pkgs/toml/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/toml/dependencies +++ b/build/pkgs/toml/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/toml/distros/arch.txt b/build/pkgs/toml/distros/arch.txt new file mode 100644 index 00000000000..821ee775ac7 --- /dev/null +++ b/build/pkgs/toml/distros/arch.txt @@ -0,0 +1 @@ +python-toml diff --git a/build/pkgs/toml/distros/debian.txt b/build/pkgs/toml/distros/debian.txt new file mode 100644 index 00000000000..543e89d2a6f --- /dev/null +++ b/build/pkgs/toml/distros/debian.txt @@ -0,0 +1 @@ +python3-toml diff --git a/build/pkgs/toml/distros/fedora.txt b/build/pkgs/toml/distros/fedora.txt new file mode 100644 index 00000000000..821ee775ac7 --- /dev/null +++ b/build/pkgs/toml/distros/fedora.txt @@ -0,0 +1 @@ +python-toml diff --git a/build/pkgs/toml/distros/gentoo.txt b/build/pkgs/toml/distros/gentoo.txt new file mode 100644 index 00000000000..64fcea3559f --- /dev/null +++ b/build/pkgs/toml/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/toml diff --git a/build/pkgs/toml/distros/opensuse.txt b/build/pkgs/toml/distros/opensuse.txt new file mode 100644 index 00000000000..fbc340aee15 --- /dev/null +++ b/build/pkgs/toml/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-toml diff --git a/build/pkgs/tomli/dependencies b/build/pkgs/tomli/dependencies index 7cd1e28759d..992761d1f11 100644 --- a/build/pkgs/tomli/dependencies +++ b/build/pkgs/tomli/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | pip flit_core + | pip flit_core $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/tomli/distros/gentoo.txt b/build/pkgs/tomli/distros/gentoo.txt new file mode 100644 index 00000000000..0458e252a4d --- /dev/null +++ b/build/pkgs/tomli/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/tomli diff --git a/build/pkgs/tomli/spkg-configure.m4 b/build/pkgs/tomli/spkg-configure.m4 new file mode 100644 index 00000000000..95a8b8b84c2 --- /dev/null +++ b/build/pkgs/tomli/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([tomli], [SAGE_PYTHON_PACKAGE_CHECK([tomli])]) diff --git a/build/pkgs/tomlkit/dependencies b/build/pkgs/tomlkit/dependencies index 3eb5a92ef22..e67b4c08948 100644 --- a/build/pkgs/tomlkit/dependencies +++ b/build/pkgs/tomlkit/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) poetry_core + | $(PYTHON_TOOLCHAIN) poetry_core $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/tornado/dependencies b/build/pkgs/tornado/dependencies index 212c6234efb..0d4701f9d71 100644 --- a/build/pkgs/tornado/dependencies +++ b/build/pkgs/tornado/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) certifi | $(PYTHON_TOOLCHAIN) + certifi | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/tornado/distros/gentoo.txt b/build/pkgs/tornado/distros/gentoo.txt new file mode 100644 index 00000000000..6ae4b9fc443 --- /dev/null +++ b/build/pkgs/tornado/distros/gentoo.txt @@ -0,0 +1 @@ +www-servers/tornado diff --git a/build/pkgs/tornado/distros/opensuse.txt b/build/pkgs/tornado/distros/opensuse.txt index 426685be95b..1f37b341221 100644 --- a/build/pkgs/tornado/distros/opensuse.txt +++ b/build/pkgs/tornado/distros/opensuse.txt @@ -1 +1 @@ -python3-tornado +python3${PYTHON_MINOR}-tornado diff --git a/build/pkgs/tornado/spkg-configure.m4 b/build/pkgs/tornado/spkg-configure.m4 new file mode 100644 index 00000000000..1ee5bc9f544 --- /dev/null +++ b/build/pkgs/tornado/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([tornado], [SAGE_PYTHON_PACKAGE_CHECK([tornado])]) diff --git a/build/pkgs/tox/dependencies b/build/pkgs/tox/dependencies index 5a00a282b7d..d910d42722f 100644 --- a/build/pkgs/tox/dependencies +++ b/build/pkgs/tox/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) packaging six filelock pluggy py toml virtualenv importlib_metadata | $(PYTHON_TOOLCHAIN) + packaging six filelock pluggy py toml virtualenv importlib_metadata | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/traitlets/dependencies b/build/pkgs/traitlets/dependencies index df88de8f64c..e835448bea5 100644 --- a/build/pkgs/traitlets/dependencies +++ b/build/pkgs/traitlets/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) ipython_genutils decorator six hatchling + | $(PYTHON_TOOLCHAIN) ipython_genutils decorator six hatchling $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/traitlets/distros/gentoo.txt b/build/pkgs/traitlets/distros/gentoo.txt new file mode 100644 index 00000000000..46bfaab6fef --- /dev/null +++ b/build/pkgs/traitlets/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/traitlets diff --git a/build/pkgs/traitlets/distros/opensuse.txt b/build/pkgs/traitlets/distros/opensuse.txt index 93cb8375e46..f0cc6730e1f 100644 --- a/build/pkgs/traitlets/distros/opensuse.txt +++ b/build/pkgs/traitlets/distros/opensuse.txt @@ -1 +1 @@ -python3-traitlets +python3${PYTHON_MINOR}-traitlets diff --git a/build/pkgs/traitlets/spkg-configure.m4 b/build/pkgs/traitlets/spkg-configure.m4 new file mode 100644 index 00000000000..df2382b8f01 --- /dev/null +++ b/build/pkgs/traitlets/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([traitlets], [SAGE_PYTHON_PACKAGE_CHECK([traitlets])]) diff --git a/build/pkgs/typing_extensions/dependencies b/build/pkgs/typing_extensions/dependencies index f8bd1ee040d..e0e94942dba 100644 --- a/build/pkgs/typing_extensions/dependencies +++ b/build/pkgs/typing_extensions/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | flit_core + | flit_core $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/typing_extensions/distros/arch.txt b/build/pkgs/typing_extensions/distros/arch.txt new file mode 100644 index 00000000000..92ad68dabc4 --- /dev/null +++ b/build/pkgs/typing_extensions/distros/arch.txt @@ -0,0 +1 @@ +python-typing_extensions diff --git a/build/pkgs/typing_extensions/distros/debian.txt b/build/pkgs/typing_extensions/distros/debian.txt new file mode 100644 index 00000000000..424ebf1a645 --- /dev/null +++ b/build/pkgs/typing_extensions/distros/debian.txt @@ -0,0 +1 @@ +python3-typing-extensions diff --git a/build/pkgs/typing_extensions/distros/fedora.txt b/build/pkgs/typing_extensions/distros/fedora.txt new file mode 100644 index 00000000000..8c13a4539ac --- /dev/null +++ b/build/pkgs/typing_extensions/distros/fedora.txt @@ -0,0 +1 @@ +python-typing-extensions diff --git a/build/pkgs/typing_extensions/distros/freebsd.txt b/build/pkgs/typing_extensions/distros/freebsd.txt new file mode 100644 index 00000000000..b4424d384df --- /dev/null +++ b/build/pkgs/typing_extensions/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-typing-extensions diff --git a/build/pkgs/typing_extensions/distros/gentoo.txt b/build/pkgs/typing_extensions/distros/gentoo.txt new file mode 100644 index 00000000000..20b3d1de123 --- /dev/null +++ b/build/pkgs/typing_extensions/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/typing-extensions diff --git a/build/pkgs/typing_extensions/distros/opensuse.txt b/build/pkgs/typing_extensions/distros/opensuse.txt new file mode 100644 index 00000000000..62a10cbbc72 --- /dev/null +++ b/build/pkgs/typing_extensions/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-typing_extensions diff --git a/build/pkgs/tzdata/dependencies b/build/pkgs/tzdata/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/tzdata/dependencies +++ b/build/pkgs/tzdata/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/tzlocal/dependencies b/build/pkgs/tzlocal/dependencies index 1d3b818d4ac..4e161b299ab 100644 --- a/build/pkgs/tzlocal/dependencies +++ b/build/pkgs/tzlocal/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) pytz_deprecation_shim | $(PYTHON_TOOLCHAIN) + pytz_deprecation_shim | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/tzlocal/distros/arch.txt b/build/pkgs/tzlocal/distros/arch.txt new file mode 100644 index 00000000000..1de39af60b2 --- /dev/null +++ b/build/pkgs/tzlocal/distros/arch.txt @@ -0,0 +1 @@ +python-tzlocal diff --git a/build/pkgs/tzlocal/distros/debian.txt b/build/pkgs/tzlocal/distros/debian.txt new file mode 100644 index 00000000000..95d2d705c05 --- /dev/null +++ b/build/pkgs/tzlocal/distros/debian.txt @@ -0,0 +1 @@ +python3-tzlocal diff --git a/build/pkgs/tzlocal/distros/fedora.txt b/build/pkgs/tzlocal/distros/fedora.txt new file mode 100644 index 00000000000..1de39af60b2 --- /dev/null +++ b/build/pkgs/tzlocal/distros/fedora.txt @@ -0,0 +1 @@ +python-tzlocal diff --git a/build/pkgs/tzlocal/distros/freebsd.txt b/build/pkgs/tzlocal/distros/freebsd.txt new file mode 100644 index 00000000000..c42ec397d1c --- /dev/null +++ b/build/pkgs/tzlocal/distros/freebsd.txt @@ -0,0 +1 @@ +devel/py-tzlocal diff --git a/build/pkgs/tzlocal/distros/gentoo.txt b/build/pkgs/tzlocal/distros/gentoo.txt new file mode 100644 index 00000000000..2018442dcc4 --- /dev/null +++ b/build/pkgs/tzlocal/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/tzlocal diff --git a/build/pkgs/tzlocal/distros/opensuse.txt b/build/pkgs/tzlocal/distros/opensuse.txt index 95d2d705c05..2e4de5e9e49 100644 --- a/build/pkgs/tzlocal/distros/opensuse.txt +++ b/build/pkgs/tzlocal/distros/opensuse.txt @@ -1 +1 @@ -python3-tzlocal +python3${PYTHON_MINOR}-tzlocal diff --git a/build/pkgs/tzlocal/spkg-configure.m4 b/build/pkgs/tzlocal/spkg-configure.m4 new file mode 100644 index 00000000000..e020b2823f9 --- /dev/null +++ b/build/pkgs/tzlocal/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([tzlocal], [SAGE_PYTHON_PACKAGE_CHECK([tzlocal])]) diff --git a/build/pkgs/urllib3/dependencies b/build/pkgs/urllib3/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/urllib3/dependencies +++ b/build/pkgs/urllib3/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/urllib3/distros/arch.txt b/build/pkgs/urllib3/distros/arch.txt new file mode 100644 index 00000000000..af6e58664fb --- /dev/null +++ b/build/pkgs/urllib3/distros/arch.txt @@ -0,0 +1 @@ +python-urllib3 diff --git a/build/pkgs/urllib3/distros/debian.txt b/build/pkgs/urllib3/distros/debian.txt new file mode 100644 index 00000000000..918569f9677 --- /dev/null +++ b/build/pkgs/urllib3/distros/debian.txt @@ -0,0 +1 @@ +python3-urllib3 diff --git a/build/pkgs/urllib3/distros/fedora.txt b/build/pkgs/urllib3/distros/fedora.txt new file mode 100644 index 00000000000..af6e58664fb --- /dev/null +++ b/build/pkgs/urllib3/distros/fedora.txt @@ -0,0 +1 @@ +python-urllib3 diff --git a/build/pkgs/urllib3/distros/freebsd.txt b/build/pkgs/urllib3/distros/freebsd.txt new file mode 100644 index 00000000000..751c1d25c41 --- /dev/null +++ b/build/pkgs/urllib3/distros/freebsd.txt @@ -0,0 +1 @@ +net/py-urllib3 diff --git a/build/pkgs/urllib3/distros/gentoo.txt b/build/pkgs/urllib3/distros/gentoo.txt new file mode 100644 index 00000000000..172a5357dba --- /dev/null +++ b/build/pkgs/urllib3/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/urllib3 diff --git a/build/pkgs/urllib3/distros/opensuse.txt b/build/pkgs/urllib3/distros/opensuse.txt new file mode 100644 index 00000000000..7466e3c2bdd --- /dev/null +++ b/build/pkgs/urllib3/distros/opensuse.txt @@ -0,0 +1 @@ +python3${PYTHON_MINOR}-urllib3 diff --git a/build/pkgs/urllib3/spkg-configure.m4 b/build/pkgs/urllib3/spkg-configure.m4 new file mode 100644 index 00000000000..d7ef3e1661c --- /dev/null +++ b/build/pkgs/urllib3/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([urllib3], [SAGE_PYTHON_PACKAGE_CHECK([urllib3])]) diff --git a/build/pkgs/vcversioner/dependencies b/build/pkgs/vcversioner/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/vcversioner/dependencies +++ b/build/pkgs/vcversioner/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/vcversioner/distros/opensuse.txt b/build/pkgs/vcversioner/distros/opensuse.txt index 3a9b9818aa4..a9b307f8509 100644 --- a/build/pkgs/vcversioner/distros/opensuse.txt +++ b/build/pkgs/vcversioner/distros/opensuse.txt @@ -1 +1 @@ -python3-vcversioner +python3${PYTHON_MINOR}-vcversioner diff --git a/build/pkgs/virtualenv/dependencies b/build/pkgs/virtualenv/dependencies index a8b8def7051..021e0fc1bd7 100644 --- a/build/pkgs/virtualenv/dependencies +++ b/build/pkgs/virtualenv/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) appdirs distlib filelock six importlib_metadata importlib_resources platformdirs | $(PYTHON_TOOLCHAIN) + appdirs distlib filelock six importlib_metadata importlib_resources platformdirs | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/wcwidth/dependencies b/build/pkgs/wcwidth/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/wcwidth/dependencies +++ b/build/pkgs/wcwidth/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/wcwidth/distros/gentoo.txt b/build/pkgs/wcwidth/distros/gentoo.txt new file mode 100644 index 00000000000..edeb80b62a1 --- /dev/null +++ b/build/pkgs/wcwidth/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/wcwidth diff --git a/build/pkgs/wcwidth/distros/opensuse.txt b/build/pkgs/wcwidth/distros/opensuse.txt index 2974220c878..8fea03a6c67 100644 --- a/build/pkgs/wcwidth/distros/opensuse.txt +++ b/build/pkgs/wcwidth/distros/opensuse.txt @@ -1 +1 @@ -python3-wcwidth +python3${PYTHON_MINOR}-wcwidth diff --git a/build/pkgs/wcwidth/spkg-configure.m4 b/build/pkgs/wcwidth/spkg-configure.m4 new file mode 100644 index 00000000000..5bde15af224 --- /dev/null +++ b/build/pkgs/wcwidth/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([wcwidth], [SAGE_PYTHON_PACKAGE_CHECK([wcwidth])]) diff --git a/build/pkgs/webencodings/dependencies b/build/pkgs/webencodings/dependencies index 0738c2d7777..47296a7bace 100644 --- a/build/pkgs/webencodings/dependencies +++ b/build/pkgs/webencodings/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) | $(PYTHON_TOOLCHAIN) + | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/webencodings/distros/arch.txt b/build/pkgs/webencodings/distros/arch.txt new file mode 100644 index 00000000000..12ddba901a4 --- /dev/null +++ b/build/pkgs/webencodings/distros/arch.txt @@ -0,0 +1 @@ +python-webencodings diff --git a/build/pkgs/webencodings/distros/debian.txt b/build/pkgs/webencodings/distros/debian.txt new file mode 100644 index 00000000000..ac30c2f3307 --- /dev/null +++ b/build/pkgs/webencodings/distros/debian.txt @@ -0,0 +1 @@ +python3-webencodings diff --git a/build/pkgs/webencodings/distros/fedora.txt b/build/pkgs/webencodings/distros/fedora.txt new file mode 100644 index 00000000000..12ddba901a4 --- /dev/null +++ b/build/pkgs/webencodings/distros/fedora.txt @@ -0,0 +1 @@ +python-webencodings diff --git a/build/pkgs/webencodings/distros/gentoo.txt b/build/pkgs/webencodings/distros/gentoo.txt new file mode 100644 index 00000000000..7539b0fdcde --- /dev/null +++ b/build/pkgs/webencodings/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/webencodings diff --git a/build/pkgs/webencodings/distros/opensuse.txt b/build/pkgs/webencodings/distros/opensuse.txt index ac30c2f3307..b8d9c4d299c 100644 --- a/build/pkgs/webencodings/distros/opensuse.txt +++ b/build/pkgs/webencodings/distros/opensuse.txt @@ -1 +1 @@ -python3-webencodings +python3${PYTHON_MINOR}-webencodings diff --git a/build/pkgs/webencodings/spkg-configure.m4 b/build/pkgs/webencodings/spkg-configure.m4 new file mode 100644 index 00000000000..1b9a5c431f3 --- /dev/null +++ b/build/pkgs/webencodings/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([webencodings], [ + SAGE_PYTHON_PACKAGE_CHECK([webencodings]) +]) diff --git a/build/pkgs/wheel/dependencies b/build/pkgs/wheel/dependencies index 98d3e59447b..a8e327be793 100644 --- a/build/pkgs/wheel/dependencies +++ b/build/pkgs/wheel/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) setuptools + setuptools | $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/wheel/distros/arch.txt b/build/pkgs/wheel/distros/arch.txt new file mode 100644 index 00000000000..ae4cbb9f52f --- /dev/null +++ b/build/pkgs/wheel/distros/arch.txt @@ -0,0 +1 @@ +python-wheel diff --git a/build/pkgs/wheel/distros/debian.txt b/build/pkgs/wheel/distros/debian.txt new file mode 100644 index 00000000000..3c066725a1d --- /dev/null +++ b/build/pkgs/wheel/distros/debian.txt @@ -0,0 +1 @@ +python3-wheel diff --git a/build/pkgs/wheel/distros/fedora.txt b/build/pkgs/wheel/distros/fedora.txt new file mode 100644 index 00000000000..ae4cbb9f52f --- /dev/null +++ b/build/pkgs/wheel/distros/fedora.txt @@ -0,0 +1 @@ +python-wheel diff --git a/build/pkgs/wheel/distros/gentoo.txt b/build/pkgs/wheel/distros/gentoo.txt new file mode 100644 index 00000000000..ec571d59d93 --- /dev/null +++ b/build/pkgs/wheel/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/wheel diff --git a/build/pkgs/wheel/distros/opensuse.txt b/build/pkgs/wheel/distros/opensuse.txt index 3c066725a1d..3df335c1375 100644 --- a/build/pkgs/wheel/distros/opensuse.txt +++ b/build/pkgs/wheel/distros/opensuse.txt @@ -1 +1 @@ -python3-wheel +python3${PYTHON_MINOR}-wheel diff --git a/build/pkgs/wheel/spkg-configure.m4 b/build/pkgs/wheel/spkg-configure.m4 new file mode 100644 index 00000000000..7897ea96cc6 --- /dev/null +++ b/build/pkgs/wheel/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([wheel], [SAGE_PYTHON_PACKAGE_CHECK([wheel])]) diff --git a/build/pkgs/widgetsnbextension/dependencies b/build/pkgs/widgetsnbextension/dependencies index f7ff1dca568..301cefdea49 100644 --- a/build/pkgs/widgetsnbextension/dependencies +++ b/build/pkgs/widgetsnbextension/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) jupyter_packaging | $(PYTHON_TOOLCHAIN) jupyter_core + jupyter_packaging | $(PYTHON_TOOLCHAIN) jupyter_core $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/widgetsnbextension/spkg-configure.m4 b/build/pkgs/widgetsnbextension/spkg-configure.m4 new file mode 100644 index 00000000000..bf82dafe209 --- /dev/null +++ b/build/pkgs/widgetsnbextension/spkg-configure.m4 @@ -0,0 +1,3 @@ +SAGE_SPKG_CONFIGURE([widgetsnbextension], [ + SAGE_PYTHON_PACKAGE_CHECK([widgetsnbextension]) +]) diff --git a/build/pkgs/zipp/dependencies b/build/pkgs/zipp/dependencies index 4361e46ddaf..9be6b4aab7c 100644 --- a/build/pkgs/zipp/dependencies +++ b/build/pkgs/zipp/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) vcversioner | $(PYTHON_TOOLCHAIN) + vcversioner | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/zipp/distros/gentoo.txt b/build/pkgs/zipp/distros/gentoo.txt new file mode 100644 index 00000000000..7f59450c2b7 --- /dev/null +++ b/build/pkgs/zipp/distros/gentoo.txt @@ -0,0 +1 @@ +dev-python/zipp diff --git a/build/pkgs/zipp/spkg-configure.m4 b/build/pkgs/zipp/spkg-configure.m4 new file mode 100644 index 00000000000..0fe3a9cd224 --- /dev/null +++ b/build/pkgs/zipp/spkg-configure.m4 @@ -0,0 +1 @@ +SAGE_SPKG_CONFIGURE([zipp], [SAGE_PYTHON_PACKAGE_CHECK([zipp])]) diff --git a/configure.ac b/configure.ac index 4a255967fc6..a8f700a09ec 100644 --- a/configure.ac +++ b/configure.ac @@ -445,6 +445,40 @@ AC_ARG_ENABLE([download-from-upstream-url], [disallow downloading packages from their upstream URL if they cannot be found on the Sage mirrors])], [], [AS_VAR_SET([enable_download_from_upstream_url], [yes])]) +AC_ARG_ENABLE( + [system-site-packages], [AS_HELP_STRING( + [--enable-system-site-packages], + [allow the use of python packages from the system (experimental; default: no)] + )], [ + AS_IF([test "x$enable_system_site_packages" = "xyes"], [ + dnl When installing python SPKGs in the presence of system-site + dnl packages, we need to --ignore-installed so that a patched SPKG + dnl can be installed in the presence of an unpatched system package + dnl that appears (to pip) to be identical. The --no-deps flag is + dnl then needed because --ignore-installed will make any installed + dnl dependencies invisible to pip, who does not appreciate that. + SAGE_PIP_INSTALL_FLAGS="${SAGE_PIP_INSTALL_FLAGS} --no-deps --ignore-installed" + + SAGE_VENV_FLAGS="${SAGE_VENV_FLAGS} --system-site-packages" + + dnl We want to raise an error if the user asked for "system site + dnl packages" but the system python will not be used. Technically + dnl that causes no problems (SAGE_PYTHON_PACKAGE_CHECK always fails, + dnl so SPKGs are used for all python packages), but it may be confusing + dnl to end users who expect the flag to actually give them access to + dnl their system python packages and who may not be paying close + dnl attention to their ./configure output. + with_system_python3="force" + + dnl This is substituted in to build/bin/sage-build-env-config.in for use + dnl by build/bin/sage-get-system-packages + ENABLE_SYSTEM_SITE_PACKAGES=yes + ]) +]) +AC_SUBST([ENABLE_SYSTEM_SITE_PACKAGES]) +AC_SUBST([SAGE_PIP_INSTALL_FLAGS]) +AC_SUBST([SAGE_VENV_FLAGS]) + SAGE_SPKG_OPTIONS="" AS_IF([test "x$enable_experimental_packages" = "xyes"], [ AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -y"]) @@ -487,7 +521,7 @@ AS_IF([test "$SAGE_ENABLE_notebook" = no -a "$SAGE_ENABLE_sagelib" = no], [ AC_ARG_ENABLE([r], AS_HELP_STRING([--disable-r], [disable build of the R package and related packages]), [ - for pkg in r rpy2 r_jupyter; do + for pkg in r rpy2 r_jupyter tzlocal; do AS_VAR_SET([SAGE_ENABLE_$pkg], [$enableval]) done ]) diff --git a/m4/sage_python_package_check.m4 b/m4/sage_python_package_check.m4 new file mode 100644 index 00000000000..e0713512ea0 --- /dev/null +++ b/m4/sage_python_package_check.m4 @@ -0,0 +1,118 @@ +# +# SYNOPSIS +# +# SAGE_PYTHON_PACKAGE_CHECK(package) +# +# DESCRIPTION +# +# Determine if the system copy of a python package can be used by sage. +# +# This macro uses setuptools.version's pkg_resources to check that the +# "install-requires.txt" file for the named package is satisfied, and +# it can typically fail in four ways: +# +# 1. If --enable-system-site-packages was not passed to ./configure, +# +# 2. If we are not using the system python (no $PYTHON_FOR_VENV), +# +# 3. If we are unable to create a venv with the system python, +# +# 4. If setuptools is not available to the system python, +# +# 5. If the contents of install-requires.txt are not met (wrong +# version, no version, etc.) by the system python. +# +# In any of those cases, we set sage_spkg_install_$package to "yes" +# so that the corresponding SPKG is installed. Otherwise, we do +# nothing, since the default value of sage_spkg_install_$package +# is "no" (to use the system copy). +# +# The SAGE_SPKG_CONFIGURE_PYTHON3() macro is AC_REQUIRE'd to ensure +# that $PYTHON_FOR_VENV is available, if it is going to be available. +# The check is run inside a new venv, and with the PYTHONUSERBASE +# variable poisoned in the same manner as sage-env poisons it, to +# ensure that the ./configure- and run-time views of the system +# are as similar as possible. +# +# To avoid suggesting these system packages to users who have not +# set --enable-system-site-packages, this macro also changes the +# default for --with-system-foo from "yes" to "no" in that case. +# + +AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [ + AC_MSG_CHECKING([if --enable-system-site-packages was used]) + AS_IF([test "${enable_system_site_packages}" = "yes"], [ + AC_MSG_RESULT(yes) + AC_REQUIRE([SAGE_SPKG_CONFIGURE_PYTHON3]) + + dnl We run this check inside a python venv, because that's ultimately + dnl how the system $PYTHON_FOR_VENV will be used. + AC_MSG_CHECKING([if we can create a python venv in config.venv]) + + dnl Use --clear because ./configure typically clobbers its output files. + AS_IF(["${PYTHON_FOR_VENV}" build/bin/sage-venv dnl + --system-site-packages dnl + --clear dnl + config.venv dnl + 2>&AS_MESSAGE_LOG_FD], [ + AC_MSG_RESULT(yes) + dnl strip all comments from install-requires.txt; this should leave + dnl only a single line containing the version specification for this + dnl package. + SAGE_PKG_VERSPEC=$(sed '/^#/d' "./build/pkgs/$1/install-requires.txt") + AC_MSG_CHECKING([for python package $1 ("${SAGE_PKG_VERSPEC}")]) + + dnl To prevent user-site (pip install --user) packages from being + dnl detected as "system" packages, we poison PYTHONUSERBASE. The + dnl sage-env script also does this at runtime; we mimic that + dnl implementation to ensure that the behaviors at ./configure and + dnl runtime are identical. Beware that (as in sage-env) the poisoning + dnl is skipped if PYTHONUSERBASE is non-empty. In particular, if the + dnl user points PYTHONUSERBASE to any path (even the default), then + dnl his local pip packages will be detected. + PYTHONUSERBASE_SAVED="${PYTHONUSERBASE}" + AS_IF([test -z "${PYTHONUSERBASE}"], [ + PYTHONUSERBASE="${HOME}/.sage/local" + ]) + + AS_IF( + [PYTHONUSERBASE="${PYTHONUSERBASE}" config.venv/bin/python3 -c dnl + "import pkg_resources; dnl + pkg_resources.require('${SAGE_PKG_VERSPEC}'.splitlines())" dnl + 2>&AS_MESSAGE_LOG_FD], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no); sage_spkg_install_$1=yes] + ) + + PYTHONUSERBASE="${PYTHONUSERBASE_SAVED}" + ], [ + dnl failed to create a venv for some reason + AC_MSG_RESULT(no) + sage_spkg_install_$1=yes + ]) + + dnl Clean up config.venv, but only if we could have created it. + dnl (The --clear flag to pyvenv will not clobber a plain file.) + AS_IF([test -d config.venv], [rm -rf config.venv]) + ], [ + dnl System site packages are disabled. + AC_MSG_RESULT(no; skipping check) + sage_spkg_install_$1=yes + + dnl We have to retroactively hack the --with-system-foo={no,yes,force} + dnl mechanism here because it wasn't designed with the ability to + dnl disable arbitrary chunks of system packages in mind. The easy cases + dnl are "no" and "force" which require no action; "no" means we won't + dnl suggest the package anyway, and "force" will raise an error when + dnl the system-package check fails. + dnl + dnl The default of "yes" is more troubling because it is the default. To + dnl avoid prompting users to install packages that won't be used, we want + dnl to ignore "yes" when reporting the "hint: install these packages..." + dnl at the end of ./configure. To accomplish that, we change "yes" to + dnl "no" here, essentially changing the default for packages using this + dnl macro when --enable-system-site-packages is disabled. Packages with + dnl "no" are not suggested to the user. + AS_IF([test "${sage_use_system_$1}" = "yes"],[sage_use_system_$1=no]) + ]) +]) diff --git a/m4/sage_spkg_configure.m4 b/m4/sage_spkg_configure.m4 index a0eeaa53a74..1f07d7cd294 100644 --- a/m4/sage_spkg_configure.m4 +++ b/m4/sage_spkg_configure.m4 @@ -58,6 +58,31 @@ dnl indicate why m4_pushdef([SPKG_USE_SYSTEM], [sage_use_system_]SPKG_NAME) # BEGIN SAGE_SPKG_CONFIGURE_]m4_toupper($1)[ +dnl Hide the output from Python (system site package) checks +dnl when --enable-system-site-packages was not given. This +dnl doesn't affect the test results but it minimizes the noise +dnl in the ./configure output. The config.log however retains +dnl everything. +dnl +dnl Open descriptor 9 as a copy of AS_MESSAGE_FD, so that it +dnl can later be used to restore AS_MESSAGE_FD. Afterwards, +dnl send AS_MESSAGE_FD to /dev/null. We'll restore it if this +dnl isn't a python package or if --enable-system-site-packages +dnl was given (or at the end of this macro, if nothing else). +exec 9<&AS_MESSAGE_FD +exec AS_MESSAGE_FD>/dev/null + +AS_IF([test "${enable_system_site_packages}" = "yes"], [ + dnl Python package checks are enabled, so restore AS_MESSAGE_FD + exec AS_MESSAGE_FD<&9 +]) + +SPKG_CONFIGURE="${SAGE_ROOT}/build/pkgs/$1/spkg-configure.m4" +AS_IF([! grep -q [SAGE_PYTHON_PACKAGE_CHECK] "${SPKG_CONFIGURE}"],[ + dnl Not a python package, so restore AS_MESSAGE_FD + exec AS_MESSAGE_FD<&9 +]) + echo "-----------------------------------------------------------------------------" >& AS_MESSAGE_FD echo "Checking whether SageMath should install SPKG $1..." >& AS_MESSAGE_FD AS_BOX([Checking whether SageMath should install SPKG $1...]) >& AS_MESSAGE_LOG_FD @@ -140,6 +165,13 @@ AS_VAR_IF(SPKG_INSTALL, [no], [ dnl Run POST $5 +dnl Restore the message file descriptor that we clobbered earlier +dnl for the sake of hiding site package check noise. It's possible +dnl that we've already done this above, but it doesn't hurt to do +dnl it again, and we want everything "back to normal" at the end +dnl of this macro. +exec AS_MESSAGE_FD<&9 + # END SAGE_SPKG_CONFIGURE_]m4_toupper($1)[ m4_popdef([SPKG_USE_SYSTEM]) m4_popdef([SPKG_REQUIRE]) diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sage-conf/VERSION.txt +++ b/pkgs/sage-conf/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sage-conf_pypi/VERSION.txt +++ b/pkgs/sage-conf_pypi/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sage-docbuild/VERSION.txt +++ b/pkgs/sage-docbuild/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sage-setup/VERSION.txt +++ b/pkgs/sage-setup/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sage-sws2rst/VERSION.txt +++ b/pkgs/sage-sws2rst/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-bliss/VERSION.txt +++ b/pkgs/sagemath-bliss/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-categories/VERSION.txt +++ b/pkgs/sagemath-categories/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-coxeter3/VERSION.txt +++ b/pkgs/sagemath-coxeter3/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-environment/VERSION.txt +++ b/pkgs/sagemath-environment/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-mcqd/VERSION.txt +++ b/pkgs/sagemath-mcqd/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-meataxe/VERSION.txt +++ b/pkgs/sagemath-meataxe/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-objects/VERSION.txt +++ b/pkgs/sagemath-objects/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-repl/VERSION.txt +++ b/pkgs/sagemath-repl/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-sirocco/VERSION.txt +++ b/pkgs/sagemath-sirocco/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/pkgs/sagemath-tdlib/VERSION.txt +++ b/pkgs/sagemath-tdlib/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/src/VERSION.txt b/src/VERSION.txt index 11692eaae58..ed84bdcdf51 100644 --- a/src/VERSION.txt +++ b/src/VERSION.txt @@ -1 +1 @@ -10.2.beta1 +10.2.beta2 diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh index 6f192dbbc5c..a4f2cf54b18 100644 --- a/src/bin/sage-version.sh +++ b/src/bin/sage-version.sh @@ -4,6 +4,6 @@ # which stops "setup.py develop" from rewriting it as a Python file. : # This file is auto-generated by the sage-update-version script, do not edit! -SAGE_VERSION='10.2.beta1' -SAGE_RELEASE_DATE='2023-09-01' -SAGE_VERSION_BANNER='SageMath version 10.2.beta1, Release Date: 2023-09-01' +SAGE_VERSION='10.2.beta2' +SAGE_RELEASE_DATE='2023-09-10' +SAGE_VERSION_BANNER='SageMath version 10.2.beta2, Release Date: 2023-09-10' diff --git a/src/doc/en/reference/groups/index.rst b/src/doc/en/reference/groups/index.rst index 46764ef45e1..97a7c126698 100644 --- a/src/doc/en/reference/groups/index.rst +++ b/src/doc/en/reference/groups/index.rst @@ -18,6 +18,7 @@ Groups sage/groups/braid sage/groups/cubic_braid sage/groups/indexed_free_group + sage/groups/artin sage/groups/raag sage/groups/cactus_group sage/groups/group_exp diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index 94ebc11620f..ede570759cd 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -351,6 +351,10 @@ REFERENCES: *Characteristic polynomials of subspace arrangements and finite fields*. Advances in Mathematics, 122(2):193-233, 1996. +.. [Ath2000] \C. A. Athanasiadis, + *Deformations of Coxeter hyperplane arrangements and their characteristic polynomials*. + Adv. Stud. Pure Math., 27, 2000. + .. [Av2000] \D. Avis, *A revised implementation of the reverse search vertex enumeration algorithm.* Polytopes-combinatorics and computation. Birkhauser Basel, 2000. diff --git a/src/sage/algebras/affine_nil_temperley_lieb.py b/src/sage/algebras/affine_nil_temperley_lieb.py index f7901ae314d..720c5f481cd 100644 --- a/src/sage/algebras/affine_nil_temperley_lieb.py +++ b/src/sage/algebras/affine_nil_temperley_lieb.py @@ -119,7 +119,7 @@ def _repr_(self): sage: A = AffineNilTemperleyLiebTypeA(3); A The affine nilTemperley Lieb algebra A3 over the ring Integer Ring """ - return "The affine nilTemperley Lieb algebra A%s over the ring %s"%(self._n, self._base_ring) + return "The affine nilTemperley Lieb algebra A%s over the ring %s" % (self._n, self._base_ring) def weyl_group(self): """ @@ -234,7 +234,7 @@ def has_no_braid_relation(self, w, i): return False s = w.parent().simple_reflections() wi = w*s[i] - adjacent = [(i-1)%w.parent().n, (i+1)%w.parent().n] + adjacent = [(i-1) % w.parent().n, (i+1) % w.parent().n] for j in adjacent: if j in w.descents(): if j in wi.descents(): @@ -258,6 +258,6 @@ def _repr_term(self, t, short_display=True): if len(redword) == 0: return "1" elif short_display: - return "*".join("%s%d"%(self._prefix, i) for i in redword) + return "*".join("%s%d" % (self._prefix, i) for i in redword) else: - return "*".join("%s[%d]"%(self._prefix, i) for i in redword) + return "*".join("%s[%d]" % (self._prefix, i) for i in redword) diff --git a/src/sage/algebras/cellular_basis.py b/src/sage/algebras/cellular_basis.py index 42ce84307d5..873bd899b3e 100644 --- a/src/sage/algebras/cellular_basis.py +++ b/src/sage/algebras/cellular_basis.py @@ -233,7 +233,7 @@ def _latex_term(self, x): sm = latex(m) if sm.find('\\text{\\textt') != -1: sm = str(m) - return "C^{%s}_{%s}"%(sla, sm) + return "C^{%s}_{%s}" % (sla, sm) def cellular_basis_of(self): """ diff --git a/src/sage/algebras/down_up_algebra.py b/src/sage/algebras/down_up_algebra.py index c5fe5361282..3ee1bcea25f 100644 --- a/src/sage/algebras/down_up_algebra.py +++ b/src/sage/algebras/down_up_algebra.py @@ -237,7 +237,7 @@ def _latex_(self): sage: latex(DU) \mathcal{DU}(a,b,g) """ - return "\\mathcal{DU}(%s,%s,%s)"%(self._alpha, self._beta, self._gamma) + return "\\mathcal{DU}(%s,%s,%s)" % (self._alpha, self._beta, self._gamma) def _repr_term(self, m): r""" diff --git a/src/sage/algebras/free_algebra.py b/src/sage/algebras/free_algebra.py index bcfb0e3a62e..460b623b877 100644 --- a/src/sage/algebras/free_algebra.py +++ b/src/sage/algebras/free_algebra.py @@ -598,7 +598,7 @@ def exp_to_monomial(T): out = [] for i in range(len(T)): if T[i]: - out.append((i%ngens,T[i])) + out.append((i % ngens,T[i])) return M(out) return self.element_class(self, {exp_to_monomial(T):c for T,c in x.letterplace_polynomial().dict().items()}) # ok, not a free algebra element (or should not be viewed as one). diff --git a/src/sage/algebras/fusion_rings/f_matrix.py b/src/sage/algebras/fusion_rings/f_matrix.py index b8ba585b0f4..fe39ebf72b4 100644 --- a/src/sage/algebras/fusion_rings/f_matrix.py +++ b/src/sage/algebras/fusion_rings/f_matrix.py @@ -280,7 +280,7 @@ def __init__(self, fusion_ring, fusion_label="f", var_prefix='fx', inject_variab n_vars = self.findcases() self._poly_ring = PolynomialRing(self._FR.field(), n_vars, var_prefix) if inject_variables: - print("creating variables %s%s..%s%s"%(var_prefix, 1, var_prefix, n_vars)) + print("creating variables %s%s..%s%s" % (var_prefix, 1, var_prefix, n_vars)) self._poly_ring.inject_variables(get_main_globals()) self._idx_to_sextuple, self._fvars = self.findcases(output=True) @@ -309,7 +309,7 @@ def _repr_(self): sage: FusionRing("B2", 1).get_fmatrix() F-Matrix factory for The Fusion Ring of Type B2 and level 1 with Integer Ring coefficients """ - return "F-Matrix factory for %s"%self._FR + return "F-Matrix factory for %s" % self._FR def clear_equations(self): r""" @@ -1600,7 +1600,7 @@ def _triangular_elim(self, eqns=None, verbose=True): n = self.pool._processes chunks = [[] for i in range(n)] for i, eq_tup in enumerate(eqns): - chunks[i%n].append(eq_tup) + chunks[i % n].append(eq_tup) eqns = chunks else: eqns = [eqns] @@ -1680,7 +1680,7 @@ def equations_graph(self, eqns=None): s = [v for v in eq.variables()] for x in s: for y in s: - if y!=x: + if y != x: G.add_edge(x, y) return G diff --git a/src/sage/algebras/fusion_rings/fusion_double.py b/src/sage/algebras/fusion_rings/fusion_double.py index 07c0f55bc97..520ea96ef13 100644 --- a/src/sage/algebras/fusion_rings/fusion_double.py +++ b/src/sage/algebras/fusion_rings/fusion_double.py @@ -198,7 +198,7 @@ def _repr_(self): The Fusion Ring of the Drinfeld Double of Symmetric group of order 3! as a permutation group """ - return "The Fusion Ring of the Drinfeld Double of %s"%self._G + return "The Fusion Ring of the Drinfeld Double of %s" % self._G def inject_variables(self): """ diff --git a/src/sage/algebras/fusion_rings/fusion_ring.py b/src/sage/algebras/fusion_rings/fusion_ring.py index 4cf1e08d0f2..02da0032802 100644 --- a/src/sage/algebras/fusion_rings/fusion_ring.py +++ b/src/sage/algebras/fusion_rings/fusion_ring.py @@ -1180,7 +1180,7 @@ def _get_trees(fr, top_row, root): comp_basis = list() for top in product((a*a).monomials(), repeat=n_strands//2): # If the n_strands is odd, we must extend the top row by a fusing anyon - top_row = list(top)+[a]*(n_strands%2) + top_row = list(top)+[a]*(n_strands % 2) comp_basis.extend(tuple([*top, *levels]) for levels in _get_trees(self, top_row, b)) return comp_basis diff --git a/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py b/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py index 5f21e1049b0..cf1c7a04c39 100644 --- a/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py +++ b/src/sage/algebras/hecke_algebras/ariki_koike_algebra.py @@ -366,7 +366,7 @@ def _latex_(self): sage: latex(H) \mathcal{H}_{5,2}(q) """ - return "\\mathcal{H}_{%s,%s}(%s)"%(self._r, self._n, self._q) + return "\\mathcal{H}_{%s,%s}(%s)" % (self._r, self._n, self._q) def hecke_parameter(self): r""" @@ -479,7 +479,7 @@ def _repr_(self): Ariki-Koike algebra of rank 5 and order 2 with q=q and u=(u0, u1, u2, u3, u4) ... in the LT-basis """ - return "%s in the %s-basis"%(self.realization_of(), self._realization_name()) + return "%s in the %s-basis" % (self.realization_of(), self._realization_name()) def hecke_parameter(self): r""" @@ -602,8 +602,8 @@ def _repr_term(self, m): sage: LT._repr_term( ((1, 0, 2), Permutation([3,2,1])) ) 'L1*L3^2*T[2,1,2]' """ - gen_str = lambda e: '' if e == 1 else '^%s'%e - lhs = '*'.join('L%s'%(j+1) + gen_str(i) + gen_str = lambda e: '' if e == 1 else '^%s' % e + lhs = '*'.join('L%s' % (j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) redword = m[1].reduced_word() if not redword: @@ -625,15 +625,15 @@ def _latex_term(self, m): sage: LT._latex_term( ((1, 0, 2), Permutation([3,2,1])) ) 'L_{1} L_{3}^{2} T_{2} T_{1} T_{2}' """ - gen_str = lambda e: '' if e == 1 else '^{%s}'%e - lhs = ' '.join('L_{%s}'%(j+1) + gen_str(i) + gen_str = lambda e: '' if e == 1 else '^{%s}' % e + lhs = ' '.join('L_{%s}' % (j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) redword = m[1].reduced_word() if not redword: if not lhs: return '1' return lhs - return lhs + ' ' + ' '.join("T_{%d}"%i for i in redword) + return lhs + ' ' + ' '.join("T_{%d}" % i for i in redword) def _from_T_basis(self, t): r""" @@ -698,10 +698,10 @@ def algebra_generators(self): for i in range(self._n): r = list(self._zero_tuple) # Make a copy r[i] = 1 - d['L%s'%(i+1)] = self.monomial( (tuple(r), self._one_perm) ) + d['L%s' % (i+1)] = self.monomial( (tuple(r), self._one_perm) ) G = self._Pn.group_generators() for i in range(1, self._n): - d['T%s'%i] = self.monomial( (self._zero_tuple, G[i]) ) + d['T%s' % i] = self.monomial( (self._zero_tuple, G[i]) ) return Family(sorted(d), lambda i: d[i]) def T(self, i=None): @@ -725,10 +725,10 @@ def T(self, i=None): """ G = self.algebra_generators() if i is None: - return [G['L1']] + [G['T%s'%j] for j in range(1, self._n)] + return [G['L1']] + [G['T%s' % j] for j in range(1, self._n)] if i == 0: return G['L1'] - return G['T%s'%i] + return G['T%s' % i] def L(self, i=None): r""" @@ -759,10 +759,10 @@ def L(self, i=None): if i is None: if self._r == 1: return [self._Li_power(j, 1) for j in range(1, self._n+1)] - return [G['L%s'%j] for j in range(1, self._n+1)] + return [G['L%s' % j] for j in range(1, self._n+1)] if self._r == 1: return self._Li_power(i, 1) - return G['L%s'%i] + return G['L%s' % i] @cached_method def product_on_basis(self, m1, m2): @@ -1179,7 +1179,7 @@ def __init__(self, algebra): sage: TestSuite(T).run() # long time """ _Basis.__init__(self, algebra, prefix='T') - self._assign_names(['T%s'%i for i in range(self._n)]) + self._assign_names(['T%s' % i for i in range(self._n)]) def _repr_term(self, t): r""" @@ -1200,7 +1200,7 @@ def _repr_term(self, t): if len(redword) == 0: return "1" return (self._print_options['prefix'] - + '[%s]'%','.join('%d'%i for i in redword)) + + '[%s]' % ','.join('%d' % i for i in redword)) def _latex_term(self, t): r""" @@ -1220,7 +1220,7 @@ def _latex_term(self, t): redword += t[1].reduced_word() if len(redword) == 0: return "1" - return ''.join("%s_{%d}"%(self._print_options['prefix'], i) + return ''.join("%s_{%d}" % (self._print_options['prefix'], i) for i in redword) def _from_LT_basis(self, m): diff --git a/src/sage/algebras/lie_algebras/classical_lie_algebra.py b/src/sage/algebras/lie_algebras/classical_lie_algebra.py index 26e0153a309..a2bb531abe0 100644 --- a/src/sage/algebras/lie_algebras/classical_lie_algebra.py +++ b/src/sage/algebras/lie_algebras/classical_lie_algebra.py @@ -345,7 +345,7 @@ def set_row(mat, row, val): def build_assoc(row): ret = {} for i, v in row.dict().items(): - ret[i//m, i%m] = v + ret[i//m, i % m] = v return self._assoc(ret) while added: @@ -1124,7 +1124,7 @@ def __init__(self, R, cartan_type): dim = self._classical.dimension() from sage.sets.finite_enumerated_set import FiniteEnumeratedSet index_set = FiniteEnumeratedSet(range(dim)) - names = tuple(['CR%s'%s for s in range(dim)]) + names = tuple(['CR%s' % s for s in range(dim)]) category = LieAlgebras(R).FiniteDimensional().WithBasis() FinitelyGeneratedLieAlgebra.__init__(self, R, names=names, index_set=index_set, diff --git a/src/sage/algebras/lie_algebras/examples.py b/src/sage/algebras/lie_algebras/examples.py index 89ad4362e5e..2c6c23297f9 100644 --- a/src/sage/algebras/lie_algebras/examples.py +++ b/src/sage/algebras/lie_algebras/examples.py @@ -309,6 +309,7 @@ def regular_vector_fields(R): from sage.algebras.lie_algebras.virasoro import LieAlgebraRegularVectorFields return LieAlgebraRegularVectorFields(R) + witt = regular_vector_fields def pwitt(R, p): diff --git a/src/sage/algebras/lie_algebras/free_lie_algebra.py b/src/sage/algebras/lie_algebras/free_lie_algebra.py index 207f8d63a8c..60d49a174b6 100644 --- a/src/sage/algebras/lie_algebras/free_lie_algebra.py +++ b/src/sage/algebras/lie_algebras/free_lie_algebra.py @@ -713,7 +713,7 @@ def _rewrite_bracket(self, l, r): sage: Lyn([x, [y, [z, x]]]) # indirect doctest [x, [[x, z], y]] """ - assert l < r, "Order mismatch %s > %s"%(l, r) + assert l < r, "Order mismatch %s > %s" % (l, r) if self._is_basis_element(l, r): # Compute the grade of the new element diff --git a/src/sage/algebras/lie_algebras/heisenberg.py b/src/sage/algebras/lie_algebras/heisenberg.py index 629fb0a8306..d2f336f642c 100644 --- a/src/sage/algebras/lie_algebras/heisenberg.py +++ b/src/sage/algebras/lie_algebras/heisenberg.py @@ -58,7 +58,7 @@ def p(self, i): sage: L.p(2) p2 """ - return self.element_class(self, {'p%i'%i: self.base_ring().one()}) + return self.element_class(self, {'p%i' % i: self.base_ring().one()}) def q(self, i): """ @@ -70,7 +70,7 @@ def q(self, i): sage: L.q(2) q2 """ - return self.element_class(self, {'q%i'%i: self.base_ring().one()}) + return self.element_class(self, {'q%i' % i: self.base_ring().one()}) def z(self): """ @@ -122,6 +122,23 @@ def _repr_term(self, m): """ return m + def _ascii_art_term(self, m): + r""" + Return a string representation of the term indexed by ``m``. + + EXAMPLES:: + + sage: H = lie_algebras.Heisenberg(QQ, 3) + sage: H._ascii_art_term('p1') + p1 + sage: H._ascii_art_term('z') + z + sage: ascii_art(sum(i * b for i, b in enumerate(H.basis()))) + p2 + 2*p3 + 3*q1 + 4*q2 + 5*q3 + 6*z + """ + from sage.typeset.ascii_art import ascii_art + return ascii_art(m) + def _latex_term(self, m): r""" Return a string representation of the term indexed by ``m``. @@ -138,7 +155,7 @@ def _latex_term(self, m): """ if len(m) == 1: return m - return "%s_{%s}"%(m[0], m[1:]) # else it is of length at least 2 + return "%s_{%s}" % (m[0], m[1:]) # else it is of length at least 2 def _unicode_art_term(self, m): r""" @@ -261,12 +278,12 @@ def lie_algebra_generators(self): """ if self._n == 0: return Family(['z'], lambda i: self.z()) - k = ['p%s'%i for i in range(1, self._n+1)] - k += ['q%s'%i for i in range(1, self._n+1)] + k = ['p%s' % i for i in range(1, self._n+1)] + k += ['q%s' % i for i in range(1, self._n+1)] d = {} for i in range(1, self._n+1): - d['p%s'%i] = self.p(i) - d['q%s'%i] = self.q(i) + d['p%s' % i] = self.p(i) + d['q%s' % i] = self.q(i) return Family(k, lambda i: d[i]) @cached_method @@ -282,8 +299,8 @@ def basis(self): """ d = {} for i in range(1, self._n+1): - d['p%s'%i] = self.p(i) - d['q%s'%i] = self.q(i) + d['p%s' % i] = self.p(i) + d['q%s' % i] = self.q(i) d['z'] = self.z() return Family(self._indices, lambda i: d[i]) @@ -385,8 +402,8 @@ def __init__(self, R, n): sage: TestSuite(L).run() """ HeisenbergAlgebra_fd.__init__(self, n) - names = tuple(['p%s'%i for i in range(1,n+1)] - + ['q%s'%i for i in range(1,n+1)] + names = tuple(['p%s' % i for i in range(1,n+1)] + + ['q%s' % i for i in range(1,n+1)] + ['z']) LieAlgebraWithGenerators.__init__(self, R, names=names, index_set=names, category=LieAlgebras(R).Nilpotent().FiniteDimensional().WithBasis()) @@ -687,8 +704,8 @@ def __init__(self, R, n): p = tuple(MS({(0,i): one}) for i in range(1, n+1)) q = tuple(MS({(i,n+1): one}) for i in range(1, n+1)) z = (MS({(0,n+1): one}),) - names = tuple('p%s'%i for i in range(1,n+1)) - names = names + tuple('q%s'%i for i in range(1,n+1)) + ('z',) + names = tuple('p%s' % i for i in range(1,n+1)) + names = names + tuple('q%s' % i for i in range(1,n+1)) + ('z',) cat = LieAlgebras(R).Nilpotent().FiniteDimensional().WithBasis() LieAlgebraFromAssociative.__init__(self, MS, p + q + z, names=names, index_set=names, category=cat) @@ -716,7 +733,7 @@ def p(self, i): [0 0 0] [0 0 0] """ - return self._gens['p%s'%i] + return self._gens['p%s' % i] def q(self, i): r""" @@ -730,7 +747,7 @@ def q(self, i): [0 0 1] [0 0 0] """ - return self._gens['q%s'%i] + return self._gens['q%s' % i] def z(self): """ diff --git a/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py index 31b542cd373..8cc6533b781 100644 --- a/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py @@ -111,7 +111,7 @@ def __init__(self, R, ngens=None, gram_matrix=None, names=None, latex_names = None if (names is None) and (index_set is None): - if ngens==1: + if ngens == 1: names = 'psi' else: names = 'psi_' diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py index 5c14016eab2..1007488e165 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py @@ -328,10 +328,10 @@ def __classcall_private__(cls, R=None, arg0=None, index_set=None, 'string_quotes', 'sorting_key', 'graded', 'super'] for key in kwds: if key not in known_keywords: - raise ValueError("got an unexpected keyword argument '%s'"%key) + raise ValueError("got an unexpected keyword argument '%s'" % key) if isinstance(arg0,dict) and arg0: - graded=kwds.pop("graded", False) + graded = kwds.pop("graded", False) if weights is not None or graded: from .graded_lie_conformal_algebra import \ GradedLieConformalAlgebra diff --git a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py index a4669506314..7581daf0ddb 100644 --- a/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py +++ b/src/sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py @@ -152,15 +152,15 @@ def _standardize_s_coeff(s_coeff, index_set, ce, parity=None): #e.g. v = { 0: { (L,2):3, (G,3):1}, 1:{(L,1),2} } v = s_coeff[mypair] key = tuple(mypair) - vals={} + vals = {} for l in v.keys(): lth_product = {k:y for k,y in v[l].items() if y} if lth_product: - vals[l]=lth_product + vals[l] = lth_product myvals = tuple((k, tuple(v.items())) for k, v in vals.items() if v) - if key in sc.keys() and sorted(sc[key]) != sorted(myvals): + if key in sc and sorted(sc[key]) != sorted(myvals): raise ValueError("two distinct values given for one " "and the same bracket, skew-symmetry" "is not satisfied?") @@ -175,25 +175,25 @@ def _standardize_s_coeff(s_coeff, index_set, ce, parity=None): else: parsgn = 1 maxpole = max(v.keys()) - vals={} + vals = {} for k in range(maxpole+1): kth_product = {} for j in range(maxpole+1-k): if k+j in v.keys(): for i in v[k+j]: if (i[0] not in ce) or ( - i[0] in ce and i[1] + j == 0): - kth_product[(i[0],i[1]+j)] = \ - kth_product.get((i[0], i[1]+j), 0) - kth_product[(i[0],i[1]+j)] += parsgn*\ - v[k+j][i]*(-1)**(k+j+1)*binomial(i[1]+j,j) - kth_product = {k:v for k,v in kth_product.items() if v} + i[0] in ce and i[1] + j == 0): + kth_product[(i[0], i[1] + j)] = \ + kth_product.get((i[0], i[1] + j), 0) + kth_product[(i[0], i[1] + j)] += parsgn *\ + v[k+j][i]*(-1)**(k+j+1)*binomial(i[1]+j,j) + kth_product = {k: v for k, v in kth_product.items() if v} if kth_product: - vals[k]=kth_product + vals[k] = kth_product myvals = tuple((k, tuple(v.items())) for k, v in vals.items() if v) - if key in sc.keys() and sorted(sc[key]) != sorted(myvals): + if key in sc and sorted(sc[key]) != sorted(myvals): raise ValueError("two distinct values given for one " "and the same bracket. " "Skew-symmetry is not satisfied?") @@ -214,7 +214,7 @@ def __init__(self, R, s_coeff, index_set=None, central_elements=None, """ names, index_set = standardize_names_index_set(names,index_set) if central_elements is None: - central_elements= tuple() + central_elements = tuple() if names is not None and names != tuple(index_set): names2 = names + tuple(central_elements) @@ -266,14 +266,14 @@ def __init__(self, R, s_coeff, index_set=None, central_elements=None, category = default_category.or_subcategory(category) if element_class is None: - element_class=LCAStructureCoefficientsElement + element_class = LCAStructureCoefficientsElement FinitelyFreelyGeneratedLCA.__init__( self, R, index_set=index_set, central_elements=central_elements, category=category, element_class=element_class, prefix=prefix, names=names, latex_names=latex_names, **kwds) - s_coeff=dict(s_coeff) + s_coeff = dict(s_coeff) self._s_coeff = Family({k: tuple((j, sum(c*self.monomial(i) for i,c in v )) for j,v in s_coeff[k]) for k in s_coeff}) self._parity = dict(zip(self.gens(),parity+(0,)*len(central_elements))) diff --git a/src/sage/algebras/nil_coxeter_algebra.py b/src/sage/algebras/nil_coxeter_algebra.py index 5d255b9786d..862fdc3b97e 100644 --- a/src/sage/algebras/nil_coxeter_algebra.py +++ b/src/sage/algebras/nil_coxeter_algebra.py @@ -110,16 +110,18 @@ def homogeneous_generator_noncommutative_variables(self, r): 0 sage: U.homogeneous_generator_noncommutative_variables(0) 1 - """ - assert (len(self._cartan_type) == 2 and self._cartan_type[0] in ['A','B']) or (len(self._cartan_type) == 3 and self._cartan_type[2] == 1), "Analogue of symmetric functions in noncommutative variables is not defined in type %s"%(self._cartan_type) + ct = self._cartan_type + msg = f"Analogue of symmetric functions in noncommutative variables is not defined in type {ct}" + assert (len(ct) == 2 and ct[0] in ['A', 'B']) or (len(ct) == 3 and ct[2] == 1), msg if r >= self._n: return self.zero() return self.sum_of_monomials(w for w in self._W.pieri_factors() if w.length() == r) - def homogeneous_noncommutative_variables(self,la): + def homogeneous_noncommutative_variables(self, la): r""" Give the homogeneous function indexed by `la`, viewed inside the Nil-Coxeter algebra. + This is only defined in finite type `A`, `B` and affine types `A^{(1)}`, `B^{(1)}`, `C^{(1)}`, `D^{(1)}`. INPUT: @@ -182,9 +184,9 @@ def k_schur_noncommutative_variables(self, la): """ - assert self._cartan_type[0] == 'A' and len(self._cartan_type) == 3 and self._cartan_type[2] == 1, "%s is not affine type A."%(self._W) - assert la in Partitions(), "%s is not a partition."%(la) - assert (len(la) == 0 or la[0] < self._W.n), "%s is not a %s-bounded partition."%(la, self._W.n-1) + assert self._cartan_type[0] == 'A' and len(self._cartan_type) == 3 and self._cartan_type[2] == 1, "%s is not affine type A." % (self._W) + assert la in Partitions(), "%s is not a partition." % (la) + assert (len(la) == 0 or la[0] < self._W.n), "%s is not a %s-bounded partition." % (la, self._W.n-1) Sym = SymmetricFunctions(self._base_ring) h = Sym.homogeneous() ks = Sym.kschur(self._n-1,1) diff --git a/src/sage/algebras/orlik_solomon.py b/src/sage/algebras/orlik_solomon.py index 52dae24fee3..920056787c6 100644 --- a/src/sage/algebras/orlik_solomon.py +++ b/src/sage/algebras/orlik_solomon.py @@ -502,7 +502,7 @@ def as_gca(self): for j in indices: if j != i: mon *= A.gen(j) - rel += sign *mon + rel += sign * mon sign = -sign rels.append(rel) I = A.ideal(rels) diff --git a/src/sage/algebras/quantum_clifford.py b/src/sage/algebras/quantum_clifford.py index 5079283e8ec..2b85615cf20 100644 --- a/src/sage/algebras/quantum_clifford.py +++ b/src/sage/algebras/quantum_clifford.py @@ -288,14 +288,14 @@ def algebra_generators(self): for i in range(self._n): r = list(zero) # Make a copy r[i] = 1 - d['psi%s'%i] = self.monomial( (self._psi(r), one) ) + d['psi%s' % i] = self.monomial((self._psi(r), one)) r[i] = -1 - d['psid%s'%i] = self.monomial( (self._psi(r), one) ) + d['psid%s' % i] = self.monomial((self._psi(r), one)) zero = self._psi(zero) for i in range(self._n): temp = list(zero) # Make a copy temp[i] = 1 - d['w%s'%i] = self.monomial( (zero, tuple(temp)) ) + d['w%s' % i] = self.monomial((zero, tuple(temp))) return Family(sorted(d), lambda i: d[i]) @cached_method @@ -397,10 +397,10 @@ def _repr_term(self, m): 5 """ p, v = m - rp = '*'.join('psi%s'%i if p[i] > 0 else 'psid%s'%i + rp = '*'.join('psi%s' % i if p[i] > 0 else 'psid%s' % i for i in range(self._n) if p[i] != 0) - gen_str = lambda e: '' if e == 1 else '^%s'%e - rv = '*'.join('w%s'%i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) + gen_str = lambda e: '' if e == 1 else '^%s' % e + rv = '*'.join('w%s' % i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) if rp: if rv: return rp + '*' + rv @@ -429,10 +429,10 @@ def _latex_term(self, m): 5 """ p, v = m - rp = ''.join('\\psi_{%s}'%i if p[i] > 0 else '\\psi^{\\dagger}_{%s}'%i + rp = ''.join('\\psi_{%s}' % i if p[i] > 0 else '\\psi^{\\dagger}_{%s}' % i for i in range(self._n) if p[i] != 0) - gen_str = lambda e: '' if e == 1 else '^{%s}'%e - rv = ''.join('\\omega_{%s}'%i + gen_str(v[i]) + gen_str = lambda e: '' if e == 1 else '^{%s}' % e + rv = ''.join('\\omega_{%s}' % i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) if not rp and not rv: return '1' @@ -700,15 +700,15 @@ def _repr_term(self, m): def ppr(i): val = p[i] if val == -1: - return 'psid%s'%i + return 'psid%s' % i elif val == 1: - return 'psi%s'%i + return 'psi%s' % i elif val == 2: - return 'psi%s*psid%s'%(i,i) + return 'psi%s*psid%s' % (i,i) rp = '*'.join(ppr(i) for i in range(self._n) if p[i] != 0) - gen_str = lambda e: '' if e == 1 else '^%s'%e - rv = '*'.join('w%s'%i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) + gen_str = lambda e: '' if e == 1 else '^%s' % e + rv = '*'.join('w%s' % i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) if rp: if rv: return rp + '*' + rv @@ -741,15 +741,15 @@ def _latex_term(self, m): def ppr(i): val = p[i] if val == -1: - return '\\psi^{\\dagger}_{%s}'%i + return '\\psi^{\\dagger}_{%s}' % i elif val == 1: - return '\\psi_{%s}'%i + return '\\psi_{%s}' % i elif val == 2: return '\\psi_{%s}\\psi^{\\dagger}_{%s}' % (i, i) rp = ''.join(ppr(i) for i in range(self._n) if p[i] != 0) - gen_str = lambda e: '' if e == 1 else '^{%s}'%e - rv = ''.join('\\omega_{%s}'%i + gen_str(v[i]) + gen_str = lambda e: '' if e == 1 else '^{%s}' % e + rv = ''.join('\\omega_{%s}' % i + gen_str(v[i]) for i in range(self._n) if v[i] != 0) if not rp and not rv: return '1' @@ -875,7 +875,7 @@ def key(X): return (self._psi(p), tuple(e)) q = self._q - ret = {key(X): (-1)**len(X) * sign * q**(q_power+k*(len(pairings)%2)) + ret = {key(X): (-1)**len(X) * sign * q**(q_power+k*(len(pairings) % 2)) for X in powerset(pairings)} return self._from_dict(ret) diff --git a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx index 8cb7e848fd0..723c284989e 100644 --- a/src/sage/algebras/quatalg/quaternion_algebra_element.pyx +++ b/src/sage/algebras/quatalg/quaternion_algebra_element.pyx @@ -34,7 +34,6 @@ Check that :trac:`20829` is fixed:: from sage.structure.element cimport AlgebraElement, Element from sage.structure.richcmp cimport rich_to_bool, rich_to_bool_sgn, richcmp_item -from sage.algebras.quatalg.quaternion_algebra_element cimport QuaternionAlgebraElement_abstract from sage.rings.rational cimport Rational from sage.rings.integer cimport Integer from sage.rings.number_field.number_field_element cimport NumberFieldElement diff --git a/src/sage/algebras/splitting_algebra.py b/src/sage/algebras/splitting_algebra.py index 08a4992d48a..3b0dfce4586 100644 --- a/src/sage/algebras/splitting_algebra.py +++ b/src/sage/algebras/splitting_algebra.py @@ -332,10 +332,10 @@ def __init__(self, monic_polynomial, names='X', iterate=True, warning=True): try: cf0_inv = ~(cf[0]) cf0_inv = self(cf0_inv) - verbose("invertible coefficient: %s found" %(cf0_inv)) + verbose("invertible coefficient: %s found" % (cf0_inv)) break except NotImplementedError: - verbose("constant coefficient: %s not invertibe" %(cf0)) + verbose("constant coefficient: %s not invertibe" % (cf0)) # ------------------------------------------------------------------ # assuming that cf splits into linear factors over self diff --git a/src/sage/algebras/steenrod/steenrod_algebra_bases.py b/src/sage/algebras/steenrod/steenrod_algebra_bases.py index f028e6d5df5..c289b284fe1 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra_bases.py +++ b/src/sage/algebras/steenrod/steenrod_algebra_bases.py @@ -834,12 +834,12 @@ def degree_dictionary(n, basis): """ dict = {} if basis.find('wood') >= 0: - k=0 - m=0 + k = 0 + m = 0 deg = 2**m * (2**(k+1) - 1) while deg <= n: dict[deg] = (m,k) - if m>0: + if m > 0: m = m - 1 k = k + 1 else: @@ -847,8 +847,8 @@ def degree_dictionary(n, basis): k = 0 deg = 2**m * (2**(k+1) - 1) elif basis.find('wall') >= 0 or basis.find('arnon') >= 0: - k=0 - m=0 + k = 0 + m = 0 deg = 2**k * (2**(m-k+1) - 1) while deg <= n: dict[deg] = (m,k) @@ -859,8 +859,8 @@ def degree_dictionary(n, basis): k = k - 1 deg = 2**k * (2**(m-k+1) - 1) elif basis.find('pst') >= 0 or basis.find('comm') >= 0: - s=0 - t=1 + s = 0 + t = 1 deg = 2**s * (2**t - 1) while deg <= n: if basis.find('pst') >= 0: @@ -1128,7 +1128,7 @@ def steenrod_basis_error_check(dim, p, **kwds): for i in range(dim): if i % 5 == 0: - verbose("up to dimension %s"%i) + verbose("up to dimension %s" % i) milnor_dim = len(steenrod_algebra_basis.f(i,'milnor',p=p,generic=generic)) for B in bases: if milnor_dim != len(steenrod_algebra_basis.f(i,B,p,generic=generic)): @@ -1147,7 +1147,7 @@ def steenrod_basis_error_check(dim, p, **kwds): for i in range(dim): if i % 5 == 0: - verbose("up to dimension %s"%i) + verbose("up to dimension %s" % i) for pro in profiles: milnor_dim = len(steenrod_algebra_basis.f(i,'milnor',p=p,profile=pro,generic=generic)) for B in bases: diff --git a/src/sage/algebras/steenrod/steenrod_algebra_misc.py b/src/sage/algebras/steenrod/steenrod_algebra_misc.py index d8fedad70b8..91ab657a84f 100644 --- a/src/sage/algebras/steenrod/steenrod_algebra_misc.py +++ b/src/sage/algebras/steenrod/steenrod_algebra_misc.py @@ -177,7 +177,7 @@ def get_basis_name(basis, p, generic=None): if basis.find('long') >= 0: result = result + '_long' else: - gencase = " for the generic Steenrod algebra" if p==2 and generic else "" + gencase = " for the generic Steenrod algebra" if p == 2 and generic else "" raise ValueError("%s is not a recognized basis%s at the prime %s" % (basis, gencase, p)) return result diff --git a/src/sage/algebras/yokonuma_hecke_algebra.py b/src/sage/algebras/yokonuma_hecke_algebra.py index 700395a2d84..df474b8d4f7 100644 --- a/src/sage/algebras/yokonuma_hecke_algebra.py +++ b/src/sage/algebras/yokonuma_hecke_algebra.py @@ -183,7 +183,7 @@ def _latex_(self): sage: latex(Y) \mathcal{Y}_{5,2}(q) """ - return "\\mathcal{Y}_{%s,%s}(%s)"%(self._d, self._n, self._q) + return "\\mathcal{Y}_{%s,%s}(%s)" % (self._d, self._n, self._q) def _repr_term(self, m): """ @@ -195,8 +195,8 @@ def _repr_term(self, m): sage: Y._repr_term( ((1, 0, 2), Permutation([3,2,1])) ) 't1*t3^2*g[2,1,2]' """ - gen_str = lambda e: '' if e == 1 else '^%s'%e - lhs = '*'.join('t%s'%(j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) + gen_str = lambda e: '' if e == 1 else '^%s' % e + lhs = '*'.join('t%s' % (j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) redword = m[1].reduced_word() if not redword: if not lhs: @@ -217,14 +217,14 @@ def _latex_term(self, m): sage: Y._latex_term( ((1, 0, 2), Permutation([3,2,1])) ) 't_{1} t_{3}^2 g_{2} g_{1} g_{2}' """ - gen_str = lambda e: '' if e == 1 else '^%s'%e - lhs = ' '.join('t_{%s}'%(j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) + gen_str = lambda e: '' if e == 1 else '^%s' % e + lhs = ' '.join('t_{%s}' % (j+1) + gen_str(i) for j,i in enumerate(m[0]) if i > 0) redword = m[1].reduced_word() if not redword: if not lhs: return '1' return lhs - return lhs + ' ' + ' '.join("g_{%d}"%i for i in redword) + return lhs + ' ' + ' '.join("g_{%d}" % i for i in redword) @cached_method def algebra_generators(self): @@ -243,10 +243,10 @@ def algebra_generators(self): for i in range(self._n): r = list(zero) # Make a copy r[i] = 1 - d['t%s'%(i+1)] = self.monomial( (tuple(r), one) ) + d['t%s' % (i+1)] = self.monomial( (tuple(r), one) ) G = self._Pn.group_generators() for i in range(1, self._n): - d['g%s'%i] = self.monomial( (tuple(zero), G[i]) ) + d['g%s' % i] = self.monomial( (tuple(zero), G[i]) ) return Family(sorted(d), lambda i: d[i]) @cached_method @@ -323,8 +323,8 @@ def g(self, i=None): """ G = self.algebra_generators() if i is None: - return [G['g%s'%i] for i in range(1, self._n)] - return G['g%s'%i] + return [G['g%s' % i] for i in range(1, self._n)] + return G['g%s' % i] def t(self, i=None): """ @@ -345,8 +345,8 @@ def t(self, i=None): """ G = self.algebra_generators() if i is None: - return [G['t%s'%i] for i in range(1, self._n+1)] - return G['t%s'%i] + return [G['t%s' % i] for i in range(1, self._n+1)] + return G['t%s' % i] def product_on_basis(self, m1, m2): """ @@ -488,7 +488,7 @@ def __invert__(self): if not self: raise ZeroDivisionError if len(self) != 1: - raise NotImplementedError("inverse only implemented for basis elements (monomials in the generators)"%self) + raise NotImplementedError("inverse only implemented for basis elements (monomials in the generators)" % self) H = self.parent() t,w = self.support_of_term() c = ~self.coefficients()[0] diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd index 3e57e15c98a..0031a0ae337 100644 --- a/src/sage/arith/long.pxd +++ b/src/sage/arith/long.pxd @@ -17,8 +17,6 @@ Fast conversion of Python objects to C long from libc.limits cimport LONG_MIN, LONG_MAX from cpython.object cimport Py_SIZE -from cpython.int cimport PyInt_AS_LONG -from cpython.long cimport PyLong_AsLong from cpython.number cimport PyNumber_Index, PyIndex_Check from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit @@ -84,7 +82,7 @@ cdef enum: cdef inline bint integer_check_long(x, long* value, int* err) except -1: """ Return whether ``x`` is some integer type. This is true for the - Python types ``int`` and ``long``, for Sage Integers and for types + Python type ``int``, for Sage Integers and for types implementing ``__index__``. If possible, compute the value of this integer as C long and store diff --git a/src/sage/combinat/designs/bibd.py b/src/sage/combinat/designs/bibd.py index e484070c4e8..ed44883be25 100644 --- a/src/sage/combinat/designs/bibd.py +++ b/src/sage/combinat/designs/bibd.py @@ -1048,6 +1048,7 @@ def _PBD_4_5_8_9_12_closure(B): BB.append(X) return BB + table_7_1 = { 0:{'t':-4,'u':16,'s':2}, 1:{'t':-4,'u':17,'s':2}, @@ -1652,4 +1653,5 @@ def arc(self, s=2, solver=None, verbose=0, *, integrality_tolerance=1e-3): values = p.get_values(b, convert=bool, tolerance=integrality_tolerance) return [self._points[i] for (i,j) in values.items() if j] + BIBD = BalancedIncompleteBlockDesign diff --git a/src/sage/combinat/designs/database.py b/src/sage/combinat/designs/database.py index ebefb6bc669..5302771756c 100644 --- a/src/sage/combinat/designs/database.py +++ b/src/sage/combinat/designs/database.py @@ -296,6 +296,7 @@ def MOLS_18_3(): # # This dictionary is used by designs.mutually_orthogonal_latin_squares(k,n). + MOLS_constructions = { 10 : (2, MOLS_10_2), 12 : (5, MOLS_12_5), @@ -2021,6 +2022,7 @@ def OA_10_1620(): # # This dictionary is used by designs.orthogonal_array(k,n). + OA_constructions = { 18 : (7 , OA_7_18), 40 : (9 , OA_9_40), @@ -2455,6 +2457,7 @@ def QDM_57_9_1_1_8(): # } # } + QDM: dict[tuple[int, int], dict] = {} for ((n,k,lmbda,mu,u),f) in [((19,6,1,1,1), QDM_19_6_1_1_1), ((21,5,1,1,1), QDM_21_5_1_1_1), @@ -4018,6 +4021,7 @@ def DM_993_32_1(): G = AdditiveCyclic(993) return G, M + DM = { (12 ,1) : (6 ,DM_12_6_1), (21 ,1) : (6 ,DM_21_6_1), @@ -4686,6 +4690,7 @@ def BIBD_56_11_2(): D = IncidenceStructure(libgap.Orbit(G, B, libgap.OnSets)) return D._blocks + # Index of the BIBD constructions # # Associates to triple (v,k,lambda) a function that return a diff --git a/src/sage/combinat/designs/difference_family.py b/src/sage/combinat/designs/difference_family.py index 382240627ab..6745985adec 100644 --- a/src/sage/combinat/designs/difference_family.py +++ b/src/sage/combinat/designs/difference_family.py @@ -3606,6 +3606,7 @@ def difference_family(v, k, l=1, existence=False, explain_construction=False, ch return G, D + from sage.misc.rest_index_of_methods import gen_rest_table_index import sys __doc__ = __doc__.format(INDEX_OF_FUNCTIONS=gen_rest_table_index(sys.modules[__name__])) diff --git a/src/sage/combinat/designs/ext_rep.py b/src/sage/combinat/designs/ext_rep.py index cc2f13687a0..0f5bdf339fa 100644 --- a/src/sage/combinat/designs/ext_rep.py +++ b/src/sage/combinat/designs/ext_rep.py @@ -565,6 +565,7 @@ def open_extrep_url(url): else: return f.read() + pattern_integer = re.compile(r'\d+$') pattern_decimal = re.compile(r'-?\d+\.\d+$') pattern_rational = re.compile(r'-?\d+/\d+$') diff --git a/src/sage/combinat/dyck_word.py b/src/sage/combinat/dyck_word.py index a6620735321..80911865d49 100644 --- a/src/sage/combinat/dyck_word.py +++ b/src/sage/combinat/dyck_word.py @@ -539,7 +539,7 @@ def _repr_lattice(self, type=None, labelling=None, underpath=True) -> str: final_fall = " " else: final_fall = " _" + "__" * (length_of_final_fall - 1) - row = " "*(n - alst[-1] - 1) + final_fall + "\n" + row = " " * (n - alst[-1] - 1) + final_fall + "\n" for i in range(n - 1): c = 0 row = row + " "*(n-i-2-alst[-i-2]) @@ -1982,23 +1982,30 @@ def number_of_parking_functions(self) -> int: from sage.arith.misc import multinomial return multinomial(self.rise_composition()) - def list_parking_functions(self): + def list_parking_functions(self) -> list: r""" Return all parking functions whose supporting Dyck path is ``self``. EXAMPLES:: sage: DyckWord([1,1,0,0,1,0]).list_parking_functions() - Permutations of the multi-set [1, 1, 3] - sage: DyckWord([1,1,1,0,0,0]).list_parking_functions() - Permutations of the multi-set [1, 1, 1] - sage: DyckWord([1,0,1,0,1,0]).list_parking_functions() - Standard permutations of 3 + [[1, 1, 3], [1, 3, 1], [3, 1, 1]] """ + return list(self.parking_functions()) + + def parking_functions(self): + r""" + Iterate over parking functions whose supporting Dyck path is ``self``. + + EXAMPLES:: + + sage: list(DyckWord([1,1,0,1,0,0]).parking_functions()) + [[1, 1, 2], [1, 2, 1], [2, 1, 1]] + """ + from sage.combinat.parking_functions import ParkingFunction alist = self._area_sequence_iter() - return Permutations([i - ai + 1 for i, ai in enumerate(alist)]) - # TODO: upon implementation of ParkingFunction class - # map(ParkingFunction, Permutations([i - alist[i]+1 for i in range(len(alist))])) + for pi in Permutations([i - ai + 1 for i, ai in enumerate(alist)]): + yield ParkingFunction(pi) def reading_permutation(self) -> Permutation: r""" diff --git a/src/sage/combinat/parking_functions.py b/src/sage/combinat/parking_functions.py index bd67b573238..d356cedb2b7 100644 --- a/src/sage/combinat/parking_functions.py +++ b/src/sage/combinat/parking_functions.py @@ -222,11 +222,17 @@ def __init__(self, parent, lst): sage: type(b) + + Some checks for more general inputs:: + + sage: PF = ParkingFunction((1, 1, 2, 2, 5, 6)) + sage: PF = ParkingFunction(Permutation([4,2,3,1])) """ - if isinstance(lst, ParkingFunction): - lst = list(lst) if not isinstance(lst, list): - raise TypeError('input must be a list') + try: + lst = list(lst) + except TypeError: + raise TypeError('input must be convertible to a list') if parent is None: parent = ParkingFunctions_n(len(lst)) ClonableArray.__init__(self, parent, lst) diff --git a/src/sage/combinat/ribbon_tableau.py b/src/sage/combinat/ribbon_tableau.py index 65b9b7079cd..843626c4752 100644 --- a/src/sage/combinat/ribbon_tableau.py +++ b/src/sage/combinat/ribbon_tableau.py @@ -1083,7 +1083,9 @@ def __contains__(self, x): return all(xi.is_semistandard() for xi in x) def __iter__(self): - """ + r""" + Iterate over ``self``. + EXAMPLES:: sage: sp = SkewPartitions(3).list() @@ -1098,6 +1100,21 @@ def __iter__(self): 34 sage: RibbonTableaux(a,weight,k).cardinality() 34 + + TESTS: + + Check that :issue:`36196` is fixed:: + + sage: shapes = [[[1], [0]], [[1], [0]], [[1], [0]]] + sage: weight = [1, 1, 1] + sage: SMST = SemistandardMultiSkewTableaux(shapes, weight) + sage: list(SMST) + [[[[1]], [[2]], [[3]]], + [[[2]], [[1]], [[3]]], + [[[1]], [[3]], [[2]]], + [[[2]], [[3]], [[1]]], + [[[3]], [[1]], [[2]]], + [[[3]], [[2]], [[1]]]] """ parts = self._shape mu = self._weight @@ -1122,9 +1139,12 @@ def __iter__(self): S = SkewTableaux() for lk in l: pos = 0 # Double check this - restmp = [S.from_shape_and_word(parts[0], [lk[j] for j in range(s[0])])] + lk = list(lk) + w = lk[:s[0]] + restmp = [S.from_shape_and_word(parts[0], w)] for i in range(1, len(parts)): - w = [lk[j] for j in range(pos + s[i - 1], pos + s[i - 1] + s[i])] + pos += s[i-1] + w = lk[pos: pos + s[i]] restmp.append(S.from_shape_and_word(parts[i], w)) yield self.element_class(self, restmp) diff --git a/src/sage/data_structures/bounded_integer_sequences.pyx b/src/sage/data_structures/bounded_integer_sequences.pyx index 7e3846470c0..907f9b4298a 100644 --- a/src/sage/data_structures/bounded_integer_sequences.pyx +++ b/src/sage/data_structures/bounded_integer_sequences.pyx @@ -110,7 +110,7 @@ AUTHORS: from cysignals.signals cimport sig_check, sig_on, sig_off from sage.data_structures.bitset_base cimport * -from cpython.int cimport PyInt_FromSize_t +from cpython.long cimport PyLong_FromSize_t from cpython.slice cimport PySlice_GetIndicesEx from sage.libs.flint.flint cimport FLINT_BIT_COUNT as BIT_COUNT from sage.structure.richcmp cimport richcmp_not_equal, rich_to_bool @@ -295,7 +295,7 @@ cdef biseq_getitem_py(biseq_t S, mp_size_t index): """ cdef size_t out = biseq_getitem(S, index) - return PyInt_FromSize_t(out) + return PyLong_FromSize_t(out) cdef inline void biseq_inititem(biseq_t S, mp_size_t index, size_t item): """ diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx index 1de6dedab82..b95130b19dd 100644 --- a/src/sage/ext/memory.pyx +++ b/src/sage/ext/memory.pyx @@ -3,14 +3,14 @@ Low-level memory allocation functions TESTS: -Check that a ``MemoryError`` is raised if we try to allocate a +Check that an error is raised if we try to allocate a ridiculously large integer, see :trac:`15363`:: - sage: 2^(2^63-3) - Traceback (most recent call last): - ... - OverflowError: exponent must be at most 2147483647 # 32-bit - RuntimeError: Aborted # 64-bit + sage: try: + ....: 2^(2^63-3) + ....: except (OverflowError, RuntimeError, FloatingPointError): + ....: print ('Overflow error') + ...Overflow error AUTHORS: diff --git a/src/sage/geometry/hyperplane_arrangement/library.py b/src/sage/geometry/hyperplane_arrangement/library.py index 83c4f80c325..4ec9f9fdbdf 100644 --- a/src/sage/geometry/hyperplane_arrangement/library.py +++ b/src/sage/geometry/hyperplane_arrangement/library.py @@ -5,12 +5,12 @@ :mod:`sage.geometry.hyperplane_arrangement.arrangement` for details about how to construct your own hyperplane arrangements. """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2013 David Perkinson # # Distributed under the terms of the GNU General Public License (GPL) -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.graphs.graph_generators import graphs from sage.matrix.constructor import matrix, random_matrix @@ -233,6 +233,86 @@ def coordinate(self, n, K=QQ, names=None): x = H.gens() return H(x) + def Coxeter(self, data, K=QQ, names=None): + r""" + Return the Coxeter arrangement. + + This generalizes the braid arrangements to crystallographic + root systems. + + INPUT: + + - ``data`` -- either an integer or a Cartan type (or coercible + into; see "CartanType") + + - ``K`` -- field (default:``QQ``) + + - ``names`` -- tuple of strings or ``None`` (default); the + variable names for the ambient space + + OUTPUT: + + - If ``data`` is an integer `n`, return the braid arrangement in + dimension `n`, i.e. the set of `n(n-1)` hyperplanes: + `\{ x_i - x_j = 0,1 : 1 \leq i \leq j \leq n \}`. This corresponds + to the Coxeter arrangement of Cartan type `A_{n-1}`. + + - If ``data`` is a Cartan type, return the Coxeter arrangement of given + type. + + The Coxeter arrangement of a given crystallographic + Cartan type is defined by the inner products + `\langle a,x \rangle = 0` where + `a \in \Phi^+` runs over positive roots of the root system `\Phi`. + + EXAMPLES:: + + sage: # needs sage.combinat + sage: hyperplane_arrangements.Coxeter(4) + Arrangement of 6 hyperplanes of dimension 4 and rank 3 + sage: hyperplane_arrangements.Coxeter("B4") + Arrangement of 16 hyperplanes of dimension 4 and rank 4 + sage: hyperplane_arrangements.Coxeter("A3") + Arrangement of 6 hyperplanes of dimension 4 and rank 3 + + If the Cartan type is not crystallographic, the Coxeter arrangement + is not implemented yet:: + + sage: hyperplane_arrangements.Coxeter("H3") + Traceback (most recent call last): + ... + NotImplementedError: Coxeter arrangements are not implemented for non crystallographic Cartan types + + The characteristic polynomial is pre-computed using the results + of Terao, see [Ath2000]_:: + + sage: # needs sage.combinat + sage: hyperplane_arrangements.Coxeter("A3").characteristic_polynomial() + x^3 - 6*x^2 + 11*x - 6 + """ + from sage.combinat.root_system.weyl_group import WeylGroup + if data in NN: + cartan_type = CartanType(["A", data - 1]) + else: + cartan_type = CartanType(data) + if not cartan_type.is_crystallographic(): + raise NotImplementedError("Coxeter arrangements are not implemented for non crystallographic Cartan types") + W = WeylGroup(cartan_type) + Ra = RootSystem(cartan_type).ambient_space() + PR = Ra.positive_roots() + d = Ra.dimension() + H = make_parent(K, d, names) + x = H.gens() + hyperplanes = [] + + for a in PR: + hyperplanes.append(sum(a[j] * x[j] for j in range(d))) + A = H(*hyperplanes) + x = polygen(QQ, 'x') + charpoly = prod(x - d + 1 for d in W.degrees()) + A.characteristic_polynomial.set_cache(charpoly) + return A + def G_semiorder(self, G, K=QQ, names=None): r""" Return the semiorder hyperplane arrangement of a graph. @@ -699,7 +779,7 @@ def Shi(self, data, K=QQ, names=None, m=1): x^3 - 54*x^2 + 972*x - 5832 """ if data in NN: - cartan_type = CartanType(["A",data-1]) + cartan_type = CartanType(["A", data - 1]) else: cartan_type = CartanType(data) if not cartan_type.is_crystallographic(): @@ -722,4 +802,5 @@ def Shi(self, data, K=QQ, names=None, m=1): A.characteristic_polynomial.set_cache(charpoly) return A + hyperplane_arrangements = HyperplaneArrangementLibrary() diff --git a/src/sage/geometry/triangulation/triangulations.cc b/src/sage/geometry/triangulation/triangulations.cc index 68e4efa75e1..8ea306d8f7c 100644 --- a/src/sage/geometry/triangulation/triangulations.cc +++ b/src/sage/geometry/triangulation/triangulations.cc @@ -117,7 +117,7 @@ triangulations_ptr init_triangulations compact_simplices seed; for (int i=0; inext_triangulation(); PyObject* py_triang = PyTuple_New(triang.size()); for (size_t i=0; i -#define PyInt_FromLong PyLong_FromLong -#define PyInt_AsLong PyLong_AsLong -#define PyInt_AS_LONG PyLong_AS_LONG class triangulations: public std::vector { diff --git a/src/sage/graphs/base/boost_graph.pyx b/src/sage/graphs/base/boost_graph.pyx index ff222837117..72e1353339e 100644 --- a/src/sage/graphs/base/boost_graph.pyx +++ b/src/sage/graphs/base/boost_graph.pyx @@ -561,7 +561,7 @@ cpdef bandwidth_heuristics(g, algorithm='cuthill_mckee'): Given a wrong algorithm:: - from sage.graphs.base.boost_graph import bandwidth_heuristics + sage: from sage.graphs.base.boost_graph import bandwidth_heuristics sage: bandwidth_heuristics(graphs.PathGraph(3), algorithm='tip top') Traceback (most recent call last): ... @@ -569,7 +569,7 @@ cpdef bandwidth_heuristics(g, algorithm='cuthill_mckee'): Given a graph with no edges:: - from sage.graphs.base.boost_graph import bandwidth_heuristics + sage: from sage.graphs.base.boost_graph import bandwidth_heuristics sage: bandwidth_heuristics(Graph()) (0, []) sage: bandwidth_heuristics(graphs.RandomGNM(10,0)) # needs networkx diff --git a/src/sage/graphs/comparability.pyx b/src/sage/graphs/comparability.pyx index 119cd892265..405b4ace2ff 100644 --- a/src/sage/graphs/comparability.pyx +++ b/src/sage/graphs/comparability.pyx @@ -677,7 +677,6 @@ def is_permutation(g, algorithm="greedy", certificate=False, check=True, ....: break """ - from sage.graphs.comparability import is_comparability if certificate: # First poset, we stop if it fails diff --git a/src/sage/graphs/digraph.py b/src/sage/graphs/digraph.py index a8e6e9997b1..d30d5e63efa 100644 --- a/src/sage/graphs/digraph.py +++ b/src/sage/graphs/digraph.py @@ -84,7 +84,6 @@ :meth:`~DiGraph.strongly_connected_components_subgraphs` | Return the strongly connected components as a list of subgraphs. :meth:`~DiGraph.strongly_connected_component_containing_vertex` | Return the strongly connected component containing a given vertex :meth:`~DiGraph.strongly_connected_components` | Return the list of strongly connected components. - :meth:`~DiGraph.immediate_dominators` | Return the immediate dominators of all vertices reachable from `root`. :meth:`~DiGraph.strong_articulation_points` | Return the strong articulation points of this digraph. diff --git a/src/sage/graphs/generators/chessboard.py b/src/sage/graphs/generators/chessboard.py index 59517d128bb..dfe5b15b273 100644 --- a/src/sage/graphs/generators/chessboard.py +++ b/src/sage/graphs/generators/chessboard.py @@ -4,11 +4,11 @@ The methods defined here appear in :mod:`sage.graphs.graph_generators`. -- :meth:`BishopGraph ` -- :meth:`KingGraph ` -- :meth:`KnightGraph ` -- :meth:`QueenGraph ` -- :meth:`RookGraph ` +- :meth:`BishopGraph ` +- :meth:`KingGraph ` +- :meth:`KnightGraph ` +- :meth:`QueenGraph ` +- :meth:`RookGraph ` AUTHORS: diff --git a/src/sage/graphs/generators/smallgraphs.py b/src/sage/graphs/generators/smallgraphs.py index bb73e4c487e..a090eb3f73d 100644 --- a/src/sage/graphs/generators/smallgraphs.py +++ b/src/sage/graphs/generators/smallgraphs.py @@ -912,7 +912,7 @@ def Balaban11Cage(embedding=1): sage: g3 = graphs.Balaban11Cage(embedding=3) # needs networkx sage: g1.show(figsize=[10,10]) # long time # needs sage.plot sage: g2.show(figsize=[10,10]) # long time # needs networkx sage.plot - sage: g3.show(figsize=[10,10]) # long time # needs sage.plot + sage: g3.show(figsize=[10,10]) # long time # needs networkx sage.plot Proof that the embeddings are the same graph:: diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 2deb533f7f1..1a205d6de34 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -5399,7 +5399,8 @@ def is_planar(self, on_embedding=None, kuratowski=False, set_embedding=False, se sage: k43 = graphs.CompleteBipartiteGraph(4, 3) sage: result = k43.is_planar(kuratowski=True); result - (False, Graph on 6 vertices) + (False, + Kuratowski subgraph of (Complete bipartite graph of order 4+3): Graph on 6 vertices) sage: result[1].is_isomorphic(graphs.CompleteBipartiteGraph(3, 3)) True @@ -5412,19 +5413,61 @@ def is_planar(self, on_embedding=None, kuratowski=False, set_embedding=False, se Traceback (most recent call last): ... NotImplementedError: cannot compute with embeddings of - multiple-edged or looped graphs + multiple-edged or looped graphs + sage: G.is_planar(set_embedding=True) + Traceback (most recent call last): + ... + NotImplementedError: cannot compute with embeddings of + multiple-edged or looped graphs + sage: G.is_planar(kuratowski=True) + (True, None) sage: G.is_planar(set_pos=True) + True + sage: sorted(G.get_pos().items()) + [(0, [0, 0]), (1, [0, 1])] + + Digraphs with multiple edges or loops or pairs of opposite arcs are + partially supported (:trac:`35152`):: + + sage: D = digraphs.Complete(3) + sage: D.is_planar() + True + sage: D.is_planar(set_pos=True) + True + sage: sorted(D.get_pos().items()) + [(0, [0, 1]), (1, [1, 1]), (2, [1, 0])] + sage: D.is_planar(on_embedding={}) Traceback (most recent call last): ... NotImplementedError: cannot compute with embeddings of - multiple-edged or looped graphs - sage: G.is_planar(set_embedding=True) + digraphs with pairs of opposite arcs + sage: D.is_planar(set_embedding=True) Traceback (most recent call last): ... NotImplementedError: cannot compute with embeddings of - multiple-edged or looped graphs - sage: G.is_planar(kuratowski=True) + digraphs with pairs of opposite arcs + sage: D.is_planar(kuratowski=True) (True, None) + sage: D.allow_multiple_edges(True) + sage: D.add_edges(D.edges(sort=False)) + sage: D.allow_loops(True) + sage: D.add_edges((u, u) for u in D) + sage: D.is_planar() + True + sage: D.is_planar(kuratowski=True) + (True, None) + sage: D.is_planar(set_pos=True) + True + sage: D.is_planar(set_embedding=True) + Traceback (most recent call last): + ... + NotImplementedError: cannot compute with embeddings of + multiple-edged or looped graphs + sage: D.is_planar(on_embedding={}) + Traceback (most recent call last): + ... + NotImplementedError: cannot compute with embeddings of + multiple-edged or looped graphs :: @@ -5485,31 +5528,35 @@ def is_planar(self, on_embedding=None, kuratowski=False, set_embedding=False, se if self.order() > 4 and self.size() > 3 * self.order() - 6: return False - if self.has_multiple_edges() or self.has_loops(): - if set_embedding or (on_embedding is not None) or set_pos: + if set_embedding or (on_embedding is not None): + # So far, working with embeddings is not working properly when a + # (di)graph has multiple edges or loops, or when a digraph has pairs + # of opposite arcs + if self.has_multiple_edges() or self.has_loops(): raise NotImplementedError("cannot compute with embeddings of multiple-edged or looped graphs") - else: - return self.to_simple().is_planar(kuratowski=kuratowski) + elif (self.is_directed() and + any(self.has_edge(v, u) for u, v in self.edge_iterator(labels=False))): + raise NotImplementedError("cannot compute with embeddings of digraphs with pairs of opposite arcs") if on_embedding is not None: self._check_embedding_validity(on_embedding, boolean=False) return (0 == self.genus(minimal=False, set_embedding=False, on_embedding=on_embedding)) + + # We take the underlying undirected and simple graph + G = self.to_simple(to_undirected=True, immutable=False) + # And check if it is planar + from sage.graphs.planarity import is_planar + planar = is_planar(G, kuratowski=kuratowski, set_pos=set_pos, set_embedding=set_embedding) + if kuratowski: + bool_result = planar[0] else: - from sage.graphs.planarity import is_planar - G = self.to_undirected() - if hasattr(G, '_immutable'): - G = copy(G) - planar = is_planar(G, kuratowski=kuratowski, set_pos=set_pos, set_embedding=set_embedding) - if kuratowski: - bool_result = planar[0] - else: - bool_result = planar - if bool_result: - if set_pos: - self._pos = G._pos - if set_embedding: - self._embedding = G._embedding - return planar + bool_result = planar + if bool_result: + if set_pos: + self._pos = G._pos + if set_embedding: + self._embedding = G._embedding + return planar def is_circular_planar(self, on_embedding=None, kuratowski=False, set_embedding=True, boundary=None, @@ -5591,7 +5638,7 @@ def is_circular_planar(self, on_embedding=None, kuratowski=False, sage: g439.is_circular_planar(boundary=[1, 2, 3, 4]) False sage: g439.is_circular_planar(kuratowski=True, boundary=[1, 2, 3, 4]) - (False, Graph on 8 vertices) + (False, Kuratowski subgraph of (): Graph on 8 vertices) sage: g439.is_circular_planar(kuratowski=True, boundary=[1, 2, 3]) (True, None) sage: g439.get_embedding() diff --git a/src/sage/graphs/graph_plot.py b/src/sage/graphs/graph_plot.py index 0a7dbb81fc6..7908454db54 100644 --- a/src/sage/graphs/graph_plot.py +++ b/src/sage/graphs/graph_plot.py @@ -168,8 +168,7 @@ 'Which graphviz layout program to use -- one of ' '"circo", "dot", "fdp", "neato", or "twopi".', 'by_component': - 'Whether to do the spring layout by connected component -- a boolean.', - } + 'Whether to do the spring layout by connected component -- a boolean.'} graphplot_options = layout_options.copy() @@ -225,8 +224,7 @@ 'graph_border': 'Whether or not to draw a frame around the graph.', 'edge_labels_background': - 'The color of the background of the edge labels.', - }) + 'The color of the background of the edge labels.'}) _PLOT_OPTIONS_TABLE = "" @@ -235,9 +233,7 @@ __doc__ = __doc__.format(PLOT_OPTIONS_TABLE=_PLOT_OPTIONS_TABLE) -DEFAULT_SHOW_OPTIONS = { - 'figsize' : (4, 4) - } +DEFAULT_SHOW_OPTIONS = {'figsize': (4, 4)} DEFAULT_PLOT_OPTIONS = { 'vertex_size' : 200, @@ -258,8 +254,7 @@ 'dist' : .075, 'max_dist' : 1.5, 'loop_size' : .075, - 'edge_labels_background' : 'white' - } + 'edge_labels_background' : 'white'} class GraphPlot(SageObject): @@ -582,7 +577,7 @@ def set_edges(self, **edge_options): Set edge plotting parameters for the ``GraphPlot`` object. This function is called by the constructor but can also be called to - update the vertex options of an existing ``GraphPlot`` object. + update the edge options of an existing ``GraphPlot`` object. Note that the changes are cumulative. EXAMPLES:: @@ -719,8 +714,8 @@ def set_edges(self, **edge_options): if 'edge_style' in self._options: from sage.plot.misc import get_matplotlib_linestyle eoptions['linestyle'] = get_matplotlib_linestyle( - self._options['edge_style'], - return_type='long') + self._options['edge_style'], + return_type='long') if 'edge_thickness' in self._options: eoptions['thickness'] = self._options['edge_thickness'] @@ -832,20 +827,20 @@ def set_edges(self, **edge_options): # Compute perpendicular bisector p1 = self._pos[a] p2 = self._pos[b] - m = ((p1[0] + p2[0])/2., (p1[1] + p2[1])/2.) # midpoint + m = ((p1[0] + p2[0]) / 2., (p1[1] + p2[1]) / 2.) # midpoint if not p1[1] == p2[1]: - s = (p1[0] - p2[0])/(p2[1] - p1[1]) # perp slope + s = (p1[0] - p2[0]) / (p2[1] - p1[1]) # perp slope def y(x): - return s*(x - m[0]) + m[1] # perp bisector line + return s * (x - m[0]) + m[1] # perp bisector line # f, g are functions to determine x-values of point # on line y at distance d from point m (on each side) def f(d): - return sqrt(d**2/(1. + s**2)) + m[0] + return sqrt(d**2 / (1. + s**2)) + m[0] def g(d): - return -sqrt(d**2/(1. + s**2)) + m[0] + return -sqrt(d**2 / (1. + s**2)) + m[0] odd_x = f even_x = g @@ -897,31 +892,31 @@ def even_xy(d): even_end = ph(even_xy(k), p2, vr)[1] self._plot_components['edges'].append( arrow(path=[[odd_start, odd_xy(k), odd_end]], - head=local_labels[2*i][2], zorder=1, - rgbcolor=local_labels[2*i][1], + head=local_labels[2 * i][2], zorder=1, + rgbcolor=local_labels[2 * i][1], **eoptions)) self._plot_components['edges'].append( arrow(path=[[even_start, even_xy(k), even_end]], - head=local_labels[2*i + 1][2], zorder=1, - rgbcolor=local_labels[2*i + 1][1], + head=local_labels[2 * i + 1][2], zorder=1, + rgbcolor=local_labels[2 * i + 1][1], **eoptions)) else: self._plot_components['edges'].append( bezier_path([[p1, odd_xy(k), p2]], zorder=1, - rgbcolor=local_labels[2*i][1], + rgbcolor=local_labels[2 * i][1], **eoptions)) self._plot_components['edges'].append( bezier_path([[p1, even_xy(k), p2]], zorder=1, - rgbcolor=local_labels[2*i + 1][1], + rgbcolor=local_labels[2 * i + 1][1], **eoptions)) if labels: j = k / 2.0 bg = self._options['edge_labels_background'] self._plot_components['edge_labels'].append( - text(local_labels[2*i][0], odd_xy(j), + text(local_labels[2 * i][0], odd_xy(j), background_color=bg)) self._plot_components['edge_labels'].append( - text(local_labels[2*i + 1][0], even_xy(j), + text(local_labels[2 * i + 1][0], even_xy(j), background_color=bg)) if len_local_labels % 2: # draw line for last odd @@ -941,7 +936,7 @@ def even_xy(d): bg = self._options['edge_labels_background'] self._plot_components['edge_labels'].append( text(str(edges_to_draw[a, b][0][0]), - [(C[0] + D[0])/2., (C[1] + D[1])/2.], + [(C[0] + D[0]) / 2., (C[1] + D[1]) / 2.], background_color=bg)) elif is_directed: self._plot_components['edges'].append( @@ -959,8 +954,8 @@ def even_xy(d): bg = self._options['edge_labels_background'] self._plot_components['edge_labels'].append( text(str(edges_to_draw[a, b][0][0]), - [(self._pos[a][0] + self._pos[b][0])/2., - (self._pos[a][1] + self._pos[b][1])/2.], + [(self._pos[a][0] + self._pos[b][0]) / 2., + (self._pos[a][1] + self._pos[b][1]) / 2.], background_color=bg)) def _polar_hack_for_multidigraph(self, A, B, VR): @@ -991,7 +986,6 @@ def _polar_hack_for_multidigraph(self, A, B, VR): sage: GP._polar_hack_for_multidigraph((int(0), int(1)), ....: (int(2), int(2)), .1) ([0.08..., 1.04...], [1.91..., 1.95...]) - """ D = [float(B[i] - A[i]) for i in range(2)] R = sqrt(D[0]**2 + D[1]**2) @@ -1415,7 +1409,7 @@ def plot(self, **kwds): sage: p = graphs.PetersenGraph().plot(egabrag='garbage') Traceback (most recent call last): ... - ValueError: Invalid input 'egabrag=garbage' + ValueError: invalid input 'egabrag=garbage' Make sure that no graphics primitive is clipped:: @@ -1441,7 +1435,7 @@ def plot(self, **kwds): # Check the arguments for o in options: if o not in graphplot_options and o not in G._extra_kwds: - raise ValueError("Invalid input '{}={}'".format(o, options[o])) + raise ValueError("invalid input '{}={}'".format(o, options[o])) for comp in self._plot_components.values(): if not isinstance(comp, list): @@ -1488,13 +1482,12 @@ def layout_tree(self, root, orientation): sage: T = Graph() sage: T.add_edges(G.min_spanning_tree(starting_vertex=0)) sage: T.show(layout='tree', tree_root=0) # indirect doctest - """ T = self._graph if not self._graph.is_tree(): - raise RuntimeError("Cannot use tree layout on this graph: " - "self.is_tree() returns False.") + raise RuntimeError("cannot use tree layout on this graph: " + "self.is_tree() returns False") children = {root: T.neighbors(root)} @@ -1544,7 +1537,7 @@ def slide(v, dx): if x < ox: slide(p, ox - x) x = ox - obstruction[y] = x+1 + obstruction[y] = x + 1 continue t = C.pop() diff --git a/src/sage/graphs/isgci.py b/src/sage/graphs/isgci.py index 147e2ba2778..e19c4a8103e 100644 --- a/src/sage/graphs/isgci.py +++ b/src/sage/graphs/isgci.py @@ -135,28 +135,28 @@ * - Apex - - :meth:`~Graph.is_apex()`, - :meth:`~Graph.apex_vertices()` + - :meth:`~sage.graphs.graph.Graph.is_apex`, + :meth:`~sage.graphs.graph.Graph.apex_vertices` * - AT_free - - :meth:`~Graph.is_asteroidal_triple_free` + - :meth:`~sage.graphs.graph.Graph.is_asteroidal_triple_free` * - Biconnected - - :meth:`~Graph.is_biconnected`, - :meth:`~GenericGraph.blocks_and_cut_vertices`, - :meth:`~GenericGraph.blocks_and_cuts_tree` + - :meth:`~sage.graphs.graph.Graph.is_biconnected`, + :meth:`~sage.graphs.generic_graph.GenericGraph.blocks_and_cut_vertices`, + :meth:`~sage.graphs.generic_graph.GenericGraph.blocks_and_cuts_tree` * - BinaryTrees - :meth:`~sage.graphs.graph_generators.GraphGenerators.BalancedTree`, - :meth:`~Graph.is_tree` + :meth:`~sage.graphs.graph.Graph.is_tree` * - Bipartite - :meth:`~sage.graphs.graph_generators.GraphGenerators.BalancedTree`, - :meth:`~sage.graphs.graph.Graph.is_bipartite` + :meth:`~sage.graphs.generic_graph.GenericGraph.is_bipartite` * - Block @@ -212,7 +212,7 @@ * - Polyhedral - - :meth:`~sage.graphs.generic_graph.Graph.is_polyhedral` + - :meth:`~sage.graphs.graph.Graph.is_polyhedral` * - Split diff --git a/src/sage/graphs/planarity.pyx b/src/sage/graphs/planarity.pyx index 206095f00b2..1088a7659de 100644 --- a/src/sage/graphs/planarity.pyx +++ b/src/sage/graphs/planarity.pyx @@ -96,6 +96,7 @@ def is_planar(g, kuratowski=False, set_pos=False, set_embedding=False): ....: assert (hasattr(G, '_pos') and G._pos is not None) == set_pos, (set_embedding, set_pos) """ + g._scream_if_not_simple() if set_pos and not g.is_connected(): raise ValueError("is_planar() cannot set vertex positions for a disconnected graph") @@ -118,9 +119,8 @@ def is_planar(g, kuratowski=False, set_pos=False, set_embedding=False): # (planarity 3 uses 1-based array indexing, with 0 representing NIL) cdef int i cdef list listto = list(g) - cdef dict ffrom = {vvv: i + 1 for i, vvv in enumerate(listto)} - cdef dict to = {i + 1: vvv for i, vvv in enumerate(listto)} - g.relabel(ffrom) + cdef dict ffrom = {vvv: i for i, vvv in enumerate(listto, start=1)} + cdef dict to = {i: vvv for i, vvv in enumerate(listto, start=1)} cdef graphP theGraph theGraph = gp_New() @@ -129,7 +129,7 @@ def is_planar(g, kuratowski=False, set_pos=False, set_embedding=False): if status != OK: raise RuntimeError("gp_InitGraph status is not ok") for u, v in g.edge_iterator(labels=False): - status = gp_AddEdge(theGraph, u, 0, v, 0) + status = gp_AddEdge(theGraph, ffrom[u], 0, ffrom[v], 0) if status == NOTOK: raise RuntimeError("gp_AddEdge status is not ok") elif status == NONEMBEDDABLE: @@ -141,15 +141,16 @@ def is_planar(g, kuratowski=False, set_pos=False, set_embedding=False): break status = gp_Embed(theGraph, EMBEDFLAGS_PLANAR) - gp_SortVertices(theGraph) - - # Use to and from mappings to relabel vertices back from the set {1,...,n} - g.relabel(to) if status == NOTOK: raise RuntimeError("status is not ok") - elif status == NONEMBEDDABLE: + + gp_SortVertices(theGraph) + + if status == NONEMBEDDABLE: # Kuratowski subgraph isolator + if not kuratowski: + return False g_dict = {} from sage.graphs.graph import Graph for i in range(1, theGraph.N + 1): @@ -160,29 +161,30 @@ def is_planar(g, kuratowski=False, set_pos=False, set_embedding=False): j = theGraph.E[j].link[1] if linked_list: g_dict[to[i]] = linked_list - G = Graph(g_dict) gp_Free(&theGraph) - if kuratowski: - return (False, G) - else: - return False - else: - if set_pos or set_embedding: - emb_dict = {} - for i in range(1, theGraph.N + 1): - linked_list = [] - j = theGraph.V[i].link[1] - while j: - linked_list.append(to[theGraph.E[j].neighbor]) - j = theGraph.E[j].link[1] - emb_dict[to[i]] = linked_list - if set_embedding: - g._embedding = emb_dict - if set_pos: - g.layout(layout='planar', save_pos=True, on_embedding=emb_dict) + G = g.__class__(data=g_dict, weighted=g._weighted, + loops=g.allows_loops(), + multiedges=g.allows_multiple_edges(), + name="Kuratowski subgraph of (%s)" % g.name()) + if g.get_pos(): + G.set_pos({u: g._pos[u] for u in g_dict}) + return (False, G) + + if set_pos or set_embedding: + emb_dict = {} + for i in range(1, theGraph.N + 1): + linked_list = [] + j = theGraph.V[i].link[1] + while j: + linked_list.append(to[theGraph.E[j].neighbor]) + j = theGraph.E[j].link[1] + emb_dict[to[i]] = linked_list + if set_embedding: + g._embedding = emb_dict + if set_pos: + g.layout(layout='planar', save_pos=True, on_embedding=emb_dict) - gp_Free(&theGraph) - if kuratowski: - return (True, None) - else: - return True + gp_Free(&theGraph) + if kuratowski: + return (True, None) + return True diff --git a/src/sage/graphs/strongly_regular_db.pyx b/src/sage/graphs/strongly_regular_db.pyx index ae7eee6f4ea..8f9f37d196f 100644 --- a/src/sage/graphs/strongly_regular_db.pyx +++ b/src/sage/graphs/strongly_regular_db.pyx @@ -2649,7 +2649,6 @@ def SRG_126_50_13_24(): sage: G.is_strongly_regular(parameters=True) (126, 50, 13, 24) """ - from sage.graphs.strongly_regular_db import SRG_175_72_20_36 from sage.graphs.generators.smallgraphs import HoffmanSingletonGraph hs = HoffmanSingletonGraph() s = set(hs.vertices(sort=False)).difference(hs.neighbors(0) + [0]) diff --git a/src/sage/groups/abelian_gps/abelian_group.py b/src/sage/groups/abelian_gps/abelian_group.py index efa54bac7d1..f2d088adbf4 100644 --- a/src/sage/groups/abelian_gps/abelian_group.py +++ b/src/sage/groups/abelian_gps/abelian_group.py @@ -1880,5 +1880,6 @@ def gen(self, n): """ return self._gens[n] + # We allow subclasses to override this, analogous to Element AbelianGroup_class.Subgroup = AbelianGroup_subgroup diff --git a/src/sage/groups/artin.py b/src/sage/groups/artin.py index 0e91205c8e1..617852bacc6 100644 --- a/src/sage/groups/artin.py +++ b/src/sage/groups/artin.py @@ -12,7 +12,7 @@ - Travis Scrimshaw (2018-02-05): Initial version """ -#**************************************************************************** +# **************************************************************************** # Copyright (C) 2018 Travis Scrimshaw # # This program is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # http://www.gnu.org/licenses/ -#***************************************************************************** +# ***************************************************************************** from sage.misc.cachefunc import cached_method from sage.groups.free_group import FreeGroup @@ -103,26 +103,55 @@ def coxeter_group_element(self, W=None): Return the corresponding Coxeter group element under the natural projection. + INPUT: + + - ``W`` -- (default: ``self.parent().coxeter_group()``) the image Coxeter group + OUTPUT: - A permutation. + An element of the Coxeter group ``W``. EXAMPLES:: - sage: A. = ArtinGroup(['B',3]) + sage: B. = ArtinGroup(['B',3]) sage: b = s1 * s2 / s3 / s2 - sage: b.coxeter_group_element() + sage: b1 = b.coxeter_group_element(); b1 [ 1 -1 0] [ 2 -1 0] [ a -a 1] sage: b.coxeter_group_element().reduced_word() [1, 2, 3, 2] + sage: A. = ArtinGroup(['A',3]) + sage: c = s1 * s2 *s3 + sage: c1 = c.coxeter_group_element(); c1 + [4, 1, 2, 3] + sage: c1.reduced_word() + [3, 2, 1] + sage: c.coxeter_group_element(W=SymmetricGroup(4)) + (1,4,3,2) + sage: A. = BraidGroup(4) + sage: c = s1 * s2 * s3^-1 + sage: c0 = c.coxeter_group_element(); c0 + [4, 1, 2, 3] + sage: c1 = c.coxeter_group_element(W=SymmetricGroup(4)); c1 + (1,4,3,2) + + From an element of the Coxeter group it is possible to recover + the image by the standard section to the Artin group:: + + sage: B(b1) + s1*s2*s3*s2 + sage: A(c0) + s1*s2*s3 + sage: A(c0) == A(c1) + True """ if W is None: W = self.parent().coxeter_group() s = W.simple_reflections() - I = W.index_set() - return W.prod(s[I[abs(i)-1]] for i in self.Tietze()) + In = W.index_set() + return W.prod(s[In[abs(i)-1]] for i in self.Tietze()) + class FiniteTypeArtinGroupElement(ArtinGroupElement): """ @@ -208,7 +237,7 @@ def left_normal_form(self): sage: B = BraidGroup(4) sage: b = B([1, 2, 3, -1, 2, -3]) sage: b.left_normal_form() - (s0^-1*s1^-1*s2^-1*s0^-1*s1^-1*s0^-1, s0*s1*s2*s1*s0, s0*s2*s1) + (s0^-1*s1^-1*s0^-1*s2^-1*s1^-1*s0^-1, s0*s1*s2*s1*s0, s0*s2*s1) sage: c = B([1]) sage: c.left_normal_form() (1, s0) @@ -257,11 +286,11 @@ def _left_normal_form_coxeter(self): delta = 0 Delta = self.parent().coxeter_group().long_element() sr = self.parent().coxeter_group().simple_reflections() - l = self.Tietze() - if l == (): + tz = self.Tietze() + if tz == (): return (0,) form = [] - for i in l: + for i in tz: if i > 0: form.append(sr[i]) else: @@ -294,6 +323,7 @@ def _left_normal_form_coxeter(self): delta -= 1 return tuple([-delta] + form) + class ArtinGroup(FinitelyPresentedGroup): r""" An Artin group. @@ -437,12 +467,12 @@ def __init__(self, coxeter_matrix, names): rels = [] # Generate the relations based on the Coxeter graph I = coxeter_matrix.index_set() - for ii,i in enumerate(I): - for j in I[ii+1:]: - m = coxeter_matrix[i,j] + for ii, i in enumerate(I): + for j in I[ii + 1:]: + m = coxeter_matrix[i, j] if m == Infinity: # no relation continue - elt = [i,j]*m + elt = [i, j] * m for ind in range(m, 2*m): elt[ind] = -elt[ind] rels.append(free_group(elt)) @@ -610,7 +640,7 @@ def some_elements(self): rank = self.coxeter_matrix().rank() elements_list = [self.gen(0)] elements_list.append(self.prod(self.gens())) - elements_list.append(elements_list[-1] ** min(rank,3)) + elements_list.append(elements_list[-1] ** min(rank, 3)) return elements_list def _standard_lift_Tietze(self, w): @@ -649,7 +679,7 @@ def _standard_lift(self, w): sage: B = BraidGroup(5) sage: P = Permutation([5, 3, 1, 2, 4]) sage: B._standard_lift(P) - s0*s1*s0*s2*s1*s3 + s0*s1*s2*s3*s0*s1 """ return self(self._standard_lift_Tietze(w)) @@ -711,7 +741,7 @@ def delta(self): sage: B = BraidGroup(5) sage: B.delta() - s0*s1*s0*s2*s1*s0*s3*s2*s1*s0 + s0*s1*s2*s3*s0*s1*s2*s0*s1*s0 """ return self._standard_lift(self._coxeter_group.long_element()) diff --git a/src/sage/groups/braid.py b/src/sage/groups/braid.py index f4ad632b332..acc89d5a5e5 100644 --- a/src/sage/groups/braid.py +++ b/src/sage/groups/braid.py @@ -67,27 +67,32 @@ # https://www.gnu.org/licenses/ ############################################################################## -from sage.rings.integer import Integer -from sage.rings.integer_ring import IntegerRing +from itertools import combinations +from sage.categories.action import Action +from sage.categories.groups import Groups +from sage.combinat.permutation import Permutation +from sage.combinat.permutation import Permutations +from sage.combinat.subset import Subsets +from sage.features import PythonModule +from sage.groups.artin import FiniteTypeArtinGroup, FiniteTypeArtinGroupElement +from sage.groups.finitely_presented import FinitelyPresentedGroup +from sage.groups.finitely_presented import GroupMorphismWithGensImages +from sage.groups.free_group import FreeGroup, is_FreeGroup +from sage.functions.generalized import sign +from sage.groups.perm_gps.permgroup_named import SymmetricGroup +from sage.groups.perm_gps.permgroup_named import SymmetricGroupElement +from sage.knots.knot import Knot +from sage.libs.gap.libgap import libgap +from sage.matrix.constructor import identity_matrix, matrix from sage.misc.lazy_attribute import lazy_attribute from sage.misc.lazy_import import lazy_import from sage.misc.cachefunc import cached_method from sage.misc.misc_c import prod -from sage.categories.groups import Groups -from sage.groups.free_group import FreeGroup, is_FreeGroup -from sage.groups.perm_gps.permgroup_named import SymmetricGroup +from sage.rings.integer import Integer +from sage.rings.integer_ring import IntegerRing from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing -from sage.matrix.constructor import identity_matrix, matrix -from sage.combinat.permutation import Permutations -from sage.combinat.subset import Subsets -from sage.categories.action import Action -from sage.knots.knot import Knot from sage.sets.set import Set -from sage.groups.finitely_presented import FinitelyPresentedGroup -from sage.groups.artin import FiniteTypeArtinGroup, FiniteTypeArtinGroupElement from sage.structure.richcmp import richcmp, rich_to_bool -from sage.features import PythonModule - lazy_import('sage.libs.braiding', ['leftnormalform', 'rightnormalform', 'centralizer', 'supersummitset', 'greatestcommondivisor', @@ -446,11 +451,20 @@ def permutation(self, W=None): sage: B. = BraidGroup() sage: S = SymmetricGroup(4) sage: b = s0*s1/s2/s1 - sage: b.permutation(W=S) + sage: c0 = b.permutation(W=S); c0 (1,4,2) - sage: c = b.permutation(W=Permutations(4)); c + sage: c1 = b.permutation(W=Permutations(4)); c1 [4, 1, 3, 2] - sage: c == b.permutation() + sage: c1 == b.permutation() + True + + The canonical section from the symmetric group to the braid group + (sending a permutation to its associated permutation braid) + can be recovered:: + + sage: B(c0) + s0*s1*s2*s1 + sage: B(c0) == B(c1) True """ return self.coxeter_group_element(W) @@ -864,8 +878,8 @@ def links_gould_polynomial(self, varnames=None, use_symbolics=False): varnames = 't0, t1' rep = self.parent()._links_gould_representation(symbolics=use_symbolics) - l = len(rep) - mu = rep[l-1] # quantum trace factor + ln = len(rep) + mu = rep[ln - 1] # quantum trace factor M = mu * self.links_gould_matrix(symbolics=use_symbolics) d1, d2 = M.dimensions() e = d1//4 @@ -873,13 +887,13 @@ def links_gould_polynomial(self, varnames=None, use_symbolics=False): R = LaurentPolynomialRing(ZZ, varnames) # partial quantum trace according to I. Marin section 2.5 - part_trace = matrix(B, 4, 4, lambda i, j: sum(M[e*i+ k, e*j+k] for k in range(e))) - ptemp = part_trace[0,0] # part_trace == psymb*M.parent().one() + part_trace = matrix(B, 4, 4, lambda i, j: sum(M[e * i + k, e * j + k] for k in range(e))) + ptemp = part_trace[0, 0] # part_trace == psymb*M.parent().one() if use_symbolics: v1, v2 = R.variable_names() pstr = str(ptemp._sympy_().simplify()) pstr = pstr.replace('t0', v1).replace('t1', v2) - F = R.fraction_field() # to make coercion work + F = R.fraction_field() # to make coercion work return R(F(pstr)) else: ltemp = ptemp.lift().constant_coefficient() @@ -1322,8 +1336,6 @@ def _annular_khovanov_complex_cached(self, qagrad, ring=None): sage: B = BraidGroup(3) sage: B([1,2,1,2])._annular_khovanov_complex_cached((5,-1)).homology() {1: Z, 2: Z, 3: 0} - - """ from sage.homology.chain_complex import ChainComplex if ring is None: @@ -1492,7 +1504,7 @@ def left_normal_form(self, algorithm='libbraiding'): (1,) sage: b = B([-2, 2, -4, -4, 4, -5, -1, 4, -1, 1]) sage: L1 = b.left_normal_form(); L1 - (s0^-1*s1^-1*s2^-1*s3^-1*s4^-1*s0^-1*s1^-1*s2^-1*s3^-1*s0^-1*s1^-1*s2^-1*s0^-1*s1^-1*s0^-1, + (s0^-1*s1^-1*s0^-1*s2^-1*s1^-1*s0^-1*s3^-1*s2^-1*s1^-1*s0^-1*s4^-1*s3^-1*s2^-1*s1^-1*s0^-1, s0*s2*s1*s0*s3*s2*s1*s0*s4*s3*s2*s1, s3) sage: L1 == b.left_normal_form() @@ -1500,8 +1512,8 @@ def left_normal_form(self, algorithm='libbraiding'): sage: B([1]).left_normal_form(algorithm='artin') (1, s0) sage: B([-3]).left_normal_form(algorithm='artin') - (s0^-1*s1^-1*s2^-1*s3^-1*s4^-1*s0^-1*s1^-1*s2^-1*s3^-1*s0^-1*s1^-1*s2^-1*s0^-1*s1^-1*s0^-1, - s0*s1*s0*s2*s1*s3*s2*s1*s0*s4*s3*s2*s1*s0) + (s0^-1*s1^-1*s0^-1*s2^-1*s1^-1*s0^-1*s3^-1*s2^-1*s1^-1*s0^-1*s4^-1*s3^-1*s2^-1*s1^-1*s0^-1, + s0*s1*s2*s3*s4*s0*s1*s2*s3*s1*s2*s0*s1*s0) sage: B = BraidGroup(3) sage: B([1,2,-1]).left_normal_form() (s0^-1*s1^-1*s0^-1, s1*s0, s0*s1) @@ -1509,9 +1521,9 @@ def left_normal_form(self, algorithm='libbraiding'): (s0*s1*s0,) """ if algorithm == 'libbraiding': - l = leftnormalform(self) + lnf = leftnormalform(self) B = self.parent() - return tuple([B.delta()**l[0][0]] + [B(b) for b in l[1:]] ) + return tuple([B.delta()**lnf[0][0]] + [B(b) for b in lnf[1:]]) elif algorithm == 'artin': return FiniteTypeArtinGroupElement.left_normal_form.f(self) raise ValueError("invalid algorithm") @@ -1552,11 +1564,11 @@ def _left_normal_form_coxeter(self): delta = 0 Delta = self.parent()._coxeter_group.long_element() sr = self.parent()._coxeter_group.simple_reflections() - l = self.Tietze() - if not l: + tz = self.Tietze() + if not tz: return (0,) form = [] - for i in l: + for i in tz: if i > 0: form.append(sr[i]) else: @@ -1604,9 +1616,9 @@ def right_normal_form(self): sage: b.right_normal_form() (s1*s0, s0*s2, 1) """ - l = rightnormalform(self) + rnf = rightnormalform(self) B = self.parent() - return tuple([B(b) for b in l[:-1]] + [B.delta()**l[-1][0]]) + return tuple([B(b) for b in rnf[:-1]] + [B.delta()**rnf[-1][0]]) def centralizer(self): """ @@ -1620,9 +1632,9 @@ def centralizer(self): [s1*s0*s2*s1, s0*s2] """ - l = centralizer(self) + c = centralizer(self) B = self.parent() - return [B._element_from_libbraiding(b) for b in l] + return [B._element_from_libbraiding(b) for b in c] def super_summit_set(self): """ @@ -1639,9 +1651,9 @@ def super_summit_set(self): s0^-1*s1^-1*s0^-2*s1^-1*s0*s1^3*s0] """ - l = supersummitset(self) + sss = supersummitset(self) B = self.parent() - return [B._element_from_libbraiding(b) for b in l] + return [B._element_from_libbraiding(b) for b in sss] def gcd(self, other): """ @@ -1742,13 +1754,13 @@ def conjugating_braid(self, other): sage: c.conjugating_braid(b) is None True """ - l = conjugatingbraid(self, other) - if not l: + cb = conjugatingbraid(self, other) + if not cb: return None else: B = self.parent() - l[0][0] %= 2 - return B._element_from_libbraiding(l) + cb[0][0] %= 2 + return B._element_from_libbraiding(cb) def is_conjugated(self, other): """ @@ -1769,8 +1781,8 @@ def is_conjugated(self, other): sage: c.is_conjugated(b) False """ - l = conjugatingbraid(self, other) - return bool(l) + cb = conjugatingbraid(self, other) + return bool(cb) def pure_conjugating_braid(self, other): r""" @@ -1857,7 +1869,7 @@ def pure_conjugating_braid(self, other): if p3 not in S.subgroup(LP): return None P = p3.word_problem(list(LP), display=False, as_list=True) - b1 = prod(LP[S(a)] ** b for a,b in P) + b1 = prod(LP[S(a)] ** b for a, b in P) b0 = b1 * b0 n0 = len(b0.Tietze()) L = leftnormalform(b0) @@ -2110,19 +2122,19 @@ def deformed_burau_matrix(self, variab='q'): """ R = LaurentPolynomialRing(IntegerRing(), variab) n = self.strands() - m = len(self.Tietze()) + tz = self.Tietze() + m = len(tz) from sage.algebras.free_algebra import FreeAlgebra - alg = FreeAlgebra(R, m*3, [f'{s}p_{i}' - for i in range(m) if self.Tietze()[i] > 0 - for s in 'bca'] - + [f'{s}m_{i}' - for i in range(m) if self.Tietze()[i] < 0 - for s in 'bca']) - gen_indices = ([i for i in range(m) if self.Tietze()[i] > 0] - + [i for i in range(m) if self.Tietze()[i] < 0]) + alg = FreeAlgebra(R, m*3, + [f'{s}p_{i}' for i in range(m) if tz[i] > 0 + for s in 'bca'] + + [f'{s}m_{i}' for i in range(m) if tz[i] < 0 + for s in 'bca']) + gen_indices = ([i for i in range(m) if tz[i] > 0] + + [i for i in range(m) if tz[i] < 0]) M = identity_matrix(alg, n) - for k, i in enumerate(self.Tietze()): + for k, i in enumerate(tz): A = identity_matrix(alg, n) gen_index = gen_indices.index(k) b, c, a = alg.gens()[3*gen_index:3*gen_index+3] @@ -2469,8 +2481,8 @@ def eps_monom(q_tuple): ret_q *= prod(prod(1 - q**(N - 1 - q_tuple[3*i + 1] - h) for h in range(q_tuple[3*i + 2])) for i in range(self._minus_begin//3)) - ret_q *= prod(prod(1 - q**(q_tuple[3*j + 1] + l + 1 - N) - for l in range(q_tuple[3*j + 2])) + ret_q *= prod(prod(1 - q**(q_tuple[3*j + 1] + k + 1 - N) + for k in range(q_tuple[3*j + 2])) for j in range(self._minus_begin//3, len(q_tuple)//3)) return ret_q @@ -2678,7 +2690,14 @@ def _element_constructor_(self, x): sage: B = BraidGroup(4) sage: B([1, 2, 3]) # indirect doctest s0*s1*s2 - """ + sage: p = Permutation([3,1,2,4]); B(p) + s0*s1 + sage: q = SymmetricGroup(4)((1,2)); B(q) + s0 + """ + if not isinstance(x, (tuple, list)): + if isinstance(x, (SymmetricGroupElement, Permutation)): + x = self._standard_lift_Tietze(x) return self.element_class(self, x) def an_element(self): @@ -2732,7 +2751,7 @@ def _standard_lift_Tietze(self, p): OUTPUT: - The lexicographically smallest word that represents the braid, + A shortest word that represents the braid, in Tietze list form. EXAMPLES:: @@ -2740,22 +2759,11 @@ def _standard_lift_Tietze(self, p): sage: B = BraidGroup(5) sage: P = Permutation([5, 3, 1, 2, 4]) sage: B._standard_lift_Tietze(P) - (1, 2, 1, 3, 2, 4) - """ - if not p.length(): - return () - pl = p - l = [] - while pl.length(): - i = 1 - while i < max(pl): - if pl(i) > pl(i+1): - l.append(i) - pl = self._coxeter_group.simple_reflection(i) * pl - i = 1 - else: - i += 1 - return tuple(l) + (1, 2, 3, 4, 1, 2) + """ + G = SymmetricGroup(self.strands()) + pl = G(p) + return tuple(pl.reduced_word()) @cached_method def _links_gould_representation(self, symbolics=False): @@ -2788,7 +2796,7 @@ def _links_gould_representation(self, symbolics=False): """ from sage.matrix.constructor import matrix n = self.strands() - d = 4 # dimension of the natural module + d = 4 # dimension of the natural module from sage.matrix.special import diagonal_matrix if symbolics: from sage.symbolic.ring import SR as BR @@ -2805,7 +2813,7 @@ def _links_gould_representation(self, symbolics=False): LR = LaurentPolynomialRing(ZZ, 's0r, s1r') PR = PolynomialRing(LR, 'Yr') s0r, s1r, Yr = PR.gens_dict_recursive().values() - pqr = Yr**2 + (s0r**2-1)*(s1r**2 -1) + pqr = Yr**2 + (s0r**2 - 1) * (s1r**2 - 1) BR = PR.quotient_ring(pqr) s0 = BR(s0r) s1 = BR(s1r) @@ -2819,12 +2827,12 @@ def _links_gould_representation(self, symbolics=False): if n == 2: # R-Matrix taken from I. Marin R = matrix(BR, {(0, 0): t0, (1, 4): s0, (2, 8): s0, (3, 12): 1, - (4, 1): s0, (4, 4): t0 - 1, (5, 5): -1, (6, 6): t0*t1 - 1, - (6, 9): -s0*s1, (6, 12): -Y*s0*s1, (7, 13): s1, (8, 2): s0, - (8, 8): t0 - 1, (9, 6): -s0*s1, (9, 12): Y, (10, 10): -1, - (11, 14): s1, (12, 3): 1, (12, 6): -Y*s0*s1, (12, 9): Y, - (12, 12): -(t0 - 1)*(t1 - 1), (13, 7): s1, (13, 13): t1 - 1, - (14, 11): s1, (14, 14): t1 - 1, (15, 15): t1}, sparse=sparse) + (4, 1): s0, (4, 4): t0 - 1, (5, 5): -1, (6, 6): t0*t1 - 1, + (6, 9): -s0*s1, (6, 12): -Y*s0*s1, (7, 13): s1, (8, 2): s0, + (8, 8): t0 - 1, (9, 6): -s0*s1, (9, 12): Y, (10, 10): -1, + (11, 14): s1, (12, 3): 1, (12, 6): -Y*s0*s1, (12, 9): Y, + (12, 12): -(t0 - 1)*(t1 - 1), (13, 7): s1, (13, 13): t1 - 1, + (14, 11): s1, (14, 14): t1 - 1, (15, 15): t1}, sparse=sparse) RI = (~t0 + ~t1)*(1 + R) - ~t0*~t1*(R + R**2) - 1 # quantum trace operator on two fold tensor space @@ -2901,58 +2909,58 @@ def _LKB_matrix_(self, braid, variab): for i in braid[1:]: A = A*self._LKB_matrix_((i,), variab) return A - l = list(Set(range(n)).subsets(2)) + n2 = [set(X) for X in combinations(range(n), 2)] R = LaurentPolynomialRing(IntegerRing(), variab) q = R.gens()[0] t = R.gens()[1] if not braid: - return identity_matrix(R, len(l), sparse=True) - A = matrix(R, len(l), sparse=True) + return identity_matrix(R, len(n2), sparse=True) + A = matrix(R, len(n2), sparse=True) if braid[0] > 0: - i = braid[0]-1 - for m in range(len(l)): - j = min(l[m]) - k = max(l[m]) + i = braid[0] - 1 + for m in range(len(n2)): + j = min(n2[m]) + k = max(n2[m]) if i == j-1: - A[l.index(Set([i, k])), m] = q - A[l.index(Set([i, j])), m] = q*q-q - A[l.index(Set([j, k])), m] = 1-q + A[n2.index(Set([i, k])), m] = q + A[n2.index(Set([i, j])), m] = q*q-q + A[n2.index(Set([j, k])), m] = 1-q elif i == j and not j == k-1: - A[l.index(Set([j, k])), m] = 0 - A[l.index(Set([j+1, k])), m] = 1 + A[n2.index(Set([j, k])), m] = 0 + A[n2.index(Set([j+1, k])), m] = 1 elif k-1 == i and not k-1 == j: - A[l.index(Set([j, i])), m] = q - A[l.index(Set([j, k])), m] = 1-q - A[l.index(Set([i, k])), m] = (1-q)*q*t + A[n2.index(Set([j, i])), m] = q + A[n2.index(Set([j, k])), m] = 1-q + A[n2.index(Set([i, k])), m] = (1-q)*q*t elif i == k: - A[l.index(Set([j, k])), m] = 0 - A[l.index(Set([j, k+1])), m] = 1 + A[n2.index(Set([j, k])), m] = 0 + A[n2.index(Set([j, k+1])), m] = 1 elif i == j and j == k-1: - A[l.index(Set([j, k])), m] = -t*q*q + A[n2.index(Set([j, k])), m] = -t*q*q else: - A[l.index(Set([j, k])), m] = 1 + A[n2.index(Set([j, k])), m] = 1 return A else: i = -braid[0]-1 - for m in range(len(l)): - j = min(l[m]) - k = max(l[m]) + for m in range(len(n2)): + j = min(n2[m]) + k = max(n2[m]) if i == j-1: - A[l.index(Set([j-1, k])), m] = 1 + A[n2.index(Set([j-1, k])), m] = 1 elif i == j and not j == k-1: - A[l.index(Set([j+1, k])), m] = q**(-1) - A[l.index(Set([j, k])), m] = 1-q**(-1) - A[l.index(Set([j, j+1])), m] = t**(-1)*q**(-1)-t**(-1)*q**(-2) + A[n2.index(Set([j+1, k])), m] = q**(-1) + A[n2.index(Set([j, k])), m] = 1-q**(-1) + A[n2.index(Set([j, j+1])), m] = t**(-1)*q**(-1)-t**(-1)*q**(-2) elif k-1 == i and not k-1 == j: - A[l.index(Set([j, k-1])), m] = 1 + A[n2.index(Set([j, k-1])), m] = 1 elif i == k: - A[l.index(Set([j, k+1])), m] = q**(-1) - A[l.index(Set([j, k])), m] = 1-q**(-1) - A[l.index(Set([k, k+1])), m] = -q**(-1)+q**(-2) + A[n2.index(Set([j, k+1])), m] = q**(-1) + A[n2.index(Set([j, k])), m] = 1-q**(-1) + A[n2.index(Set([k, k+1])), m] = -q**(-1)+q**(-2) elif i == j and j == k-1: - A[l.index(Set([j, k])), m] = -t**(-1)*q**(-2) + A[n2.index(Set([j, k])), m] = -t**(-1)*q**(-2) else: - A[l.index(Set([j, k])), m] = 1 + A[n2.index(Set([j, k])), m] = 1 return A def dimension_of_TL_space(self, drain_size): @@ -3364,7 +3372,7 @@ def _element_from_libbraiding(self, nf): sage: B = BraidGroup(5) sage: B._element_from_libbraiding([[-2], [2, 1], [1, 2], [2, 1]]) - (s0^-1*s1^-1*s2^-1*s3^-1*s0^-1*s1^-1*s2^-1*s0^-1*s1^-1*s0^-1)^2*s1*s0^2*s1^2*s0 + (s0^-1*s1^-1*s0^-1*s2^-1*s1^-1*s0^-1*s3^-1*s2^-1*s1^-1*s0^-1)^2*s1*s0^2*s1^2*s0 sage: B._element_from_libbraiding([[0]]) 1 """ @@ -3397,6 +3405,96 @@ def mirror_involution(self): gens_mirr = [~g for g in self.gens()] return self.hom(gens_mirr, check=False) + def presentation_two_generators(self, isomorphisms=False): + r""" + Construct a finitely presented group isomorphic to ``self`` with only two generators. + + INPUT: + + - ``isomorphism`` -- boolean (default ``False``); if ``True``, then an isomorphism + from ``self`` and the isomorphic group and its inverse is also returned + + EXAMPLES:: + + sage: B = BraidGroup(3) + sage: B.presentation_two_generators() + Finitely presented group < x0, x1 | x1^3*x0^-2 > + sage: B = BraidGroup(4) + sage: G, hom1, hom2 = B.presentation_two_generators(isomorphisms=True) + sage: G + Finitely presented group < x0, x1 | x1^4*x0^-3, x0*x1*x0*x1^-2*x0^-1*x1^3*x0^-1*x1^-2 > + sage: hom1(B.gen(0)) + x0*x1^-1 + sage: hom1(B.gen(1)) + x1*x0*x1^-2 + sage: hom1(B.gen(2)) + x1^2*x0*x1^-3 + sage: all(hom2(hom1(a)) == a for a in B.gens()) + True + sage: all(hom2(a) == B.one() for a in G.relations()) + True + """ + n = self.strands() + F = FreeGroup(2, "x") + rel = [n * (2,) + (n - 1) * (-1,)] + rel += [(1,) + (j - 1) * (2,) + (1,) + j * (-2,) + (-1,) + (j + 1) * (2,) + (-1,) + j * (-2,) + for j in range(2, n - 1)] + G = F / rel + if not isomorphisms: + return G + a1 = (1, -2) + L1 = [j * (2,) + a1 + j * (-2,) for j in range(n - 1)] + h1 = self.hom(codomain=G, im_gens=[G(a) for a in L1], check=False) + a2 = tuple(range(1, n)) + L2 = [(1,) + a2, a2] + h2 = G.hom(codomain=self, im_gens=[self(a) for a in L2], check=False) + return (G, h1, h2) + + def epimorphisms(self, H): + r""" + Return the epimorphisms from ``self`` to ``H``, up to automorphism of `H` passing + through the :meth:`two generator presentation + ` of ``self``. + + INPUT: + + - `H` -- another group + + EXAMPLES:: + + sage: B = BraidGroup(5) + sage: B.epimorphisms(SymmetricGroup(5)) + [Generic morphism: + From: Braid group on 5 strands + To: Symmetric group of order 5! as a permutation group + Defn: s0 |--> (1,5) + s1 |--> (4,5) + s2 |--> (3,4) + s3 |--> (2,3)] + + ALGORITHM: + + Uses libgap's GQuotients function. + """ + G, hom1, hom2 = self.presentation_two_generators(isomorphisms=True) + from sage.misc.misc_c import prod + HomSpace = self.Hom(H) + G0g = libgap(self) + Gg = libgap(G) + Hg = libgap(H) + gquotients = Gg.GQuotients(Hg) + hom1g = libgap.GroupHomomorphismByImagesNC(G0g, Gg, [libgap(hom1(u)) for u in self.gens()]) + g0quotients = [hom1g * h for h in gquotients] + res = [] + # the following closure is needed to attach a specific value of quo to + # each function in the different morphisms + fmap = lambda tup: (lambda a: H(prod(tup[abs(i)-1]**sign(i) for i in a.Tietze()))) + for quo in g0quotients: + tup = tuple(H(quo.ImageElm(i.gap()).sage()) for i in self.gens()) + fhom = GroupMorphismWithGensImages(HomSpace, fmap(tup)) + res.append(fhom) + return res + def BraidGroup(n=None, names='s'): """ diff --git a/src/sage/groups/matrix_gps/morphism.py b/src/sage/groups/matrix_gps/morphism.py index 9805161d016..e2fc2e0fd59 100644 --- a/src/sage/groups/matrix_gps/morphism.py +++ b/src/sage/groups/matrix_gps/morphism.py @@ -42,6 +42,7 @@ def to_libgap(x): from sage.libs.gap.libgap import libgap return libgap(x) + lazy_import('sage.groups.libgap_morphism', 'GroupMorphism_libgap', 'MatrixGroupMorphism_im_gens', deprecation=25444) diff --git a/src/sage/groups/perm_gps/cubegroup.py b/src/sage/groups/perm_gps/cubegroup.py index e23d072de58..c27ed7521dd 100644 --- a/src/sage/groups/perm_gps/cubegroup.py +++ b/src/sage/groups/perm_gps/cubegroup.py @@ -295,6 +295,7 @@ def create_poly(face, color): #################################################### + singmaster_indices = { 1: "ulb", 2: "ub", @@ -1180,6 +1181,7 @@ def cubie_faces(): return cubies + cubie_face_list = cubie_faces() diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py index 6e59f4f4b84..7dee76ad643 100644 --- a/src/sage/groups/perm_gps/permgroup.py +++ b/src/sage/groups/perm_gps/permgroup.py @@ -5087,6 +5087,7 @@ def is_normal(self, other=None): other = self.ambient_group() return PermutationGroup_generic.is_normal(self, other) + # Allow for subclasses to use a different subgroup class PermutationGroup_generic.Subgroup = PermutationGroup_subgroup @@ -5194,5 +5195,6 @@ def orbits(self): """ return self._orbits + from sage.misc.rest_index_of_methods import gen_rest_table_index __doc__ = __doc__.format(METHODS_OF_PermutationGroup_generic=gen_rest_table_index(PermutationGroup_generic)) diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx index 8811ccf3a51..74915b37612 100644 --- a/src/sage/libs/flint/fmpz_poly.pyx +++ b/src/sage/libs/flint/fmpz_poly.pyx @@ -27,7 +27,7 @@ from sage.arith.long cimport pyobject_to_long from sage.cpython.string cimport char_to_str, str_to_bytes from sage.structure.sage_object cimport SageObject from sage.rings.integer cimport Integer -from sage.libs.flint.fmpz_poly cimport * + cdef class Fmpz_poly(SageObject): diff --git a/src/sage/libs/flint/qsieve.pyx b/src/sage/libs/flint/qsieve.pyx index 780d6f5c150..7d93d41f4cc 100644 --- a/src/sage/libs/flint/qsieve.pyx +++ b/src/sage/libs/flint/qsieve.pyx @@ -7,7 +7,6 @@ been absorbed into flint. from cysignals.signals cimport sig_on, sig_off from sage.libs.flint.fmpz cimport fmpz_t, fmpz_init, fmpz_set_mpz from sage.libs.flint.fmpz_factor cimport * -from sage.libs.flint.qsieve cimport * from sage.rings.integer cimport Integer diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx index 2f7ed35be9d..d5993cca5a5 100644 --- a/src/sage/libs/gmp/pylong.pyx +++ b/src/sage/libs/gmp/pylong.pyx @@ -26,7 +26,6 @@ AUTHORS: from cpython.object cimport Py_SIZE -from cpython.int cimport PyInt_FromLong from cpython.long cimport PyLong_FromLong from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT from .mpz cimport * @@ -85,7 +84,7 @@ cdef mpz_get_pyintlong(mpz_srcptr z): if the value is too large. """ if mpz_fits_slong_p(z): - return PyInt_FromLong(mpz_get_si(z)) + return PyLong_FromLong(mpz_get_si(z)) return mpz_get_pylong_large(z) diff --git a/src/sage/libs/mpmath/ext_impl.pyx b/src/sage/libs/mpmath/ext_impl.pyx index 97a9ad39b9e..2d8d2470273 100644 --- a/src/sage/libs/mpmath/ext_impl.pyx +++ b/src/sage/libs/mpmath/ext_impl.pyx @@ -25,7 +25,6 @@ See if :trac:`15118` is fixed:: # http://www.gnu.org/licenses/ #***************************************************************************** -from cpython.int cimport * from cpython.long cimport * from cpython.float cimport * from cpython.complex cimport * diff --git a/src/sage/libs/mpmath/ext_main.pyx b/src/sage/libs/mpmath/ext_main.pyx index 7b907f0d603..845c85234a6 100644 --- a/src/sage/libs/mpmath/ext_main.pyx +++ b/src/sage/libs/mpmath/ext_main.pyx @@ -14,7 +14,6 @@ context class, and related utilities. # http://www.gnu.org/licenses/ #***************************************************************************** -from cpython.int cimport * from cpython.long cimport * from cpython.float cimport * from cpython.complex cimport * diff --git a/src/sage/libs/pari/__init__.py b/src/sage/libs/pari/__init__.py index ba4c5ad0efd..95b93560892 100644 --- a/src/sage/libs/pari/__init__.py +++ b/src/sage/libs/pari/__init__.py @@ -202,4 +202,5 @@ def _get_pari_instance(): return P + pari = _get_pari_instance() diff --git a/src/sage/matrix/berlekamp_massey.py b/src/sage/matrix/berlekamp_massey.py index 199991e93cd..a6fe70c50e6 100644 --- a/src/sage/matrix/berlekamp_massey.py +++ b/src/sage/matrix/berlekamp_massey.py @@ -84,15 +84,11 @@ def berlekamp_massey(a): K = a[0].parent().fraction_field() except AttributeError: K = sage.rings.rational_field.RationalField() - R = K['x'] - x = R.gen() - - f = {-1: R(a), 0: x**(2 * M)} - s = {-1: 1, 0: 0} - j = 0 - while f[j].degree() >= M: - j += 1 - qj, f[j] = f[j - 2].quo_rem(f[j - 1]) - s[j] = s[j - 2] - qj * s[j - 1] - t = s[j].reverse() - return ~(t[t.degree()]) * t # make monic (~ is inverse in python) + + R, x = K['x'].objgen() + f0, f1 = R(a), x**(2 * M) + s0, s1 = 1, 0 + while f1.degree() >= M: + f0, (q, f1) = f1, f0.quo_rem(f1) + s0, s1 = s1, s0 - q * s1 + return s1.reverse().monic() diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx index 83d5ee42fbe..422b73ecb68 100644 --- a/src/sage/matrix/matrix_integer_sparse.pyx +++ b/src/sage/matrix/matrix_integer_sparse.pyx @@ -29,7 +29,7 @@ TESTS:: from cysignals.memory cimport check_calloc, sig_free from cysignals.signals cimport sig_on, sig_off -from cpython.int cimport PyInt_FromSize_t +from cpython.long cimport PyLong_FromSize_t from sage.ext.stdsage cimport PY_NEW from sage.ext.mod_int cimport * @@ -723,7 +723,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): del M - return PyInt_FromSize_t(r) + return PyLong_FromSize_t(r) def _det_linbox(self): r""" diff --git a/src/sage/matrix/matrix_modn_sparse.pxd b/src/sage/matrix/matrix_modn_sparse.pxd index 5c471a7082f..dded069b3d8 100644 --- a/src/sage/matrix/matrix_modn_sparse.pxd +++ b/src/sage/matrix/matrix_modn_sparse.pxd @@ -1,4 +1,4 @@ -from .matrix_sparse cimport Matrix_sparse +from sage.matrix.matrix_sparse cimport Matrix_sparse from sage.modules.vector_modn_sparse cimport * cdef class Matrix_modn_sparse(Matrix_sparse): diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index dd908a4c91b..84cfbedb226 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -86,44 +86,42 @@ from libc.limits cimport UINT_MAX from cysignals.memory cimport check_calloc, sig_free from cysignals.signals cimport sig_on, sig_off -from sage.ext.stdsage cimport PY_NEW +cimport sage.libs.linbox.givaro as givaro +cimport sage.libs.linbox.linbox as linbox +from sage.arith.misc import is_prime +from sage.data_structures.binary_search cimport * +from sage.ext.stdsage cimport PY_NEW from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry - +from sage.libs.gmp.mpz cimport mpz_set +from sage.libs.linbox.conversion cimport (get_method, + METHOD_DEFAULT, + METHOD_DENSE_ELIMINATION, + METHOD_SPARSE_ELIMINATION, + METHOD_BLACKBOX, + METHOD_WIEDEMANN, + new_linbox_matrix_modn_sparse, + new_linbox_matrix_integer_sparse, + new_linbox_vector_integer_dense, + new_sage_vector_integer_dense) +from sage.matrix.args cimport SparseEntry, MatrixArgs_init +from sage.matrix.matrix2 import Matrix as Matrix2 +from sage.matrix.matrix_dense cimport Matrix_dense +from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense +from sage.misc.verbose import verbose, get_verbose +from sage.modules.vector_integer_dense cimport Vector_integer_dense +from sage.modules.vector_integer_sparse cimport * from sage.modules.vector_modn_sparse cimport * - -cimport sage.libs.linbox.givaro as givaro -cimport sage.libs.linbox.linbox as linbox - -from sage.libs.linbox.conversion cimport * - -from .matrix2 cimport Matrix -cimport sage.matrix.matrix as matrix -cimport sage.matrix.matrix_sparse as matrix_sparse -cimport sage.matrix.matrix_dense as matrix_dense +from sage.rings.fast_arith cimport arith_int from sage.rings.finite_rings.integer_mod cimport IntegerMod_int, IntegerMod_abstract from sage.rings.integer cimport Integer -from sage.rings.rational_field import QQ from sage.rings.integer_ring import ZZ - -from sage.misc.verbose import verbose, get_verbose - -from sage.matrix.matrix2 import Matrix as Matrix2 -from .args cimport SparseEntry, MatrixArgs_init -from sage.arith.misc import is_prime - -cimport sage.structure.element - -from sage.data_structures.binary_search cimport * -from sage.modules.vector_integer_sparse cimport * - -from .matrix_integer_dense cimport Matrix_integer_dense -from sage.modules.vector_integer_dense cimport Vector_integer_dense +from sage.rings.rational_field import QQ +from sage.structure.element cimport Matrix ################ # TODO: change this to use extern cdef's methods. -from sage.rings.fast_arith cimport arith_int cdef arith_int ai ai = arith_int() ################ @@ -133,7 +131,7 @@ ai = arith_int() # Github Issue #12679. MAX_MODULUS = 46341 -cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): +cdef class Matrix_modn_sparse(Matrix_sparse): def __cinit__(self): nr = self._nrows nc = self._ncols @@ -257,7 +255,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): else: raise ValueError("unknown matrix format") - cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix _right): + cdef Matrix _matrix_times_matrix_(self, Matrix _right): """ This code is implicitly called for multiplying self by another sparse matrix. @@ -336,7 +334,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): set_entry(&ans.rows[i], j, s) return ans - def _matrix_times_matrix_dense(self, sage.structure.element.Matrix _right): + def _matrix_times_matrix_dense(self, Matrix _right): """ Multiply self by the sparse matrix _right, and return the result as a dense matrix. @@ -361,7 +359,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): """ cdef Matrix_modn_sparse right - cdef matrix_dense.Matrix_dense ans + cdef Matrix_dense ans right = _right cdef c_vector_modint* v @@ -871,7 +869,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): self.cache('det', d) return d elif algorithm == 'generic': - d = matrix_sparse.Matrix_sparse.determinant(self) + d = Matrix_sparse.determinant(self) self.cache('det', d) return d else: @@ -949,7 +947,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): if algorithm == "generic": return Matrix_sparse.solve_right(self, B) else: - if isinstance(B, sage.structure.element.Matrix): + if isinstance(B, Matrix): from sage.matrix.special import diagonal_matrix m, d = self._solve_matrix_linbox(B, algorithm) return m * diagonal_matrix([QQ((1,x)) for x in d]) @@ -1121,7 +1119,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): from sage.modules.free_module_element import vector cdef Matrix_integer_dense B - if not isinstance(mat, Matrix): + if not isinstance(mat, Matrix2): B = matrix(ZZ, mat, sparse=False) else: B = mat.change_ring(ZZ).dense_matrix() diff --git a/src/sage/matrix/matrix_polynomial_dense.pyx b/src/sage/matrix/matrix_polynomial_dense.pyx index e8b4d4d9176..10d9a9248b6 100644 --- a/src/sage/matrix/matrix_polynomial_dense.pyx +++ b/src/sage/matrix/matrix_polynomial_dense.pyx @@ -1670,8 +1670,8 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense): # the row-wise case (resp. column-wise case), it will be convenient to # have leading position ncols (resp. nrows) for these zero vectors pos_zero_vec = self.ncols() if row_wise else self.nrows() - leading_positions = [pos if pos>=0 else pos_zero_vec + 1 \ - for pos in leading_positions] + leading_positions = [pos if pos >= 0 else pos_zero_vec + 1 + for pos in leading_positions] # leading positions should not have duplicates, which is equivalent to: # once sorted, it doesn't contain a pair of equal successive entries if not ordered: diff --git a/src/sage/misc/rest_index_of_methods.py b/src/sage/misc/rest_index_of_methods.py index 82b988deda2..d1b102829c9 100644 --- a/src/sage/misc/rest_index_of_methods.py +++ b/src/sage/misc/rest_index_of_methods.py @@ -14,7 +14,7 @@ from sage.misc.sageinspect import is_function_or_cython_function as _isfunction -def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True): +def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True, root=None): r""" Return a ReST table describing a list of functions. @@ -35,13 +35,19 @@ def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True): precedence over the automatically computed name for the functions. Only used when ``list_of_entries`` is a list. - - ``sort`` (boolean; ``True``) -- whether to sort the list of methods - lexicographically. + - ``sort`` -- boolean (default: ``True``); whether to sort the list of + methods lexicographically. - - ``only_local_functions`` (boolean; ``True``) -- if ``list_of_entries`` is - a module, ``only_local_functions = True`` means that imported functions - will be filtered out. This can be useful to disable for making indexes of - e.g. catalog modules such as :mod:`sage.coding.codes_catalog`. + - ``only_local_functions`` -- boolean (default: ``True``); if + ``list_of_entries`` is a module, ``only_local_functions = True`` means + that imported functions will be filtered out. This can be useful to + disable for making indexes of e.g. catalog modules such as + :mod:`sage.coding.codes_catalog`. + + - ``root`` -- module or class (default: ``None``); the module, or class, + whose elements are to be listed. This is needed to recover the class when + this method is called from :meth:`gen_thematic_rest_table_index` (see + :issue:`36178`). .. WARNING:: @@ -70,8 +76,8 @@ def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True): :func:`~sage.misc.rest_index_of_methods.doc_index` @ Attribute an index name to a function. :func:`~sage.misc.rest_index_of_methods.gen_rest_table_index` @ Return a ReST table describing a list of functions. - :func:`~sage.misc.rest_index_of_methods.gen_thematic_rest_table_index` @ Return a ReST string of thematically sorted function (or methods) of a module (or class). - :func:`~sage.misc.rest_index_of_methods.list_of_subfunctions` @ Returns the functions (resp. methods) of a given module (resp. class) with their names. + :func:`~sage.misc.rest_index_of_methods.gen_thematic_rest_table_index` @ Return a ReST string of thematically sorted functions (or methods) of a module (or class). + :func:`~sage.misc.rest_index_of_methods.list_of_subfunctions` @ Return the functions (resp. methods) of a given module (resp. class) with their names. @@ -123,8 +129,8 @@ def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True): :func:`~sage.misc.rest_index_of_methods.doc_index` @ Attribute an index name to a function. :func:`~sage.misc.rest_index_of_methods.gen_rest_table_index` @ Return a ReST table describing a list of functions. - :func:`~sage.misc.rest_index_of_methods.gen_thematic_rest_table_index` @ Return a ReST string of thematically sorted function (or methods) of a module (or class). - :func:`~sage.misc.rest_index_of_methods.list_of_subfunctions` @ Returns the functions (resp. methods) of a given module (resp. class) with their names. + :func:`~sage.misc.rest_index_of_methods.gen_thematic_rest_table_index` @ Return a ReST string of thematically sorted functions (or methods) of a module (or class). + :func:`~sage.misc.rest_index_of_methods.list_of_subfunctions` @ Return the functions (resp. methods) of a given module (resp. class) with their names. sage: print(gen_rest_table_index(sage.misc.rest_index_of_methods, only_local_functions=False)) @@ -134,8 +140,8 @@ def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True): :delim: @ :func:`~sage.misc.rest_index_of_methods.doc_index` @ Attribute an index name to a function. - :func:`~sage.misc.rest_index_of_methods.gen_thematic_rest_table_index` @ Return a ReST string of thematically sorted function (or methods) of a module (or class). - :func:`~sage.misc.rest_index_of_methods.list_of_subfunctions` @ Returns the functions (resp. methods) of a given module (resp. class) with their names. + :func:`~sage.misc.rest_index_of_methods.gen_thematic_rest_table_index` @ Return a ReST string of thematically sorted functions (or methods) of a module (or class). + :func:`~sage.misc.rest_index_of_methods.list_of_subfunctions` @ Return the functions (resp. methods) of a given module (resp. class) with their names. @@ -146,6 +152,13 @@ def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True): True sage: 'all_max_cliques`' in gen_rest_table_index(Graph) # needs sage.graphs False + + Check that :issue:`36178` is fixed:: + + sage: print(gen_rest_table_index(Graph)) # needs sage.graphs + ... + :meth:`~sage.graphs.graph.Graph.independent_set` @ Return a maximum independent set. + ... """ if names is None: names = {} @@ -169,14 +182,24 @@ def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True): if sort: list_of_entries.sort(key=fname) + obj_or_root_is_class = False + if inspect.isclass(root): + obj_or_root_is_class = True + class_name = root.__name__ + module_name = root.__module__ + elif inspect.isclass(obj): + obj_or_root_is_class = True + class_name = obj.__name__ + module_name = obj.__module__ + for e in list_of_entries: if inspect.ismethod(e): link = ":meth:`~{module}.{cls}.{func}`".format( module=e.im_class.__module__, cls=e.im_class.__name__, func=fname(e)) - elif _isfunction(e) and inspect.isclass(obj): + elif _isfunction(e) and obj_or_root_is_class: link = ":meth:`~{module}.{cls}.{func}`".format( - module=obj.__module__, cls=obj.__name__, func=fname(e)) + module=module_name, cls=class_name, func=fname(e)) elif _isfunction(e): link = ":func:`~{module}.{func}`".format( module=e.__module__, func=fname(e)) @@ -204,15 +227,15 @@ def gen_rest_table_index(obj, names=None, sort=True, only_local_functions=True): def list_of_subfunctions(root, only_local_functions=True): r""" - Returns the functions (resp. methods) of a given module (resp. class) with their names. + Return the functions (resp. methods) of a given module (resp. class) with their names. INPUT: - ``root`` -- the module, or class, whose elements are to be listed. - - ``only_local_functions`` (boolean; ``True``) -- if ``root`` is a module, - ``only_local_functions = True`` means that imported functions will be - filtered out. This can be useful to disable for making indexes of + - ``only_local_functions`` -- boolean (default: ``True``); if ``root`` is a + module, ``only_local_functions = True`` means that imported functions will + be filtered out. This can be useful to disable for making indexes of e.g. catalog modules such as :mod:`sage.coding.codes_catalog`. OUTPUT: @@ -276,21 +299,22 @@ def can_import(f): return list(functions.keys()), functions -def gen_thematic_rest_table_index(root,additional_categories=None,only_local_functions=True): +def gen_thematic_rest_table_index(root, additional_categories=None, only_local_functions=True): r""" - Return a ReST string of thematically sorted function (or methods) of a module (or class). + Return a ReST string of thematically sorted functions (or methods) of a + module (or class). INPUT: - ``root`` -- the module, or class, whose elements are to be listed. - - ``additional_categories`` -- a dictionary associating a category (given as - a string) to a function's name. Can be used when the decorator - :func:`doc_index` does not work on a function. + - ``additional_categories`` -- dictionary (default: ``None``); a dictionary + associating a category (given as a string) to a function's name. Can be + used when the decorator :func:`doc_index` does not work on a function. - - ``only_local_functions`` (boolean; ``True``) -- if ``root`` is a module, - ``only_local_functions = True`` means that imported functions will be - filtered out. This can be useful to disable for making indexes of + - ``only_local_functions`` -- boolean (default: ``True``); if ``root`` is a + module, ``only_local_functions = True`` means that imported functions will + be filtered out. This can be useful to disable for making indexes of e.g. catalog modules such as :mod:`sage.coding.codes_catalog`. EXAMPLES:: @@ -317,7 +341,7 @@ def gen_thematic_rest_table_index(root,additional_categories=None,only_local_fun except AttributeError: doc_ind = "Unsorted" theme_to_function[doc_ind].append(f) - s = ["**"+theme+"**\n\n"+gen_rest_table_index(list_of_functions,names=names) + s = ["**" + theme + "**\n\n" + gen_rest_table_index(list_of_functions, names=names, root=root) for theme, list_of_functions in sorted(theme_to_function.items())] return "\n\n".join(s) @@ -345,9 +369,10 @@ def doc_index(name): 'Wouhouuuuu' """ def hey(f): - setattr(f,"doc_index",name) + setattr(f, "doc_index", name) return f return hey -__doc__ = __doc__.format(INDEX_OF_FUNCTIONS=gen_rest_table_index([gen_rest_table_index])) +__doc__ = __doc__.format(INDEX_OF_FUNCTIONS=gen_rest_table_index([gen_rest_table_index, + gen_thematic_rest_table_index])) diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index ce5e9987027..88ac75ea843 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -1614,7 +1614,8 @@ def foo(x, a='\')"', b={not (2+1==3):'bar'}): return The following was fixed in :trac:`16309`:: - sage: cython( # needs sage.misc.cython + sage: # needs sage.misc.cython + sage: cython( ....: ''' ....: class Foo: ....: @staticmethod diff --git a/src/sage/modular/abvar/homspace.py b/src/sage/modular/abvar/homspace.py index 6d96cc0fabe..8e89399d611 100644 --- a/src/sage/modular/abvar/homspace.py +++ b/src/sage/modular/abvar/homspace.py @@ -148,14 +148,15 @@ :: - sage: T = E.image_of_hecke_algebra() # long time - sage: T.gens() # long time + sage: # long time + sage: T = E.image_of_hecke_algebra() + sage: T.gens() (Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, Abelian variety endomorphism of Abelian variety J0(33) of dimension 3) - sage: T.index_in(E) # long time + sage: T.index_in(E) +Infinity - sage: T.index_in_saturation() # long time + sage: T.index_in_saturation() 1 AUTHORS: diff --git a/src/sage/modular/arithgroup/congroup_gamma0.py b/src/sage/modular/arithgroup/congroup_gamma0.py index 5bc0a6e4b3a..e960ce477d3 100644 --- a/src/sage/modular/arithgroup/congroup_gamma0.py +++ b/src/sage/modular/arithgroup/congroup_gamma0.py @@ -39,6 +39,7 @@ def is_Gamma0(x): """ return isinstance(x, Gamma0_class) + _gamma0_cache = {} def Gamma0_constructor(N): """ diff --git a/src/sage/modular/arithgroup/farey.cpp b/src/sage/modular/arithgroup/farey.cpp index 34f5e5727db..209391676de 100644 --- a/src/sage/modular/arithgroup/farey.cpp +++ b/src/sage/modular/arithgroup/farey.cpp @@ -1010,7 +1010,7 @@ PyObject* FareySymbol::word_problem(const mpz_t a, const mpz_t b, LLT_algorithm(M, p, beta1); wd = PyList_New(p.size()); for(i=0; i::const_iterator i=p.begin(); i!=p.end(); i++) { vector::const_iterator j = find(pairing.begin(), pairing.end(), *i); vector::const_iterator k = find(j+1, pairing.end(), *i); - PyObject* J = PyInt_FromLong(long(j-pairing.begin())); - PyObject* K = PyInt_FromLong(long(k-pairing.begin())); + PyObject* J = PyLong_FromLong(long(j-pairing.begin())); + PyObject* K = PyLong_FromLong(long(k-pairing.begin())); PyObject* tuple = PyTuple_New(2); PyTuple_SetItem(tuple, 0, J); PyTuple_SetItem(tuple, 1, K); diff --git a/src/sage/modular/arithgroup/farey.hpp b/src/sage/modular/arithgroup/farey.hpp index 076d5cd0504..03c03cf1434 100644 --- a/src/sage/modular/arithgroup/farey.hpp +++ b/src/sage/modular/arithgroup/farey.hpp @@ -29,9 +29,6 @@ #include #include "sl2z.hpp" -#define PyInt_FromLong PyLong_FromLong -#define PyInt_AsLong PyLong_AsLong -#define PyInt_AS_LONG PyLong_AS_LONG //--- pure virtual base class for helper class for membership test -------- diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py index 7e8ffa6658c..8d8b580a74e 100644 --- a/src/sage/modular/cusps_nf.py +++ b/src/sage/modular/cusps_nf.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field r""" The set `\mathbb{P}^1(K)` of cusps of a number field `K` @@ -62,7 +63,7 @@ sage: Gamma0_NFCusps(N) [Cusp [0: 1] of Number Field in a with defining polynomial x^2 + 5, - Cusp [1: 3] of Number Field in a with defining polynomial x^2 + 5, + Cusp [1: 3] of Number Field in a with defining polynomial x^2 + 5, ...] """ # **************************************************************************** @@ -859,7 +860,7 @@ def ABmatrix(self): sage: M = alpha.ABmatrix() sage: M # random [-a^2 - a - 1, -3*a - 7, 8, -2*a^2 - 3*a + 4] - sage: M[0] == alpha.numerator() and M[2]==alpha.denominator() + sage: M[0] == alpha.numerator() and M[2] == alpha.denominator() True An AB-matrix associated to a cusp alpha will send Infinity to alpha: @@ -870,7 +871,7 @@ def ABmatrix(self): sage: M = alpha.ABmatrix() sage: (k.ideal(M[1], M[3])*alpha.ideal()).is_principal() True - sage: M[0] == alpha.numerator() and M[2]==alpha.denominator() + sage: M[0] == alpha.numerator() and M[2] == alpha.denominator() True sage: NFCusp(k, oo).apply(M) == alpha True @@ -1249,7 +1250,8 @@ def units_mod_ideal(I): sage: from sage.modular.cusps_nf import units_mod_ideal sage: k. = NumberField(x^3 + 11) sage: k.unit_group() - Unit group with structure C2 x Z of Number Field in a with defining polynomial x^3 + 11 + Unit group with structure C2 x Z of + Number Field in a with defining polynomial x^3 + 11 sage: I = k.ideal(5, a + 1) sage: units_mod_ideal(I) [1, @@ -1261,7 +1263,8 @@ def units_mod_ideal(I): sage: from sage.modular.cusps_nf import units_mod_ideal sage: k. = NumberField(x^4 - x^3 -21*x^2 + 17*x + 133) sage: k.unit_group() - Unit group with structure C6 x Z of Number Field in a with defining polynomial x^4 - x^3 - 21*x^2 + 17*x + 133 + Unit group with structure C6 x Z of + Number Field in a with defining polynomial x^4 - x^3 - 21*x^2 + 17*x + 133 sage: I = k.ideal(3) sage: U = units_mod_ideal(I) sage: all(U[j].is_unit() and (U[j] not in I) for j in range(len(U))) diff --git a/src/sage/modular/modform/constructor.py b/src/sage/modular/modform/constructor.py index c30a28354ca..023f9a380d2 100644 --- a/src/sage/modular/modform/constructor.py +++ b/src/sage/modular/modform/constructor.py @@ -134,6 +134,7 @@ def canonical_parameters(group, level, weight, base_ring): # forms spaces. return level, group, weight, base_ring + _cache = {} def ModularForms_clear_cache(): diff --git a/src/sage/modular/modform/element.py b/src/sage/modular/modform/element.py index fba61a0fdd8..6d10fdf47c3 100644 --- a/src/sage/modular/modform/element.py +++ b/src/sage/modular/modform/element.py @@ -2315,13 +2315,14 @@ def minimal_twist(self, p=None): sage: f.twist(chi, level=11) == g True - sage: f = Newforms(575, 2, names='a')[4] # long time - sage: g, chi = f.minimal_twist(5) # long time - sage: g # long time + sage: # long time + sage: f = Newforms(575, 2, names='a')[4] + sage: g, chi = f.minimal_twist(5) + sage: g q + a*q^2 - a*q^3 - 2*q^4 + (1/2*a + 2)*q^5 + O(q^6) - sage: chi # long time + sage: chi Dirichlet character modulo 5 of conductor 5 mapping 2 |--> 1/2*a - sage: f.twist(chi, level=g.level()) == g # long time + sage: f.twist(chi, level=g.level()) == g True """ if p is None: diff --git a/src/sage/modular/modform_hecketriangle/analytic_type.py b/src/sage/modular/modform_hecketriangle/analytic_type.py index 7b2618991df..0c809b3328c 100644 --- a/src/sage/modular/modform_hecketriangle/analytic_type.py +++ b/src/sage/modular/modform_hecketriangle/analytic_type.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.graphs r""" Analytic types of modular forms diff --git a/src/sage/modular/overconvergent/weightspace.py b/src/sage/modular/overconvergent/weightspace.py index 8f0ecc8b8c0..e9478c40a90 100644 --- a/src/sage/modular/overconvergent/weightspace.py +++ b/src/sage/modular/overconvergent/weightspace.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics r""" The space of `p`-adic weights @@ -17,7 +17,8 @@ sage: W = pAdicWeightSpace(17) sage: W - Space of 17-adic weight-characters defined over 17-adic Field with capped relative precision 20 + Space of 17-adic weight-characters + defined over 17-adic Field with capped relative precision 20 sage: R. = QQ[] sage: L = Qp(17).extension(x^2 - 17, names='a'); L.rename('L') sage: W.base_extend(L) @@ -101,7 +102,8 @@ def WeightSpace_constructor(p, base_ring=None): EXAMPLES:: sage: pAdicWeightSpace(3) # indirect doctest - Space of 3-adic weight-characters defined over 3-adic Field with capped relative precision 20 + Space of 3-adic weight-characters + defined over 3-adic Field with capped relative precision 20 sage: pAdicWeightSpace(3, QQ) Space of 3-adic weight-characters defined over Rational Field sage: pAdicWeightSpace(10) @@ -248,11 +250,13 @@ def base_extend(self, R): sage: W = pAdicWeightSpace(3, QQ) sage: W.base_extend(Qp(3)) - Space of 3-adic weight-characters defined over 3-adic Field with capped relative precision 20 + Space of 3-adic weight-characters + defined over 3-adic Field with capped relative precision 20 sage: W.base_extend(IntegerModRing(12)) Traceback (most recent call last): ... - TypeError: No coercion map from 'Rational Field' to 'Ring of integers modulo 12' is defined + TypeError: No coercion map from 'Rational Field' + to 'Ring of integers modulo 12' is defined """ if R.has_coerce_map_from(self.base_ring()): return WeightSpace_constructor(self.prime(), R) @@ -356,7 +360,9 @@ def pAdicEisensteinSeries(self, ring, prec=20): sage: kappa = pAdicWeightSpace(3)(3, DirichletGroup(3,QQ).0) sage: kappa.pAdicEisensteinSeries(QQ[['q']], 20) - 1 - 9*q + 27*q^2 - 9*q^3 - 117*q^4 + 216*q^5 + 27*q^6 - 450*q^7 + 459*q^8 - 9*q^9 - 648*q^10 + 1080*q^11 - 117*q^12 - 1530*q^13 + 1350*q^14 + 216*q^15 - 1845*q^16 + 2592*q^17 + 27*q^18 - 3258*q^19 + O(q^20) + 1 - 9*q + 27*q^2 - 9*q^3 - 117*q^4 + 216*q^5 + 27*q^6 - 450*q^7 + 459*q^8 + - 9*q^9 - 648*q^10 + 1080*q^11 - 117*q^12 - 1530*q^13 + 1350*q^14 + 216*q^15 + - 1845*q^16 + 2592*q^17 + 27*q^18 - 3258*q^19 + O(q^20) """ if not self.is_even(): raise ValueError("Eisenstein series not defined for odd weight-characters") @@ -570,7 +576,8 @@ def chi(self): sage: kappa = pAdicWeightSpace(29)(13, DirichletGroup(29, Qp(29)).0^14) sage: kappa.chi() - Dirichlet character modulo 29 of conductor 29 mapping 2 |--> 28 + 28*29 + 28*29^2 + ... + O(29^20) + Dirichlet character modulo 29 of conductor 29 + mapping 2 |--> 28 + 28*29 + 28*29^2 + ... + O(29^20) """ return self._chi @@ -667,7 +674,8 @@ def Lvalue(self): sage: pAdicWeightSpace(7)(5, DirichletGroup(7, Qp(7)).0^4).Lvalue() 0 sage: pAdicWeightSpace(7)(6, DirichletGroup(7, Qp(7)).0^4).Lvalue() - 1 + 2*7 + 7^2 + 3*7^3 + 3*7^5 + 4*7^6 + 2*7^7 + 5*7^8 + 2*7^9 + 3*7^10 + 6*7^11 + 2*7^12 + 3*7^13 + 5*7^14 + 6*7^15 + 5*7^16 + 3*7^17 + 6*7^18 + O(7^19) + 1 + 2*7 + 7^2 + 3*7^3 + 3*7^5 + 4*7^6 + 2*7^7 + 5*7^8 + 2*7^9 + 3*7^10 + 6*7^11 + + 2*7^12 + 3*7^13 + 5*7^14 + 6*7^15 + 5*7^16 + 3*7^17 + 6*7^18 + O(7^19) """ if self._k > 0: return -self._chi.bernoulli(self._k) / self._k diff --git a/src/sage/modular/pollack_stevens/distributions.py b/src/sage/modular/pollack_stevens/distributions.py index 55a5ec72663..274cdfa87a4 100644 --- a/src/sage/modular/pollack_stevens/distributions.py +++ b/src/sage/modular/pollack_stevens/distributions.py @@ -224,6 +224,7 @@ def create_object(self, version, key): """ return Symk_class(*key) + OverconvergentDistributions = OverconvergentDistributions_factory('OverconvergentDistributions') Symk = Symk_factory('Symk') diff --git a/src/sage/modular/pollack_stevens/fund_domain.py b/src/sage/modular/pollack_stevens/fund_domain.py index 3e25c950b30..4bd2638d5a6 100644 --- a/src/sage/modular/pollack_stevens/fund_domain.py +++ b/src/sage/modular/pollack_stevens/fund_domain.py @@ -56,6 +56,7 @@ def M2Z(x): x.set_immutable() return x + Id = M2Z([1, 0, 0, 1]) sig = M2Z([0, 1, -1, 0]) tau = M2Z([0, -1, 1, -1]) diff --git a/src/sage/modular/pollack_stevens/padic_lseries.py b/src/sage/modular/pollack_stevens/padic_lseries.py index 396a96af90e..748b5dc9993 100644 --- a/src/sage/modular/pollack_stevens/padic_lseries.py +++ b/src/sage/modular/pollack_stevens/padic_lseries.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.ring.padics r""" `p`-adic `L`-series attached to overconvergent eigensymbols diff --git a/src/sage/modular/pollack_stevens/sigma0.py b/src/sage/modular/pollack_stevens/sigma0.py index ab8e24959cd..bd203ec8600 100644 --- a/src/sage/modular/pollack_stevens/sigma0.py +++ b/src/sage/modular/pollack_stevens/sigma0.py @@ -162,6 +162,7 @@ def create_object(self, version, key): """ return Sigma0_class(*key) + Sigma0 = Sigma0_factory('sage.modular.pollack_stevens.sigma0.Sigma0') diff --git a/src/sage/modular/pollack_stevens/space.py b/src/sage/modular/pollack_stevens/space.py index 43e396b03c8..88b7be6d2cd 100644 --- a/src/sage/modular/pollack_stevens/space.py +++ b/src/sage/modular/pollack_stevens/space.py @@ -189,6 +189,7 @@ def create_object(self, version, key): """ return PollackStevensModularSymbolspace(*key) + PollackStevensModularSymbols = PollackStevensModularSymbols_factory('PollackStevensModularSymbols') diff --git a/src/sage/modules/fg_pid/fgp_morphism.py b/src/sage/modules/fg_pid/fgp_morphism.py index 71b43dcdc1a..809bb439f0c 100644 --- a/src/sage/modules/fg_pid/fgp_morphism.py +++ b/src/sage/modules/fg_pid/fgp_morphism.py @@ -453,6 +453,7 @@ def lift(self, x): assert self(y) == x, "bug in phi.lift()" return y + from sage.categories.homset import Homset import sage.misc.weak_dict diff --git a/src/sage/modules/vector_modn_sparse.pyx b/src/sage/modules/vector_modn_sparse.pyx index 746f9897db2..e2dd1d7c1a6 100644 --- a/src/sage/modules/vector_modn_sparse.pyx +++ b/src/sage/modules/vector_modn_sparse.pyx @@ -7,8 +7,6 @@ from cysignals.memory cimport sig_malloc, sig_free -from sage.modules.vector_modn_sparse cimport c_vector_modint - cdef int allocate_c_vector_modint(c_vector_modint* v, Py_ssize_t num_nonzero) except -1: """ diff --git a/src/sage/plot/plot3d/plot3d.py b/src/sage/plot/plot3d/plot3d.py index 41a1ad5de53..2d2bfb9e34d 100644 --- a/src/sage/plot/plot3d/plot3d.py +++ b/src/sage/plot/plot3d/plot3d.py @@ -953,6 +953,7 @@ def smooth_triangle(self, a, b, c, da, db, dc, color=None): """ return [a,b,c] + from . import parametric_plot3d def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): """ diff --git a/src/sage/probability/probability_distribution.pyx b/src/sage/probability/probability_distribution.pyx index 3cbc81a8a39..1f120cd6089 100644 --- a/src/sage/probability/probability_distribution.pyx +++ b/src/sage/probability/probability_distribution.pyx @@ -46,8 +46,7 @@ import sage.rings.real_double from sage.modules.free_module_element import vector # TODO: Add more distributions available in gsl -# available but not currently wrapped are exponential, laplace, cauchy, landau, gamma, -# gamma, beta logistic. +# available but not currently wrapped are laplace, cauchy, landau, logistic. cdef enum: uniform @@ -61,6 +60,8 @@ cdef enum: exppow weibull beta + exponential + gamma cdef class ProbabilityDistribution: r""" @@ -501,6 +502,31 @@ cdef class RealDistribution(ProbabilityDistribution): sage: T.cum_distribution_function(1) 1.0 + The exponential distribution has one parameter ``mu``:: + + sage: mu = 2 + sage: T = RealDistribution('exponential', mu) + sage: s = T.get_random_element() + sage: 0 <= s + True + sage: s.parent() + Real Double Field + sage: T.distribution_function(0) + 0.5 + + The gamma distribution has two parameters ``a`` and ``b``:: + + sage: a = 2 + sage: b = 2 + sage: T = RealDistribution('gamma', [a, b]) + sage: s = T.get_random_element() + sage: 0 <= s + True + sage: s.parent() + Real Double Field + sage: T.distribution_function(0) + 0.0 + The weibull distribution has two parameters ``a`` and ``b``:: sage: a = 1 @@ -682,6 +708,10 @@ cdef class RealDistribution(ProbabilityDistribution): result = gsl_ran_weibull(self.r, self.parameters[0], self.parameters[1]) elif self.distribution_type == beta: result = gsl_ran_beta(self.r, self.parameters[0], self.parameters[1]) + elif self.distribution_type == exponential: + result = gsl_ran_exponential(self.r, self.parameters[0]) + elif self.distribution_type == gamma: + result = gsl_ran_gamma(self.r, self.parameters[0], self.parameters[1]) else: raise TypeError("Not a supported probability distribution") @@ -732,7 +762,6 @@ cdef class RealDistribution(ProbabilityDistribution): self.parameters[1] = float(parameters[1]) self.distribution_type = pareto elif name == 'rayleigh': - self.distribution_type = rayleigh try: float(parameters) except Exception: @@ -813,6 +842,25 @@ cdef class RealDistribution(ProbabilityDistribution): self.parameters[0] = float(parameters[0]) self.parameters[1] = float(parameters[1]) self.distribution_type = beta + elif name == 'exponential': + try: + float(parameters) + except Exception: + raise TypeError("exponential distribution requires parameter mu coercible to float") + self.parameters = sig_malloc(sizeof(double)) + self.parameters[0] = float(parameters) + self.distribution_type = exponential + elif name == 'gamma': + if len(parameters) != 2: + raise TypeError("gamma distribution requires two real parameters") + try: + map(float, parameters) + except Exception: + raise TypeError("gamma distribution requires real parameters") + self.parameters = sig_malloc(sizeof(double)*2) + self.parameters[0] = float(parameters[0]) + self.parameters[1] = float(parameters[1]) + self.distribution_type = gamma else: raise TypeError("Not a supported probability distribution") @@ -878,6 +926,10 @@ cdef class RealDistribution(ProbabilityDistribution): return sage.rings.real_double.RDF(gsl_ran_weibull_pdf(x, self.parameters[0], self.parameters[1])) elif self.distribution_type == beta: return sage.rings.real_double.RDF(gsl_ran_beta_pdf(x, self.parameters[0], self.parameters[1])) + elif self.distribution_type == exponential: + return sage.rings.real_double.RDF(gsl_ran_exponential_pdf(x, self.parameters[0])) + elif self.distribution_type == gamma: + return sage.rings.real_double.RDF(gsl_ran_gamma_pdf(x, self.parameters[0], self.parameters[1])) else: raise TypeError("Not a supported probability distribution") @@ -914,6 +966,10 @@ cdef class RealDistribution(ProbabilityDistribution): return sage.rings.real_double.RDF(gsl_cdf_weibull_P(x, self.parameters[0], self.parameters[1])) elif self.distribution_type == beta: return sage.rings.real_double.RDF(gsl_cdf_beta_P(x, self.parameters[0], self.parameters[1])) + elif self.distribution_type == exponential: + return sage.rings.real_double.RDF(gsl_cdf_exponential_P(x, self.parameters[0])) + elif self.distribution_type == gamma: + return sage.rings.real_double.RDF(gsl_cdf_gamma_P(x, self.parameters[0], self.parameters[1])) else: raise TypeError("Not a supported probability distribution") @@ -951,6 +1007,10 @@ cdef class RealDistribution(ProbabilityDistribution): return sage.rings.real_double.RDF(gsl_cdf_weibull_Pinv(x, self.parameters[0], self.parameters[1])) elif self.distribution_type == beta: return sage.rings.real_double.RDF(gsl_cdf_beta_Pinv(x, self.parameters[0], self.parameters[1])) + elif self.distribution_type == exponential: + return sage.rings.real_double.RDF(gsl_cdf_exponential_Pinv(x, self.parameters[0])) + elif self.distribution_type == gamma: + return sage.rings.real_double.RDF(gsl_cdf_gamma_Pinv(x, self.parameters[0], self.parameters[1])) else: raise TypeError("Not a supported probability distribution") diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py index 28c66344013..d9c298f5f0a 100644 --- a/src/sage/quadratic_forms/genera/genus.py +++ b/src/sage/quadratic_forms/genera/genus.py @@ -298,13 +298,13 @@ def _blocks(b, even_only=False): if not even_only: for s in [(1, 2), (5, 6), (1, 6), (5, 2), (7, 0), (3, 4)]: b1 = copy(b) - b1[2] = s[0]*(-1)**(rk//2 -1) % 8 + b1[2] = s[0]*(-1)**(rk // 2 - 1) % 8 b1[3] = 1 b1[4] = s[1] blocks.append(b1) for s in [(1, 4), (5, 0)]: b1 = copy(b) - b1[2] = s[0]*(-1)**(rk//2 - 2) % 8 + b1[2] = s[0]*(-1)**(rk // 2 - 2) % 8 b1[3] = 1 b1[4] = s[1] blocks.append(b1) @@ -514,7 +514,7 @@ def is_2_adic_genus(genus_symbol_quintuple_list): if s[2] % 8 in (3, 5): if not s[4] in (2, 4, 6): return False - if (s[1] - s[4])% 2 == 1: + if (s[1] - s[4]) % 2 == 1: return False if s[3] == 0 and s[4] != 0: return False @@ -764,7 +764,7 @@ def canonical_2_adic_reduction(genus_symbol_quintuple_list): for i in compart: genus_symbol_quintuple_list[i][4] = 0 genus_symbol_quintuple_list[compart[0]][4] = oddity - verbose(mesg="End oddity fusion: %s" %canonical_symbol, level=2) + verbose(mesg="End oddity fusion: %s" % canonical_symbol, level=2) # Sign walking: trains = canonical_2_adic_trains(genus_symbol_quintuple_list) for train in trains: @@ -778,7 +778,7 @@ def canonical_2_adic_reduction(genus_symbol_quintuple_list): if t1-1 in compart or t1 in compart: o = canonical_symbol[compart[0]][4] canonical_symbol[compart[0]][4] = (o+4) % 8 - verbose(mesg="End sign walking: %s" %canonical_symbol, level=2) + verbose(mesg="End sign walking: %s" % canonical_symbol, level=2) return canonical_symbol @@ -912,35 +912,35 @@ def p_adic_symbol(A, p, val): m0 = min(c.valuation(p) for c in A.list()) q = p**m0 n = A.nrows() - A = MatrixSpace(ZZ, n, n)([ c // q for c in A.list() ]) + A = MatrixSpace(ZZ, n, n)([c // q for c in A.list()]) A_p = MatrixSpace(FiniteField(p), n, n)(A) B_p = A_p.kernel().echelonized_basis_matrix() if B_p.nrows() == 0: e0 = Integer(A_p.det()).kronecker(p) n0 = A.nrows() - return [ [m0, n0, e0] ] + return [[m0, n0, e0]] else: C_p = basis_complement(B_p) e0 = Integer((C_p * A_p * C_p.transpose()).det()).kronecker(p) n0 = C_p.nrows() - sym = [ [0, n0, e0] ] + sym = [[0, n0, e0]] r = B_p.nrows() B = MatrixSpace(ZZ, r, n)(B_p) C = MatrixSpace(ZZ, n - r, n)(C_p) # Construct the blocks for the Jordan decomposition [F,X;X,A_new] F = MatrixSpace(QQ, n - r, n - r)(C * A * C.transpose()) U = F**-1 - d = LCM([ c.denominator() for c in U.list() ]) + d = LCM([c.denominator() for c in U.list()]) R = ZZ.quotient_ring(Integer(p)**(val + 3)) u = R(d)**-1 - MatR = MatrixSpace(R, n - r , n - r) + MatR = MatrixSpace(R, n - r, n - r) MatZ = MatrixSpace(ZZ, n - r, n - r) U = MatZ(MatR(MatZ(U * d)) * u) # X = C*A*B.transpose() # A = B*A*B.transpose() - X.transpose()*U*X X = C * A - A = B * (A - X.transpose()*U*X) * B.transpose() - return [ [s[0]+m0] + s[1:] for s in sym + p_adic_symbol(A, p, val) ] + A = B * (A - X.transpose() * U * X) * B.transpose() + return [[s[0]+m0] + s[1:] for s in sym + p_adic_symbol(A, p, val)] def is_even_matrix(A): @@ -969,7 +969,7 @@ def is_even_matrix(A): (True, -1) """ for i in range(A.nrows()): - if A[i,i] % 2 == 1: + if A[i, i] % 2: return False, i return True, -1 @@ -1024,35 +1024,35 @@ def split_odd(A): even, i = is_even_matrix(A) R = A.parent().base_ring() C = MatrixSpace(R, n0 - 1, n0)(0) - u = A[i,i] + u = A[i, i] for j in range(n0-1): if j < i: - C[j,j] = 1 - C[j,i] = -A[j,i] * u + C[j, j] = 1 + C[j, i] = -A[j, i] * u else: - C[j,j+1] = 1 - C[j,i] = -A[j+1,i] * u + C[j, j+1] = 1 + C[j, i] = -A[j+1, i] * u B = C*A*C.transpose() even, j = is_even_matrix(B) if even: I = A.parent()(1) # TODO: we could manually (re)construct the kernel here... if i == 0: - I[1,0] = 1 - A[1,0]*u + I[1, 0] = 1 - A[1, 0]*u i = 1 else: - I[0,i] = 1 - A[0,i]*u + I[0, i] = 1 - A[0, i]*u i = 0 A = I*A*I.transpose() - u = A[i,i] - C = MatrixSpace(R,n0-1,n0)(0) + u = A[i, i] + C = MatrixSpace(R, n0-1, n0)(0) for j in range(n0-1): if j < i: - C[j,j] = 1 - C[j,i] = -A[j,i] * u + C[j, j] = 1 + C[j, i] = -A[j, i] * u else: - C[j,j+1] = 1 - C[j,i] = -A[j+1,i] * u + C[j, j+1] = 1 + C[j, i] = -A[j+1, i] * u B = C * A * C.transpose() even, j = is_even_matrix(B) if even: @@ -1141,9 +1141,9 @@ def two_adic_symbol(A, val): # deal with the empty matrix if n == 0: return [[0, 0, 1, 0, 0]] - m0 = min([ c.valuation(2) for c in A.list() ]) + m0 = min([c.valuation(2) for c in A.list()]) q = 2**m0 - A = A.parent()([ c // q for c in A.list() ]) + A = A.parent()([c // q for c in A.list()]) A_2 = MatrixSpace(FiniteField(2), n, n)(A) K_2 = A_2.kernel() R_8 = ZZ.quotient_ring(Integer(8)) @@ -1170,12 +1170,12 @@ def two_adic_symbol(A, val): B_2 = K_2.echelonized_basis_matrix() C_2 = basis_complement(B_2) n0 = C_2.nrows() - C = MatrixSpace(ZZ,n0,n)(C_2) + C = MatrixSpace(ZZ, n0, n)(C_2) A_new = C * A * C.transpose() # compute oddity modulo 8: A_8 = MatrixSpace(R_8, n0, n0)(A_new) # d0 = A_8.det() # no determinant over Z/8Z - d0 = ZZ(R_8(MatrixSpace(ZZ,n0,n0)(A_8).determinant())) + d0 = ZZ(R_8(MatrixSpace(ZZ, n0, n0)(A_8).determinant())) if d0 == 0: print("A:") print(A_new) @@ -1187,11 +1187,11 @@ def two_adic_symbol(A, val): tr8 = trace_diag_mod_8(A_8) sym = [[0, n0, d0, 1, tr8]] r = B_2.nrows() - B = MatrixSpace(ZZ,r,n)(B_2) + B = MatrixSpace(ZZ, r, n)(B_2) C = MatrixSpace(ZZ, n - r, n)(C_2) F = MatrixSpace(QQ, n - r, n - r)(C * A * C.transpose()) U = F**-1 - d = LCM([ c.denominator() for c in U.list() ]) + d = LCM([c.denominator() for c in U.list()]) R = ZZ.quotient_ring(Integer(2)**(val + 3)) u = R(d)**-1 MatR = MatrixSpace(R, n - r, n - r) @@ -1199,7 +1199,7 @@ def two_adic_symbol(A, val): U = MatZ(MatR(MatZ(U * d)) * u) X = C * A A = B * (A - X.transpose()*U*X) * B.transpose() - return [ [s[0]+m0] + s[1:] for s in sym + two_adic_symbol(A, val) ] + return [[s[0]+m0] + s[1:] for s in sym + two_adic_symbol(A, val)] class Genus_Symbol_p_adic_ring(): @@ -1336,14 +1336,14 @@ def __repr__(self): Genus symbol at 2: [1^2]_0 2^2 Genus symbol at 3: 1^2 3^2 """ - p=self._prime + p = self._prime CS_string = "" if p == 2: CS = self.canonical_symbol() for train in self.trains(): - #mark the beginning of a train with a colon + # mark the beginning of a train with a colon CS_string += " :" - #collect the indices where compartments begin and end + # collect the indices where compartments begin and end compartment_begins = [] compartment_ends = [] for comp in self.compartments(): @@ -1352,24 +1352,24 @@ def __repr__(self): for block_index in train: if block_index in compartment_begins: - #mark the beginning of this compartment with [ + # mark the beginning of this compartment with [ CS_string += "[" block = CS[block_index] block_string = "%s^%s " % (p**block[0], block[2] * block[1]) CS_string += block_string if block_index in compartment_ends: - #close this compartment with ] and remove a space + # close this compartment with ] and remove a space CS_string = CS_string[:-1] + "]" # the oddity belongs to the compartment # and is saved in its first block i = compartment_ends.index(block_index) compartment_start = compartment_begins[i] oddity = CS[compartment_start][4] - CS_string +="_%s " % oddity + CS_string += "_%s " % oddity # remove the first colon CS_string = CS_string[2:] # remove some unnecessary whitespace - CS_string = CS_string.replace(" :",":") + CS_string = CS_string.replace(" :", ":") else: for s in self._symbol: @@ -1390,7 +1390,7 @@ def _latex_(self): sage: latex(g) \mbox{Genus symbol at } 2\mbox{: }1^{4} [2^{2} 4^{1}]_{3} :16^{4} [32^{1}]_{1} """ - p=self._prime + p = self._prime CS_string = "" if p == 2: CS = self.canonical_symbol() @@ -1419,14 +1419,14 @@ def _latex_(self): i = compartment_ends.index(block_index) compartment_start = compartment_begins[i] oddity = CS[compartment_start][4] - CS_string +="_{%s}" % oddity - #remove the first colon + CS_string += "_{%s}" % oddity + # remove the first colon CS_string = CS_string[2:] else: for s in self._symbol: CS_string += " {%s}^{%s}" % (p**s[0], s[2]*s[1]) - return r"\mbox{Genus symbol at } %s\mbox{: }%s" % (p,CS_string) + return r"\mbox{Genus symbol at } %s\mbox{: }%s" % (p, CS_string) def __eq__(self, other): r""" @@ -1493,16 +1493,15 @@ def __ne__(self, other): False sage: G3 != G3 False - """ return not self == other # Added these two methods to make this class iterable... - #def __getitem__(self, i): - # return self._symbol[i] + # def __getitem__(self, i): + # return self._symbol[i] # - #def len(self): - # return len(self._symbol) + # def len(self): + # return len(self._symbol) # ------------------------------------------------------ def automorphous_numbers(self): @@ -1612,11 +1611,11 @@ def automorphous_numbers(self): II = [] for block in collect_small_blocks(G): if block.ncols() == 1: - u = block[0,0] + u = block[0, 0] if I.count(u) < 2: - I.append(block[0,0]) - else: # rank2 - q = block[0,1] + I.append(block[0, 0]) + else: # rank2 + q = block[0, 1] II += [2*q, 3*2*q, 5*2*q, 7*2*q] L = I + II @@ -1648,9 +1647,9 @@ def automorphous_numbers(self): v, u = r.val_unit(ZZ(2)) u = u % 8 assert v >= 0 - if v==0 and u==1: + if v == 0 and u == 1: automorphs.append(ZZ(2)) - if v==0 and u==5: + if v == 0 and u == 5: automorphs.append(ZZ(6)) if v in [0, 2, 4]: # this overlaps with the first two cases! automorphs.append(ZZ(5)) @@ -1797,7 +1796,7 @@ def mass(self): p = self.prime() sym = self._symbol ############## - #diagonal product + # diagonal product ############## # diagonal factors @@ -1881,14 +1880,14 @@ def _species_list(self): for k in range(sym[-1][0] + 1): if sym[s][0] == k: symbols.append(sym[s]) - s +=1 + s += 1 else: symbols.append([k, 0, 1, 0, 0]) # avoid a case distinction - sym = [[-2, 0, 1, 0, 0],[-1, 0, 1, 0, 0]] + symbols + [[sym[-1][0]+1, 0, 1, 0, 0],[sym[-1][0] + 2, 0, 1, 0, 0]] + sym = [[-2, 0, 1, 0, 0], [-1, 0, 1, 0, 0]] + symbols + [[sym[-1][0]+1, 0, 1, 0, 0], [sym[-1][0] + 2, 0, 1, 0, 0]] for k in range(1, len(sym)-1): free = True - if sym[k-1][3]==1 or sym[k+1][3]==1: + if sym[k-1][3] == 1 or sym[k+1][3] == 1: free = False n = sym[k][1] o = sym[k][4] @@ -2040,7 +2039,7 @@ def determinant(self): 3 """ p = self._prime - return prod([ p**(s[0]*s[1]) for s in self._symbol ]) + return prod([p**(s[0] * s[1]) for s in self._symbol]) det = determinant @@ -2069,7 +2068,7 @@ def dimension(self): sage: G3.dimension() 4 """ - return sum([ s[1] for s in self._symbol ]) + return sum([s[1] for s in self._symbol]) dim = dimension rank = dimension @@ -2197,13 +2196,13 @@ def excess(self): for s in self._symbol: if s[0] % 2 == 1 and s[2] in (3, 5): k += 1 - return Integer(sum([ s[4] for s in self._symbol ]) + 4*k).mod(8) + return Integer(sum([s[4] for s in self._symbol]) + 4*k).mod(8) else: k = 0 for s in self._symbol: if s[0] % 2 == 1 and s[2] == -1: k += 1 - return Integer(sum([ s[1] * (p**s[0]-1) for s in self._symbol]) + 4*k).mod(8) + return Integer(sum([s[1] * (p**s[0]-1) for s in self._symbol]) + 4*k).mod(8) def scale(self): r""" @@ -2375,7 +2374,7 @@ def __init__(self, signature_pair, local_symbols, representative=None, check=Tru if not all(isinstance(sym, Genus_Symbol_p_adic_ring) for sym in local_symbols): raise TypeError("local symbols must be a list of local genus symbols") n = signature_pair[0] + signature_pair[1] - if not all(sym.dimension()==n for sym in local_symbols): + if not all(sym.dimension() == n for sym in local_symbols): raise TypeError("all local symbols must be of the same dimension") if representative is not None: if not representative.is_symmetric(): @@ -2388,7 +2387,7 @@ def __init__(self, signature_pair, local_symbols, representative=None, check=Tru raise ValueError("the first symbol must be 2-adic") if representative is not None: if representative.base_ring() != ZZ: - representative = matrix(ZZ,representative) + representative = matrix(ZZ, representative) representative.set_immutable() self._representative = representative self._signature = signature_pair @@ -2426,8 +2425,8 @@ def __repr__(self): """ rep = "Genus" if self.dimension() <= 20: - rep += " of\n%s" %self._representative - rep += "\nSignature: %s"%(self._signature,) + rep += " of\n%s" % self._representative + rep += "\nSignature: %s" % (self._signature,) for s in self._local_symbols: rep += "\n" + s.__repr__() return rep @@ -2450,10 +2449,10 @@ def _latex_(self): """ rep = r"\mbox{Genus" if self.dimension() <= 20: - rep += r" of}\\ %s" %self._representative._latex_() + rep += r" of}\\ %s" % self._representative._latex_() else: - rep +=r"}" - rep += r"\\ \mbox{Signature: } %s"%(self._signature,) + rep += r"}" + rep += r"\\ \mbox{Signature: } %s" % (self._signature,) for s in self._local_symbols: rep += r"\\ " + s._latex_() return rep @@ -2686,7 +2685,7 @@ def spinor_generators(self, proper): if p.divides(self.determinant()): continue g = Q(A.delta(p)) - if g.gap() in U.gap(): # containment in sage is broken + if g.gap() in U.gap(): # containment in sage is broken continue else: spinor_gens.append(p) @@ -2729,15 +2728,15 @@ def _proper_is_improper(self): P = [s.prime() for s in self._local_symbols] while True: x = V.random_element() - q = x * G* x + q = x * G * x if q != 0 and all(q.valuation(p) == norm.valuation(p) for p in P): break - Q = [p for p in q.prime_factors() if (norm.valuation(p) + q.valuation(p)) % 2 != 0] + Q = [p for p in q.prime_factors() if (norm.valuation(p) + q.valuation(p)) % 2] r = ZZ.prod(Q) # M = \tau_x(L) # q = [L: L & M] A, K = self._proper_spinor_kernel() - j = A.delta(r) # diagonal embedding of r + j = A.delta(r) # diagonal embedding of r return j in K, j def signature(self): @@ -2894,7 +2893,7 @@ def rational_representative(self): for sym in self._local_symbols: p = sym._prime # it is important to use the definition of Cassels here! - if QuadraticForm(QQ,2*sym.gram_matrix()).hasse_invariant(p) == -1: + if QuadraticForm(QQ, 2*sym.gram_matrix()).hasse_invariant(p) == -1: P.append(p) q = quadratic_form_from_invariants(F=QQ, rk=m, det=det, P=P, sminus=sminus) @@ -2949,7 +2948,7 @@ def _compute_representative(self, LLL=True): m = pari(L) gp.read(SAGE_EXTCODE + "/pari/simon/qfsolve.gp") - m = gp.eval('qflllgram_indefgoon(%s)'%m) + m = gp.eval('qflllgram_indefgoon(%s)' % m) # convert the output string to sage L = pari(m).sage()[0] elif sig[1] != 0: @@ -3089,7 +3088,7 @@ def representatives(self, backend=None, algorithm=None): e = ZZ(2) if self.signature_pair()[0] == 0: e *= ZZ(-1) - Q = QuadraticForm(ZZ,e*self.representative()) + Q = QuadraticForm(ZZ, e * self.representative()) seeds = [Q] for p in self.spinor_generators(proper=False): v = Q.find_primitive_p_divisible_vector__next(p) @@ -3257,22 +3256,22 @@ def mass(self, backend='sage'): if pos * neg != 0: raise ValueError("the genus must be definite.") if pos + neg == 1: - return QQ(1)/QQ(2) + return QQ(1) / QQ(2) if backend == 'sage': mass = self._standard_mass() for sym in self._local_symbols: - mass *= sym.mass()/sym._standard_mass() + mass *= sym.mass() / sym._standard_mass() return QQ(mass.canonicalize_radical()) elif backend == 'magma': - e = 1 # lattices in magma are positive definite - if neg !=0: + e = 1 # lattices in magma are positive definite + if neg != 0: e = -1 # for some reason LatticeWithGram wants a dense matrix - L = magma(e*self.representative().dense_matrix()) + L = magma(e * self.representative().dense_matrix()) L = L.LatticeWithGram() return QQ(L.Mass()) else: - raise ValueError("unknown backend: %s"%backend) + raise ValueError("unknown backend: %s" % backend) def level(self): r""" @@ -3378,18 +3377,18 @@ def _gram_from_jordan_block(p, block, discr_form=False): if p == 2: o = ZZ(block[3]) t = ZZ(block[4]) - U = matrix(QQ, 2, [0,1, 1,0]) - V = matrix(QQ, 2, [2,1, 1,2]) + U = matrix(QQ, 2, [0, 1, 1, 0]) + V = matrix(QQ, 2, [2, 1, 1, 2]) W = matrix(QQ, 1, [1]) if o == 0: if det in [1, 7]: qL = (rk // 2) * [U] else: - qL = (rk//2 - 1)*[U] + [V] + qL = (rk // 2 - 1) * [U] + [V] if o == 1: if rk % 2 == 1: qL = max(0, (rk - 3) // 2) * [U] - if t*det % 8 in [3, 5]: + if t * det % 8 in [3, 5]: qL += [V] elif rk >= 3: qL += [U] @@ -3400,21 +3399,21 @@ def _gram_from_jordan_block(p, block, discr_form=False): else: det = 1 qL = max(0, (rk - 4) // 2) * [U] - if (det , t) == (1, 0): + if (det, t) == (1, 0): qL += [U, 1 * W, 7 * W] - if (det , t) == (1, 2): + if (det, t) == (1, 2): qL += [U, 1 * W, 1 * W] - if (det , t) == (1, 4): + if (det, t) == (1, 4): qL += [V, 1 * W, 3 * W] - if (det , t) == (1, 6): + if (det, t) == (1, 6): qL += [U, 7 * W, 7 * W] - if (det , t) == (-1, 0): + if (det, t) == (-1, 0): qL += [V, 1 * W, 7 * W] - if (det , t) == (-1, 2): + if (det, t) == (-1, 2): qL += [U, 3 * W, 7 * W] - if (det , t) == (-1, 4): + if (det, t) == (-1, 4): qL += [U, 1 * W, 3 * W] - if (det , t) == (-1, 6): + if (det, t) == (-1, 6): qL += [U, 1 * W, 5 * W] # if the rank is 2 there is a U too much if rk == 2: @@ -3508,7 +3507,7 @@ def M_p(species, p): return QQ(1) n = species.abs() s = (n + 1) // ZZ(2) - mp = ZZ(2) * ZZ.prod(ZZ(1) - p**(-2*k) for k in range(1, s)) + mp = ZZ(2) * ZZ.prod(ZZ(1) - p**(-2 * k) for k in range(1, s)) if n % 2 == 0: - mp *= ZZ(1) - species.sign() * p**(-s) - return QQ(1) / mp + mp *= ZZ.one() - species.sign() * p**(-s) + return QQ.one() / mp diff --git a/src/sage/quadratic_forms/quadratic_form__local_normal_form.py b/src/sage/quadratic_forms/quadratic_form__local_normal_form.py index a74dccc3fb3..5770a3c22f0 100644 --- a/src/sage/quadratic_forms/quadratic_form__local_normal_form.py +++ b/src/sage/quadratic_forms/quadratic_form__local_normal_form.py @@ -1,7 +1,6 @@ """ Local Normal Form """ - # **************************************************************************** # Copyright (C) 2007 William Stein and Jonathan Hanke # @@ -18,18 +17,19 @@ # **************************************************************************** import copy + from sage.rings.infinity import Infinity -from sage.rings.integer_ring import IntegerRing, ZZ +from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ -from sage.arith.misc import GCD -from sage.arith.misc import valuation -from sage.arith.misc import is_prime +from sage.arith.misc import GCD, valuation, is_prime def find_entry_with_minimal_scale_at_prime(self, p): r""" - Finds the entry of the quadratic form with minimal scale at the - prime `p`, preferring diagonal entries in case of a tie. (I.e. If + Find the entry of the quadratic form with minimal scale at the + prime `p`, preferring diagonal entries in case of a tie. + + (I.e. If we write the quadratic form as a symmetric matrix `M`, then this entry ``M[i,j]`` has the minimal valuation at the prime `p`.) @@ -56,14 +56,13 @@ def find_entry_with_minimal_scale_at_prime(self, p): (1, 1) sage: Q.find_entry_with_minimal_scale_at_prime(5) (0, 0) - """ n = self.dim() min_val = Infinity ij_index = None val_2 = valuation(2, p) for d in range(n): # d = difference j-i - for e in range(n - d): # e is the length of the diagonal with value d. + for e in range(n - d): # e is the length of the diagonal with value d. # Compute the valuation of the entry if d == 0: @@ -121,9 +120,9 @@ def local_normal_form(self, p): [ * 6 ] """ # Sanity Checks - if (self.base_ring() != IntegerRing()): + if self.base_ring() != ZZ: raise NotImplementedError("this currently only works for quadratic forms defined over ZZ") - if not ((p>=2) and is_prime(p)): + if not (p >= 2 and is_prime(p)): raise TypeError("p is not a positive prime number") # Some useful local variables @@ -145,12 +144,12 @@ def local_normal_form(self, p): min_val = valuation(Q[min_i, min_j], p) # Error if we still haven't seen non-zero coefficients! - if (min_val == Infinity): + if min_val == Infinity: raise RuntimeError("the original matrix is degenerate") # Step 2: Arrange for the upper leftmost entry to have minimal valuation # ---------------------------------------------------------------------- - if (min_i == min_j): + if min_i == min_j: block_size = 1 Q.swap_variables(0, min_i, in_place=True) else: @@ -159,7 +158,7 @@ def local_normal_form(self, p): Q.swap_variables(1, min_j, in_place=True) # 1x1 => make upper left the smallest - if (p != 2): + if p != 2: block_size = 1 Q.add_symmetric(1, 0, 1, in_place=True) # 2x2 => replace it with the appropriate 2x2 matrix @@ -171,8 +170,8 @@ def local_normal_form(self, p): min_scale = p ** min_val # This is the minimal valuation of the Hessian matrix entries. # Perform cancellation over Z by ensuring divisibility - if (block_size == 1): - a = 2 * Q[0,0] + if block_size == 1: + a = 2 * Q[0, 0] for j in range(block_size, n): b = Q[0, j] g = GCD(a, b) @@ -181,16 +180,16 @@ def local_normal_form(self, p): if valuation(g, p) != valuation(a, p): raise RuntimeError("we have a problem with our rescaling not preserving p-integrality") - Q.multiply_variable(ZZ(a/g), j, in_place=True) # Ensures that the new b entry is divisible by a - Q.add_symmetric(ZZ(-b/g), j, 0, in_place=True) # Performs the cancellation + Q.multiply_variable(ZZ(a / g), j, in_place=True) # Ensures that the new b entry is divisible by a + Q.add_symmetric(ZZ(-b / g), j, 0, in_place=True) # Performs the cancellation - elif (block_size == 2): - a1 = 2 * Q[0,0] + elif block_size == 2: + a1 = 2 * Q[0, 0] a2 = Q[0, 1] b1 = Q[1, 0] # This is the same as a2 b2 = 2 * Q[1, 1] - big_det = (a1*b2 - a2*b1) + big_det = a1 * b2 - a2 * b1 small_det = big_det / (min_scale * min_scale) # Cancels out the rows/columns of the 2x2 block @@ -202,18 +201,18 @@ def local_normal_form(self, p): Q.multiply_variable(big_det, j, in_place=True) # Performs the cancellation (by producing -big_det * jth row/column) - Q.add_symmetric(ZZ(-(a*b2 - b*a2)), j, 0, in_place=True) - Q.add_symmetric(ZZ(-(-a*b1 + b*a1)), j, 1, in_place=True) + Q.add_symmetric(ZZ(-(a * b2 - b * a2)), j, 0, in_place=True) + Q.add_symmetric(ZZ(-(-a * b1 + b * a1)), j, 1, in_place=True) # Now remove the extra factor (non p-unit factor) in big_det we introduced above Q.divide_variable(ZZ(min_scale * min_scale), j, in_place=True) # Uses Cassels's proof to replace the remaining 2 x 2 block - if (((1 + small_det) % 8) == 0): + if (1 + small_det) % 8 == 0: Q[0, 0] = 0 Q[1, 1] = 0 Q[0, 1] = min_scale - elif (((5 + small_det) % 8) == 0): + elif (5 + small_det) % 8 == 0: Q[0, 0] = min_scale Q[1, 1] = min_scale Q[0, 1] = min_scale @@ -223,7 +222,7 @@ def local_normal_form(self, p): # Check that the cancellation worked, extract the upper-left block, and trim Q to handle the next block. for i in range(block_size): for j in range(block_size, n): - if Q[i,j] != 0: + if Q[i, j] != 0: raise RuntimeError(f"the cancellation did not work properly at entry ({i},{j})") Q_Jordan = Q_Jordan + Q.extract_variables(range(block_size)) Q = Q.extract_variables(range(block_size, n)) @@ -300,7 +299,7 @@ def jordan_blocks_by_scale_and_unimodular(self, p, safe_flag=True): return copy.deepcopy(self.__jordan_blocks_by_scale_and_unimodular_dict[p]) else: return self.__jordan_blocks_by_scale_and_unimodular_dict[p] - except Exception: + except (KeyError, AttributeError): # Initialize the global dictionary if it doesn't exist if not hasattr(self, '__jordan_blocks_by_scale_and_unimodular_dict'): self.__jordan_blocks_by_scale_and_unimodular_dict = {} @@ -317,28 +316,28 @@ def jordan_blocks_by_scale_and_unimodular(self, p, safe_flag=True): tmp_Jordan_list = [] i = 0 start_ind = 0 - if (n >= 2) and (Q1[0,1] != 0): - start_scale = valuation(Q1[0,1], p) - 1 + if n >= 2 and Q1[0, 1] != 0: + start_scale = valuation(Q1[0, 1], p) - 1 else: - start_scale = valuation(Q1[0,0], p) + start_scale = valuation(Q1[0, 0], p) - while (i < n): + while i < n: # Determine the size of the current block - if (i == n-1) or (Q1[i,i+1] == 0): + if i == n - 1 or Q1[i, i + 1] == 0: block_size = 1 else: block_size = 2 # Determine the valuation of the current block if block_size == 1: - block_scale = valuation(Q1[i,i], p) + block_scale = valuation(Q1[i, i], p) else: - block_scale = valuation(Q1[i,i+1], p) - 1 + block_scale = valuation(Q1[i, i + 1], p) - 1 # Process the previous block if the valuation increased if block_scale > start_scale: - tmp_Jordan_list += [(start_scale, Q1.extract_variables(range(start_ind, i)).scale_by_factor(ZZ(1) / (QQ(p)**(start_scale))))] + tmp_Jordan_list += [(start_scale, Q1.extract_variables(range(start_ind, i)).scale_by_factor(ZZ.one() / QQ(p)**start_scale))] start_ind = i start_scale = block_scale @@ -346,7 +345,7 @@ def jordan_blocks_by_scale_and_unimodular(self, p, safe_flag=True): i += block_size # Add the last block - tmp_Jordan_list += [(start_scale, Q1.extract_variables(range(start_ind, n)).scale_by_factor(ZZ(1) / QQ(p)**(start_scale)))] + tmp_Jordan_list += [(start_scale, Q1.extract_variables(range(start_ind, n)).scale_by_factor(ZZ.one() / QQ(p)**start_scale))] # Cache the result self.__jordan_blocks_by_scale_and_unimodular_dict[p] = tmp_Jordan_list diff --git a/src/sage/rings/abc.pyx b/src/sage/rings/abc.pyx index d967cfbb95c..6ad9dd8d6f0 100644 --- a/src/sage/rings/abc.pyx +++ b/src/sage/rings/abc.pyx @@ -14,13 +14,13 @@ class NumberField_quadratic(Field): EXAMPLES:: sage: import sage.rings.abc - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: isinstance(K, sage.rings.abc.NumberField_quadratic) # optional - sage.rings.number_field + sage: K. = QuadraticField(2) # needs sage.rings.number_field + sage: isinstance(K, sage.rings.abc.NumberField_quadratic) # needs sage.rings.number_field True By design, there is a unique direct subclass:: - sage: sage.rings.abc.NumberField_quadratic.__subclasses__() # optional - sage.rings.number_field + sage: sage.rings.abc.NumberField_quadratic.__subclasses__() # needs sage.rings.number_field [] sage: len(sage.rings.abc.NumberField_quadratic.__subclasses__()) <= 1 @@ -40,13 +40,13 @@ class NumberField_cyclotomic(Field): EXAMPLES:: sage: import sage.rings.abc - sage: K. = CyclotomicField(15) # optional - sage.rings.number_field - sage: isinstance(K, sage.rings.abc.NumberField_cyclotomic) # optional - sage.rings.number_field + sage: K. = CyclotomicField(15) # needs sage.rings.number_field + sage: isinstance(K, sage.rings.abc.NumberField_cyclotomic) # needs sage.rings.number_field True By design, there is a unique direct subclass:: - sage: sage.rings.abc.NumberField_cyclotomic.__subclasses__() # optional - sage.rings.number_field + sage: sage.rings.abc.NumberField_cyclotomic.__subclasses__() # needs sage.rings.number_field [] sage: len(sage.rings.abc.NumberField_cyclotomic.__subclasses__()) <= 1 @@ -66,13 +66,13 @@ class UniversalCyclotomicField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: K = UniversalCyclotomicField() # optional - sage.rings.number_field - sage: isinstance(K, sage.rings.abc.UniversalCyclotomicField) # optional - sage.rings.number_field + sage: K = UniversalCyclotomicField() # needs sage.rings.number_field + sage: isinstance(K, sage.rings.abc.UniversalCyclotomicField) # needs sage.rings.number_field True By design, there is a unique direct subclass:: - sage: sage.rings.abc.UniversalCyclotomicField.__subclasses__() # optional - sage.rings.number_field + sage: sage.rings.abc.UniversalCyclotomicField.__subclasses__() # needs sage.rings.number_field [] sage: len(sage.rings.abc.NumberField_cyclotomic.__subclasses__()) <= 1 @@ -92,16 +92,16 @@ class AlgebraicField_common(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(QQbar, sage.rings.abc.AlgebraicField_common) # optional - sage.rings.number_field + sage: isinstance(QQbar, sage.rings.abc.AlgebraicField_common) # needs sage.rings.number_field True - sage: isinstance(AA, sage.rings.abc.AlgebraicField_common) # optional - sage.rings.number_field + sage: isinstance(AA, sage.rings.abc.AlgebraicField_common) # needs sage.rings.number_field True By design, other than the abstract subclasses :class:`~sage.rings.abc.AlgebraicField` and :class:`~sage.rings.abc.AlgebraicRealField`, there is only one direct implementation subclass:: - sage: sage.rings.abc.AlgebraicField_common.__subclasses__() # optional - sage.rings.number_field + sage: sage.rings.abc.AlgebraicField_common.__subclasses__() # needs sage.rings.number_field [, , ] @@ -123,14 +123,14 @@ class AlgebraicField(AlgebraicField_common): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(QQbar, sage.rings.abc.AlgebraicField) # optional - sage.rings.number_field + sage: isinstance(QQbar, sage.rings.abc.AlgebraicField) # needs sage.rings.number_field True - sage: isinstance(AA, sage.rings.abc.AlgebraicField) # optional - sage.rings.number_field + sage: isinstance(AA, sage.rings.abc.AlgebraicField) # needs sage.rings.number_field False By design, there is a unique direct subclass:: - sage: sage.rings.abc.AlgebraicField.__subclasses__() # optional - sage.rings.number_field + sage: sage.rings.abc.AlgebraicField.__subclasses__() # needs sage.rings.number_field [] sage: len(sage.rings.abc.AlgebraicField.__subclasses__()) <= 1 @@ -150,14 +150,14 @@ class AlgebraicRealField(AlgebraicField_common): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(QQbar, sage.rings.abc.AlgebraicRealField) # optional - sage.rings.number_field + sage: isinstance(QQbar, sage.rings.abc.AlgebraicRealField) # needs sage.rings.number_field False - sage: isinstance(AA, sage.rings.abc.AlgebraicRealField) # optional - sage.rings.number_field + sage: isinstance(AA, sage.rings.abc.AlgebraicRealField) # needs sage.rings.number_field True By design, there is a unique direct subclass:: - sage: sage.rings.abc.AlgebraicRealField.__subclasses__() # optional - sage.rings.number_field + sage: sage.rings.abc.AlgebraicRealField.__subclasses__() # needs sage.rings.number_field [] sage: len(sage.rings.abc.AlgebraicRealField.__subclasses__()) <= 1 @@ -177,12 +177,12 @@ cdef class RealField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(RR, sage.rings.abc.RealField) + sage: isinstance(RR, sage.rings.abc.RealField) # needs sage.rings.real_mpfr True By design, there is a unique direct subclass:: - sage: sage.rings.abc.RealField.__subclasses__() + sage: sage.rings.abc.RealField.__subclasses__() # needs sage.rings.real_mpfr [] sage: len(sage.rings.abc.RealField.__subclasses__()) <= 1 @@ -202,12 +202,12 @@ class RealBallField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(RBF, sage.rings.abc.RealBallField) + sage: isinstance(RBF, sage.rings.abc.RealBallField) # needs sage.libs.flint True By design, there is a unique direct subclass:: - sage: sage.rings.abc.RealBallField.__subclasses__() + sage: sage.rings.abc.RealBallField.__subclasses__() # needs sage.libs.flint [] sage: len(sage.rings.abc.RealBallField.__subclasses__()) <= 1 @@ -227,12 +227,12 @@ cdef class RealIntervalField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(RIF, sage.rings.abc.RealIntervalField) + sage: isinstance(RIF, sage.rings.abc.RealIntervalField) # needs sage.rings.real_interval_field True By design, there is a unique direct subclass:: - sage: sage.rings.abc.RealIntervalField.__subclasses__() + sage: sage.rings.abc.RealIntervalField.__subclasses__() # needs sage.rings.real_interval_field [] sage: len(sage.rings.abc.RealIntervalField.__subclasses__()) <= 1 @@ -277,12 +277,12 @@ cdef class ComplexField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(CC, sage.rings.abc.ComplexField) + sage: isinstance(CC, sage.rings.abc.ComplexField) # needs sage.rings.real_mpfr True By design, there is a unique direct subclass:: - sage: sage.rings.abc.ComplexField.__subclasses__() + sage: sage.rings.abc.ComplexField.__subclasses__() # needs sage.rings.real_mpfr [] sage: len(sage.rings.abc.ComplexField.__subclasses__()) <= 1 @@ -302,12 +302,12 @@ class ComplexBallField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(CBF, sage.rings.abc.ComplexBallField) + sage: isinstance(CBF, sage.rings.abc.ComplexBallField) # needs sage.libs.flint True By design, there is a unique direct subclass:: - sage: sage.rings.abc.ComplexBallField.__subclasses__() + sage: sage.rings.abc.ComplexBallField.__subclasses__() # needs sage.libs.flint [] sage: len(sage.rings.abc.ComplexBallField.__subclasses__()) <= 1 @@ -327,12 +327,12 @@ class ComplexIntervalField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(CIF, sage.rings.abc.ComplexIntervalField) + sage: isinstance(CIF, sage.rings.abc.ComplexIntervalField) # needs sage.rings.complex_interval_field True By design, there is a unique direct subclass:: - sage: sage.rings.abc.ComplexIntervalField.__subclasses__() + sage: sage.rings.abc.ComplexIntervalField.__subclasses__() # needs sage.rings.complex_interval_field [] sage: len(sage.rings.abc.ComplexIntervalField.__subclasses__()) <= 1 @@ -352,12 +352,12 @@ cdef class ComplexDoubleField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(CDF, sage.rings.abc.ComplexDoubleField) + sage: isinstance(CDF, sage.rings.abc.ComplexDoubleField) # needs sage.rings.complex_double True By design, there is a unique direct subclass:: - sage: sage.rings.abc.ComplexDoubleField.__subclasses__() + sage: sage.rings.abc.ComplexDoubleField.__subclasses__() # needs sage.rings.complex_double [] sage: len(sage.rings.abc.ComplexDoubleField.__subclasses__()) <= 1 @@ -403,13 +403,13 @@ class Order: sage: import sage.rings.abc sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1); O = K.order(2*a) # optional - sage.rings.number_field - sage: isinstance(O, sage.rings.abc.Order) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1); O = K.order(2*a) # needs sage.rings.number_field + sage: isinstance(O, sage.rings.abc.Order) # needs sage.rings.number_field True By design, there is a unique direct subclass:: - sage: sage.rings.abc.Order.__subclasses__() # optional - sage.rings.number_field + sage: sage.rings.abc.Order.__subclasses__() # needs sage.rings.number_field [] sage: len(sage.rings.abc.Order.__subclasses__()) <= 1 @@ -429,14 +429,14 @@ class pAdicRing(EuclideanDomain): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(Zp(5), sage.rings.abc.pAdicRing) # optional - sage.rings.padics + sage: isinstance(Zp(5), sage.rings.abc.pAdicRing) # needs sage.rings.padics True - sage: isinstance(Qp(5), sage.rings.abc.pAdicRing) # optional - sage.rings.padics + sage: isinstance(Qp(5), sage.rings.abc.pAdicRing) # needs sage.rings.padics False By design, there is a unique direct subclass:: - sage: sage.rings.abc.pAdicRing.__subclasses__() # optional - sage.rings.padics + sage: sage.rings.abc.pAdicRing.__subclasses__() # needs sage.rings.padics [] sage: len(sage.rings.abc.pAdicRing.__subclasses__()) <= 1 @@ -456,14 +456,14 @@ class pAdicField(Field): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(Zp(5), sage.rings.abc.pAdicField) # optional - sage.rings.padics + sage: isinstance(Zp(5), sage.rings.abc.pAdicField) # needs sage.rings.padics False - sage: isinstance(Qp(5), sage.rings.abc.pAdicField) # optional - sage.rings.padics + sage: isinstance(Qp(5), sage.rings.abc.pAdicField) # needs sage.rings.padics True By design, there is a unique direct subclass:: - sage: sage.rings.abc.pAdicField.__subclasses__() # optional - sage.rings.padics + sage: sage.rings.abc.pAdicField.__subclasses__() # needs sage.rings.padics [] sage: len(sage.rings.abc.pAdicField.__subclasses__()) <= 1 @@ -483,13 +483,13 @@ cdef class SymbolicRing(CommutativeRing): EXAMPLES:: sage: import sage.rings.abc - sage: isinstance(SR, sage.rings.abc.SymbolicRing) # optional - sage.symbolic + sage: isinstance(SR, sage.rings.abc.SymbolicRing) # needs sage.symbolic True By design, other than the abstract subclass :class:`~sage.rings.abc.CallableSymbolicExpressionRing`, there is only one direct implementation subclass:: - sage: sage.rings.abc.SymbolicRing.__subclasses__() # optional - sage.symbolic + sage: sage.rings.abc.SymbolicRing.__subclasses__() # needs sage.symbolic [, ] @@ -510,13 +510,13 @@ class CallableSymbolicExpressionRing(SymbolicRing): EXAMPLES:: sage: import sage.rings.abc - sage: f = x.function(x).parent() # optional - sage.symbolic - sage: isinstance(f, sage.rings.abc.CallableSymbolicExpressionRing) # optional - sage.symbolic + sage: f = x.function(x).parent() # needs sage.symbolic + sage: isinstance(f, sage.rings.abc.CallableSymbolicExpressionRing) # needs sage.symbolic True By design, there is a unique direct subclass:: - sage: sage.rings.abc.CallableSymbolicExpressionRing.__subclasses__() # optional - sage.symbolic + sage: sage.rings.abc.CallableSymbolicExpressionRing.__subclasses__() # needs sage.symbolic [] sage: len(sage.rings.abc.CallableSymbolicExpressionRing.__subclasses__()) <= 1 diff --git a/src/sage/rings/algebraic_closure_finite_field.py b/src/sage/rings/algebraic_closure_finite_field.py index b8dff4c3903..d7ad457f88c 100644 --- a/src/sage/rings/algebraic_closure_finite_field.py +++ b/src/sage/rings/algebraic_closure_finite_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Algebraic closures of finite fields diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py index a1fe036917e..8a6002af635 100644 --- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py @@ -823,7 +823,7 @@ def univariate_decomposition(self): for a, m in df: am = a**m q, r = denominator.quo_rem(am) - assert r==0 + assert r == 0 numer = p * q.inverse_mod(am) % am # The inverse exists because the product and a**m # are relatively prime. @@ -1930,7 +1930,7 @@ def asymptotics_smooth(self, p, alpha, N, asy_var, coordinate=None, if v.mod(2) == 0: At_derivs = diff_all(At, T, 2 * N - 2, sub=hderivs1, sub_final=[Tstar, atP], rekey=AA) - Phitu_derivs = diff_all(Phitu, T, 2 * N - 2 +v, + Phitu_derivs = diff_all(Phitu, T, 2 * N - 2 + v, sub=hderivs1, sub_final=[Tstar, atP], zero_order=v + 1, rekey=BB) else: diff --git a/src/sage/rings/big_oh.py b/src/sage/rings/big_oh.py index 21938a2256b..e9b22e77b37 100644 --- a/src/sage/rings/big_oh.py +++ b/src/sage/rings/big_oh.py @@ -119,7 +119,7 @@ def O(*x, **kwds): Traceback (most recent call last): ... ArithmeticError: O(y) not defined - sage: O(x, y) # needs sage.symbolic + sage: O(x, y) Traceback (most recent call last): ... ArithmeticError: O(x, y) not defined diff --git a/src/sage/rings/cfinite_sequence.py b/src/sage/rings/cfinite_sequence.py index 733fbcbd6a7..7229dab646a 100644 --- a/src/sage/rings/cfinite_sequence.py +++ b/src/sage/rings/cfinite_sequence.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.symbolic r""" C-Finite Sequences diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx index 95e615f3ee6..198e5edb591 100644 --- a/src/sage/rings/complex_arb.pyx +++ b/src/sage/rings/complex_arb.pyx @@ -101,13 +101,14 @@ Coercion Automatic coercions work as expected:: - sage: bpol = 1/3*CBF(i) + AA(sqrt(2)) # optional - sage.symbolic - sage: bpol += polygen(RealBallField(20), 'x') + QQbar(i) # optional - sage.symbolic - sage: bpol # optional - sage.symbolic + sage: # needs sage.symbolic + sage: bpol = 1/3*CBF(i) + AA(sqrt(2)) + sage: bpol += polygen(RealBallField(20), 'x') + QQbar(i) + sage: bpol x + [1.41421 +/- ...e-6] + [1.33333 +/- ...e-6]*I - sage: bpol.parent() # optional - sage.symbolic + sage: bpol.parent() Univariate Polynomial Ring in x over Complex ball field with 20 bits of precision - sage: bpol/3 # optional - sage.symbolic + sage: bpol/3 ([0.333333 +/- ...e-7])*x + [0.47140 +/- ...e-6] + [0.44444 +/- ...e-6]*I TESTS:: @@ -117,12 +118,12 @@ TESTS:: :: - sage: SR.coerce(CBF(0.42 + 3.33*I)) # optional - sage.symbolic + sage: SR.coerce(CBF(0.42 + 3.33*I)) # needs sage.symbolic [0.4200000000000000 +/- ...e-17] + [3.330000000000000 +/- ...e-17]*I Check that :trac:`19839` is fixed:: - sage: log(SR(CBF(0.42))).pyobject().parent() # optional - sage.symbolic + sage: log(SR(CBF(0.42))).pyobject().parent() # needs sage.symbolic Complex ball field with 53 bits of precision :trac:`24621`:: @@ -153,7 +154,7 @@ import sage.categories.fields cimport sage.rings.abc cimport sage.rings.rational -from cpython.int cimport PyInt_AS_LONG +from cpython.long cimport PyLong_AsLong from cpython.object cimport Py_EQ, Py_NE from cpython.complex cimport PyComplex_FromDoubles @@ -591,15 +592,15 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField): 1.000000000000000 sage: CBF(1, 1) 1.000000000000000 + 1.000000000000000*I - sage: CBF(pi, sqrt(2)) # optional - sage.symbolic + sage: CBF(pi, sqrt(2)) # needs sage.symbolic [3.141592653589793 +/- ...e-16] + [1.414213562373095 +/- ...e-16]*I sage: CBF(I) 1.000000000000000*I - sage: CBF(pi + I/3) # optional - sage.symbolic + sage: CBF(pi + I/3) # needs sage.symbolic [3.141592653589793 +/- ...e-16] + [0.3333333333333333 +/- ...e-17]*I sage: CBF(QQbar(i/7)) # abs tol 1e-16 [0.1428571428571429 +/- 4.29e-17]*I - sage: CBF(AA(sqrt(2))) # optional - sage.symbolic + sage: CBF(AA(sqrt(2))) # needs sage.symbolic [1.414213562373095 +/- ...e-16] sage: CBF(CIF(0, 1)) 1.000000000000000*I @@ -616,9 +617,9 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField): sage: NF. = QuadraticField(-2) sage: CBF(1/5 + a/2) [0.2000000000000000 +/- ...e-17] + [0.707106781186547 +/- ...e-16]*I - sage: CBF(infinity, NaN) + sage: CBF(infinity, NaN) # needs sage.symbolic [+/- inf] + nan*I - sage: CBF(x) + sage: CBF(x) # needs sage.symbolic Traceback (most recent call last): ... TypeError: unable to convert x to a ComplexBall @@ -636,13 +637,14 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField): The following conversions used to yield incorrect enclosures:: - sage: a = CBF(airy_ai(1)); a # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = CBF(airy_ai(1)); a [0.1352924163128814 +/- 6.95e-17] - sage: a.overlaps(ComplexBallField(100).one().airy_ai()) # optional - sage.symbolic + sage: a.overlaps(ComplexBallField(100).one().airy_ai()) True - sage: v = CBF(zetaderiv(1, 3/2)); v # optional - sage.symbolic + sage: v = CBF(zetaderiv(1, 3/2)); v [-3.932239737431101 +/- 5.58e-16] - sage: v.overlaps(ComplexBallField(100)(3/2).zetaderiv(1)) # optional - sage.symbolic + sage: v.overlaps(ComplexBallField(100)(3/2).zetaderiv(1)) True """ try: @@ -1077,7 +1079,7 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField): ....: return CBF(NaN) ....: else: ....: return z.sqrt() - sage: CBF.integral(my_sqrt, -1 + CBF(i), -1 - CBF(i)) + sage: CBF.integral(my_sqrt, -1 + CBF(i), -1 - CBF(i)) # needs sage.symbolic [+/- ...e-14] + [-0.4752076627926 +/- 5...e-14]*I Note, though, that proper handling of the ``analytic`` flag is required @@ -1085,7 +1087,7 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField): sage: correct = CBF.integral(my_sqrt, 1, 2); correct [1.21895141649746 +/- ...e-15] - sage: RBF(integral(sqrt(x), x, 1, 2)) # long time # optional - sage.symbolic + sage: RBF(integral(sqrt(x), x, 1, 2)) # long time # needs sage.symbolic [1.21895141649746 +/- ...e-15] sage: wrong = CBF.integral(lambda z, _: z.sqrt(), 1, 2) # WRONG! sage: correct - wrong @@ -1348,7 +1350,7 @@ cdef class ComplexBall(RingElement): 0 sage: ComplexBall(CBF100, ComplexBall(CBF53, ComplexBall(CBF100, 1/3))) [0.333333333333333333333333333333 +/- ...e-31] - sage: ComplexBall(CBF100, RBF(pi)) + sage: ComplexBall(CBF100, RBF(pi)) # needs sage.symbolic [3.141592653589793 +/- ...e-16] sage: ComplexBall(CBF100, -3r) @@ -1512,7 +1514,7 @@ cdef class ComplexBall(RingElement): TESTS:: - sage: [loads(dumps(b)).identical(b) for b in + sage: [loads(dumps(b)).identical(b) for b in # needs sage.symbolic ....: [ComplexBallField(60)(1/3 + i*pi), CBF(NaN)]] [True, True] """ @@ -2104,9 +2106,9 @@ cdef class ComplexBall(RingElement): sage: CBF(17, 1023).nbits() 10 - sage: CBF(1/3, NaN).nbits() + sage: CBF(1/3, NaN).nbits() # needs sage.symbolic 53 - sage: CBF(NaN).nbits() + sage: CBF(NaN).nbits() # needs sage.symbolic 0 """ return acb_bits(self.value) @@ -2121,13 +2123,13 @@ cdef class ComplexBall(RingElement): their parent's nominal precision (see :mod:`~sage.rings.real_arb` for more information):: - sage: b = CBF(exp(I*pi/3).n(100)) - sage: b.mid() + sage: b = CBF(exp(I*pi/3).n(100)) # needs sage.symbolic + sage: b.mid() # needs sage.symbolic 0.50000000000000000000000000000 + 0.86602540378443864676372317075*I The ``round()`` method rounds such a ball to its parent's precision:: - sage: b.round().mid() + sage: b.round().mid() # needs sage.symbolic 0.500000000000000 + 0.866025403784439*I .. SEEALSO:: :meth:`trim` @@ -2150,7 +2152,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(exp(I*pi/3)).accuracy() + sage: CBF(exp(I*pi/3)).accuracy() # needs sage.symbolic 51 sage: CBF(I/2).accuracy() == CBF.base().maximal_accuracy() True @@ -2218,7 +2220,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(NaN).is_NaN() + sage: CBF(NaN).is_NaN() # needs sage.symbolic True sage: CBF(-5).gamma().is_NaN() True @@ -2261,7 +2263,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(pi, 1/3).is_nonzero() + sage: CBF(pi, 1/3).is_nonzero() # needs sage.symbolic True sage: CBF(RIF(-0.5, 0.5), 1/3).is_nonzero() True @@ -2505,7 +2507,7 @@ cdef class ComplexBall(RingElement): sage: CBF(1).contains_exact(CBF(1)) True - sage: CBF(sqrt(2)).contains_exact(sqrt(2)) # optional - sage.symbolic + sage: CBF(sqrt(2)).contains_exact(sqrt(2)) # needs sage.symbolic Traceback (most recent call last): ... TypeError: unsupported type: @@ -2732,7 +2734,7 @@ cdef class ComplexBall(RingElement): cdef ComplexBall self = val cdef ComplexBall res = self._new() if is_small_python_int(shift): - acb_mul_2exp_si(res.value, self.value, PyInt_AS_LONG(shift)) + acb_mul_2exp_si(res.value, self.value, PyLong_AsLong(shift)) elif isinstance(shift, Integer): sig_on() fmpz_init(tmpz) @@ -2805,7 +2807,7 @@ cdef class ComplexBall(RingElement): sage: CBF(-1)**(1/2) 1.000000000000000*I - sage: CBF(e)**CBF(i*pi) + sage: CBF(e)**CBF(i*pi) # needs sage.symbolic [-1.00000000000000 +/- ...e-16] + [+/- ...e-15]*I sage: CBF(0, 1)**AA(2)**(1/2) [-0.60569986707881 +/- ...e-15] + [0.79569320156748 +/- ...e-15]*I @@ -2824,13 +2826,13 @@ cdef class ComplexBall(RingElement): TESTS:: - sage: (CBF(e)**CBF(i))**RBF(pi) + sage: (CBF(e)**CBF(i))**RBF(pi) # needs sage.symbolic [-1.0000000000000 +/- ...e-15] + [+/- ...e-15]*I sage: CBF(2*i)**10r -1024.000000000000 sage: CBF(1,1) ^ -1r 0.5000000000000000 - 0.5000000000000000*I - sage: CBF(2)**SR.var('x') # optional - sage.symbolic + sage: CBF(2)**SR.var('x') # needs sage.symbolic 2.000000000000000^x """ if (isinstance(base, ComplexBall) @@ -2864,7 +2866,7 @@ cdef class ComplexBall(RingElement): TESTS:: - sage: CBF(2).pow(SR.var('x')) # optional - sage.symbolic + sage: CBF(2).pow(SR.var('x')) # needs sage.symbolic Traceback (most recent call last): ... TypeError: no canonical coercion from Symbolic Ring to Complex ball @@ -2874,7 +2876,7 @@ cdef class ComplexBall(RingElement): cdef ComplexBall res = self._new() if is_small_python_int(expo): if _do_sig(prec(self)): sig_on() - acb_pow_si(res.value, self.value, PyInt_AS_LONG(expo), prec(self)) + acb_pow_si(res.value, self.value, PyLong_AsLong(expo), prec(self)) if _do_sig(prec(self)): sig_off() elif isinstance(expo, Integer): if _do_sig(prec(self)): sig_on() @@ -3119,7 +3121,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(i*pi).exp() + sage: CBF(i*pi).exp() # needs sage.symbolic [-1.00000000000000 +/- ...e-16] + [+/- ...e-16]*I """ cdef ComplexBall res = self._new() @@ -3136,7 +3138,7 @@ cdef class ComplexBall(RingElement): sage: CBF(1/2).exppii() 1.000000000000000*I - sage: CBF(0, -1/pi).exppii() + sage: CBF(0, -1/pi).exppii() # needs sage.symbolic [2.71828182845904 +/- ...e-15] """ cdef ComplexBall res = self._new() @@ -3151,7 +3153,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(i*pi).sin() + sage: CBF(i*pi).sin() # needs sage.symbolic [11.54873935725775 +/- ...e-15]*I """ cdef ComplexBall res = self._new() @@ -3166,7 +3168,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(i*pi).cos() + sage: CBF(i*pi).cos() # needs sage.symbolic [11.59195327552152 +/- ...e-15] """ cdef ComplexBall res = self._new() @@ -3181,9 +3183,9 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(pi/2, 1/10).tan() + sage: CBF(pi/2, 1/10).tan() # needs sage.symbolic [+/- ...e-14] + [10.03331113225399 +/- ...e-15]*I - sage: CBF(pi/2).tan() + sage: CBF(pi/2).tan() # needs sage.symbolic nan """ cdef ComplexBall res = self._new() @@ -3198,9 +3200,9 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(pi, 1/10).cot() + sage: CBF(pi, 1/10).cot() # needs sage.symbolic [+/- ...e-14] + [-10.03331113225399 +/- ...e-15]*I - sage: CBF(pi).cot() + sage: CBF(pi).cot() # needs sage.symbolic nan """ cdef ComplexBall res = self._new() @@ -3277,7 +3279,7 @@ cdef class ComplexBall(RingElement): sage: CBF(1, 1).tanh() [1.083923327338694 +/- ...e-16] + [0.2717525853195117 +/- ...e-17]*I - sage: CBF(0, pi/2).tanh() + sage: CBF(0, pi/2).tanh() # needs sage.symbolic nan*I """ cdef ComplexBall res = self._new() @@ -3294,7 +3296,7 @@ cdef class ComplexBall(RingElement): sage: CBF(1, 1).coth() [0.868014142895925 +/- ...e-16] + [-0.2176215618544027 +/- ...e-17]*I - sage: CBF(0, pi).coth() + sage: CBF(0, pi).coth() # needs sage.symbolic nan*I """ cdef ComplexBall res = self._new() @@ -3309,7 +3311,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(pi/2, 1/10).sech() + sage: CBF(pi/2, 1/10).sech() # needs sage.symbolic [0.397174529918189 +/- ...e-16] + [-0.0365488656274242 +/- ...e-17]*I """ cdef ComplexBall res = self._new() @@ -3326,7 +3328,7 @@ cdef class ComplexBall(RingElement): sage: CBF(1, 1).csch() [0.303931001628426 +/- ...e-16] + [-0.621518017170428 +/- ...e-16]*I - sage: CBF(i*pi).csch() + sage: CBF(i*pi).csch() # needs sage.symbolic nan*I """ cdef ComplexBall res = self._new() @@ -3837,15 +3839,15 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(1, pi/2).hypergeometric([], []) + sage: CBF(1, pi/2).hypergeometric([], []) # needs sage.symbolic [+/- ...e-16] + [2.71828182845904 +/- ...e-15]*I - sage: CBF(1, pi).hypergeometric([1/4], [1/4]) + sage: CBF(1, pi).hypergeometric([1/4], [1/4]) # needs sage.symbolic [-2.7182818284590 +/- ...e-14] + [+/- ...e-14]*I - sage: CBF(1000, 1000).hypergeometric([10], [AA(sqrt(2))]) # optional - sage.symbolic + sage: CBF(1000, 1000).hypergeometric([10], [AA(sqrt(2))]) # needs sage.symbolic [9.79300951360e+454 +/- ...e+442] + [5.522579106816e+455 +/- ...e+442]*I - sage: CBF(1000, 1000).hypergeometric([100], [AA(sqrt(2))]) # optional - sage.symbolic + sage: CBF(1000, 1000).hypergeometric([100], [AA(sqrt(2))]) # needs sage.symbolic [1.27967355557e+590 +/- ...e+578] + [-9.32333491987e+590 +/- ...e+578]*I sage: CBF(0, 1).hypergeometric([], [1/2, 1/3, 1/4]) @@ -3879,7 +3881,7 @@ cdef class ComplexBall(RingElement): TESTS:: - sage: CBF(0, 1).hypergeometric([QQbar(sqrt(2)), RLF(pi)], [1r, 1/2]) # optional - sage.symbolic + sage: CBF(0, 1).hypergeometric([QQbar(sqrt(2)), RLF(pi)], [1r, 1/2]) # needs sage.symbolic [-8.7029449215408 +/- ...e-14] + [-0.8499070546106 +/- ...e-14]*I """ @@ -3953,7 +3955,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(1000, 1000).hypergeometric_U(RLF(pi), -100) + sage: CBF(1000, 1000).hypergeometric_U(RLF(pi), -100) # needs sage.symbolic [-7.261605907166e-11 +/- ...e-24] + [-7.928136216391e-11 +/- ...e-24]*I sage: CBF(1000, 1000).hypergeometric_U(0, -100) 1.000000000000000 @@ -4006,7 +4008,7 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: CBF(10*pi).airy() + sage: CBF(10*pi).airy() # needs sage.symbolic ([1.2408955946101e-52 +/- ...e-66], [-6.965048886977e-52 +/- ...e-65], [2.2882956833435e+50 +/- ...e+36], @@ -4218,7 +4220,7 @@ cdef class ComplexBall(RingElement): TESTS: - sage: CBF(Ei(I)) # abs tol 1e-16 + sage: CBF(Ei(I)) # abs tol 1e-16 # needs sage.symbolic [0.337403922900968 +/- 3.76e-16] + [2.51687939716208 +/- 2.01e-15]*I """ cdef ComplexBall result = self._new() @@ -4242,7 +4244,7 @@ cdef class ComplexBall(RingElement): TESTS: - sage: CBF(Si(I)) + sage: CBF(Si(I)) # needs sage.symbolic [1.05725087537573 +/- 2.77e-15]*I """ cdef ComplexBall result = self._new() @@ -4268,7 +4270,7 @@ cdef class ComplexBall(RingElement): TESTS: - sage: CBF(Ci(I)) # abs tol 1e-17 + sage: CBF(Ci(I)) # abs tol 1e-17 # needs sage.symbolic [0.837866940980208 +/- 4.72e-16] + [1.570796326794897 +/- 5.54e-16]*I """ cdef ComplexBall result = self._new() @@ -4294,7 +4296,7 @@ cdef class ComplexBall(RingElement): TESTS: - sage: CBF(Shi(I)) # abs tol 1e-15 + sage: CBF(Shi(I)) # abs tol 1e-15 # needs sage.symbolic [0.946083070367183 +/- 9.22e-16]*I """ cdef ComplexBall result = self._new() @@ -4320,7 +4322,7 @@ cdef class ComplexBall(RingElement): TESTS: - sage: CBF(Chi(I)) # abs tol 1e-16 + sage: CBF(Chi(I)) # abs tol 1e-16 # needs sage.symbolic [0.337403922900968 +/- 3.25e-16] + [1.570796326794897 +/- 5.54e-16]*I """ cdef ComplexBall result = self._new() @@ -4347,16 +4349,16 @@ cdef class ComplexBall(RingElement): 0 sage: CBF(0).li(offset=True) [-1.045163780117493 +/- ...e-16] - sage: li(0).n() + sage: li(0).n() # needs sage.symbolic 0.000000000000000 - sage: Li(0).n() + sage: Li(0).n() # needs sage.symbolic -1.04516378011749 TESTS:: - sage: CBF(li(0)) + sage: CBF(li(0)) # needs sage.symbolic 0 - sage: CBF(Li(0)) + sage: CBF(Li(0)) # needs sage.symbolic [-1.04516378011749...] """ cdef ComplexBall result = self._new() @@ -4375,9 +4377,9 @@ cdef class ComplexBall(RingElement): sage: CBF(0).Li() [-1.045163780117493 +/- ...e-16] - sage: li(0).n() + sage: li(0).n() # needs sage.symbolic 0.000000000000000 - sage: Li(0).n() + sage: Li(0).n() # needs sage.symbolic -1.04516378011749 """ cdef ComplexBall result = self._new() @@ -4479,12 +4481,13 @@ cdef class ComplexBall(RingElement): EXAMPLES:: - sage: tau = CBF(sqrt(2),pi) # optional - sage.symbolic - sage: tau.modular_lambda() # optional - sage.symbolic + sage: # needs sage.symbolic + sage: tau = CBF(sqrt(2),pi) + sage: tau.modular_lambda() [-0.00022005123884157 +/- ...e-18] + [-0.00079787346459944 +/- ...e-18]*I - sage: (tau + 2).modular_lambda() # optional - sage.symbolic + sage: (tau + 2).modular_lambda() [-0.00022005123884157 +/- ...e-18] + [-0.00079787346459944 +/- ...e-18]*I - sage: (tau / (1 - 2*tau)).modular_lambda() # optional - sage.symbolic + sage: (tau / (1 - 2*tau)).modular_lambda() [-0.00022005123884 +/- ...e-15] + [-0.00079787346460 +/- ...e-15]*I """ @@ -4564,19 +4567,19 @@ cdef class ComplexBall(RingElement): EXAMPLES:: sage: tau = CBF(1,4) - sage: z = CBF(sqrt(2), sqrt(3)) # optional - sage.symbolic - sage: z.elliptic_p(tau) # optional - sage.symbolic + sage: z = CBF(sqrt(2), sqrt(3)) # needs sage.symbolic + sage: z.elliptic_p(tau) # needs sage.symbolic [-3.28920996772709 +/- ...e-15] + [-0.0003673767302933 +/- ...e-17]*I - sage: (z + tau).elliptic_p(tau) # optional - sage.symbolic + sage: (z + tau).elliptic_p(tau) # needs sage.symbolic [-3.28920996772709 +/- ...e-15] + [-0.000367376730293 +/- ...e-16]*I - sage: (z + 1).elliptic_p(tau) # optional - sage.symbolic + sage: (z + 1).elliptic_p(tau) # needs sage.symbolic [-3.28920996772709 +/- ...e-15] + [-0.0003673767302933 +/- ...e-17]*I - sage: z.elliptic_p(tau, 3) # optional - sage.symbolic + sage: z.elliptic_p(tau, 3) # needs sage.symbolic [[-3.28920996772709 +/- ...e-15] + [-0.0003673767302933 +/- ...e-17]*I, [0.002473055794309 +/- ...e-16] + [0.003859554040267 +/- ...e-16]*I, [-0.01299087561709 +/- ...e-15] + [0.00725027521915 +/- ...e-15]*I] - sage: (z + 3 + 4*tau).elliptic_p(tau, 3) # optional - sage.symbolic + sage: (z + 3 + 4*tau).elliptic_p(tau, 3) # needs sage.symbolic [[-3.28920996772709 +/- ...e-15] + [-0.00036737673029 +/- ...e-15]*I, [0.0024730557943 +/- ...e-14] + [0.0038595540403 +/- ...e-14]*I, [-0.01299087562 +/- ...e-12] + [0.00725027522 +/- ...e-12]*I] @@ -4615,7 +4618,7 @@ cdef class ComplexBall(RingElement): sage: CBF(0,1).elliptic_invariants() ([189.07272012923 +/- ...e-12], [+/- ...e-12]) - sage: CBF(sqrt(2)/2, sqrt(2)/2).elliptic_invariants() # optional - sage.symbolic + sage: CBF(sqrt(2)/2, sqrt(2)/2).elliptic_invariants() # needs sage.symbolic ([+/- ...e-12] + [-332.5338031465...]*I, [1254.46842157...] + [1254.46842157...]*I) """ diff --git a/src/sage/rings/complex_conversion.pyx b/src/sage/rings/complex_conversion.pyx index a11f86a7735..abf179064c6 100644 --- a/src/sage/rings/complex_conversion.pyx +++ b/src/sage/rings/complex_conversion.pyx @@ -12,7 +12,7 @@ cdef class CCtoCDF(Map): sage: f = CCtoCDF(CC, CDF) # indirect doctest sage: f(CC.0) 1.0*I - sage: f(exp(pi*CC.0/4)) + sage: f(exp(pi*CC.0/4)) # needs sage.symbolic 0.7071067811865476 + 0.7071067811865475*I """ z = ComplexDoubleElement.__new__(ComplexDoubleElement) diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx index 132ae733eb9..f2080959a54 100644 --- a/src/sage/rings/complex_double.pyx +++ b/src/sage/rings/complex_double.pyx @@ -24,7 +24,7 @@ EXAMPLES:: Complex Double Field sage: type(CDF.0) - sage: ComplexDoubleElement(sqrt(2),3) + sage: ComplexDoubleElement(sqrt(2), 3) # needs sage.symbolic 1.4142135623730951 + 3.0*I sage: parent(CDF(-2)) Complex Double Field @@ -315,13 +315,13 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField): 2.0 - 3.0*I sage: CDF(4.5) # indirect doctest 4.5 - sage: CDF(1+I) # indirect doctest + sage: CDF(1+I) # indirect doctest # needs sage.symbolic 1.0 + 1.0*I - sage: CDF(pari(1)) + sage: CDF(pari(1)) # needs sage.libs.pari 1.0 - sage: CDF(pari("I")) + sage: CDF(pari("I")) # needs sage.libs.pari 1.0*I - sage: CDF(pari("x^2 + x + 1").polroots()[0]) + sage: CDF(pari("x^2 + x + 1").polroots()[0]) # needs sage.libs.pari -0.5 - 0.8660254037844386*I sage: from gmpy2 import mpc sage: CDF(mpc('2.0+1.0j')) @@ -338,6 +338,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField): numbers and higher-precision ones, though of course there may be loss of precision:: + sage: # needs sage.rings.real_mpfr sage: a = ComplexField(200)(-2).sqrt(); a 1.4142135623730950488016887242096980785696718753769480731767*I sage: b = CDF(a); b @@ -353,7 +354,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField): Check that :trac:`31836` is fixed:: - sage: a = CDF() ; a + sage: a = CDF(); a 0.0 sage: a.parent() Complex Double Field @@ -421,16 +422,17 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField): Thus the sum of a CDF and a symbolic object is symbolic:: - sage: a = pi + CDF.0; a + sage: a = pi + CDF.0; a # needs sage.symbolic pi + 1.0*I - sage: parent(a) + sage: parent(a) # needs sage.symbolic Symbolic Ring TESTS:: + sage: # needs sage.rings.real_mpfr sage: CDF(1) + RR(1) 2.0 - sage: CDF.0 - CC(1) - int(1) - RR(1) - QQbar(1) + sage: CDF.0 - CC(1) - int(1) - RR(1) - QQbar(1) # needs sage.rings.number_field -4.0 + 1.0*I sage: CDF.has_coerce_map_from(ComplexField(20)) False @@ -476,7 +478,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField): 'ComplexField(53 : Bits := true)' sage: magma(CDF) # optional - magma Complex field of precision 15 - sage: floor(RR(log(2**53, 10))) + sage: floor(RR(log(2**53, 10))) # needs sage.symbolic 15 sage: magma(CDF).sage() # optional - magma Complex Field with 53 bits of precision @@ -890,13 +892,14 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: - sage: CDF((1.2, 0.3))._magma_init_(magma) # optional - magma + sage: # optional - magma + sage: CDF((1.2, 0.3))._magma_init_(magma) 'ComplexField(53 : Bits := true)![1.2, 0.3]' - sage: magma(CDF(1.2, 0.3)) # optional - magma # indirect doctest + sage: magma(CDF(1.2, 0.3)) # indirect doctest 1.20000000000000 + 0.300000000000000*$.1 - sage: s = magma(CDF(1.2, 0.3)).sage(); s # optional - magma # indirect doctest + sage: s = magma(CDF(1.2, 0.3)).sage(); s # indirect doctest 1.20000000000000 + 0.300000000000000*I - sage: s.parent() # optional - magma + sage: s.parent() Complex Field with 53 bits of precision """ return "%s![%s, %s]" % (self.parent()._magma_init_(magma), self.real(), self.imag()) @@ -981,11 +984,11 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: - sage: s1 = CDF(exp(I)); s1 + sage: s1 = CDF(exp(I)); s1 # needs sage.symbolic 0.5403023058681398 + 0.8414709848078965*I - sage: s1._interface_init_() + sage: s1._interface_init_() # needs sage.symbolic '0.54030230586813977 + 0.84147098480789650*I' - sage: s1 == CDF(gp(s1)) + sage: s1 == CDF(gp(s1)) # needs sage.symbolic True """ # Sending to another computer algebra system is slow anyway, right? @@ -1013,7 +1016,7 @@ cdef class ComplexDoubleElement(FieldElement): sage: CDF.0._maxima_init_() '1.0000000000000000*%i' - sage: CDF(.5 + I)._maxima_init_() + sage: CDF(.5 + I)._maxima_init_() # needs sage.symbolic '0.50000000000000000 + 1.0000000000000000*%i' """ from .complex_mpfr import ComplexField @@ -1025,11 +1028,11 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: - sage: CDF(1, 0)._sympy_() + sage: CDF(1, 0)._sympy_() # needs sympy 1.00000000000000 - sage: CDF(1/3, 1)._sympy_() + sage: CDF(1/3, 1)._sympy_() # needs sympy 0.333333333333333 + 1.0*I - sage: type(_) + sage: type(_) # needs sympy """ x = GSL_REAL(self._complex) @@ -1145,6 +1148,7 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: + sage: # needs sage.libs.pari sage: CDF(1,2).__pari__() 1.00000000000000 + 2.00000000000000*I sage: pari(CDF(1,2)) @@ -1354,11 +1358,11 @@ cdef class ComplexDoubleElement(FieldElement): sage: CDF(6).argument() 0.0 - sage: CDF(i).argument() + sage: CDF(i).argument() # needs sage.symbolic 1.5707963267948966 sage: CDF(-1).argument() 3.141592653589793 - sage: CDF(-1 - 0.000001*i).argument() + sage: CDF(-1 - 0.000001*i).argument() # needs sage.symbolic -3.1415916535897934 """ return RealDoubleElement(gsl_complex_arg(self._complex)) @@ -1570,7 +1574,7 @@ cdef class ComplexDoubleElement(FieldElement): sage: CDF(0.5).is_integer() False - sage: CDF(I).is_integer() + sage: CDF(I).is_integer() # needs sage.symbolic False sage: CDF(2).is_integer() True @@ -1628,7 +1632,7 @@ cdef class ComplexDoubleElement(FieldElement): sage: CDF(1, 2).is_NaN() False - sage: CDF(NaN).is_NaN() + sage: CDF(NaN).is_NaN() # needs sage.symbolic True sage: (1/CDF(0, 0)).is_NaN() True @@ -1663,11 +1667,11 @@ cdef class ComplexDoubleElement(FieldElement): We raise to symbolic powers:: - sage: var('x, n') + sage: var('x, n') # needs sage.symbolic (x, n) - sage: CDF(1.2)^x + sage: CDF(1.2)^x # needs sage.symbolic 1.2^x - sage: CDF(1.2)^(x^n + n^x) + sage: CDF(1.2)^(x^n + n^x) # needs sage.symbolic 1.2^(n^x + x^n) A real number powered to an exact integer always yields a real @@ -1739,9 +1743,9 @@ cdef class ComplexDoubleElement(FieldElement): We numerically verify a famous identity to the precision of a double:: - sage: z = CDF(0, 2*pi); z + sage: z = CDF(0, 2*pi); z # needs sage.symbolic 6.283185307179586*I - sage: exp(z) # rel tol 1e-4 + sage: exp(z) # rel tol 1e-4 # needs sage.symbolic 1.0 - 2.4492935982947064e-16*I """ return self._new_c(gsl_complex_exp(self._complex)) @@ -2194,41 +2198,42 @@ cdef class ComplexDoubleElement(FieldElement): We compute a few values of :meth:`eta()`:: - sage: CDF(0,1).eta() + sage: CDF(0,1).eta() # needs sage.libs.pari 0.7682254223260566 - sage: CDF(1,1).eta() + sage: CDF(1,1).eta() # needs sage.libs.pari 0.7420487758365647 + 0.1988313702299107*I - sage: CDF(25,1).eta() + sage: CDF(25,1).eta() # needs sage.libs.pari 0.7420487758365647 + 0.1988313702299107*I :meth:`eta()` works even if the inputs are large:: sage: CDF(0, 10^15).eta() 0.0 - sage: CDF(10^15, 0.1).eta() # abs tol 1e-10 + sage: CDF(10^15, 0.1).eta() # abs tol 1e-10 # needs sage.libs.pari -0.115342592727 - 0.19977923088*I We compute a few values of :meth:`eta()`, but with the fractional power of `e` omitted:: - sage: CDF(0,1).eta(True) + sage: CDF(0,1).eta(True) # needs sage.libs.pari 0.9981290699259585 We compute :meth:`eta()` to low precision directly from the definition:: - sage: z = CDF(1,1); z.eta() + sage: z = CDF(1,1); z.eta() # needs sage.libs.pari 0.7420487758365647 + 0.1988313702299107*I - sage: i = CDF(0,1); pi = CDF(pi) - sage: exp(pi * i * z / 12) * prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) + sage: i = CDF(0,1); pi = CDF(pi) # needs sage.symbolic + sage: exp(pi * i * z / 12) * prod(1 - exp(2*pi*i*n*z) # needs sage.libs.pari sage.symbolic + ....: for n in range(1, 10)) 0.7420487758365647 + 0.19883137022991068*I The optional argument allows us to omit the fractional part:: - sage: z.eta(omit_frac=True) + sage: z.eta(omit_frac=True) # needs sage.libs.pari 0.9981290699259585 - sage: pi = CDF(pi) - sage: prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) # abs tol 1e-12 + sage: pi = CDF(pi) # needs sage.symbolic + sage: prod(1 - exp(2*pi*i*n*z) for n in range(1,10)) # abs tol 1e-12 # needs sage.libs.pari sage.symbolic 0.998129069926 + 4.59084695545e-19*I We illustrate what happens when `z` is not in the upper half plane:: @@ -2242,7 +2247,7 @@ cdef class ComplexDoubleElement(FieldElement): You can also use functional notation:: sage: z = CDF(1,1) - sage: eta(z) + sage: eta(z) # needs sage.libs.pari 0.7420487758365647 + 0.1988313702299107*I """ if GSL_IMAG(self._complex) <= 0: @@ -2295,8 +2300,8 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: - sage: i = CDF(I) - sage: (1+i).agm(2-i) # rel tol 1e-15 + sage: i = CDF(I) # needs sage.symbolic + sage: (1+i).agm(2-i) # rel tol 1e-15 # needs sage.symbolic 1.6278054848727064 + 0.1368275483973686*I An example to show that the returned value depends on the algorithm @@ -2372,9 +2377,9 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: - sage: CDF(1,2).dilog() + sage: CDF(1,2).dilog() # needs sage.libs.pari -0.059474798673809476 + 2.0726479717747566*I - sage: CDF(10000000,10000000).dilog() + sage: CDF(10000000,10000000).dilog() # needs sage.libs.pari -134.411774490731 + 38.79396299904504*I """ global complex_double_element_dilog @@ -2389,6 +2394,7 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: + sage: # needs sage.libs.pari sage: CDF(5,0).gamma() 24.0 sage: CDF(1,1).gamma() @@ -2420,11 +2426,11 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: - sage: CDF(1,1).gamma_inc(CDF(2,3)) + sage: CDF(1,1).gamma_inc(CDF(2,3)) # needs sage.libs.pari 0.0020969148636468277 - 0.059981913655449706*I - sage: CDF(1,1).gamma_inc(5) + sage: CDF(1,1).gamma_inc(5) # needs sage.libs.pari -0.001378130936215849 + 0.006519820023119819*I - sage: CDF(2,0).gamma_inc(CDF(1,1)) + sage: CDF(2,0).gamma_inc(CDF(1,1)) # needs sage.libs.pari 0.7070920963459381 - 0.4203536409598115*I """ global complex_double_element_gamma_inc @@ -2439,11 +2445,11 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: sage: z = CDF(1, 1) - sage: z.zeta() + sage: z.zeta() # needs sage.libs.pari 0.5821580597520036 - 0.9268485643308071*I - sage: zeta(z) + sage: zeta(z) # needs sage.libs.pari 0.5821580597520036 - 0.9268485643308071*I - sage: zeta(CDF(1)) + sage: zeta(CDF(1)) # needs sage.libs.pari Infinity """ if GSL_REAL(self._complex) == 1 and GSL_IMAG(self._complex) == 0: @@ -2467,18 +2473,18 @@ cdef class ComplexDoubleElement(FieldElement): EXAMPLES:: - sage: z = (1/2)*(1 + RDF(sqrt(3)) *CDF.0); z # abs tol 1e-16 + sage: z = (1/2)*(1 + RDF(sqrt(3)) * CDF.0); z # abs tol 1e-16 # needs sage.symbolic 0.5 + 0.8660254037844387*I - sage: p = z.algdep(5); p + sage: p = z.algdep(5); p # needs sage.libs.pari sage.symbolic x^2 - x + 1 - sage: abs(z^2 - z + 1) < 1e-14 + sage: abs(z^2 - z + 1) < 1e-14 # needs sage.symbolic True :: - sage: CDF(0,2).algdep(10) + sage: CDF(0,2).algdep(10) # needs sage.libs.pari x^2 + 4 - sage: CDF(1,5).algdep(2) + sage: CDF(1,5).algdep(2) # needs sage.libs.pari x^2 - 2*x + 26 """ from sage.arith.misc import algdep @@ -2543,7 +2549,7 @@ cdef class FloatToCDF(Morphism): 1.0 + 2.0*I sage: CDF('i') # indirect doctest 1.0*I - sage: CDF(2+i) # indirect doctest + sage: CDF(2+i) # indirect doctest # needs sage.symbolic 2.0 + 1.0*I """ cdef ComplexDoubleElement z = ComplexDoubleElement.__new__(ComplexDoubleElement) @@ -2569,11 +2575,11 @@ cdef class ComplexToCDF(Morphism): EXAMPLES:: - sage: import numpy # optional - numpy - sage: f = CDF.coerce_map_from(numpy.complex_) # optional - numpy - sage: f(numpy.complex_(I)) # optional - numpy + sage: import numpy # needs numpy + sage: f = CDF.coerce_map_from(numpy.complex_) # needs numpy + sage: f(numpy.complex_(I)) # needs numpy 1.0*I - sage: f(numpy.complex_(I)).parent() # optional - numpy + sage: f(numpy.complex_(I)).parent() # needs numpy Complex Double Field """ def __init__(self, R): @@ -2589,8 +2595,8 @@ cdef class ComplexToCDF(Morphism): EXAMPLES:: - sage: import numpy # optional - numpy - sage: CDF(numpy.complex_(I)) # indirect doctest # optional - numpy + sage: import numpy # needs numpy + sage: CDF(numpy.complex_(I)) # indirect doctest # needs numpy 1.0*I """ cdef ComplexDoubleElement z = ComplexDoubleElement.__new__(ComplexDoubleElement) @@ -2603,9 +2609,9 @@ cdef class ComplexToCDF(Morphism): EXAMPLES:: - sage: import numpy # optional - numpy - sage: f = sage.rings.complex_double.ComplexToCDF(numpy.complex_) # optional - numpy - sage: f._repr_type() # optional - numpy + sage: import numpy # needs numpy + sage: f = sage.rings.complex_double.ComplexToCDF(numpy.complex_) # needs numpy + sage: f._repr_type() # needs numpy 'Native' """ return "Native" diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx index 12e32fc2d90..7fe25fd8114 100644 --- a/src/sage/rings/complex_interval.pyx +++ b/src/sage/rings/complex_interval.pyx @@ -230,7 +230,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): '-2.5000000000000000?*I' sage: CIF(1.5).str(base=3) '1.1111111111111111111111111111111112?' - sage: CIF(1, pi).str(style='brackets') + sage: CIF(1, pi).str(style='brackets') # needs sage.symbolic '[1.0000000000000000 .. 1.0000000000000000] + [3.1415926535897931 .. 3.1415926535897936]*I' .. SEEALSO:: @@ -285,16 +285,18 @@ cdef class ComplexIntervalFieldElement(FieldElement): EXAMPLES:: - sage: sum(plot(CIF(RIF(1/k, 1/k), RIF(-k, k))) for k in [1..10]) + sage: sum(plot(CIF(RIF(1/k, 1/k), RIF(-k, k))) for k in [1..10]) # needs sage.plot Graphics object consisting of 20 graphics primitives Exact and nearly exact points are still visible:: + sage: # needs sage.plot sage: plot(CIF(pi, 1), color='red') + plot(CIF(1, e), color='purple') + plot(CIF(-1, -1)) Graphics object consisting of 6 graphics primitives A demonstration that `z \mapsto z^2` acts chaotically on `|z|=1`:: + sage: # needs sage.plot sage.symbolic sage: z = CIF(0, 2*pi/1000).exp() sage: g = Graphics() sage: for i in range(40): @@ -351,11 +353,11 @@ cdef class ComplexIntervalFieldElement(FieldElement): (2.50000000000000, 3.00000000000000) (-4.50000000000000, -4.00000000000000) + sage: # needs sage.symbolic sage: z = CIF(RIF(sqrt(2), sqrt(3)), RIF(e, pi)) sage: a, b, c, d = z.bisection() sage: a.intersection(b).intersection(c).intersection(d) == CIF(z.center()) True - sage: zz = a.union(b).union(c).union(c) sage: zz.real().endpoints() == z.real().endpoints() True @@ -399,9 +401,9 @@ cdef class ComplexIntervalFieldElement(FieldElement): True sage: CIF(-5, 0).sqrt().is_exact() False - sage: CIF(0, 2*pi).is_exact() + sage: CIF(0, 2*pi).is_exact() # needs sage.symbolic False - sage: CIF(e).is_exact() + sage: CIF(e).is_exact() # needs sage.symbolic False sage: CIF(1e100).is_exact() True @@ -985,7 +987,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): Here a conversion to Maxima happens, which results in a ``TypeError``:: sage: a = CIF(2.3) - sage: maxima(a) + sage: maxima(a) # needs sage.symbolic Traceback (most recent call last): ... TypeError @@ -999,7 +1001,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): EXAMPLES:: - sage: sage_input(CIF(RIF(e, pi), RIF(sqrt(2), sqrt(3))), verify=True) + sage: sage_input(CIF(RIF(e, pi), RIF(sqrt(2), sqrt(3))), verify=True) # needs sage.symbolic # Verified CIF(RIF(RR(2.7182818284590451), RR(3.1415926535897936)), RIF(RR(1.4142135623730949), RR(1.7320508075688774))) sage: sage_input(ComplexIntervalField(64)(2)^I, preparse=False, verify=True) @@ -1997,7 +1999,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): sage: CIF(2, 1).is_NaN() False - sage: CIF(NaN).is_NaN() + sage: CIF(NaN).is_NaN() # needs sage.symbolic True sage: (1 / CIF(0, 0)).is_NaN() True @@ -2019,7 +2021,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): Check that :trac:`17285` is fixed:: - sage: CIF(cos(2/3)) + sage: CIF(cos(2/3)) # needs sage.symbolic 0.7858872607769480? ALGORITHM: @@ -2061,7 +2063,7 @@ cdef class ComplexIntervalFieldElement(FieldElement): Check that :trac:`17825` is fixed:: - sage: CIF(sin(2/3)) + sage: CIF(sin(2/3)) # needs sage.symbolic 0.618369803069737? ALGORITHM: diff --git a/src/sage/rings/complex_interval_field.py b/src/sage/rings/complex_interval_field.py index 7cbf5d60929..9fedd3f4476 100644 --- a/src/sage/rings/complex_interval_field.py +++ b/src/sage/rings/complex_interval_field.py @@ -304,7 +304,7 @@ def _magma_init_(self, magma): sage: magma(ComplexIntervalField(100)) # optional - magma # indirect doctest Complex field of precision 30 - sage: floor(RR(log(2**100, 10))) + sage: floor(RR(log(2**100, 10))) # needs sage.symbolic 30 """ return "ComplexField(%s : Bits := true)" % self.prec() @@ -445,7 +445,7 @@ def __call__(self, x=None, im=None, **kwds): TypeError: unable to convert '1+I' to real interval sage: CIF(2,3) 2 + 3*I - sage: CIF(pi, e) + sage: CIF(pi, e) # needs sage.symbolic 3.141592653589794? + 2.718281828459046?*I sage: ComplexIntervalField(100)(CIF(RIF(2,3))) 3.? @@ -558,7 +558,7 @@ def _repr_(self): sage: ComplexIntervalField(100) # indirect doctest Complex Interval Field with 100 bits of precision """ - return "Complex Interval Field with %s bits of precision"%self._prec + return "Complex Interval Field with %s bits of precision" % self._prec def _latex_(self): r""" diff --git a/src/sage/rings/complex_mpc.pyx b/src/sage/rings/complex_mpc.pyx index c847a9302b5..cbbe65d2014 100644 --- a/src/sage/rings/complex_mpc.pyx +++ b/src/sage/rings/complex_mpc.pyx @@ -1195,27 +1195,27 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): sage: MPC = MPComplexField() sage: a = MPC(2,1) - sage: a.__pari__() + sage: a.__pari__() # needs sage.libs.pari 2.00000000000000 + 1.00000000000000*I - sage: pari(a) + sage: pari(a) # needs sage.libs.pari 2.00000000000000 + 1.00000000000000*I - sage: pari(a).type() + sage: pari(a).type() # needs sage.libs.pari 't_COMPLEX' - sage: a = MPC(pi) - sage: pari(a) + sage: a = MPC(pi) # needs sage.libs.pari sage.symbolic + sage: pari(a) # needs sage.libs.pari sage.symbolic 3.14159265358979 - sage: pari(a).type() + sage: pari(a).type() # needs sage.libs.pari sage.symbolic 't_REAL' sage: a = MPC(-2).sqrt() - sage: pari(a) + sage: pari(a) # needs sage.libs.pari 1.41421356237310*I The precision is preserved, rounded up to the wordsize:: sage: MPC = MPComplexField(250) - sage: MPC(1,2).__pari__().bitprecision() + sage: MPC(1,2).__pari__().bitprecision() # needs sage.libs.pari 256 - sage: MPC(pi).__pari__().bitprecision() + sage: MPC(pi).__pari__().bitprecision() # needs sage.libs.pari 256 """ if mpfr_zero_p(self.value.re): @@ -1520,7 +1520,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): 2.23606797749979 sage: a.__abs__() 2.23606797749979 - sage: float(sqrt(2^2 + 1^1)) + sage: float(sqrt(2^2 + 1^1)) # needs sage.symbolic 2.23606797749979 sage: b = MPC(42,0) @@ -2192,7 +2192,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement): sage: a = MPC(1,0) sage: a.dilog() 1.64493406684823 - sage: float(pi^2/6) + sage: float(pi^2/6) # needs sage.symbolic 1.6449340668482262 :: @@ -2557,4 +2557,3 @@ cdef class CCtoMPC(Map): # Support Python's numbers abstract base class # import numbers -from sage.rings.complex_mpc import MPComplexNumber diff --git a/src/sage/rings/complex_mpfr.pyx b/src/sage/rings/complex_mpfr.pyx index 61f2cadc8e4..416b8a9a847 100644 --- a/src/sage/rings/complex_mpfr.pyx +++ b/src/sage/rings/complex_mpfr.pyx @@ -146,6 +146,7 @@ def is_ComplexNumber(x): while elements of the class :class:`ComplexField_class` are of type :class:`ComplexNumber`:: + sage: # needs sage.symbolic sage: c = 1 + 2*I sage: is_ComplexNumber(c) False @@ -457,12 +458,12 @@ class ComplexField_class(sage.rings.abc.ComplexField): 1.00000000000000 + 1.00000000000000*I sage: CC(2,3) 2.00000000000000 + 3.00000000000000*I - sage: CC(QQ[I].gen()) + sage: CC(QQ[I].gen()) # needs sage.symbolic 1.00000000000000*I - sage: CC.gen() + QQ[I].gen() + sage: CC.gen() + QQ[I].gen() # needs sage.symbolic 2.00000000000000*I sage: x = polygen(ZZ, 'x') - sage: CC.gen() + QQ.extension(x^2 + 1, 'I', embedding=None).gen() + sage: CC.gen() + QQ.extension(x^2 + 1, 'I', embedding=None).gen() # needs sage.rings.number_field Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for +: 'Complex Field with 53 bits of precision' and 'Number Field in I with defining polynomial x^2 + 1' @@ -493,9 +494,9 @@ class ComplexField_class(sage.rings.abc.ComplexField): Check that :trac:`14989` is fixed:: sage: x = polygen(ZZ, 'x') - sage: QQi = NumberField(x^2 + 1, 'i', embedding=CC(0,1)) - sage: i = QQi.order(QQi.gen()).gen(1) - sage: CC(i) + sage: QQi = NumberField(x^2 + 1, 'i', embedding=CC(0,1)) # needs sage.rings.number_field + sage: i = QQi.order(QQi.gen()).gen(1) # needs sage.rings.number_field + sage: CC(i) # needs sage.rings.number_field 1.00000000000000*I TESTS:: @@ -715,8 +716,8 @@ class ComplexField_class(sage.rings.abc.ComplexField): sage: re, im = CC6.random_element(2^-20) sage: -2^-20 <= re <= 2^-20, -2^-20 <= im <= 2^-20 (True, True) - sage: re, im = CC6.random_element(pi^20) - sage: bool(-pi^20 <= re <= pi^20), bool(-pi^20 <= im <= pi^20) + sage: re, im = CC6.random_element(pi^20) # needs sage.symbolic + sage: bool(-pi^20 <= re <= pi^20), bool(-pi^20 <= im <= pi^20) # needs sage.symbolic (True, True) Passes extra positional or keyword arguments through:: @@ -847,19 +848,20 @@ class ComplexField_class(sage.rings.abc.ComplexField): TESTS:: + sage: # needs sage.libs.pari sage: k = ComplexField(100) sage: R. = k[] - sage: k._factor_univariate_polynomial( x ) + sage: k._factor_univariate_polynomial(x) x - sage: k._factor_univariate_polynomial( 2*x ) + sage: k._factor_univariate_polynomial(2*x) (2.0000000000000000000000000000) * x - sage: k._factor_univariate_polynomial( x^2 ) + sage: k._factor_univariate_polynomial(x^2) x^2 - sage: k._factor_univariate_polynomial( x^2 + 3 ) + sage: k._factor_univariate_polynomial(x^2 + 3) (x - 1.7320508075688772935274463415*I) * (x + 1.7320508075688772935274463415*I) - sage: k._factor_univariate_polynomial( x^2 + 1 ) + sage: k._factor_univariate_polynomial(x^2 + 1) (x - I) * (x + I) - sage: k._factor_univariate_polynomial( k(I) * (x^2 + 1) ) + sage: k._factor_univariate_polynomial(k(I) * (x^2 + 1)) (1.0000000000000000000000000000*I) * (x - I) * (x + I) """ @@ -982,7 +984,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): Check that :trac:`12038` is resolved:: sage: from sage.rings.complex_mpfr import ComplexNumber as CN - sage: coerce(CN, 1+I) + sage: coerce(CN, 1+I) # needs sage.symbolic Traceback (most recent call last): ... TypeError: ...__init__() takes at least 2 positional arguments (1 given) @@ -999,11 +1001,11 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: s1 = CC(exp(I)); s1 + sage: s1 = CC(exp(I)); s1 # needs sage.symbolic 0.540302305868140 + 0.841470984807897*I - sage: s1._interface_init_() + sage: s1._interface_init_() # needs sage.symbolic '0.54030230586813977 + 0.84147098480789650*I' - sage: s1 == CC(gp(s1)) + sage: s1 == CC(gp(s1)) # needs sage.libs.pari sage.symbolic True """ return self.str() @@ -1026,7 +1028,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): sage: CC.0._maxima_init_() '1.0000000000000000*%i' - sage: CC(.5 + I)._maxima_init_() + sage: CC(.5 + I)._maxima_init_() # needs sage.symbolic '0.50000000000000000 + 1.0000000000000000*%i' """ return self.str(istr='%i') @@ -1038,10 +1040,10 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: import numpy # optional - numpy - sage: numpy.array([1.0, 2.5j]).dtype # optional - numpy + sage: import numpy # needs numpy + sage: numpy.array([1.0, 2.5j]).dtype # needs numpy dtype('complex128') - sage: numpy.array([1.000000000000000000000000000000000000j]).dtype # optional - numpy + sage: numpy.array([1.000000000000000000000000000000000000j]).dtype # needs numpy dtype('O') """ if self._prec <= 53: @@ -1265,20 +1267,22 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: a = CC(pi + I*e); a # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = CC(pi + I*e); a 3.14159265358979 + 2.71828182845905*I - sage: a.str(truncate=True) # optional - sage.symbolic + sage: a.str(truncate=True) '3.14159265358979 + 2.71828182845905*I' - sage: a.str() # optional - sage.symbolic + sage: a.str() '3.1415926535897931 + 2.7182818284590451*I' - sage: a.str(base=2) # optional - sage.symbolic + sage: a.str(base=2) '11.001001000011111101101010100010001000010110100011000 + 10.101101111110000101010001011000101000101011101101001*I' - sage: CC(0.5 + 0.625*I).str(base=2) # optional - sage.symbolic + sage: CC(0.5 + 0.625*I).str(base=2) '0.10000000000000000000000000000000000000000000000000000 + 0.10100000000000000000000000000000000000000000000000000*I' - sage: a.str(base=16) # optional - sage.symbolic + sage: a.str(base=16) '3.243f6a8885a30 + 2.b7e151628aed2*I' - sage: a.str(base=36) # optional - sage.symbolic + sage: a.str(base=36) '3.53i5ab8p5fc + 2.puw5nggjf8f*I' + sage: CC(0) 0.000000000000000 sage: CC.0.str(istr='%i') @@ -1389,24 +1393,25 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): Coerce the object using the ``pari`` function:: + sage: # needs sage.libs.pari sage: a = ComplexNumber(2,1) - sage: pari(a) # optional - sage.libs.pari + sage: pari(a) 2.00000000000000 + 1.00000000000000*I - sage: pari(a).type() # optional - sage.libs.pari + sage: pari(a).type() 't_COMPLEX' - sage: type(pari(a)) # optional - sage.libs.pari + sage: type(pari(a)) - sage: a.__pari__() # optional - sage.libs.pari + sage: a.__pari__() 2.00000000000000 + 1.00000000000000*I - sage: type(a.__pari__()) # optional - sage.libs.pari + sage: type(a.__pari__()) - sage: a = CC(pi) # optional - sage.symbolic - sage: pari(a) # optional - sage.libs.pari sage.symbolic + sage: a = CC(pi) # needs sage.symbolic + sage: pari(a) # needs sage.symbolic 3.14159265358979 - sage: pari(a).type() # optional - sage.libs.pari sage.symbolic + sage: pari(a).type() # needs sage.symbolic 't_REAL' sage: a = CC(-2).sqrt() - sage: pari(a) # optional - sage.libs.pari + sage: pari(a) 1.41421356237310*I """ if self.is_real(): @@ -1473,11 +1478,11 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: CC(1, 0)._sympy_() # optional - sympy + sage: CC(1, 0)._sympy_() # needs sympy 1.00000000000000 - sage: CC(1/3, 1)._sympy_() # optional - sympy + sage: CC(1/3, 1)._sympy_() # needs sympy 0.333333333333333 + 1.0*I - sage: type(_) # optional - sympy + sage: type(_) # needs sympy """ import sympy @@ -1857,7 +1862,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): 2.23606797749979 sage: a.__abs__() 2.23606797749979 - sage: float(sqrt(2^2 + 1^1)) + sage: float(sqrt(2^2 + 1^1)) # needs sage.symbolic 2.23606797749979 :: @@ -2067,13 +2072,13 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): You can either use the indirect:: sage: z = CC(0,1) - sage: plot(z) # optional - sage.plot + sage: plot(z) # needs sage.plot Graphics object consisting of 1 graphics primitive or the more direct:: sage: z = CC(0,1) - sage: z.plot() # optional - sage.plot + sage: z.plot() # needs sage.plot Graphics object consisting of 1 graphics primitive """ return sage.plot.point.point2d((self.real(), self.imag()), **kargs) @@ -2089,7 +2094,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: (1+CC(I)).arccos() + sage: (1+CC(I)).arccos() # needs sage.libs.pari 0.904556894302381 - 1.06127506190504*I """ return self._parent(self.__pari__().acos()) @@ -2100,7 +2105,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: (1+CC(I)).arccosh() + sage: (1+CC(I)).arccosh() # needs sage.libs.pari 1.06127506190504 + 0.904556894302381*I """ return self._parent(self.__pari__().acosh()) @@ -2111,7 +2116,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: (1+CC(I)).arcsin() + sage: (1+CC(I)).arcsin() # needs sage.libs.pari 0.666239432492515 + 1.06127506190504*I """ return self._parent(self.__pari__().asin()) @@ -2122,7 +2127,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: (1+CC(I)).arcsinh() + sage: (1+CC(I)).arcsinh() # needs sage.libs.pari 1.06127506190504 + 0.666239432492515*I """ return self._parent(self.__pari__().asinh()) @@ -2133,7 +2138,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: (1+CC(I)).arctan() + sage: (1+CC(I)).arctan() # needs sage.libs.pari 1.01722196789785 + 0.402359478108525*I """ return self._parent(self.__pari__().atan()) @@ -2144,7 +2149,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: (1+CC(I)).arctanh() + sage: (1+CC(I)).arctanh() # needs sage.libs.pari 0.402359478108525 + 1.01722196789785*I """ return self._parent(self.__pari__().atanh()) @@ -2155,7 +2160,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: ComplexField(100)(1,1).coth() + sage: ComplexField(100)(1,1).coth() # needs sage.libs.pari 0.86801414289592494863584920892 - 0.21762156185440268136513424361*I """ return ~(self.tanh()) @@ -2166,7 +2171,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: ComplexField(100)(1,1).arccoth() + sage: ComplexField(100)(1,1).arccoth() # needs sage.libs.pari 0.40235947810852509365018983331 - 0.55357435889704525150853273009*I """ return (~self).arctanh() @@ -2177,7 +2182,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: ComplexField(100)(1,1).csc() + sage: ComplexField(100)(1,1).csc() # needs sage.libs.pari 0.62151801717042842123490780586 - 0.30393100162842645033448560451*I """ return ~(self.sin()) @@ -2188,7 +2193,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: ComplexField(100)(1,1).csch() + sage: ComplexField(100)(1,1).csch() # needs sage.libs.pari 0.30393100162842645033448560451 - 0.62151801717042842123490780586*I """ return ~(self.sinh()) @@ -2199,7 +2204,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: ComplexField(100)(1,1).arccsch() + sage: ComplexField(100)(1,1).arccsch() # needs sage.libs.pari 0.53063753095251782601650945811 - 0.45227844715119068206365839783*I """ return (~self).arcsinh() @@ -2210,7 +2215,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: ComplexField(100)(1,1).sec() + sage: ComplexField(100)(1,1).sec() # needs sage.libs.pari 0.49833703055518678521380589177 + 0.59108384172104504805039169297*I """ return ~(self.cos()) @@ -2221,7 +2226,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: ComplexField(100)(1,1).sech() + sage: ComplexField(100)(1,1).sech() # needs sage.libs.pari 0.49833703055518678521380589177 - 0.59108384172104504805039169297*I """ return ~(self.cosh()) @@ -2232,7 +2237,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: - sage: ComplexField(100)(1,1).arcsech() + sage: ComplexField(100)(1,1).arcsech() # needs sage.libs.pari 0.53063753095251782601650945811 - 1.1185178796437059371676632938*I """ return (~self).arccosh() @@ -2243,6 +2248,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: + sage: # needs sage.libs.pari sage: (1+CC(I)).cot() 0.217621561854403 - 0.868014142895925*I sage: i = ComplexField(200).0 @@ -2349,37 +2355,35 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): First we compute `\eta(1+i)`:: sage: i = CC.0 - sage: z = 1+i; z.eta() + sage: z = 1 + i; z.eta() # needs sage.libs.pari 0.742048775836565 + 0.198831370229911*I We compute eta to low precision directly from the definition:: - sage: z = 1 + i; z.eta() - 0.742048775836565 + 0.198831370229911*I - sage: pi = CC(pi) # otherwise we will get a symbolic result. - sage: exp(pi * i * z / 12) * prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) + sage: pi = CC(pi) # otherwise we will get a symbolic result. # needs sage.symbolic + sage: exp(pi * i * z / 12) * prod(1 - exp(2*pi*i*n*z) # needs sage.libs.pari sage.symbolic + ....: for n in range(1,10)) 0.742048775836565 + 0.198831370229911*I The optional argument allows us to omit the fractional part:: - sage: z = 1 + i - sage: z.eta(omit_frac=True) + sage: z.eta(omit_frac=True) # needs sage.libs.pari 0.998129069925959 - sage: prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) + sage: prod(1 - exp(2*pi*i*n*z) for n in range(1,10)) # needs sage.libs.pari sage.symbolic 0.998129069925958 + 4.59099857829247e-19*I We illustrate what happens when `z` is not in the upper half plane:: sage: z = CC(1) - sage: z.eta() + sage: z.eta() # needs sage.libs.pari Traceback (most recent call last): ... ValueError: value must be in the upper half plane You can also use functional notation:: - sage: eta(1+CC(I)) + sage: eta(1 + CC(I)) # needs sage.libs.pari 0.742048775836565 + 0.198831370229911*I """ try: @@ -2564,7 +2568,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): 1.62780548487271 + 0.136827548397369*I sage: a.agm(b, algorithm="principal") 1.62780548487271 + 0.136827548397369*I - sage: a.agm(b, algorithm="pari") + sage: a.agm(b, algorithm="pari") # needs sage.libs.pari 1.62780548487271 + 0.136827548397369*I An example to show that the returned value depends on the algorithm @@ -2576,13 +2580,13 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): -0.371591652351761 + 0.319894660206830*I sage: a.agm(b, algorithm="principal") 0.338175462986180 - 0.0135326969565405*I - sage: a.agm(b, algorithm="pari") + sage: a.agm(b, algorithm="pari") # needs sage.libs.pari -0.371591652351761 + 0.319894660206830*I sage: a.agm(b, algorithm="optimal").abs() 0.490319232466314 sage: a.agm(b, algorithm="principal").abs() 0.338446122230459 - sage: a.agm(b, algorithm="pari").abs() + sage: a.agm(b, algorithm="pari").abs() # needs sage.libs.pari 0.490319232466314 TESTS: @@ -2799,21 +2803,21 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: sage: a = ComplexNumber(1,0) - sage: a.dilog() + sage: a.dilog() # needs sage.libs.pari 1.64493406684823 - sage: float(pi^2/6) # optional - sage.symbolic + sage: float(pi^2/6) # needs sage.symbolic 1.6449340668482262 :: sage: b = ComplexNumber(0,1) - sage: b.dilog() + sage: b.dilog() # needs sage.libs.pari -0.205616758356028 + 0.915965594177219*I :: sage: c = ComplexNumber(0,0) - sage: c.dilog() + sage: c.dilog() # needs sage.libs.pari 0.000000000000000 """ return self._parent(self.__pari__().dilog()) @@ -2849,17 +2853,17 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: sage: i = ComplexField(30).0 - sage: (1+i).gamma() + sage: (1 + i).gamma() # needs sage.libs.pari 0.49801567 - 0.15494983*I TESTS:: - sage: CC(0).gamma() + sage: CC(0).gamma() # needs sage.libs.pari Infinity :: - sage: CC(-1).gamma() + sage: CC(-1).gamma() # needs sage.libs.pari Infinity """ try: @@ -2875,6 +2879,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): EXAMPLES:: + sage: # needs sage.libs.pari sage: C, i = ComplexField(30).objgen() sage: (1+i).gamma_inc(2 + 3*i) # abs tol 2e-10 0.0020969149 - 0.059981914*I @@ -2890,7 +2895,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): Check that :trac:`7099` is fixed:: sage: C = ComplexField(400) - sage: C(2 + I).gamma_inc(C(3 + I)) # abs tol 1e-120 + sage: C(2 + I).gamma_inc(C(3 + I)) # abs tol 1e-120 # needs sage.libs.pari 0.121515644664508695525971545977439666159749344176962379708992904126499444842886620664991650378432544392118359044438541515 + 0.101533909079826033296475736021224621546966200987295663190553587086145836461236284668967411665020429964946098113930918850*I """ @@ -3224,9 +3229,9 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): sage: i = ComplexField(30).gen() sage: z = 1 + i - sage: z.zeta() + sage: z.zeta() # needs sage.libs.pari 0.58215806 - 0.92684856*I - sage: zeta(z) + sage: zeta(z) # needs sage.libs.pari 0.58215806 - 0.92684856*I sage: CC(1).zeta() diff --git a/src/sage/rings/continued_fraction.py b/src/sage/rings/continued_fraction.py index c5298a34ae4..a3f877e423d 100644 --- a/src/sage/rings/continued_fraction.py +++ b/src/sage/rings/continued_fraction.py @@ -67,14 +67,14 @@ sage: 0 + 1/(2 + 1/22) 22/45 - sage: continued_fraction(pi) + sage: continued_fraction(pi) # needs sage.symbolic [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] - sage: continued_fraction_list(pi, nterms=5) + sage: continued_fraction_list(pi, nterms=5) # needs sage.symbolic [3, 7, 15, 1, 292] sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 5, embedding=1.709) # optional - sage.rings.number_field - sage: continued_fraction(cbrt5) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 5, embedding=1.709) # needs sage.rings.number_field + sage: continued_fraction(cbrt5) # needs sage.rings.number_field [1; 1, 2, 2, 4, 3, 3, 1, 5, 1, 1, 4, 10, 17, 1, 14, 1, 1, 3052, 1, ...] It is also possible to create a continued fraction from a list of partial @@ -85,10 +85,9 @@ Even infinite:: - sage: w = words.ThueMorseWord([1,2]) - sage: w + sage: w = words.ThueMorseWord([1,2]); w # needs sage.combinat word: 1221211221121221211212211221211221121221... - sage: continued_fraction(w) + sage: continued_fraction(w) # needs sage.combinat [1; 2, 2, 1, 2, 1, 1, 2, 2, 1...] To go back and forth between the value (as a real number) and the partial @@ -101,18 +100,18 @@ sage: cf.value() 13/27 - sage: cf = continued_fraction(pi) - sage: cf.quotients() + sage: cf = continued_fraction(pi) # needs sage.symbolic + sage: cf.quotients() # needs sage.symbolic lazy list [3, 7, 15, ...] - sage: cf.value() + sage: cf.value() # needs sage.symbolic pi + sage: # needs sage.combinat sage: w = words.FibonacciWord([1,2]) sage: cf = continued_fraction(w) sage: cf.quotients() word: 1211212112112121121211211212112112121121... - sage: v = cf.value() - sage: v + sage: v = cf.value(); v 1.387954587967143? sage: v.n(digits=100) 1.387954587967142336919313859873185477878152452498532271894917289826418577622648932169885237034242967 @@ -122,6 +121,7 @@ Recall that quadratic numbers correspond to ultimately periodic continued fractions. For them special methods give access to preperiod and period:: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(2) sage: cf = continued_fraction(sqrt2); cf [1; (2)*] @@ -132,18 +132,18 @@ sage: cf.period() (2,) - sage: cf = (3*sqrt2 + 1/2).continued_fraction(); cf + sage: cf = (3*sqrt2 + 1/2).continued_fraction(); cf # needs sage.rings.number_field [4; (1, 2, 1, 7)*] sage: cf = continued_fraction([(1,2,3),(1,4)]); cf [1; 2, 3, (1, 4)*] - sage: cf.value() + sage: cf.value() # needs sage.rings.number_field -2/23*sqrt2 + 36/23 On the following we can remark how the tail may change even in the same quadratic field:: - sage: for i in range(20): print(continued_fraction(i*sqrt2)) + sage: for i in range(20): print(continued_fraction(i*sqrt2)) # needs sage.rings.number_field [0] [1; (2)*] [2; (1, 4)*] @@ -157,6 +157,7 @@ Nevertheless, the tail is preserved under invertible integer homographies:: + sage: # needs sage.rings.number_field sage: apply_homography = lambda m,z: (m[0,0]*z + m[0,1]) / (m[1,0]*z + m[1,1]) sage: m1 = SL2Z([60,13,83,18]) sage: m2 = SL2Z([27,80,28,83]) @@ -264,7 +265,7 @@ def rat_interval_cf_list(r1, r2): sage: from sage.rings.continued_fraction import rat_interval_cf_list sage: rat_interval_cf_list(257/113, 5224/2297) [2, 3, 1, 1, 1, 4] - sage: for prec in range(10,54): + sage: for prec in range(10,54): # needs sage.rings.real_interval_field ....: R = RealIntervalField(prec) ....: for _ in range(100): ....: x = R.random_element() * R.random_element() + R.random_element() / 100 @@ -361,7 +362,7 @@ def str(self, nterms=10, unicode=False, join=True): EXAMPLES:: - sage: print(continued_fraction(pi).str()) + sage: print(continued_fraction(pi).str()) # needs sage.symbolic 1 3 + ---------------------------------------------------- 1 @@ -381,9 +382,9 @@ def str(self, nterms=10, unicode=False, join=True): 1 2 + --------- 1 + ... - sage: print(continued_fraction(pi).str(nterms=1)) + sage: print(continued_fraction(pi).str(nterms=1)) # needs sage.symbolic 3 + ... - sage: print(continued_fraction(pi).str(nterms=2)) + sage: print(continued_fraction(pi).str(nterms=2)) # needs sage.symbolic 1 3 + --------- 7 + ... @@ -505,8 +506,8 @@ def _latex_(self, nterms=10): r""" EXAMPLES:: - sage: cf_pi = continued_fraction(pi) - sage: latex(cf_pi) + sage: cf_pi = continued_fraction(pi) # needs sage.symbolic + sage: latex(cf_pi) # needs sage.symbolic 3 + \frac{\displaystyle 1}{\displaystyle 7 + \frac{\displaystyle 1}{\displaystyle 15 @@ -518,7 +519,7 @@ def _latex_(self, nterms=10): + \frac{\displaystyle 1}{\displaystyle 2 + \frac{\displaystyle 1}{\displaystyle 1 + \frac{\displaystyle 1}{\displaystyle \dots}}}}}}}}}} - sage: print(cf_pi._latex_(nterms=3)) + sage: print(cf_pi._latex_(nterms=3)) # needs sage.symbolic 3 + \frac{\displaystyle 1}{\displaystyle 7 + \frac{\displaystyle 1}{\displaystyle 15 @@ -594,18 +595,19 @@ def _mpfr_(self, R): EXAMPLES:: - sage: continued_fraction(1/2).n() + sage: continued_fraction(1/2).n() # needs sage.rings.real_mpfr 0.500000000000000 - sage: continued_fraction([0,4]).n() + sage: continued_fraction([0,4]).n() # needs sage.rings.real_mpfr 0.250000000000000 - sage: continued_fraction([12,1,3,4,2,2,3,1,2]).n(digits=4) + sage: continued_fraction([12,1,3,4,2,2,3,1,2]).n(digits=4) # needs sage.rings.real_mpfr 12.76 - sage: continued_fraction(12/7).n(digits=13) == (12/7).n(digits=13) + sage: continued_fraction(12/7).n(digits=13) == (12/7).n(digits=13) # needs sage.rings.real_mpfr True - sage: continued_fraction(-14/333).n(digits=21) == (-14/333).n(digits=21) + sage: continued_fraction(-14/333).n(digits=21) == (-14/333).n(digits=21) # needs sage.rings.real_mpfr True + sage: # needs sage.symbolic sage: a = (106*pi - 333) / (355 - 113*pi) - 292 sage: cf = continued_fraction(a); cf [0; 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, ...] @@ -622,10 +624,11 @@ def _mpfr_(self, R): sage: cf.n(digits=8) 0.63459101 + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2, 'a', embedding=1.25) # optional - sage.rings.number_field - sage: b = 504/253*a^2 + 635/253*a + 661/253 # optional - sage.rings.number_field - sage: cf = continued_fraction(b); cf # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2, 'a', embedding=1.25) + sage: b = 504/253*a^2 + 635/253*a + 661/253 + sage: cf = continued_fraction(b); cf [8; 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, 4, 1, 1, 2, 14, 3, ...] sage: cf.n(digits=3) 8.94 @@ -648,7 +651,7 @@ def _mpfr_(self, R): rational case):: sage: fields = [] - sage: for prec in [17, 24, 53, 128, 256]: + sage: for prec in [17, 24, 53, 128, 256]: # needs sage.rings.real_mpfr ....: for rnd in ['RNDN', 'RNDD', 'RNDU', 'RNDZ', 'RNDA']: ....: fields.append(RealField(prec=prec, rnd=rnd)) sage: for n in range(3000): # long time, not tested, known bug (see :trac:`29957`) @@ -745,7 +748,7 @@ def __float__(self): sage: a = continued_fraction(-17/389); a [-1; 1, 21, 1, 7, 2] - sage: float(a) + sage: float(a) # needs sage.rings.real_mpfr -0.043701799485861184 sage: float(-17/389) -0.043701799485861184 @@ -759,6 +762,7 @@ def numerator(self, n): EXAMPLES:: + sage: # needs sage.symbolic sage: c = continued_fraction(pi); c [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] sage: c.numerator(0) @@ -793,6 +797,7 @@ def denominator(self, n): EXAMPLES:: + sage: # needs sage.symbolic sage: c = continued_fraction(pi); c [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] sage: c.denominator(0) @@ -815,11 +820,11 @@ def convergent(self, n): EXAMPLES:: - sage: a = continued_fraction(pi); a + sage: a = continued_fraction(pi); a # needs sage.symbolic [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] - sage: a.convergent(3) + sage: a.convergent(3) # needs sage.symbolic 355/113 - sage: a.convergent(15) + sage: a.convergent(15) # needs sage.symbolic 411557987/131002976 """ return self.numerator(n) / self.denominator(n) @@ -883,15 +888,15 @@ def __getitem__(self, n): TESTS:: - sage: cf1 = continued_fraction(pi); cf1 + sage: cf1 = continued_fraction(pi); cf1 # needs sage.symbolic [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] - sage: cf2 = continued_fraction(QuadraticField(2).gen()); cf2 + sage: cf2 = continued_fraction(QuadraticField(2).gen()); cf2 # needs sage.rings.number_field [1; (2)*] sage: cf3 = continued_fraction(4/17); cf3 [0; 4, 4] - sage: cf1[3:17] + sage: cf1[3:17] # needs sage.symbolic [1; 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2] - sage: cf2[:10] + sage: cf2[:10] # needs sage.rings.number_field [1; 2, 2, 2, 2, 2, 2, 2, 2, 2] sage: cf3[1:16] [4; 4] @@ -899,7 +904,7 @@ def __getitem__(self, n): Be careful that the truncation of an infinite continued fraction might be shorter by one:: - sage: len(continued_fraction(golden_ratio)[:8]) + sage: len(continued_fraction(golden_ratio)[:8]) # needs sage.symbolic 7 """ if isinstance(n, slice): @@ -926,6 +931,7 @@ def __iter__(self): EXAMPLES:: + sage: # needs sage.symbolic sage: cf = continued_fraction(pi) sage: i = iter(cf) sage: [next(i) for _ in range(10)] @@ -964,7 +970,7 @@ def sign(self): EXAMPLES:: - sage: continued_fraction(tan(pi/7)).sign() + sage: continued_fraction(tan(pi/7)).sign() # needs sage.symbolic 1 sage: continued_fraction(-34/2115).sign() -1 @@ -1032,7 +1038,7 @@ def is_zero(self): False sage: continued_fraction(-1/2).is_zero() False - sage: continued_fraction(pi).is_zero() + sage: continued_fraction(pi).is_zero() # needs sage.symbolic False """ return self.quotient(0) == ZZ_0 and self.quotient(1) is Infinity @@ -1049,7 +1055,7 @@ def is_one(self): False sage: continued_fraction(0).is_one() False - sage: continued_fraction(pi).is_one() + sage: continued_fraction(pi).is_one() # needs sage.symbolic False """ return self.quotient(0) == ZZ_1 and self.quotient(1) is Infinity @@ -1098,7 +1104,7 @@ def multiplicative_order(self): 2 sage: continued_fraction(1).multiplicative_order() 1 - sage: continued_fraction(pi).multiplicative_order() + sage: continued_fraction(pi).multiplicative_order() # needs sage.symbolic +Infinity """ if self.is_zero(): @@ -1128,18 +1134,17 @@ def numerical_approx(self, prec=None, digits=None, algorithm=None): EXAMPLES:: - sage: w = words.FibonacciWord([1,3]) - sage: cf = continued_fraction(w) - sage: cf + sage: w = words.FibonacciWord([1,3]) # needs sage.combinat + sage: cf = continued_fraction(w); cf # needs sage.combinat [1; 3, 1, 1, 3, 1, 3, 1, 1, 3, 1, 1, 3, 1, 3, 1, 1, 3, 1, 3...] - sage: cf.numerical_approx(prec=53) + sage: cf.numerical_approx(prec=53) # needs sage.combinat 1.28102513329557 The method `n` is a shortcut to this one:: - sage: cf.n(digits=25) + sage: cf.n(digits=25) # needs sage.combinat 1.281025133295569815552930 - sage: cf.n(digits=33) + sage: cf.n(digits=33) # needs sage.combinat 1.28102513329556981555293038097590 """ from sage.arith.numerical_approx import (digits_to_bits, @@ -1174,22 +1179,20 @@ def apply_homography(self, a, b, c, d, forward_value=False): We demonstrate now the effect of the optional argument ``forward_value``:: - sage: cf = continued_fraction(pi) - sage: h1 = cf.apply_homography(35, -27, 12, -5) - sage: h1 + sage: cf = continued_fraction(pi) # needs sage.symbolic + sage: h1 = cf.apply_homography(35, -27, 12, -5); h1 # needs sage.symbolic [2; 1, 1, 6, 3, 1, 2, 1, 5, 3, 1, 1, 1, 1, 9, 12, 1, 1, 1, 3...] - sage: h1.value() + sage: h1.value() # needs sage.symbolic 2.536941776086946? - sage: h2 = cf.apply_homography(35, -27, 12, -5, forward_value=True) - sage: h2 + sage: h2 = cf.apply_homography(35, -27, 12, -5, forward_value=True); h2 # needs sage.symbolic [2; 1, 1, 6, 3, 1, 2, 1, 5, 3, 1, 1, 1, 1, 9, 12, 1, 1, 1, 3...] - sage: h2.value() + sage: h2.value() # needs sage.symbolic (35*pi - 27)/(12*pi - 5) TESTS:: - sage: CF = [continued_fraction(x) for x in [sqrt(2), AA(3).sqrt(), + sage: CF = [continued_fraction(x) for x in [sqrt(2), AA(3).sqrt(), # needs sage.rings.number_field sage.symbolic ....: AA(3)**(1/3), QuadraticField(37).gen(), pi, 113/27, ....: [3,1,2,2], words.FibonacciWord([1,3])]] sage: for _ in range(100): # not tested, known bug (see :trac:`32086`) @@ -1211,7 +1214,7 @@ def apply_homography(self, a, b, c, d, forward_value=False): ... ValueError: continued fraction can not represent infinity - sage: continued_fraction(pi).apply_homography(0, 1, 0, 0) + sage: continued_fraction(pi).apply_homography(0, 1, 0, 0) # needs sage.symbolic Traceback (most recent call last): ... ZeroDivisionError: division by zero @@ -1262,9 +1265,9 @@ def __neg__(self): EXAMPLES:: - sage: -continued_fraction(e) + sage: -continued_fraction(e) # needs sage.symbolic [-3; 3, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1, 14...] - sage: -continued_fraction(sqrt(7)) + sage: -continued_fraction(sqrt(7)) # needs sage.symbolic [-3; 2, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4...] """ return self.apply_homography(-1, 0, 0, 1) @@ -1275,9 +1278,9 @@ def __invert__(self): EXAMPLES:: - sage: ~continued_fraction(e) + sage: ~continued_fraction(e) # needs sage.symbolic [0; 2, 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1...] - sage: ~continued_fraction(sqrt(7)) + sage: ~continued_fraction(sqrt(7)) # needs sage.symbolic [0; 2, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1...] """ return self.apply_homography(0, 1, 1, 0) @@ -1327,12 +1330,12 @@ def period(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(3) sage: cf = continued_fraction(sqrt3); cf [1; (1, 2)*] sage: cf.period() (1, 2) - sage: for k in xsrange(2,40): ....: if not k.is_square(): ....: s = QuadraticField(k).gen() @@ -1365,12 +1368,12 @@ def preperiod(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(3) sage: cf = continued_fraction(sqrt3); cf [1; (1, 2)*] sage: cf.preperiod() (1,) - sage: cf = continued_fraction(sqrt3/7); cf [0; 4, (24, 8)*] sage: cf.preperiod() @@ -1448,6 +1451,7 @@ def __richcmp__(self, other, op): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: a = continued_fraction([(0,),(1,2,3,1,2,3,1)]); a.n() 0.694249167819459 sage: b = continued_fraction([(0,),(1,2,3)]); b.n() @@ -1492,49 +1496,49 @@ def value(self): sage: cf = continued_fraction([(),(2,)]); cf [(2)*] - sage: v = cf.value(); v + sage: v = cf.value(); v # needs sage.rings.number_field sqrt2 + 1 - sage: v.continued_fraction() + sage: v.continued_fraction() # needs sage.rings.number_field [(2)*] sage: cf = continued_fraction([(),(1,2)]); cf [(1, 2)*] - sage: v = cf.value(); v + sage: v = cf.value(); v # needs sage.rings.number_field 1/2*sqrt3 + 1/2 - sage: v.continued_fraction() + sage: v.continued_fraction() # needs sage.rings.number_field [(1, 2)*] The number ``sqrt3`` that appear above is actually internal to the continued fraction. In order to be access it from the console:: - sage: cf.value().parent().inject_variables() + sage: cf.value().parent().inject_variables() # needs sage.rings.number_field Defining sqrt3 - sage: sqrt3 + sage: sqrt3 # needs sage.rings.number_field sqrt3 - sage: ((sqrt3+1)/2).continued_fraction() + sage: ((sqrt3+1)/2).continued_fraction() # needs sage.rings.number_field [(1, 2)*] Some ultimately periodic but non periodic examples:: sage: cf = continued_fraction([(1,),(2,)]); cf [1; (2)*] - sage: v = cf.value(); v + sage: v = cf.value(); v # needs sage.rings.number_field sqrt2 - sage: v.continued_fraction() + sage: v.continued_fraction() # needs sage.rings.number_field [1; (2)*] sage: cf = continued_fraction([(1,3),(1,2)]); cf [1; 3, (1, 2)*] - sage: v = cf.value(); v + sage: v = cf.value(); v # needs sage.rings.number_field -sqrt3 + 3 - sage: v.continued_fraction() + sage: v.continued_fraction() # needs sage.rings.number_field [1; 3, (1, 2)*] sage: cf = continued_fraction([(-5,18), (1,3,1,5)]) - sage: cf.value().continued_fraction() == cf + sage: cf.value().continued_fraction() == cf # needs sage.rings.number_field True sage: cf = continued_fraction([(-1,),(1,)]) - sage: cf.value().continued_fraction() == cf + sage: cf.value().continued_fraction() == cf # needs sage.rings.number_field True TESTS:: @@ -1544,7 +1548,7 @@ def value(self): sage: a3 = ((1,),(1,2)) sage: a4 = ((-2,2),(1,124,13)) sage: a5 = ((0,),(1,)) - sage: for a in a1,a2,a3,a4,a5: + sage: for a in a1,a2,a3,a4,a5: # needs sage.rings.number_field ....: cf = continued_fraction(a) ....: assert cf.value().continued_fraction() == cf """ @@ -1575,10 +1579,10 @@ def _repr_(self): r""" TESTS:: - sage: a = continued_fraction(pi.n()); a + sage: a = continued_fraction(pi.n()); a # needs sage.symbolic [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3] - sage: a.rename('continued fraction of pi') - sage: a + sage: a.rename('continued fraction of pi') # needs sage.symbolic + sage: a # needs sage.symbolic continued fraction of pi sage: continued_fraction([(0,1),(2,)]) @@ -1656,10 +1660,10 @@ def _latex_(self): + \frac{\displaystyle 1}{\displaystyle 7 + \frac{\displaystyle 1}{\displaystyle 2 }}}}} - sage: K. = QuadraticField(1234) - sage: cf=continued_fraction(a); cf + sage: K. = QuadraticField(1234) # needs sage.rings.number_field + sage: cf = continued_fraction(a); cf # needs sage.rings.number_field [35; (7, 1, 3, 1, 4, 4, 2, 9, 1, 1, 2, 3, 1, 1, 34, 1, 1, 3, 2, 1, 1, 9, 2, 4, 4, 1, 3, 1, 7, 70)*] - sage: latex(cf) + sage: latex(cf) # needs sage.rings.number_field 35 + \frac{\displaystyle 1}{\displaystyle 7 + \frac{\displaystyle 1}{\displaystyle 1 @@ -1701,6 +1705,7 @@ def __invert__(self): sage: a.value() * (~a).value() 1 + sage: # needs sage.rings.number_field sage: K. = QuadraticField(5) sage: a1 = (sqrt5+1)/2 sage: c1 = a1.continued_fraction(); c1 @@ -1710,9 +1715,9 @@ def __invert__(self): sage: c1.value() * (~c1).value() 1 - sage: c2 = (sqrt5/3 + 1/7).continued_fraction(); c2 + sage: c2 = (sqrt5/3 + 1/7).continued_fraction(); c2 # needs sage.rings.number_field [0; 1, (7, 1, 17, ..., 1, 2)*] - sage: c2.value() * (~c2).value() + sage: c2.value() * (~c2).value() # needs sage.rings.number_field 1 """ if not self: @@ -1744,7 +1749,7 @@ def __neg__(self): sage: quots2 = [((),(1,)), ((), (1,2)), ((0,),(1,)), ....: ((),(2,1)), ((3,),(2,1))] - sage: for q in quots2: + sage: for q in quots2: # needs sage.rings.number_field ....: cf = continued_fraction(q) ....: ncf = -cf ....: nncf = -ncf @@ -1795,16 +1800,14 @@ class ContinuedFraction_real(ContinuedFraction_base): EXAMPLES:: - sage: cf = continued_fraction(pi) - sage: cf + sage: cf = continued_fraction(pi); cf # needs sage.symbolic [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] - sage: cf.value() + sage: cf.value() # needs sage.symbolic pi - sage: cf = continued_fraction(e) - sage: cf + sage: cf = continued_fraction(e); cf # needs sage.symbolic [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1, ...] - sage: cf.value() + sage: cf.value() # needs sage.symbolic e """ def __init__(self, x): @@ -1815,7 +1818,7 @@ def __init__(self, x): TESTS:: - sage: TestSuite(continued_fraction(pi)).run() + sage: TestSuite(continued_fraction(pi)).run() # needs sage.symbolic """ ContinuedFraction_base.__init__(self) self._x0 = x @@ -1833,7 +1836,7 @@ def length(self): EXAMPLES:: - sage: continued_fraction(pi).length() + sage: continued_fraction(pi).length() # needs sage.symbolic +Infinity """ return Infinity @@ -1842,7 +1845,7 @@ def __len__(self): r""" TESTS:: - sage: len(continued_fraction(pi)) + sage: len(continued_fraction(pi)) # needs sage.symbolic Traceback (most recent call last): ... ValueError: the length is infinite! @@ -1855,9 +1858,9 @@ def __richcmp__(self, other, op): EXAMPLES:: - sage: continued_fraction(pi) > continued_fraction(e) + sage: continued_fraction(pi) > continued_fraction(e) # needs sage.symbolic True - sage: continued_fraction(pi) > continued_fraction(e+4) + sage: continued_fraction(pi) > continued_fraction(e+4) # needs sage.symbolic False """ try: @@ -1875,7 +1878,7 @@ def _repr_(self): EXAMPLES:: - sage: continued_fraction(pi) # indirect doctest + sage: continued_fraction(pi) # indirect doctest # needs sage.symbolic [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] """ return '[%d; ' % self.quotient(0) + ', '.join(str(self.quotient(i)) for i in range(1, 20)) + ", ...]" @@ -1886,12 +1889,13 @@ def quotient(self, n): EXAMPLES:: + sage: # needs sage.symbolic sage: cf = continued_fraction(pi) sage: cf.quotient(27) 13 sage: cf.quotient(2552) 152 - sage: cf.quotient(10000) # long time + sage: cf.quotient(10000) # long time 5 The algorithm is not efficient with element of the symbolic ring and, @@ -1900,6 +1904,7 @@ def quotient(self, n): evaluate in ``RIF`` an expression of the form ``(a*x+b)/(c*x+d)`` where both the numerator and the denominator are extremely small:: + sage: # needs sage.symbolic sage: a1 = pi sage: c1 = continued_fraction(a1) sage: p0 = c1.numerator(12); q0 = c1.denominator(12) @@ -1915,12 +1920,13 @@ def quotient(self, n): The same computation with an element of a number field instead of ``pi`` gives a very satisfactory answer:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2, embedding=1.25) # optional - sage.rings.number_field - sage: c2 = continued_fraction(a2) # optional - sage.rings.number_field - sage: p0 = c2.numerator(111); q0 = c2.denominator(111) # optional - sage.rings.number_field - sage: p1 = c2.numerator(112); q1 = c2.denominator(112) # optional - sage.rings.number_field - sage: num = (q0*a2 - p0); num.n() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2, embedding=1.25) + sage: c2 = continued_fraction(a2) + sage: p0 = c2.numerator(111); q0 = c2.denominator(111) + sage: p1 = c2.numerator(112); q1 = c2.denominator(112) + sage: num = (q0*a2 - p0); num.n() -4.56719261665907e46 sage: den = (q1*a2 - p1); den.n() -3.65375409332726e47 @@ -1933,6 +1939,7 @@ def quotient(self, n): The consequence is that the precision needed with ``c1`` grows when we compute larger and larger partial quotients:: + sage: # needs sage.symbolic sage: c1.quotient(100) 2 sage: c1._xa.parent() @@ -1946,6 +1953,7 @@ def quotient(self, n): sage: c1._xa.parent() Real Interval Field with 1053 bits of precision + sage: # needs sage.rings.number_field sage: c2.quotient(200) 6 sage: c2._xa.parent() @@ -1995,8 +2003,8 @@ def value(self): EXAMPLES:: - sage: cf = continued_fraction(e) - sage: cf.value() + sage: cf = continued_fraction(e) # needs sage.symbolic + sage: cf.value() # needs sage.symbolic e """ return self._x0 @@ -2008,16 +2016,16 @@ class ContinuedFraction_infinite(ContinuedFraction_base): EXAMPLES:: - sage: t = continued_fraction(words.ThueMorseWord([1,2])); t + sage: t = continued_fraction(words.ThueMorseWord([1,2])); t # needs sage.combinat [1; 2, 2, 1, 2, 1, 1, 2, 2, 1...] - sage: t.n(digits=100) + sage: t.n(digits=100) # needs sage.combinat 1.422388736882785488341547116024565825306879108991711829311892452916456747272565883312455412962072042 We check that comparisons work well:: - sage: t > continued_fraction(1) and t < continued_fraction(3/2) + sage: t > continued_fraction(1) and t < continued_fraction(3/2) # needs sage.combinat True - sage: t < continued_fraction(1) or t > continued_fraction(2) + sage: t < continued_fraction(1) or t > continued_fraction(2) # needs sage.combinat False Can also be called with a ``value`` option:: @@ -2025,16 +2033,14 @@ class ContinuedFraction_infinite(ContinuedFraction_base): sage: def f(n): ....: if n % 3 == 2: return 2*(n+1)//3 ....: return 1 - sage: w = Word(f, alphabet=NN) - sage: w + sage: w = Word(f, alphabet=NN); w # needs sage.combinat word: 1,1,2,1,1,4,1,1,6,1,1,8,1,1,10,1,1,12,1,1,14,1,1,16,1,1,18,1,1,20,1,1,22,1,1,24,1,1,26,1,... - sage: cf = continued_fraction(w, value=e-1) - sage: cf + sage: cf = continued_fraction(w, value=e-1); cf # needs sage.combinat sage.symbolic [1; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1...] In that case a small check is done on the input:: - sage: cf = continued_fraction(w, value=pi) + sage: cf = continued_fraction(w, value=pi) # needs sage.combinat sage.symbolic Traceback (most recent call last): ... ValueError: value evaluates to 3.141592653589794? while the continued @@ -2056,32 +2062,32 @@ def __init__(self, w, value=None, check=True): TESTS:: - sage: w = words.FibonacciWord(['a','b']) - sage: continued_fraction(w) + sage: w = words.FibonacciWord(['a','b']) # needs sage.combinat + sage: continued_fraction(w) # needs sage.combinat Traceback (most recent call last): ... ValueError: the sequence must consist of integers sage: from itertools import count - sage: w = Word(count(), length="infinite") - sage: continued_fraction(w) + sage: w = Word(count(), length="infinite") # needs sage.combinat + sage: continued_fraction(w) # needs sage.combinat [0; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19...] - sage: w = Word(count(), length="unknown") - sage: continued_fraction(w) + sage: w = Word(count(), length="unknown") # needs sage.combinat + sage: continued_fraction(w) # needs sage.combinat Traceback (most recent call last): ... ValueError: word with unknown length cannot be converted to continued fractions - sage: continued_fraction(words.FibonacciWord([0,1])) + sage: continued_fraction(words.FibonacciWord([0,1])) # needs sage.combinat Traceback (most recent call last): ... ValueError: only the first partial quotient can be null - sage: w = words.ThueMorseWord([int(1), int(2)]) - sage: t = continued_fraction(w) - sage: type(t.quotient(1)) + sage: w = words.ThueMorseWord([int(1), int(2)]) # needs sage.combinat + sage: t = continued_fraction(w) # needs sage.combinat + sage: type(t.quotient(1)) # needs sage.combinat """ ContinuedFraction_base.__init__(self) @@ -2118,8 +2124,8 @@ def _repr_(self): EXAMPLES:: - sage: w = words.FibonacciWord([3,13]) - sage: cf = continued_fraction(w); cf + sage: w = words.FibonacciWord([3,13]) # needs sage.combinat + sage: cf = continued_fraction(w); cf # needs sage.combinat [3; 13, 3, 3, 13, 3, 13, 3, 3, 13, 3, 3, 13, 3, 13, 3, 3, 13, 3, 13...] """ return "[" + str(self._w[0]) + "; " + ", ".join(map(str, self._w[1:20])) + "...]" @@ -2130,9 +2136,9 @@ def length(self): EXAMPLES:: - sage: w = words.FibonacciWord([3,13]) - sage: cf = continued_fraction(w) - sage: cf.length() + sage: w = words.FibonacciWord([3,13]) # needs sage.combinat + sage: cf = continued_fraction(w) # needs sage.combinat + sage: cf.length() # needs sage.combinat +Infinity """ return Infinity @@ -2147,6 +2153,7 @@ def quotient(self, n): EXAMPLES:: + sage: # needs sage.combinat sage: w = words.FibonacciWord([1,3]) sage: cf = continued_fraction(w) sage: cf.quotient(0) @@ -2164,9 +2171,9 @@ def quotients(self): EXAMPLES:: - sage: w = words.FibonacciWord([1,5]) - sage: cf = continued_fraction(w) - sage: cf.quotients() + sage: w = words.FibonacciWord([1,5]) # needs sage.combinat + sage: cf = continued_fraction(w) # needs sage.combinat + sage: cf.quotients() # needs sage.combinat word: 1511515115115151151511511515115115151151... """ return self._w @@ -2181,6 +2188,7 @@ def _Integer_quotient(self, n): EXAMPLES:: + sage: # needs sage.combinat sage: w = words.ThueMorseWord([int(1), int(2)]) sage: t = continued_fraction(w) sage: t.quotient(0) @@ -2204,20 +2212,17 @@ def value(self): sage: def f(n): ....: if n % 3 == 2: return 2*(n+1)//3 ....: return 1 - sage: w = Word(f, alphabet=NN) - sage: w + sage: w = Word(f, alphabet=NN); w # needs sage.combinat word: 1,1,2,1,1,4,1,1,6,1,1,8,1,1,10,1,1,12,1,1,14,1,1,16,1,1,18,1,1,20,1,1,22,1,1,24,1,1,26,1,... - sage: cf = continued_fraction(w, value=e-1) - sage: cf + sage: cf = continued_fraction(w, value=e-1); cf # needs sage.combinat sage.symbolic [1; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1...] - sage: cf.value() + sage: cf.value() # needs sage.combinat sage.symbolic e - 1 - sage: w = words.FibonacciWord([2,5]) - sage: cf = continued_fraction(w) - sage: cf + sage: w = words.FibonacciWord([2,5]) # needs sage.combinat + sage: cf = continued_fraction(w); cf # needs sage.combinat [2; 5, 2, 2, 5, 2, 5, 2, 2, 5, 2, 2, 5, 2, 5, 2, 2, 5, 2, 5...] - sage: cf.value() + sage: cf.value() # needs sage.combinat 2.184951302409338? """ if self._value is not None: @@ -2234,12 +2239,12 @@ def __neg__(self): EXAMPLES:: - sage: -continued_fraction(words.FibonacciWord([2,5])) + sage: -continued_fraction(words.FibonacciWord([2,5])) # needs sage.combinat [-3; 1, 4, 2, 2, 5, 2, 5, 2, 2, 5, 2, 2, 5, 2, 5, 2, 2, 5, 2...] sage: from sage.misc.lazy_list import lazy_list sage: l = lazy_list(lambda n: (n**2)%17) - sage: -continued_fraction(l) + sage: -continued_fraction(l) # needs sage.combinat [-1; 5, 9, 16, 8, 2, 15, 13, 13, 15, 2, 8, 16, 9, 4, 1, 0, 1, 4, 9...] """ from sage.combinat.words.word import Word @@ -2374,20 +2379,20 @@ def continued_fraction_list(x, type="std", partial_convergents=False, sage: 2 + 1/(2 + 1/(1 + 1/(2 + 1/2))) 45/19 - sage: continued_fraction_list(45/19,type="hj") + sage: continued_fraction_list(45/19, type="hj") [3, 2, 3, 2, 3] sage: 3 - 1/(2 - 1/(3 - 1/(2 - 1/3))) 45/19 Specifying ``bits`` or ``nterms`` modify the length of the output:: + sage: # needs sage.symbolic sage: continued_fraction_list(e, bits=20) [2, 1, 2, 1, 1, 4, 2] - sage: continued_fraction_list(sqrt(2)+sqrt(3), bits=30) + sage: continued_fraction_list(sqrt(2) + sqrt(3), bits=30) [3, 6, 1, 5, 7, 2] sage: continued_fraction_list(pi, bits=53) [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14] - sage: continued_fraction_list(log(3/2), nterms=15) [0, 2, 2, 6, 1, 11, 2, 1, 2, 2, 1, 4, 3, 1, 1] sage: continued_fraction_list(tan(sqrt(pi)), nterms=20) @@ -2397,16 +2402,18 @@ def continued_fraction_list(x, type="std", partial_convergents=False, and the parameters ``bits`` and ``nterms`` are not specified then a warning is raised:: - sage: continued_fraction_list(sqrt(2)) - doctest:...: UserWarning: the continued fraction of sqrt(2) seems infinite, return only the first 20 terms + sage: continued_fraction_list(sqrt(2)) # needs sage.symbolic + doctest:...: UserWarning: the continued fraction of sqrt(2) seems infinite, + return only the first 20 terms [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2] - sage: continued_fraction_list(sqrt(4/19)) - doctest:...: UserWarning: the continued fraction of 2*sqrt(1/19) seems infinite, return only the first 20 terms + sage: continued_fraction_list(sqrt(4/19)) # needs sage.symbolic + doctest:...: UserWarning: the continued fraction of 2*sqrt(1/19) seems infinite, + return only the first 20 terms [0, 2, 5, 1, 1, 2, 1, 16, 1, 2, 1, 1, 5, 4, 5, 1, 1, 2, 1, 16] An examples with the list of partial convergents:: - sage: continued_fraction_list(RR(pi), partial_convergents=True) + sage: continued_fraction_list(RR(pi), partial_convergents=True) # needs sage.symbolic ([3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3], [(3, 1), (22, 7), @@ -2427,24 +2434,24 @@ def continued_fraction_list(x, type="std", partial_convergents=False, sage: continued_fraction_list(1 + 10^-10, nterms=3) [1, 10000000000] - sage: continued_fraction_list(1 + 10^-20 - e^-100, nterms=3) + sage: continued_fraction_list(1 + 10^-20 - e^-100, nterms=3) # needs sage.symbolic [1, 100000000000000000000, 2688] - sage: continued_fraction_list(1 + 10^-20 - e^-100, nterms=5) + sage: continued_fraction_list(1 + 10^-20 - e^-100, nterms=5) # needs sage.symbolic [1, 100000000000000000000, 2688, 8, 1] - sage: continued_fraction_list(1 + 10^-20 - e^-100, nterms=5) + sage: continued_fraction_list(1 + 10^-20 - e^-100, nterms=5) # needs sage.symbolic [1, 100000000000000000000, 2688, 8, 1] Fixed :trac:`18901`:: sage: a = 1.575709393346379 - sage: type(a) + sage: type(a) # needs sage.rings.real_mpfr sage: continued_fraction_list(a) [1, 1, 1, 2, 1, 4, 18, 1, 5, 2, 25037802, 7, 1, 3, 1, 28, 1, 8, 2] Check that this works for arb elements (:trac:`20069`):: - sage: continued_fraction(RBF(e)) + sage: continued_fraction(RBF(e)) # needs sage.symbolic [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12] """ from .rational_field import QQ @@ -2537,41 +2544,44 @@ def continued_fraction(x, value=None): It can be called with elements defined from symbolic values, in which case the partial quotients are evaluated in a lazy way:: - sage: c = continued_fraction(golden_ratio); c # optional - sage.symbolic + sage: c = continued_fraction(golden_ratio); c # needs sage.symbolic [1; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...] - sage: c.convergent(12) # optional - sage.symbolic + sage: c.convergent(12) # needs sage.symbolic 377/233 - sage: fibonacci(14)/fibonacci(13) + sage: fibonacci(14)/fibonacci(13) # needs sage.libs.pari 377/233 - sage: continued_fraction(pi) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: continued_fraction(pi) [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] - sage: c = continued_fraction(pi); c # optional - sage.symbolic + sage: c = continued_fraction(pi); c [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] - sage: a = c.convergent(3); a # optional - sage.symbolic + sage: a = c.convergent(3); a 355/113 - sage: a.n() # optional - sage.symbolic + sage: a.n() 3.14159292035398 - sage: pi.n() # optional - sage.symbolic + sage: pi.n() 3.14159265358979 - sage: continued_fraction(sqrt(2)) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: continued_fraction(sqrt(2)) [1; 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ...] - sage: continued_fraction(tan(1)) # optional - sage.symbolic + sage: continued_fraction(tan(1)) [1; 1, 1, 3, 1, 5, 1, 7, 1, 9, 1, 11, 1, 13, 1, 15, 1, 17, 1, 19, ...] - sage: continued_fraction(tanh(1)) # optional - sage.symbolic + sage: continued_fraction(tanh(1)) [0; 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, ...] - sage: continued_fraction(e) # optional - sage.symbolic + sage: continued_fraction(e) [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1, ...] If you want to play with quadratic numbers (such as ``golden_ratio`` and ``sqrt(2)`` above), it is much more convenient to use number fields as follows since preperiods and periods are computed:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 5, embedding=2.23) # optional - sage.rings.number_field - sage: my_golden_ratio = (1 + sqrt5)/2 # optional - sage.rings.number_field - sage: cf = continued_fraction((1+sqrt5)/2); cf # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 5, embedding=2.23) + sage: my_golden_ratio = (1 + sqrt5)/2 + sage: cf = continued_fraction((1+sqrt5)/2); cf [(1)*] sage: cf.convergent(12) 377/233 @@ -2584,6 +2594,7 @@ def continued_fraction(x, value=None): sage: cf.period() (1, 3, 1, 1, 3, 9) + sage: # needs sage.rings.number_field sage: L. = NumberField(x^2 - 2, embedding=1.41) sage: cf = continued_fraction(sqrt2); cf [1; (2)*] @@ -2600,20 +2611,20 @@ def continued_fraction(x, value=None): sage: cf = continued_fraction([(1,1), (2,8)]); cf [1; 1, (2, 8)*] - sage: cf.value() + sage: cf.value() # needs sage.rings.number_field 2/11*sqrt5 + 14/11 It is possible to deal with higher degree number fields but in that case the continued fraction expansion is known to be aperiodic:: - sage: K. = NumberField(x^3 - 2, embedding=1.25) - sage: cf = continued_fraction(a); cf + sage: K. = NumberField(x^3 - 2, embedding=1.25) # needs sage.rings.number_field + sage: cf = continued_fraction(a); cf # needs sage.rings.number_field [1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, ...] Note that initial rounding can result in incorrect trailing partial quotients:: - sage: continued_fraction(RealField(39)(e)) + sage: continued_fraction(RealField(39)(e)) # needs sage.symbolic [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 2] Note the value returned for floating point number is the continued fraction @@ -2635,8 +2646,8 @@ def continued_fraction(x, value=None): Constants in symbolic subrings work like constants in ``SR``:: - sage: SCR = SR.subring(no_variables=True) # optional - sage.symbolic - sage: continued_fraction(SCR(pi)) # optional - sage.symbolic + sage: SCR = SR.subring(no_variables=True) # needs sage.symbolic + sage: continued_fraction(SCR(pi)) # needs sage.symbolic [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ...] """ diff --git a/src/sage/rings/continued_fraction_gosper.py b/src/sage/rings/continued_fraction_gosper.py index 08d5dd34658..4f86b3d9da6 100644 --- a/src/sage/rings/continued_fraction_gosper.py +++ b/src/sage/rings/continued_fraction_gosper.py @@ -4,12 +4,13 @@ EXAMPLES:: + sage: # needs sage.symbolic sage: from sage.rings.continued_fraction_gosper import gosper_iterator sage: x = continued_fraction(pi) sage: it = iter(gosper_iterator(3,2,3,1,x)) - sage: Word(it, length='infinite') + sage: Word(it, length='infinite') # needs sage.combinat word: 1,10,2,2,1,4,1,1,1,97,4,1,2,1,2,45,6,4,9,1,27,2,6,1,4,2,3,1,3,1,15,2,1,1,2,1,1,2,32,1,... - sage: continued_fraction((3*pi + 2) / (3*pi + 1)) + sage: continued_fraction((3*pi + 2) / (3*pi + 1)) # needs sage.combinat [1; 10, 2, 2, 1, 4, 1, 1, 1, 97, 4, 1, 2, 1, 2, 45, 6, 4, 9, 1, ...] REFERENCES: @@ -104,9 +105,9 @@ def __iter__(self): sage: from sage.rings.continued_fraction_gosper import gosper_iterator sage: a, b, c, d = (Integer(randint(-100,100)) for _ in range(4)) - sage: ig = iter(gosper_iterator(a, b, c, d, continued_fraction(pi))) - sage: icf = iter(continued_fraction((a*pi + b) / (c*pi + d))); - sage: for i in range(10): + sage: ig = iter(gosper_iterator(a, b, c, d, continued_fraction(pi))) # needs sage.symbolic + sage: icf = iter(continued_fraction((a*pi + b) / (c*pi + d))); # needs sage.symbolic + sage: for i in range(10): # needs sage.symbolic ....: try: ....: assert next(ig) == next(icf) ....: except StopIteration: @@ -121,8 +122,8 @@ def __next__(self): TESTS:: sage: from sage.rings.continued_fraction_gosper import gosper_iterator - sage: it = gosper_iterator(1, 0, 0, 1, continued_fraction(pi)) - sage: list(next(it) for _ in range(10)) + sage: it = gosper_iterator(1, 0, 0, 1, continued_fraction(pi)) # needs sage.symbolic + sage: list(next(it) for _ in range(10)) # needs sage.symbolic [3, 7, 15, 1, 292, 1, 1, 1, 2, 1] """ while True: @@ -156,10 +157,10 @@ def emit(self, q): sage: a = Integer(randint(-100,100)); b = Integer(randint(-100,100)); sage: c = Integer(randint(-100,100)); d = Integer(randint(-100,100)); sage: from sage.rings.continued_fraction_gosper import gosper_iterator - sage: gi = gosper_iterator(a,b,c,d,continued_fraction(pi)) - sage: for i in range(10): + sage: gi = gosper_iterator(a, b, c, d, continued_fraction(pi)) # needs sage.symbolic + sage: for i in range(10): # needs sage.symbolic ....: gi.emit(i) - sage: gi.currently_emitted + sage: gi.currently_emitted # needs sage.symbolic 10 """ self.currently_emitted += 1 @@ -182,10 +183,10 @@ def ingest(self): sage: a = Integer(randint(-100,100)); b = Integer(randint(-100,100)); sage: c = Integer(randint(-100,100)); d = Integer(randint(-100,100)); sage: from sage.rings.continued_fraction_gosper import gosper_iterator - sage: gi = gosper_iterator(a,b,c,d,continued_fraction(pi)) - sage: for i in range(10): + sage: gi = gosper_iterator(a, b, c, d, continued_fraction(pi)) # needs sage.symbolic + sage: for i in range(10): # needs sage.symbolic ....: gi.ingest() - sage: gi.currently_read + sage: gi.currently_read # needs sage.symbolic 10 """ try: diff --git a/src/sage/rings/derivation.py b/src/sage/rings/derivation.py index 74903e6072f..26b6f2d5905 100644 --- a/src/sage/rings/derivation.py +++ b/src/sage/rings/derivation.py @@ -231,32 +231,32 @@ def __init__(self, domain, codomain, twist=None): sage: TestSuite(M).run() sage: from sage.rings.derivation import RingDerivationModule - sage: R5. = GF(5)[] # optional - sage.rings.finite_rings - sage: R25. = GF(25)[] # optional - sage.rings.finite_rings - sage: R7. = GF(7)[] # optional - sage.rings.finite_rings + sage: R5. = GF(5)[] + sage: R25. = GF(25)[] # needs sage.rings.finite_rings + sage: R7. = GF(7)[] - sage: RingDerivationModule(R5, R25) # optional - sage.rings.finite_rings + sage: RingDerivationModule(R5, R25) # needs sage.rings.finite_rings Module of derivations from Univariate Polynomial Ring in x over Finite Field of size 5 to Univariate Polynomial Ring in x over Finite Field in z2 of size 5^2 - sage: RingDerivationModule(R5, R5^2) # optional - sage.rings.finite_rings + sage: RingDerivationModule(R5, R5^2) Traceback (most recent call last): ... TypeError: the codomain must be an algebra over the domain or a morphism with the correct domain - sage: RingDerivationModule(R5, R7) # optional - sage.rings.finite_rings + sage: RingDerivationModule(R5, R7) # needs sage.rings.finite_rings Traceback (most recent call last): ... TypeError: the codomain must be an algebra over the domain or a morphism with the correct domain - sage: theta = R5.hom([R5.gen()^2]) # optional - sage.rings.finite_rings - sage: RingDerivationModule(R5, R25, twist=theta) # optional - sage.rings.finite_rings + sage: theta = R5.hom([R5.gen()^2]) + sage: RingDerivationModule(R5, R25, twist=theta) # needs sage.rings.finite_rings Module of twisted derivations from Univariate Polynomial Ring in x over Finite Field of size 5 to Univariate Polynomial Ring in x over Finite Field in z2 of size 5^2 (twisting morphism: x |--> x^2) - sage: RingDerivationModule(R7, R7, twist=theta) # optional - sage.rings.finite_rings + sage: RingDerivationModule(R7, R7, twist=theta) # needs sage.rings.finite_rings Traceback (most recent call last): ... TypeError: the domain of the derivation must coerce to the domain of the twisting homomorphism @@ -1074,10 +1074,10 @@ def _richcmp_(self, other, op): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: D = sum(v*R.derivation(v) for v in R.gens()); D # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: D = sum(v*R.derivation(v) for v in R.gens()); D x*d/dx + y*d/dy + z*d/dz - sage: D.pth_power() == D # optional - sage.rings.finite_rings + sage: D.pth_power() == D True """ @@ -1149,17 +1149,18 @@ def pth_power(self): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: Dx = R.derivation(x) # optional - sage.rings.finite_rings - sage: Dx.pth_power() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: Dx = R.derivation(x) + sage: Dx.pth_power() 0 - sage: (x*Dx).pth_power() # optional - sage.rings.finite_rings + sage: (x*Dx).pth_power() x*d/dx - sage: (x^6*Dx).pth_power() # optional - sage.rings.finite_rings + sage: (x^6*Dx).pth_power() x^26*d/dx - sage: Dy = R.derivation(y) # optional - sage.rings.finite_rings - sage: (x*Dx + y*Dy).pth_power() # optional - sage.rings.finite_rings + sage: Dy = R.derivation(y) # needs sage.rings.finite_rings + sage: (x*Dx + y*Dy).pth_power() # needs sage.rings.finite_rings x*d/dx + y*d/dy An error is raised if the domain has characteristic zero:: @@ -1182,14 +1183,15 @@ def pth_power(self): TESTS:: - sage: R. = GF(3)[] # optional - sage.rings.finite_rings - sage: D = R.derivation_module().random_element() # optional - sage.rings.finite_rings - sage: Dp = D.pth_power() # optional - sage.rings.finite_rings - sage: f = R.random_element() # optional - sage.rings.finite_rings - sage: Dp(f) == D(D(D(f))) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(3)[] + sage: D = R.derivation_module().random_element() + sage: Dp = D.pth_power() + sage: f = R.random_element() + sage: Dp(f) == D(D(D(f))) True - sage: D.bracket(Dp) # optional - sage.rings.finite_rings + sage: D.bracket(Dp) # needs sage.rings.finite_rings 0 """ @@ -1578,15 +1580,16 @@ def __init__(self, parent, arg=None): TESTS:: + sage: # needs sage.rings.finite_rings sage: from sage.rings.derivation import RingDerivationWithoutTwist_wrapper - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: S = R.quo([x^5, y^5]) # optional - sage.rings.finite_rings - sage: M = S.derivation_module() # optional - sage.rings.finite_rings - sage: der = M.random_element() # optional - sage.rings.finite_rings - sage: isinstance(der, RingDerivationWithoutTwist_wrapper) # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: S = R.quo([x^5, y^5]) + sage: M = S.derivation_module() + sage: der = M.random_element() + sage: isinstance(der, RingDerivationWithoutTwist_wrapper) True - sage: TestSuite(der).run() # optional - sage.rings.finite_rings + sage: TestSuite(der).run() # needs sage.rings.finite_rings """ if isinstance(arg, list) and len(arg) == 1 and isinstance(arg[0], RingDerivation): @@ -1617,11 +1620,12 @@ def _add_(self, other): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: S. = R.quo([X^5, Y^5]) # optional - sage.rings.finite_rings - sage: Dx = S.derivation(x) # optional - sage.rings.finite_rings - sage: Dy = S.derivation(y) # optional - sage.rings.finite_rings - sage: Dx + Dy # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: S. = R.quo([X^5, Y^5]) + sage: Dx = S.derivation(x) + sage: Dy = S.derivation(y) + sage: Dx + Dy d/dx + d/dy """ @@ -1633,11 +1637,12 @@ def _sub_(self, other): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: S. = R.quo([X^5, Y^5]) # optional - sage.rings.finite_rings - sage: Dx = S.derivation(x) # optional - sage.rings.finite_rings - sage: Dy = S.derivation(y) # optional - sage.rings.finite_rings - sage: Dx - Dy # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: S. = R.quo([X^5, Y^5]) + sage: Dx = S.derivation(x) + sage: Dy = S.derivation(y) + sage: Dx - Dy d/dx - d/dy """ @@ -1649,10 +1654,11 @@ def _neg_(self): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: S. = R.quo([X^5, Y^5]) # optional - sage.rings.finite_rings - sage: Dx = S.derivation(x) # optional - sage.rings.finite_rings - sage: -Dx # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: S. = R.quo([X^5, Y^5]) + sage: Dx = S.derivation(x) + sage: -Dx -d/dx """ @@ -1664,12 +1670,13 @@ def _lmul_(self, factor): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: S. = R.quo([X^5, Y^5]) # optional - sage.rings.finite_rings - sage: Dx = S.derivation(x) # optional - sage.rings.finite_rings - sage: Dx * 2 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: S. = R.quo([X^5, Y^5]) + sage: Dx = S.derivation(x) + sage: Dx * 2 2*d/dx - sage: Dx * x^2 # optional - sage.rings.finite_rings + sage: Dx * x^2 x^2*d/dx """ @@ -1681,12 +1688,13 @@ def _rmul_(self, factor): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: S. = R.quo([X^5, Y^5]) # optional - sage.rings.finite_rings - sage: Dx = S.derivation(x) # optional - sage.rings.finite_rings - sage: 2 * Dx # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: S. = R.quo([X^5, Y^5]) + sage: Dx = S.derivation(x) + sage: 2 * Dx 2*d/dx - sage: x^2 * Dx # optional - sage.rings.finite_rings + sage: x^2 * Dx x^2*d/dx """ @@ -1699,20 +1707,21 @@ def list(self): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: S. = R.quo([X^5, Y^5]) # optional - sage.rings.finite_rings - sage: M = S.derivation_module() # optional - sage.rings.finite_rings - sage: M.basis() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: S. = R.quo([X^5, Y^5]) + sage: M = S.derivation_module() + sage: M.basis() Family (d/dx, d/dy) - sage: S.derivation(x).list() # optional - sage.rings.finite_rings + sage: S.derivation(x).list() # needs sage.rings.finite_rings [1, 0] - sage: S.derivation(y).list() # optional - sage.rings.finite_rings + sage: S.derivation(y).list() # needs sage.rings.finite_rings [0, 1] - sage: f = x*S.derivation(x) + y*S.derivation(y); f # optional - sage.rings.finite_rings + sage: f = x*S.derivation(x) + y*S.derivation(y); f # needs sage.rings.finite_rings x*d/dx + y*d/dy - sage: f.list() # optional - sage.rings.finite_rings + sage: f.list() # needs sage.rings.finite_rings [x, y] """ @@ -1906,19 +1915,19 @@ def list(self): EXAMPLES:: - sage: R. = GF(5)[[]] # optional - sage.rings.finite_rings - sage: M = R.derivation_module() # optional - sage.rings.finite_rings - sage: M.basis() # optional - sage.rings.finite_rings + sage: R. = GF(5)[[]] + sage: M = R.derivation_module() + sage: M.basis() Family (d/dx, d/dy) - sage: R.derivation(x).list() # optional - sage.rings.finite_rings + sage: R.derivation(x).list() [1, 0] - sage: R.derivation(y).list() # optional - sage.rings.finite_rings + sage: R.derivation(y).list() [0, 1] - sage: f = x*R.derivation(x) + y*R.derivation(y); f # optional - sage.rings.finite_rings + sage: f = x*R.derivation(x) + y*R.derivation(y); f x*d/dx + y*d/dy - sage: f.list() # optional - sage.rings.finite_rings + sage: f.list() [x, y] """ @@ -1991,11 +2000,12 @@ def _call_(self, x): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: S. = R.quo([X^5, Y^5]) # optional - sage.rings.finite_rings - sage: f = x^3*S.derivation(); f # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: S. = R.quo([X^5, Y^5]) + sage: f = x^3*S.derivation(); f x^3*d/dx - sage: f(x^3) # optional - sage.rings.finite_rings + sage: f(x^3) 0 """ @@ -2091,10 +2101,11 @@ def _latex_(self): EXAMPLES:: - sage: k. = GF(5^3) # optional - sage.rings.finite_rings - sage: Frob = k.frobenius_endomorphism() # optional - sage.rings.finite_rings - sage: der = k.derivation(a + 1, twist=Frob) # optional - sage.rings.finite_rings - sage: latex(der) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF(5^3) + sage: Frob = k.frobenius_endomorphism() + sage: der = k.derivation(a + 1, twist=Frob) + sage: latex(der) \left(a + 1\right) \left(\left[a \mapsto a^{5}\right] - \text{id}\right) """ scalar = self._scalar @@ -2370,13 +2381,12 @@ def extend_to_fraction_field(self): sage: d x*([x |--> y, y |--> x] - id) - sage: D = d.extend_to_fraction_field() - sage: D + sage: D = d.extend_to_fraction_field(); D # needs sage.libs.singular x*([x |--> y, y |--> x] - id) - sage: D.domain() + sage: D.domain() # needs sage.libs.singular Fraction Field of Multivariate Polynomial Ring in x, y over Integer Ring - sage: D(1/x) + sage: D(1/x) # needs sage.libs.singular (x - y)/y """ parent = self.parent() diff --git a/src/sage/rings/factorint.pyx b/src/sage/rings/factorint.pyx index fea5b444b00..d4df0e5ea05 100644 --- a/src/sage/rings/factorint.pyx +++ b/src/sage/rings/factorint.pyx @@ -129,25 +129,26 @@ cpdef factor_aurifeuillian(n, check=True): EXAMPLES:: + sage: # needs sage.libs.pari sage: from sage.rings.factorint import factor_aurifeuillian as fa - sage: fa(2^6 + 1) # optional - sage.libs.pari + sage: fa(2^6 + 1) [5, 13] - sage: fa(2^58 + 1) # optional - sage.libs.pari + sage: fa(2^58 + 1) [536838145, 536903681] - sage: fa(3^3 + 1) # optional - sage.libs.pari + sage: fa(3^3 + 1) [4, 1, 7] - sage: fa(5^5 - 1) # optional - sage.libs.pari + sage: fa(5^5 - 1) [4, 11, 71] - sage: prod(_) == 5^5 - 1 # optional - sage.libs.pari + sage: prod(_) == 5^5 - 1 True - sage: fa(2^4 + 1) # optional - sage.libs.pari + sage: fa(2^4 + 1) [17] - sage: fa((6^2*3)^3 + 1) # optional - sage.libs.pari + sage: fa((6^2*3)^3 + 1) [109, 91, 127] TESTS:: - sage: for n in [2,3,5,6,30,31,33]: # optional - sage.libs.pari + sage: for n in [2,3,5,6,30,31,33]: # needs sage.libs.pari ....: for m in [8,96,109201283]: ....: s = -1 if n % 4 == 1 else 1 ....: y = (m^2*n)^n + s diff --git a/src/sage/rings/factorint_flint.pyx b/src/sage/rings/factorint_flint.pyx index 44d8c3ebd4a..7e08edafa97 100644 --- a/src/sage/rings/factorint_flint.pyx +++ b/src/sage/rings/factorint_flint.pyx @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.libs.flint +# sage.doctest: needs sage.libs.flint r""" Integer factorization using FLINT diff --git a/src/sage/rings/factorint_pari.pyx b/src/sage/rings/factorint_pari.pyx index b94682d0deb..8e5ed7c619e 100644 --- a/src/sage/rings/factorint_pari.pyx +++ b/src/sage/rings/factorint_pari.pyx @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.libs.pari +# sage.doctest: needs sage.libs.pari r""" Integer factorization using PARI diff --git a/src/sage/rings/fast_arith.pyx b/src/sage/rings/fast_arith.pyx index 06ef980c8be..bdb5884668e 100644 --- a/src/sage/rings/fast_arith.pyx +++ b/src/sage/rings/fast_arith.pyx @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.libs.pari +# sage.doctest: needs sage.libs.pari """ Basic arithmetic with C integers """ diff --git a/src/sage/rings/finite_rings/conway_polynomials.py b/src/sage/rings/finite_rings/conway_polynomials.py index 35604cbcd07..02779f49bca 100644 --- a/src/sage/rings/finite_rings/conway_polynomials.py +++ b/src/sage/rings/finite_rings/conway_polynomials.py @@ -471,7 +471,7 @@ def find_leveller(qindex, level, x, xleveled, searched, i): searched[i] = True crt_possibles = [] for j in range(1,len(qlist)): - if i==j: + if i == j: continue if crt[(i,j)][qindex][1] >= level: if xleveled[j]: @@ -487,7 +487,7 @@ def find_leveller(qindex, level, x, xleveled, searched, i): def propagate_levelling(qindex, level, x, xleveled, i): for j in range(1, len(qlist)): - if i==j: + if i == j: continue if not xleveled[j] and crt[(i,j)][qindex][1] >= level: newxj = x[i][0] + crt[(i,j)][qindex][0] diff --git a/src/sage/rings/finite_rings/finite_field_givaro.py b/src/sage/rings/finite_rings/finite_field_givaro.py index 0a0aa9a8d67..2dd96beeb34 100644 --- a/src/sage/rings/finite_rings/finite_field_givaro.py +++ b/src/sage/rings/finite_rings/finite_field_givaro.py @@ -510,7 +510,7 @@ def _pari_modulus(self): Mod(1, 3)*a^4 + Mod(2, 3)*a^3 + Mod(2, 3) """ f = pari(str(self.modulus())) - return f.subst('x', 'a') * pari("Mod(1,%s)"%self.characteristic()) + return f.subst('x', 'a') * pari("Mod(1,%s)" % self.characteristic()) def __iter__(self): """ diff --git a/src/sage/rings/finite_rings/finite_field_ntl_gf2e.py b/src/sage/rings/finite_rings/finite_field_ntl_gf2e.py index 17161467f12..654f7a2b54b 100644 --- a/src/sage/rings/finite_rings/finite_field_ntl_gf2e.py +++ b/src/sage/rings/finite_rings/finite_field_ntl_gf2e.py @@ -305,4 +305,4 @@ def _pari_modulus(self): Mod(1, 2)*a^16 + Mod(1, 2)*a^5 + Mod(1, 2)*a^3 + Mod(1, 2)*a^2 + Mod(1, 2) """ f = pari(str(self.modulus())) - return f.subst('x', 'a') * pari("Mod(1,%s)"%self.characteristic()) + return f.subst('x', 'a') * pari("Mod(1,%s)" % self.characteristic()) diff --git a/src/sage/rings/finite_rings/homset.py b/src/sage/rings/finite_rings/homset.py index dfce6a12f1a..f9d523199ec 100644 --- a/src/sage/rings/finite_rings/homset.py +++ b/src/sage/rings/finite_rings/homset.py @@ -153,9 +153,9 @@ def _repr_(self): D = self.domain() C = self.codomain() if C == D: - return "Automorphism group of %s"%D + return "Automorphism group of %s" % D else: - return "Set of field embeddings from %s to %s"%(D, C) + return "Set of field embeddings from %s to %s" % (D, C) def is_aut(self): """ diff --git a/src/sage/rings/finite_rings/integer_mod.pyx b/src/sage/rings/finite_rings/integer_mod.pyx index d64ba5af84f..38dd4569c7f 100644 --- a/src/sage/rings/finite_rings/integer_mod.pyx +++ b/src/sage/rings/finite_rings/integer_mod.pyx @@ -70,7 +70,7 @@ TESTS:: from cysignals.signals cimport sig_on, sig_off, sig_check -from cpython.int cimport * +from cpython.long cimport * from cpython.list cimport * from cpython.ref cimport * @@ -2793,8 +2793,8 @@ cdef class IntegerMod_int(IntegerMod_abstract): cdef long long_exp cdef int_fast32_t res cdef mpz_t res_mpz - if type(exp) is int and -100000 < PyInt_AS_LONG(exp) < 100000: - long_exp = PyInt_AS_LONG(exp) + if type(exp) is int and -100000 < PyLong_AsLong(exp) < 100000: + long_exp = PyLong_AsLong(exp) elif type(exp) is Integer and mpz_cmpabs_ui((exp).value, 100000) == -1: long_exp = mpz_get_si((exp).value) else: @@ -3624,8 +3624,8 @@ cdef class IntegerMod_int64(IntegerMod_abstract): cdef long long_exp cdef int_fast64_t res cdef mpz_t res_mpz - if type(exp) is int and -100000 < PyInt_AS_LONG(exp) < 100000: - long_exp = PyInt_AS_LONG(exp) + if type(exp) is int and -100000 < PyLong_AsLong(exp) < 100000: + long_exp = PyLong_AsLong(exp) elif type(exp) is Integer and mpz_cmpabs_ui((exp).value, 100000) == -1: long_exp = mpz_get_si((exp).value) else: diff --git a/src/sage/rings/finite_rings/integer_mod_ring.py b/src/sage/rings/finite_rings/integer_mod_ring.py index 20a876f4192..b615d3a8c1a 100644 --- a/src/sage/rings/finite_rings/integer_mod_ring.py +++ b/src/sage/rings/finite_rings/integer_mod_ring.py @@ -1600,7 +1600,7 @@ def _gap_init_(self): sage: R = Integers(12345678900) sage: R Ring of integers modulo 12345678900 - sage: gap(R) # indirect doctest # needs sage.libs.gap + sage: gap(R) # indirect doctest # needs sage.libs.gap (Integers mod 12345678900) """ return 'ZmodnZ({})'.format(self.order()) diff --git a/src/sage/rings/fraction_field.py b/src/sage/rings/fraction_field.py index 1aff655bed8..5d298720a90 100644 --- a/src/sage/rings/fraction_field.py +++ b/src/sage/rings/fraction_field.py @@ -25,6 +25,7 @@ The GCD is not taken (since it doesn't converge sometimes) in the inexact case:: + sage: # needs sage.rings.real_mpfr sage: Z. = CC[] sage: I = CC.gen() sage: (1+I+z)/(z+0.1*I) @@ -263,12 +264,13 @@ def _coerce_map_from_(self, S): We demonstrate that :trac:`7958` is resolved in the case of number fields:: + sage: # needs sage.rings.number_field sage: _. = ZZ[] - sage: K. = NumberField(x^5 - 3*x^4 + 2424*x^3 + 2*x - 232) # optional - sage.rings.number_field - sage: R = K.ring_of_integers() # optional - sage.rings.number_field - sage: S. = R[] # optional - sage.rings.number_field - sage: F = FractionField(S) # optional - sage.rings.number_field - sage: F(1/a) # optional - sage.rings.number_field + sage: K. = NumberField(x^5 - 3*x^4 + 2424*x^3 + 2*x - 232) + sage: R = K.ring_of_integers() + sage: S. = R[] + sage: F = FractionField(S) + sage: F(1/a) (a^4 - 3*a^3 + 2424*a^2 + 2)/232 Some corner cases have been known to fail in the past (:trac:`5917`):: @@ -296,6 +298,7 @@ def _coerce_map_from_(self, S): sage: 1/(R.gen() + 1) 1/(x + 1) + sage: # needs sage.modules sage: R = LaurentPolynomialRing(ZZ, 'x,y') sage: FF = FractionField(PolynomialRing(ZZ, 'x,y')) sage: prod(R.gens()) + prod(FF.gens()) @@ -306,13 +309,14 @@ def _coerce_map_from_(self, S): Test for :trac:`31320`:: sage: FQt = Frac(QQ['t']) - sage: LCt = LaurentPolynomialRing(CC,'t') - sage: coercion_model.common_parent(FQt, LCt) + sage: LCt = LaurentPolynomialRing(CC,'t') # needs sage.rings.real_mpfr + sage: coercion_model.common_parent(FQt, LCt) # needs sage.rings.real_mpfr Fraction Field of Univariate Polynomial Ring in t over Complex Field with 53 bits of precision Coercion from a localization:: + sage: # needs sage.libs.pari sage: R. = ZZ[] sage: L = Localization(R, (x**2 + 1,7)) sage: F = L.fraction_field() @@ -393,12 +397,13 @@ def _number_field_to_frac_of_ring_of_integers(self, x): We demonstrate that :trac:`7958` is resolved in the case of number fields:: + sage: # needs sage.rings.number_field sage: _. = ZZ[] - sage: K. = NumberField(x^5 - 3*x^4 + 2424*x^3 + 2*x - 232) # optional - sage.rings.number_field - sage: R = K.ring_of_integers() # optional - sage.rings.number_field - sage: S. = R[] # optional - sage.rings.number_field - sage: F = FractionField(S) # indirect doctest # optional - sage.rings.number_field - sage: F(1/a) # optional - sage.rings.number_field + sage: K. = NumberField(x^5 - 3*x^4 + 2424*x^3 + 2*x - 232) + sage: R = K.ring_of_integers() + sage: S. = R[] + sage: F = FractionField(S) # indirect doctest + sage: F(1/a) (a^4 - 3*a^3 + 2424*a^2 + 2)/232 """ f = x.polynomial() # Polynomial over QQ @@ -459,7 +464,7 @@ def characteristic(self): Integer Ring sage: R = Frac(ZZ['t']); R.characteristic() 0 - sage: R = Frac(GF(5)['w']); R.characteristic() # optional - sage.rings.finite_rings + sage: R = Frac(GF(5)['w']); R.characteristic() 5 """ return self._R.characteristic() @@ -481,7 +486,7 @@ def _latex_(self): EXAMPLES:: - sage: latex(Frac(GF(7)['x,y,z'])) # indirect doctest # optional - sage.rings.finite_rings + sage: latex(Frac(GF(7)['x,y,z'])) # indirect doctest \mathrm{Frac}(\Bold{F}_{7}[x, y, z]) """ return "\\mathrm{Frac}(%s)" % latex.latex(self._R) @@ -494,7 +499,7 @@ def _magma_init_(self, magma): sage: QQ['x'].fraction_field()._magma_init_(magma) # optional - magma 'SageCreateWithNames(FieldOfFractions(SageCreateWithNames(PolynomialRing(_sage_ref...),["x"])),["x"])' - sage: GF(9,'a')['x,y,z'].fraction_field()._magma_init_(magma) # optional - magma # optional - sage.rings.finite_rings + sage: GF(9,'a')['x,y,z'].fraction_field()._magma_init_(magma) # optional - magma, needs sage.rings.finite_rings 'SageCreateWithNames(FieldOfFractions(SageCreateWithNames(PolynomialRing(_sage_ref...,3,"grevlex"),["x","y","z"])),["x","y","z"])' ``_magma_init_`` gets called implicitly below:: @@ -538,7 +543,7 @@ def is_exact(self): sage: Frac(ZZ['x']).is_exact() True - sage: Frac(CDF['x']).is_exact() + sage: Frac(CDF['x']).is_exact() # needs sage.rings.complex_double False """ return self.ring().is_exact() @@ -571,17 +576,17 @@ def _element_constructor_(self, x, y=None, coerce=True): The next example failed before :trac:`4376`:: - sage: K(pari((x + 1)/(x^2 + x + 1))) # optional - sage.libs.pari + sage: K(pari((x + 1)/(x^2 + x + 1))) # needs sage.libs.pari (x + 1)/(x^2 + x + 1) These examples failed before :trac:`11368`:: sage: R. = PolynomialRing(QQ) sage: S = R.fraction_field() - sage: S(pari((x + y)/y)) # optional - sage.libs.pari + sage: S(pari((x + y)/y)) # needs sage.libs.pari (x + y)/y - sage: S(pari(x + y + 1/z)) # optional - sage.libs.pari + sage: S(pari(x + y + 1/z)) # needs sage.libs.pari (x*z + y*z + 1)/z This example failed before :trac:`23664`:: @@ -607,19 +612,19 @@ def _element_constructor_(self, x, y=None, coerce=True): sage: A. = Frac(PolynomialRing(QQ,'a,c')) sage: B. = PolynomialRing(A,'d,e') sage: R. = PolynomialRing(B,'x') - sage: (a*d*x^2+a+e+1).resultant(-4*c^2*x+1) + sage: (a*d*x^2+a+e+1).resultant(-4*c^2*x+1) # needs sage.libs.pari a*d + (16*c^4)*e + (16*a*c^4 + 16*c^4) Check that :trac:`24539` is fixed:: sage: tau = polygen(QQ, 'tau') - sage: PolynomialRing(CyclotomicField(2), 'z').fraction_field()(tau/(1+tau)) # optional - sage.rings.number_field + sage: PolynomialRing(CyclotomicField(2), 'z').fraction_field()(tau/(1+tau)) # needs sage.rings.number_field z/(z + 1) Check that :trac:`26150` is fixed:: - sage: z = SR.var('z') # optional - sage.symbolic - sage: CyclotomicField(2)['z'].fraction_field()(2*(4*z + 5)/((z + 1)*(z - 1)^4)) # optional - sage.rings.number_field sage.symbolic + sage: z = SR.var('z') # needs sage.symbolic + sage: CyclotomicField(2)['z'].fraction_field()(2*(4*z + 5)/((z + 1)*(z - 1)^4)) # needs sage.rings.number_field sage.symbolic (8*z + 10)/(z^5 - 3*z^4 + 2*z^3 + 2*z^2 - 3*z + 1) :: @@ -731,12 +736,12 @@ def construction(self): sage: Frac(ZZ['x']).construction() (FractionField, Univariate Polynomial Ring in x over Integer Ring) - sage: K = Frac(GF(3)['t']) # optional - sage.rings.finite_rings - sage: f, R = K.construction() # optional - sage.rings.finite_rings - sage: f(R) # optional - sage.rings.finite_rings + sage: K = Frac(GF(3)['t']) + sage: f, R = K.construction() + sage: f(R) Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 3 - sage: f(R) == K # optional - sage.rings.finite_rings + sage: f(R) == K True """ from sage.categories.pushout import FractionField @@ -986,8 +991,8 @@ def ring_of_integers(self): EXAMPLES:: - sage: K = FractionField(GF(5)['t']) # optional - sage.rings.finite_rings - sage: K.ring_of_integers() # optional - sage.rings.finite_rings + sage: K = FractionField(GF(5)['t']) + sage: K.ring_of_integers() Univariate Polynomial Ring in t over Finite Field of size 5 """ return self._R @@ -998,8 +1003,8 @@ def maximal_order(self): EXAMPLES:: - sage: K = FractionField(GF(5)['t']) # optional - sage.rings.finite_rings - sage: K.maximal_order() # optional - sage.rings.finite_rings + sage: K = FractionField(GF(5)['t']) + sage: K.maximal_order() Univariate Polynomial Ring in t over Finite Field of size 5 """ return self._R @@ -1010,8 +1015,8 @@ def class_number(self): EXAMPLES:: - sage: R. = GF(5)[]; K = R.fraction_field() # optional - sage.rings.finite_rings - sage: K.class_number() # optional - sage.rings.finite_rings + sage: R. = GF(5)[]; K = R.fraction_field() + sage: K.class_number() 1 """ return 1 @@ -1022,11 +1027,12 @@ def _factor_univariate_polynomial(self, f): EXAMPLES:: - sage: k. = GF(9) # optional - sage.rings.finite_rings - sage: K = k['t'].fraction_field() # optional - sage.rings.finite_rings - sage: R. = K[] # optional - sage.rings.finite_rings - sage: f = x^3 + a # optional - sage.rings.finite_rings - sage: f.factor() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF(9) + sage: K = k['t'].fraction_field() + sage: R. = K[] + sage: f = x^3 + a + sage: f.factor() (x + 2*a + 1)^3 """ @@ -1041,9 +1047,9 @@ def function_field(self): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: K = R.fraction_field() # optional - sage.rings.finite_rings - sage: K.function_field() # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: K = R.fraction_field() + sage: K.function_field() Rational function field in t over Finite Field of size 5 .. SEEALSO:: @@ -1060,15 +1066,16 @@ def _coerce_map_from_(self, R): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: K = R.fraction_field() # optional - sage.rings.finite_rings - sage: L = K.function_field() # optional - sage.rings.finite_rings - sage: f = K.coerce_map_from(L); f # indirect doctest # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: K = R.fraction_field() + sage: L = K.function_field() + sage: f = K.coerce_map_from(L); f # indirect doctest Isomorphism: From: Rational function field in t over Finite Field of size 5 To: Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5 - sage: f(~L.gen()) # optional - sage.rings.finite_rings + sage: f(~L.gen()) 1/t """ @@ -1166,12 +1173,12 @@ def _richcmp_(self, other, op): sage: R. = QQ[] sage: f = R.fraction_field().coerce_map_from(R) - sage: S. = GF(2)[] # optional - sage.rings.finite_rings - sage: g = S.fraction_field().coerce_map_from(S) # optional - sage.rings.finite_rings + sage: S. = GF(2)[] + sage: g = S.fraction_field().coerce_map_from(S) - sage: f == g # indirect doctest # optional - sage.rings.finite_rings + sage: f == g # indirect doctest False - sage: f == f # optional - sage.rings.finite_rings + sage: f == f True """ @@ -1236,19 +1243,20 @@ def _call_(self, x, check=True): Over inexact rings, we have to take the precision of the denominators into account:: - sage: R = ZpCR(2) # optional - sage.rings.padics - sage: S. = R[] # optional - sage.rings.padics - sage: f = x/S(R(3, absprec=2)) # optional - sage.rings.padics - sage: S(f) # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: R = ZpCR(2) + sage: S. = R[] + sage: f = x/S(R(3, absprec=2)) + sage: S(f) (1 + 2 + O(2^2))*x Test for Localization:: sage: R. = ZZ[] - sage: L = Localization(R, x**2 + 2*x + 1) # optional - sage.libs.pari - sage: 1/(x + 1) in L # indirect doctest # optional - sage.libs.pari + sage: L = Localization(R, x**2 + 2*x + 1) # needs sage.libs.pari + sage: 1/(x + 1) in L # indirect doctest # needs sage.libs.pari True - sage: 1/(x + 2) in L # indirect doctest # optional - sage.libs.pari + sage: 1/(x + 2) in L # indirect doctest # needs sage.libs.pari False """ codom = self.codomain() @@ -1298,12 +1306,12 @@ def _richcmp_(self, other, op): sage: R. = QQ[] sage: f = R.fraction_field().coerce_map_from(R).section() - sage: S. = GF(2)[] # optional - sage.rings.finite_rings - sage: g = S.fraction_field().coerce_map_from(S).section() # optional - sage.rings.finite_rings + sage: S. = GF(2)[] + sage: g = S.fraction_field().coerce_map_from(S).section() - sage: f == g # indirect doctest # optional - sage.rings.finite_rings + sage: f == g # indirect doctest False - sage: f == f # optional - sage.rings.finite_rings + sage: f == f True """ diff --git a/src/sage/rings/fraction_field_element.pyx b/src/sage/rings/fraction_field_element.pyx index 75e47af1299..2134c2fa07b 100644 --- a/src/sage/rings/fraction_field_element.pyx +++ b/src/sage/rings/fraction_field_element.pyx @@ -64,9 +64,9 @@ cdef class FractionFieldElement(FieldElement): Test if :trac:`5451` is fixed:: - sage: A = FiniteField(9,'theta')['t'] # optional - sage.rings.finite_rings - sage: K. = FractionField(A) # optional - sage.rings.finite_rings - sage: f = 2/(t^2 + 2*t); g = t^9/(t^18 + t^10 + t^2); f + g # optional - sage.rings.finite_rings + sage: A = FiniteField(9,'theta')['t'] # needs sage.rings.finite_rings + sage: K. = FractionField(A) # needs sage.rings.finite_rings + sage: f = 2/(t^2 + 2*t); g = t^9/(t^18 + t^10 + t^2); f + g # needs sage.rings.finite_rings (2*t^15 + 2*t^14 + 2*t^13 + 2*t^12 + 2*t^11 + 2*t^10 + 2*t^9 + t^7 + t^6 + t^5 + t^4 + t^3 + t^2 + t + 1)/(t^17 + t^9 + t) Test if :trac:`8671` is fixed:: @@ -99,8 +99,8 @@ cdef class FractionFieldElement(FieldElement): sage: f.numerator() 'hi' - sage: x = var('x') # optional - sage.symbolic - sage: K((x + 1)/(x^2 + x + 1)) # optional - sage.symbolic + sage: x = var('x') # needs sage.symbolic + sage: K((x + 1)/(x^2 + x + 1)) (x + 1)/(x^2 + x + 1) sage: K(355/113) 355/113 @@ -127,31 +127,32 @@ cdef class FractionFieldElement(FieldElement): sage: F = ZZ['x,y'].fraction_field() sage: x,y = F.gens() - sage: K = GF(7)['a,b'].fraction_field() # optional - sage.rings.finite_rings - sage: a,b = K.gens() # optional - sage.rings.finite_rings + sage: K = GF(7)['a,b'].fraction_field() + sage: a,b = K.gens() :: - sage: phi = F.hom([a + b, a*b], K) # optional - sage.rings.finite_rings - sage: phi(x+y) # indirect doctest # optional - sage.rings.finite_rings + sage: phi = F.hom([a + b, a*b], K) + sage: phi(x+y) # indirect doctest a*b + a + b :: - sage: (x^2/y)._im_gens_(K, [a + b, a*b]) # optional - sage.rings.finite_rings + sage: (x^2/y)._im_gens_(K, [a + b, a*b]) (a^2 + 2*a*b + b^2)/(a*b) - sage: (x^2/y)._im_gens_(K, [a, a*b]) # optional - sage.rings.finite_rings + sage: (x^2/y)._im_gens_(K, [a, a*b]) a/b :: + sage: # needs sage.rings.number_field sage: Zx. = ZZ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: cc = K.hom([-i]) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: F = R.fraction_field() # optional - sage.rings.number_field - sage: phi = F.hom([F(b), F(a)], base_map=cc) # optional - sage.rings.number_field - sage: phi(i/a) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: cc = K.hom([-i]) + sage: R. = K[] + sage: F = R.fraction_field() + sage: phi = F.hom([F(b), F(a)], base_map=cc) + sage: phi(i/a) ((-i))/b """ nnum = codomain.coerce(self._numerator._im_gens_(codomain, im_gens, base_map=base_map)) @@ -173,10 +174,10 @@ cdef class FractionFieldElement(FieldElement): EXAMPLES:: - sage: R. = RealField(10)[] - sage: f = (x^2+2*x+1)/(x+1); f + sage: R. = RealField(10)[] # needs sage.rings.real_mpfr + sage: f = (x^2+2*x+1)/(x+1); f # needs sage.rings.real_mpfr (x^2 + 2.0*x + 1.0)/(x + 1.0) - sage: f.reduce(); f + sage: f.reduce(); f # needs sage.rings.real_mpfr x + 1.0 TESTS: @@ -393,10 +394,10 @@ cdef class FractionFieldElement(FieldElement): Check that :trac:`25199` is fixed:: - sage: R. = QQbar[] # optional - sage.rings.number_field - sage: hash(R.0) == hash(FractionField(R).0) # optional - sage.rings.number_field + sage: R. = QQbar[] # needs sage.rings.number_field + sage: hash(R.0) == hash(FractionField(R).0) True - sage: ((x+1)/(x^2+1)).subs({x: 1}) # optional - sage.rings.number_field + sage: ((x+1)/(x^2+1)).subs({x: 1}) 1 """ if self._denominator.is_one(): @@ -568,13 +569,13 @@ cdef class FractionFieldElement(FieldElement): (x + y)/(x*y) sage: 1/x + 1/(x*y) (y + 1)/(x*y) - sage: Frac(CDF['x']).gen() + 3 + sage: Frac(CDF['x']).gen() + 3 # needs sage.rings.complex_double x + 3.0 Subtraction is implemented by adding the negative:: - sage: K. = Frac(GF(7)['t']) # optional - sage.rings.finite_rings - sage: t - 1/t # indirect doctest # optional - sage.rings.finite_rings + sage: K. = Frac(GF(7)['t']) + sage: t - 1/t # indirect doctest (t^2 + 6)/t """ rnum = self._numerator @@ -646,10 +647,11 @@ cdef class FractionFieldElement(FieldElement): EXAMPLES:: - sage: K. = Frac(GF(7)['t']) # optional - sage.rings.finite_rings - sage: a = t/(1+t) # optional - sage.rings.finite_rings - sage: b = 3/t # optional - sage.rings.finite_rings - sage: a * b # indirect doctest # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = Frac(GF(7)['t']) + sage: a = t/(1+t) + sage: b = 3/t + sage: a * b # indirect doctest 3/(t + 1) """ rnum = self._numerator @@ -764,8 +766,8 @@ cdef class FractionFieldElement(FieldElement): """ EXAMPLES:: - sage: K. = Frac(I.parent()['x,y']) - sage: complex(x/(I*x) + (I*y)/y) + sage: K. = Frac(I.parent()['x,y']) # needs sage.symbolic + sage: complex(x/(I*x) + (I*y)/y) # needs sage.symbolic 0j """ return complex(self._numerator) / complex(self._denominator) @@ -775,7 +777,7 @@ cdef class FractionFieldElement(FieldElement): TESTS:: sage: K = Frac(ZZ['x']) - sage: QQ(K(x) / K(2*x)) # optional - sage.symbolic + sage: QQ(K(x) / K(2*x)) # needs sage.symbolic 1/2 """ return self._conversion(QQ) @@ -811,15 +813,16 @@ cdef class FractionFieldElement(FieldElement): 3/2 sage: x = polygen(QQ) - sage: A. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: A((x+3) / (2*x - 1)) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: A((x+3) / (2*x - 1)) # needs sage.rings.number_field 14/15*u^2 + 7/15*u + 11/15 - sage: B = A['y'].fraction_field() # optional - sage.rings.number_field - sage: A(B(u)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: B = A['y'].fraction_field() + sage: A(B(u)) u - sage: C = A['x,y'].fraction_field() # optional - sage.rings.number_field - sage: A(C(u)) # optional - sage.rings.number_field + sage: C = A['x,y'].fraction_field() + sage: A(C(u)) u """ if self._denominator.is_one(): @@ -857,15 +860,15 @@ cdef class FractionFieldElement(FieldElement): sage: x,y = FR.gens() sage: a = x^2; a x^2 - sage: type(a.numerator()) + sage: type(a.numerator()) # needs sage.libs.singular - sage: type(a.denominator()) + sage: type(a.denominator()) # needs sage.libs.singular sage: a = x^(-2); a 1/x^2 - sage: type(a.numerator()) + sage: type(a.numerator()) # needs sage.libs.singular - sage: type(a.denominator()) + sage: type(a.denominator()) # needs sage.libs.singular sage: x^0 1 @@ -897,10 +900,10 @@ cdef class FractionFieldElement(FieldElement): """ EXAMPLES:: - sage: K. = Frac(GF(5)['t']) # optional - sage.rings.finite_rings - sage: f = (t^2+t)/(t+2); f # optional - sage.rings.finite_rings + sage: K. = Frac(GF(5)['t']) + sage: f = (t^2+t)/(t+2); f (t^2 + t)/(t + 2) - sage: -f # optional - sage.rings.finite_rings + sage: -f (4*t^2 + 4*t)/(t + 2) """ return self.__class__(self._parent, @@ -921,9 +924,9 @@ cdef class FractionFieldElement(FieldElement): """ EXAMPLES:: - sage: K. = Frac(GF(7)['t']) # optional - sage.rings.finite_rings - sage: f = (t^2+5)/(t-1) # optional - sage.rings.finite_rings - sage: ~f # optional - sage.rings.finite_rings + sage: K. = Frac(GF(7)['t']) + sage: f = (t^2+5)/(t-1) + sage: ~f (t + 6)/(t^2 + 5) """ if self.is_zero(): @@ -935,12 +938,13 @@ cdef class FractionFieldElement(FieldElement): """ EXAMPLES:: - sage: K. = Frac(GF(7)['t']) # optional - sage.rings.finite_rings - sage: t/t == 1 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = Frac(GF(7)['t']) + sage: t/t == 1 True - sage: t + 1/t == (t^2+1)/t # optional - sage.rings.finite_rings + sage: t + 1/t == (t^2+1)/t True - sage: t == t/5 # optional - sage.rings.finite_rings + sage: t == t/5 False :: @@ -1039,9 +1043,9 @@ cdef class FractionFieldElement(FieldElement): sage: x,y = F.gens() sage: elt = (2*x + 2*y) / (3*x - 3*y); elt (2*x + 2*y)/(3*x - 3*y) - sage: elt._symbolic_(SR) # optional - sage.symbolic + sage: elt._symbolic_(SR) # needs sage.symbolic 2/3*(x + y)/(x - y) - sage: symbolic_expression(elt) # optional - sage.symbolic + sage: symbolic_expression(elt) # needs sage.symbolic 2/3*(x + y)/(x - y) """ return ring(self._numerator)/ring(self._denominator) @@ -1098,18 +1102,19 @@ cdef class FractionFieldElement(FieldElement): Check that :trac:`25440` has been resolved:: - sage: R. = GF(2)[] # optional - sage.rings.finite_rings - sage: S. = R.fraction_field()[] # optional - sage.rings.finite_rings - sage: (y+1)(R.one()) # optional - sage.rings.finite_rings + sage: R. = GF(2)[] + sage: S. = R.fraction_field()[] + sage: (y+1)(R.one()) 0 Check that inexact elements are treated correctly:: - sage: K = Qp(2, 5) # optional - sage.rings.padics - sage: R. = K[] # optional - sage.rings.padics - sage: L = R.fraction_field() # optional - sage.rings.padics - sage: S. = L[] # optional - sage.rings.padics - sage: y(K(1,1)/x) # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: K = Qp(2, 5) + sage: R. = K[] + sage: L = R.fraction_field() + sage: S. = L[] + sage: y(K(1,1)/x) (1 + O(2))/((1 + O(2))*x) """ if self.numerator().is_one(): @@ -1204,7 +1209,7 @@ cdef class FractionFieldElement_1poly_field(FractionFieldElement): sage: R. = QQ[] sage: h = (t^14 + 2*t^12 - 4*t^11 - 8*t^9 + 6*t^8 + 12*t^6 - 4*t^5 ....: - 8*t^3 + t^2 + 2)/(t^6 + 6*t^5 + 9*t^4 - 2*t^2 - 12*t - 18) - sage: h.support() # optional - sage.libs.pari + sage: h.support() # needs sage.libs.pari [t - 1, t + 3, t^2 + 2, t^2 + t + 1, t^4 - 2] """ L = [fac[0] for fac in self.numerator().factor()] + [fac[0] for fac in self.denominator().factor()] diff --git a/src/sage/rings/function_field/constructor.py b/src/sage/rings/function_field/constructor.py index 31156bc9c6f..071f66ec163 100644 --- a/src/sage/rings/function_field/constructor.py +++ b/src/sage/rings/function_field/constructor.py @@ -86,7 +86,7 @@ def create_key(self, F, names): sage: K. = FunctionField(QQ) # indirect doctest """ if not isinstance(names, tuple): - names=(names,) + names = (names,) return (F, names) def create_object(self, version, key,**extra_args): @@ -112,7 +112,7 @@ def create_object(self, version, key,**extra_args): return RationalFunctionField(key[0], names=key[1]) -FunctionField=FunctionFieldFactory("sage.rings.function_field.constructor.FunctionField") +FunctionField = FunctionFieldFactory("sage.rings.function_field.constructor.FunctionField") class FunctionFieldExtensionFactory(UniqueFactory): @@ -134,7 +134,7 @@ class FunctionFieldExtensionFactory(UniqueFactory): EXAMPLES:: sage: K. = FunctionField(QQ) - sage: R.=K[] + sage: R. = K[] sage: y2 = y*1 sage: y2 is y False @@ -152,27 +152,28 @@ def create_key(self,polynomial,names): sage: K. = FunctionField(QQ) sage: R. = K[] - sage: L. = K.extension(x - y^2) # indirect doctest # needs sage.rings.function_field + sage: L. = K.extension(x - y^2) # indirect doctest # needs sage.rings.function_field TESTS: Verify that :trac:`16530` has been resolved:: + sage: # needs sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] - sage: L. = K.extension(y^2 - x) # needs sage.rings.function_field - sage: R. = L[] # needs sage.rings.function_field - sage: M. = L.extension(z - 1) # needs sage.rings.function_field + sage: L. = K.extension(y^2 - x) + sage: R. = L[] + sage: M. = L.extension(z - 1) sage: R. = K[] - sage: N. = K.extension(z - 1) # needs sage.rings.function_field - sage: M is N # needs sage.rings.function_field + sage: N. = K.extension(z - 1) + sage: M is N False """ if names is None: - names=polynomial.variable_name() + names = polynomial.variable_name() if not isinstance(names,tuple): - names=(names,) + names = (names,) return (polynomial,names,polynomial.base_ring()) def create_object(self,version,key,**extra_args): @@ -184,9 +185,9 @@ def create_object(self,version,key,**extra_args): sage: K. = FunctionField(QQ) sage: R. = K[] - sage: L. = K.extension(x - y^2) # indirect doctest # needs sage.rings.function_field + sage: L. = K.extension(x - y^2) # indirect doctest # needs sage.rings.function_field sage: y2 = y*1 - sage: M. = K.extension(x - y2^2) # indirect doctest # needs sage.rings.function_field + sage: M. = K.extension(x - y2^2) # indirect doctest # needs sage.rings.function_field sage: L is M # needs sage.rings.function_field True """ diff --git a/src/sage/rings/function_field/differential.py b/src/sage/rings/function_field/differential.py index 03b327b1abf..9b6fec9a72d 100644 --- a/src/sage/rings/function_field/differential.py +++ b/src/sage/rings/function_field/differential.py @@ -152,8 +152,8 @@ def _latex_(self): sage: # needs sage.rings.finite_rings sage: K. = FunctionField(GF(4)); _. = K[] sage: L. = K.extension(Y^3 + x + x^3*Y) # needs sage.rings.function_field - sage: w = y.differential() - sage: latex(w) + sage: w = y.differential() # needs sage.rings.function_field + sage: latex(w) # needs sage.rings.function_field \left( x y^{2} + \frac{1}{x} y \right)\, dx """ if self._f.is_zero(): # zero differential diff --git a/src/sage/rings/function_field/divisor.py b/src/sage/rings/function_field/divisor.py index 59f0f7a0cbb..84c837ffb09 100644 --- a/src/sage/rings/function_field/divisor.py +++ b/src/sage/rings/function_field/divisor.py @@ -1023,7 +1023,7 @@ def _repr_(self): sage: F.divisor_group() Divisor group of Function field in y defined by y^2 + 4*x^3 + 4 """ - return "Divisor group of %s"%(self._field,) + return "Divisor group of %s" % (self._field,) def _element_constructor_(self, x): """ diff --git a/src/sage/rings/function_field/function_field.py b/src/sage/rings/function_field/function_field.py index 973d9a8f505..26975773a88 100644 --- a/src/sage/rings/function_field/function_field.py +++ b/src/sage/rings/function_field/function_field.py @@ -129,7 +129,7 @@ sage: TestSuite(L).run(max_runs=8) # long time (25s) # needs sage.rings.function_field sage.rings.number_field sage: TestSuite(M).run(max_runs=8) # long time (35s) # needs sage.rings.finite_rings sage.rings.function_field sage: TestSuite(N).run(max_runs=8, skip='_test_derivation') # long time (15s), needs sage.rings.finite_rings - sage: TestSuite(O).run() + sage: TestSuite(O).run() # needs sage.rings.function_field sage: TestSuite(R).run() # needs sage.rings.finite_rings sage.rings.function_field sage: TestSuite(S).run() # long time (4s) # needs sage.rings.finite_rings sage.rings.function_field @@ -781,7 +781,7 @@ def _convert_map_from_(self, R): sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^3 + x^3 + 4*x + 1) # needs sage.rings.function_field - sage: K(L(x)) # indirect doctest # needs sage.rings.function_field + sage: K(L(x)) # indirect doctest # needs sage.rings.function_field x """ try: diff --git a/src/sage/rings/function_field/function_field_polymod.py b/src/sage/rings/function_field/function_field_polymod.py index cf0dfc439c5..460096c94a1 100644 --- a/src/sage/rings/function_field/function_field_polymod.py +++ b/src/sage/rings/function_field/function_field_polymod.py @@ -280,7 +280,7 @@ def _to_base_field(self, f): K = self.base_field() if f.element().is_constant(): return K(f.element()) - raise ValueError("%r is not an element of the base field"%(f,)) + raise ValueError("%r is not an element of the base field" % (f,)) def _to_constant_base_field(self, f): """ @@ -572,7 +572,7 @@ def _repr_(self): sage: L._repr_() 'Function field in y defined by y^5 - 2*x*y + (-x^4 - 1)/x' """ - return "Function field in %s defined by %s"%(self.variable_name(), self._polynomial) + return "Function field in %s defined by %s" % (self.variable_name(), self._polynomial) def base_field(self): """ diff --git a/src/sage/rings/function_field/function_field_rational.py b/src/sage/rings/function_field/function_field_rational.py index 0332b9ccfed..1b169275da4 100644 --- a/src/sage/rings/function_field/function_field_rational.py +++ b/src/sage/rings/function_field/function_field_rational.py @@ -220,7 +220,7 @@ def _repr_(self): sage: K._repr_() 'Rational function field in t over Rational Field' """ - return "Rational function field in %s over %s"%( + return "Rational function field in %s over %s" % ( self.variable_name(), self._constant_field) def _element_constructor_(self, x): @@ -304,7 +304,7 @@ def _to_constant_base_field(self, f): # When K is not exact, f.denominator() might not be an exact 1, so # we need to divide explicitly to get the correct precision return K(f.numerator()) / K(f.denominator()) - raise ValueError("only constants can be converted into the constant base field but %r is not a constant"%(f,)) + raise ValueError("only constants can be converted into the constant base field but %r is not a constant" % (f,)) def _to_polynomial(self, f): """ @@ -349,7 +349,7 @@ def _to_bivariate_polynomial(self, f): v = f.list() denom = lcm([a.denominator() for a in v]) S = denom.parent() - x,t = S.base_ring()['%s,%s'%(f.parent().variable_name(),self.variable_name())].gens() + x,t = S.base_ring()['%s,%s' % (f.parent().variable_name(),self.variable_name())].gens() phi = S.hom([t]) return sum([phi((denom * v[i]).numerator()) * x**i for i in range(len(v))]), denom diff --git a/src/sage/rings/function_field/maps.py b/src/sage/rings/function_field/maps.py index ead3310d054..85377f1c894 100644 --- a/src/sage/rings/function_field/maps.py +++ b/src/sage/rings/function_field/maps.py @@ -9,17 +9,19 @@ sage: K.hom(1/x) Function Field endomorphism of Rational function field in x over Rational Field Defn: x |--> 1/x - sage: L. = K.extension(y^2 - x) # needs sage.rings.function_field - sage: K.hom(y) # needs sage.rings.function_field + + sage: # needs sage.rings.function_field + sage: L. = K.extension(y^2 - x) + sage: K.hom(y) Function Field morphism: From: Rational function field in x over Rational Field To: Function field in y defined by y^2 - x Defn: x |--> y - sage: L.hom([y,x]) # needs sage.rings.function_field + sage: L.hom([y,x]) Function Field endomorphism of Function field in y defined by y^2 - x Defn: y |--> y x |--> x - sage: L.hom([x,y]) # needs sage.rings.function_field + sage: L.hom([x,y]) Traceback (most recent call last): ... ValueError: invalid morphism @@ -71,10 +73,11 @@ class FunctionFieldVectorSpaceIsomorphism(Morphism): EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldVectorSpaceIsomorphism) # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: isinstance(f, sage.rings.function_field.maps.FunctionFieldVectorSpaceIsomorphism) True """ def _repr_(self) -> str: @@ -83,14 +86,15 @@ def _repr_(self) -> str: EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: f # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: f Isomorphism: From: Vector space of dimension 2 over Rational function field in x over Rational Field To: Function field in y defined by y^2 - x*y + 4*x^3 - sage: t # needs sage.modules sage.rings.function_field + sage: t Isomorphism: From: Function field in y defined by y^2 - x*y + 4*x^3 To: Vector space of dimension 2 over Rational function field in x over Rational Field @@ -106,10 +110,11 @@ def is_injective(self) -> bool: EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: f.is_injective() # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: f.is_injective() True """ return True @@ -120,10 +125,11 @@ def is_surjective(self) -> bool: EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: f.is_surjective() # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: f.is_surjective() True """ return True @@ -143,15 +149,15 @@ def _richcmp_(self, other, op): sage: K = QQ['x'].fraction_field() sage: L = K.function_field() sage: f = K.coerce_map_from(L) + sage: f == f + True - sage: K = QQbar['x'].fraction_field() # needs sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QQbar['x'].fraction_field() sage: L = K.function_field() sage: g = K.coerce_map_from(L) - - sage: f == g # needs sage.rings.number_field + sage: f == g False - sage: f == f - True """ if type(self) is not type(other): @@ -186,9 +192,10 @@ class MapVectorSpaceToFunctionField(FunctionFieldVectorSpaceIsomorphism): EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space(); f # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space(); f Isomorphism: From: Vector space of dimension 2 over Rational function field in x over Rational Field To: Function field in y defined by y^2 - x*y + 4*x^3 @@ -197,9 +204,10 @@ def __init__(self, V, K): """ EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space(); type(f) # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space(); type(f) """ self._V = V @@ -217,20 +225,22 @@ def _call_(self, v): EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ) sage: R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: f(x*V.0 + (1/x^3)*V.1) # indirect doctest # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: f(x*V.0 + (1/x^3)*V.1) # indirect doctest 1/x^3*y + x TESTS: Test that this map is a bijection for some random inputs:: - sage: R. = L[] # needs sage.rings.function_field - sage: M. = L.extension(z^3 - y - x) # needs sage.rings.function_field - sage: for F in [K, L, M]: # needs sage.modules sage.rings.function_field + sage: # needs sage.modules sage.rings.function_field + sage: R. = L[] + sage: M. = L.extension(z^3 - y - x) + sage: for F in [K, L, M]: ....: for base in F._intermediate_fields(K): ....: V, f, t = F.vector_space(base) ....: for i in range(100): @@ -261,10 +271,11 @@ def domain(self): EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: f.domain() # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: f.domain() Vector space of dimension 2 over Rational function field in x over Rational Field """ return self._V @@ -275,10 +286,11 @@ def codomain(self): EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: f.codomain() # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: f.codomain() Function field in y defined by y^2 - x*y + 4*x^3 """ return self._K @@ -290,9 +302,10 @@ class MapFunctionFieldToVectorSpace(FunctionFieldVectorSpaceIsomorphism): EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space(); t # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space(); t Isomorphism: From: Function field in y defined by y^2 - x*y + 4*x^3 To: Vector space of dimension 2 over Rational function field in x over Rational Field @@ -309,10 +322,11 @@ def __init__(self, K, V): EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: TestSuite(t).run(skip="_test_category") # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: TestSuite(t).run(skip="_test_category") """ self._V = V self._K = K @@ -326,19 +340,21 @@ def _call_(self, x): EXAMPLES:: + sage: # needs sage.modules sage.rings.function_field sage: K. = FunctionField(QQ); R. = K[] - sage: L. = K.extension(y^2 - x*y + 4*x^3) # needs sage.rings.function_field - sage: V, f, t = L.vector_space() # needs sage.modules sage.rings.function_field - sage: t(x + (1/x^3)*y) # indirect doctest # needs sage.modules sage.rings.function_field + sage: L. = K.extension(y^2 - x*y + 4*x^3) + sage: V, f, t = L.vector_space() + sage: t(x + (1/x^3)*y) # indirect doctest (x, 1/x^3) TESTS: Test that this map is a bijection for some random inputs:: - sage: R. = L[] # needs sage.rings.function_field - sage: M. = L.extension(z^3 - y - x) # needs sage.rings.function_field - sage: for F in [K, L, M]: # needs sage.modules sage.rings.function_field + sage: # needs sage.modules sage.rings.function_field + sage: R. = L[] + sage: M. = L.extension(z^3 - y - x) + sage: for F in [K, L, M]: ....: for base in F._intermediate_fields(K): ....: V, f, t = F.vector_space(base) ....: for i in range(100): @@ -391,11 +407,11 @@ def _repr_type(self) -> str: EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(7)); R. = K[] - sage: L. = K.extension(y^3 + 6*x^3 + x) # needs sage.rings.function_field - sage: f = L.hom(y*2) # needs sage.rings.function_field - sage: f._repr_type() # needs sage.rings.function_field + sage: L. = K.extension(y^3 + 6*x^3 + x) + sage: f = L.hom(y*2) + sage: f._repr_type() 'Function Field' """ return "Function Field" @@ -406,11 +422,11 @@ def _repr_defn(self) -> str: EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(7)); R. = K[] - sage: L. = K.extension(y^3 + 6*x^3 + x) # needs sage.rings.function_field - sage: f = L.hom(y*2) # needs sage.rings.function_field - sage: f._repr_defn() # needs sage.rings.function_field + sage: L. = K.extension(y^3 + 6*x^3 + x) + sage: f = L.hom(y*2) + sage: f._repr_defn() 'y |--> 2*y' """ a = '%s |--> %s' % (self.domain().variable_name(), self._im_gen) @@ -425,15 +441,15 @@ class FunctionFieldMorphism_polymod(FunctionFieldMorphism): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(7)); R. = K[] - sage: L. = K.extension(y^3 + 6*x^3 + x) # needs sage.rings.function_field - sage: f = L.hom(y*2); f # needs sage.rings.function_field + sage: L. = K.extension(y^3 + 6*x^3 + x) + sage: f = L.hom(y*2); f Function Field endomorphism of Function field in y defined by y^3 + 6*x^3 + x Defn: y |--> 2*y - sage: factor(L.polynomial()) # needs sage.rings.function_field + sage: factor(L.polynomial()) y^3 + 6*x^3 + x - sage: f(y).charpoly('y') # needs sage.rings.function_field + sage: f(y).charpoly('y') y^3 + 6*x^3 + x """ def __init__(self, parent, im_gen, base_morphism): @@ -442,11 +458,11 @@ def __init__(self, parent, im_gen, base_morphism): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(7)); R. = K[] - sage: L. = K.extension(y^3 + 6*x^3 + x) # needs sage.rings.function_field - sage: f = L.hom(y*2) # needs sage.rings.function_field - sage: TestSuite(f).run(skip="_test_category") # needs sage.rings.function_field + sage: L. = K.extension(y^3 + 6*x^3 + x) + sage: f = L.hom(y*2) + sage: TestSuite(f).run(skip="_test_category") """ FunctionFieldMorphism.__init__(self, parent, im_gen, base_morphism) # Verify that the morphism is valid: @@ -462,12 +478,12 @@ def _call_(self, x): """ EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(7)); R. = K[] - sage: L. = K.extension(y^3 + 6*x^3 + x); f = L.hom(y*2) # needs sage.rings.function_field - sage: f(y/x + x^2/(x+1)) # indirect doctest # needs sage.rings.function_field + sage: L. = K.extension(y^3 + 6*x^3 + x); f = L.hom(y*2) + sage: f(y/x + x^2/(x+1)) # indirect doctest 2/x*y + x^2/(x + 1) - sage: f(y) # needs sage.rings.function_field + sage: f(y) 2*y """ v = x.list() @@ -503,7 +519,7 @@ def _call_(self, x): sage: f = K.hom(1/x); f Function Field endomorphism of Rational function field in x over Finite Field of size 7 Defn: x |--> 1/x - sage: f(x+1) # indirect doctest + sage: f(x + 1) # indirect doctest (x + 1)/x sage: 1/x + 1 (x + 1)/x @@ -569,7 +585,7 @@ def _repr_type(self) -> str: EXAMPLES:: sage: K. = FunctionField(QQ) - sage: QQ.convert_map_from(K) # indirect doctest + sage: QQ.convert_map_from(K) # indirect doctest Conversion map: From: Rational function field in x over Rational Field To: Rational Field @@ -724,23 +740,23 @@ class FunctionFieldCompletion(Map): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: m = L.completion(p) # needs sage.rings.function_field - sage: m # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: m = L.completion(p) + sage: m Completion map: From: Function field in y defined by y^2 + y + (x^2 + 1)/x To: Laurent Series Ring in s over Finite Field of size 2 - sage: m(x) # needs sage.rings.function_field + sage: m(x) s^2 + s^3 + s^4 + s^5 + s^7 + s^8 + s^9 + s^10 + s^12 + s^13 + s^15 + s^16 + s^17 + s^19 + O(s^22) - sage: m(y) # needs sage.rings.function_field + sage: m(y) s^-1 + 1 + s^3 + s^5 + s^7 + s^9 + s^13 + s^15 + s^17 + O(s^19) - sage: m(x*y) == m(x) * m(y) # needs sage.rings.function_field + sage: m(x*y) == m(x) * m(y) True - sage: m(x+y) == m(x) + m(y) # needs sage.rings.function_field + sage: m(x+y) == m(x) + m(y) True The variable name of the series can be supplied. If the place is not @@ -764,12 +780,12 @@ def __init__(self, field, place, name=None, prec=None, gen_name=None): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: m = L.completion(p) # needs sage.rings.function_field - sage: m # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: m = L.completion(p) + sage: m Completion map: From: Function field in y defined by y^2 + y + (x^2 + 1)/x To: Laurent Series Ring in s over Finite Field of size 2 @@ -803,12 +819,12 @@ def _repr_type(self) -> str: EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: m = L.completion(p) # needs sage.rings.function_field - sage: m # indirect doctest # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: m = L.completion(p) + sage: m # indirect doctest Completion map: From: Function field in y defined by y^2 + y + (x^2 + 1)/x To: Laurent Series Ring in s over Finite Field of size 2 @@ -821,12 +837,12 @@ def _call_(self, f): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: m = L.completion(p) # needs sage.rings.function_field - sage: m(y) # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: m = L.completion(p) + sage: m(y) s^-1 + 1 + s^3 + s^5 + s^7 + s^9 + s^13 + s^15 + s^17 + O(s^19) """ if self._precision == infinity: @@ -840,12 +856,12 @@ def _call_with_args(self, f, args, kwds): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: m = L.completion(p) # needs sage.rings.function_field - sage: m(x+y, 10) # indirect doctest # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: m = L.completion(p) + sage: m(x+y, 10) # indirect doctest s^-1 + 1 + s^2 + s^4 + s^8 + O(s^9) """ if self._precision == infinity: @@ -865,12 +881,12 @@ def _expand(self, f, prec=None): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: m = L.completion(p) # needs sage.rings.function_field - sage: m(x, prec=20) # indirect doctest # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: m = L.completion(p) + sage: m(x, prec=20) # indirect doctest s^2 + s^3 + s^4 + s^5 + s^7 + s^8 + s^9 + s^10 + s^12 + s^13 + s^15 + s^16 + s^17 + s^19 + O(s^22) """ @@ -900,16 +916,16 @@ def _expand_lazy(self, f): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: m = L.completion(p, prec=infinity) # needs sage.rings.function_field - sage: e = m(x); e # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: m = L.completion(p, prec=infinity) + sage: e = m(x); e s^2 + s^3 + s^4 + s^5 + s^7 + s^8 + ... - sage: e.coefficient(99) # indirect doctest # needs sage.rings.function_field + sage: e.coefficient(99) # indirect doctest 0 - sage: e.coefficient(100) # needs sage.rings.function_field + sage: e.coefficient(100) 1 """ place = self._place @@ -933,12 +949,12 @@ def default_precision(self): EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: m = L.completion(p) # needs sage.rings.function_field - sage: m.default_precision() # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: m = L.completion(p) + sage: m.default_precision() 20 """ return self._precision @@ -954,15 +970,15 @@ def _repr_(self) -> str: EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(2)); _. = K[] - sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] # needs sage.rings.function_field - sage: R = p.valuation_ring() # needs sage.rings.function_field - sage: k, fr_k, to_k = R.residue_field() # needs sage.rings.function_field - sage: k # needs sage.rings.function_field + sage: L. = K.extension(Y^2 + Y + x + 1/x) + sage: p = L.places_finite()[0] + sage: R = p.valuation_ring() + sage: k, fr_k, to_k = R.residue_field() + sage: k Finite Field of size 2 - sage: fr_k # needs sage.rings.function_field + sage: fr_k Ring morphism: From: Finite Field of size 2 To: Valuation ring at Place (x, x*y) @@ -983,14 +999,14 @@ def _repr_(self) -> str: EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(5)); R. = PolynomialRing(K) - sage: F. = K.extension(t^2-x^3-1) # needs sage.rings.function_field - sage: O = F.maximal_order() # needs sage.rings.function_field - sage: I = O.ideal(x - 2) # needs sage.rings.function_field - sage: D = I.divisor() # needs sage.rings.function_field - sage: V, from_V, to_V = D.function_space() # needs sage.rings.function_field - sage: from_V # needs sage.rings.function_field + sage: F. = K.extension(t^2-x^3-1) + sage: O = F.maximal_order() + sage: I = O.ideal(x - 2) + sage: D = I.divisor() + sage: V, from_V, to_V = D.function_space() + sage: from_V Linear map: From: Vector space of dimension 2 over Finite Field of size 5 To: Function field in y defined by y^2 + 4*x^3 + 4 @@ -1011,14 +1027,14 @@ def _repr_(self) -> str: EXAMPLES:: - sage: # needs sage.rings.finite_rings + sage: # needs sage.rings.finite_rings sage.rings.function_field sage: K. = FunctionField(GF(5)); R. = PolynomialRing(K) - sage: F. = K.extension(t^2 - x^3 - 1) # needs sage.rings.function_field - sage: O = F.maximal_order() # needs sage.rings.function_field - sage: I = O.ideal(x - 2) # needs sage.rings.function_field - sage: D = I.divisor() # needs sage.rings.function_field - sage: V, from_V, to_V = D.function_space() # needs sage.rings.function_field - sage: to_V # needs sage.rings.function_field + sage: F. = K.extension(t^2 - x^3 - 1) + sage: O = F.maximal_order() + sage: I = O.ideal(x - 2) + sage: D = I.divisor() + sage: V, from_V, to_V = D.function_space() + sage: to_V Section of linear map: From: Function field in y defined by y^2 + 4*x^3 + 4 To: Vector space of dimension 2 over Finite Field of size 5 diff --git a/src/sage/rings/function_field/order.py b/src/sage/rings/function_field/order.py index 52732cad62a..615cbab3690 100644 --- a/src/sage/rings/function_field/order.py +++ b/src/sage/rings/function_field/order.py @@ -259,7 +259,7 @@ def _repr_(self): sage: FunctionField(QQ,'y').maximal_order()._repr_() 'Maximal order of Rational function field in y over Rational Field' """ - return "Maximal order of %s"%(self.function_field(),) + return "Maximal order of %s" % (self.function_field(),) class FunctionFieldMaximalOrderInfinite(FunctionFieldMaximalOrder, FunctionFieldOrderInfinite): @@ -278,4 +278,4 @@ def _repr_(self): sage: F.maximal_order_infinite() # needs sage.modules sage.rings.function_field Maximal infinite order of Function field in y defined by y^3 + x^6 + x^4 + x^2 """ - return "Maximal infinite order of %s"%(self.function_field(),) + return "Maximal infinite order of %s" % (self.function_field(),) diff --git a/src/sage/rings/function_field/order_basis.py b/src/sage/rings/function_field/order_basis.py index 3452d961459..eebaeab97d1 100644 --- a/src/sage/rings/function_field/order_basis.py +++ b/src/sage/rings/function_field/order_basis.py @@ -93,7 +93,7 @@ def __init__(self, basis, check=True): R = V.base_field().maximal_order() self._module = V.span([to_V(b) for b in basis], base_ring=R) - self._from_module= from_V + self._from_module = from_V self._to_module = to_V self._basis = tuple(basis) self._ring = field.polynomial_ring() diff --git a/src/sage/rings/function_field/order_polymod.py b/src/sage/rings/function_field/order_polymod.py index e4f7d6eece8..97f5a625819 100644 --- a/src/sage/rings/function_field/order_polymod.py +++ b/src/sage/rings/function_field/order_polymod.py @@ -683,7 +683,7 @@ def decomposition(self, ideal): # occurs by constructing a matrix in k, and finding a non-zero # vector in the kernel of the matrix. - m =[] + m = [] for g in q.basis_matrix(): m.extend(matrix([g * mr for mr in matrices_reduced]).columns()) beta = [c.lift() for c in matrix(m).right_kernel().basis()[0]] @@ -784,7 +784,7 @@ def _element_constructor_(self, f): O = F.base_field().maximal_order_infinite() coordinates = self.coordinate_vector(f) if not all(c in O for c in coordinates): - raise TypeError("%r is not an element of %r"%(f,self)) + raise TypeError("%r is not an element of %r" % (f,self)) return f @@ -1288,7 +1288,7 @@ def decomposition(self, ideal): # p and qgen generates the prime; modulo pO, qgenb generates the prime qgenb = [to(qgen[i]) for i in range(n)] - m =[] + m = [] for i in range(n): m.append(sum(qgenb[j] * mtable[i][j] for j in range(n))) beta = [fr(coeff) for coeff in matrix(m).left_kernel().basis()[0]] @@ -1383,7 +1383,7 @@ def add(Ib,Jb): Kb.append(Lb) # J_1, J_2, ... - Jb =[Kb[0]] + [div(Kb[j],Kb[j-1]) for j in range(1,len(Kb))] + Jb = [Kb[0]] + [div(Kb[j],Kb[j-1]) for j in range(1,len(Kb))] # H_1, H_2, ... Hb = [div(Jb[j],Jb[j+1]) for j in range(len(Jb)-1)] + [Jb[-1]] @@ -1455,7 +1455,7 @@ def split(h): # Compute an element beta in O but not in pO. How to find beta # is explained in Section 4.8.3 of [Coh1993]. We keep beta # as a vector over k[x] with respect to the basis of O. - m =[] + m = [] for i in range(n): r = [] for g in prime._hnf: diff --git a/src/sage/rings/function_field/order_rational.py b/src/sage/rings/function_field/order_rational.py index ff701315f0f..99da2af1ebd 100644 --- a/src/sage/rings/function_field/order_rational.py +++ b/src/sage/rings/function_field/order_rational.py @@ -84,7 +84,7 @@ def _element_constructor_(self, f): raise TypeError("unable to convert to an element of {}".format(F)) if not f.denominator() in self.function_field().constant_base_field(): - raise TypeError("%r is not an element of %r"%(f,self)) + raise TypeError("%r is not an element of %r" % (f,self)) return f diff --git a/src/sage/rings/function_field/place.py b/src/sage/rings/function_field/place.py index 48ea2a2c32f..dbc3ab0e767 100644 --- a/src/sage/rings/function_field/place.py +++ b/src/sage/rings/function_field/place.py @@ -24,17 +24,17 @@ sage: F. = FunctionField(GF(2)) sage: O = F.maximal_order() sage: p = O.ideal(x^2 + x + 1).place() # needs sage.libs.pari - sage: k, fr_k, to_k = p.residue_field() # needs sage.rings.function_field - sage: k + sage: k, fr_k, to_k = p.residue_field() # needs sage.libs.pari sage.rings.function_field + sage: k # needs sage.libs.pari sage.rings.function_field Finite Field in z2 of size 2^2 The homomorphisms are between the valuation ring and the residue field:: - sage: fr_k + sage: fr_k # needs sage.libs.pari sage.rings.function_field Ring morphism: From: Finite Field in z2 of size 2^2 To: Valuation ring at Place (x^2 + x + 1) - sage: to_k + sage: to_k # needs sage.libs.pari sage.rings.function_field Ring morphism: From: Valuation ring at Place (x^2 + x + 1) To: Finite Field in z2 of size 2^2 diff --git a/src/sage/rings/function_field/place_polymod.py b/src/sage/rings/function_field/place_polymod.py index b1d525152f0..e11a6c86ab7 100644 --- a/src/sage/rings/function_field/place_polymod.py +++ b/src/sage/rings/function_field/place_polymod.py @@ -602,7 +602,7 @@ def candidates(): if deg > 1: if isinstance(k, NumberField): if name is None: - name='s' + name = 's' K = k.extension(min_poly, names=name) def from_W(e): diff --git a/src/sage/rings/function_field/place_rational.py b/src/sage/rings/function_field/place_rational.py index b6fd87f4fc2..9b98397ba90 100644 --- a/src/sage/rings/function_field/place_rational.py +++ b/src/sage/rings/function_field/place_rational.py @@ -78,13 +78,13 @@ def residue_field(self, name=None): sage: O = F.maximal_order() sage: p = O.ideal(x^2 + x + 1).place() sage: k, fr_k, to_k = p.residue_field() # needs sage.rings.function_field - sage: k + sage: k # needs sage.rings.function_field Finite Field in z2 of size 2^2 - sage: fr_k + sage: fr_k # needs sage.rings.function_field Ring morphism: From: Finite Field in z2 of size 2^2 To: Valuation ring at Place (x^2 + x + 1) - sage: to_k + sage: to_k # needs sage.rings.function_field Ring morphism: From: Valuation ring at Place (x^2 + x + 1) To: Finite Field in z2 of size 2^2 @@ -128,7 +128,7 @@ def to_K(f): d = f.denominator() n_deg = n.degree() - d_deg =d.degree() + d_deg = d.degree() if n_deg < d_deg: return K(0) @@ -170,8 +170,8 @@ def valuation_ring(self): sage: K. = FunctionField(GF(2)); _. = K[] sage: L. = K.extension(Y^2 + Y + x + 1/x) # needs sage.rings.function_field - sage: p = L.places_finite()[0] - sage: p.valuation_ring() + sage: p = L.places_finite()[0] # needs sage.rings.function_field + sage: p.valuation_ring() # needs sage.rings.function_field Valuation ring at Place (x, x*y) """ from .valuation_ring import FunctionFieldValuationRing diff --git a/src/sage/rings/function_field/valuation.py b/src/sage/rings/function_field/valuation.py index 3f504868e4c..e8afd1cb232 100644 --- a/src/sage/rings/function_field/valuation.py +++ b/src/sage/rings/function_field/valuation.py @@ -358,7 +358,7 @@ def create_key_and_extra_args_from_valuation_on_isomorphic_field(self, domain, v sage: R. = K[] sage: L. = K.extension(y^2 + y + x^3) # needs sage.rings.function_field sage: v = K.valuation(1/x) # needs sage.rings.function_field - sage: w = v.extension(L) # indirect doctest # needs sage.rings.function_field + sage: w = v.extension(L) # indirect doctest # needs sage.rings.function_field """ from sage.categories.function_fields import FunctionFields @@ -1118,7 +1118,7 @@ class FunctionFieldFromLimitValuation(FiniteExtensionFromLimitValuation, Discret sage: K. = FunctionField(QQ) sage: R. = K[] sage: L. = K.extension(y^2 - (x^2 + x + 1)) # needs sage.rings.function_field - sage: v = K.valuation(x - 1) # indirect doctest # needs sage.rings.function_field + sage: v = K.valuation(x - 1) # indirect doctest # needs sage.rings.function_field sage: w = v.extension(L); w # needs sage.rings.function_field (x - 1)-adic valuation diff --git a/src/sage/rings/homset.py b/src/sage/rings/homset.py index 6013a6ca28b..0e500de2608 100644 --- a/src/sage/rings/homset.py +++ b/src/sage/rings/homset.py @@ -91,7 +91,7 @@ def _repr_(self): sage: Hom(ZZ, QQ) # indirect doctest Set of Homomorphisms from Integer Ring to Rational Field """ - return "Set of Homomorphisms from %s to %s"%(self.domain(), self.codomain()) + return "Set of Homomorphisms from %s to %s" % (self.domain(), self.codomain()) def has_coerce_map_from(self, x): """ @@ -212,7 +212,7 @@ def natural_map(self): """ f = self.codomain().coerce_map_from(self.domain()) if f is None: - raise TypeError("natural coercion morphism from %s to %s not defined"%(self.domain(), self.codomain())) + raise TypeError("natural coercion morphism from %s to %s not defined" % (self.domain(), self.codomain())) return f def zero(self): @@ -266,10 +266,11 @@ class RingHomset_quo_ring(RingHomset_generic): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) - sage: S. = R.quotient(x^2 + y^2) # needs sage.libs.singular - sage: H = S.Hom(R) # needs sage.libs.singular - sage: H == loads(dumps(H)) # needs sage.libs.singular + sage: S. = R.quotient(x^2 + y^2) + sage: H = S.Hom(R) + sage: H == loads(dumps(H)) True We test pickling of actual homomorphisms in a quotient:: @@ -287,18 +288,19 @@ def _element_constructor_(self, x, base_map=None, check=True): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) - sage: S. = R.quotient(x^2 + y^2) # needs sage.libs.singular - sage: H = S.Hom(R) # needs sage.libs.singular - sage: phi = H([b, a]); phi # needs sage.libs.singular + sage: S. = R.quotient(x^2 + y^2) + sage: H = S.Hom(R) + sage: phi = H([b, a]); phi Ring morphism: From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) To: Multivariate Polynomial Ring in x, y over Rational Field Defn: a |--> b b |--> a sage: R2. = PolynomialRing(ZZ, 2) - sage: H2 = Hom(R2, S) # needs sage.libs.singular - sage: H2(phi) # needs sage.libs.singular + sage: H2 = Hom(R2, S) + sage: H2(phi) Composite map: From: Multivariate Polynomial Ring in x, y over Integer Ring To: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py index 2bb3a47e4d3..d36d9406f32 100644 --- a/src/sage/rings/ideal.py +++ b/src/sage/rings/ideal.py @@ -125,9 +125,9 @@ def Ideal(*args, **kwds): Note that some rings use different ideal implementations than the standard, even if they are PIDs.:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: I = R * (x^2 + 3) # optional - sage.rings.finite_rings - sage: type(I) # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: I = R * (x^2 + 3) + sage: type(I) You can also pass in a specific ideal type:: @@ -163,11 +163,11 @@ def Ideal(*args, **kwds): sage: J = R.ideal([2*x + 2*x^2]) sage: J Principal ideal (x^2 + x) of Univariate Polynomial Ring in x over Rational Field - sage: S = R.quotient_ring(I) # optional - sage.libs.pari - sage: U = R.quotient_ring(J) # optional - sage.libs.pari + sage: S = R.quotient_ring(I) # needs sage.libs.pari + sage: U = R.quotient_ring(J) # needs sage.libs.pari sage: I == J True - sage: S == U # optional - sage.libs.pari + sage: S == U # needs sage.libs.pari True """ if len(args) == 0: @@ -295,8 +295,8 @@ def _repr_short(self): the generators are not represented from left to right but from top to bottom. This is the case, e.g., for matrices:: - sage: MS = MatrixSpace(QQ, 2, 2) # optional - sage.modules - sage: MS * [MS.1, 2] # optional - sage.modules + sage: MS = MatrixSpace(QQ, 2, 2) # needs sage.modules + sage: MS * [MS.1, 2] # needs sage.modules Left Ideal ( [0 1] @@ -316,8 +316,8 @@ def _repr_short(self): s = s.replace('\n','\n ') L.append(s) if has_return: - return '\n(\n %s\n)\n'%(',\n\n '.join(L)) - return '(%s)'%(', '.join(L)) + return '\n(\n %s\n)\n' % (',\n\n '.join(L)) + return '(%s)' % (', '.join(L)) def __repr__(self): """ @@ -329,7 +329,7 @@ def __repr__(self): sage: P*[a^2,a*b+c,c^3] # indirect doctest Ideal (a^2, a*b + c, c^3) of Multivariate Polynomial Ring in a, b, c over Rational Field """ - return "Ideal %s of %s"%(self._repr_short(), self.ring()) + return "Ideal %s of %s" % (self._repr_short(), self.ring()) def random_element(self, *args, **kwds): """ @@ -337,9 +337,9 @@ def random_element(self, *args, **kwds): EXAMPLES:: - sage: P. = GF(5)[[]] # optional - sage.rings.finite_rings - sage: I = P.ideal([a^2, a*b + c, c^3]) # optional - sage.rings.finite_rings - sage: I.random_element() # random # optional - sage.rings.finite_rings + sage: P. = GF(5)[[]] + sage: I = P.ideal([a^2, a*b + c, c^3]) + sage: I.random_element() # random 2*a^5*c + a^2*b*c^4 + ... + O(a, b, c)^13 """ @@ -377,10 +377,10 @@ def __contains__(self, x): sage: P. = QQ[] sage: I = P * [a, b] - sage: a + b in I # optional - sage.libs.singular + sage: a + b in I # needs sage.libs.singular True sage: P2. = QQ[] - sage: x + 2*y + w*z in I # optional - sage.libs.singular + sage: x + 2*y + w*z in I False """ try: @@ -470,11 +470,11 @@ def base_ring(self): And `p`-adic numbers:: - sage: R = Zp(7, prec=10); R # optional - sage.rings.padics + sage: R = Zp(7, prec=10); R # needs sage.rings.padics 7-adic Ring with capped relative precision 10 - sage: I = 7*R; I # optional - sage.rings.padics + sage: I = 7*R; I # needs sage.rings.padics Principal ideal (7 + O(7^11)) of 7-adic Ring with capped relative precision 10 - sage: I.base_ring() # optional - sage.rings.padics + sage: I.base_ring() # needs sage.rings.padics 7-adic Ring with capped relative precision 10 """ return self.ring().base_ring() @@ -486,6 +486,7 @@ def apply_morphism(self, phi): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: psi = CC['x'].hom([-CC['x'].0]) sage: J = ideal([CC['x'].0 + 1]); J Principal ideal (x + 1.00000000000000) of Univariate Polynomial Ring in x @@ -509,6 +510,7 @@ def apply_morphism(self, phi): TESTS:: + sage: # needs sage.rings.number_fields sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: A = K.ideal(a) @@ -522,6 +524,7 @@ def apply_morphism(self, phi): :: + sage: # needs sage.rings.number_fields sage: K. = NumberField(x^2 + 5) sage: B = K.ideal([2, a + 1]); B Fractional ideal (2, a + 1) @@ -531,9 +534,9 @@ def apply_morphism(self, phi): Since 2 is totally ramified, complex conjugation fixes it:: - sage: B.apply_morphism(taus[1]) # complex conjugation + sage: B.apply_morphism(taus[1]) # complex conjugation # needs sage.rings.number_fields Fractional ideal (2, a + 1) - sage: taus[1](B) + sage: taus[1](B) # needs sage.rings.number_fields Fractional ideal (2, a + 1) """ from sage.categories.morphism import is_Morphism @@ -589,12 +592,12 @@ def ring(self): sage: I = R.ideal(x^2 - 3) sage: I.ring() Univariate Polynomial Ring in x over Rational Field - sage: Rbar = R.quotient(I, names='a') # optional - sage.libs.pari - sage: S = PolynomialRing(Rbar, 'y'); y = Rbar.gen(); S # optional - sage.libs.pari + sage: Rbar = R.quotient(I, names='a') # needs sage.libs.pari + sage: S = PolynomialRing(Rbar, 'y'); y = Rbar.gen(); S # needs sage.libs.pari Univariate Polynomial Ring in y over Univariate Quotient Polynomial Ring in a over Rational Field with modulus x^2 - 3 - sage: J = S.ideal(y^2 + 1) # optional - sage.libs.pari - sage: J.ring() # optional - sage.libs.pari + sage: J = S.ideal(y^2 + 1) # needs sage.libs.pari + sage: J.ring() # needs sage.libs.pari Univariate Polynomial Ring in y over Univariate Quotient Polynomial Ring in a over Rational Field with modulus x^2 - 3 """ @@ -699,16 +702,16 @@ def is_maximal(self): sage: R = ZZ sage: I = R.ideal(7) - sage: I.is_maximal() # optional - sage.libs.pari + sage: I.is_maximal() True - sage: R.ideal(16).is_maximal() # optional - sage.libs.pari + sage: R.ideal(16).is_maximal() False sage: S = Integers(8) - sage: S.ideal(0).is_maximal() # optional - sage.libs.pari + sage: S.ideal(0).is_maximal() False - sage: S.ideal(2).is_maximal() # optional - sage.libs.pari + sage: S.ideal(2).is_maximal() True - sage: S.ideal(4).is_maximal() # optional - sage.libs.pari + sage: S.ideal(4).is_maximal() False """ from sage.rings.integer_ring import ZZ @@ -744,28 +747,29 @@ def is_primary(self, P=None): sage: R. = QQ[] sage: I = R.ideal([x^2, x*y]) - sage: I.is_primary() # optional - sage.libs.singular + sage: I.is_primary() # needs sage.libs.singular False - sage: J = I.primary_decomposition()[1]; J # optional - sage.libs.singular + sage: J = I.primary_decomposition()[1]; J # needs sage.libs.singular Ideal (y, x^2) of Multivariate Polynomial Ring in x, y over Rational Field - sage: J.is_primary() # optional - sage.libs.singular + sage: J.is_primary() # needs sage.libs.singular True - sage: J.is_prime() # optional - sage.libs.singular + sage: J.is_prime() # needs sage.libs.singular False Some examples from the Macaulay2 documentation:: - sage: R. = GF(101)[] # optional - sage.rings.finite_rings - sage: I = R.ideal([y^6]) # optional - sage.rings.finite_rings - sage: I.is_primary() # optional - sage.libs.singular sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(101)[] + sage: I = R.ideal([y^6]) + sage: I.is_primary() # needs sage.libs.singular True - sage: I.is_primary(R.ideal([y])) # optional - sage.libs.singular sage.rings.finite_rings + sage: I.is_primary(R.ideal([y])) # needs sage.libs.singular True - sage: I = R.ideal([x^4, y^7]) # optional - sage.libs.singular sage.rings.finite_rings - sage: I.is_primary() # optional - sage.libs.singular sage.rings.finite_rings + sage: I = R.ideal([x^4, y^7]) + sage: I.is_primary() # needs sage.libs.singular True - sage: I = R.ideal([x*y, y^2]) # optional - sage.libs.singular sage.rings.finite_rings - sage: I.is_primary() # optional - sage.libs.singular sage.rings.finite_rings + sage: I = R.ideal([x*y, y^2]) + sage: I.is_primary() # needs sage.libs.singular False .. NOTE:: @@ -804,24 +808,24 @@ def is_prime(self): sage: R. = QQ[] sage: I = R.ideal([x, y]) - sage: I.is_prime() # a maximal ideal # optional - sage.libs.singular + sage: I.is_prime() # a maximal ideal # needs sage.libs.singular True sage: I = R.ideal([x^2 - y]) - sage: I.is_prime() # a non-maximal prime ideal # optional - sage.libs.singular + sage: I.is_prime() # a non-maximal prime ideal # needs sage.libs.singular True sage: I = R.ideal([x^2, y]) - sage: I.is_prime() # a non-prime primary ideal # optional - sage.libs.singular + sage: I.is_prime() # a non-prime primary ideal # needs sage.libs.singular False sage: I = R.ideal([x^2, x*y]) - sage: I.is_prime() # a non-prime non-primary ideal # optional - sage.libs.singular + sage: I.is_prime() # a non-prime non-primary ideal # needs sage.libs.singular False sage: S = Integers(8) - sage: S.ideal(0).is_prime() # optional - sage.libs.singular + sage: S.ideal(0).is_prime() False - sage: S.ideal(2).is_prime() # optional - sage.libs.singular + sage: S.ideal(2).is_prime() True - sage: S.ideal(4).is_prime() # optional - sage.libs.singular + sage: S.ideal(4).is_prime() False Note that this method is not implemented for all rings where it @@ -892,7 +896,7 @@ def embedded_primes(self): sage: R. = QQ[] sage: I = R.ideal(x^2, x*y) - sage: I.embedded_primes() # optional - sage.libs.singular + sage: I.embedded_primes() # needs sage.libs.singular [Ideal (y, x) of Multivariate Polynomial Ring in x, y over Rational Field] """ # by definition, embedded primes are associated primes that @@ -960,20 +964,20 @@ def is_trivial(self): :: sage: I = QQ['x', 'y'].ideal(-5) - sage: I.is_trivial() # optional - sage.libs.singular + sage: I.is_trivial() # needs sage.libs.singular True :: - sage: I = CC['x'].ideal(0) - sage: I.is_trivial() + sage: I = CC['x'].ideal(0) # needs sage.rings.real_mpfr + sage: I.is_trivial() # needs sage.rings.real_mpfr True This test addresses issue :trac:`20514`:: sage: R = QQ['x', 'y'] sage: I = R.ideal(R.gens()) - sage: I.is_trivial() # optional - sage.libs.singular + sage: I.is_trivial() # needs sage.libs.singular False """ return self.is_zero() or self == self.ring().unit_ideal() @@ -1118,9 +1122,9 @@ def norm(self): EXAMPLES:: - sage: R. = GF(8, names='a')[] # optional - sage.rings.finite_rings - sage: I = R.ideal(t^4 + t + 1) # optional - sage.rings.finite_rings - sage: I.norm() # optional - sage.rings.finite_rings + sage: R. = GF(8, names='a')[] # needs sage.rings.finite_rings + sage: I = R.ideal(t^4 + t + 1) # needs sage.rings.finite_rings + sage: I.norm() # needs sage.rings.finite_rings Principal ideal (t^4 + t + 1) of Univariate Polynomial Ring in t over Finite Field in a of size 2^3 """ @@ -1142,9 +1146,9 @@ def absolute_norm(self): EXAMPLES:: - sage: R. = GF(9, names='a')[] # optional - sage.rings.finite_rings - sage: I = R.ideal(t^4 + t + 1) # optional - sage.rings.finite_rings - sage: I.absolute_norm() # optional - sage.rings.finite_rings + sage: R. = GF(9, names='a')[] # needs sage.rings.finite_rings + sage: I = R.ideal(t^4 + t + 1) # needs sage.rings.finite_rings + sage: I.absolute_norm() # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError @@ -1178,11 +1182,11 @@ def _macaulay2_init_(self, macaulay2=None): Field ideals generated from the polynomial ring over two variables in the finite field of size 2:: - sage: P. = PolynomialRing(GF(2), 2) # optional - sage.rings.finite_rings - sage: I = sage.rings.ideal.FieldIdeal(P); I # optional - sage.rings.finite_rings + sage: P. = PolynomialRing(GF(2), 2) + sage: I = sage.rings.ideal.FieldIdeal(P); I Ideal (x^2 + x, y^2 + y) of Multivariate Polynomial Ring in x, y over Finite Field of size 2 - sage: macaulay2(I) # optional - macaulay2 # optional - sage.rings.finite_rings + sage: macaulay2(I) # optional - macaulay2 # needs sage.rings.finite_rings 2 2 ideal (x + x, y + y) @@ -1229,7 +1233,7 @@ def free_resolution(self, *args, **kwds): sage: R. = PolynomialRing(QQ) sage: I = R.ideal([x^4 + 3*x^2 + 2]) - sage: I.free_resolution() # optional - sage.modules + sage: I.free_resolution() # needs sage.modules S^1 <-- S^1 <-- 0 """ if not self.is_principal(): @@ -1248,7 +1252,7 @@ def graded_free_resolution(self, *args, **kwds): sage: R. = PolynomialRing(QQ) sage: I = R.ideal([x^3]) - sage: I.graded_free_resolution() # optional - sage.modules + sage: I.graded_free_resolution() # needs sage.modules S(0) <-- S(-3) <-- 0 """ from sage.homology.graded_resolution import GradedFiniteFreeResolution_free_module @@ -1276,7 +1280,7 @@ def __repr__(self): sage: I # indirect doctest Principal ideal (x) of Univariate Polynomial Ring in x over Integer Ring """ - return "Principal ideal (%s) of %s"%(self.gen(), self.ring()) + return "Principal ideal (%s) of %s" % (self.gen(), self.ring()) def is_principal(self): r""" @@ -1575,18 +1579,18 @@ def is_prime(self): EXAMPLES:: - sage: ZZ.ideal(2).is_prime() # optional - sage.libs.pari + sage: ZZ.ideal(2).is_prime() True - sage: ZZ.ideal(-2).is_prime() # optional - sage.libs.pari + sage: ZZ.ideal(-2).is_prime() True - sage: ZZ.ideal(4).is_prime() # optional - sage.libs.pari + sage: ZZ.ideal(4).is_prime() False - sage: ZZ.ideal(0).is_prime() # optional - sage.libs.pari + sage: ZZ.ideal(0).is_prime() True sage: R. = QQ[] - sage: P = R.ideal(x^2 + 1); P # optional - sage.libs.pari + sage: P = R.ideal(x^2 + 1); P Principal ideal (x^2 + 1) of Univariate Polynomial Ring in x over Rational Field - sage: P.is_prime() # optional - sage.libs.pari + sage: P.is_prime() # needs sage.libs.pari True In fields, only the zero ideal is prime:: @@ -1616,18 +1620,19 @@ def is_maximal(self): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: p = R.ideal(t^2 + 2) # optional - sage.rings.finite_rings - sage: p.is_maximal() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: p = R.ideal(t^2 + 2) + sage: p.is_maximal() True - sage: p = R.ideal(t^2 + 1) # optional - sage.rings.finite_rings - sage: p.is_maximal() # optional - sage.rings.finite_rings + sage: p = R.ideal(t^2 + 1) + sage: p.is_maximal() False - sage: p = R.ideal(0) # optional - sage.rings.finite_rings - sage: p.is_maximal() # optional - sage.rings.finite_rings + sage: p = R.ideal(0) + sage: p.is_maximal() False - sage: p = R.ideal(1) # optional - sage.rings.finite_rings - sage: p.is_maximal() # optional - sage.rings.finite_rings + sage: p = R.ideal(1) + sage: p.is_maximal() False """ if not self.ring().is_field() and self.is_zero(): @@ -1645,32 +1650,33 @@ def residue_field(self): EXAMPLES:: + sage: # needs sage.libs.pari sage: P = ZZ.ideal(61); P Principal ideal (61) of Integer Ring - sage: F = P.residue_field(); F # optional - sage.libs.pari + sage: F = P.residue_field(); F Residue field of Integers modulo 61 - sage: pi = F.reduction_map(); pi # optional - sage.libs.pari + sage: pi = F.reduction_map(); pi Partially defined reduction map: From: Rational Field To: Residue field of Integers modulo 61 - sage: pi(123/234) # optional - sage.libs.pari + sage: pi(123/234) 6 - sage: pi(1/61) # optional - sage.libs.pari + sage: pi(1/61) Traceback (most recent call last): ... ZeroDivisionError: Cannot reduce rational 1/61 modulo 61: it has negative valuation - sage: lift = F.lift_map(); lift # optional - sage.libs.pari + sage: lift = F.lift_map(); lift Lifting map: From: Residue field of Integers modulo 61 To: Integer Ring - sage: lift(F(12345/67890)) # optional - sage.libs.pari + sage: lift(F(12345/67890)) 33 sage: (12345/67890) % 61 33 TESTS:: - sage: ZZ.ideal(96).residue_field() # optional - sage.libs.pari + sage: ZZ.ideal(96).residue_field() Traceback (most recent call last): ... ValueError: The ideal (Principal ideal (96) of Integer Ring) is not prime @@ -1679,15 +1685,15 @@ def residue_field(self): sage: R. = QQ[] sage: I = R.ideal(x^2 + 1) - sage: I.is_prime() # optional - sage.libs.pari + sage: I.is_prime() # needs sage.libs.pari True - sage: I.residue_field() # optional - sage.libs.pari + sage: I.residue_field() Traceback (most recent call last): ... TypeError: residue fields only supported for polynomial rings over finite fields. """ if not self.is_prime(): - raise ValueError("The ideal (%s) is not prime"%self) + raise ValueError("The ideal (%s) is not prime" % self) from sage.rings.integer_ring import ZZ if self.ring() is ZZ: return ZZ.residue_field(self, check=False) @@ -1707,11 +1713,11 @@ def __repr__(self): sage: from sage.rings.ideal import Ideal_fractional sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: Ideal_fractional(K, [a]) # indirect doctest # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: Ideal_fractional(K, [a]) # indirect doctest # needs sage.rings.number_field Fractional ideal (a) of Number Field in a with defining polynomial x^2 + 1 """ - return "Fractional ideal %s of %s"%(self._repr_short(), self.ring()) + return "Fractional ideal %s of %s" % (self._repr_short(), self.ring()) # constructors for standard (benchmark) ideals, written uppercase as # these are constructors @@ -1744,19 +1750,19 @@ def Cyclic(R, n=None, homog=False, singular=None): rationals:: sage: P. = PolynomialRing(QQ, 3, order='lex') - sage: I = sage.rings.ideal.Cyclic(P); I # optional - sage.libs.singular + sage: I = sage.rings.ideal.Cyclic(P); I # needs sage.libs.singular Ideal (x + y + z, x*y + x*z + y*z, x*y*z - 1) of Multivariate Polynomial Ring in x, y, z over Rational Field - sage: I.groebner_basis() # optional - sage.libs.singular + sage: I.groebner_basis() # needs sage.libs.singular [x + y + z, y^2 + y*z + z^2, z^3 - 1] We compute a Groebner basis for cyclic 6, which is a standard benchmark and test ideal:: sage: R. = QQ['x,y,z,t,u,v'] - sage: I = sage.rings.ideal.Cyclic(R, 6) # optional - sage.libs.singular - sage: B = I.groebner_basis() # optional - sage.libs.singular - sage: len(B) # optional - sage.libs.singular + sage: I = sage.rings.ideal.Cyclic(R, 6) # needs sage.libs.singular + sage: B = I.groebner_basis() # needs sage.libs.singular + sage: len(B) # needs sage.libs.singular 45 """ from .rational_field import RationalField @@ -1802,14 +1808,14 @@ def Katsura(R, n=None, homog=False, singular=None): EXAMPLES:: sage: P. = PolynomialRing(QQ, 3) - sage: I = sage.rings.ideal.Katsura(P, 3); I # optional - sage.libs.singular + sage: I = sage.rings.ideal.Katsura(P, 3); I # needs sage.libs.singular Ideal (x + 2*y + 2*z - 1, x^2 + 2*y^2 + 2*z^2 - x, 2*x*y + 2*y*z - y) of Multivariate Polynomial Ring in x, y, z over Rational Field :: - sage: Q. = PolynomialRing(QQ, implementation="singular") # optional - sage.libs.singular - sage: J = sage.rings.ideal.Katsura(Q,1); J # optional - sage.libs.singular + sage: Q. = PolynomialRing(QQ, implementation="singular") # needs sage.libs.singular + sage: J = sage.rings.ideal.Katsura(Q,1); J # needs sage.libs.singular Ideal (x - 1) of Multivariate Polynomial Ring in x over Rational Field """ from .rational_field import RationalField @@ -1849,15 +1855,15 @@ def FieldIdeal(R): The field ideal generated from the polynomial ring over two variables in the finite field of size 2:: - sage: P. = PolynomialRing(GF(2), 2) # optional - sage.rings.finite_rings - sage: I = sage.rings.ideal.FieldIdeal(P); I # optional - sage.rings.finite_rings + sage: P. = PolynomialRing(GF(2), 2) + sage: I = sage.rings.ideal.FieldIdeal(P); I Ideal (x^2 + x, y^2 + y) of Multivariate Polynomial Ring in x, y over Finite Field of size 2 Another, similar example:: - sage: Q. = PolynomialRing(GF(2^4, name='alpha'), 4) # optional - sage.rings.finite_rings - sage: J = sage.rings.ideal.FieldIdeal(Q); J # optional - sage.rings.finite_rings + sage: Q. = PolynomialRing(GF(2^4, name='alpha'), 4) # needs sage.rings.finite_rings + sage: J = sage.rings.ideal.FieldIdeal(Q); J # needs sage.rings.finite_rings Ideal (x1^16 + x1, x2^16 + x2, x3^16 + x3, x4^16 + x4) of Multivariate Polynomial Ring in x1, x2, x3, x4 over Finite Field in alpha of size 2^4 diff --git a/src/sage/rings/ideal_monoid.py b/src/sage/rings/ideal_monoid.py index 01193661aae..0988ffc72e5 100644 --- a/src/sage/rings/ideal_monoid.py +++ b/src/sage/rings/ideal_monoid.py @@ -3,8 +3,8 @@ WARNING: This is used by some rings that are not commutative! :: - sage: MS = MatrixSpace(QQ, 3, 3) # optional - sage.modules - sage: type(MS.ideal(MS.one()).parent()) # optional - sage.modules + sage: MS = MatrixSpace(QQ, 3, 3) # needs sage.modules + sage: type(MS.ideal(MS.one()).parent()) # needs sage.modules """ @@ -53,9 +53,9 @@ def __init__(self, R): TESTS:: - sage: R = QuadraticField(-23, 'a') # optional - sage.rings.number_field + sage: R = QuadraticField(-23, 'a') # needs sage.rings.number_field sage: from sage.rings.ideal_monoid import IdealMonoid - sage: M = IdealMonoid(R); M # indirect doctest # optional - sage.rings.number_field + sage: M = IdealMonoid(R); M # indirect doctest # needs sage.rings.number_field Monoid of ideals of Number Field in a with defining polynomial x^2 + 23 with a = 4.795831523312720?*I @@ -63,8 +63,8 @@ def __init__(self, R): sage: id.parent().category() Category of commutative monoids - sage: MS = MatrixSpace(QQ, 3, 3) # optional - sage.modules - sage: MS.ideal(MS.one()).parent().category() # optional - sage.modules + sage: MS = MatrixSpace(QQ, 3, 3) # needs sage.modules + sage: MS.ideal(MS.one()).parent().category() # needs sage.modules Category of monoids """ self.__R = R @@ -81,9 +81,9 @@ def _repr_(self): TESTS:: - sage: R = QuadraticField(-23, 'a') # optional - sage.rings.number_field + sage: R = QuadraticField(-23, 'a') # needs sage.rings.number_field sage: from sage.rings.ideal_monoid import IdealMonoid - sage: M = IdealMonoid(R); M._repr_() # optional - sage.rings.number_field + sage: M = IdealMonoid(R); M._repr_() # needs sage.rings.number_field 'Monoid of ideals of Number Field in a with defining polynomial x^2 + 23 with a = 4.795831523312720?*I' """ @@ -95,9 +95,9 @@ def ring(self): EXAMPLES:: - sage: R = QuadraticField(-23, 'a') # optional - sage.rings.number_field + sage: R = QuadraticField(-23, 'a') # needs sage.rings.number_field sage: from sage.rings.ideal_monoid import IdealMonoid - sage: M = IdealMonoid(R); M.ring() is R # optional - sage.rings.number_field + sage: M = IdealMonoid(R); M.ring() is R # needs sage.rings.number_field True """ return self.__R @@ -108,12 +108,13 @@ def _element_constructor_(self, x): EXAMPLES:: - sage: R. = QuadraticField(-23) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: R. = QuadraticField(-23) sage: from sage.rings.ideal_monoid import IdealMonoid - sage: M = IdealMonoid(R) # optional - sage.rings.number_field - sage: M(a) # indirect doctest # optional - sage.rings.number_field + sage: M = IdealMonoid(R) + sage: M(a) # indirect doctest Fractional ideal (a) - sage: M([a-4, 13]) # optional - sage.rings.number_field + sage: M([a-4, 13]) Fractional ideal (13, 1/2*a + 9/2) """ try: @@ -137,15 +138,16 @@ def _coerce_map_from_(self, x): EXAMPLES:: - sage: R = QuadraticField(-23, 'a') # optional - sage.rings.number_field - sage: M = R.ideal_monoid() # optional - sage.rings.number_field - sage: M.has_coerce_map_from(R) # indirect doctest # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: R = QuadraticField(-23, 'a') + sage: M = R.ideal_monoid() + sage: M.has_coerce_map_from(R) # indirect doctest True - sage: M.has_coerce_map_from(QQ.ideal_monoid()) # optional - sage.rings.number_field + sage: M.has_coerce_map_from(QQ.ideal_monoid()) True - sage: M.has_coerce_map_from(Zmod(6)) # optional - sage.rings.number_field + sage: M.has_coerce_map_from(Zmod(6)) False - sage: M.has_coerce_map_from(loads(dumps(M))) # optional - sage.rings.number_field + sage: M.has_coerce_map_from(loads(dumps(M))) True """ if isinstance(x, IdealMonoid_c): @@ -159,13 +161,14 @@ def __eq__(self, other): EXAMPLES:: - sage: R = QuadraticField(-23, 'a') # optional - sage.rings.number_field - sage: M = R.ideal_monoid() # optional - sage.rings.number_field - sage: M == QQ # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: R = QuadraticField(-23, 'a') + sage: M = R.ideal_monoid() + sage: M == QQ False - sage: M == 17 # optional - sage.rings.number_field + sage: M == 17 False - sage: M == R.ideal_monoid() # optional - sage.rings.number_field + sage: M == R.ideal_monoid() True """ if not isinstance(other, IdealMonoid_c): @@ -179,13 +182,14 @@ def __ne__(self, other): EXAMPLES:: - sage: R = QuadraticField(-23, 'a') # optional - sage.rings.number_field - sage: M = R.ideal_monoid() # optional - sage.rings.number_field - sage: M != QQ # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: R = QuadraticField(-23, 'a') + sage: M = R.ideal_monoid() + sage: M != QQ True - sage: M != 17 # optional - sage.rings.number_field + sage: M != 17 True - sage: M != R.ideal_monoid() # optional - sage.rings.number_field + sage: M != R.ideal_monoid() False """ return not (self == other) @@ -196,13 +200,14 @@ def __hash__(self): EXAMPLES:: - sage: R = QuadraticField(-23, 'a') # optional - sage.rings.number_field - sage: M = R.ideal_monoid() # optional - sage.rings.number_field - sage: hash(M) == hash(QQ) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: R = QuadraticField(-23, 'a') + sage: M = R.ideal_monoid() + sage: hash(M) == hash(QQ) False - sage: hash(M) == 17 # optional - sage.rings.number_field + sage: hash(M) == 17 False - sage: hash(M) == hash(R.ideal_monoid()) # optional - sage.rings.number_field + sage: hash(M) == hash(R.ideal_monoid()) True """ # uses a random number, to have a distinct hash diff --git a/src/sage/rings/infinity.py b/src/sage/rings/infinity.py index e084e6099b7..c5ab0b24f32 100644 --- a/src/sage/rings/infinity.py +++ b/src/sage/rings/infinity.py @@ -203,8 +203,8 @@ We check that :trac:`17990` is fixed:: - sage: m = Matrix([Infinity]) # optional - sage.modules - sage: m.rows() # optional - sage.modules + sage: m = Matrix([Infinity]) # needs sage.modules + sage: m.rows() # needs sage.modules [(+Infinity)] """ #***************************************************************************** @@ -290,7 +290,7 @@ def _maxima_init_(self): """ TESTS:: - sage: maxima(-oo) # optional - sage.symbolic + sage: maxima(-oo) # needs sage.symbolic minf sage: [x._maxima_init_() for x in [unsigned_infinity, oo, -oo]] ['inf', 'inf', 'minf'] @@ -306,7 +306,7 @@ def _fricas_init_(self): sage: fricas(-oo) # optional - fricas - infinity - sage: [x._fricas_init_() for x in [unsigned_infinity, oo, -oo]] # optional - fricas + sage: [x._fricas_init_() for x in [unsigned_infinity, oo, -oo]] ['%infinity', '%plusInfinity', '%minusInfinity'] sage: [fricas(x) for x in [unsigned_infinity, oo, -oo]] # optional - fricas [infinity, + infinity, - infinity] @@ -324,9 +324,9 @@ def __pari__(self): EXAMPLES:: - sage: pari(-oo) # optional - sage.libs.pari + sage: pari(-oo) # needs sage.libs.pari -oo - sage: pari(oo) # optional - sage.libs.pari + sage: pari(oo) # needs sage.libs.pari +oo """ from sage.libs.pari.all import pari @@ -379,7 +379,7 @@ def _add_(self, other): Traceback (most recent call last): ... SignError: cannot add unsigned infinities - sage: unsigned_infinity + oo*i + sage: unsigned_infinity + oo*i # needs sage.symbolic Traceback (most recent call last): ... SignError: cannot add unsigned infinities @@ -416,7 +416,7 @@ def _sub_(self, other): Traceback (most recent call last): ... SignError: cannot subtract unsigned infinities - sage: unsigned_infinity - oo*i + sage: unsigned_infinity - oo*i # needs sage.symbolic Traceback (most recent call last): ... SignError: cannot subtract unsigned infinities @@ -472,7 +472,7 @@ def _div_(self, other): Traceback (most recent call last): ... ValueError: unsigned oo times smaller number not defined - sage: SR(infinity) / unsigned_infinity # optional - sage.symbolic + sage: SR(infinity) / unsigned_infinity # needs sage.symbolic Traceback (most recent call last): ... RuntimeError: indeterminate expression: 0 * infinity encountered. @@ -490,7 +490,7 @@ def __float__(self): +infinity sage: float(infinity) # random +infinity - sage: CDF(infinity) + sage: CDF(infinity) # needs sage.rings.complex_double +infinity sage: infinity.__float__() # random +infinity @@ -499,7 +499,7 @@ def __float__(self): -infinity sage: float(-infinity) # random -inf - sage: CDF(-infinity) + sage: CDF(-infinity) # needs sage.rings.complex_double -infinity sage: (-infinity).__float__() # random -inf @@ -568,8 +568,8 @@ def __init__(self): Sage can understand SymPy's complex infinity (:trac:`17493`):: - sage: import sympy # optional - sympy - sage: SR(sympy.zoo) # optional - sympy + sage: import sympy # needs sympy + sage: SR(sympy.zoo) # needs sympy Infinity Some equality checks:: @@ -676,7 +676,7 @@ def _element_constructor_(self, x): sage: UnsignedInfinityRing(2) # indirect doctest A number less than infinity - sage: UnsignedInfinityRing(I) # optional - sage.rings.number_field + sage: UnsignedInfinityRing(I) # needs sage.rings.number_field A number less than infinity sage: UnsignedInfinityRing(unsigned_infinity) Infinity @@ -684,31 +684,31 @@ def _element_constructor_(self, x): Infinity sage: UnsignedInfinityRing(-oo) Infinity - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: UnsignedInfinityRing(a) # optional - sage.rings.number_field + sage: K. = QuadraticField(3) # needs sage.rings.number_field + sage: UnsignedInfinityRing(a) # needs sage.rings.number_field A number less than infinity - sage: UnsignedInfinityRing(a - 2) # optional - sage.rings.number_field + sage: UnsignedInfinityRing(a - 2) # needs sage.rings.number_field A number less than infinity sage: UnsignedInfinityRing(RDF(oo)), UnsignedInfinityRing(RDF(-oo)) (Infinity, Infinity) sage: UnsignedInfinityRing(RR(oo)), UnsignedInfinityRing(RR(-oo)) (Infinity, Infinity) - sage: UnsignedInfinityRing(CDF(oo)), UnsignedInfinityRing(CDF(-oo)) + sage: UnsignedInfinityRing(CDF(oo)), UnsignedInfinityRing(CDF(-oo)) # needs sage.rings.complex_double (Infinity, Infinity) - sage: UnsignedInfinityRing(CC(oo)), UnsignedInfinityRing(CC(-oo)) + sage: UnsignedInfinityRing(CC(oo)), UnsignedInfinityRing(CC(-oo)) # needs sage.rings.real_mpfr (Infinity, Infinity) - sage: UnsignedInfinityRing(RIF(oo)), UnsignedInfinityRing(RIF(-oo)) + sage: UnsignedInfinityRing(RIF(oo)), UnsignedInfinityRing(RIF(-oo)) # needs sage.rings.real_interval_field (Infinity, Infinity) sage: UnsignedInfinityRing(float('+inf')), UnsignedInfinityRing(float('-inf')) (Infinity, Infinity) - sage: UnsignedInfinityRing(SR(oo)), UnsignedInfinityRing(SR(-oo)) # optional - sage.symbolic + sage: UnsignedInfinityRing(SR(oo)), UnsignedInfinityRing(SR(-oo)) # needs sage.symbolic (Infinity, Infinity) The following rings have a ``is_infinity`` method:: sage: RR(oo).is_infinity() True - sage: SR(oo).is_infinity() # optional - sage.symbolic + sage: SR(oo).is_infinity() # needs sage.symbolic True """ # Lazy elements can wrap infinity or not, unwrap first @@ -746,13 +746,13 @@ def _coerce_map_from_(self, R): sage: UnsignedInfinityRing.has_coerce_map_from(int) # indirect doctest True - sage: UnsignedInfinityRing.has_coerce_map_from(CC) + sage: UnsignedInfinityRing.has_coerce_map_from(CC) # needs sage.rings.real_mpfr True - sage: UnsignedInfinityRing.has_coerce_map_from(QuadraticField(-163, 'a')) # optional - sage.rings.number_field + sage: UnsignedInfinityRing.has_coerce_map_from(QuadraticField(-163, 'a')) # needs sage.rings.number_field True - sage: UnsignedInfinityRing.has_coerce_map_from(QQ^3) # optional - sage.modules + sage: UnsignedInfinityRing.has_coerce_map_from(QQ^3) # needs sage.modules False - sage: UnsignedInfinityRing.has_coerce_map_from(SymmetricGroup(13)) # optional - sage.groups + sage: UnsignedInfinityRing.has_coerce_map_from(SymmetricGroup(13)) # needs sage.groups False """ return isinstance(R, Ring) or R in (int, float, complex) @@ -943,12 +943,12 @@ def _sympy_(self): EXAMPLES:: - sage: import sympy # optional - sympy - sage: SR(unsigned_infinity)._sympy_() # optional - sympy + sage: import sympy # needs sympy + sage: SR(unsigned_infinity)._sympy_() # needs sympy zoo - sage: gamma(-3)._sympy_() is sympy.factorial(-2) # optional - sympy + sage: gamma(-3)._sympy_() is sympy.factorial(-2) # needs sympy True - sage: gamma(-3) is sympy.factorial(-2)._sage_() # optional - sympy + sage: gamma(-3) is sympy.factorial(-2)._sage_() # needs sympy True """ import sympy @@ -1133,20 +1133,20 @@ def _element_constructor_(self, x): sage: [InfinityRing(a) for a in [-2..2]] [A negative finite number, A negative finite number, Zero, A positive finite number, A positive finite number] - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: InfinityRing(a) # optional - sage.rings.number_field + sage: K. = QuadraticField(3) # needs sage.rings.number_field + sage: InfinityRing(a) # needs sage.rings.number_field A positive finite number - sage: InfinityRing(a - 2) # optional - sage.rings.number_field + sage: InfinityRing(a - 2) # needs sage.rings.number_field A negative finite number sage: InfinityRing(RDF(oo)), InfinityRing(RDF(-oo)) (+Infinity, -Infinity) sage: InfinityRing(RR(oo)), InfinityRing(RR(-oo)) (+Infinity, -Infinity) - sage: InfinityRing(RIF(oo)), InfinityRing(RIF(-oo)) + sage: InfinityRing(RIF(oo)), InfinityRing(RIF(-oo)) # needs sage.rings.real_interval_field (+Infinity, -Infinity) sage: InfinityRing(float('+inf')), InfinityRing(float('-inf')) (+Infinity, -Infinity) - sage: InfinityRing(SR(oo)), InfinityRing(SR(-oo)) # optional - sage.symbolic + sage: InfinityRing(SR(oo)), InfinityRing(SR(-oo)) # needs sage.symbolic (+Infinity, -Infinity) The following rings have ``is_positive_infinity`` / @@ -1154,22 +1154,22 @@ def _element_constructor_(self, x): sage: RR(oo).is_positive_infinity(), RR(-oo).is_negative_infinity() (True, True) - sage: SR(oo).is_positive_infinity(), SR(-oo).is_negative_infinity() # optional - sage.symbolic + sage: SR(oo).is_positive_infinity(), SR(-oo).is_negative_infinity() # needs sage.symbolic (True, True) Complex infinity raises an exception. This is fine (there is no coercion, so there is no promise of functoriality):: - sage: i_infinity = CC(0, oo) - sage: InfinityRing(CC(oo)), InfinityRing(CC(-oo)) + sage: i_infinity = CC(0, oo) # needs sage.rings.real_mpfr + sage: InfinityRing(CC(oo)), InfinityRing(CC(-oo)) # needs sage.rings.real_mpfr (+Infinity, -Infinity) - sage: InfinityRing(i_infinity) + sage: InfinityRing(i_infinity) # needs sage.rings.real_mpfr Traceback (most recent call last): ... ValueError: infinite but not with +/- phase - sage: InfinityRing(CDF(oo)), InfinityRing(CDF(-oo)) + sage: InfinityRing(CDF(oo)), InfinityRing(CDF(-oo)) # needs sage.rings.complex_double (+Infinity, -Infinity) - sage: InfinityRing(CDF(i_infinity)) + sage: InfinityRing(CDF(i_infinity)) # needs sage.rings.complex_double sage.rings.real_mpfr Traceback (most recent call last): ... ValueError: infinite but not with +/- phase @@ -1230,18 +1230,18 @@ def _coerce_map_from_(self, R): sage: InfinityRing.has_coerce_map_from(int) # indirect doctest True - sage: InfinityRing.has_coerce_map_from(AA) # optional - sage.rings.number_field + sage: InfinityRing.has_coerce_map_from(AA) # needs sage.rings.number_field True sage: InfinityRing.has_coerce_map_from(RDF) True - sage: InfinityRing.has_coerce_map_from(RIF) + sage: InfinityRing.has_coerce_map_from(RIF) # needs sage.rings.real_interval_field True As explained above, comparison works by coercing to the infinity ring:: sage: cm = get_coercion_model() - sage: cm.explain(AA(3), oo, operator.lt) # optional - sage.rings.number_field + sage: cm.explain(AA(3), oo, operator.lt) # needs sage.rings.number_field Coercion on left operand via Coercion map: From: Algebraic Real Field @@ -1254,9 +1254,9 @@ def _coerce_map_from_(self, R): symbolic comparisons with infinities all happen in the symbolic ring:: - sage: SR.has_coerce_map_from(InfinityRing) # optional - sage.symbolic + sage: SR.has_coerce_map_from(InfinityRing) # needs sage.symbolic True - sage: InfinityRing.has_coerce_map_from(SR) # optional - sage.symbolic + sage: InfinityRing.has_coerce_map_from(SR) # needs sage.symbolic False Complex numbers do not coerce into the infinity ring (what @@ -1264,11 +1264,11 @@ def _coerce_map_from_(self, R): be compared, so we do not have to enforce consistency when comparing with infinity either:: - sage: InfinityRing.has_coerce_map_from(CDF) + sage: InfinityRing.has_coerce_map_from(CDF) # needs sage.rings.complex_double False - sage: InfinityRing.has_coerce_map_from(CC) + sage: InfinityRing.has_coerce_map_from(CC) # needs sage.rings.real_mpfr False - sage: CC(0, oo) < CC(1) # does not coerce to infinity ring + sage: CC(0, oo) < CC(1) # does not coerce to infinity ring # needs sage.rings.real_mpfr True """ from sage.structure.coerce import parent_is_real_numerical @@ -1282,7 +1282,7 @@ def _pushout_(self, other): r""" EXAMPLES:: - sage: QQbar(-2*i)*infinity # optional - sage.rings.number_field sage.symbolic + sage: QQbar(-2*i)*infinity # needs sage.rings.number_field sage.symbolic (-I)*Infinity """ from sage.symbolic.ring import SR @@ -1483,9 +1483,9 @@ def _latex_(self): TESTS:: - sage: a = InfinityRing(pi); a # optional - sage.symbolic + sage: a = InfinityRing(pi); a # needs sage.symbolic A positive finite number - sage: a._latex_() # optional - sage.symbolic + sage: a._latex_() # needs sage.symbolic 'A positive finite number' sage: [latex(InfinityRing(a)) for a in [-2..2]] [A negative finite number, A negative finite number, Zero, A positive finite number, A positive finite number] @@ -1626,12 +1626,12 @@ def _sympy_(self): EXAMPLES:: - sage: import sympy # optional - sympy - sage: bool(-oo == -sympy.oo) # optional - sympy + sage: import sympy # needs sympy + sage: bool(-oo == -sympy.oo) # needs sympy True - sage: bool(SR(-oo) == -sympy.oo) # optional - sympy + sage: bool(SR(-oo) == -sympy.oo) # needs sympy True - sage: bool((-oo)._sympy_() == -sympy.oo) # optional - sympy + sage: bool((-oo)._sympy_() == -sympy.oo) # needs sympy True """ @@ -1644,9 +1644,9 @@ def _gap_init_(self): EXAMPLES:: - sage: gap(-Infinity) # optional - sage.libs.gap + sage: gap(-Infinity) # needs sage.libs.gap -infinity - sage: libgap(-Infinity) # optional - sage.libs.gap + sage: libgap(-Infinity) # needs sage.libs.gap -infinity """ return '-infinity' @@ -1727,10 +1727,10 @@ def _sympy_(self): EXAMPLES:: - sage: import sympy # optional - sympy - sage: bool(oo == sympy.oo) # indirect doctest # optional - sympy + sage: import sympy # needs sympy + sage: bool(oo == sympy.oo) # indirect doctest # needs sympy True - sage: bool(SR(oo) == sympy.oo) # optional - sage.symbolic sympy + sage: bool(SR(oo) == sympy.oo) # needs sympy sage.symbolic True """ import sympy @@ -1742,9 +1742,9 @@ def _gap_init_(self): EXAMPLES:: - sage: gap(+Infinity) # optional - sage.libs.gap + sage: gap(+Infinity) # needs sage.libs.gap infinity - sage: libgap(+Infinity) # optional - sage.libs.gap + sage: libgap(+Infinity) # needs sage.libs.gap infinity """ return 'infinity' @@ -1773,8 +1773,8 @@ def test_comparison(ring): EXAMPLES:: sage: from sage.rings.infinity import test_comparison - sage: rings = [ZZ, QQ, RR, RealField(200), RDF, RLF, RIF] - sage: for R in rings: + sage: rings = [ZZ, QQ, RR, RealField(200), RDF, RLF, RIF] # needs sage.rings.real_mpfr + sage: for R in rings: # needs sage.rings.real_mpfr ....: print('testing {}'.format(R)) ....: test_comparison(R) testing Integer Ring @@ -1784,19 +1784,20 @@ def test_comparison(ring): testing Real Double Field testing Real Lazy Field testing Real Interval Field with 53 bits of precision - sage: test_comparison(AA) # optional - sage.rings.number_field + sage: test_comparison(AA) # needs sage.rings.number_field Comparison with number fields does not work:: - sage: K. = NumberField(x^2 - 3) # optional - sage.rings.number_field - sage: (-oo < 1 + sqrt3) and (1 + sqrt3 < oo) # known bug # optional - sage.rings.number_field + sage: x = polygen(ZZ, 'x') + sage: K. = NumberField(x^2 - 3) # needs sage.rings.number_field + sage: (-oo < 1 + sqrt3) and (1 + sqrt3 < oo) # known bug # needs sage.rings.number_field False The symbolic ring handles its own infinities, but answers ``False`` (meaning: cannot decide) already for some very elementary comparisons:: - sage: test_comparison(SR) # known bug # optional - sage.symbolic + sage: test_comparison(SR) # known bug # needs sage.symbolic Traceback (most recent call last): ... AssertionError: testing -1000.0 in Symbolic Ring: id = ... @@ -1854,8 +1855,11 @@ def test_signed_infinity(pos_inf): EXAMPLES:: sage: from sage.rings.infinity import test_signed_infinity - sage: for pos_inf in [oo, float('+inf'), RLF(oo), RIF(oo), SR(oo)]: - ....: test_signed_infinity(pos_inf) + sage: test_signed_infinity(oo) + sage: test_signed_infinity(float('+inf')) + sage: test_signed_infinity(RLF(oo)) + sage: test_signed_infinity(RIF(oo)) # needs sage.rings.real_interval_field + sage: test_signed_infinity(SR(oo)) # needs sage.symbolic """ msg = 'testing {} ({})'.format(pos_inf, type(pos_inf)) assert InfinityRing(pos_inf) is infinity, msg diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index d5e87626d31..0ca24804524 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -24,7 +24,7 @@ Add an integer and a rational number:: Add an integer and a complex number:: - sage: b = ComplexField().0 + 1.5 + sage: b = ComplexField().0 + 1.5 # needs sage.rings.real_mpfr sage: loads((a + b).dumps()) == a + b True @@ -64,8 +64,8 @@ Return version of this integer in the multi-precision floating real field `\RR`:: sage: n = 9390823 - sage: RR = RealField(200) - sage: RR(n) + sage: RR = RealField(200) # needs sage.rings.real_mpfr + sage: RR(n) # needs sage.rings.real_mpfr 9.3908230000000000000000000000000000000000000000000000000000e6 AUTHORS: @@ -163,7 +163,7 @@ from sage.arith.long cimport (integer_check_long, from cpython.list cimport * from cpython.number cimport * -from cpython.int cimport * +from cpython.long cimport * from cpython.object cimport * from libc.stdint cimport uint64_t cimport sage.structure.element @@ -421,9 +421,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Conversion from PARI:: - sage: Integer(pari('-10380104371593008048799446356441519384')) # optional - sage.libs.pari + sage: Integer(pari('-10380104371593008048799446356441519384')) # needs sage.libs.pari -10380104371593008048799446356441519384 - sage: Integer(pari('Pol([-3])')) # optional - sage.libs.pari + sage: Integer(pari('Pol([-3])')) # needs sage.libs.pari -3 Conversion from gmpy2:: @@ -459,11 +459,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): -901824309821093821093812093810928309183091832091 sage: ZZ(RR(2.0)^80) 1208925819614629174706176 - sage: ZZ(QQbar(sqrt(28-10*sqrt(3)) + sqrt(3))) # optional - sage.rings.number_field sage.symbolic + sage: ZZ(QQbar(sqrt(28-10*sqrt(3)) + sqrt(3))) # needs sage.rings.number_field sage.symbolic 5 - sage: ZZ(AA(32).nth_root(5)) # optional - sage.rings.number_field + sage: ZZ(AA(32).nth_root(5)) # needs sage.rings.number_field 2 - sage: ZZ(pari('Mod(-3,7)')) # optional - sage.libs.pari + sage: ZZ(pari('Mod(-3,7)')) # needs sage.libs.pari 4 sage: ZZ('sage') Traceback (most recent call last): @@ -475,10 +475,10 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): '3b' sage: ZZ( ZZ(5).digits(3) , 3) 5 - sage: import numpy # optional - numpy - sage: ZZ(numpy.int64(7^7)) # optional - numpy + sage: import numpy # needs numpy + sage: ZZ(numpy.int64(7^7)) # needs numpy 823543 - sage: ZZ(numpy.ubyte(-7)) # optional - numpy + sage: ZZ(numpy.ubyte(-7)) # needs numpy 249 sage: ZZ(True) 1 @@ -494,8 +494,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): :: - sage: k = GF(2) # optional - sage.rings.finite_rings - sage: ZZ((k(0),k(1)), 2) # optional - sage.rings.finite_rings + sage: k = GF(2) + sage: ZZ((k(0),k(1)), 2) 2 :: @@ -531,40 +531,41 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Test conversion from PARI (:trac:`11685`):: - sage: ZZ(pari(-3)) # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: ZZ(pari(-3)) -3 - sage: ZZ(pari("-3.0")) # optional - sage.libs.pari + sage: ZZ(pari("-3.0")) -3 - sage: ZZ(pari("-3.5")) # optional - sage.libs.pari + sage: ZZ(pari("-3.5")) Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral real number to an Integer - sage: ZZ(pari("1e100")) # optional - sage.libs.pari + sage: ZZ(pari("1e100")) Traceback (most recent call last): ... PariError: precision too low in truncr (precision loss in truncation) - sage: ZZ(pari("10^50")) # optional - sage.libs.pari + sage: ZZ(pari("10^50")) 100000000000000000000000000000000000000000000000000 - sage: ZZ(pari("Pol(3)")) # optional - sage.libs.pari + sage: ZZ(pari("Pol(3)")) 3 - sage: ZZ(GF(3^20,'t')(1)) # optional - sage.rings.finite_rings + sage: ZZ(GF(3^20,'t')(1)) # needs sage.rings.finite_rings 1 - sage: ZZ(pari(GF(3^20,'t')(1))) # optional - sage.libs.pari sage.rings.finite_rings + sage: ZZ(pari(GF(3^20,'t')(1))) # needs sage.rings.finite_rings 1 sage: x = polygen(QQ) - sage: K. = NumberField(x^2 + 3) # optional - sage.rings.number_field - sage: ZZ(a^2) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 3) # needs sage.rings.number_field + sage: ZZ(a^2) # needs sage.rings.number_field -3 - sage: ZZ(pari(a)^2) # optional - sage.libs.pari sage.rings.number_field + sage: ZZ(pari(a)^2) # needs sage.rings.number_field -3 - sage: ZZ(pari("Mod(x, x^3+x+1)")) # Note error message refers to lifted element # optional - sage.libs.pari + sage: ZZ(pari("Mod(x, x^3+x+1)")) # Note error message refers to lifted element Traceback (most recent call last): ... TypeError: Unable to coerce PARI x to an Integer Test coercion of p-adic with negative valuation:: - sage: ZZ(pari(Qp(11)(11^-7))) # optional - sage.libs.pari sage.rings.padics + sage: ZZ(pari(Qp(11)(11^-7))) # needs sage.libs.pari sage.rings.padics Traceback (most recent call last): ... TypeError: cannot convert p-adic with negative valuation to an integer @@ -580,23 +581,23 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Test comparisons with numpy types (see :trac:`13386` and :trac:`18076`):: - sage: import numpy # optional - numpy - sage: numpy.int8('12') == 12 # optional - numpy + sage: import numpy # needs numpy + sage: numpy.int8('12') == 12 # needs numpy True - sage: 12 == numpy.int8('12') # optional - numpy + sage: 12 == numpy.int8('12') # needs numpy True - sage: float('15') == 15 # optional - numpy + sage: float('15') == 15 True - sage: 15 == float('15') # optional - numpy + sage: 15 == float('15') True Test underscores as digit separators (PEP 515, https://www.python.org/dev/peps/pep-0515/):: - sage: Integer('1_3') # optional - numpy + sage: Integer('1_3') 13 - sage: Integer(b'1_3') # optional - numpy + sage: Integer(b'1_3') 13 """ # TODO: All the code below should somehow be in an external @@ -765,8 +766,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: sage: n = -10 - sage: R = GF(17) # optional - sage.rings.finite_rings - sage: n._im_gens_(R, [R(1)]) # optional - sage.rings.finite_rings + sage: R = GF(17) + sage: n._im_gens_(R, [R(1)]) 7 """ return codomain.coerce(self) @@ -1003,9 +1004,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: ex = SR(ZZ(7)); ex # optional - sage.symbolic + sage: ex = SR(ZZ(7)); ex # needs sage.symbolic 7 - sage: parent(ex) # optional - sage.symbolic + sage: parent(ex) # needs sage.symbolic Symbolic Ring """ return sring._force_pyobject(self, force=True) @@ -1016,9 +1017,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: n = 5; n._sympy_() # optional - sympy + sage: n = 5; n._sympy_() # needs sympy 5 - sage: n = -5; n._sympy_() # optional - sympy + sage: n = -5; n._sympy_() # needs sympy -5 """ import sympy @@ -2004,7 +2005,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Traceback (most recent call last): ... ZeroDivisionError: rational division by zero - sage: 3 / QQbar.zero() # optional - sage.rings.number_field + sage: 3 / QQbar.zero() # needs sage.rings.number_field Traceback (most recent call last): ... ZeroDivisionError: division by zero in algebraic field @@ -2109,7 +2110,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): 1 sage: 2^-0 1 - sage: (-1)^(1/3) # optional - sage.symbolic + sage: (-1)^(1/3) # needs sage.symbolic (-1)^(1/3) For consistency with Python and MPFR, 0^0 is defined to be 1 in @@ -2136,30 +2137,31 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): We raise 2 to various interesting exponents:: - sage: 2^x # symbolic x # optional - sage.symbolic + sage: 2^x # symbolic x # needs sage.symbolic 2^x sage: 2^1.5 # real number 2.82842712474619 sage: 2^float(1.5) # python float abs tol 3e-16 2.8284271247461903 - sage: 2^I # complex number + sage: 2^I # complex number # needs sage.symbolic 2^I sage: r = 2 ^ int(-3); r; type(r) 1/8 - sage: f = 2^(sin(x)-cos(x)); f # optional - sage.symbolic + sage: f = 2^(sin(x)-cos(x)); f # needs sage.symbolic 2^(-cos(x) + sin(x)) - sage: f(x=3) + sage: f(x=3) # needs sage.symbolic 2^(-cos(3) + sin(3)) A symbolic sum:: - sage: x, y, z = var('x,y,z') # optional - sage.symbolic - sage: 2^(x + y + z) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: x, y, z = var('x,y,z') + sage: 2^(x + y + z) 2^(x + y + z) - sage: 2^(1/2) # optional - sage.symbolic + sage: 2^(1/2) sqrt(2) - sage: 2^(-1/2) # optional - sage.symbolic + sage: 2^(-1/2) 1/2*sqrt(2) TESTS:: @@ -2650,6 +2652,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): :: + sage: # needs sage.rings.real_mpfr sage: x = 3^100000 sage: RR(log(RR(x), 3)) 100000.000000000 @@ -2658,6 +2661,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): :: + sage: # needs sage.rings.real_mpfr sage: x.exact_log(3) 100000 sage: (x + 1).exact_log(3) @@ -2667,6 +2671,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): :: + sage: # needs sage.rings.real_mpfr sage: x.exact_log(2.5) Traceback (most recent call last): ... @@ -2764,15 +2769,15 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: Integer(124).log(5) # optional - sage.symbolic + sage: Integer(124).log(5) # needs sage.symbolic log(124)/log(5) - sage: Integer(124).log(5, 100) + sage: Integer(124).log(5, 100) # needs sage.rings.real_mpfr 2.9950093311241087454822446806 sage: Integer(125).log(5) 3 - sage: Integer(125).log(5, prec=53) + sage: Integer(125).log(5, prec=53) # needs sage.rings.real_mpfr 3.00000000000000 - sage: log(Integer(125)) # optional - sage.symbolic + sage: log(Integer(125)) # needs sage.symbolic 3*log(5) For extremely large numbers, this works:: @@ -2785,33 +2790,33 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): works in a reasonable amount of time for this ``x``:: sage: x = 3^100000 - sage: log(x) # optional - sage.symbolic + sage: log(x) # needs sage.symbolic log(1334971414230...5522000001) But approximations are probably more useful in this case, and work to as high a precision as we desire:: - sage: x.log(3, 53) # default precision for RealField + sage: x.log(3, 53) # default precision for RealField # needs sage.rings.real_mpfr 100000.000000000 - sage: (x + 1).log(3, 53) + sage: (x + 1).log(3, 53) # needs sage.rings.real_mpfr 100000.000000000 - sage: (x + 1).log(3, 1000) + sage: (x + 1).log(3, 1000) # needs sage.rings.real_mpfr 100000.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 We can use non-integer bases, with default e:: - sage: x.log(2.5, prec=53) + sage: x.log(2.5, prec=53) # needs sage.rings.real_mpfr 119897.784671579 We also get logarithms of negative integers, via the symbolic ring, using the branch from `-\pi` to `\pi`:: - sage: log(-1) # optional - sage.symbolic + sage: log(-1) # needs sage.symbolic I*pi The logarithm of zero is done likewise:: - sage: log(0) + sage: log(0) # needs sage.symbolic -Infinity Some rational bases yield integer logarithms (:trac:`21517`):: @@ -2826,7 +2831,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): TESTS:: - sage: (-2).log(3) # optional - sage.symbolic + sage: (-2).log(3) # needs sage.symbolic (I*pi + log(2))/log(3) """ cdef int self_sgn @@ -2883,11 +2888,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: Integer(8).exp() # optional - sage.symbolic + sage: Integer(8).exp() # needs sage.symbolic e^8 - sage: Integer(8).exp(prec=100) # optional - sage.symbolic + sage: Integer(8).exp(prec=100) # needs sage.symbolic 2980.9579870417282747435920995 - sage: exp(Integer(8)) # optional - sage.symbolic + sage: exp(Integer(8)) # needs sage.symbolic e^8 For even fairly large numbers, this may not be useful. @@ -2895,9 +2900,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): :: sage: y = Integer(145^145) - sage: y.exp() # optional - sage.symbolic + sage: y.exp() # needs sage.symbolic e^25024207011349079210459585279553675697932183658421565260323592409432707306554163224876110094014450895759296242775250476115682350821522931225499163750010280453185147546962559031653355159703678703793369785727108337766011928747055351280379806937944746847277089168867282654496776717056860661614337004721164703369140625 - sage: y.exp(prec=53) # default RealField precision # optional - sage.symbolic + sage: y.exp(prec=53) # default RealField precision # needs sage.symbolic +infinity """ from sage.functions.all import exp @@ -2977,12 +2982,12 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): Setting the optional ``limit`` argument works as expected:: sage: a = 10^100 + 1 - sage: a.prime_divisors() # optional - sage.libs.pari + sage: a.prime_divisors() # needs sage.libs.pari [73, 137, 401, 1201, 1601, 1676321, 5964848081, 129694419029057750551385771184564274499075700947656757821537291527196801] - sage: a.prime_divisors(limit=10^3) # optional - sage.libs.pari + sage: a.prime_divisors(limit=10^3) [73, 137, 401] - sage: a.prime_divisors(limit=10^7) # optional - sage.libs.pari + sage: a.prime_divisors(limit=10^7) [73, 137, 401, 1201, 1601, 1676321] """ res = [r[0] for r in self.factor(*args, **kwds)] @@ -3024,32 +3029,32 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): [1, 2, 3, 4, 6, 8, 9, 12, 17, 18, 24, 34, 36, 51, 68, 72, 102, 136, 153, 204, 306, 408, 612, 1224] sage: a = odd_part(factorial(31)) - sage: v = a.divisors() # optional - sage.libs.pari - sage: len(v) # optional - sage.libs.pari + sage: v = a.divisors() # needs sage.libs.pari + sage: len(v) # needs sage.libs.pari 172800 - sage: prod(e + 1 for p, e in factor(a)) # optional - sage.libs.pari + sage: prod(e + 1 for p, e in factor(a)) # needs sage.libs.pari 172800 - sage: all(t.divides(a) for t in v) # optional - sage.libs.pari + sage: all(t.divides(a) for t in v) # needs sage.libs.pari True :: sage: n = 2^551 - 1 - sage: L = n.divisors() # optional - sage.libs.pari - sage: len(L) # optional - sage.libs.pari + sage: L = n.divisors() # needs sage.libs.pari + sage: len(L) # needs sage.libs.pari 256 - sage: L[-1] == n # optional - sage.libs.pari + sage: L[-1] == n # needs sage.libs.pari True TESTS: Overflow:: - sage: prod(primes_first_n(64)).divisors() # optional - sage.libs.pari + sage: prod(primes_first_n(64)).divisors() # needs sage.libs.pari Traceback (most recent call last): ... OverflowError: value too large - sage: prod(primes_first_n(58)).divisors() # optional - sage.libs.pari + sage: prod(primes_first_n(58)).divisors() # needs sage.libs.pari Traceback (most recent call last): ... OverflowError: value too large # 32-bit @@ -3059,8 +3064,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): (the ``divisors`` call below allocates about 800 MB every time, so a memory leak will not go unnoticed):: - sage: n = prod(primes_first_n(25)) # optional - sage.libs.pari - sage: for i in range(20): # long time # optional - sage.libs.pari + sage: n = prod(primes_first_n(25)) # needs sage.libs.pari + sage: for i in range(20): # long time # needs sage.libs.pari ....: try: ....: alarm(RDF.random_element(1e-3, 0.5)) ....: _ = n.divisors() @@ -3342,9 +3347,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): This example caused trouble in :trac:`6083`:: - sage: a = next_prime(2**31) # optional - sage.libs.pari - sage: b = Integers(a)(100) # optional - sage.libs.pari - sage: a % b # optional - sage.libs.pari + sage: a = next_prime(2**31) # needs sage.libs.pari + sage: b = Integers(a)(100) # needs sage.libs.pari + sage: a % b # needs sage.libs.pari Traceback (most recent call last): ... ArithmeticError: reduction modulo 100 not defined @@ -3440,10 +3445,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: divmod(1, sys.maxsize+1r) # should not raise OverflowError: Python int too large to convert to C long (0, 1) - sage: import mpmath # optional - mpmath - sage: mpmath.mp.prec = 1000 # optional - mpmath - sage: root = mpmath.findroot(lambda x: x^2 - 3, 2) # optional - mpmath - sage: len(str(root)) # optional - mpmath + + sage: import mpmath # needs mpmath + sage: mpmath.mp.prec = 1000 # needs mpmath + sage: root = mpmath.findroot(lambda x: x^2 - 3, 2) # needs mpmath + sage: len(str(root)) # needs mpmath 301 """ cdef Integer q = PY_NEW(Integer) @@ -3451,7 +3457,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): cdef long d, res if is_small_python_int(other): - d = PyInt_AS_LONG(other) + d = PyLong_AsLong(other) if d > 0: mpz_fdiv_qr_ui(q.value, r.value, self.value, d) elif d == 0: @@ -3696,44 +3702,46 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: n = next_prime(10^6)*next_prime(10^7); n.trial_division() # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: n = next_prime(10^6)*next_prime(10^7); n.trial_division() 1000003 - sage: (-n).trial_division() # optional - sage.libs.pari + sage: (-n).trial_division() 1000003 - sage: n.trial_division(bound=100) # optional - sage.libs.pari + sage: n.trial_division(bound=100) 10000049000057 - sage: n.trial_division(bound=-10) # optional - sage.libs.pari + sage: n.trial_division(bound=-10) Traceback (most recent call last): ... ValueError: bound must be positive - sage: n.trial_division(bound=0) # optional - sage.libs.pari + sage: n.trial_division(bound=0) Traceback (most recent call last): ... ValueError: bound must be positive - sage: ZZ(0).trial_division() # optional - sage.libs.pari + sage: ZZ(0).trial_division() Traceback (most recent call last): ... ValueError: self must be nonzero - sage: n = next_prime(10^5) * next_prime(10^40); n.trial_division() # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: n = next_prime(10^5) * next_prime(10^40); n.trial_division() 100003 - sage: n.trial_division(bound=10^4) # optional - sage.libs.pari + sage: n.trial_division(bound=10^4) 1000030000000000000000000000000000000012100363 - sage: (-n).trial_division(bound=10^4) # optional - sage.libs.pari + sage: (-n).trial_division(bound=10^4) 1000030000000000000000000000000000000012100363 - sage: (-n).trial_division() # optional - sage.libs.pari + sage: (-n).trial_division() 100003 - sage: n = 2 * next_prime(10^40); n.trial_division() # optional - sage.libs.pari + sage: n = 2 * next_prime(10^40); n.trial_division() 2 - sage: n = 3 * next_prime(10^40); n.trial_division() # optional - sage.libs.pari + sage: n = 3 * next_prime(10^40); n.trial_division() 3 - sage: n = 5 * next_prime(10^40); n.trial_division() # optional - sage.libs.pari + sage: n = 5 * next_prime(10^40); n.trial_division() 5 - sage: n = 2 * next_prime(10^4); n.trial_division() # optional - sage.libs.pari + sage: n = 2 * next_prime(10^4); n.trial_division() 2 - sage: n = 3 * next_prime(10^4); n.trial_division() # optional - sage.libs.pari + sage: n = 3 * next_prime(10^4); n.trial_division() 3 - sage: n = 5 * next_prime(10^4); n.trial_division() # optional - sage.libs.pari + sage: n = 5 * next_prime(10^4); n.trial_division() 5 You can specify a starting point:: @@ -3859,7 +3867,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: n = 2^100 - 1; n.factor() # optional - sage.libs.pari + sage: n = 2^100 - 1; n.factor() # needs sage.libs.pari 3 * 5^3 * 11 * 31 * 41 * 101 * 251 * 601 * 1801 * 4051 * 8101 * 268501 This factorization can be converted into a list of pairs `(p, @@ -3886,9 +3894,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): that appear in the factorization:: sage: n = 920384092842390423848290348203948092384082349082 - sage: n.factor(proof=False) # optional - sage.libs.pari + sage: n.factor(proof=False) # needs sage.libs.pari 2 * 11 * 1531 * 4402903 * 10023679 * 619162955472170540533894518173 - sage: n.factor(proof=True) # optional - sage.libs.pari + sage: n.factor(proof=True) # needs sage.libs.pari 2 * 11 * 1531 * 4402903 * 10023679 * 619162955472170540533894518173 We factor using trial division only:: @@ -3899,15 +3907,16 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): An example where FLINT is used:: sage: n = 82862385732327628428164127822 - sage: n.factor(algorithm='flint') # optional - sage.libs.flint + sage: n.factor(algorithm='flint') # needs sage.libs.flint 2 * 3 * 11 * 13 * 41 * 73 * 22650083 * 1424602265462161 We factor using a quadratic sieve algorithm:: - sage: p = next_prime(10^20) # optional - sage.libs.pari - sage: q = next_prime(10^21) # optional - sage.libs.pari - sage: n = p * q # optional - sage.libs.pari - sage: n.factor(algorithm='qsieve') # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: p = next_prime(10^20) + sage: q = next_prime(10^21) + sage: n = p * q + sage: n.factor(algorithm='qsieve') # needs sage.libs.flint doctest:... RuntimeWarning: the factorization returned by qsieve may be incomplete (the factors may not be prime) or even wrong; see qsieve? for details @@ -3915,10 +3924,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): We factor using the elliptic curve method:: - sage: p = next_prime(10^15) # optional - sage.libs.pari - sage: q = next_prime(10^21) # optional - sage.libs.pari - sage: n = p * q # optional - sage.libs.pari - sage: n.factor(algorithm='ecm') # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: p = next_prime(10^15) + sage: q = next_prime(10^21) + sage: n = p * q + sage: n.factor(algorithm='ecm') 1000000000000037 * 1000000000000000000117 TESTS:: @@ -4614,13 +4624,14 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: gamma(5) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: gamma(5) 24 - sage: gamma(0) # optional - sage.symbolic + sage: gamma(0) Infinity - sage: gamma(-1) # optional - sage.symbolic + sage: gamma(-1) Infinity - sage: gamma(-2^150) # optional - sage.symbolic + sage: gamma(-2^150) Infinity """ if mpz_sgn(self.value) > 0: @@ -4810,7 +4821,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: 144.perfect_power() # optional - sage.libs.pari + sage: 144.perfect_power() # needs sage.libs.pari (12, 2) sage: 1.perfect_power() (1, 1) @@ -4818,15 +4829,15 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): (0, 1) sage: (-1).perfect_power() (-1, 1) - sage: (-8).perfect_power() # optional - sage.libs.pari + sage: (-8).perfect_power() # needs sage.libs.pari (-2, 3) sage: (-4).perfect_power() (-4, 1) - sage: (101^29).perfect_power() # optional - sage.libs.pari + sage: (101^29).perfect_power() # needs sage.libs.pari (101, 29) - sage: (-243).perfect_power() # optional - sage.libs.pari + sage: (-243).perfect_power() # needs sage.libs.pari (-3, 5) - sage: (-64).perfect_power() # optional - sage.libs.pari + sage: (-64).perfect_power() # needs sage.libs.pari (-4, 3) TESTS:: @@ -4872,6 +4883,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: ZZ(5).global_height() 1.60943791243410 sage: ZZ(-2).global_height(prec=100) @@ -5135,55 +5147,57 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: 17.is_prime_power() # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: 17.is_prime_power() True - sage: 10.is_prime_power() # optional - sage.libs.pari + sage: 10.is_prime_power() False - sage: 64.is_prime_power() # optional - sage.libs.pari + sage: 64.is_prime_power() True - sage: (3^10000).is_prime_power() # optional - sage.libs.pari + sage: (3^10000).is_prime_power() True - sage: (10000).is_prime_power() # optional - sage.libs.pari + sage: (10000).is_prime_power() False - sage: (-3).is_prime_power() # optional - sage.libs.pari + sage: (-3).is_prime_power() False - sage: 0.is_prime_power() # optional - sage.libs.pari + sage: 0.is_prime_power() False - sage: 1.is_prime_power() # optional - sage.libs.pari + sage: 1.is_prime_power() False - sage: p = next_prime(10^20); p # optional - sage.libs.pari + sage: p = next_prime(10^20); p 100000000000000000039 - sage: p.is_prime_power() # optional - sage.libs.pari + sage: p.is_prime_power() True - sage: (p^97).is_prime_power() # optional - sage.libs.pari + sage: (p^97).is_prime_power() True - sage: (p + 1).is_prime_power() # optional - sage.libs.pari + sage: (p + 1).is_prime_power() False With the ``get_data`` keyword set to ``True``:: - sage: (3^100).is_prime_power(get_data=True) # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: (3^100).is_prime_power(get_data=True) (3, 100) - sage: 12.is_prime_power(get_data=True) # optional - sage.libs.pari + sage: 12.is_prime_power(get_data=True) (12, 0) - sage: (p^97).is_prime_power(get_data=True) # optional - sage.libs.pari + sage: (p^97).is_prime_power(get_data=True) (100000000000000000039, 97) - sage: q = p.next_prime(); q # optional - sage.libs.pari + sage: q = p.next_prime(); q 100000000000000000129 - sage: (p*q).is_prime_power(get_data=True) # optional - sage.libs.pari + sage: (p*q).is_prime_power(get_data=True) (10000000000000000016800000000000000005031, 0) The method works for large entries when ``proof=False``:: sage: proof.arithmetic(False) - sage: ((10^500 + 961)^4).is_prime_power() # optional - sage.libs.pari + sage: ((10^500 + 961)^4).is_prime_power() # needs sage.libs.pari True sage: proof.arithmetic(True) We check that :trac:`4777` is fixed:: sage: n = 150607571^14 - sage: n.is_prime_power() # optional - sage.libs.pari + sage: n.is_prime_power() # needs sage.libs.pari True TESTS:: @@ -5277,26 +5291,26 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: sage: z = 2^31 - 1 - sage: z.is_prime() # optional - sage.libs.pari + sage: z.is_prime() # needs sage.libs.pari True sage: z = 2^31 - sage: z.is_prime() # optional - sage.libs.pari + sage: z.is_prime() False sage: z = 7 - sage: z.is_prime() # optional - sage.libs.pari + sage: z.is_prime() True sage: z = -7 - sage: z.is_prime() # optional - sage.libs.pari + sage: z.is_prime() False - sage: z.is_irreducible() # optional - sage.libs.pari + sage: z.is_irreducible() True :: sage: z = 10^80 + 129 - sage: z.is_prime(proof=False) # optional - sage.libs.pari + sage: z.is_prime(proof=False) # needs sage.libs.pari True - sage: z.is_prime(proof=True) # optional - sage.libs.pari + sage: z.is_prime(proof=True) # needs sage.libs.pari True When starting Sage the arithmetic proof flag is True. We can change @@ -5305,12 +5319,12 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: proof.arithmetic() True sage: n = 10^100 + 267 - sage: timeit("n.is_prime()") # not tested # optional - sage.libs.pari + sage: timeit("n.is_prime()") # not tested # needs sage.libs.pari 5 loops, best of 3: 163 ms per loop sage: proof.arithmetic(False) sage: proof.arithmetic() False - sage: timeit("n.is_prime()") # not tested # optional - sage.libs.pari + sage: timeit("n.is_prime()") # not tested # needs sage.libs.pari 1000 loops, best of 3: 573 us per loop ALGORITHM: @@ -5327,7 +5341,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): ....: if tab[i]: ....: for j in range(2*i, size, i): ....: tab[j] = 0 - sage: all(ZZ(i).is_prime() == b for i,b in enumerate(tab)) # optional - sage.libs.pari + sage: all(ZZ(i).is_prime() == b for i,b in enumerate(tab)) # needs sage.libs.pari True """ if mpz_sgn(self.value) <= 0: @@ -5390,16 +5404,16 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: sage: z = 2^31 - 1 - sage: z.is_irreducible() # optional - sage.libs.pari + sage: z.is_irreducible() # needs sage.libs.pari True sage: z = 2^31 - sage: z.is_irreducible() # optional - sage.libs.pari + sage: z.is_irreducible() False sage: z = 7 - sage: z.is_irreducible() # optional - sage.libs.pari + sage: z.is_irreducible() True sage: z = -7 - sage: z.is_irreducible() # optional - sage.libs.pari + sage: z.is_irreducible() True """ cdef Integer n = self if self >= 0 else -self @@ -5419,10 +5433,10 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: sage: z = 2^31 - 1 - sage: z.is_pseudoprime() # optional - sage.libs.pari + sage: z.is_pseudoprime() # needs sage.libs.pari True sage: z = 2^31 - sage: z.is_pseudoprime() # optional - sage.libs.pari + sage: z.is_pseudoprime() # needs sage.libs.pari False """ return self.__pari__().ispseudoprime() @@ -5442,18 +5456,19 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: + sage: # needs sage.libs.pari sage: x = 10^200 + 357 - sage: x.is_pseudoprime() # optional - sage.libs.pari + sage: x.is_pseudoprime() True - sage: (x^12).is_pseudoprime_power() # optional - sage.libs.pari + sage: (x^12).is_pseudoprime_power() True - sage: (x^12).is_pseudoprime_power(get_data=True) # optional - sage.libs.pari + sage: (x^12).is_pseudoprime_power(get_data=True) (1000...000357, 12) - sage: (997^100).is_pseudoprime_power() # optional - sage.libs.pari + sage: (997^100).is_pseudoprime_power() True - sage: (998^100).is_pseudoprime_power() # optional - sage.libs.pari + sage: (998^100).is_pseudoprime_power() False - sage: ((10^1000 + 453)^2).is_pseudoprime_power() # optional - sage.libs.pari + sage: ((10^1000 + 453)^2).is_pseudoprime_power() True TESTS:: @@ -5462,7 +5477,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): False sage: (-1).is_pseudoprime_power() False - sage: 1.is_pseudoprime_power() # optional - sage.libs.pari + sage: 1.is_pseudoprime_power() # needs sage.libs.pari False """ return self.is_prime_power(proof=False, get_data=get_data) @@ -5529,26 +5544,27 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: + sage: n = 7 + sage: n.is_norm(QQ) + True + sage: n.is_norm(QQ, element=True) + (True, 7) + + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K = NumberField(x^2 - 2, 'beta') # optional - sage.rings.number_field + sage: K = NumberField(x^2 - 2, 'beta') sage: n = 4 - sage: n.is_norm(K) # optional - sage.rings.number_field + sage: n.is_norm(K) True - sage: 5.is_norm(K) # optional - sage.rings.number_field + sage: 5.is_norm(K) False - sage: 7.is_norm(QQ) - True - sage: n.is_norm(K, element=True) # optional - sage.rings.number_field + sage: n.is_norm(K, element=True) (True, -4*beta + 6) - sage: n.is_norm(K, element=True)[1].norm() # optional - sage.rings.number_field + sage: n.is_norm(K, element=True)[1].norm() 4 sage: n = 5 - sage: n.is_norm(K, element=True) # optional - sage.rings.number_field + sage: n.is_norm(K, element=True) (False, None) - sage: n = 7 - sage: n.is_norm(QQ, element=True) - (True, 7) - """ from sage.rings.rational_field import QQ return QQ(self).is_norm(K, element=element, proof=proof) @@ -5559,9 +5575,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: 3._bnfisnorm(QuadraticField(-1, 'i')) # optional - sage.rings.number_field + sage: 3._bnfisnorm(QuadraticField(-1, 'i')) # needs sage.rings.number_field (1, 3) - sage: 7._bnfisnorm(CyclotomicField(7)) # optional - sage.rings.number_field + sage: 7._bnfisnorm(CyclotomicField(7)) # needs sage.rings.number_field (zeta7^5 - zeta7^2, 1) """ from sage.rings.rational_field import QQ @@ -5662,11 +5678,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: (-163).class_number() # optional - sage.libs.pari + sage: (-163).class_number() # needs sage.libs.pari 1 - sage: (-104).class_number() # optional - sage.libs.pari + sage: (-104).class_number() # needs sage.libs.pari 6 - sage: [((4*n + 1), (4*n + 1).class_number()) for n in [21..29]] # optional - sage.libs.pari + sage: [((4*n + 1), (4*n + 1).class_number()) for n in [21..29]] # needs sage.libs.pari [(85, 2), (89, 1), (93, 1), @@ -5748,8 +5764,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): 2 sage: a.squarefree_part(bound=2**14) 2 - sage: a = 7^3 * next_prime(2^100)^2 * next_prime(2^200) # optional - sage.libs.pari - sage: a / a.squarefree_part(bound=1000) # optional - sage.libs.pari + sage: a = 7^3 * next_prime(2^100)^2 * next_prime(2^200) # needs sage.libs.pari + sage: a / a.squarefree_part(bound=1000) # needs sage.libs.pari 49 """ cdef Integer z @@ -5796,17 +5812,18 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: (-37).next_probable_prime() # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: (-37).next_probable_prime() 2 - sage: (100).next_probable_prime() # optional - sage.libs.pari + sage: (100).next_probable_prime() 101 - sage: (2^512).next_probable_prime() # optional - sage.libs.pari + sage: (2^512).next_probable_prime() 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084171 - sage: 0.next_probable_prime() # optional - sage.libs.pari + sage: 0.next_probable_prime() 2 - sage: 126.next_probable_prime() # optional - sage.libs.pari + sage: 126.next_probable_prime() 127 - sage: 144168.next_probable_prime() # optional - sage.libs.pari + sage: 144168.next_probable_prime() 144169 """ return Integer( self.__pari__().nextprime(True) ) @@ -5825,23 +5842,23 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: 100.next_prime() # optional - sage.libs.pari + sage: 100.next_prime() # needs sage.libs.pari 101 - sage: (10^50).next_prime() # optional - sage.libs.pari + sage: (10^50).next_prime() # needs sage.libs.pari 100000000000000000000000000000000000000000000000151 Use ``proof=False``, which is way faster since it does not need a primality proof:: - sage: b = (2^1024).next_prime(proof=False) # optional - sage.libs.pari - sage: b - 2^1024 # optional - sage.libs.pari + sage: b = (2^1024).next_prime(proof=False) # needs sage.libs.pari + sage: b - 2^1024 # needs sage.libs.pari 643 :: - sage: Integer(0).next_prime() # optional - sage.libs.pari + sage: Integer(0).next_prime() # needs sage.libs.pari 2 - sage: Integer(1001).next_prime() # optional - sage.libs.pari + sage: Integer(1001).next_prime() # needs sage.libs.pari 1009 """ # Use PARI to compute the next *pseudo*-prime @@ -5870,11 +5887,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: 10.previous_prime() # optional - sage.libs.pari + sage: 10.previous_prime() # needs sage.libs.pari 7 - sage: 7.previous_prime() # optional - sage.libs.pari + sage: 7.previous_prime() # needs sage.libs.pari 5 - sage: 14376485.previous_prime() # optional - sage.libs.pari + sage: 14376485.previous_prime() # needs sage.libs.pari 14376463 sage: 2.previous_prime() @@ -5885,8 +5902,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): An example using ``proof=False``, which is way faster since it does not need a primality proof:: - sage: b = (2^1024).previous_prime(proof=False) # optional - sage.libs.pari - sage: 2^1024 - b # optional - sage.libs.pari + sage: b = (2^1024).previous_prime(proof=False) # needs sage.libs.pari + sage: 2^1024 - b # needs sage.libs.pari 105 """ if mpz_cmp_ui(self.value, 2) <= 0: @@ -5926,23 +5943,23 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: (-1).next_prime_power() 2 - sage: 2.next_prime_power() # optional - sage.libs.pari + sage: 2.next_prime_power() 3 - sage: 103.next_prime_power() # optional - sage.libs.pari + sage: 103.next_prime_power() # needs sage.libs.pari 107 - sage: 107.next_prime_power() # optional - sage.libs.pari + sage: 107.next_prime_power() 109 - sage: 2044.next_prime_power() # optional - sage.libs.pari + sage: 2044.next_prime_power() # needs sage.libs.pari 2048 TESTS:: - sage: [(2**k - 1).next_prime_power() for k in range(1,10)] # optional - sage.libs.pari + sage: [(2**k - 1).next_prime_power() for k in range(1,10)] [2, 4, 8, 16, 32, 64, 128, 256, 512] - sage: [(2**k).next_prime_power() for k in range(10)] # optional - sage.libs.pari + sage: [(2**k).next_prime_power() for k in range(10)] # needs sage.libs.pari [2, 3, 5, 9, 17, 37, 67, 131, 257, 521] - sage: for _ in range(10): # optional - sage.libs.pari + sage: for _ in range(10): # needs sage.libs.pari ....: n = ZZ.random_element(2**256).next_prime_power() ....: m = n.next_prime_power().previous_prime_power() ....: assert m == n, "problem with n = {}".format(n) @@ -5990,13 +6007,14 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: 3.previous_prime_power() # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: 3.previous_prime_power() 2 - sage: 103.previous_prime_power() # optional - sage.libs.pari + sage: 103.previous_prime_power() 101 - sage: 107.previous_prime_power() # optional - sage.libs.pari + sage: 107.previous_prime_power() 103 - sage: 2044.previous_prime_power() # optional - sage.libs.pari + sage: 2044.previous_prime_power() 2039 sage: 2.previous_prime_power() @@ -6006,12 +6024,12 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): TESTS:: - sage: [(2**k + 1).previous_prime_power() for k in range(1,10)] # optional - sage.libs.pari + sage: [(2**k + 1).previous_prime_power() for k in range(1,10)] [2, 4, 8, 16, 32, 64, 128, 256, 512] - sage: [(2**k).previous_prime_power() for k in range(2, 10)] # optional - sage.libs.pari + sage: [(2**k).previous_prime_power() for k in range(2, 10)] # needs sage.libs.pari [3, 7, 13, 31, 61, 127, 251, 509] - sage: for _ in range(10): # optional - sage.libs.pari + sage: for _ in range(10): # needs sage.libs.pari ....: n = ZZ.random_element(3,2**256).previous_prime_power() ....: m = n.previous_prime_power().next_prime_power() ....: assert m == n, "problem with n = {}".format(n) @@ -6080,11 +6098,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: 100.is_squarefree() # optional - sage.libs.pari + sage: 100.is_squarefree() # needs sage.libs.pari False - sage: 102.is_squarefree() # optional - sage.libs.pari + sage: 102.is_squarefree() # needs sage.libs.pari True - sage: 0.is_squarefree() # optional - sage.libs.pari + sage: 0.is_squarefree() # needs sage.libs.pari False """ return self.__pari__().issquarefree() @@ -6129,11 +6147,11 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: (-4).is_fundamental_discriminant() + sage: (-4).is_fundamental_discriminant() # needs sage.libs.pari True sage: (-12).is_fundamental_discriminant() False - sage: 101.is_fundamental_discriminant() + sage: 101.is_fundamental_discriminant() # needs sage.libs.pari True TESTS:: @@ -6142,7 +6160,8 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): False sage: 1.is_fundamental_discriminant() False - sage: len([D for D in srange(-100,100) if D.is_fundamental_discriminant()]) + sage: len([D for D in srange(-100,100) # needs sage.libs.pari + ....: if D.is_fundamental_discriminant()]) 61 """ @@ -6163,16 +6182,16 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: sage: n = 9390823 - sage: m = n.__pari__(); m # optional - sage.libs.pari + sage: m = n.__pari__(); m # needs sage.libs.pari 9390823 - sage: type(m) # optional - sage.libs.pari + sage: type(m) # needs sage.libs.pari TESTS:: sage: n = 10^10000000 - sage: m = n.__pari__() # crash from trac 875 # optional - sage.libs.pari - sage: m % 1234567 # optional - sage.libs.pari + sage: m = n.__pari__() # crash from trac 875 # needs sage.libs.pari + sage: m % 1234567 # needs sage.libs.pari 1041334 """ @@ -6202,19 +6221,18 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): EXAMPLES:: - sage: import numpy # optional - numpy - sage: numpy.array([1, 2, 3]) # optional - numpy + sage: # needs numpy + sage: import numpy + sage: numpy.array([1, 2, 3]) array([1, 2, 3]) - sage: numpy.array([1, 2, 3]).dtype # optional - numpy + sage: numpy.array([1, 2, 3]).dtype dtype('int32') # 32-bit dtype('int64') # 64-bit - - sage: numpy.array(2**40).dtype # optional - numpy + sage: numpy.array(2**40).dtype dtype('int64') - sage: numpy.array(2**400).dtype # optional - numpy + sage: numpy.array(2**400).dtype dtype('O') - - sage: numpy.array([1,2,3,0.1]).dtype # optional - numpy + sage: numpy.array([1,2,3,0.1]).dtype dtype('float64') """ if mpz_fits_slong_p(self.value): @@ -6241,11 +6259,12 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): '117' Large integers use hex: - sage: m = 3^(2^20) # optional - magma - sage: s = m._magma_init_(magma) # optional - magma - sage: 'StringToInteger' in s # optional - magma + sage: # optional - magma + sage: m = 3^(2^20) + sage: s = m._magma_init_(magma) + sage: 'StringToInteger' in s True - sage: magma(m).sage() == m # optional - magma + sage: magma(m).sage() == m True """ if self.ndigits(2) > 10000: @@ -6377,19 +6396,19 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): 12 sage: sqrt(Integer(144)) 12 - sage: Integer(102).sqrt() # optional - sage.symbolic + sage: Integer(102).sqrt() # needs sage.symbolic sqrt(102) :: sage: n = 2 - sage: n.sqrt(all=True) # optional - sage.symbolic + sage: n.sqrt(all=True) # needs sage.symbolic [sqrt(2), -sqrt(2)] - sage: n.sqrt(prec=10) + sage: n.sqrt(prec=10) # needs sage.rings.real_mpfr 1.4 - sage: n.sqrt(prec=100) + sage: n.sqrt(prec=100) # needs sage.rings.real_mpfr 1.4142135623730950488016887242 - sage: n.sqrt(prec=100, all=True) + sage: n.sqrt(prec=100, all=True) # needs sage.rings.real_mpfr [1.4142135623730950488016887242, -1.4142135623730950488016887242] sage: n.sqrt(extend=False) Traceback (most recent call last): @@ -6406,13 +6425,13 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): TESTS:: - sage: type(5.sqrt()) # optional - sage.symbolic + sage: type(5.sqrt()) # needs sage.symbolic - sage: type(5.sqrt(prec=53)) + sage: type(5.sqrt(prec=53)) # needs sage.rings.real_mpfr - sage: type((-5).sqrt(prec=53)) + sage: type((-5).sqrt(prec=53)) # needs sage.rings.real_mpfr - sage: type(0.sqrt(prec=53)) + sage: type(0.sqrt(prec=53)) # needs sage.rings.real_mpfr Check that :trac:`9466` and :trac:`26509` are fixed:: @@ -6654,7 +6673,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: try: ....: print('Possible error output from gmp', flush=True) ....: 1 << (2^60) - ....: except (MemoryError, OverflowError, RuntimeError): + ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError): ....: pass ....: else: ....: print("Failed to raise exception") @@ -6664,7 +6683,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): if type(y) is int: # For a Python int, we can just use the Python/C API. - n = PyInt_AS_LONG(y) + n = PyLong_AsLong(y) else: # If it's not already an Integer, try to convert it. if not isinstance(y, Integer): @@ -7030,7 +7049,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: 10.binomial(2) 45 - sage: 10.binomial(2, algorithm='pari') # optional - sage.libs.pari + sage: 10.binomial(2, algorithm='pari') # needs sage.libs.pari 45 sage: 10.binomial(-2) 0 @@ -7072,7 +7091,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): check for reliable interrupting, see :trac:`18919`:: sage: from cysignals import AlarmInterrupt - sage: for i in [1..10]: # long time (5s) # optional - sage.libs.pari + sage: for i in [1..10]: # long time (5s) # needs sage.libs.pari ....: try: ....: alarm(i/11) ....: (2^100).binomial(2^22, algorithm='pari') @@ -7407,7 +7426,7 @@ cdef class int_to_Z(Morphism): if type(a) is not int: raise TypeError("must be a Python int object") - return smallInteger(PyInt_AS_LONG(a)) + return smallInteger(PyLong_AsLong(a)) def _repr_type(self): """ @@ -7680,7 +7699,8 @@ cdef Integer zero = the_integer_ring._zero_element cdef Integer one = the_integer_ring._one_element # pool of small integer for fast sign computation -# Use the same defaults as Python, documented at https://docs.python.org/2/c-api/int.html#PyInt_FromLong +# Use the same defaults as Python3 documented at +# https://docs.python.org/3/c-api/long.html#c.PyLong_FromLong DEF small_pool_min = -5 DEF small_pool_max = 256 # we could use the above zero and one here diff --git a/src/sage/rings/integer_fake.pxd b/src/sage/rings/integer_fake.pxd index d900190f74d..4a02062c64b 100644 --- a/src/sage/rings/integer_fake.pxd +++ b/src/sage/rings/integer_fake.pxd @@ -17,7 +17,7 @@ This provides two functions: TESTS:: - sage: cython( # optional - sage.misc.cython + sage: cython( # needs sage.misc.cython ....: ''' ....: from sage.rings.integer_fake cimport Integer_AS_MPZ, is_Integer ....: from sage.rings.integer cimport Integer diff --git a/src/sage/rings/integer_ring.pyx b/src/sage/rings/integer_ring.pyx index b4046098436..c7a05a13e16 100644 --- a/src/sage/rings/integer_ring.pyx +++ b/src/sage/rings/integer_ring.pyx @@ -43,7 +43,7 @@ other types will also coerce to the integers, when it makes sense. # http://www.gnu.org/licenses/ #***************************************************************************** -from cpython.int cimport * +from cpython.long cimport * from cpython.list cimport * from cpython.object cimport Py_NE @@ -245,7 +245,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): 17 sage: Z(Mod(19,23)) 19 - sage: Z(2 + 3*5 + O(5^3)) # optional - sage.rings.padics + sage: Z(2 + 3*5 + O(5^3)) # needs sage.rings.padics 17 Arbitrary numeric bases are supported; strings or list of integers @@ -394,19 +394,21 @@ cdef class IntegerRing_class(PrincipalIdealDomain): EXAMPLES:: - sage: ZZ[sqrt(2), sqrt(3)] # optional - sage.rings.number_field sage.symbolic - Relative Order in Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field sage: ZZ['x'] Univariate Polynomial Ring in x over Integer Ring sage: ZZ['x,y'] Multivariate Polynomial Ring in x, y over Integer Ring - sage: R = ZZ[sqrt(5) + 1]; R # optional - sage.rings.number_field sage.symbolic + + sage: # needs sage.rings.number_field sage.symbolic + sage: ZZ[sqrt(2), sqrt(3)] + Relative Order in Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field + sage: R = ZZ[sqrt(5) + 1]; R Order in Number Field in a with defining polynomial x^2 - 2*x - 4 with a = 3.236067977499790? - sage: R.is_maximal() # optional - sage.rings.number_field sage.symbolic + sage: R.is_maximal() False - sage: R = ZZ[(1 + sqrt(5))/2]; R # optional - sage.rings.number_field sage.symbolic + sage: R = ZZ[(1 + sqrt(5))/2]; R Order in Number Field in a with defining polynomial x^2 - x - 1 with a = 1.618033988749895? - sage: R.is_maximal() # optional - sage.rings.number_field sage.symbolic + sage: R.is_maximal() True """ if x in self: @@ -478,7 +480,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): L = [] if type(step) is int: - istep = PyInt_AS_LONG(step) + istep = PyLong_AsLong(step) step_sign = istep else: zstep = step @@ -531,7 +533,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): sage: ZZ.coerce(int(5)) # indirect doctest 5 - sage: ZZ.coerce(GF(7)(2)) # optional - sage.rings.finite_rings + sage: ZZ.coerce(GF(7)(2)) Traceback (most recent call last): ... TypeError: no canonical coercion from Finite Field of size 7 to Integer Ring @@ -553,14 +555,15 @@ cdef class IntegerRing_class(PrincipalIdealDomain): Coercions are available from numpy integer types:: - sage: import numpy # optional - numpy - sage: ZZ.coerce(numpy.int8('1')) # optional - numpy + sage: # needs numpy + sage: import numpy + sage: ZZ.coerce(numpy.int8('1')) 1 - sage: ZZ.coerce(numpy.int32('32')) # optional - numpy + sage: ZZ.coerce(numpy.int32('32')) 32 - sage: ZZ.coerce(numpy.int64('-12')) # optional - numpy + sage: ZZ.coerce(numpy.int64('-12')) -12 - sage: ZZ.coerce(numpy.uint64('11')) # optional - numpy + sage: ZZ.coerce(numpy.uint64('11')) 11 TESTS:: @@ -600,10 +603,11 @@ cdef class IntegerRing_class(PrincipalIdealDomain): - ``x``, ``y`` integers -- bounds for the result. - ``distribution``-- a string: - - ``'uniform'`` - - ``'mpz_rrandomb'`` - - ``'1/n'`` - - ``'gaussian'`` + + - ``'uniform'`` + - ``'mpz_rrandomb'`` + - ``'1/n'`` + - ``'gaussian'`` OUTPUT: @@ -718,7 +722,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): We return a sample from a discrete Gaussian distribution:: - sage: ZZ.random_element(11.0, distribution="gaussian").parent() is ZZ + sage: ZZ.random_element(11.0, distribution="gaussian").parent() is ZZ # needs sage.modules True TESTS: @@ -727,7 +731,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): sage: ZZ.random_element(5, -5, distribution="1/n").parent() is ZZ True - sage: ZZ.random_element(5, -5, distribution="gaussian").parent() is ZZ + sage: ZZ.random_element(5, -5, distribution="gaussian").parent() is ZZ # needs sage.modules True sage: ZZ.random_element(5, -5, distribution="mpz_rrandomb").parent() is ZZ True @@ -923,9 +927,9 @@ cdef class IntegerRing_class(PrincipalIdealDomain): EXAMPLES:: sage: x = polygen(ZZ, 'x') - sage: ZZ.extension(x^2 - 5, 'a') # optional - sage.rings.number_field + sage: ZZ.extension(x^2 - 5, 'a') # needs sage.rings.number_field Order in Number Field in a with defining polynomial x^2 - 5 - sage: ZZ.extension([x^2 + 1, x^2 + 2], 'a,b') # optional - sage.rings.number_field + sage: ZZ.extension([x^2 + 1, x^2 + 2], 'a,b') # needs sage.rings.number_field Relative Order in Number Field in a with defining polynomial x^2 + 1 over its base field """ @@ -979,40 +983,41 @@ cdef class IntegerRing_class(PrincipalIdealDomain): EXAMPLES:: - sage: F = ZZ.residue_field(61); F # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: F = ZZ.residue_field(61); F Residue field of Integers modulo 61 - sage: pi = F.reduction_map(); pi # optional - sage.libs.pari + sage: pi = F.reduction_map(); pi Partially defined reduction map: From: Rational Field To: Residue field of Integers modulo 61 - sage: pi(123/234) # optional - sage.libs.pari + sage: pi(123/234) 6 - sage: pi(1/61) # optional - sage.libs.pari + sage: pi(1/61) Traceback (most recent call last): ... ZeroDivisionError: Cannot reduce rational 1/61 modulo 61: it has negative valuation - sage: lift = F.lift_map(); lift # optional - sage.libs.pari + sage: lift = F.lift_map(); lift Lifting map: From: Residue field of Integers modulo 61 To: Integer Ring - sage: lift(F(12345/67890)) # optional - sage.libs.pari + sage: lift(F(12345/67890)) 33 - sage: (12345/67890) % 61 # optional - sage.libs.pari + sage: (12345/67890) % 61 33 Construction can be from a prime ideal instead of a prime:: - sage: ZZ.residue_field(ZZ.ideal(97)) # optional - sage.libs.pari + sage: ZZ.residue_field(ZZ.ideal(97)) Residue field of Integers modulo 97 TESTS:: - sage: ZZ.residue_field(ZZ.ideal(96)) # optional - sage.libs.pari + sage: ZZ.residue_field(ZZ.ideal(96)) Traceback (most recent call last): ... TypeError: Principal ideal (96) of Integer Ring is not prime - sage: ZZ.residue_field(96) # optional - sage.libs.pari + sage: ZZ.residue_field(96) Traceback (most recent call last): ... TypeError: 96 is not prime @@ -1163,7 +1168,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): sage: ZZ.completion(infinity, 53) Integer Ring - sage: ZZ.completion(5, 15, {'print_mode': 'bars'}) # optional - sage.rings.padics + sage: ZZ.completion(5, 15, {'print_mode': 'bars'}) # needs sage.rings.padics 5-adic Ring with capped relative precision 15 """ if p == sage.rings.infinity.Infinity: @@ -1276,43 +1281,44 @@ cdef class IntegerRing_class(PrincipalIdealDomain): TESTS:: + sage: # needs sage.libs.pari sage: R. = PolynomialRing(ZZ, sparse=True) sage: p = (x + 1)^23 * (x - 1)^23 * (x - 100) * (x + 5445)^5 - sage: ZZ._roots_univariate_polynomial(p) # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p) [(100, 1), (-5445, 5), (1, 23), (-1, 23)] sage: p *= (1 + x^3458645 - 76*x^3435423343 + x^45346567867756556) - sage: ZZ._roots_univariate_polynomial(p) # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p) [(1, 23), (-1, 23), (100, 1), (-5445, 5)] sage: p *= x^156468451540687043504386074354036574634735074 - sage: ZZ._roots_univariate_polynomial(p) # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p) [(0, 156468451540687043504386074354036574634735074), (1, 23), (-1, 23), (100, 1), (-5445, 5)] - sage: ZZ._roots_univariate_polynomial(p, multiplicities=False) # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p, multiplicities=False) [0, 1, -1, 100, -5445] + sage: # needs sage.libs.pari sage: R. = PolynomialRing(ZZ, sparse=False) sage: p = (x + 1)^23 * (x - 1)^23 * (x - 100) * (x + 5445)^5 - sage: ZZ._roots_univariate_polynomial(p) # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p) [(100, 1), (-5445, 5), (1, 23), (-1, 23)] - sage: ZZ._roots_univariate_polynomial(p, multiplicities=False) # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p, multiplicities=False) [100, -5445, 1, -1] - - sage: ZZ._roots_univariate_polynomial(p, algorithm="sparse") # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p, algorithm="sparse") [(100, 1), (-5445, 5), (1, 23), (-1, 23)] - sage: ZZ._roots_univariate_polynomial(p, algorithm="dense") # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p, algorithm="dense") [(100, 1), (-5445, 5), (1, 23), (-1, 23)] - sage: ZZ._roots_univariate_polynomial(p, algorithm="foobar") # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p, algorithm="foobar") Traceback (most recent call last): ... ValueError: unknown algorithm 'foobar' - sage: p = x^20 * p - sage: ZZ._roots_univariate_polynomial(p, algorithm="sparse") # optional - sage.libs.pari + sage: p = x^20 * p # needs sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p, algorithm="sparse") # needs sage.libs.pari [(0, 20), (100, 1), (-5445, 5), (1, 23), (-1, 23)] - sage: ZZ._roots_univariate_polynomial(p, algorithm="dense") # optional - sage.libs.pari + sage: ZZ._roots_univariate_polynomial(p, algorithm="dense") # needs sage.libs.pari [(100, 1), (-5445, 5), (0, 20), (1, 23), (-1, 23)] """ deg = p.degree() @@ -1465,7 +1471,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): EXAMPLES:: - sage: gap(ZZ) # indirect doctest # optional - sage.libs.gap + sage: gap(ZZ) # indirect doctest # needs sage.libs.gap Integers """ return 'Integers' @@ -1521,7 +1527,7 @@ cdef class IntegerRing_class(PrincipalIdealDomain): EXAMPLES:: - sage: ZZ._sympy_() # optional - sympy + sage: ZZ._sympy_() # needs sympy Integers """ from sympy import Integers @@ -1551,9 +1557,9 @@ cdef class IntegerRing_class(PrincipalIdealDomain): EXAMPLES:: - sage: v = ZZ.valuation(3); v # optional - sage.rings.padics + sage: v = ZZ.valuation(3); v # needs sage.rings.padics 3-adic valuation - sage: v(3) # optional - sage.rings.padics + sage: v(3) # needs sage.rings.padics 1 .. SEEALSO:: diff --git a/src/sage/rings/invariants/invariant_theory.py b/src/sage/rings/invariants/invariant_theory.py index f9b7f6a561b..a2ee2268c6f 100644 --- a/src/sage/rings/invariants/invariant_theory.py +++ b/src/sage/rings/invariants/invariant_theory.py @@ -214,14 +214,15 @@ def transvectant(f, g, h=1, scale='default'): factor will not be invertible in that case. The scale argument ``'none'`` can be used to compute the transvectant in this case:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: f = AlgebraicForm(2, 5, a0*x1^5 + a1*x1^4*x0 + a2*x1^3*x0^2 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(5)[] + sage: f = AlgebraicForm(2, 5, a0*x1^5 + a1*x1^4*x0 + a2*x1^3*x0^2 ....: + a3*x1^2*x0^3 + a4*x1*x0^4 + a5*x0^5, x0, x1) - sage: transvectant(f, f, 4) # optional - sage.rings.finite_rings + sage: transvectant(f, f, 4) Traceback (most recent call last): ... ZeroDivisionError - sage: transvectant(f, f, 4, scale='none') # optional - sage.rings.finite_rings + sage: transvectant(f, f, 4, scale='none') Binary quadratic given by -a3^2*x0^2 + a2*a4*x0^2 + a2*a3*x0*x1 - a1*a4*x0*x1 - a2^2*x1^2 + a1*a3*x1^2 @@ -278,7 +279,7 @@ def transvectant(f, g, h=1, scale='default'): elif scale == 'none': scalar = 1 else: - raise ValueError('unknown scale type: %s' %scale) + raise ValueError('unknown scale type: %s' % scale) def diff(j): df = f.form().derivative(x,j).derivative(y,h-j) @@ -533,7 +534,7 @@ def __init__(self, n, d, polynomial, *args, **kwds): elif len(variables) == n-1: variables = variables + (None,) else: - raise ValueError('need '+str(n)+' or '+ + raise ValueError('need '+str(n)+' or ' + str(n-1)+' variables, got '+str(variables)) ring = polynomial.parent() homogeneous = variables[-1] is not None @@ -562,7 +563,7 @@ def _check(self): deg = sum([ e[R.gens().index(x)] for x in self._variables if x is not None ]) degrees.add(deg) - if self._homogeneous and len(degrees)>1: + if self._homogeneous and len(degrees) > 1: raise ValueError('polynomial is not homogeneous') if degrees == set() or \ (self._homogeneous and degrees == set([self._d])) or \ @@ -1492,7 +1493,7 @@ def EisensteinE(self): """ a = self.scaled_coeffs() assert len(a) == 5 - return a[0]*a[3]**2 +a[1]**2*a[4] -a[0]*a[2]*a[4] -2*a[1]*a[2]*a[3] +a[2]**3 + return a[0]*a[3]**2 + a[1]**2*a[4] - a[0]*a[2]*a[4] - 2*a[1]*a[2]*a[3] + a[2]**3 @cached_method def g_covariant(self): @@ -2442,9 +2443,9 @@ def arithmetic_invariants(self): invariants = {} invariants['I4'] = R(2)**-1*5**4*clebsch['A'] invariants['I8'] = 5**5 * (R(2)**-1*47*clebsch['A']**2 - -2**2*clebsch['B']) + - 2**2*clebsch['B']) invariants['I12'] = 5**10 * (R(2)**-1*3*clebsch['A']**3 - -2**5*R(3)**-1*clebsch['C']) + - 2**5*R(3)**-1*clebsch['C']) invariants['I18'] = 2**8*R(3)**-1*5**15 * clebsch['R'] return invariants @@ -2526,9 +2527,9 @@ def _covariant_conic(A_scaled_coeffs, B_scaled_coeffs, monomials): (b0*c1+c0*b1-2*f0*f1) * monomials[0] + (a0*c1+c0*a1-2*g0*g1) * monomials[1] + (a0*b1+b0*a1-2*h0*h1) * monomials[2] + - 2*(f0*g1+g0*f1 -c0*h1-h0*c1) * monomials[3] + - 2*(h0*f1+f0*h1 -b0*g1-g0*b1) * monomials[4] + - 2*(g0*h1+h0*g1 -a0*f1-f0*a1) * monomials[5] ) + 2*(f0*g1+g0*f1 - c0*h1-h0*c1) * monomials[3] + + 2*(h0*f1+f0*h1 - b0*g1-g0*b1) * monomials[4] + + 2*(g0*h1+h0*g1 - a0*f1-f0*a1) * monomials[5] ) ###################################################################### @@ -2856,12 +2857,12 @@ def S_invariant(self): """ a,b,c,a2,a3,b1,b3,c1,c2,m = self.scaled_coeffs() S = ( a*b*c*m-(b*c*a2*a3+c*a*b1*b3+a*b*c1*c2) - -m*(a*b3*c2+b*c1*a3+c*a2*b1) - +(a*b1*c2**2+a*c1*b3**2+b*a2*c1**2+b*c2*a3**2+c*b3*a2**2+c*a3*b1**2) - -m**4+2*m**2*(b1*c1+c2*a2+a3*b3) - -3*m*(a2*b3*c1+a3*b1*c2) - -(b1**2*c1**2+c2**2*a2**2+a3**2*b3**2) - +(c2*a2*a3*b3+a3*b3*b1*c1+b1*c1*c2*a2) ) + - m*(a*b3*c2+b*c1*a3+c*a2*b1) + + (a*b1*c2**2+a*c1*b3**2+b*a2*c1**2+b*c2*a3**2+c*b3*a2**2+c*a3*b1**2) + - m**4+2*m**2*(b1*c1+c2*a2+a3*b3) + - 3*m*(a2*b3*c1+a3*b1*c2) + - (b1**2*c1**2+c2**2*a2**2+a3**2*b3**2) + + (c2*a2*a3*b3+a3*b3*b1*c1+b1*c1*c2*a2) ) return S def T_invariant(self): @@ -2882,35 +2883,35 @@ def T_invariant(self): """ a,b,c,a2,a3,b1,b3,c1,c2,m = self.scaled_coeffs() T = ( a**2*b**2*c**2-6*a*b*c*(a*b3*c2+b*c1*a3+c*a2*b1) - -20*a*b*c*m**3+12*a*b*c*m*(b1*c1+c2*a2+a3*b3) - +6*a*b*c*(a2*b3*c1+a3*b1*c2)+ - 4*(a**2*b*c2**3+a**2*c*b3**3+b**2*c*a3**3+ + - 20*a*b*c*m**3+12*a*b*c*m*(b1*c1+c2*a2+a3*b3) + + 6*a*b*c*(a2*b3*c1+a3*b1*c2) + + 4*(a**2*b*c2**3+a**2*c*b3**3+b**2*c*a3**3 + b**2*a*c1**3+c**2*a*b1**3+c**2*b*a2**3) - +36*m**2*(b*c*a2*a3+c*a*b1*b3+a*b*c1*c2) - -24*m*(b*c*b1*a3**2+b*c*c1*a2**2+c*a*c2*b1**2+c*a*a2*b3**2+a*b*a3*c2**2+ + + 36*m**2*(b*c*a2*a3+c*a*b1*b3+a*b*c1*c2) + - 24*m*(b*c*b1*a3**2+b*c*c1*a2**2+c*a*c2*b1**2+c*a*a2*b3**2+a*b*a3*c2**2 + a*b*b3*c1**2) - -3*(a**2*b3**2*c2**2+b**2*c1**2*a3**2+c**2*a2**2*b1**2)+ + - 3*(a**2*b3**2*c2**2+b**2*c1**2*a3**2+c**2*a2**2*b1**2) + 18*(b*c*b1*c1*a2*a3+c*a*c2*a2*b3*b1+a*b*a3*b3*c1*c2) - -12*(b*c*c2*a3*a2**2+b*c*b3*a2*a3**2+c*a*c1*b3*b1**2+ + - 12*(b*c*c2*a3*a2**2+b*c*b3*a2*a3**2+c*a*c1*b3*b1**2 + c*a*a3*b1*b3**2+a*b*a2*c1*c2**2+a*b*b1*c2*c1**2) - -12*m**3*(a*b3*c2+b*c1*a3+c*a2*b1) - +12*m**2*(a*b1*c2**2+a*c1*b3**2+b*a2*c1**2+ + - 12*m**3*(a*b3*c2+b*c1*a3+c*a2*b1) + + 12*m**2*(a*b1*c2**2+a*c1*b3**2+b*a2*c1**2 + b*c2*a3**2+c*b3*a2**2+c*a3*b1**2) - -60*m*(a*b1*b3*c1*c2+b*c1*c2*a2*a3+c*a2*a3*b1*b3) - +12*m*(a*a2*b3*c2**2+a*a3*c2*b3**2+b*b3*c1*a3**2+ + - 60*m*(a*b1*b3*c1*c2+b*c1*c2*a2*a3+c*a2*a3*b1*b3) + + 12*m*(a*a2*b3*c2**2+a*a3*c2*b3**2+b*b3*c1*a3**2 + b*b1*a3*c1**2+c*c1*a2*b1**2+c*c2*b1*a2**2) - +6*(a*b3*c2+b*c1*a3+c*a2*b1)*(a2*b3*c1+a3*b1*c2) - +24*(a*b1*b3**2*c1**2+a*c1*c2**2*b1**2+b*c2*c1**2*a2**2 - +b*a2*a3**2*c2**2+c*a3*a2**2*b3**2+c*b3*b1**2*a3**2) - -12*(a*a2*b1*c2**3+a*a3*c1*b3**3+b*b3*c2*a3**3+b*b1*a2*c1**3 - +c*c1*a3*b1**3+c*c2*b3*a2**3) - -8*m**6+24*m**4*(b1*c1+c2*a2+a3*b3)-36*m**3*(a2*b3*c1+a3*b1*c2) - -12*m**2*(b1*c1*c2*a2+c2*a2*a3*b3+a3*b3*b1*c1) - -24*m**2*(b1**2*c1**2+c2**2*a2**2+a3**2*b3**2) - +36*m*(a2*b3*c1+a3*b1*c2)*(b1*c1+c2*a2+a3*b3) - +8*(b1**3*c1**3+c2**3*a2**3+a3**3*b3**3) - -27*(a2**2*b3**2*c1**2+a3**2*b1**2*c2**2)-6*b1*c1*c2*a2*a3*b3 - -12*(b1**2*c1**2*c2*a2+b1**2*c1**2*a3*b3+c2**2*a2**2*a3*b3+ + + 6*(a*b3*c2+b*c1*a3+c*a2*b1)*(a2*b3*c1+a3*b1*c2) + + 24*(a*b1*b3**2*c1**2+a*c1*c2**2*b1**2+b*c2*c1**2*a2**2 + + b*a2*a3**2*c2**2+c*a3*a2**2*b3**2+c*b3*b1**2*a3**2) + - 12*(a*a2*b1*c2**3+a*a3*c1*b3**3+b*b3*c2*a3**3+b*b1*a2*c1**3 + + c*c1*a3*b1**3+c*c2*b3*a2**3) + - 8*m**6+24*m**4*(b1*c1+c2*a2+a3*b3)-36*m**3*(a2*b3*c1+a3*b1*c2) + - 12*m**2*(b1*c1*c2*a2+c2*a2*a3*b3+a3*b3*b1*c1) + - 24*m**2*(b1**2*c1**2+c2**2*a2**2+a3**2*b3**2) + + 36*m*(a2*b3*c1+a3*b1*c2)*(b1*c1+c2*a2+a3*b3) + + 8*(b1**3*c1**3+c2**3*a2**3+a3**3*b3**3) + - 27*(a2**2*b3**2*c1**2+a3**2*b1**2*c2**2)-6*b1*c1*c2*a2*a3*b3 + - 12*(b1**2*c1**2*c2*a2+b1**2*c1**2*a3*b3+c2**2*a2**2*a3*b3 + c2**2*a2**2*b1*c1+a3**2*b3**2*b1*c1+a3**2*b3**2*c2*a2) ) return T @@ -3086,8 +3087,8 @@ def syzygy(self, U, S, T, H, Theta, J): return ( -J**2 + 4*Theta**3 + T*U**2*Theta**2 + Theta*(-4*S**3*U**4 + 2*S*T*U**3*H - 72*S**2*U**2*H**2 - 18*T*U*H**3 + 108*S*H**4) - -16*S**4*U**5*H - 11*S**2*T*U**4*H**2 -4*T**2*U**3*H**3 - +54*S*T*U**2*H**4 -432*S**2*U*H**5 -27*T*H**6 ) + - 16*S**4*U**5*H - 11*S**2*T*U**4*H**2 - 4*T**2*U**3*H**3 + + 54*S*T*U**2*H**4 - 432*S**2*U*H**5 - 27*T*H**6 ) ###################################################################### @@ -3967,7 +3968,7 @@ def syzygy(self, Delta, Theta, Phi, Theta_prime, Delta_prime, U, V, T, T_prime, (Theta*Phi - 3*Theta_prime*Delta)*T**2*T_prime + (Theta*Theta_prime - 4*Delta*Delta_prime)*T*T_prime**2 - (Delta_prime*Theta)*T_prime**3 - )* V + \ + ) * V + \ ( (Delta*Phi*Delta_prime) * T**2 + (3*Delta*Theta_prime*Delta_prime - Theta*Phi*Delta_prime) * T*T_prime + (2*Delta*Delta_prime**2 - 2*Theta*Theta_prime*Delta_prime diff --git a/src/sage/rings/laurent_series_ring.py b/src/sage/rings/laurent_series_ring.py index e2a5c524cfe..565e5d12f4c 100644 --- a/src/sage/rings/laurent_series_ring.py +++ b/src/sage/rings/laurent_series_ring.py @@ -6,11 +6,11 @@ sage: R = LaurentSeriesRing(QQ, "x") sage: R.base_ring() Rational Field - sage: S = LaurentSeriesRing(GF(17)['x'], 'y') # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: S = LaurentSeriesRing(GF(17)['x'], 'y') + sage: S Laurent Series Ring in y over Univariate Polynomial Ring in x over Finite Field of size 17 - sage: S.base_ring() # optional - sage.rings.finite_rings + sage: S.base_ring() Univariate Polynomial Ring in x over Finite Field of size 17 .. SEEALSO:: @@ -89,7 +89,7 @@ class LaurentSeriesRing(UniqueRepresentation, CommutativeRing): sage: Frac(QQ[['x']]) Laurent Series Ring in x over Rational Field - sage: Frac(GF(5)['y']) # optional - sage.rings.finite_rings + sage: Frac(GF(5)['y']) Fraction Field of Univariate Polynomial Ring in y over Finite Field of size 5 When the base ring is a domain, the fraction field is the @@ -101,23 +101,23 @@ class LaurentSeriesRing(UniqueRepresentation, CommutativeRing): Laurent series rings are determined by their variable and the base ring, and are globally unique:: - sage: K = Qp(5, prec=5) # optional - sage.rings.padics - sage: L = Qp(5, prec=200) # optional - sage.rings.padics - sage: R. = LaurentSeriesRing(K) # optional - sage.rings.padics - sage: S. = LaurentSeriesRing(L) # optional - sage.rings.padics - sage: R is S # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: K = Qp(5, prec=5) + sage: L = Qp(5, prec=200) + sage: R. = LaurentSeriesRing(K) + sage: S. = LaurentSeriesRing(L) + sage: R is S False - sage: T. = LaurentSeriesRing(Qp(5, prec=200)) # optional - sage.rings.padics - sage: S is T # optional - sage.rings.padics + sage: T. = LaurentSeriesRing(Qp(5, prec=200)) + sage: S is T True - sage: W. = LaurentSeriesRing(Qp(5, prec=199)) # optional - sage.rings.padics - sage: W is T # optional - sage.rings.padics + sage: W. = LaurentSeriesRing(Qp(5, prec=199)) + sage: W is T False - sage: K = LaurentSeriesRing(CC, 'q') - sage: K + sage: K = LaurentSeriesRing(CC, 'q'); K # needs sage.rings.real_mpfr Laurent Series Ring in q over Complex Field with 53 bits of precision - sage: loads(K.dumps()) == K + sage: loads(K.dumps()) == K # needs sage.rings.real_mpfr True sage: P = QQ[['x']] sage: F = Frac(P) @@ -127,10 +127,10 @@ class LaurentSeriesRing(UniqueRepresentation, CommutativeRing): a field equipped with a discrete valuation for which it is complete. The appropriate (sub)category is automatically set in this case:: - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: R. = k[[]] # optional - sage.rings.finite_rings - sage: F = Frac(R) # optional - sage.rings.finite_rings - sage: F.category() # optional - sage.rings.finite_rings + sage: k = GF(11) + sage: R. = k[[]] + sage: F = Frac(R) + sage: F.category() Join of Category of complete discrete valuation fields and Category of commutative algebras over (finite enumerated fields and @@ -405,35 +405,37 @@ def _element_constructor_(self, x, n=0, prec=infinity): EXAMPLES:: - sage: R. = LaurentSeriesRing(Qp(5, 10)) # optional - sage.rings.padics - sage: S. = LaurentSeriesRing(RationalField()) # optional - sage.rings.padics - sage: R(t + t^2 + O(t^3)) # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: R. = LaurentSeriesRing(Qp(5, 10)) + sage: S. = LaurentSeriesRing(RationalField()) + sage: R(t + t^2 + O(t^3)) (1 + O(5^10))*u + (1 + O(5^10))*u^2 + O(u^3) - sage: R(t + t^2 + O(t^3), prec=2) # optional - sage.rings.padics + sage: R(t + t^2 + O(t^3), prec=2) (1 + O(5^10))*u + O(u^2) Coercing an element into its own parent produces that element again, unless a different ``n`` or ``prec`` is given:: - sage: u is R(u) # optional - sage.rings.padics + sage: u is R(u) # needs sage.rings.padics True - sage: R(u, n=3, prec=7) # optional - sage.rings.padics + sage: R(u, n=3, prec=7) # needs sage.rings.padics (1 + O(5^10))*u^4 + O(u^7) Rational functions are accepted:: - sage: I = sqrt(-1) # optional - sage.rings.number_field sage.symbolic - sage: K. = QQ[I] # optional - sage.rings.number_field sage.symbolic - sage: P. = PolynomialRing(K) # optional - sage.rings.number_field sage.symbolic - sage: L. = LaurentSeriesRing(QQ[I]) # optional - sage.rings.number_field sage.symbolic - sage: L((t*I)/(t^3+I*2*t)) # optional - sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field sage.symbolic + sage: I = sqrt(-1) + sage: K. = QQ[I] + sage: P. = PolynomialRing(K) + sage: L. = LaurentSeriesRing(QQ[I]) + sage: L((t*I)/(t^3+I*2*t)) 1/2 + 1/4*I*u^2 - 1/8*u^4 - 1/16*I*u^6 + 1/32*u^8 + 1/64*I*u^10 - 1/128*u^12 - 1/256*I*u^14 + 1/512*u^16 + 1/1024*I*u^18 + O(u^20) :: - sage: L(t*I) / L(t^3+I*2*t) # optional - sage.rings.number_field + sage: L(t*I) / L(t^3+I*2*t) # needs sage.rings.number_field sage.symbolic 1/2 + 1/4*I*u^2 - 1/8*u^4 - 1/16*I*u^6 + 1/32*u^8 + 1/64*I*u^10 - 1/128*u^12 - 1/256*I*u^14 + 1/512*u^16 + 1/1024*I*u^18 + O(u^20) @@ -442,8 +444,9 @@ def _element_constructor_(self, x, n=0, prec=infinity): Check that :trac:`28993` is fixed:: - sage: from sage.modular.etaproducts import qexp_eta - sage: qexp_eta(S, prec=30) + sage: from sage.modular.etaproducts import qexp_eta # needs sage.modular + sage: S. = LaurentSeriesRing(RationalField()) + sage: qexp_eta(S, prec=30) # needs sage.modular 1 - t - t^2 + t^5 + t^7 - t^12 - t^15 + t^22 + t^26 + O(t^30) When converting from `R((z))` to `R((z))((w))`, the variable @@ -458,24 +461,25 @@ def _element_constructor_(self, x, n=0, prec=infinity): Various conversions from PARI (see also :trac:`2508`):: + sage: # needs sage.libs.pari sage: L. = LaurentSeriesRing(QQ, default_prec=10) - sage: L(pari('1/x')) # optional - sage.libs.pari + sage: L(pari('1/x')) q^-1 - sage: L(pari('polchebyshev(5)')) # optional - sage.libs.pari + sage: L(pari('polchebyshev(5)')) 5*q - 20*q^3 + 16*q^5 - sage: L(pari('polchebyshev(5) - 1/x^4')) # optional - sage.libs.pari + sage: L(pari('polchebyshev(5) - 1/x^4')) -q^-4 + 5*q - 20*q^3 + 16*q^5 - sage: L(pari('1/polchebyshev(5)')) # optional - sage.libs.pari + sage: L(pari('1/polchebyshev(5)')) 1/5*q^-1 + 4/5*q + 64/25*q^3 + 192/25*q^5 + 2816/125*q^7 + O(q^9) - sage: L(pari('polchebyshev(5) + O(x^40)')) # optional - sage.libs.pari + sage: L(pari('polchebyshev(5) + O(x^40)')) 5*q - 20*q^3 + 16*q^5 + O(q^40) - sage: L(pari('polchebyshev(5) - 1/x^4 + O(x^40)')) # optional - sage.libs.pari + sage: L(pari('polchebyshev(5) - 1/x^4 + O(x^40)')) -q^-4 + 5*q - 20*q^3 + 16*q^5 + O(q^40) - sage: L(pari('1/polchebyshev(5) + O(x^10)')) # optional - sage.libs.pari + sage: L(pari('1/polchebyshev(5) + O(x^10)')) 1/5*q^-1 + 4/5*q + 64/25*q^3 + 192/25*q^5 + 2816/125*q^7 + 8192/125*q^9 + O(q^10) - sage: L(pari('1/polchebyshev(5) + O(x^10)'), -10) # Multiply by q^-10 # optional - sage.libs.pari + sage: L(pari('1/polchebyshev(5) + O(x^10)'), -10) # Multiply by q^-10 1/5*q^-11 + 4/5*q^-9 + 64/25*q^-7 + 192/25*q^-5 + 2816/125*q^-3 + 8192/125*q^-1 + O(1) - sage: L(pari('O(x^-10)')) # optional - sage.libs.pari + sage: L(pari('O(x^-10)')) O(q^-10) Check that :trac:`30073` is fixed:: @@ -540,8 +544,8 @@ def random_element(self, algorithm='default'): EXAMPLES:: - sage: S. = LaurentSeriesRing(GF(3)) # optional - sage.rings.finite_rings - sage: S.random_element() # random # optional - sage.rings.finite_rings + sage: S. = LaurentSeriesRing(GF(3)) + sage: S.random_element() # random s^-8 + s^-7 + s^-6 + s^-5 + s^-1 + s + s^3 + s^4 + s^5 + 2*s^6 + s^7 + s^11 + O(s^12) """ @@ -577,9 +581,9 @@ def construction(self): sage: parent(1/2 * t) Laurent Series Ring in t over Rational Field - sage: QQbar.gen() * t # optional - sage.rings.number_field + sage: QQbar.gen() * t # needs sage.rings.number_field I*t - sage: parent(QQbar.gen() * t) # optional - sage.rings.number_field + sage: parent(QQbar.gen() * t) # needs sage.rings.number_field Laurent Series Ring in t over Algebraic Field """ from sage.categories.pushout import CompletionFunctor @@ -655,15 +659,16 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): """ EXAMPLES:: - sage: R. = LaurentSeriesRing(GF(17)) # optional - sage.rings.finite_rings - sage: S. = LaurentSeriesRing(GF(19)) # optional - sage.rings.finite_rings - sage: R.hom([y], S) # indirect doctest # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = LaurentSeriesRing(GF(17)) + sage: S. = LaurentSeriesRing(GF(19)) + sage: R.hom([y], S) # indirect doctest Traceback (most recent call last): ... ValueError: relations do not all (canonically) map to 0 under map determined by images of generators - sage: f = R.hom(x + x^3, R) # optional - sage.rings.finite_rings - sage: f(x^2) # optional - sage.rings.finite_rings + sage: f = R.hom(x + x^3, R) + sage: f(x^2) x^2 + 2*x^4 + x^6 The image of the generator needs to be a unit:: @@ -690,8 +695,8 @@ def characteristic(self): """ EXAMPLES:: - sage: R. = LaurentSeriesRing(GF(17)) # optional - sage.rings.finite_rings - sage: R.characteristic() # optional - sage.rings.finite_rings + sage: R. = LaurentSeriesRing(GF(17)) + sage: R.characteristic() 17 """ return self.base_ring().characteristic() @@ -705,8 +710,8 @@ def residue_field(self): EXAMPLES:: - sage: R. = LaurentSeriesRing(GF(17)) # optional - sage.rings.finite_rings - sage: R.residue_field() # optional - sage.rings.finite_rings + sage: R. = LaurentSeriesRing(GF(17)) + sage: R.residue_field() Finite Field of size 17 sage: R. = LaurentSeriesRing(ZZ) diff --git a/src/sage/rings/laurent_series_ring_element.pyx b/src/sage/rings/laurent_series_ring_element.pyx index 9bef72396b7..d56996f3f78 100644 --- a/src/sage/rings/laurent_series_ring_element.pyx +++ b/src/sage/rings/laurent_series_ring_element.pyx @@ -3,16 +3,16 @@ Laurent Series EXAMPLES:: - sage: R. = LaurentSeriesRing(GF(7), 't'); R # optional - sage.rings.finite_rings + sage: R. = LaurentSeriesRing(GF(7), 't'); R Laurent Series Ring in t over Finite Field of size 7 - sage: f = 1/(1-t+O(t^10)); f # optional - sage.rings.finite_rings + sage: f = 1/(1-t+O(t^10)); f 1 + t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10) Laurent series are immutable:: - sage: f[2] # optional - sage.rings.finite_rings + sage: f[2] 1 - sage: f[2] = 5 # optional - sage.rings.finite_rings + sage: f[2] = 5 Traceback (most recent call last): ... IndexError: Laurent series are immutable @@ -21,19 +21,18 @@ We compute with a Laurent series over the complex mpfr numbers. :: - sage: K. = Frac(CC[['q']]) - sage: K + sage: K. = Frac(CC[['q']]); K # needs sage.rings.real_mpfr Laurent Series Ring in q over Complex Field with 53 bits of precision - sage: q + sage: q # needs sage.rings.real_mpfr 1.00000000000000*q Saving and loading. :: - sage: loads(q.dumps()) == q + sage: loads(q.dumps()) == q # needs sage.rings.real_mpfr True - sage: loads(K.dumps()) == K + sage: loads(K.dumps()) == K # needs sage.rings.real_mpfr True IMPLEMENTATION: Laurent series in Sage are represented internally @@ -114,13 +113,14 @@ cdef class LaurentSeries(AlgebraElement): :: - sage: S. = LaurentSeriesRing(GF(5)) # optional - sage.rings.finite_rings sage.rings.padics - sage: T. = PowerSeriesRing(pAdicRing(5)) # optional - sage.rings.finite_rings sage.rings.padics - sage: S(t) # optional - sage.rings.finite_rings sage.rings.padics + sage: # needs sage.rings.finite_rings sage.rings.padics + sage: S. = LaurentSeriesRing(GF(5)) + sage: T. = PowerSeriesRing(pAdicRing(5)) + sage: S(t) s - sage: parent(S(t)) # optional - sage.rings.finite_rings sage.rings.padics + sage: parent(S(t)) Laurent Series Ring in s over Finite Field of size 5 - sage: parent(S(t)[1]) # optional - sage.rings.finite_rings sage.rings.padics + sage: parent(S(t)[1]) Finite Field of size 5 """ AlgebraElement.__init__(self, parent) @@ -182,7 +182,7 @@ cdef class LaurentSeries(AlgebraElement): sage: R. = LaurentSeriesRing(ZZ) sage: p = R([1,2,3]); p 1 + 2*q + 3*q^2 - sage: p.change_ring(GF(2)) # optional - sage.rings.finite_rings + sage: p.change_ring(GF(2)) 1 + q^2 """ return self._parent.change_ring(R)(self) @@ -280,21 +280,22 @@ cdef class LaurentSeries(AlgebraElement): def _im_gens_(self, codomain, im_gens, base_map=None): """ Return the image of this series under the map that sends the generators of - the parent to im_gens. + the parent to ``im_gens``. EXAMPLES:: + sage: # needs sage.rings.number_field sage: Zx. = ZZ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: R. = LaurentSeriesRing(K) # optional - sage.rings.number_field - sage: z = t^-1 + i*t # optional - sage.rings.number_field - sage: z._im_gens_(R, [t^2]) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: R. = LaurentSeriesRing(K) + sage: z = t^-1 + i*t + sage: z._im_gens_(R, [t^2]) t^-2 + i*t^2 - The argument base_map is not yet supported, because it isn't over power series:: + The argument ``base_map`` is not yet supported, because it isn't over power series:: - sage: cc = K.hom([i]) # optional - sage.rings.number_field - sage: z._im_gens_(R, [t^2], base_map=cc) # optional - sage.rings.number_field + sage: cc = K.hom([i]) # needs sage.rings.number_field + sage: z._im_gens_(R, [t^2], base_map=cc) # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError @@ -668,11 +669,12 @@ cdef class LaurentSeries(AlgebraElement): EXAMPLES:: - sage: A. = LaurentSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: x = t^(-1) + t^2 + O(t^5) # optional - sage.rings.finite_rings - sage: x.lift_to_precision(10) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: A. = LaurentSeriesRing(GF(5)) + sage: x = t^(-1) + t^2 + O(t^5) + sage: x.lift_to_precision(10) t^-1 + t^2 + O(t^10) - sage: x.lift_to_precision() # optional - sage.rings.finite_rings + sage: x.lift_to_precision() t^-1 + t^2 """ if absprec is not None and absprec <= self.precision_absolute(): @@ -1598,8 +1600,8 @@ cdef class LaurentSeries(AlgebraElement): TESTS:: - sage: y = var('y') # optional - sage.symbolic - sage: f.derivative(y) # optional - sage.symbolic + sage: y = var('y') # needs sage.symbolic + sage: f.derivative(y) # needs sage.symbolic Traceback (most recent call last): ... ValueError: cannot differentiate with respect to y @@ -1701,6 +1703,7 @@ cdef class LaurentSeries(AlgebraElement): sage: (x^-2 + 1 + x).nth_root(2)**2 x^-2 + 1 + x + O(x^18) + sage: # needs sage.modular sage: j = j_invariant_qexp() sage: q = j.parent().gen() sage: j(q^3).nth_root(3) @@ -1752,10 +1755,11 @@ cdef class LaurentSeries(AlgebraElement): Check whether a polynomial over a Laurent series ring is contained in the polynomial ring over the power series ring (see :trac:`19459`): - sage: L. = LaurentSeriesRing(GF(2)) # optional - sage.rings.finite_rings - sage: R. = PolynomialRing(L) # optional - sage.rings.finite_rings - sage: S. = PolynomialRing(L._power_series_ring) # optional - sage.rings.finite_rings - sage: t**(-1)*x*y in S # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: L. = LaurentSeriesRing(GF(2)) + sage: R. = PolynomialRing(L) + sage: S. = PolynomialRing(L._power_series_ring) + sage: t**(-1)*x*y in S False There used to be an issue with non-canonical representations of zero, @@ -1775,8 +1779,8 @@ cdef class LaurentSeries(AlgebraElement): Test for :trac:`32440`:: - sage: L. = LaurentSeriesRing(QQ, implementation='pari') # optional - sage.libs.pari - sage: (x + O(x^3)).power_series() # optional - sage.libs.pari + sage: L. = LaurentSeriesRing(QQ, implementation='pari') # needs sage.libs.pari + sage: (x + O(x^3)).power_series() # needs sage.libs.pari x + O(x^3) """ if self.__n < 0: @@ -1837,9 +1841,9 @@ cdef class LaurentSeries(AlgebraElement): Test for :trac:`23928`:: - sage: R. = LaurentSeriesRing(QQ, implementation='pari') # optional - sage.libs.pari - sage: f = x.add_bigoh(7) # optional - sage.libs.pari - sage: f(x) # optional - sage.libs.pari + sage: R. = LaurentSeriesRing(QQ, implementation='pari') # needs sage.libs.pari + sage: f = x.add_bigoh(7) # needs sage.libs.pari + sage: f(x) # needs sage.libs.pari x + O(x^7) """ if len(kwds) >= 1: @@ -1879,16 +1883,17 @@ cdef class LaurentSeries(AlgebraElement): sage: L. = LaurentSeriesRing(QQ) sage: f = x + 1/x + O(x^2); f x^-1 + x + O(x^2) - sage: f.__pari__() # optional - sage.libs.pari + sage: f.__pari__() # needs sage.libs.pari x^-1 + x + O(x^2) Check that :trac:`32437` is fixed:: - sage: F. = GF(257^2) # optional - sage.rings.finite_rings - sage: R. = LaurentSeriesRing(F) # optional - sage.rings.finite_rings - sage: g = t + O(t^99) # optional - sage.rings.finite_rings - sage: f = u*t + O(t^99) # optional - sage.rings.finite_rings - sage: g(f) # indirect doctest # optional - sage.libs.pari sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(257^2) + sage: R. = LaurentSeriesRing(F) + sage: g = t + O(t^99) + sage: f = u*t + O(t^99) + sage: g(f) # indirect doctest # needs sage.libs.pari u*t + O(t^99) """ f = self.__u diff --git a/src/sage/rings/lazy_series.py b/src/sage/rings/lazy_series.py index 3278c8eed7c..e9a035c445d 100644 --- a/src/sage/rings/lazy_series.py +++ b/src/sage/rings/lazy_series.py @@ -83,21 +83,21 @@ A similar statement is true for lazy symmetric functions:: - sage: h = SymmetricFunctions(QQ).h() # optional - sage.combinat - sage: L = LazySymmetricFunctions(h) # optional - sage.combinat - sage: 1 / (1-L(h[1])) # optional - sage.combinat + sage: h = SymmetricFunctions(QQ).h() # needs sage.combinat + sage: L = LazySymmetricFunctions(h) # needs sage.combinat + sage: 1 / (1-L(h[1])) # needs sage.combinat h[] + h[1] + (h[1,1]) + (h[1,1,1]) + (h[1,1,1,1]) + (h[1,1,1,1,1]) + (h[1,1,1,1,1,1]) + O^7 We can change the base ring:: sage: h = g.change_ring(QQ) - sage: h.parent() + sage: h.parent() # needs sage.combinat Lazy Laurent Series Ring in z over Rational Field - sage: h + sage: h # needs sage.combinat 4*z + 6*z^2 + 8*z^3 + 19*z^4 + 38*z^5 + 71*z^6 + 130*z^7 + O(z^8) - sage: hinv = h^-1; hinv + sage: hinv = h^-1; hinv # needs sage.combinat 1/4*z^-1 - 3/8 + 1/16*z - 17/32*z^2 + 5/64*z^3 - 29/128*z^4 + 165/256*z^5 + O(z^6) - sage: hinv.valuation() + sage: hinv.valuation() # needs sage.combinat -1 TESTS: @@ -145,9 +145,9 @@ sage: check(L, z) sage: L. = LazyPowerSeriesRing(QQ) sage: check(L, z) - sage: p = SymmetricFunctions(QQ).p() # optional - sage.combinat - sage: L = LazySymmetricFunctions(p) # optional - sage.combinat - sage: check(L, L(p[1])) # optional - sage.combinat + sage: p = SymmetricFunctions(QQ).p() # needs sage.combinat + sage: L = LazySymmetricFunctions(p) # needs sage.combinat + sage: check(L, L(p[1])) # needs sage.combinat We check that the elements in the cache of the stream of homogeneous components are in the correct ring:: @@ -171,30 +171,30 @@ ....: yield n ....: n += 1 - sage: L. = LazyLaurentSeriesRing(GF(2)) # optional - sage.rings.finite_rings - sage: check(L, lambda n: n, valuation=-5) # optional - sage.rings.finite_rings - sage: check(L, gen(), valuation=-5) # optional - sage.rings.finite_rings + sage: L. = LazyLaurentSeriesRing(GF(2)) + sage: check(L, lambda n: n, valuation=-5) + sage: check(L, gen(), valuation=-5) - sage: L = LazyDirichletSeriesRing(QQbar, "s") # optional - sage.rings.number_field - sage: check(L, lambda n: n, valuation=2) # optional - sage.rings.number_field - sage: check(L, gen(), valuation=2) # optional - sage.rings.number_field + sage: L = LazyDirichletSeriesRing(QQbar, "s") # needs sage.rings.number_field + sage: check(L, lambda n: n, valuation=2) # needs sage.rings.number_field + sage: check(L, gen(), valuation=2) - sage: L. = LazyPowerSeriesRing(GF(2)) # optional - sage.rings.finite_rings - sage: check(L, lambda n: n, valuation=0) # optional - sage.rings.finite_rings - sage: check(L, gen(), valuation=0) # optional - sage.rings.finite_rings + sage: L. = LazyPowerSeriesRing(GF(2)) + sage: check(L, lambda n: n, valuation=0) + sage: check(L, gen(), valuation=0) - sage: L. = LazyPowerSeriesRing(GF(2)) # optional - sage.rings.finite_rings - sage: check(L, lambda n: (x + y)^n, valuation=None) # optional - sage.rings.finite_rings - sage: def gen(): # optional - sage.rings.finite_rings + sage: L. = LazyPowerSeriesRing(GF(2)) + sage: check(L, lambda n: (x + y)^n, valuation=None) # needs sage.rings.finite_rings + sage: def gen(): ....: n = 0 ....: while True: ....: yield (x+y)^n ....: n += 1 - sage: check(L, gen(), valuation=None) # optional - sage.rings.finite_rings + sage: check(L, gen(), valuation=None) # needs sage.rings.finite_rings - sage: s = SymmetricFunctions(GF(2)).s() # optional - sage.combinat sage.rings.finite_rings - sage: L = LazySymmetricFunctions(s) # optional - sage.combinat sage.rings.finite_rings - sage: check(L, lambda n: sum(k*s(la) for k, la in enumerate(Partitions(n))), # optional - sage.combinat sage.rings.finite_rings + sage: s = SymmetricFunctions(GF(2)).s() # needs sage.combinat + sage: L = LazySymmetricFunctions(s) # needs sage.combinat + sage: check(L, lambda n: sum(k*s(la) for k, la in enumerate(Partitions(n))), # needs sage.combinat ....: valuation=0) """ @@ -296,9 +296,9 @@ def __init__(self, parent, coeff_stream): sage: L. = LazyLaurentSeriesRing(ZZ) sage: TestSuite(L.an_element()).run() - sage: L = LazyDirichletSeriesRing(QQbar, 'z') # optional - sage.rings.number_field - sage: g = L(constant=1) # optional - sage.rings.number_field - sage: TestSuite(g).run() # optional - sage.rings.number_field + sage: L = LazyDirichletSeriesRing(QQbar, 'z') # needs sage.rings.number_field + sage: g = L(constant=1) # needs sage.rings.number_field + sage: TestSuite(g).run() # needs sage.rings.number_field """ Element.__init__(self, parent) self._coeff_stream = coeff_stream @@ -436,9 +436,9 @@ def coefficients(self, n=None): sage: f.coefficients() lazy list [1, 1, -1/6, ...] - sage: L. = LazyPowerSeriesRing(GF(2)) # optional - sage.rings.finite_rings - sage: f = L(lambda n: n) # optional - sage.rings.finite_rings - sage: f.coefficients(5) # optional - sage.rings.finite_rings + sage: L. = LazyPowerSeriesRing(GF(2)) + sage: f = L(lambda n: n) + sage: f.coefficients(5) [1, 1, 1, 1, 1] """ coeff_stream = self._coeff_stream @@ -496,10 +496,10 @@ def map_coefficients(self, f): sage: L = LazyDirichletSeriesRing(ZZ, "z") sage: s = L(lambda n: n-1) - sage: s # optional - sage.symbolic + sage: s # needs sage.symbolic 1/(2^z) + 2/3^z + 3/4^z + 4/5^z + 5/6^z + 6/7^z + O(1/(8^z)) - sage: ms = s.map_coefficients(lambda c: c + 1) - sage: ms # optional - sage.symbolic + sage: ms = s.map_coefficients(lambda c: c + 1) # needs sage.symbolic + sage: ms # needs sage.symbolic 2/2^z + 3/3^z + 4/4^z + 5/5^z + 6/6^z + 7/7^z + 8/8^z + O(1/(9^z)) Similarly for multivariate power series:: @@ -520,12 +520,13 @@ def map_coefficients(self, f): Similarly for lazy symmetric functions:: - sage: p = SymmetricFunctions(QQ).p() # optional - sage.combinat - sage: L = LazySymmetricFunctions(p) # optional - sage.combinat - sage: f = 1/(1-2*L(p[1])); f # optional - sage.combinat + sage: # needs sage.combinat + sage: p = SymmetricFunctions(QQ).p() + sage: L = LazySymmetricFunctions(p) + sage: f = 1/(1-2*L(p[1])); f p[] + 2*p[1] + (4*p[1,1]) + (8*p[1,1,1]) + (16*p[1,1,1,1]) + (32*p[1,1,1,1,1]) + (64*p[1,1,1,1,1,1]) + O^7 - sage: f.map_coefficients(lambda c: log(c, 2)) # optional - sage.combinat + sage: f.map_coefficients(lambda c: log(c, 2)) p[1] + (2*p[1,1]) + (3*p[1,1,1]) + (4*p[1,1,1,1]) + (5*p[1,1,1,1,1]) + (6*p[1,1,1,1,1,1]) + O^7 @@ -674,10 +675,10 @@ def shift(self, n): sage: D = LazyDirichletSeriesRing(QQ, 't') sage: f = D([0,1,2]) - sage: f # optional - sage.symbolic + sage: f # needs sage.symbolic 1/(2^t) + 2/3^t sage: sf = f.shift(3) - sage: sf # optional - sage.symbolic + sage: sf # needs sage.symbolic 1/(5^t) + 2/6^t Examples with power series (where the minimal valuation is `0`):: @@ -1021,60 +1022,65 @@ def __bool__(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(GF(2)) # optional - sage.rings.finite_rings - sage: bool(z - z) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: L. = LazyLaurentSeriesRing(GF(2)) + sage: bool(z - z) False - sage: f = 1/(1 - z) # optional - sage.rings.finite_rings - sage: bool(f) # optional - sage.rings.finite_rings + sage: f = 1/(1 - z) + sage: bool(f) True - sage: M = L(lambda n: n, valuation=0); M # optional - sage.rings.finite_rings + sage: M = L(lambda n: n, valuation=0); M z + z^3 + z^5 + O(z^7) - sage: M.is_zero() # optional - sage.rings.finite_rings + sage: M.is_zero() False - sage: M = L(lambda n: 2*n if n < 10 else 1, valuation=0); M # optional - sage.rings.finite_rings + sage: M = L(lambda n: 2*n if n < 10 else 1, valuation=0); M O(z^7) - sage: bool(M) # optional - sage.rings.finite_rings + sage: bool(M) Traceback (most recent call last): ... ValueError: undecidable as lazy Laurent series - sage: M[15] # optional - sage.rings.finite_rings + sage: M[15] 1 - sage: bool(M) # optional - sage.rings.finite_rings + sage: bool(M) True - sage: L. = LazyLaurentSeriesRing(GF(2), sparse=True) # optional - sage.rings.finite_rings - sage: M = L(lambda n: 2*n if n < 10 else 1, valuation=0); M # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: L. = LazyLaurentSeriesRing(GF(2), sparse=True) + sage: M = L(lambda n: 2*n if n < 10 else 1, valuation=0); M O(z^7) - sage: bool(M) # optional - sage.rings.finite_rings + sage: bool(M) Traceback (most recent call last): ... ValueError: undecidable as lazy Laurent series - sage: M[15] # optional - sage.rings.finite_rings + sage: M[15] 1 - sage: bool(M) # optional - sage.rings.finite_rings + sage: bool(M) True Uninitialized series:: - sage: g = L.undefined(valuation=0) # optional - sage.rings.finite_rings - sage: bool(g) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: g = L.undefined(valuation=0) + sage: bool(g) True - sage: g.define(0) # optional - sage.rings.finite_rings - sage: bool(g) # optional - sage.rings.finite_rings + sage: g.define(0) + sage: bool(g) False - sage: g = L.undefined(valuation=0) # optional - sage.rings.finite_rings - sage: bool(g) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: g = L.undefined(valuation=0) + sage: bool(g) True - sage: g.define(1 + z) # optional - sage.rings.finite_rings - sage: bool(g) # optional - sage.rings.finite_rings + sage: g.define(1 + z) + sage: bool(g) True - sage: g = L.undefined(valuation=0) # optional - sage.rings.finite_rings - sage: bool(g) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: g = L.undefined(valuation=0) + sage: bool(g) True - sage: g.define(1 + z*g) # optional - sage.rings.finite_rings - sage: bool(g) # optional - sage.rings.finite_rings + sage: g.define(1 + z*g) + sage: bool(g) True """ if isinstance(self._coeff_stream, Stream_zero): @@ -1122,7 +1128,7 @@ def define(self, s): sage: C.define(1 + z*C^2) sage: C 1 + z + 2*z^2 + 5*z^3 + 14*z^4 + 42*z^5 + 132*z^6 + O(z^7) - sage: binomial(2000, 1000) / C[1000] + sage: binomial(2000, 1000) / C[1000] # needs sage.symbolic 1001 The Catalan numbers but with a valuation 1:: @@ -1213,14 +1219,15 @@ def define(self, s): We can compute the Frobenius character of unlabeled trees:: - sage: m = SymmetricFunctions(QQ).m() # optional - sage.combinat - sage: s = SymmetricFunctions(QQ).s() # optional - sage.combinat - sage: L = LazySymmetricFunctions(m) # optional - sage.combinat - sage: E = L(lambda n: s[n], valuation=0) # optional - sage.combinat - sage: X = L(s[1]) # optional - sage.combinat - sage: A = L.undefined() # optional - sage.combinat - sage: A.define(X*E(A, check=False)) # optional - sage.combinat - sage: A[:6] # optional - sage.combinat + sage: # needs sage.combinat + sage: m = SymmetricFunctions(QQ).m() + sage: s = SymmetricFunctions(QQ).s() + sage: L = LazySymmetricFunctions(m) + sage: E = L(lambda n: s[n], valuation=0) + sage: X = L(s[1]) + sage: A = L.undefined() + sage: A.define(X*E(A, check=False)) + sage: A[:6] [m[1], 2*m[1, 1] + m[2], 9*m[1, 1, 1] + 5*m[2, 1] + 2*m[3], @@ -1262,7 +1269,7 @@ def define(self, s): sage: g = D.undefined(valuation=2) sage: o = D(constant=1, valuation=2) sage: g.define(o * e(g)) - sage: g # optional - sage.symbolic + sage: g # needs sage.symbolic 1/(2^s) + 1/(3^s) + 2/4^s + 1/(5^s) + 3/6^s + 1/(7^s) + 9/2/8^s + O(1/(9^s)) For Laurent series there is no minimal valuation, so it has @@ -1287,7 +1294,7 @@ def define(self, s): sage: g = D([0, 1]) sage: f = D.undefined() sage: f.define(1 + ~f*g) - sage: f # optional - sage.symbolic + sage: f # needs sage.symbolic 1 + 1/(2^s) - 1/(4^s) + O(1/(8^s)) sage: oeis(f[:30]) # optional - internet @@ -1335,11 +1342,12 @@ def define(self, s): sage: f 1 + 2*t + 12*t^3 + 32*t^4 + 368*t^5 + 2192*t^6 + O(t^7) - sage: s = SymmetricFunctions(QQ).s() # optional - sage.combinat - sage: L = LazySymmetricFunctions(s) # optional - sage.combinat - sage: f = L.undefined() # optional - sage.combinat - sage: f.define(1+(s[1]*f).revert()) # optional - sage.combinat - sage: f # optional - sage.combinat + sage: # needs sage.combinat + sage: s = SymmetricFunctions(QQ).s() + sage: L = LazySymmetricFunctions(s) + sage: f = L.undefined() + sage: f.define(1+(s[1]*f).revert()) + sage: f # needs lrcalc_python s[] + s[1] + (-s[1,1]-s[2]) + (3*s[1,1,1]+6*s[2,1]+3*s[3]) + (-13*s[1,1,1,1]-39*s[2,1,1]-26*s[2,2]-39*s[3,1]-13*s[4]) @@ -1347,7 +1355,7 @@ def define(self, s): + (-419*s[1,1,1,1,1,1]-2095*s[2,1,1,1,1]-3771*s[2,2,1,1]-2095*s[2,2,2]-4190*s[3,1,1,1]-6704*s[3,2,1]-2095*s[3,3]-4190*s[4,1,1]-3771*s[4,2]-2095*s[5,1]-419*s[6]) + O^7 - sage: (f*s[1]).revert() + 1 - f # optional - sage.combinat + sage: (f*s[1]).revert() + 1 - f # needs lrcalc_python sage.combinat O^7 """ @@ -1470,12 +1478,13 @@ def _ascii_art_(self): EXAMPLES:: - sage: e = SymmetricFunctions(QQ).e() # optional - sage.combinat - sage: L. = LazyLaurentSeriesRing(e) # optional - sage.combinat - sage: L.options.display_length = 3 # optional - sage.combinat - sage: ascii_art(1 / (1 - e[1]*z)) # optional - sage.combinat + sage: # needs sage.combinat sage.modules + sage: e = SymmetricFunctions(QQ).e() + sage: L. = LazyLaurentSeriesRing(e) + sage: L.options.display_length = 3 + sage: ascii_art(1 / (1 - e[1]*z)) e[] + e[1]*z + e[1, 1]*z^2 + O(e[]*z^3) - sage: L.options._reset() # optional - sage.combinat + sage: L.options._reset() """ from sage.typeset.ascii_art import ascii_art, AsciiArt if isinstance(self._coeff_stream, Stream_zero): @@ -1490,12 +1499,13 @@ def _unicode_art_(self): EXAMPLES:: - sage: e = SymmetricFunctions(QQ).e() # optional - sage.combinat - sage: L. = LazyLaurentSeriesRing(e) # optional - sage.combinat - sage: L.options.display_length = 3 # optional - sage.combinat - sage: unicode_art(1 / (1 - e[1]*z)) # optional - sage.combinat + sage: # needs sage.combinat sage.modules + sage: e = SymmetricFunctions(QQ).e() + sage: L. = LazyLaurentSeriesRing(e) + sage: L.options.display_length = 3 + sage: unicode_art(1 / (1 - e[1]*z)) e[] + e[1]*z + e[1, 1]*z^2 + O(e[]*z^3) - sage: L.options._reset() # optional - sage.combinat + sage: L.options._reset() """ from sage.typeset.unicode_art import unicode_art, UnicodeArt if isinstance(self._coeff_stream, Stream_zero): @@ -1550,7 +1560,7 @@ def change_ring(self, ring): sage: t.parent() Lazy Dirichlet Series Ring in z over Rational Field sage: it = t^-1 - sage: it # optional - sage.symbolic + sage: it # needs sage.symbolic 1/2 - 1/2/2^z - 1/2/3^z - 1/2/5^z + 1/2/6^z - 1/2/7^z + O(1/(8^z)) A Taylor series example:: @@ -1616,30 +1626,28 @@ def _add_(self, other): Similarly for Dirichlet series:: + sage: # needs sage.symbolic sage: L = LazyDirichletSeriesRing(ZZ, "z") sage: s = L(lambda n: n) - sage: s # optional - sage.symbolic + sage: s 1 + 2/2^z + 3/3^z + 4/4^z + 5/5^z + 6/6^z + 7/7^z + O(1/(8^z)) sage: t = L(constant=1) - sage: t # optional - sage.symbolic + sage: t 1 + 1/(2^z) + 1/(3^z) + O(1/(4^z)) sage: st = s + t - sage: st # optional - sage.symbolic + sage: st 2 + 3/2^z + 4/3^z + 5/4^z + 6/5^z + 7/6^z + 8/7^z + O(1/(8^z)) - sage: r = L(constant=-1) sage: rt = r + t - sage: rt # optional - sage.symbolic + sage: rt 0 - sage: r = L([1,2,3]) sage: rt = r + t - sage: rt # optional - sage.symbolic + sage: rt 2 + 3/2^z + 4/3^z + 1/(4^z) + 1/(5^z) + 1/(6^z) + O(1/(7^z)) - sage: r = L([1,2,3], constant=-1) sage: rt = r + t - sage: rt # optional - sage.symbolic + sage: rt 2 + 3/2^z + 4/3^z """ P = self.parent() @@ -1832,20 +1840,20 @@ def _acted_upon_(self, scalar, self_on_left): Similarly for Dirichlet series:: + sage: # needs sage.symbolic sage: L = LazyDirichletSeriesRing(ZZ, "z") sage: g = L([0,1]) - sage: 2 * g # optional - sage.symbolic + sage: 2 * g 2/2^z - sage: -1 * g # optional - sage.symbolic + sage: -1 * g -1/(2^z) - sage: 0*g # optional - sage.symbolic + sage: 0*g 0 sage: M = L(lambda n: n) - sage: M # optional - sage.symbolic + sage: M 1 + 2/2^z + 3/3^z + 4/4^z + 5/5^z + 6/6^z + 7/7^z + O(1/(8^z)) - sage: 3 * M # optional - sage.symbolic + sage: 3 * M 3 + 6/2^z + 9/3^z + 12/4^z + 15/5^z + 18/6^z + 21/7^z + O(1/(8^z)) - sage: 1 * M is M True @@ -1976,7 +1984,7 @@ def exp(self): sage: L = LazyDirichletSeriesRing(QQ, "s") sage: Z = L(constant=1, valuation=2) - sage: exp(Z) # optional - sage.symbolic + sage: exp(Z) # needs sage.symbolic 1 + 1/(2^s) + 1/(3^s) + 3/2/4^s + 1/(5^s) + 2/6^s + 1/(7^s) + O(1/(8^s)) """ from .lazy_series_ring import LazyLaurentSeriesRing @@ -1992,7 +2000,7 @@ def log(self): sage: L = LazyDirichletSeriesRing(QQ, "s") sage: Z = L(constant=1) - sage: log(Z) # optional - sage.symbolic + sage: log(Z) # needs sage.symbolic 1/(2^s) + 1/(3^s) + 1/2/4^s + 1/(5^s) + 1/(7^s) + O(1/(8^s)) """ from .lazy_series_ring import LazyLaurentSeriesRing @@ -2023,7 +2031,7 @@ def sin(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic sage: sin(z)[0:6] == sin(x).series(x, 6).coefficients(sparse=False) True """ @@ -2049,8 +2057,8 @@ def cos(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") - sage: cos(z)[0:6] == cos(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic + sage: cos(z)[0:6] == cos(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from .lazy_series_ring import LazyLaurentSeriesRing @@ -2075,8 +2083,8 @@ def tan(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") - sage: tan(z)[0:6] == tan(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic + sage: tan(z)[0:6] == tan(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ return self.sin() / self.cos() @@ -2097,8 +2105,8 @@ def cot(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") - sage: cot(z)[0:6] == cot(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic + sage: cot(z)[0:6] == cot(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ return ~self.tan() @@ -2119,8 +2127,8 @@ def csc(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") - sage: (z*csc(z))[0:6] == (x*csc(x)).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic + sage: (z*csc(z))[0:6] == (x*csc(x)).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ return ~self.sin() @@ -2141,8 +2149,8 @@ def sec(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") - sage: sec(z)[0:6] == sec(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic + sage: sec(z)[0:6] == sec(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ return ~self.cos() @@ -2167,8 +2175,8 @@ def arcsin(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") - sage: asin(z)[0:6] == asin(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic + sage: asin(z)[0:6] == asin(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from .lazy_series_ring import LazyLaurentSeriesRing @@ -2188,24 +2196,24 @@ def arccos(self): EXAMPLES:: sage: L. = LazyLaurentSeriesRing(RR) - sage: arccos(z) + sage: arccos(z) # needs sage.symbolic 1.57079632679490 - 1.00000000000000*z + 0.000000000000000*z^2 - 0.166666666666667*z^3 + 0.000000000000000*z^4 - 0.0750000000000000*z^5 + O(1.00000000000000*z^7) - sage: L. = LazyLaurentSeriesRing(SR) - sage: arccos(z/(1-z)) + sage: L. = LazyLaurentSeriesRing(SR) # needs sage.symbolic + sage: arccos(z/(1-z)) # needs sage.symbolic 1/2*pi - z - z^2 - 7/6*z^3 - 3/2*z^4 - 83/40*z^5 - 73/24*z^6 + O(z^7) - sage: L. = LazyPowerSeriesRing(SR) - sage: arccos(x/(1-y)) + sage: L. = LazyPowerSeriesRing(SR) # needs sage.symbolic + sage: arccos(x/(1-y)) # needs sage.symbolic 1/2*pi + (-x) + (-x*y) + ((-1/6)*x^3-x*y^2) + ((-1/2)*x^3*y-x*y^3) + ((-3/40)*x^5-x^3*y^2-x*y^4) + ((-3/8)*x^5*y+(-5/3)*x^3*y^3-x*y^5) + O(x,y)^7 TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: acos(z)[0:6] == acos(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: acos(z)[0:6] == acos(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from sage.symbolic.constants import pi @@ -2228,8 +2236,8 @@ def arctan(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") - sage: atan(z)[0:6] == atan(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic + sage: atan(z)[0:6] == atan(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from .lazy_series_ring import LazyLaurentSeriesRing @@ -2251,24 +2259,24 @@ def arccot(self): EXAMPLES:: sage: L. = LazyLaurentSeriesRing(RR) - sage: arccot(z) + sage: arccot(z) # needs sage.symbolic 1.57079632679490 - 1.00000000000000*z + 0.000000000000000*z^2 + 0.333333333333333*z^3 + 0.000000000000000*z^4 - 0.200000000000000*z^5 + O(1.00000000000000*z^7) - sage: L. = LazyLaurentSeriesRing(SR) - sage: arccot(z/(1-z)) + sage: L. = LazyLaurentSeriesRing(SR) # needs sage.symbolic + sage: arccot(z/(1-z)) # needs sage.symbolic 1/2*pi - z - z^2 - 2/3*z^3 + 4/5*z^5 + 4/3*z^6 + O(z^7) - sage: L. = LazyPowerSeriesRing(SR) - sage: acot(x/(1-y)) + sage: L. = LazyPowerSeriesRing(SR) # needs sage.symbolic + sage: acot(x/(1-y)) # needs sage.symbolic 1/2*pi + (-x) + (-x*y) + (1/3*x^3-x*y^2) + (x^3*y-x*y^3) + ((-1/5)*x^5+2*x^3*y^2-x*y^4) + (-x^5*y+10/3*x^3*y^3-x*y^5) + O(x,y)^7 TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: acot(z)[0:6] == acot(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: acot(z)[0:6] == acot(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from sage.symbolic.constants import pi @@ -2294,8 +2302,8 @@ def sinh(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: sinh(z)[0:6] == sinh(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: sinh(z)[0:6] == sinh(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from .lazy_series_ring import LazyLaurentSeriesRing @@ -2321,8 +2329,8 @@ def cosh(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: cosh(z)[0:6] == cosh(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: cosh(z)[0:6] == cosh(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from .lazy_series_ring import LazyLaurentSeriesRing @@ -2338,18 +2346,18 @@ def tanh(self): EXAMPLES:: sage: L. = LazyLaurentSeriesRing(QQ) - sage: tanh(z) + sage: tanh(z) # needs sage.libs.flint z - 1/3*z^3 + 2/15*z^5 - 17/315*z^7 + O(z^8) sage: L. = LazyPowerSeriesRing(QQ) - sage: tanh(x/(1-y)) + sage: tanh(x/(1-y)) # needs sage.libs.flint x + x*y + (-1/3*x^3+x*y^2) + (-x^3*y+x*y^3) + (2/15*x^5-2*x^3*y^2+x*y^4) + (2/3*x^5*y-10/3*x^3*y^3+x*y^5) + (-17/315*x^7+2*x^5*y^2-5*x^3*y^4+x*y^6) + O(x,y)^8 TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: tanh(z)[0:6] == tanh(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: tanh(z)[0:6] == tanh(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from sage.arith.misc import bernoulli @@ -2371,16 +2379,16 @@ def coth(self): EXAMPLES:: sage: L. = LazyLaurentSeriesRing(QQ) - sage: coth(z) + sage: coth(z) # needs sage.libs.flint z^-1 + 1/3*z - 1/45*z^3 + 2/945*z^5 + O(z^6) - sage: coth(z + z^2) + sage: coth(z + z^2) # needs sage.libs.flint z^-1 - 1 + 4/3*z - 2/3*z^2 + 44/45*z^3 - 16/15*z^4 + 884/945*z^5 + O(z^6) TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: coth(z)[0:6] == coth(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: coth(z)[0:6] == coth(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from sage.arith.misc import bernoulli @@ -2401,18 +2409,18 @@ def sech(self): EXAMPLES:: sage: L. = LazyLaurentSeriesRing(QQ) - sage: sech(z) + sage: sech(z) # needs sage.libs.flint 1 - 1/2*z^2 + 5/24*z^4 - 61/720*z^6 + O(z^7) sage: L. = LazyPowerSeriesRing(QQ) - sage: sech(x/(1-y)) + sage: sech(x/(1-y)) # needs sage.libs.flint 1 + (-1/2*x^2) + (-x^2*y) + (5/24*x^4-3/2*x^2*y^2) + (5/6*x^4*y-2*x^2*y^3) + (-61/720*x^6+25/12*x^4*y^2-5/2*x^2*y^4) + O(x,y)^7 TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: sech(z)[0:6] == sech(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: sech(z)[0:6] == sech(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from sage.combinat.combinat import euler_number @@ -2433,17 +2441,17 @@ def csch(self): EXAMPLES:: sage: L. = LazyLaurentSeriesRing(QQ) - sage: csch(z) + sage: csch(z) # needs sage.libs.flint z^-1 - 1/6*z + 7/360*z^3 - 31/15120*z^5 + O(z^6) sage: L. = LazyLaurentSeriesRing(QQ) - sage: csch(z/(1-z)) + sage: csch(z/(1-z)) # needs sage.libs.flint z^-1 - 1 - 1/6*z - 1/6*z^2 - 53/360*z^3 - 13/120*z^4 - 787/15120*z^5 + O(z^6) TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: csch(z)[0:6] == csch(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: csch(z)[0:6] == csch(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ from sage.arith.misc import bernoulli @@ -2481,8 +2489,8 @@ def arcsinh(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: asinh(z)[0:6] == asinh(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: asinh(z)[0:6] == asinh(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ @@ -2519,8 +2527,8 @@ def arctanh(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: atanh(z)[0:6] == atanh(x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: atanh(z)[0:6] == atanh(x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ @@ -2554,8 +2562,8 @@ def hypergeometric(self, a, b): TESTS:: - sage: L. = LazyLaurentSeriesRing(SR); x = var("x") - sage: z.hypergeometric([1,1],[1])[0:6] == hypergeometric([1,1],[1], x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(SR); x = var("x") # needs sage.symbolic + sage: z.hypergeometric([1,1],[1])[0:6] == hypergeometric([1,1],[1], x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True """ @@ -2643,16 +2651,17 @@ def __pow__(self, n): EXAMPLES:: + sage: # needs sage.symbolic sage: D = LazyDirichletSeriesRing(QQ, 's') sage: Z = D(constant=1) - sage: Z^2 # optional - sage.symbolic + sage: Z^2 1 + 2/2^s + 2/3^s + 3/4^s + 2/5^s + 4/6^s + 2/7^s + O(1/(8^s)) sage: f = Z^(1/3) - sage: f # optional - sage.symbolic + sage: f 1 + 1/3/2^s + 1/3/3^s + 2/9/4^s + 1/3/5^s + 1/9/6^s + 1/3/7^s + O(1/(8^s)) - sage: f^2 # optional - sage.symbolic + sage: f^2 1 + 2/3/2^s + 2/3/3^s + 5/9/4^s + 2/3/5^s + 4/9/6^s + 2/3/7^s + O(1/(8^s)) - sage: f^3 - Z # optional - sage.symbolic + sage: f^3 - Z O(1/(8^s)) sage: L. = LazyLaurentSeriesRing(QQ) @@ -2706,12 +2715,12 @@ def sqrt(self): This also works for Dirichlet series:: + sage: # needs sage.symbolic sage: D = LazyDirichletSeriesRing(SR, "s") sage: Z = D(constant=1) - sage: f = sqrt(Z) - sage: f # optional - sage.symbolic + sage: f = sqrt(Z); f 1 + 1/2/2^s + 1/2/3^s + 3/8/4^s + 1/2/5^s + 1/4/6^s + 1/2/7^s + O(1/(8^s)) - sage: f*f - Z # optional - sage.symbolic + sage: f*f - Z O(1/(8^s)) """ return self ** QQ((1, 2)) # == 1/2 @@ -2820,6 +2829,7 @@ def _mul_(self, other): Multiplication of series with eventually constant coefficients may yield another such series:: + sage: # needs sage.symbolic sage: L. = LazyLaurentSeriesRing(SR) sage: var("a b c d e u v w") (a, b, c, d, e, u, v, w) @@ -2966,8 +2976,8 @@ def __pow__(self, n): We also support the general case:: - sage: L. = LazyLaurentSeriesRing(SR) - sage: (1 + z)^(1 + z) + sage: L. = LazyLaurentSeriesRing(SR) # needs sage.symbolic + sage: (1 + z)^(1 + z) # needs sage.symbolic 1 + z + z^2 + 1/2*z^3 + 1/3*z^4 + 1/12*z^5 + 3/40*z^6 + O(z^7) TESTS: @@ -3036,6 +3046,7 @@ def __invert__(self): We can also compute the multiplicative inverse of a symmetric function:: + sage: # needs sage.modules sage: h = SymmetricFunctions(QQ).h() sage: p = SymmetricFunctions(QQ).p() sage: L = LazySymmetricFunctions(p) @@ -3043,7 +3054,7 @@ def __invert__(self): sage: (~E)[:4] [p[], -p[1], 1/2*p[1, 1] - 1/2*p[2], -1/6*p[1, 1, 1] + 1/2*p[2, 1] - 1/3*p[3]] - sage: (E * ~E)[:6] + sage: (E * ~E)[:6] # needs sage.modules [p[], 0, 0, 0, 0, 0] TESTS:: @@ -3154,9 +3165,9 @@ def _div_(self, other): An example over the ring of symmetric functions:: - sage: e = SymmetricFunctions(QQ).e() - sage: R. = LazyLaurentSeriesRing(e) - sage: 1 / (1 - e[1]*z) + sage: e = SymmetricFunctions(QQ).e() # needs sage.modules + sage: R. = LazyLaurentSeriesRing(e) # needs sage.modules + sage: 1 / (1 - e[1]*z) # needs sage.modules e[] + e[1]*z + e[1, 1]*z^2 + e[1, 1, 1]*z^3 + e[1, 1, 1, 1]*z^4 + e[1, 1, 1, 1, 1]*z^5 + e[1, 1, 1, 1, 1, 1]*z^6 + O(e[]*z^7) @@ -3166,7 +3177,7 @@ def _div_(self, other): sage: 1 / (1 - y) 1 + y + y^2 + y^3 + y^4 + y^5 + y^6 + O(x,y)^7 - sage: (x + y) / (1 - y) + sage: (x + y) / (1 - y) # needs sage.libs.singular (x+y) + (x*y+y^2) + (x*y^2+y^3) + (x*y^3+y^4) + (x*y^4+y^5) + (x*y^5+y^6) + (x*y^6+y^7) + O(x,y)^8 TESTS:: @@ -3342,7 +3353,7 @@ def exp(self): 1 + z + 1/2*z^2 + 1/6*z^3 + 1/24*z^4 + 1/120*z^5 + 1/720*z^6 + O(z^7) sage: exp(z + z^2) 1 + z + 3/2*z^2 + 7/6*z^3 + 25/24*z^4 + 27/40*z^5 + 331/720*z^6 + O(z^7) - sage: exp(0) + sage: exp(0) # needs sage.symbolic 1 sage: exp(1 + z) Traceback (most recent call last): @@ -3357,7 +3368,7 @@ def exp(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic sage: exp(z)[0:6] == exp(x).series(x, 6).coefficients(sparse=False) True @@ -3409,8 +3420,8 @@ def log(self): TESTS:: - sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") - sage: log(1+z)[0:6] == log(1+x).series(x, 6).coefficients(sparse=False) + sage: L. = LazyLaurentSeriesRing(QQ); x = var("x") # needs sage.symbolic + sage: log(1+z)[0:6] == log(1+x).series(x, 6).coefficients(sparse=False) # needs sage.symbolic True sage: log(z) @@ -3541,17 +3552,17 @@ def _im_gens_(self, codomain, im_gens, base_map=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: Z. = ZZ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: R. = LazyLaurentSeriesRing(K) # optional - sage.rings.number_field - sage: f = R(lambda n: i^n, valuation=-2); f # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: R. = LazyLaurentSeriesRing(K) + sage: f = R(lambda n: i^n, valuation=-2); f -t^-2 - i*t^-1 + 1 + i*t - t^2 - i*t^3 + t^4 + O(t^5) - sage: f._im_gens_(R, [t + t^2]) # optional - sage.rings.number_field + sage: f._im_gens_(R, [t + t^2]) -t^-2 + (-i + 2)*t^-1 + (i - 2) + 4*t + (2*i - 6)*t^2 + (-2*i + 4)*t^3 + (-2*i - 7)*t^4 + O(t^5) - - sage: cc = K.hom([-i]) # optional - sage.rings.number_field - sage: f._im_gens_(R, [t + t^2], base_map=cc) # optional - sage.rings.number_field + sage: cc = K.hom([-i]) + sage: f._im_gens_(R, [t + t^2], base_map=cc) -t^-2 + (i + 2)*t^-1 + (-i - 2) + 4*t + (-2*i - 6)*t^2 + (2*i + 4)*t^3 + (2*i - 7)*t^4 + O(t^5) """ @@ -3788,7 +3799,7 @@ def __call__(self, g, *, check=True): sage: e = L(lambda n: 1/factorial(n), 0) sage: D = LazyDirichletSeriesRing(QQ, "s") sage: g = D(constant=1)-1 - sage: g # optional - sage.symbolic + sage: g # needs sage.symbolic 1/(2^s) + 1/(3^s) + 1/(4^s) + O(1/(5^s)) sage: e(g)[0:10] @@ -3798,7 +3809,7 @@ def __call__(self, g, *, check=True): [0, 1, 1, 1, 3/2, 1, 2, 1, 13/6, 3/2] sage: g = D([0,1,0,1,1,2]) - sage: g # optional - sage.symbolic + sage: g # needs sage.symbolic 1/(2^s) + 1/(4^s) + 1/(5^s) + 2/6^s sage: e(g)[0:10] [0, 1, 1, 0, 3/2, 1, 2, 0, 7/6, 0] @@ -3811,11 +3822,11 @@ def __call__(self, g, *, check=True): ValueError: can only compose with a positive valuation series sage: e5 = L(e, degree=5) - sage: e5 # optional - sage.symbolic + sage: e5 1 + z + 1/2*z^2 + 1/6*z^3 + 1/24*z^4 - sage: e5(g) # optional - sage.symbolic + sage: e5(g) # needs sage.symbolic 1 + 1/(2^s) + 3/2/4^s + 1/(5^s) + 2/6^s + O(1/(8^s)) - sage: sum(e5[k] * g^k for k in range(5)) # optional - sage.symbolic + sage: sum(e5[k] * g^k for k in range(5)) # needs sage.symbolic 1 + 1/(2^s) + 3/2/4^s + 1/(5^s) + 2/6^s + O(1/(8^s)) The output parent is always the common parent between the base ring @@ -4606,9 +4617,10 @@ def __call__(self, *g, check=True): We perform the composition with a lazy Dirichlet series:: + sage: # needs sage.symbolic sage: D = LazyDirichletSeriesRing(QQ, "s") sage: g = D(constant=1)-1 - sage: g # optional - sage.symbolic + sage: g 1/(2^s) + 1/(3^s) + 1/(4^s) + O(1/(5^s)) sage: f = 1 / (1 - x - y*z); f 1 + x + (x^2+y*z) + (x^3+2*x*y*z) + (x^4+3*x^2*y*z+y^2*z^2) @@ -4616,18 +4628,18 @@ def __call__(self, *g, check=True): + (x^6+5*x^4*y*z+6*x^2*y^2*z^2+y^3*z^3) + O(x,y,z)^7 sage: fog = f(g, g, g) - sage: fog # optional - sage.symbolic + sage: fog 1 + 1/(2^s) + 1/(3^s) + 3/4^s + 1/(5^s) + 5/6^s + O(1/(7^s)) sage: fg = 1 / (1 - g - g*g) - sage: fg # optional - sage.symbolic + sage: fg 1 + 1/(2^s) + 1/(3^s) + 3/4^s + 1/(5^s) + 5/6^s + 1/(7^s) + O(1/(8^s)) - sage: fog - fg # optional - sage.symbolic + sage: fog - fg O(1/(8^s)) sage: f = 1 / (1 - 2*a) - sage: f(g) # optional - sage.symbolic + sage: f(g) # needs sage.symbolic 1 + 2/2^s + 2/3^s + 6/4^s + 2/5^s + 10/6^s + 2/7^s + O(1/(8^s)) - sage: 1 / (1 - 2*g) # optional - sage.symbolic + sage: 1 / (1 - 2*g) # needs sage.symbolic 1 + 2/2^s + 2/3^s + 6/4^s + 2/5^s + 10/6^s + 2/7^s + O(1/(8^s)) The output parent is always the common parent between the base ring @@ -5276,11 +5288,11 @@ def _floordiv_(self, other): sage: g = x^2 + y*x sage: x // g 0 - sage: g = (x^2 + y*x) / (1 - x + x*y) + sage: g = (x^2 + y*x) / (1 - x + x*y) # needs sage.libs.singular sage: x // g 0 - sage: f = (x + y) / (1 - x - y + x*y) - sage: f // g + sage: f = (x + y) / (1 - x - y + x*y) # needs sage.libs.singular + sage: f // g # needs sage.libs.singular 0 sage: L. = LazyPowerSeriesRing(QQ) @@ -5385,6 +5397,7 @@ def xgcd(self, f): sage: g == s * a + t * b True + sage: # needs sage.rings.finite_rings sage: L. = LazyPowerSeriesRing(GF(2)) sage: a = L(lambda n: n % 2, valuation=3); a x^3 + x^5 + x^7 + x^9 + O(x^10) @@ -5439,6 +5452,7 @@ def _format_series(self, formatter, format_strings=False): TESTS:: + sage: # needs sage.modules sage: h = SymmetricFunctions(ZZ).h() sage: e = SymmetricFunctions(ZZ).e() sage: L = LazySymmetricFunctions(tensor([h, e])) @@ -5514,8 +5528,8 @@ class LazySymmetricFunction(LazyCompletionGradedAlgebraElement): EXAMPLES:: - sage: s = SymmetricFunctions(ZZ).s() - sage: L = LazySymmetricFunctions(s) + sage: s = SymmetricFunctions(ZZ).s() # needs sage.modules + sage: L = LazySymmetricFunctions(s) # needs sage.modules """ def is_unit(self): """ @@ -5523,21 +5537,17 @@ def is_unit(self): EXAMPLES:: + sage: # needs sage.modules sage: m = SymmetricFunctions(ZZ).m() sage: L = LazySymmetricFunctions(m) - sage: L(2*m[1]).is_unit() False - sage: L(-1 + 2*m[1]).is_unit() True - sage: L(2 + m[1]).is_unit() False - sage: m = SymmetricFunctions(QQ).m() sage: L = LazySymmetricFunctions(m) - sage: L(2 + 3*m[1]).is_unit() True """ @@ -5581,6 +5591,7 @@ def __call__(self, *args, check=True): EXAMPLES:: + sage: # needs sage.modules sage: P. = QQ[] sage: s = SymmetricFunctions(P).s() sage: L = LazySymmetricFunctions(s) @@ -5588,15 +5599,12 @@ def __call__(self, *args, check=True): sage: g = s[3] sage: L(f)(L(g)) - L(f(g)) 0 - sage: f = s[2] + s[2,1] sage: g = s[1] + s[2,2] sage: L(f)(L(g)) - L(f(g)) 0 - sage: L(f)(g) - L(f(g)) 0 - sage: f = s[2] + s[2,1] sage: g = s[1] + s[2,2] sage: L(f)(L(q*g)) - L(f(q*g)) @@ -5605,6 +5613,7 @@ def __call__(self, *args, check=True): The Frobenius character of the permutation action on set partitions is a plethysm:: + sage: # needs sage.modules sage: s = SymmetricFunctions(QQ).s() sage: S = LazySymmetricFunctions(s) sage: E1 = S(lambda n: s[n], valuation=1) @@ -5615,6 +5624,7 @@ def __call__(self, *args, check=True): The plethysm with a tensor product is also implemented:: + sage: # needs sage.modules sage: s = SymmetricFunctions(QQ).s() sage: X = tensor([s[1],s[[]]]) sage: Y = tensor([s[[]],s[1]]) @@ -5622,14 +5632,14 @@ def __call__(self, *args, check=True): sage: S2 = LazySymmetricFunctions(tensor([s, s])) sage: A = S(s[1,1,1]) sage: B = S2(X+Y) - sage: A(B) + sage: A(B) # needs lrcalc_python (s[]#s[1,1,1]+s[1]#s[1,1]+s[1,1]#s[1]+s[1,1,1]#s[]) - sage: H = S(lambda n: s[n]) - sage: H(S2(X*Y)) + sage: H = S(lambda n: s[n]) # needs sage.modules + sage: H(S2(X*Y)) # needs lrcalc_python sage.modules (s[]#s[]) + (s[1]#s[1]) + (s[1,1]#s[1,1]+s[2]#s[2]) + (s[1,1,1]#s[1,1,1]+s[2,1]#s[2,1]+s[3]#s[3]) + O^7 - sage: H(S2(X+Y)) + sage: H(S2(X+Y)) # needs sage.modules (s[]#s[]) + (s[]#s[1]+s[1]#s[]) + (s[]#s[2]+s[1]#s[1]+s[2]#s[]) + (s[]#s[3]+s[1]#s[2]+s[2]#s[1]+s[3]#s[]) + (s[]#s[4]+s[1]#s[3]+s[2]#s[2]+s[3]#s[1]+s[4]#s[]) @@ -5639,22 +5649,23 @@ def __call__(self, *args, check=True): TESTS:: + sage: # needs sage.modules sage: s = SymmetricFunctions(QQ).s() sage: S = LazySymmetricFunctions(s) sage: f = 1 / (1 - S(s[2])) - sage: g = f(s[2]); g + sage: g = f(s[2]); g # needs lrcalc_python s[] + (s[2,2]+s[4]) + O^7 - sage: S(sum(f[i](s[2]) for i in range(5))).truncate(10) == g.truncate(10) + sage: S(sum(f[i](s[2]) for i in range(5))).truncate(10) == g.truncate(10) # needs lrcalc_python True sage: f = 1 / (1 - S(s[2])) sage: g = S(s[1]) / (1 - S(s[1])) - sage: f(g) + sage: f(g) # needs lrcalc_python s[] + s[2] + (s[1,1,1]+2*s[2,1]+s[3]) + (2*s[1,1,1,1]+4*s[2,1,1]+5*s[2,2]+5*s[3,1]+3*s[4]) + (2*s[1,1,1,1,1]+10*s[2,1,1,1]+14*s[2,2,1]+18*s[3,1,1]+16*s[3,2]+14*s[4,1]+4*s[5]) + (3*s[1,1,1,1,1,1]+22*s[2,1,1,1,1]+38*s[2,2,1,1]+28*s[2,2,2]+48*s[3,1,1,1]+82*s[3,2,1]+25*s[3,3]+51*s[4,1,1]+56*s[4,2]+31*s[5,1]+9*s[6]) + O^7 - sage: f(0) + sage: f(0) # needs lrcalc_python 1 sage: f(s(1)) Traceback (most recent call last): @@ -5664,6 +5675,7 @@ def __call__(self, *args, check=True): Check that composing the zero series with anything yields zero in the correct parent:: + sage: # needs sage.modules sage: e = SymmetricFunctions(QQ).e() sage: h = SymmetricFunctions(QQ).h() sage: s = SymmetricFunctions(QQ).s() @@ -5676,10 +5688,10 @@ def __call__(self, *args, check=True): Check that composing `f` with zero series yields the constant term of `f`:: - sage: f = 3*L(tensor([s[1], s[1]])) - sage: f(0, 0) + sage: f = 3*L(tensor([s[1], s[1]])) # needs sage.modules + sage: f(0, 0) # needs sage.modules 0 - sage: (3+f)(0, 0) + sage: (3+f)(0, 0) # needs sage.modules 3 """ fP = parent(self) @@ -5766,6 +5778,7 @@ def revert(self): EXAMPLES:: + sage: # needs sage.modules sage: h = SymmetricFunctions(QQ).h() sage: L = LazySymmetricFunctions(h) sage: f = L(lambda n: h[n]) - 1 @@ -5774,30 +5787,28 @@ def revert(self): TESTS:: - sage: f = L(lambda n: h[n]) - 1 - h[1] - sage: g = f.revert() - sage: g[1] + sage: f = L(lambda n: h[n]) - 1 - h[1] # needs sage.modules + sage: g = f.revert() # needs sage.modules + sage: g[1] # needs sage.modules Traceback (most recent call last): ... ValueError: compositional inverse does not exist + sage: # needs sage.modules sage: R. = QQ[] sage: p = SymmetricFunctions(R.fraction_field()).p() sage: L = LazySymmetricFunctions(p) sage: f = L(a + b*p[1]) sage: f.revert() (((-a)/b)*p[]) + 1/b*p[1] - sage: f = L(2*p[1]) sage: f.revert() 1/2*p[1] - sage: f = L(2*p[1] + p[1,1]) sage: f.revert() 1/2*p[1] + (-1/8*p[1,1]) + (1/16*p[1,1,1]) + (-5/128*p[1,1,1,1]) + (7/256*p[1,1,1,1,1]) + (-21/1024*p[1,1,1,1,1,1]) + (33/2048*p[1,1,1,1,1,1,1]) + O^8 - sage: f.revert()(f) p[1] + O^8 @@ -5891,6 +5902,7 @@ def derivative_with_respect_to_p1(self, n=1): The species `E` of sets satisfies the relationship `E' = E`:: + sage: # needs sage.modules sage: h = SymmetricFunctions(QQ).h() sage: T = LazySymmetricFunctions(h) sage: E = T(lambda n: h[n]) @@ -5900,14 +5912,17 @@ def derivative_with_respect_to_p1(self, n=1): The species `C` of cyclic orderings and the species `L` of linear orderings satisfy the relationship `C' = L`:: + sage: # needs sage.modules sage: p = SymmetricFunctions(QQ).p() - sage: C = T(lambda n: (sum(euler_phi(k)*p([k])**(n//k) for k in divisors(n))/n if n > 0 else 0)) + sage: C = T(lambda n: (sum(euler_phi(k)*p([k])**(n//k) + ....: for k in divisors(n))/n if n > 0 else 0)) sage: L = T(lambda n: p([1]*n)) - sage: L - C.derivative_with_respect_to_p1() + sage: L - C.derivative_with_respect_to_p1() # needs sage.libs.pari O^6 TESTS:: + sage: # needs sage.modules sage: T = LazySymmetricFunctions(p) sage: a = T(p([1,1,1])) sage: a.derivative_with_respect_to_p1() @@ -5970,13 +5985,14 @@ def functorial_composition(self, *args): \mathfrak{p}_{2}`, where `\mathfrak{p}` is the :class:`~sage.combinat.species.subset_species.SubsetSpecies`.:: + sage: # needs sage.modules sage: R. = QQ[] sage: h = SymmetricFunctions(R).h() sage: m = SymmetricFunctions(R).m() sage: L = LazySymmetricFunctions(m) sage: P = L(lambda n: sum(q^k*h[n-k]*h[k] for k in range(n+1))) sage: P2 = L(lambda n: h[2]*h[n-2], valuation=2) - sage: P.functorial_composition(P2)[:4] + sage: P.functorial_composition(P2)[:4] # needs sage.libs.pari [m[], m[1], (q+1)*m[1, 1] + (q+1)*m[2], @@ -5984,12 +6000,12 @@ def functorial_composition(self, *args): For example, there are:: - sage: P.functorial_composition(P2)[4].coefficient([4])[3] + sage: P.functorial_composition(P2)[4].coefficient([4])[3] # needs sage.libs.pari sage.modules 3 unlabelled graphs on 4 vertices and 3 edges, and:: - sage: P.functorial_composition(P2)[4].coefficient([2,2])[3] + sage: P.functorial_composition(P2)[4].coefficient([2,2])[3] # needs sage.libs.pari sage.modules 8 labellings of their vertices with two 1's and two 2's. @@ -5997,6 +6013,7 @@ def functorial_composition(self, *args): The symmetric function `h_1 \sum_n h_n` is the neutral element with respect to functorial composition:: + sage: # needs sage.modules sage: p = SymmetricFunctions(QQ).p() sage: h = SymmetricFunctions(QQ).h() sage: e = SymmetricFunctions(QQ).e() @@ -6005,7 +6022,7 @@ def functorial_composition(self, *args): sage: Ep = p[1]*H.derivative_with_respect_to_p1(); Ep h[1] + (h[1,1]) + (h[2,1]) + (h[3,1]) + (h[4,1]) + (h[5,1]) + O^7 sage: f = L(lambda n: h[n-n//2, n//2]) - sage: f - Ep.functorial_composition(f) + sage: f - Ep.functorial_composition(f) # needs sage.libs.pari O^7 The symmetric function `\sum_n h_n` is a left absorbing element:: @@ -6015,30 +6032,32 @@ def functorial_composition(self, *args): The functorial composition distributes over the sum:: + sage: # needs sage.modules sage: F1 = L(lambda n: h[n]) sage: F2 = L(lambda n: e[n]) sage: f1 = F1.functorial_composition(f) sage: f2 = F2.functorial_composition(f) - sage: (F1 + F2).functorial_composition(f) - f1 - f2 # long time + sage: (F1 + F2).functorial_composition(f) - f1 - f2 # long time O^7 TESTS: Check a corner case:: - sage: h = SymmetricFunctions(QQ).h() - sage: L = LazySymmetricFunctions(h) - sage: L(h[2,1]).functorial_composition(3*h[0]) + sage: h = SymmetricFunctions(QQ).h() # needs sage.modules + sage: L = LazySymmetricFunctions(h) # needs sage.modules + sage: L(h[2,1]).functorial_composition(3*h[0]) # needs sage.libs.pari sage.modules 3*h[] + O^7 Check an instance of a non-group action:: + sage: # needs sage.modules sage: s = SymmetricFunctions(QQ).s() sage: p = SymmetricFunctions(QQ).p() sage: L = LazySymmetricFunctions(p) sage: f = L(lambda n: s[n]) sage: g = 2*s[2, 1, 1] + s[2, 2] + 3*s[4] - sage: r = f.functorial_composition(g); r[4] + sage: r = f.functorial_composition(g); r[4] # needs sage.libs.pari Traceback (most recent call last): ... ValueError: the argument is not the Frobenius character of a permutation representation @@ -6194,14 +6213,15 @@ def arithmetic_product(self, *args, check=True): consistent for all the lists in the structure. :: sage: R. = QQ[] - sage: p = SymmetricFunctions(R).p() - sage: m = SymmetricFunctions(R).m() - sage: L = LazySymmetricFunctions(m) + sage: p = SymmetricFunctions(R).p() # needs sage.modules + sage: m = SymmetricFunctions(R).m() # needs sage.modules + sage: L = LazySymmetricFunctions(m) # needs sage.modules + sage: # needs sage.modules sage: C = species.CycleSpecies().cycle_index_series() sage: c = L(lambda n: C[n]) sage: Lplus = L(lambda n: p([1]*n), valuation=1) - sage: r = c.arithmetic_product(Lplus); r + sage: r = c.arithmetic_product(Lplus); r # needs sage.libs.pari m[1] + (3*m[1,1]+2*m[2]) + (8*m[1,1,1]+4*m[2,1]+2*m[3]) + (42*m[1,1,1,1]+21*m[2,1,1]+12*m[2,2]+7*m[3,1]+3*m[4]) @@ -6211,7 +6231,7 @@ def arithmetic_product(self, *args, check=True): In particular, the number of regular octopuses is:: - sage: [r[n].coefficient([1]*n) for n in range(8)] + sage: [r[n].coefficient([1]*n) for n in range(8)] # needs sage.libs.pari sage.modules [0, 1, 3, 8, 42, 144, 1440, 5760] It is shown in [MM2008]_ that the exponential generating @@ -6219,7 +6239,7 @@ def arithmetic_product(self, *args, check=True): (x) = \sum_{n \geq 1} \sigma (n) (n - 1)! \frac{x^{n}}{n!}` (where `\sigma (n)` is the sum of the divisors of `n`). :: - sage: [sum(divisors(i))*factorial(i-1) for i in range(1,8)] + sage: [sum(divisors(i))*factorial(i-1) for i in range(1,8)] # needs sage.modules [1, 3, 8, 42, 144, 1440, 5760] AUTHORS: @@ -6234,6 +6254,7 @@ def arithmetic_product(self, *args, check=True): Check that the product with zero works:: + sage: # needs sage.modules sage: s = SymmetricFunctions(QQ).s() sage: L = LazySymmetricFunctions(s) sage: L(0).arithmetic_product(s[2]) @@ -6244,27 +6265,27 @@ def arithmetic_product(self, *args, check=True): Check that the arithmetic product of symmetric functions of finite support works:: - sage: L(s([2])).arithmetic_product(s([1,1,1])) + sage: L(s([2])).arithmetic_product(s([1,1,1])) # needs sage.modules s[2, 2, 1, 1] + s[3, 1, 1, 1] + s[3, 2, 1] + s[3, 3] + 2*s[4, 1, 1] - sage: f = 1/(1-L(s[1])) - sage: f.arithmetic_product(s[1]) - f + sage: f = 1/(1-L(s[1])) # needs sage.modules + sage: f.arithmetic_product(s[1]) - f # needs lrcalc_python sage.modules O^7 Check that the arithmetic product of symmetric functions with constant a term works as advertised:: - sage: p = SymmetricFunctions(QQ).p() - sage: L = LazySymmetricFunctions(p) - sage: L(5).arithmetic_product(3*p[2,1]) + sage: p = SymmetricFunctions(QQ).p() # needs sage.modules + sage: L = LazySymmetricFunctions(p) # needs sage.modules + sage: L(5).arithmetic_product(3*p[2,1]) # needs sage.modules 15*p[] Check the arithmetic product of symmetric functions over a finite field works:: - sage: s = SymmetricFunctions(FiniteField(2)).s() - sage: L = LazySymmetricFunctions(s) - sage: L(s([2])).arithmetic_product(s([1,1,1])) + sage: s = SymmetricFunctions(FiniteField(2)).s() # needs sage.modules + sage: L = LazySymmetricFunctions(s) # needs sage.modules + sage: L(s([2])).arithmetic_product(s([1,1,1])) # needs sage.modules s[2, 2, 1, 1] + s[3, 1, 1, 1] + s[3, 2, 1] + s[3, 3] """ @@ -6361,6 +6382,7 @@ def symmetric_function(self, degree=None): EXAMPLES:: + sage: # needs sage.modules sage: s = SymmetricFunctions(QQ).s() sage: S = LazySymmetricFunctions(s) sage: elt = S(s[2]) @@ -6369,28 +6391,30 @@ def symmetric_function(self, degree=None): TESTS:: + sage: # needs sage.modules sage: s = SymmetricFunctions(QQ).s() sage: S = LazySymmetricFunctions(s) sage: elt = S(s[2]) sage: elt.symmetric_function() s[2] sage: f = 1 / (1 - elt) - sage: f + sage: f # needs lrcalc_python s[] + s[2] + (s[2,2]+s[3,1]+s[4]) + (s[2,2,2]+2*s[3,2,1]+s[3,3]+s[4,1,1]+3*s[4,2]+2*s[5,1]+s[6]) + O^7 sage: f.symmetric_function() Traceback (most recent call last): ... ValueError: not a symmetric function - sage: f4 = f.truncate(5); f4 + sage: # needs sage.modules + sage: f4 = f.truncate(5); f4 # needs lrcalc_python s[] + s[2] + (s[2,2]+s[3,1]+s[4]) - sage: f4.symmetric_function() + sage: f4.symmetric_function() # needs lrcalc_python s[] + s[2] + s[2, 2] + s[3, 1] + s[4] - sage: f4.symmetric_function() == f.symmetric_function(4) + sage: f4.symmetric_function() == f.symmetric_function(4) # needs lrcalc_python True sage: S.zero().symmetric_function() 0 - sage: f4.symmetric_function(0) + sage: f4.symmetric_function(0) # needs lrcalc_python s[] """ @@ -6420,15 +6444,15 @@ class LazyDirichletSeries(LazyModuleElement): sage: L = LazyDirichletSeriesRing(ZZ, "z") sage: f = L(constant=1)^2 - sage: f # optional - sage.symbolic + sage: f # needs sage.symbolic 1 + 2/2^z + 2/3^z + 3/4^z + 2/5^z + 4/6^z + 2/7^z + O(1/(8^z)) - sage: f.coefficient(100) == number_of_divisors(100) + sage: f.coefficient(100) == number_of_divisors(100) # needs sage.libs.pari True Lazy Dirichlet series is picklable:: sage: g = loads(dumps(f)) - sage: g # optional - sage.symbolic + sage: g # needs sage.symbolic 1 + 2/2^z + 2/3^z + 3/4^z + 2/5^z + 4/6^z + 2/7^z + O(1/(8^z)) sage: g == f True @@ -6468,14 +6492,14 @@ def valuation(self): EXAMPLES:: sage: L = LazyDirichletSeriesRing(ZZ, "z") - sage: mu = L(moebius); mu.valuation() + sage: mu = L(moebius); mu.valuation() # needs sage.libs.pari 0 - sage: (mu - mu).valuation() + sage: (mu - mu).valuation() # needs sage.libs.pari +Infinity sage: g = L(constant=1, valuation=2) - sage: g.valuation() + sage: g.valuation() # needs sage.symbolic log(2) - sage: (g*g).valuation() + sage: (g*g).valuation() # needs sage.symbolic 2*log(2) """ if isinstance(self._coeff_stream, Stream_zero): @@ -6495,36 +6519,36 @@ def _mul_(self, other): sage: D = LazyDirichletSeriesRing(QQ, "s") sage: zeta = D(constant=1) - sage: zeta # optional - sage.symbolic + sage: zeta # needs sage.symbolic 1 + 1/(2^s) + 1/(3^s) + O(1/(4^s)) - sage: zeta * zeta # optional - sage.symbolic + sage: zeta * zeta # needs sage.symbolic 1 + 2/2^s + 2/3^s + 3/4^s + 2/5^s + 4/6^s + 2/7^s + O(1/(8^s)) - sage: [number_of_divisors(n) for n in range(1, 8)] + sage: [number_of_divisors(n) for n in range(1, 8)] # needs sage.libs.pari [1, 2, 2, 3, 2, 4, 2] sage: mu = D(moebius) - sage: mu # optional - sage.symbolic + sage: mu # needs sage.symbolic 1 - 1/(2^s) - 1/(3^s) - 1/(5^s) + 1/(6^s) - 1/(7^s) + O(1/(8^s)) - sage: zeta * mu # optional - sage.symbolic + sage: zeta * mu # needs sage.symbolic 1 + O(1/(8^s)) sage: D.one() * mu is mu True sage: mu * D.one() is mu True - sage: zeta*(2-zeta) # optional - sage.symbolic + sage: zeta*(2-zeta) # needs sage.symbolic 1 - 1/(4^s) - 2/6^s + O(1/(8^s)) sage: d1 = D([0,0,1,2,3]) sage: d2 = D([0,1,2,3]) - sage: d1 * d2 # optional - sage.symbolic + sage: d1 * d2 # needs sage.symbolic 1/(6^s) + 2/8^s + 2/9^s + 3/10^s + 7/12^s + O(1/(13^s)) - sage: d1 * d2 # not tested - exact result # optional - sage.symbolic + sage: d1 * d2 # not tested # needs sage.symbolic 1/(6^s) + 2/8^s + 2/9^s + 3/10^s + 7/12^s + 6/15^s + 6/16^s + 9/20^s sage: L. = LazyLaurentSeriesRing(D) - sage: 1/(1-t*zeta) # optional - sage.symbolic + sage: 1/(1-t*zeta) # needs sage.symbolic (1 + O(1/(8^s))) + (1 + 1/(2^s) + 1/(3^s) + 1/(4^s) + 1/(5^s) + 1/(6^s) + 1/(7^s) + O(1/(8^s)))*t + (1 + 2/2^s + 2/3^s + 3/4^s + 2/5^s + 4/6^s + 2/7^s + O(1/(8^s)))*t^2 @@ -6572,10 +6596,10 @@ def __invert__(self): TESTS:: sage: L = LazyDirichletSeriesRing(ZZ, "z", sparse=False) - sage: ~L(constant=1) - L(moebius) + sage: ~L(constant=1) - L(moebius) # needs sage.libs.pari O(1/(8^z)) sage: L = LazyDirichletSeriesRing(ZZ, "z", sparse=True) - sage: ~L(constant=1) - L(moebius) + sage: ~L(constant=1) - L(moebius) # needs sage.libs.pari O(1/(8^z)) Trying to invert a non-invertible 'exact' series raises a @@ -6622,12 +6646,13 @@ def __call__(self, p, *, check=True): sage: Z = D(constant=1) sage: from sage.arith.misc import dedekind_psi sage: Psi = D(dedekind_psi) - sage: Z(s)*Z(s-1)/Z(2*s) - Psi + sage: Z(s)*Z(s-1)/Z(2*s) - Psi # needs sage.symbolic O(1/(8^s)) - sage: Z(s)*Z(s-1)/Z(2*s-2) - (1/Psi).map_coefficients(abs) + sage: Z(s)*Z(s-1)/Z(2*s-2) - (1/Psi).map_coefficients(abs) # needs sage.symbolic O(1/(8^s)) + sage: # needs sage.symbolic sage: Z(5) zeta(5) sage: Z(1+I) @@ -6638,7 +6663,7 @@ def __call__(self, p, *, check=True): Infinity sage: f = D([1,2,-3,-4], valuation=2) - sage: f # optional - sage.symbolic + sage: f # needs sage.symbolic 1/(2^s) + 2/3^s - 3/4^s - 4/5^s sage: f(2) 449/3600 @@ -6656,11 +6681,11 @@ def __call__(self, p, *, check=True): 5 sage: f = D([1,2,-3,-4], constant=2) - sage: bool(f(2) == -1 + -5/3^2 + -6/4^2 + 2*zeta(2)) + sage: bool(f(2) == -1 + -5/3^2 + -6/4^2 + 2*zeta(2)) # needs sage.symbolic True - sage: f(0) + sage: f(0) # needs sage.symbolic -13 - sage: f(1) + sage: f(1) # needs sage.symbolic Infinity """ P = self.parent() @@ -6706,24 +6731,22 @@ def _format_series(self, formatter, format_strings=False): TESTS:: + sage: # needs sage.symbolic sage: L = LazyDirichletSeriesRing(QQ, "s") sage: f = L(constant=1) - sage: f._format_series(repr) # optional - sage.symbolic + sage: f._format_series(repr) '1 + 1/(2^s) + 1/(3^s) + O(1/(4^s))' - sage: f._format_series(unicode_art) # optional - sage.symbolic + sage: f._format_series(unicode_art) -s -s 1 + 2 + 3 + O(1/(4^s)) - - sage: L([1,-1,1])._format_series(repr) # optional - sage.symbolic + sage: L([1,-1,1])._format_series(repr) '1 - 1/(2^s) + 1/(3^s)' - - sage: L([1,-1,1])._format_series(ascii_art) # optional - sage.symbolic + sage: L([1,-1,1])._format_series(ascii_art) -s -s 1 + -2 + 3 - sage: R. = QQ[] sage: L = LazyDirichletSeriesRing(R, "s") - sage: L([1,-1 + x,1/3])._format_series(ascii_art) # optional - sage.symbolic + sage: L([1,-1 + x,1/3])._format_series(ascii_art) ( -s) (3 ) ( -s ) (---) @@ -6732,9 +6755,9 @@ def _format_series(self, formatter, format_strings=False): sage: L. = LazyLaurentSeriesRing(QQ) sage: D = LazyDirichletSeriesRing(L, "s") sage: f = D([2, 0, 1/(1-z), 3]) - sage: f # optional - sage.symbolic + sage: f # needs sage.symbolic (2)/1^s + ((1+z+z^2+O(z^3))/3^s) + (3)/4^s - sage: f._format_series(ascii_art) # optional - sage.symbolic + sage: f._format_series(ascii_art) # needs sage.symbolic ((2)/1^s) + ((1 + z + z^2 + O(z^3))/3^s) + ((3)/4^s) """ P = self.parent() diff --git a/src/sage/rings/lazy_series_ring.py b/src/sage/rings/lazy_series_ring.py index 32545f65574..c36328731df 100644 --- a/src/sage/rings/lazy_series_ring.py +++ b/src/sage/rings/lazy_series_ring.py @@ -155,10 +155,10 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No If ``x`` can be converted into an element of the underlying Laurent polynomial ring, we do this:: - sage: L = LazyLaurentSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings - sage: L(2) # optional - sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(2), 'z') + sage: L(2) 0 - sage: L(3) # optional - sage.rings.finite_rings + sage: L(3) 1 In particular, ``x`` can be a Laurent polynomial:: @@ -256,13 +256,13 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No sage: D = LazyDirichletSeriesRing(QQ, "s") sage: L. = LazyLaurentSeriesRing(D) - sage: L(lambda n: 1/factorial(n), valuation=0) + sage: L(lambda n: 1/factorial(n), valuation=0) # needs sage.symbolic (1 + 1/2/2^s + 1/6/3^s + 1/24/4^s + 1/120/5^s + 1/720/6^s + 1/5040/7^s + O(1/(8^s))) We can also specify that the given function should be interpreted as the coefficients of the Laurent series:: - sage: L(coefficients=lambda n: 1/factorial(n), valuation=0) + sage: L(coefficients=lambda n: 1/factorial(n), valuation=0) # needs sage.symbolic 1 + z + 1/2*z^2 + 1/6*z^3 + 1/24*z^4 + 1/120*z^5 + 1/720*z^6 + O(z^7) When the argument ``x`` is callable and not convertible into @@ -272,14 +272,14 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No sage: R. = QQ[] sage: D = LazyDirichletSeriesRing(ZZ, 't') - sage: D(1+2*q) + sage: D(1+2*q) # needs sage.symbolic 3 + 5/2^t + 7/3^t + 9/4^t + 11/5^t + 13/6^t + 15/7^t + O(1/(8^t)) In this example, the Dirichlet series ``m`` is considered as an element in the base ring:: sage: m = D(moebius) - sage: s = L(m, valuation=0) + sage: s = L(m, valuation=0) # needs sage.symbolic sage: s[0] 1 - 1/(2^s) - 1/(3^s) - 1/(5^s) + 1/(6^s) - 1/(7^s) + O(1/(8^s)) sage: s[1] @@ -287,21 +287,22 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No Converting various series from a univariate power series:: - sage: L = LazyLaurentSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings - sage: R = LazyPowerSeriesRing(ZZ, 'z') # optional - sage.rings.finite_rings - sage: L.has_coerce_map_from(R) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(2), 'z') + sage: R = LazyPowerSeriesRing(ZZ, 'z') + sage: L.has_coerce_map_from(R) True - sage: L(R(lambda n: n)) # optional - sage.rings.finite_rings + sage: L(R(lambda n: n)) z + z^3 + z^5 + z^7 + O(z^8) - sage: L(R([2,4,6])) == L.zero() # optional - sage.rings.finite_rings + sage: L(R([2,4,6])) == L.zero() True - sage: L(R([2,4,6], valuation=2, constant=4)) == L.zero() # optional - sage.rings.finite_rings + sage: L(R([2,4,6], valuation=2, constant=4)) == L.zero() True - sage: L(R([2,4,6], valuation=2, constant=5)) # optional - sage.rings.finite_rings + sage: L(R([2,4,6], valuation=2, constant=5)) z^5 + z^6 + z^7 + O(z^8) - sage: L(R([2,3,4], valuation=2, constant=4)) # optional - sage.rings.finite_rings + sage: L(R([2,3,4], valuation=2, constant=4)) z^3 - sage: L(R([2,3,4], valuation=2, constant=5)) # optional - sage.rings.finite_rings + sage: L(R([2,3,4], valuation=2, constant=5)) z^3 + z^5 + z^6 + z^7 + O(z^8) Can only convert from known to be constant multivariate power series:: @@ -400,7 +401,7 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No sage: D = LazyDirichletSeriesRing(ZZ, "s") sage: E = LazyDirichletSeriesRing(QQ, "t") - sage: D(E([1,2,3])) + sage: D(E([1,2,3])) # needs sage.symbolic 1 + 2/2^s + 3/3^s This gives zero:: @@ -712,9 +713,9 @@ def one(self): sage: L.one() 1 - sage: m = SymmetricFunctions(ZZ).m() - sage: L = LazySymmetricFunctions(m) - sage: L.one() + sage: m = SymmetricFunctions(ZZ).m() # needs sage.modules + sage: L = LazySymmetricFunctions(m) # needs sage.modules + sage: L.one() # needs sage.modules m[] """ @@ -733,9 +734,9 @@ def zero(self): sage: L.zero() 0 - sage: s = SymmetricFunctions(ZZ).s() - sage: L = LazySymmetricFunctions(s) - sage: L.zero() + sage: s = SymmetricFunctions(ZZ).s() # needs sage.modules + sage: L = LazySymmetricFunctions(s) # needs sage.modules + sage: L.zero() # needs sage.modules 0 sage: L = LazyDirichletSeriesRing(ZZ, 'z') @@ -759,14 +760,14 @@ def characteristic(self): sage: L.characteristic() 0 - sage: R. = LazyLaurentSeriesRing(GF(11)); R # optional - sage.rings.finite_rings + sage: R. = LazyLaurentSeriesRing(GF(11)); R Lazy Laurent Series Ring in w over Finite Field of size 11 - sage: R.characteristic() # optional - sage.rings.finite_rings + sage: R.characteristic() 11 - sage: R. = LazyPowerSeriesRing(GF(7)); R # optional - sage.rings.finite_rings + sage: R. = LazyPowerSeriesRing(GF(7)); R Multivariate Lazy Taylor Series Ring in x, y over Finite Field of size 7 - sage: R.characteristic() # optional - sage.rings.finite_rings + sage: R.characteristic() 7 sage: L = LazyDirichletSeriesRing(ZZ, "s") @@ -781,13 +782,13 @@ def _coerce_map_from_(self, S): EXAMPLES:: - sage: L = LazyLaurentSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings - sage: L.has_coerce_map_from(ZZ) # optional - sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(2), 'z') + sage: L.has_coerce_map_from(ZZ) True - sage: L.has_coerce_map_from(GF(2)) # optional - sage.rings.finite_rings + sage: L.has_coerce_map_from(GF(2)) True sage: R = LazyPowerSeriesRing(ZZ, 'z') - sage: L.has_coerce_map_from(R) # optional - sage.rings.finite_rings + sage: L.has_coerce_map_from(R) True sage: L = LazyLaurentSeriesRing(QQ, 'z') @@ -801,17 +802,18 @@ def _coerce_map_from_(self, S): sage: L.has_coerce_map_from(R) False - sage: L = LazyPowerSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings - sage: L.has_coerce_map_from(ZZ) # optional - sage.rings.finite_rings + sage: L = LazyPowerSeriesRing(GF(2), 'z') + sage: L.has_coerce_map_from(ZZ) True - sage: L.has_coerce_map_from(GF(2)) # optional - sage.rings.finite_rings + sage: L.has_coerce_map_from(GF(2)) True - sage: s = SymmetricFunctions(GF(2)).s() # optional - sage.rings.finite_rings - sage: L = LazySymmetricFunctions(s) # optional - sage.rings.finite_rings - sage: L.has_coerce_map_from(ZZ) # optional - sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings + sage: s = SymmetricFunctions(GF(2)).s() + sage: L = LazySymmetricFunctions(s) + sage: L.has_coerce_map_from(ZZ) True - sage: L.has_coerce_map_from(GF(2)) # optional - sage.rings.finite_rings + sage: L.has_coerce_map_from(GF(2)) True """ if self.base_ring().has_coerce_map_from(S): @@ -845,13 +847,13 @@ def _coerce_map_from_base_ring(self): sage: L = LazyDirichletSeriesRing(QQ, 'z') sage: phi = L._coerce_map_from_base_ring() sage: m = phi(2) - sage: m # optional - sage.symbolic + sage: m # needs sage.symbolic 2 sage: m = phi(2, valuation=2) - sage: m # optional - sage.symbolic + sage: m # needs sage.symbolic 2/2^z sage: m = phi(2, valuation=2, constant=4) - sage: m # optional - sage.symbolic + sage: m # needs sage.symbolic 2/2^z + 4/3^z + 4/4^z + 4/5^z + O(1/(6^z)) """ # Return a DefaultConvertMap_unique; this can pass additional @@ -1019,7 +1021,7 @@ def _test_revert(self, **options): count += 1 e1 = y(x) e2 = x(y) - tester.assertEqual(e1, e2, "y(x) and x(y) differ for x = %s and y = %s" %(x, y)) + tester.assertEqual(e1, e2, "y(x) and x(y) differ for x = %s and y = %s" % (x, y)) # tester.assertEqual(e1, self.gen()) # we want to test at least 2 elements tester.assertGreater(count, 1, msg="only %s elements in %s.some_elements() have a compositional inverse" % (count, self)) @@ -1050,12 +1052,13 @@ class LazyLaurentSeriesRing(LazySeriesRing): Lazy Laurent series ring over a finite field:: - sage: L. = LazyLaurentSeriesRing(GF(3)); L # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: L. = LazyLaurentSeriesRing(GF(3)); L Lazy Laurent Series Ring in z over Finite Field of size 3 - sage: e = 1 / (1 + z) # optional - sage.rings.finite_rings - sage: e.coefficient(100) # optional - sage.rings.finite_rings + sage: e = 1 / (1 + z) + sage: e.coefficient(100) 1 - sage: e.coefficient(100).parent() # optional - sage.rings.finite_rings + sage: e.coefficient(100).parent() Finite Field of size 3 Series can be defined by specifying a coefficient function @@ -1197,21 +1200,21 @@ def __init__(self, base_ring, names, sparse=True, category=None): and Category of infinite sets sage: L = LazyLaurentSeriesRing(ZZ['x, y'], 't') - sage: TestSuite(L).run() + sage: TestSuite(L).run() # needs sage.libs.singular sage: L.category() Category of infinite commutative no zero divisors algebras over (unique factorization domains and commutative algebras over (euclidean domains and infinite enumerated sets and metric spaces) and infinite sets) - sage: L = LazyLaurentSeriesRing(GF(5), 't') # optional - sage.rings.finite_rings - sage: TestSuite(L).run() # optional - sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(5), 't') + sage: TestSuite(L).run() - sage: L = LazyLaurentSeriesRing(GF(5)['x'], 't') # optional - sage.rings.finite_rings - sage: TestSuite(L).run() # optional - sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(5)['x'], 't') + sage: TestSuite(L).run() - sage: L = LazyLaurentSeriesRing(GF(5)['x, y'], 't') # optional - sage.rings.finite_rings - sage: TestSuite(L).run() # optional - sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(5)['x, y'], 't') + sage: TestSuite(L).run() sage: L = LazyLaurentSeriesRing(Zmod(6), 't') sage: TestSuite(L).run(skip=['_test_revert']) @@ -1220,8 +1223,8 @@ def __init__(self, base_ring, names, sparse=True, category=None): (finite commutative rings and subquotients of monoids and quotients of semigroups and finite enumerated sets) - sage: E. = ExteriorAlgebra(QQ) - sage: L = LazyLaurentSeriesRing(E, 't') # not tested + sage: E. = ExteriorAlgebra(QQ) # needs sage.modules + sage: L = LazyLaurentSeriesRing(E, 't') # not tested # needs sage.modules sage: LazyLaurentSeriesRing.options._reset() # reset the options """ @@ -1254,7 +1257,7 @@ def _repr_(self): EXAMPLES:: - sage: LazyLaurentSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings + sage: LazyLaurentSeriesRing(GF(2), 'z') Lazy Laurent Series Ring in z over Finite Field of size 2 """ return "Lazy Laurent Series Ring in {} over {}".format(self.variable_name(), self.base_ring()) @@ -1265,8 +1268,8 @@ def _latex_(self): EXAMPLES:: - sage: L = LazyLaurentSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings - sage: latex(L) # optional - sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(2), 'z') + sage: latex(L) \Bold{F}_{2} (\!(z)\!) """ from sage.misc.latex import latex @@ -1351,16 +1354,16 @@ def some_elements(self): -2*z^-3 - 2*z^-2 + 4*z^-1 + 11 - z - 34*z^2 - 31*z^3 + O(z^4), 4*z^-2 + z^-1 + z + 4*z^2 + 9*z^3 + 16*z^4 + O(z^5)] - sage: L = LazyLaurentSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings - sage: L.some_elements()[:7] # optional - sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(2), 'z') + sage: L.some_elements()[:7] [0, 1, z, z^-4 + z^-3 + z^2 + z^3, z^-2, 1 + z + z^3 + z^4 + z^6 + O(z^7), z^-1 + z + z^3 + O(z^5)] - sage: L = LazyLaurentSeriesRing(GF(3), 'z') # optional - sage.rings.finite_rings - sage: L.some_elements()[:7] # optional - sage.rings.finite_rings + sage: L = LazyLaurentSeriesRing(GF(3), 'z') + sage: L.some_elements()[:7] [0, 1, z, z^-3 + z^-1 + 2 + z + z^2 + z^3, z^-2, @@ -1559,7 +1562,7 @@ def q_pochhammer(self, q=None): sage: R = ZZ['q'].fraction_field() sage: q = R.gen() sage: L. = LazyLaurentSeriesRing(LazyDirichletSeriesRing(R, "s")) - sage: z.q_pochhammer(q) + sage: z.q_pochhammer(q) # needs sage.symbolic 1 + ((1/(q-1)))*z + ((q/(q^3-q^2-q+1)))*z^2 + ... + O(z^7) REFERENCES: @@ -1603,13 +1606,13 @@ def euler(self): sage: P = 1 / phi; P 1 + q + 2*q^2 + 3*q^3 + 5*q^4 + 7*q^5 + 11*q^6 + O(q^7) - sage: P[:20] == [Partitions(n).cardinality() for n in range(20)] + sage: P[:20] == [Partitions(n).cardinality() for n in range(20)] # needs sage.libs.flint True TESTS:: sage: L. = LazyLaurentSeriesRing(LazyDirichletSeriesRing(QQ, "s")) - sage: q.euler() + sage: q.euler() # needs sage.symbolic 1 - q - q^2 + q^5 + O(q^7) REFERENCES: @@ -1668,11 +1671,11 @@ def __init__(self, base_ring, names, sparse=True, category=None): sage: L = LazyPowerSeriesRing(QQ, 's, t') sage: TestSuite(L).run(skip="_test_fraction_field") - sage: L = LazyPowerSeriesRing(GF(5), 't') # optional - sage.rings.finite_rings - sage: TestSuite(L).run() # optional - sage.rings.finite_rings + sage: L = LazyPowerSeriesRing(GF(5), 't') + sage: TestSuite(L).run() - sage: L = LazyPowerSeriesRing(GF(5), 's, t') # optional - sage.rings.finite_rings - sage: TestSuite(L).run(skip=['_test_fraction_field']) # optional - sage.rings.finite_rings + sage: L = LazyPowerSeriesRing(GF(5), 's, t') + sage: TestSuite(L).run(skip=['_test_fraction_field']) sage: L = LazyPowerSeriesRing(Zmod(6), 't') sage: TestSuite(L).run(skip=['_test_revert']) @@ -1754,7 +1757,7 @@ def _repr_(self): EXAMPLES:: - sage: LazyPowerSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings + sage: LazyPowerSeriesRing(GF(2), 'z') Lazy Taylor Series Ring in z over Finite Field of size 2 """ BR = self.base_ring() @@ -1769,8 +1772,8 @@ def _latex_(self): EXAMPLES:: - sage: L = LazyPowerSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings - sage: latex(L) # optional - sage.rings.finite_rings + sage: L = LazyPowerSeriesRing(GF(2), 'z') + sage: latex(L) \Bold{F}_{2} [\![z]\!] """ from sage.misc.latex import latex @@ -1868,10 +1871,10 @@ def _element_constructor_(self, x=None, valuation=None, constant=None, degree=No EXAMPLES:: - sage: L = LazyPowerSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings - sage: L(2) # optional - sage.rings.finite_rings + sage: L = LazyPowerSeriesRing(GF(2), 'z') + sage: L(2) 0 - sage: L(3) # optional - sage.rings.finite_rings + sage: L(3) 1 sage: L = LazyPowerSeriesRing(ZZ, 'z') @@ -1937,11 +1940,11 @@ def _element_constructor_(self, x=None, valuation=None, constant=None, degree=No (a + b + 1)/(c^3 + a*b + 1) sage: f.parent() Fraction Field of Multivariate Polynomial Ring in a, b, c over Integer Ring - sage: L(f) + sage: L(f) # needs sage.libs.singular 1 + (a+b) + (-a*b) + (-a^2*b-a*b^2-c^3) + (a^2*b^2-a*c^3-b*c^3) + (a^3*b^2+a^2*b^3+2*a*b*c^3) + (-a^3*b^3+2*a^2*b*c^3+2*a*b^2*c^3+c^6) + O(a,b,c)^7 - sage: L(f) == (1 + aa + bb) / (1 + aa*bb + cc^3) + sage: L(f) == (1 + aa + bb) / (1 + aa*bb + cc^3) # needs sage.libs.singular True TESTS:: @@ -2190,15 +2193,15 @@ def some_elements(self): 1 + z - 2*z^2 - 7*z^3 - z^4 + 20*z^5 + 23*z^6 + O(z^7), z + 4*z^2 + 9*z^3 + 16*z^4 + 25*z^5 + 36*z^6 + O(z^7)] - sage: L = LazyPowerSeriesRing(GF(3)["q"], 'z') # optional - sage.rings.finite_rings - sage: L.some_elements()[:6] # optional - sage.rings.finite_rings + sage: L = LazyPowerSeriesRing(GF(3)["q"], 'z') + sage: L.some_elements()[:6] [0, 1, z + q*z^2 + q*z^3 + q*z^4 + O(z^5), z + z^2 + z^3, 1 + z + z^2 + 2*z^3 + 2*z^4 + 2*z^5 + O(z^6), z + z^2 + z^4 + z^5 + O(z^7)] - sage: L = LazyPowerSeriesRing(GF(3), 'q, t') # optional - sage.rings.finite_rings - sage: L.some_elements()[:6] # optional - sage.rings.finite_rings + sage: L = LazyPowerSeriesRing(GF(3), 'q, t') + sage: L.some_elements()[:6] [0, 1, q, q + q^2 + q^3, 1 + q + q^2 + (-q^3) + (-q^4) + (-q^5) + (-q^6) + O(q,t)^7, @@ -2237,17 +2240,16 @@ class LazyCompletionGradedAlgebra(LazySeriesRing): EXAMPLES:: + sage: # needs sage.modules sage: NCSF = NonCommutativeSymmetricFunctions(QQ) sage: S = NCSF.Complete() - sage: L = S.formal_series_ring() - sage: L - Lazy completion of Non-Commutative Symmetric Functions over the Rational Field in the Complete basis - - sage: f = 1 / (1 - L(S[1])) - sage: f - S[] + S[1] + (S[1,1]) + (S[1,1,1]) + (S[1,1,1,1]) + (S[1,1,1,1,1]) + (S[1,1,1,1,1,1]) + O^7 - sage: g = 1 / (1 - L(S[2])) - sage: g + sage: L = S.formal_series_ring(); L + Lazy completion of Non-Commutative Symmetric Functions + over the Rational Field in the Complete basis + sage: f = 1 / (1 - L(S[1])); f + S[] + S[1] + (S[1,1]) + (S[1,1,1]) + (S[1,1,1,1]) + (S[1,1,1,1,1]) + + (S[1,1,1,1,1,1]) + O^7 + sage: g = 1 / (1 - L(S[2])); g S[] + S[2] + (S[2,2]) + (S[2,2,2]) + O^7 sage: f * g S[] + S[1] + (S[1,1]+S[2]) + (S[1,1,1]+S[1,2]) @@ -2272,23 +2274,23 @@ def __init__(self, basis, sparse=True, category=None): sage: LazySymmetricFunctions.options.halting_precision(6) + sage: # needs sage.modules sage: s = SymmetricFunctions(QQ).s() sage: L = LazySymmetricFunctions(s) + sage: TestSuite(L).run() # needs lrcalc_python + sage: p = SymmetricFunctions(GF(5)).p() + sage: L = LazySymmetricFunctions(p) sage: TestSuite(L).run() - sage: p = SymmetricFunctions(GF(5)).p() # optional - sage.rings.finite_rings - sage: L = LazySymmetricFunctions(p) # optional - sage.rings.finite_rings - sage: TestSuite(L).run() # optional - sage.rings.finite_rings - Reversion will only work when the base ring is a field:: + sage: # needs sage.modules sage: s = SymmetricFunctions(ZZ).s() sage: L = LazySymmetricFunctions(s) - sage: TestSuite(L).run(skip=['_test_revert']) - + sage: TestSuite(L).run(skip=['_test_revert']) # needs lrcalc_python sage: s = SymmetricFunctions(QQ["q"]).s() sage: L = LazySymmetricFunctions(s) - sage: TestSuite(L).run(skip=['_test_revert']) + sage: TestSuite(L).run(skip=['_test_revert']) # needs lrcalc_python Options are remembered across doctests:: @@ -2297,15 +2299,15 @@ def __init__(self, basis, sparse=True, category=None): Check that :trac:`34470` is fixed. The ideal generated by `p[1]` and `p[2]` is not principal:: - sage: p = SymmetricFunctions(QQ).p() - sage: L = LazySymmetricFunctions(s) - sage: L in PrincipalIdealDomains + sage: p = SymmetricFunctions(QQ).p() # needs sage.modules + sage: L = LazySymmetricFunctions(s) # needs sage.modules + sage: L in PrincipalIdealDomains # needs sage.modules False Check that a basis which is not graded is not enough:: - sage: ht = SymmetricFunctions(ZZ).ht() - sage: L = LazySymmetricFunctions(ht) + sage: ht = SymmetricFunctions(ZZ).ht() # needs sage.modules + sage: L = LazySymmetricFunctions(ht) # needs sage.modules Traceback (most recent call last): ... ValueError: basis should be in GradedAlgebrasWithBasis @@ -2344,8 +2346,8 @@ def _repr_(self): EXAMPLES:: - sage: s = SymmetricFunctions(GF(2)).s() # optional - sage.rings.finite_rings - sage: LazySymmetricFunctions(s) # optional - sage.rings.finite_rings + sage: s = SymmetricFunctions(GF(2)).s() # needs sage.modules + sage: LazySymmetricFunctions(s) # needs sage.modules Lazy completion of Symmetric Functions over Finite Field of size 2 in the Schur basis """ return "Lazy completion of {}".format(self._laurent_poly_ring) @@ -2356,9 +2358,9 @@ def _latex_(self): EXAMPLES:: - sage: s = SymmetricFunctions(GF(2)).s() # optional - sage.rings.finite_rings - sage: L = LazySymmetricFunctions(s) # optional - sage.rings.finite_rings - sage: latex(L) # optional - sage.rings.finite_rings + sage: s = SymmetricFunctions(GF(2)).s() # needs sage.modules + sage: L = LazySymmetricFunctions(s) # needs sage.modules + sage: latex(L) # needs sage.modules \text{\texttt{Symmetric{ }Functions{ }over{ }Finite{ }Field{ }of{ }size{ }2{ }in{ }the{ }Schur{ }basis}} """ from sage.misc.latex import latex @@ -2370,6 +2372,7 @@ def _monomial(self, c, n): EXAMPLES:: + sage: # needs sage.modules sage: m = SymmetricFunctions(ZZ).m() sage: s = SymmetricFunctions(ZZ).s() sage: L = LazySymmetricFunctions(m) @@ -2395,18 +2398,19 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No EXAMPLES:: - sage: m = SymmetricFunctions(GF(2)).m() # optional - sage.rings.finite_rings - sage: L = LazySymmetricFunctions(m) # optional - sage.rings.finite_rings - sage: L(2) # optional - sage.rings.finite_rings + sage: # needs sage.modules + sage: m = SymmetricFunctions(GF(2)).m() + sage: L = LazySymmetricFunctions(m) + sage: L(2) 0 - sage: L(3) # optional - sage.rings.finite_rings + sage: L(3) m[] + sage: # needs sage.modules sage: m = SymmetricFunctions(ZZ).m() sage: L = LazySymmetricFunctions(m) sage: f = L(lambda i: m([i]), valuation=5, degree=10); f m[5] + m[6] + m[7] + m[8] + m[9] - sage: f.coefficient(6) m[6] sage: f[20] @@ -2416,11 +2420,12 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No Then these elements are read as coefficients of the terms of degrees starting from the ``valuation``:: - sage: f = L([m[1],m[2],m[3]], valuation=1); f + sage: f = L([m[1],m[2],m[3]], valuation=1); f # needs sage.modules m[1] + m[2] + m[3] Finally, ``x`` can be a symmetric function:: + sage: # needs sage.modules sage: m = SymmetricFunctions(ZZ).m() sage: s = SymmetricFunctions(ZZ).s() sage: L = LazySymmetricFunctions(m) @@ -2429,29 +2434,31 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No TESTS:: + sage: # needs sage.modules sage: e = SymmetricFunctions(ZZ).e() sage: h = SymmetricFunctions(ZZ).h() sage: L = LazySymmetricFunctions(tensor([h, e])) sage: L(lambda n: 0) O^7 + sage: # needs sage.modules sage: L(lambda n: tensor([h[n], e([])]) + tensor([h([]), e[n]]), degree=3) (2*h[]#e[]) + (h[]#e[1]+h[1]#e[]) + (h[]#e[2]+h[2]#e[]) - sage: L(lambda n: n)[3]; Traceback (most recent call last): ... - ValueError: coefficient 3*h[] # e[] should be an element of homogeneous degree 3 but has degree 0 - + ValueError: coefficient 3*h[] # e[] should be an element + of homogeneous degree 3 but has degree 0 sage: L([1, 2, 3]); Traceback (most recent call last): ... - ValueError: coefficient 2*h[] # e[] should be an element of homogeneous degree 1 but has degree 0 - + ValueError: coefficient 2*h[] # e[] should be an element + of homogeneous degree 1 but has degree 0 sage: L(lambda n: n, degree=3); Traceback (most recent call last): ... - ValueError: coefficient h[] # e[] should be an element of homogeneous degree 1 but has degree 0 + ValueError: coefficient h[] # e[] should be an element + of homogeneous degree 1 but has degree 0 """ if valuation is None: valuation = 0 @@ -2566,9 +2573,9 @@ def _an_element_(self): EXAMPLES:: - sage: m = SymmetricFunctions(ZZ).m() - sage: L = LazySymmetricFunctions(m) - sage: L.an_element() + sage: m = SymmetricFunctions(ZZ).m() # needs sage.modules + sage: L = LazySymmetricFunctions(m) # needs sage.modules + sage: L.an_element() # needs sage.modules 2*m[] + 2*m[1] + 3*m[2] """ return self(self._laurent_poly_ring.an_element()) @@ -2579,9 +2586,9 @@ def some_elements(self): EXAMPLES:: - sage: m = SymmetricFunctions(GF(5)).m() # optional - sage.rings.finite_rings - sage: L = LazySymmetricFunctions(m) # optional - sage.rings.finite_rings - sage: L.some_elements()[:5] # optional - sage.rings.finite_rings + sage: m = SymmetricFunctions(GF(5)).m() # needs sage.modules + sage: L = LazySymmetricFunctions(m) # needs sage.modules + sage: L.some_elements()[:5] # needs sage.modules [0, m[], 2*m[] + 2*m[1] + 3*m[2], 2*m[1] + 3*m[2], 3*m[] + 2*m[1] + (m[1,1]+m[2]) + (2*m[1,1,1]+m[3]) @@ -2590,6 +2597,7 @@ def some_elements(self): + (2*m[2,2,1,1]+m[2,2,2]+2*m[3,2,1]+2*m[3,3]+m[4,1,1]+3*m[4,2]+4*m[5,1]+4*m[6]) + O^7] + sage: # needs sage.modules sage: NCSF = NonCommutativeSymmetricFunctions(QQ) sage: S = NCSF.Complete() sage: L = S.formal_series_ring() @@ -2632,13 +2640,15 @@ class LazySymmetricFunctions(LazyCompletionGradedAlgebra): EXAMPLES:: - sage: s = SymmetricFunctions(ZZ).s() - sage: LazySymmetricFunctions(s) + sage: s = SymmetricFunctions(ZZ).s() # needs sage.modules + sage: LazySymmetricFunctions(s) # needs sage.modules Lazy completion of Symmetric Functions over Integer Ring in the Schur basis - sage: m = SymmetricFunctions(ZZ).m() - sage: LazySymmetricFunctions(tensor([s, m])) - Lazy completion of Symmetric Functions over Integer Ring in the Schur basis # Symmetric Functions over Integer Ring in the monomial basis + sage: m = SymmetricFunctions(ZZ).m() # needs sage.modules + sage: LazySymmetricFunctions(tensor([s, m])) # needs sage.modules + Lazy completion of + Symmetric Functions over Integer Ring in the Schur basis + # Symmetric Functions over Integer Ring in the monomial basis """ Element = LazySymmetricFunction @@ -2724,7 +2734,7 @@ def _laurent_poly_ring(self): TESTS:: sage: L = LazyDirichletSeriesRing(ZZ, 't') - sage: L._laurent_poly_ring is SR # optional - sage.symbolic + sage: L._laurent_poly_ring is SR # needs sage.symbolic True """ from sage.symbolic.ring import SR @@ -2739,10 +2749,10 @@ def __init__(self, base_ring, names, sparse=True, category=None): sage: LazyDirichletSeriesRing.options.halting_precision(12) sage: L = LazyDirichletSeriesRing(ZZ, 't') - sage: TestSuite(L).run() + sage: TestSuite(L).run() # needs sage.symbolic sage: L = LazyDirichletSeriesRing(QQ, 't') - sage: TestSuite(L).run() + sage: TestSuite(L).run() # needs sage.symbolic sage: LazyDirichletSeriesRing.options._reset() # reset the options @@ -2770,7 +2780,7 @@ def _repr_(self): EXAMPLES:: - sage: LazyDirichletSeriesRing(QQbar, 'z') # optional - sage.rings.number_field + sage: LazyDirichletSeriesRing(QQbar, 'z') # needs sage.rings.number_field Lazy Dirichlet Series Ring in z over Algebraic Field """ return "Lazy Dirichlet Series Ring in {} over {}".format(self.variable_name(), self.base_ring()) @@ -2783,9 +2793,9 @@ def one(self): EXAMPLES:: sage: L = LazyDirichletSeriesRing(ZZ, 'z') - sage: L.one() # optional - sage.symbolic + sage: L.one() # needs sage.symbolic 1 - sage: ~L.one() # optional - sage.symbolic + sage: ~L.one() # needs sage.symbolic 1 + O(1/(8^z)) """ R = self.base_ring() @@ -2824,31 +2834,31 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No sage: L = LazyDirichletSeriesRing(ZZ, 'z') sage: R = L(3) - sage: R # optional - sage.symbolic + sage: R # needs sage.symbolic 3 sage: S = L(lambda i: i, constant=1, degree=6) - sage: S # optional - sage.symbolic + sage: S # needs sage.symbolic 1 + 2/2^z + 3/3^z + 4/4^z + 5/5^z + 1/(6^z) + 1/(7^z) + 1/(8^z) + O(1/(9^z)) sage: X = L(constant=5, degree=3) - sage: X # optional - sage.symbolic + sage: X # needs sage.symbolic 5/3^z + 5/4^z + 5/5^z + O(1/(6^z)) - sage: X.valuation() + sage: X.valuation() # needs sage.symbolic log(3) sage: e = L(moebius) - sage: e # optional - sage.symbolic + sage: e # needs sage.symbolic 1 - 1/(2^z) - 1/(3^z) - 1/(5^z) + 1/(6^z) - 1/(7^z) + O(1/(8^z)) sage: T = L([0], constant=1) - sage: T # optional - sage.symbolic + sage: T # needs sage.symbolic 1/(2^z) + 1/(3^z) + 1/(4^z) + O(1/(5^z)) sage: U = L(constant=1) - sage: U # optional - sage.symbolic + sage: U # needs sage.symbolic 1 + 1/(2^z) + 1/(3^z) + O(1/(4^z)) sage: V = L(lambda i: i, valuation=3) - sage: V # optional - sage.symbolic + sage: V # needs sage.symbolic 3/3^z + 4/4^z + 5/5^z + 6/6^z + 7/7^z + 8/8^z + 9/9^z + O(1/(10^z)) Alternatively, ``x`` can be a list of elements of the base ring. @@ -2858,44 +2868,44 @@ def _element_constructor_(self, x=None, valuation=None, degree=None, constant=No simply omitted if it is zero:: sage: f = L([1,2,3,4], 4) - sage: f # optional - sage.symbolic + sage: f # needs sage.symbolic 1/(4^z) + 2/5^z + 3/6^z + 4/7^z sage: g = L([1,3,5,7,9], 6, constant=-1) - sage: g # optional - sage.symbolic + sage: g # needs sage.symbolic 1/(6^z) + 3/7^z + 5/8^z + 7/9^z + 9/10^z - 1/(11^z) - 1/(12^z) - 1/(13^z) + O(1/(14^z)) TESTS:: - sage: L = LazyDirichletSeriesRing(GF(2), 'z') # optional - sage.rings.finite_rings + sage: L = LazyDirichletSeriesRing(GF(2), 'z') Traceback (most recent call last): ... ValueError: positive characteristic not allowed for Dirichlet series sage: L. = LazyLaurentSeriesRing(QQ) sage: D = LazyDirichletSeriesRing(QQ, 't') - sage: d = D(L.one()) - sage: d # optional - sage.symbolic + sage: d = D(L.one()) # needs sage.symbolic + sage: d # needs sage.symbolic 1 + 1/(2^t) + 1/(3^t) + 1/(4^t) + 1/(5^t) + 1/(6^t) + 1/(7^t) + O(1/(8^t)) sage: R. = LaurentPolynomialRing(QQ) sage: D = LazyDirichletSeriesRing(QQ, 't') sage: dd = D(coefficients=z + z^2) - sage: dd # optional - sage.symbolic + sage: dd # needs sage.symbolic 2 + 6/2^t + 12/3^t + 20/4^t + 30/5^t + 42/6^t + 56/7^t + O(1/(8^t)) sage: s = D(lambda n: n) - sage: d2 = D(s, valuation=2) - sage: d2 # optional - sage.symbolic + sage: d2 = D(s, valuation=2) # needs sage.symbolic + sage: d2 # needs sage.symbolic 1/(2^t) + 2/3^t + 3/4^t + 4/5^t + 5/6^t + 6/7^t + 7/8^t + O(1/(9^t)) sage: Ds = LazyDirichletSeriesRing(ZZ, 's') sage: m = Ds(moebius, valuation=2) - sage: m # optional - sage.symbolic + sage: m # needs sage.symbolic -1/(2^s) - 1/(3^s) - 1/(5^s) + 1/(6^s) - 1/(7^s) + O(1/(9^s)) sage: D = LazyDirichletSeriesRing(QQ, 't') - sage: dm = D(m) - sage: dm # optional - sage.symbolic + sage: dm = D(m) # needs sage.libs.pari + sage: dm # needs sage.libs.pari sage.symbolic -1/(2^t) - 1/(3^t) - 1/(5^t) + 1/(6^t) - 1/(7^t) + O(1/(9^t)) """ if isinstance(x, (list, tuple)): @@ -2941,7 +2951,7 @@ def _an_element_(self): sage: L = LazyDirichletSeriesRing(ZZ, 'z') sage: m = L.an_element() - sage: m # optional - sage.symbolic + sage: m # needs sage.symbolic 1/(4^z) + 1/(5^z) + 1/(6^z) + O(1/(7^z)) """ c = self.base_ring().an_element() @@ -2955,7 +2965,7 @@ def some_elements(self): sage: L = LazyDirichletSeriesRing(ZZ, 'z') sage: l = L.some_elements() - sage: l # optional - sage.symbolic + sage: l # needs sage.symbolic [0, 1, 1/(4^z) + 1/(5^z) + 1/(6^z) + O(1/(7^z)), 1/(2^z) - 1/(3^z) + 2/4^z - 2/5^z + 3/6^z - 3/7^z + 4/8^z - 4/9^z, @@ -2964,7 +2974,7 @@ def some_elements(self): sage: L = LazyDirichletSeriesRing(QQ, 'z') sage: l = L.some_elements() - sage: l # optional - sage.symbolic + sage: l # needs sage.symbolic [0, 1, 1/2/4^z + 1/2/5^z + 1/2/6^z + O(1/(7^z)), 1/2 - 1/2/2^z + 2/3^z - 2/4^z + 1/(6^z) - 1/(7^z) + 42/8^z + 2/3/9^z, @@ -2986,8 +2996,7 @@ def _monomial(self, c, n): EXAMPLES:: sage: L = LazyDirichletSeriesRing(ZZ, 'z') - sage: m = L._monomial(5, 3) - sage: m # optional - sage.symbolic + sage: m = L._monomial(5, 3); m # needs sage.symbolic 5/3^z """ try: @@ -3007,11 +3016,12 @@ def _skip_leading_zeros(iterator): sage: [x for x, _ in zip(_skip_leading_zeros(it), range(10))] [10, 11, 12, 13, 14, 15, 16, 17, 18, 19] - sage: it = map(GF(3), NN) # optional - sage.rings.finite_rings - sage: [x for x, _ in zip(it, range(10))] # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: it = map(GF(3), NN) + sage: [x for x, _ in zip(it, range(10))] [0, 1, 2, 0, 1, 2, 0, 1, 2, 0] - sage: it = map(GF(3), NN) # optional - sage.rings.finite_rings - sage: [x for x, _ in zip(_skip_leading_zeros(it), range(10))] # optional - sage.rings.finite_rings + sage: it = map(GF(3), NN) + sage: [x for x, _ in zip(_skip_leading_zeros(it), range(10))] [1, 2, 0, 1, 2, 0, 1, 2, 0, 1] """ while True: diff --git a/src/sage/rings/localization.py b/src/sage/rings/localization.py index 3062c9439d8..20c090da681 100644 --- a/src/sage/rings/localization.py +++ b/src/sage/rings/localization.py @@ -9,19 +9,20 @@ EXAMPLES:: + sage: # needs sage.modules sage: LZ = Localization(ZZ, (5,11)) - sage: m = matrix(LZ, [[5, 7], [0,11]]) # optional - sage.modules - sage: m.parent() # optional - sage.modules + sage: m = matrix(LZ, [[5, 7], [0,11]]) + sage: m.parent() Full MatrixSpace of 2 by 2 dense matrices over Integer Ring localized at (5, 11) - sage: ~m # parent of inverse is different: see documentation of m.__invert__ # optional - sage.modules + sage: ~m # parent of inverse is different: see documentation of m.__invert__ [ 1/5 -7/55] [ 0 1/11] - sage: _.parent() # optional - sage.modules + sage: _.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field - sage: mi = matrix(LZ, ~m) # optional - sage.modules - sage: mi.parent() # optional - sage.modules + sage: mi = matrix(LZ, ~m) + sage: mi.parent() Full MatrixSpace of 2 by 2 dense matrices over Integer Ring localized at (5, 11) - sage: mi == ~m # optional - sage.modules + sage: mi == ~m True The next example defines the most general ring containing the coefficients of the irreducible @@ -34,48 +35,51 @@ sage: I = S.cartesian_product(S) sage: add_units = u + [q, q + 1] + [ui - uj for ui, uj in I if ui != uj] sage: add_units += [q*ui - uj for ui, uj in I if ui != uj] - sage: L = R.localization(tuple(add_units)); L # optional - sage.libs.pari + sage: L = R.localization(tuple(add_units)); L # needs sage.libs.pari Multivariate Polynomial Ring in u0, u1, u2, q over Integer Ring localized at (q, q + 1, u2, u1, u1 - u2, u0, u0 - u2, u0 - u1, u2*q - u1, u2*q - u0, u1*q - u2, u1*q - u0, u0*q - u2, u0*q - u1) Define the representation matrices (of one of the three dimensional irreducible representations):: - sage: m1 = matrix(L, [[u1, 0, 0], [0, u0, 0], [0, 0, u0]]) # optional - sage.modules - sage: m2 = matrix(L, [[(u0*q - u0)/(u0 - u1), (u0*q - u1)/(u0 - u1), 0], # optional - sage.modules + sage: # needs sage.libs.pari sage.modules + sage: m1 = matrix(L, [[u1, 0, 0], [0, u0, 0], [0, 0, u0]]) + sage: m2 = matrix(L, [[(u0*q - u0)/(u0 - u1), (u0*q - u1)/(u0 - u1), 0], ....: [(-u1*q + u0)/(u0 - u1), (-u1*q + u1)/(u0 - u1), 0], ....: [0, 0, -1]]) - sage: m3 = matrix(L, [[-1, 0, 0], # optional - sage.modules + sage: m3 = matrix(L, [[-1, 0, 0], ....: [0, u0*(1 - q)/(u1*q - u0), q*(u1 - u0)/(u1*q - u0)], ....: [0, (u1*q^2 - u0)/(u1*q - u0), (u1*q^ 2 - u1*q)/(u1*q - u0)]]) - sage: m1.base_ring() == L # optional - sage.modules + sage: m1.base_ring() == L True Check relations of the Ariki-Koike algebra:: - sage: m1*m2*m1*m2 == m2*m1*m2*m1 # optional - sage.modules + sage: # needs sage.libs.pari sage.modules + sage: m1*m2*m1*m2 == m2*m1*m2*m1 True - sage: m2*m3*m2 == m3*m2*m3 # optional - sage.modules + sage: m2*m3*m2 == m3*m2*m3 True - sage: m1*m3 == m3*m1 # optional - sage.modules + sage: m1*m3 == m3*m1 True - sage: m1**3 - (u0+u1+u2)*m1**2 + (u0*u1+u0*u2+u1*u2)*m1 - u0*u1*u2 == 0 # optional - sage.modules + sage: m1**3 - (u0+u1+u2)*m1**2 + (u0*u1+u0*u2+u1*u2)*m1 - u0*u1*u2 == 0 True - sage: m2**2 - (q-1)*m2 - q == 0 # optional - sage.modules + sage: m2**2 - (q-1)*m2 - q == 0 True - sage: m3**2 - (q-1)*m3 - q == 0 # optional - sage.modules + sage: m3**2 - (q-1)*m3 - q == 0 True - sage: ~m1 in m1.parent() # optional - sage.modules + sage: ~m1 in m1.parent() True - sage: ~m2 in m2.parent() # optional - sage.modules + sage: ~m2 in m2.parent() True - sage: ~m3 in m3.parent() # optional - sage.modules + sage: ~m3 in m3.parent() True Obtain specializations in positive characteristic:: - sage: Fp = GF(17) # optional - sage.rings.finite_rings - sage: f = L.hom((3,5,7,11), codomain=Fp); f # optional - sage.rings.finite_rings + sage: # needs sage.libs.pari sage.modules + sage: Fp = GF(17) + sage: f = L.hom((3,5,7,11), codomain=Fp); f Ring morphism: From: Multivariate Polynomial Ring in u0, u1, u2, q over Integer Ring localized at (q, q + 1, u2, u1, u1 - u2, u0, u0 - u2, u0 - u1, u2*q - u1, u2*q - u0, @@ -85,24 +89,25 @@ u1 |--> 5 u2 |--> 7 q |--> 11 - sage: mFp1 = matrix({k: f(v) for k, v in m1.dict().items()}); mFp1 # optional - sage.modules sage.rings.finite_rings + sage: mFp1 = matrix({k: f(v) for k, v in m1.dict().items()}); mFp1 [5 0 0] [0 3 0] [0 0 3] - sage: mFp1.base_ring() # optional - sage.modules sage.rings.finite_rings + sage: mFp1.base_ring() Finite Field of size 17 - sage: mFp2 = matrix({k: f(v) for k, v in m2.dict().items()}); mFp2 # optional - sage.modules sage.rings.finite_rings + sage: mFp2 = matrix({k: f(v) for k, v in m2.dict().items()}); mFp2 [ 2 3 0] [ 9 8 0] [ 0 0 16] - sage: mFp3 = matrix({k: f(v) for k, v in m3.dict().items()}); mFp3 # optional - sage.modules sage.rings.finite_rings + sage: mFp3 = matrix({k: f(v) for k, v in m3.dict().items()}); mFp3 [16 0 0] [ 0 4 5] [ 0 7 6] Obtain specializations in characteristic 0:: - sage: fQ = L.hom((3,5,7,11), codomain=QQ); fQ # optional - sage.rings.finite_rings + sage: # needs sage.libs.pari + sage: fQ = L.hom((3,5,7,11), codomain=QQ); fQ Ring morphism: From: Multivariate Polynomial Ring in u0, u1, u2, q over Integer Ring localized at (q, q + 1, u2, u1, u1 - u2, u0, u0 - u2, u0 - u1, @@ -112,25 +117,28 @@ u1 |--> 5 u2 |--> 7 q |--> 11 - sage: mQ1 = matrix({k: fQ(v) for k, v in m1.dict().items()}); mQ1 # optional - sage.modules sage.rings.finite_rings + + sage: # needs sage.libs.pari sage.modules sage.rings.finite_rings + sage: mQ1 = matrix({k: fQ(v) for k, v in m1.dict().items()}); mQ1 [5 0 0] [0 3 0] [0 0 3] - sage: mQ1.base_ring() # optional - sage.modules sage.rings.finite_rings + sage: mQ1.base_ring() Rational Field - sage: mQ2 = matrix({k: fQ(v) for k, v in m2.dict().items()}); mQ2 # optional - sage.modules sage.rings.finite_rings + sage: mQ2 = matrix({k: fQ(v) for k, v in m2.dict().items()}); mQ2 [-15 -14 0] [ 26 25 0] [ 0 0 -1] - sage: mQ3 = matrix({k: fQ(v) for k, v in m3.dict().items()}); mQ3 # optional - sage.modules sage.rings.finite_rings + sage: mQ3 = matrix({k: fQ(v) for k, v in m3.dict().items()}); mQ3 [ -1 0 0] [ 0 -15/26 11/26] [ 0 301/26 275/26] + sage: # needs sage.libs.pari sage.libs.singular sage: S. = QQ[] sage: T = S.quo(x + y + z) - sage: F = T.fraction_field() # optional - sage.libs.singular - sage: fF = L.hom((x, y, z, t), codomain=F); fF # optional - sage.libs.singular + sage: F = T.fraction_field() + sage: fF = L.hom((x, y, z, t), codomain=F); fF Ring morphism: From: Multivariate Polynomial Ring in u0, u1, u2, q over Integer Ring localized at (q, q + 1, u2, u1, u1 - u2, u0, u0 - u2, u0 - u1, @@ -141,16 +149,16 @@ u1 |--> ybar u2 |--> zbar q |--> tbar - sage: mF1 = matrix({k: fF(v) for k, v in m1.dict().items()}); mF1 # optional - sage.libs.singular sage.modules + sage: mF1 = matrix({k: fF(v) for k, v in m1.dict().items()}); mF1 # needs sage.modules [ ybar 0 0] [ 0 -ybar - zbar 0] [ 0 0 -ybar - zbar] - sage: mF1.base_ring() == F # optional - sage.libs.singular sage.modules + sage: mF1.base_ring() == F # needs sage.modules True TESTS:: - sage: TestSuite(L).run() # optional - sage.libs.singular sage.modules + sage: TestSuite(L).run() # needs sage.libs.pari sage.libs.singular sage.modules AUTHORS: @@ -199,21 +207,24 @@ def normalize_extra_units(base_ring, add_units, warning=True): sage: normalize_extra_units(ZZ, [3, -15, 45, 9, 2, 50]) [2, 3, 5] sage: P. = ZZ[] - sage: normalize_extra_units(P, [3*x, z*y**2, 2*z, 18*(x*y*z)**2, x*z, 6*x*z, 5]) # optional - sage.libs.pari + sage: normalize_extra_units(P, # needs sage.libs.pari + ....: [3*x, z*y**2, 2*z, 18*(x*y*z)**2, x*z, 6*x*z, 5]) [2, 3, 5, z, y, x] sage: P. = QQ[] - sage: normalize_extra_units(P, [3*x, z*y**2, 2*z, 18*(x*y*z)**2, x*z, 6*x*z, 5]) # optional - sage.libs.pari + sage: normalize_extra_units(P, # needs sage.libs.pari + ....: [3*x, z*y**2, 2*z, 18*(x*y*z)**2, x*z, 6*x*z, 5]) [z, y, x] + sage: # needs sage.libs.singular sage: R. = ZZ[] - sage: Q. = R.quo(x**2 - 5) # optional - sage.libs.singular - sage: p = b**2 - 5 # optional - sage.libs.singular - sage: p == (b-a)*(b+a) # optional - sage.libs.singular + sage: Q. = R.quo(x**2 - 5) + sage: p = b**2 - 5 + sage: p == (b-a)*(b+a) True - sage: normalize_extra_units(Q, [p]) # optional - sage.libs.pari + sage: normalize_extra_units(Q, [p]) # needs sage.libs.pari doctest:...: UserWarning: Localization may not be represented uniquely [b^2 - 5] - sage: normalize_extra_units(Q, [p], warning=False) # optional - sage.libs.pari + sage: normalize_extra_units(Q, [p], warning=False) # needs sage.libs.pari [b^2 - 5] """ # convert to base ring @@ -250,13 +261,15 @@ class LocalizationElement(IntegralDomainElement): EXAMPLES:: + sage: # needs sage.libs.pari sage: from sage.rings.localization import LocalizationElement - sage: P. = GF(5)[] # optional - sage.rings.finite_rings - sage: L = P.localization((x, y*z-x)) # optional - sage.rings.finite_rings - sage: LocalizationElement(L, 4/(y*z-x)**2) # optional - sage.rings.finite_rings + sage: P. = GF(5)[] + sage: L = P.localization((x, y*z - x)) + sage: LocalizationElement(L, 4/(y*z-x)**2) (-1)/(y^2*z^2 - 2*x*y*z + x^2) - sage: _.parent() # optional - sage.rings.finite_rings - Multivariate Polynomial Ring in x, y, z over Finite Field of size 5 localized at (x, y*z - x) + sage: _.parent() + Multivariate Polynomial Ring in x, y, z over Finite Field of size 5 + localized at (x, y*z - x) """ def __init__(self, parent, x): @@ -267,9 +280,9 @@ def __init__(self, parent, x): sage: from sage.rings.localization import LocalizationElement sage: P. = RR[] - sage: L = Localization(P, x**2+x+1) - sage: l = LocalizationElement(L, (x**2+1)/(x**2+x+1)) - sage: l._value == (x**2+1)/(x**2+x+1) + sage: L = Localization(P, x**2 + x + 1) # needs sage.libs.pari + sage: l = LocalizationElement(L, (x**2+1)/(x**2+x+1)) # needs sage.libs.pari + sage: l._value == (x**2+1)/(x**2+x+1) # needs sage.libs.pari True """ IntegralDomainElement.__init__(self, parent) @@ -281,15 +294,16 @@ def _repr_(self): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: from sage.rings.localization import LocalizationElement sage: P. = CC[] - sage: L = Localization(P, x**2+x+1) + sage: L = Localization(P, x**2 + x + 1) sage: l = LocalizationElement(L, (x**2+1)/(x**2+x+1)) sage: l._repr_() == str(l) True sage: R. = ZZ[] - sage: L. = R.localization(X-Y) + sage: L. = R.localization(X - Y) sage: x*y/(x-y) x*y/(x - y) """ @@ -391,8 +405,8 @@ def factor(self, proof=None): sage: P. = QQ['x, y'] sage: L = P.localization(X - Y) sage: x, y = L.gens() - sage: p = (x^2 - y^2)/(x-y)^2 # optional - sage.libs.singular - sage: p.factor() # optional - sage.libs.singular + sage: p = (x^2 - y^2)/(x-y)^2 # needs sage.libs.singular + sage: p.factor() # needs sage.libs.singular (1/(x - y)) * (x + y) """ num = self._value.numerator() @@ -411,9 +425,9 @@ def _im_gens_(self, codomain, im_gens, base_map=None): EXAMPLES:: sage: R. = ZZ[] - sage: L = Localization(R, x**2 + 1) # optional - sage.libs.pari - sage: f = L.hom([5], codomain=Localization(ZZ, 26)) # indirect doctest # optional - sage.libs.pari - sage: f(x/(x**2+1)) # optional - sage.libs.pari + sage: L = Localization(R, x**2 + 1) # needs sage.libs.pari + sage: f = L.hom([5], codomain=Localization(ZZ, 26)) # indirect doctest # needs sage.libs.pari + sage: f(x/(x**2+1)) # needs sage.libs.pari 5/26 """ return self._value._im_gens_(codomain, im_gens, base_map=base_map) @@ -448,13 +462,14 @@ def is_unit(self): EXAMPLES:: + sage: # needs sage.libs.pari sage.singular sage: P. = QQ[] - sage: L = P.localization((x, y*z)) # optional - sage.libs.pari - sage: L(y*z).is_unit() # optional - sage.libs.pari + sage: L = P.localization((x, y*z)) + sage: L(y*z).is_unit() True - sage: L(z).is_unit() # optional - sage.libs.pari + sage: L(z).is_unit() True - sage: L(x*y*z).is_unit() # optional - sage.libs.pari + sage: L(x*y*z).is_unit() True """ return self.parent()._cut_off_extra_units_from_base_ring_element(self._value.numerator()).is_unit() @@ -467,9 +482,9 @@ def inverse_of_unit(self): sage: P. = ZZ[] sage: L = Localization(P, x*y*z) - sage: L(x*y*z).inverse_of_unit() # optional - sage.libs.singular + sage: L(x*y*z).inverse_of_unit() # needs sage.libs.singular 1/(x*y*z) - sage: L(z).inverse_of_unit() # optional - sage.libs.singular + sage: L(z).inverse_of_unit() # needs sage.libs.singular 1/z """ parent = self.parent() @@ -481,11 +496,12 @@ def _richcmp_(self, other, op): """ EXAMPLES:: - sage: P. = GF(7)[] # optional - sage.rings.finite_rings - sage: L = Localization(P, (x, y, z)) # optional - sage.rings.finite_rings - sage: L(1/x) < L(3/(x*y*z)**3) # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: P. = GF(7)[] + sage: L = Localization(P, (x, y, z)) + sage: L(1/x) < L(3/(x*y*z)**3) False - sage: ~L(y*z/x) == L(x/(y*z)) # optional - sage.rings.finite_rings + sage: ~L(y*z/x) == L(x/(y*z)) True """ sval = self._value @@ -518,8 +534,8 @@ def _rational_(self): TESTS:: sage: L = ZZ.localization(5) - sage: cp3 = cyclotomic_polynomial(3).change_ring(L) # optional - sage.libs.pari - sage: cp3.splitting_field('t') # indirect doctest # optional - sage.libs.pari sage.rings.number_field + sage: cp3 = cyclotomic_polynomial(3).change_ring(L) + sage: cp3.splitting_field('t') # indirect doctest # needs sage.libs.pari sage.rings.number_field Number Field in t with defining polynomial x^2 + x + 1 """ from sage.rings.rational_field import QQ @@ -601,42 +617,43 @@ class Localization(IntegralDomain, UniqueRepresentation): ... ValueError: factor 7 of denominator is not a unit - sage: Localization(Zp(7), (3, 5)) # optional - sage.rings.padics + sage: Localization(Zp(7), (3, 5)) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: all given elements are invertible in 7-adic Ring with capped relative precision 20 + sage: # needs sage.libs.pari sage: R. = ZZ[] - sage: L = R.localization(x**2 + 1) # optional - sage.libs.pari + sage: L = R.localization(x**2 + 1) sage: s = (x+5)/(x**2+1) - sage: s in L # optional - sage.libs.pari + sage: s in L True sage: t = (x+5)/(x**2+2) - sage: t in L # optional - sage.libs.pari + sage: t in L False - sage: L(t) # optional - sage.libs.pari + sage: L(t) Traceback (most recent call last): ... TypeError: fraction must have unit denominator - sage: L(s) in R # optional - sage.libs.pari + sage: L(s) in R False - sage: y = L(x) # optional - sage.libs.pari - sage: g = L(s) # optional - sage.libs.pari - sage: g.parent() # optional - sage.libs.pari + sage: y = L(x) + sage: g = L(s) + sage: g.parent() Univariate Polynomial Ring in x over Integer Ring localized at (x^2 + 1,) - sage: f = (y+5)/(y**2+1); f # optional - sage.libs.pari + sage: f = (y+5)/(y**2+1); f (x + 5)/(x^2 + 1) - sage: f == g # optional - sage.libs.pari + sage: f == g True - sage: (y+5)/(y**2+2) # optional - sage.libs.pari + sage: (y+5)/(y**2+2) Traceback (most recent call last): ... ValueError: factor x^2 + 2 of denominator is not a unit - sage: Lau. = LaurentPolynomialRing(ZZ) - sage: LauL = Lau.localization(u + 1) - sage: LauL(~u).parent() + sage: Lau. = LaurentPolynomialRing(ZZ) # needs sage.modules + sage: LauL = Lau.localization(u + 1) # needs sage.modules + sage: LauL(~u).parent() # needs sage.modules Multivariate Polynomial Ring in u, v over Integer Ring localized at (v, u, u + 1) More examples will be shown typing ``sage.rings.localization?`` @@ -662,8 +679,8 @@ def __init__(self, base_ring, extra_units, names=None, normalize=True, category= sage: TestSuite(L).run() sage: R. = ZZ[] - sage: L = R.localization(x**2 + 1) # optional - sage.libs.pari - sage: TestSuite(L).run() # optional - sage.libs.pari + sage: L = R.localization(x**2 + 1) # needs sage.libs.pari + sage: TestSuite(L).run() """ if type(extra_units) is tuple: extra_units = list(extra_units) @@ -703,8 +720,8 @@ def _repr_(self): EXAMPLES:: - sage: R. = GF(3)[] # optional - sage.rings.finite_rings - sage: Localization(R, a**2 - 1) # optional - sage.rings.finite_rings + sage: R. = GF(3)[] + sage: Localization(R, a**2 - 1) # needs sage.libs.pari Univariate Polynomial Ring in a over Finite Field of size 3 localized at (a + 1, a + 2) """ @@ -735,13 +752,13 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): EXAMPLES:: sage: R. = ZZ[] - sage: L = Localization(R, x**2 + 1) # optional - sage.libs.pari - sage: L.hom([5]) # indirect doctest # optional - sage.libs.pari + sage: L = Localization(R, x**2 + 1) # needs sage.libs.pari + sage: L.hom([5]) # indirect doctest # needs sage.libs.pari Traceback (most recent call last): ... ValueError: images of some localized elements fail to be units - sage: L.hom([5], codomain=Localization(ZZ, 26)) # indirect doctest # optional - sage.libs.pari + sage: L.hom([5], codomain=Localization(ZZ, 26)) # indirect doctest # needs sage.libs.pari Ring morphism: From: Univariate Polynomial Ring in x over Integer Ring localized at (x^2 + 1,) @@ -750,23 +767,22 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): TESTS:: + sage: # needs sage.libs.pari sage: phi = R.hom([5]) - sage: L._is_valid_homomorphism_(ZZ, [3], base_map=phi) # optional - sage.libs.pari + sage: L._is_valid_homomorphism_(ZZ, [3], base_map=phi) Traceback (most recent call last): ... ValueError: given base_map is not compatible with im_gens - sage: L._is_valid_homomorphism_(ZZ, [5], base_map=phi) # optional - sage.libs.pari + sage: L._is_valid_homomorphism_(ZZ, [5], base_map=phi) Traceback (most recent call last): ... ValueError: images of some localized elements fail to be units - sage: phi = R.hom([5], codomain=QQ) - sage: L._is_valid_homomorphism_(ZZ, [5], base_map=phi) # optional - sage.libs.pari + sage: L._is_valid_homomorphism_(ZZ, [5], base_map=phi) Traceback (most recent call last): ... ValueError: codomain of base_map must be Integer Ring - - sage: L._is_valid_homomorphism_(QQ, [5], base_map=phi) # optional - sage.libs.pari + sage: L._is_valid_homomorphism_(QQ, [5], base_map=phi) True """ B = self.base_ring() @@ -798,7 +814,7 @@ def ngens(self): EXAMPLES:: sage: R. = ZZ[] - sage: Localization(R, (x**2 + 1, y - 1)).ngens() # optional - sage.libs.pari + sage: Localization(R, (x**2 + 1, y - 1)).ngens() # needs sage.libs.pari 2 sage: Localization(ZZ, 2).ngens() @@ -814,7 +830,7 @@ def gen(self, i): EXAMPLES:: sage: R. = ZZ[] - sage: R.localization((x**2 + 1, y - 1)).gen(0) # optional - sage.libs.pari + sage: R.localization((x**2 + 1, y - 1)).gen(0) # needs sage.libs.pari x sage: ZZ.localization(2).gen(0) @@ -830,7 +846,7 @@ def gens(self): EXAMPLES:: sage: R. = ZZ[] - sage: Localization(R, (x**2 + 1, y - 1)).gens() # optional - sage.libs.pari + sage: Localization(R, (x**2 + 1, y - 1)).gens() # needs sage.libs.pari (x, y) sage: Localization(ZZ, 2).gens() @@ -854,10 +870,10 @@ def _cut_off_extra_units_from_base_ring_element(self, x): EXAMPLES:: sage: P. = QQ[] - sage: L = Localization(P, (x, y*z)) # optional - sage.libs.pari - sage: L._cut_off_extra_units_from_base_ring_element(x*y*z) # optional - sage.libs.pari + sage: L = Localization(P, (x, y*z)) # needs sage.libs.pari + sage: L._cut_off_extra_units_from_base_ring_element(x*y*z) # needs sage.libs.pari 1 - sage: L._cut_off_extra_units_from_base_ring_element(x*z) # optional - sage.libs.pari + sage: L._cut_off_extra_units_from_base_ring_element(x*z) # needs sage.libs.pari 1 TESTS: @@ -896,17 +912,18 @@ def _fraction_to_element(self, x): EXAMPLES:: + sage: # needs sage.libs.pari sage.libs.singular sage: P. = QQ[] sage: d = x**2 + y**2 + z**2 - sage: L = Localization(P, d) # optional - sage.libs.pari - sage: L._fraction_to_element((x+y+z)/d) # optional - sage.libs.pari + sage: L = Localization(P, d) + sage: L._fraction_to_element((x+y+z)/d) (x + y + z)/(x^2 + y^2 + z^2) - sage: _ in L # optional - sage.libs.pari + sage: _ in L True TESTS:: - sage: TestSuite(L).run() # optional - sage.libs.pari + sage: TestSuite(L).run() # needs sage.libs.pari sage.libs.singular """ potential_non_unit_denom = self._cut_off_extra_units_from_base_ring_element(x.denominator()) if potential_non_unit_denom.is_unit(): @@ -922,6 +939,7 @@ def _coerce_map_from_(self, S): EXAMPLES:: + sage: # needs sage.libs.pari sage.libs.singular sage: P. = QQ[] sage: L = Localization(P, y*z) sage: M = Localization(P, (x, y, z)) @@ -954,11 +972,12 @@ def fraction_field(self): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: L = Localization(R, (a**2 - 3, a)) # optional - sage.rings.finite_rings - sage: L.fraction_field() # optional - sage.rings.finite_rings + sage: # needs sage.libs.pari + sage: R. = GF(5)[] + sage: L = Localization(R, (a**2 - 3, a)) + sage: L.fraction_field() Fraction Field of Univariate Polynomial Ring in a over Finite Field of size 5 - sage: L.is_subring(_) # optional - sage.rings.finite_rings + sage: L.is_subring(_) True """ return self._fraction_field @@ -969,9 +988,10 @@ def characteristic(self): EXAMPLES:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: L = R.localization((a**2 - 3, a)) # optional - sage.rings.finite_rings - sage: L.characteristic() # optional - sage.rings.finite_rings + sage: # needs sage.libs.pari + sage: R. = GF(5)[] + sage: L = R.localization((a**2 - 3, a)) + sage: L.characteristic() 5 """ return self.base_ring().characteristic() diff --git a/src/sage/rings/monomials.py b/src/sage/rings/monomials.py index f0c1f92162f..ed154ab8c06 100644 --- a/src/sage/rings/monomials.py +++ b/src/sage/rings/monomials.py @@ -9,7 +9,7 @@ def _monomials(gens, R, n, i): EXAMPLES:: - sage: monomials([x], [3]) # indirect doctest + sage: monomials([x], [3]) # indirect doctest # needs sage.symbolic [1, x, x^2] """ # each power of the ith generator times all products @@ -53,7 +53,7 @@ def monomials(v, n): EXAMPLES:: - sage: monomials([x], [3]) + sage: monomials([x], [3]) # needs sage.symbolic [1, x, x^2] sage: R. = QQ[] sage: monomials([x,y], [5,5]) diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx index ba341f7f93a..797445e78eb 100644 --- a/src/sage/rings/morphism.pyx +++ b/src/sage/rings/morphism.pyx @@ -33,24 +33,25 @@ EXAMPLES: Reduction to finite field:: - sage: H = Hom(ZZ, GF(9, 'a')) # optional - sage.rings.finite_rings - sage: phi = H([1]) # optional - sage.rings.finite_rings - sage: phi(5) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: H = Hom(ZZ, GF(9, 'a')) + sage: phi = H([1]) + sage: phi(5) 2 - sage: psi = H([4]) # optional - sage.rings.finite_rings - sage: psi(5) # optional - sage.rings.finite_rings + sage: psi = H([4]) + sage: psi(5) 2 Map from single variable polynomial ring:: sage: R. = ZZ[] - sage: phi = R.hom([2], GF(5)) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: phi = R.hom([2], GF(5)) + sage: phi Ring morphism: From: Univariate Polynomial Ring in x over Integer Ring To: Finite Field of size 5 Defn: x |--> 2 - sage: phi(x + 12) # optional - sage.rings.finite_rings + sage: phi(x + 12) 4 Identity map on the real numbers:: @@ -70,8 +71,8 @@ Homomorphism from one precision of field to another. From smaller to bigger doesn't make sense:: - sage: R200 = RealField(200) - sage: f = RR.hom( R200 ) + sage: R200 = RealField(200) # needs sage.rings.real_mpfr + sage: f = RR.hom( R200 ) # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: natural coercion morphism from Real Field with 53 bits of precision @@ -79,7 +80,7 @@ From smaller to bigger doesn't make sense:: From bigger to small does:: - sage: f = RR.hom( RealField(15) ) + sage: f = RR.hom( RealField(15) ) # needs sage.rings.real_mpfr sage: f(2.5) 2.500 sage: f(RR.pi()) @@ -98,16 +99,17 @@ Inclusion map from the reals to the complexes:: A map from a multivariate polynomial ring to itself:: sage: R. = PolynomialRing(QQ,3) - sage: phi = R.hom([y,z,x^2]); phi + sage: phi = R.hom([y, z, x^2]); phi Ring endomorphism of Multivariate Polynomial Ring in x, y, z over Rational Field Defn: x |--> y y |--> z z |--> x^2 - sage: phi(x+y+z) + sage: phi(x + y + z) x^2 + y + z An endomorphism of a quotient of a multi-variate polynomial ring:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ) sage: S. = quo(R, ideal(1 + y^2)) sage: phi = S.hom([a^2, -b]) @@ -125,8 +127,7 @@ The reduction map from the integers to the integers modulo 8, viewed as a quotient ring:: sage: R = ZZ.quo(8*ZZ) - sage: pi = R.cover() - sage: pi + sage: pi = R.cover(); pi Ring morphism: From: Integer Ring To: Ring of integers modulo 8 @@ -147,28 +148,30 @@ a quotient ring:: Inclusion of ``GF(2)`` into ``GF(4,'a')``:: - sage: k = GF(2) # optional - sage.rings.finite_rings - sage: i = k.hom(GF(4, 'a')) # optional - sage.rings.finite_rings - sage: i # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k = GF(2) + sage: i = k.hom(GF(4, 'a')) + sage: i Ring morphism: From: Finite Field of size 2 To: Finite Field in a of size 2^2 Defn: 1 |--> 1 - sage: i(0) # optional - sage.rings.finite_rings + sage: i(0) 0 - sage: a = i(1); a.parent() # optional - sage.rings.finite_rings + sage: a = i(1); a.parent() Finite Field in a of size 2^2 We next compose the inclusion with reduction from the integers to ``GF(2)``:: - sage: pi = ZZ.hom(k) # optional - sage.rings.finite_rings - sage: pi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: pi = ZZ.hom(k) + sage: pi Natural morphism: From: Integer Ring To: Finite Field of size 2 - sage: f = i * pi # optional - sage.rings.finite_rings - sage: f # optional - sage.rings.finite_rings + sage: f = i * pi + sage: f Composite map: From: Integer Ring To: Finite Field in a of size 2^2 @@ -180,25 +183,27 @@ We next compose the inclusion with reduction from the integers to From: Finite Field of size 2 To: Finite Field in a of size 2^2 Defn: 1 |--> 1 - sage: a = f(5); a # optional - sage.rings.finite_rings + sage: a = f(5); a 1 - sage: a.parent() # optional - sage.rings.finite_rings + sage: a.parent() Finite Field in a of size 2^2 Inclusion from `\QQ` to the 3-adic field:: - sage: phi = QQ.hom(Qp(3, print_mode='series')) # optional - sage.rings.padics - sage: phi # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: phi = QQ.hom(Qp(3, print_mode='series')) + sage: phi Ring morphism: From: Rational Field To: 3-adic Field with capped relative precision 20 - sage: phi.codomain() # optional - sage.rings.padics + sage: phi.codomain() 3-adic Field with capped relative precision 20 - sage: phi(394) # optional - sage.rings.padics + sage: phi(394) 1 + 2*3 + 3^2 + 2*3^3 + 3^4 + 3^5 + O(3^20) An automorphism of a quotient of a univariate polynomial ring:: + sage: # needs sage.libs.pari sage: R. = PolynomialRing(QQ) sage: S. = R.quo(x^2 - 2) sage: sqrt2^2 @@ -211,12 +216,13 @@ An automorphism of a quotient of a univariate polynomial ring:: Note that Sage verifies that the morphism is valid:: - sage: (1 - sqrt2)^2 + sage: (1 - sqrt2)^2 # needs sage.libs.pari -2*sqrt2 + 3 - sage: c = S.hom([1-sqrt2]) # this is not valid + sage: c = S.hom([1 - sqrt2]) # this is not valid # needs sage.libs.pari Traceback (most recent call last): ... - ValueError: relations do not all (canonically) map to 0 under map determined by images of generators + ValueError: relations do not all (canonically) map to 0 + under map determined by images of generators Endomorphism of power series ring:: @@ -232,19 +238,19 @@ Endomorphism of power series ring:: Frobenius on a power series ring over a finite field:: - sage: R. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: f = R.hom([t^5]); f # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(5)) + sage: f = R.hom([t^5]); f Ring endomorphism of Power Series Ring in t over Finite Field of size 5 Defn: t |--> t^5 - sage: a = 2 + t + 3*t^2 + 4*t^3 + O(t^4) # optional - sage.rings.finite_rings - sage: b = 1 + t + 2*t^2 + t^3 + O(t^5) # optional - sage.rings.finite_rings - sage: f(a) # optional - sage.rings.finite_rings + sage: a = 2 + t + 3*t^2 + 4*t^3 + O(t^4) + sage: b = 1 + t + 2*t^2 + t^3 + O(t^5) + sage: f(a) 2 + t^5 + 3*t^10 + 4*t^15 + O(t^20) - sage: f(b) # optional - sage.rings.finite_rings + sage: f(b) 1 + t^5 + 2*t^10 + t^15 + O(t^25) - sage: f(a*b) # optional - sage.rings.finite_rings + sage: f(a*b) 2 + 3*t^5 + 3*t^10 + t^15 + O(t^20) - sage: f(a)*f(b) # optional - sage.rings.finite_rings + sage: f(a)*f(b) 2 + 3*t^5 + 3*t^10 + t^15 + O(t^20) Homomorphism of Laurent series ring:: @@ -270,14 +276,17 @@ positive:: sage: R.hom([1/t]) Traceback (most recent call last): ... - ValueError: relations do not all (canonically) map to 0 under map determined by images of generators + ValueError: relations do not all (canonically) map to 0 + under map determined by images of generators sage: R.hom([1]) Traceback (most recent call last): ... - ValueError: relations do not all (canonically) map to 0 under map determined by images of generators + ValueError: relations do not all (canonically) map to 0 + under map determined by images of generators Complex conjugation on cyclotomic fields:: + sage: # needs sage.rings.number_field sage: K. = CyclotomicField(7) sage: c = K.hom([1/zeta7]); c Ring endomorphism of Cyclotomic Field of order 7 and degree 6 @@ -293,6 +302,7 @@ Complex conjugation on cyclotomic fields:: Embedding a number field into the reals:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^3 - 2) sage: alpha = RR(2)^(1/3); alpha @@ -311,7 +321,7 @@ Embedding a number field into the reals:: An example from Jim Carlson:: - sage: K = QQ # by the way :-) + sage: K = QQ # by the way :-) sage: R. = K[]; R Multivariate Polynomial Ring in a, b, c, d over Rational Field sage: S. = K[]; S @@ -324,9 +334,9 @@ An example from Jim Carlson:: b |--> 0 c |--> 0 d |--> u - sage: f(a+b+c+d) + sage: f(a + b + c + d) u - sage: f( (a+b+c+d)^2 ) + sage: f((a+b+c+d)^2) u^2 TESTS:: @@ -337,51 +347,51 @@ TESTS:: :: - sage: K. = CyclotomicField(7) # optional - sage.rings.number_field - sage: c = K.hom([1/zeta7]) # optional - sage.rings.number_field - sage: c == loads(dumps(c)) # optional - sage.rings.number_field + sage: K. = CyclotomicField(7) # needs sage.rings.number_field + sage: c = K.hom([1/zeta7]) # needs sage.rings.number_field + sage: c == loads(dumps(c)) True :: - sage: R. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: f = R.hom([t^5]) # optional - sage.rings.finite_rings - sage: f == loads(dumps(f)) # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(5)) + sage: f = R.hom([t^5]) + sage: f == loads(dumps(f)) True We define the identity map in many possible ways. These should all compare equal:: - sage: k = GF(2) # optional - sage.rings.finite_rings - sage: R. = k[] # optional - sage.rings.finite_rings - sage: F4. = R.quo(x^2+x+1) # optional - sage.rings.finite_rings - sage: H = End(F4) # optional - sage.rings.finite_rings - + sage: # needs sage.rings.finite_rings + sage: k = GF(2) + sage: R. = k[] + sage: F4. = R.quo(x^2+x+1) + sage: H = End(F4) sage: from sage.rings.morphism import * - sage: phi1 = H.identity(); phi1 # optional - sage.rings.finite_rings + sage: phi1 = H.identity(); phi1 Identity endomorphism of Univariate Quotient Polynomial Ring in a over Finite Field of size 2 with modulus x^2 + x + 1 - sage: phi2 = H([a]); phi2 # optional - sage.rings.finite_rings + sage: phi2 = H([a]); phi2 Ring endomorphism of Univariate Quotient Polynomial Ring in a over Finite Field of size 2 with modulus x^2 + x + 1 Defn: a |--> a - sage: phi3 = RingHomomorphism_from_base(H, R.hom([x])); phi3 # optional - sage.rings.finite_rings + sage: phi3 = RingHomomorphism_from_base(H, R.hom([x])); phi3 # needs sage.libs.ntl Ring endomorphism of Univariate Quotient Polynomial Ring in a over Finite Field of size 2 with modulus x^2 + x + 1 Defn: Induced from base ring by Ring endomorphism of Univariate Polynomial Ring in x over Finite Field of size 2 (using GF2X) Defn: x |--> x - sage: phi4 = RingHomomorphism_cover(H); phi4 # optional - sage.rings.finite_rings + sage: phi4 = RingHomomorphism_cover(H); phi4 Ring endomorphism of Univariate Quotient Polynomial Ring in a over Finite Field of size 2 with modulus x^2 + x + 1 Defn: Natural quotient map - sage: phi5 = F4.frobenius_endomorphism() ^ 2; phi5 # optional - sage.rings.finite_rings + sage: phi5 = F4.frobenius_endomorphism() ^ 2; phi5 Frobenius endomorphism x |--> x^(2^2) of Univariate Quotient Polynomial Ring in a over Finite Field of size 2 with modulus x^2 + x + 1 - sage: maps = [phi1, phi2, phi3, phi4, phi5] # optional - sage.rings.finite_rings - sage: for f in maps: # optional - sage.rings.finite_rings + sage: maps = [phi1, phi2, phi3, phi4, phi5] # needs sage.libs.ntl + sage: for f in maps: # needs sage.libs.ntl ....: for g in maps: ....: if f != g: ....: print("{} != {}".format(f, g)) @@ -467,14 +477,14 @@ cdef class RingMap_lift(RingMap): EXAMPLES:: sage: R. = QQ[] - sage: S. = R.quo( (x^2 + y^2, y) ) # optional - sage.libs.singular - sage: S.lift() # optional - sage.libs.singular + sage: S. = R.quo( (x^2 + y^2, y) ) # needs sage.libs.singular + sage: S.lift() # needs sage.libs.singular Set-theoretic ring morphism: From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2, y) To: Multivariate Polynomial Ring in x, y over Rational Field Defn: Choice of lifting map - sage: S.lift() == 0 # optional - sage.libs.singular + sage: S.lift() == 0 # needs sage.libs.singular False Since :trac:`11068`, it is possible to create @@ -484,10 +494,11 @@ cdef class RingMap_lift(RingMap): of :class:`sage.rings.ring.Ring`, as in the following example:: - sage: MS = MatrixSpace(GF(5), 2, 2) # optional - sage.modules sage.rings.finite_rings - sage: I = MS * [MS.0*MS.1, MS.2+MS.3] * MS # optional - sage.modules sage.rings.finite_rings - sage: Q = MS.quo(I) # optional - sage.modules sage.rings.finite_rings - sage: Q.0*Q.1 # indirect doctest # optional - sage.modules sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings + sage: MS = MatrixSpace(GF(5), 2, 2) + sage: I = MS * [MS.0*MS.1, MS.2+MS.3] * MS + sage: Q = MS.quo(I) + sage: Q.0*Q.1 # indirect doctest [0 1] [0 0] """ @@ -507,9 +518,9 @@ cdef class RingMap_lift(RingMap): An invalid example:: - sage: GF9. = GaussianIntegers().quotient(3) # optional - sage.rings.number_field - sage: from sage.rings.morphism import RingMap_lift # optional - sage.rings.number_field - sage: RingMap_lift(GF9, ZZ) # optional - sage.rings.number_field + sage: GF9. = GaussianIntegers().quotient(3) # needs sage.rings.number_field + sage: from sage.rings.morphism import RingMap_lift + sage: RingMap_lift(GF9, ZZ) # needs sage.rings.number_field Traceback (most recent call last): ... TypeError: no canonical coercion from Number Field in I @@ -652,14 +663,14 @@ cdef class RingHomomorphism(RingMap): EXAMPLES:: - sage: f = ZZ.hom(Zp(3)); f # optional - sage.rings.padics + sage: f = ZZ.hom(Zp(3)); f # needs sage.rings.padics Ring morphism: From: Integer Ring To: 3-adic Ring with capped relative precision 20 TESTS:: - sage: isinstance(f, sage.rings.morphism.RingHomomorphism) # optional - sage.rings.padics + sage: isinstance(f, sage.rings.morphism.RingHomomorphism) # needs sage.rings.padics True """ @@ -674,7 +685,7 @@ cdef class RingHomomorphism(RingMap): TESTS:: - sage: ZZ.hom(Zp(3))._repr_type() # optional - sage.rings.padics + sage: ZZ.hom(Zp(3))._repr_type() # needs sage.rings.padics 'Ring' """ @@ -787,17 +798,17 @@ cdef class RingHomomorphism(RingMap): result has the type of a homomorphism between its domain and codomain:: - sage: C = CyclotomicField(24) # optional - sage.rings.number_field - sage: f = End(C)[1] # optional - sage.rings.number_field - sage: type(f*f) == type(f) # optional - sage.rings.number_field + sage: C = CyclotomicField(24) # needs sage.rings.number_field + sage: f = End(C)[1] # needs sage.rings.number_field + sage: type(f*f) == type(f) # needs sage.rings.number_field True An example where the domain of ``right`` is a relative number field:: sage: PQ. = QQ[] - sage: K. = NumberField([X^2 - 2, X^2 - 3]) # optional - sage.rings.number_field - sage: e, u, v, w = End(K) # optional - sage.rings.number_field - sage: u*v # optional - sage.rings.number_field + sage: K. = NumberField([X^2 - 2, X^2 - 3]) # needs sage.rings.number_field + sage: e, u, v, w = End(K) # needs sage.rings.number_field + sage: u*v # needs sage.rings.number_field Relative number field endomorphism of Number Field in a with defining polynomial X^2 - 2 over its base field Defn: a |--> -a @@ -822,21 +833,22 @@ cdef class RingHomomorphism(RingMap): We check that composition works when there is a base map:: + sage: # needs sage.rings.finite_rings sage: R. = ZZ[] - sage: K. = GF(7^2) # optional - sage.rings.finite_rings - sage: L. = K.extension(x^3 - 3) # optional - sage.rings.finite_rings - sage: phi = L.hom([u^7], base_map=K.frobenius_endomorphism()) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: K. = GF(7^2) + sage: L. = K.extension(x^3 - 3) + sage: phi = L.hom([u^7], base_map=K.frobenius_endomorphism()) + sage: phi Ring endomorphism of Univariate Quotient Polynomial Ring in u over Finite Field in a of size 7^2 with modulus u^3 + 4 Defn: u |--> 2*u with map of base ring - sage: psi = phi^3; psi # optional - sage.rings.finite_rings + sage: psi = phi^3; psi Ring endomorphism of Univariate Quotient Polynomial Ring in u over Finite Field in a of size 7^2 with modulus u^3 + 4 Defn: u |--> u with map of base ring - sage: psi(a) == phi(phi(phi(a))) # optional - sage.rings.finite_rings + sage: psi(a) == phi(phi(phi(a))) True It also works when the image of the base map is not contained within the base ring of the codomain:: @@ -905,8 +917,8 @@ cdef class RingHomomorphism(RingMap): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo([x^2, y^2]); f = S.cover() # optional - sage.libs.singular - sage: f.pushforward(R.ideal([x, 3*x + x*y + y^2])) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo([x^2, y^2]); f = S.cover() # needs sage.libs.singular + sage: f.pushforward(R.ideal([x, 3*x + x*y + y^2])) # needs sage.libs.singular Ideal (xx, xx*yy + 3*xx) of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y^2) """ @@ -939,18 +951,18 @@ cdef class RingHomomorphism(RingMap): sage: S. = QQ[] sage: f = R.hom([u^2, u*v, v^2], S) sage: I = S.ideal([u^6, u^5*v, u^4*v^2, u^3*v^3]) - sage: J = f.inverse_image(I); J # optional - sage.libs.singular + sage: J = f.inverse_image(I); J # needs sage.libs.singular Ideal (y^2 - x*z, x*y*z, x^2*z, x^2*y, x^3) of Multivariate Polynomial Ring in x, y, z over Rational Field - sage: f(J) == I # optional - sage.libs.singular + sage: f(J) == I # needs sage.libs.singular True Under the above homomorphism, there exists an inverse image for every element that only involves monomials of even degree:: - sage: [f.inverse_image(p) for p in [u^2, u^4, u*v + u^3*v^3]] # optional - sage.libs.singular + sage: [f.inverse_image(p) for p in [u^2, u^4, u*v + u^3*v^3]] # needs sage.libs.singular [x, x^2, x*y*z + y] - sage: f.inverse_image(u*v^2) # optional - sage.libs.singular + sage: f.inverse_image(u*v^2) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: element u*v^2 does not have preimage @@ -958,27 +970,29 @@ cdef class RingHomomorphism(RingMap): The image of the inverse image ideal can be strictly smaller than the original ideal:: - sage: S. = QQ['u,v'].quotient('v^2 - 2') # optional - sage.libs.singular - sage: f = QuadraticField(2).hom([v], S) # optional - sage.libs.singular sage.rings.number_field - sage: I = S.ideal(u + v) # optional - sage.libs.singular sage.rings.number_field - sage: J = f.inverse_image(I) # optional - sage.libs.singular sage.rings.number_field - sage: J.is_zero() # optional - sage.libs.singular sage.rings.number_field + sage: # needs sage.libs.singular sage.rings.number_field + sage: S. = QQ['u,v'].quotient('v^2 - 2') + sage: f = QuadraticField(2).hom([v], S) + sage: I = S.ideal(u + v) + sage: J = f.inverse_image(I) + sage: J.is_zero() True - sage: f(J) < I # optional - sage.libs.singular sage.rings.number_field + sage: f(J) < I True Fractional ideals are not yet fully supported:: - sage: K. = NumberField(QQ['x']('x^2+2')) # optional - sage.rings.number_field - sage: f = K.hom([-a], K) # optional - sage.rings.number_field - sage: I = K.ideal([a + 1]) # optional - sage.rings.number_field - sage: f.inverse_image(I) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(QQ['x']('x^2+2')) + sage: f = K.hom([-a], K) + sage: I = K.ideal([a + 1]) + sage: f.inverse_image(I) Traceback (most recent call last): ... NotImplementedError: inverse image not implemented... - sage: f.inverse_image(K.ideal(0)).is_zero() # optional - sage.rings.number_field + sage: f.inverse_image(K.ideal(0)).is_zero() True - sage: f.inverse()(I) # optional - sage.rings.number_field + sage: f.inverse()(I) Fractional ideal (-a + 1) ALGORITHM: @@ -992,7 +1006,7 @@ cdef class RingHomomorphism(RingMap): TESTS:: - sage: ZZ.hom(Zp(2)).inverse_image(ZZ.ideal(2)) # optional - sage.rings.padics + sage: ZZ.hom(Zp(2)).inverse_image(ZZ.ideal(2)) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: not an ideal or element in codomain 2-adic Ring @@ -1000,7 +1014,7 @@ cdef class RingHomomorphism(RingMap): :: - sage: ZZ.hom(Zp(2)).inverse_image(Zp(2).ideal(2)) # optional - sage.rings.padics + sage: ZZ.hom(Zp(2)).inverse_image(Zp(2).ideal(2)) # needs sage.rings.padics Traceback (most recent call last): ... NotImplementedError: base rings must be equal @@ -1020,13 +1034,14 @@ cdef class RingHomomorphism(RingMap): EXAMPLES:: - sage: R. = QQbar[] # optional - sage.rings.number_field - sage: f = R.hom([x, QQbar(i) * x + y^2], R) # optional - sage.rings.number_field - sage: I = R.ideal(y^3) # optional - sage.rings.number_field - sage: J = f._inverse_image_ideal(I); J # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: R. = QQbar[] + sage: f = R.hom([x, QQbar(i) * x + y^2], R) + sage: I = R.ideal(y^3) + sage: J = f._inverse_image_ideal(I); J Ideal (x^2 + 2*I*x*y - y^2) of Multivariate Polynomial Ring in x, y over Algebraic Field - sage: f(J) <= I # optional - sage.rings.number_field + sage: f(J) <= I True TESTS: @@ -1034,17 +1049,17 @@ cdef class RingHomomorphism(RingMap): Check that :trac:`31367` is fixed:: sage: A. = QQ[] - sage: B. = QQ['x,y'].quotient('y') # optional - sage.libs.singular - sage: f = A.hom([x], B) # optional - sage.libs.singular - sage: f.kernel() # optional - sage.libs.singular + sage: B. = QQ['x,y'].quotient('y') # needs sage.libs.singular + sage: f = A.hom([x], B) # needs sage.libs.singular + sage: f.kernel() # needs sage.libs.singular Principal ideal (0) of Univariate Polynomial Ring in t over Rational Field :: sage: A. = QQ[] - sage: B. = QQ['x,y,z'].quotient('z') # optional - sage.libs.singular - sage: f = A.hom([x, y], B) # optional - sage.libs.singular - sage: f.kernel() # optional - sage.libs.singular + sage: B. = QQ['x,y,z'].quotient('z') # needs sage.libs.singular + sage: f = A.hom([x, y], B) # needs sage.libs.singular + sage: f.kernel() # needs sage.libs.singular Ideal (0) of Multivariate Polynomial Ring in t, u over Rational Field """ from .polynomial.polynomial_quotient_ring import is_PolynomialQuotientRing @@ -1086,36 +1101,38 @@ cdef class RingHomomorphism(RingMap): A degenerate case:: - sage: R. = QQ['x,y'].quotient(1) # optional - sage.libs.singular - sage: f = R.hom([y, x], R) # optional - sage.libs.singular - sage: f.inverse_image(x), f.inverse_image(y) # indirect doctest # optional - sage.libs.singular + sage: R. = QQ['x,y'].quotient(1) # needs sage.libs.singular + sage: f = R.hom([y, x], R) # needs sage.libs.singular + sage: f.inverse_image(x), f.inverse_image(y) # indirect doctest # needs sage.libs.singular (0, 0) Check cases involving quotient rings in which a generator is constant (:trac:`31178`):: + sage: # needs sage.libs.singular sage: R. = QQ[] - sage: B. = R.quotient(R.ideal(x)) # optional - sage.libs.singular - sage: g = R.hom([d^2, d^3], B) # optional - sage.libs.singular - sage: g.inverse_image(d) # optional - sage.libs.singular + sage: B. = R.quotient(R.ideal(x)) + sage: g = R.hom([d^2, d^3], B) + sage: g.inverse_image(d) Traceback (most recent call last): ... ValueError: element d does not have preimage - sage: g.inverse_image(d^2) # optional - sage.libs.singular + sage: g.inverse_image(d^2) x - sage: g.inverse_image(d^3) # optional - sage.libs.singular + sage: g.inverse_image(d^3) y - sage: A. = R.quotient(R.ideal(y^2 - x^3)) # optional - sage.libs.singular - sage: h = A.hom([d^2, d^3], B) # optional - sage.libs.singular - sage: h.inverse_image(d^2) # optional - sage.libs.singular + sage: A. = R.quotient(R.ideal(y^2 - x^3)) + sage: h = A.hom([d^2, d^3], B) + sage: h.inverse_image(d^2) a Check that quotient rings are handled correctly (:trac:`33217`):: - sage: A. = QQ['X,Y,Z'].quotient('X^2+Y^2+Z^2-1') # optional - sage.libs.singular - sage: B. = QQ['T,U,V,W'].quotient(['T^2+U^2-1', 'V^2+W^2-1']) # optional - sage.libs.singular - sage: psi = A.hom([v*u, w*u, t], B) # optional - sage.libs.singular - sage: psi.inverse_image(t^2) == z^2 # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: A. = QQ['X,Y,Z'].quotient('X^2+Y^2+Z^2-1') + sage: B. = QQ['T,U,V,W'].quotient(['T^2+U^2-1', 'V^2+W^2-1']) + sage: psi = A.hom([v*u, w*u, t], B) + sage: psi.inverse_image(t^2) == z^2 True """ graph, from_B, to_A = self._graph_ideal() @@ -1135,7 +1152,7 @@ cdef class RingHomomorphism(RingMap): sage: A. = QQ[] sage: B. = QQ[] sage: f = A.hom([t^4, t^3 - t^2], B) - sage: f.kernel() # optional - sage.libs.singular + sage: f.kernel() # needs sage.libs.singular Ideal (y^4 - x^3 + 4*x^2*y - 2*x*y^2 + x^2) of Multivariate Polynomial Ring in x, y over Rational Field @@ -1144,18 +1161,18 @@ cdef class RingHomomorphism(RingMap): sage: A. = QQ[] sage: B. = QQ[] sage: f = A.hom([u^3, u^2*v, u*v^2, v^3], B) - sage: f.kernel() == A.ideal(matrix.hankel([a, b, c], [d]).minors(2)) # optional - sage.libs.singular + sage: f.kernel() == A.ideal(matrix.hankel([a, b, c], [d]).minors(2)) # needs sage.libs.singular True - sage: Q = A.quotient(f.kernel()) # optional - sage.libs.singular - sage: Q.hom(f.im_gens(), B).is_injective() # optional - sage.libs.singular + sage: Q = A.quotient(f.kernel()) # needs sage.libs.singular + sage: Q.hom(f.im_gens(), B).is_injective() # needs sage.libs.singular True The Steiner-Roman surface:: sage: R. = QQ[] - sage: S = R.quotient(x^2 + y^2 + z^2 - 1) # optional - sage.libs.singular - sage: f = R.hom([x*y, x*z, y*z], S) # optional - sage.libs.singular - sage: f.kernel() # optional - sage.libs.singular + sage: S = R.quotient(x^2 + y^2 + z^2 - 1) + sage: f = R.hom([x*y, x*z, y*z], S) # needs sage.libs.singular + sage: f.kernel() # needs sage.libs.singular Ideal (x^2*y^2 + x^2*z^2 + y^2*z^2 - x*y*z) of Multivariate Polynomial Ring in x, y, z over Rational Field @@ -1163,30 +1180,31 @@ cdef class RingHomomorphism(RingMap): The results are cached:: - sage: f.kernel() is f.kernel() # optional - sage.libs.singular + sage: f.kernel() is f.kernel() # needs sage.libs.singular True A degenerate case:: sage: R. = QQ[] - sage: f = R.hom([0, 0], R.quotient(1)) # optional - sage.libs.singular - sage: f.kernel().is_one() # optional - sage.libs.singular + sage: f = R.hom([0, 0], R.quotient(1)) # needs sage.libs.singular + sage: f.kernel().is_one() # needs sage.libs.singular True :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: K.hom([-sqrt2], K).kernel().is_zero() # optional - sage.rings.number_field + sage: K. = QuadraticField(2) # needs sage.rings.number_field + sage: K.hom([-sqrt2], K).kernel().is_zero() # needs sage.rings.number_field True :: - sage: A. = QuadraticField(2) # optional - sage.rings.number_field - sage: B. = A.extension(A['b']('b^2-3')) # optional - sage.rings.number_field - sage: C. = B.absolute_field() # optional - sage.rings.number_field - sage: A.hom([B(a)], C).kernel().is_zero() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: A. = QuadraticField(2) + sage: B. = A.extension(A['b']('b^2-3')) + sage: C. = B.absolute_field() + sage: A.hom([B(a)], C).kernel().is_zero() True - sage: A.hom([a], B).kernel() # optional - sage.rings.number_field + sage: A.hom([a], B).kernel() Traceback (most recent call last): ... NotImplementedError: base rings must be equal @@ -1261,32 +1279,34 @@ cdef class RingHomomorphism(RingMap): Ideals in quotient rings over ``QQbar`` do not support reduction yet, so the graph is constructed in the ambient ring instead:: - sage: A. = QQbar['z,w'].quotient('z*w - 1') # optional - sage.rings.number_field - sage: B. = QQbar['x,y'].quotient('2*x^2 + y^2 - 1') # optional - sage.rings.number_field - sage: f = A.hom([QQbar(2).sqrt()*x + QQbar(I)*y, # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: A. = QQbar['z,w'].quotient('z*w - 1') + sage: B. = QQbar['x,y'].quotient('2*x^2 + y^2 - 1') + sage: f = A.hom([QQbar(2).sqrt()*x + QQbar(I)*y, ....: QQbar(2).sqrt()*x - QQbar(I)*y], B) - sage: f._graph_ideal()[0] # optional - sage.rings.number_field + sage: f._graph_ideal()[0] Ideal (z*w - 1, 2*x^2 + y^2 - 1, 1.414213562373095?*x + I*y - z, 1.414213562373095?*x + (-I)*y - w) of Multivariate Polynomial Ring in x, y, z, w over Algebraic Field - sage: f.inverse()(f(z)), f.inverse()(f(w)) # optional - sage.rings.number_field + sage: f.inverse()(f(z)), f.inverse()(f(w)) (z, w) Non-trivial base maps are not supported:: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: f = R.hom([x, a*x + y], R, base_map=K.hom([-a], K)) # optional - sage.rings.number_field - sage: f._graph_ideal() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: R. = K[] + sage: f = R.hom([x, a*x + y], R, base_map=K.hom([-a], K)) + sage: f._graph_ideal() Traceback (most recent call last): ... NotImplementedError: base map must be trivial Non-commutative rings are not supported (:trac:`32824`):: - sage: A = GradedCommutativeAlgebra(QQ, 'x,y,z') # optional - sage.combinat sage.modules - sage: A.hom(A.gens(), A).kernel() # optional - sage.combinat sage.modules + sage: A = GradedCommutativeAlgebra(QQ, 'x,y,z') # needs sage.combinat sage.modules + sage: A.hom(A.gens(), A).kernel() # needs sage.combinat sage.modules Traceback (most recent call last): ... NotImplementedError: rings are not commutative @@ -1343,24 +1363,25 @@ cdef class RingHomomorphism(RingMap): sage: R. = QQ[] sage: f = R.hom([2*t - 1], R) - sage: f.inverse() # optional - sage.libs.singular + sage: f.inverse() # needs sage.libs.singular Ring endomorphism of Univariate Polynomial Ring in t over Rational Field Defn: t |--> 1/2*t + 1/2 The following non-linear homomorphism is not invertible, but it induces an isomorphism on a quotient ring:: + sage: # needs sage.libs.singular sage: R. = QQ[] sage: f = R.hom([y*z, x*z, x*y], R) - sage: f.inverse() # optional - sage.libs.singular + sage: f.inverse() Traceback (most recent call last): ... ZeroDivisionError: ring homomorphism not surjective - sage: f.is_injective() # optional - sage.libs.singular + sage: f.is_injective() True - sage: Q. = R.quotient(x*y*z - 1) # optional - sage.libs.singular - sage: g = Q.hom([y*z, x*z, x*y], Q) # optional - sage.libs.singular - sage: g.inverse() # optional - sage.libs.singular + sage: Q. = R.quotient(x*y*z - 1) + sage: g = Q.hom([y*z, x*z, x*y], Q) + sage: g.inverse() Ring endomorphism of Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (x*y*z - 1) Defn: x |--> y*z @@ -1371,24 +1392,24 @@ cdef class RingHomomorphism(RingMap): sage: S. = ZZ[] sage: f = S.hom([x + 2*y, x + 3*y], S) - sage: f.inverse() # optional - sage.libs.singular + sage: f.inverse() # needs sage.libs.singular Ring endomorphism of Multivariate Polynomial Ring in x, y over Integer Ring Defn: x |--> 3*x - 2*y y |--> -x + y - sage: (f.inverse() * f).is_identity() # optional - sage.libs.singular + sage: (f.inverse() * f).is_identity() # needs sage.libs.singular True The following homomorphism is invertible over the rationals, but not over the integers:: sage: g = S.hom([x + y, x - y - 2], S) - sage: g.inverse() # optional - sage.libs.singular + sage: g.inverse() # needs sage.libs.singular Traceback (most recent call last): ... ZeroDivisionError: ring homomorphism not surjective sage: R. = QQ[x,y] sage: h = R.hom([x + y, x - y - 2], R) - sage: (h.inverse() * h).is_identity() # optional - sage.libs.singular + sage: (h.inverse() * h).is_identity() # needs sage.libs.singular True This example by M. Nagata is a wild automorphism:: @@ -1396,13 +1417,13 @@ cdef class RingHomomorphism(RingMap): sage: R. = QQ[] sage: sigma = R.hom([x - 2*y*(z*x+y^2) - z*(z*x+y^2)^2, ....: y + z*(z*x+y^2), z], R) - sage: tau = sigma.inverse(); tau # optional - sage.libs.singular + sage: tau = sigma.inverse(); tau # needs sage.libs.singular Ring endomorphism of Multivariate Polynomial Ring in x, y, z over Rational Field Defn: x |--> -y^4*z - 2*x*y^2*z^2 - x^2*z^3 + 2*y^3 + 2*x*y*z + x y |--> -y^2*z - x*z^2 + y z |--> z - sage: (tau * sigma).is_identity() # optional - sage.libs.singular + sage: (tau * sigma).is_identity() # needs sage.libs.singular True We compute the triangular automorphism that converts moments to @@ -1426,81 +1447,85 @@ cdef class RingHomomorphism(RingMap): x1^5 + 10*x1^3*x2 + 15*x1*x2^2 + 10*x1^2*x3 + 10*x2*x3 + 5*x1*x4 + x5] sage: all(p.is_homogeneous() for p in phi.im_gens()) True - sage: phi.inverse().im_gens()[:5] # optional - sage.libs.singular + sage: phi.inverse().im_gens()[:5] # needs sage.libs.singular [x1, -x1^2 + x2, 2*x1^3 - 3*x1*x2 + x3, -6*x1^4 + 12*x1^2*x2 - 3*x2^2 - 4*x1*x3 + x4, 24*x1^5 - 60*x1^3*x2 + 30*x1*x2^2 + 20*x1^2*x3 - 10*x2*x3 - 5*x1*x4 + x5] - sage: (phi.inverse() * phi).is_identity() # optional - sage.libs.singular + sage: (phi.inverse() * phi).is_identity() # needs sage.libs.singular True Automorphisms of number fields as well as Galois fields are supported:: - sage: K. = CyclotomicField(7) # optional - sage.rings.number_field - sage: c = K.hom([1/zeta7]) # optional - sage.rings.number_field - sage: (c.inverse() * c).is_identity() # optional - sage.rings.number_field + sage: K. = CyclotomicField(7) # needs sage.rings.number_field + sage: c = K.hom([1/zeta7]) # needs sage.rings.number_field + sage: (c.inverse() * c).is_identity() # needs sage.rings.number_field True - sage: F. = GF(7^3) # optional - sage.rings.finite_rings - sage: f = F.hom(t^7, F) # optional - sage.rings.finite_rings - sage: (f.inverse() * f).is_identity() # optional - sage.rings.finite_rings + sage: F. = GF(7^3) # needs sage.rings.finite_rings + sage: f = F.hom(t^7, F) # needs sage.rings.finite_rings + sage: (f.inverse() * f).is_identity() # needs sage.rings.finite_rings True An isomorphism between the algebraic torus and the circle over a number field:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: A. = K['z,w'].quotient('z*w - 1') # optional - sage.rings.number_field - sage: B. = K['x,y'].quotient('x^2 + y^2 - 1') # optional - sage.rings.number_field - sage: f = A.hom([x + i*y, x - i*y], B) # optional - sage.rings.number_field - sage: g = f.inverse() # optional - sage.rings.number_field - sage: g.morphism_from_cover().im_gens() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: A. = K['z,w'].quotient('z*w - 1') + sage: B. = K['x,y'].quotient('x^2 + y^2 - 1') + sage: f = A.hom([x + i*y, x - i*y], B) + sage: g = f.inverse() + sage: g.morphism_from_cover().im_gens() [1/2*z + 1/2*w, (-1/2*i)*z + (1/2*i)*w] - sage: all(g(f(z)) == z for z in A.gens()) # optional - sage.rings.number_field + sage: all(g(f(z)) == z for z in A.gens()) True TESTS: Morphisms involving quotient rings:: + sage: # needs sage.libs.singular sage: R. = QQ[] - sage: S. = QQ['s,u,t'].quotient('u-t^2') # optional - sage.libs.singular - sage: f = R.hom([s, -t], S) # optional - sage.libs.singular - sage: (f.inverse() * f).is_identity() # optional - sage.libs.singular + sage: S. = QQ['s,u,t'].quotient('u-t^2') + sage: f = R.hom([s, -t], S) + sage: (f.inverse() * f).is_identity() True - sage: Q. = R.quotient(x - y^2) # optional - sage.libs.singular - sage: g = Q.hom([v, -w], Q) # optional - sage.libs.singular - sage: g.inverse()(g(v)) == v and g.inverse()(g(w)) == w # optional - sage.libs.singular + sage: Q. = R.quotient(x - y^2) + sage: g = Q.hom([v, -w], Q) + sage: g.inverse()(g(v)) == v and g.inverse()(g(w)) == w True sage: S. = QQ[] - sage: h = Q.hom([z^2, -z], S) # optional - sage.libs.singular - sage: h.inverse()(h(v)) == v and h.inverse()(h(w)) == w # optional - sage.libs.singular + sage: h = Q.hom([z^2, -z], S) + sage: h.inverse()(h(v)) == v and h.inverse()(h(w)) == w True Morphisms between number fields and quotient rings:: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: f = K.hom([-sqrt2], K.polynomial_quotient_ring()) # optional - sage.rings.number_field - sage: (f.inverse() * f).is_identity() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: f = K.hom([-sqrt2], K.polynomial_quotient_ring()) + sage: (f.inverse() * f).is_identity() True - sage: g = K.polynomial_quotient_ring().hom([-sqrt2], K) # optional - sage.rings.number_field - sage: (g.inverse() * g).is_identity() # optional - sage.rings.number_field + sage: g = K.polynomial_quotient_ring().hom([-sqrt2], K) + sage: (g.inverse() * g).is_identity() True Morphisms involving Galois fields:: - sage: A. = GF(7^3) # optional - sage.rings.finite_rings - sage: R = A.polynomial_ring().quotient(A.polynomial()) # optional - sage.rings.finite_rings - sage: g = A.hom(R.gens(), R) # optional - sage.rings.finite_rings - sage: (g.inverse() * g).is_identity() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: A. = GF(7^3) + sage: R = A.polynomial_ring().quotient(A.polynomial()) + sage: g = A.hom(R.gens(), R) + sage: (g.inverse() * g).is_identity() True - sage: B., f = A.extension(3, map=True) # optional - sage.rings.finite_rings - sage: f.inverse() # optional - sage.rings.finite_rings + sage: B., f = A.extension(3, map=True) + sage: f.inverse() Traceback (most recent call last): ... ZeroDivisionError: ring homomorphism not surjective - sage: B., f = A.extension(1, map=True) # optional - sage.rings.finite_rings - sage: f.inverse() # optional - sage.rings.finite_rings + sage: B., f = A.extension(1, map=True) + sage: f.inverse() Ring morphism: From: Finite Field in T of size 7^3 To: Finite Field in t of size 7^3 @@ -1508,9 +1533,10 @@ cdef class RingHomomorphism(RingMap): Non-injective homomorphisms:: + sage: # needs sage.libs.singular sage: R. = QQ[] sage: S. = QQ[] - sage: S.hom([x, y, 0], R).inverse() # optional - sage.libs.singular + sage: S.hom([x, y, 0], R).inverse() Traceback (most recent call last): ... ZeroDivisionError: ring homomorphism not injective @@ -1519,42 +1545,42 @@ cdef class RingHomomorphism(RingMap): Traceback (most recent call last): ... ZeroDivisionError: ring homomorphism not injective - sage: Q. = R.quotient([x^5, y^4]) # optional - sage.libs.singular - sage: R.hom([u, v], Q).inverse() # optional - sage.libs.singular + sage: Q. = R.quotient([x^5, y^4]) + sage: R.hom([u, v], Q).inverse() Traceback (most recent call last): ... ZeroDivisionError: ring homomorphism not injective - sage: Q.cover().inverse() # optional - sage.libs.singular + sage: Q.cover().inverse() Traceback (most recent call last): ... ZeroDivisionError: ring homomorphism not injective Univariate quotient rings:: - sage: R. = QQ['t'].quotient('t^5') + sage: R. = QQ['t'].quotient('t^5') # needs sage.libs.pari sage: f = R.hom([2*t], R) - sage: (f.inverse() * f).is_identity() + sage: (f.inverse() * f).is_identity() # needs sage.libs.singular True A homomorphism over ``QQbar``:: - sage: R. = QQbar[] # optional - sage.rings.number_field - sage: f = R.hom([x + QQbar(I)*y^2, -y], R) # optional - sage.rings.number_field - sage: (f.inverse() * f).is_identity() # optional - sage.rings.number_field + sage: R. = QQbar[] # needs sage.rings.number_field + sage: f = R.hom([x + QQbar(I)*y^2, -y], R) # needs sage.rings.number_field + sage: (f.inverse() * f).is_identity() # needs sage.rings.number_field True Check that results are cached:: - sage: R. = GF(823)[] # optional - sage.rings.finite_rings - sage: f = R.hom([x, y+x^2], R) # optional - sage.rings.finite_rings - sage: f.inverse() is f.inverse() # optional - sage.rings.finite_rings + sage: R. = GF(823)[] + sage: f = R.hom([x, y+x^2], R) + sage: f.inverse() is f.inverse() # needs sage.rings.finite_rings True Some subclasses of ring homomorphisms are not supported:: sage: from sage.rings.morphism import FrobeniusEndomorphism_generic - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: FrobeniusEndomorphism_generic(K).inverse() # optional - sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: FrobeniusEndomorphism_generic(K).inverse() Traceback (most recent call last): ... NotImplementedError @@ -1581,11 +1607,11 @@ cdef class RingHomomorphism(RingMap): sage: R. = QQ[] sage: f = R.hom([x + 123*y^2, y], R) - sage: f._graph_ideal()[0].groebner_basis.is_in_cache() # optional - sage.libs.singular + sage: f._graph_ideal()[0].groebner_basis.is_in_cache() False - sage: f.is_injective() # optional - sage.libs.singular + sage: f.is_injective() # needs sage.libs.singular True - sage: f._graph_ideal()[0].groebner_basis.is_in_cache() # optional - sage.libs.singular + sage: f._graph_ideal()[0].groebner_basis.is_in_cache() # needs sage.libs.singular True """ if not self.is_injective(): @@ -1605,9 +1631,9 @@ cdef class RingHomomorphism(RingMap): EXAMPLES:: - sage: R. = GF(17)[] # optional - sage.rings.finite_rings - sage: f = R.hom([3*x, y + x^2 + x^3], R) # optional - sage.rings.finite_rings - sage: (f * ~f).is_identity() # optional - sage.rings.finite_rings + sage: R. = GF(17)[] + sage: f = R.hom([3*x, y + x^2 + x^3], R) + sage: (f * ~f).is_identity() # needs sage.rings.finite_rings True """ return self.inverse() @@ -1619,10 +1645,10 @@ cdef class RingHomomorphism(RingMap): EXAMPLES:: sage: R. = QQ[] - sage: R.hom([y*z, x*z, x*y], R).is_surjective() # optional - sage.libs.singular + sage: R.hom([y*z, x*z, x*y], R).is_surjective() # needs sage.libs.singular False - sage: Q. = R.quotient(x*y*z - 1) # optional - sage.libs.singular - sage: R.hom([y*z, x*z, x*y], Q).is_surjective() # optional - sage.libs.singular + sage: Q. = R.quotient(x*y*z - 1) # needs sage.libs.singular + sage: R.hom([y*z, x*z, x*y], Q).is_surjective() # needs sage.libs.singular True ALGORITHM: @@ -1643,10 +1669,10 @@ cdef class RingHomomorphism(RingMap): EXAMPLES:: sage: R. = QQ[] - sage: R.hom([y*z, x*z, x*y], R).is_invertible() # optional - sage.libs.singular + sage: R.hom([y*z, x*z, x*y], R).is_invertible() # needs sage.libs.singular False - sage: Q. = R.quotient(x*y*z - 1) # optional - sage.libs.singular - sage: Q.hom([y*z, x*z, x*y], Q).is_invertible() # optional - sage.libs.singular + sage: Q. = R.quotient(x*y*z - 1) # needs sage.libs.singular + sage: Q.hom([y*z, x*z, x*y], Q).is_invertible() # needs sage.libs.singular True ALGORITHM: @@ -1788,12 +1814,12 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): Here's another example where the domain isn't free:: - sage: S. = R.quotient(x - y) # optional - sage.libs.singular - sage: phi = S.hom([xx + 1, xx + 1]) # optional - sage.libs.singular + sage: S. = R.quotient(x - y) # needs sage.libs.singular + sage: phi = S.hom([xx + 1, xx + 1]) # needs sage.libs.singular Note that one has to specify valid images:: - sage: phi = S.hom([xx + 1, xx - 1]) # optional - sage.libs.singular + sage: phi = S.hom([xx + 1, xx - 1]) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: relations do not all (canonically) map to 0 @@ -1801,12 +1827,13 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): You can give a map of the base ring:: + sage: # needs sage.rings.number_field sage: Zx. = ZZ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: cc = K.hom([-i]) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: z = 1 + i*t + (3+4*i)*t^2 # optional - sage.rings.number_field - sage: z._im_gens_(R, [t^2], base_map=cc) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: cc = K.hom([-i]) + sage: R. = K[] + sage: z = 1 + i*t + (3+4*i)*t^2 + sage: z._im_gens_(R, [t^2], base_map=cc) (-4*i + 3)*t^4 - i*t^2 + 1 The base map's codomain is extended to the whole codomain:: @@ -1826,8 +1853,8 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): speed up creation of a homomorphism:: sage: R. = QQ[] - sage: S. = R.quotient(x - y) # optional - sage.libs.singular - sage: phi = S.hom([xx + 1, xx - 1], check=False) # optional - sage.libs.singular + sage: S. = R.quotient(x - y) # needs sage.libs.singular + sage: phi = S.hom([xx + 1, xx - 1], check=False) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: relations do not all (canonically) map to 0 @@ -1889,21 +1916,22 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: cc = K.hom([-i]) # optional - sage.rings.number_field - sage: S. = K[] # optional - sage.rings.number_field - sage: phi = S.hom([y^2], base_map=cc) # optional - sage.rings.number_field - sage: phi # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: cc = K.hom([-i]) + sage: S. = K[] + sage: phi = S.hom([y^2], base_map=cc) + sage: phi Ring endomorphism of Univariate Polynomial Ring in y over Number Field in i with defining polynomial x^2 + 1 Defn: y |--> y^2 with map of base ring - sage: phi(y) # optional - sage.rings.number_field + sage: phi(y) y^2 - sage: phi(i*y) # optional - sage.rings.number_field + sage: phi(i*y) -i*y^2 - sage: phi.base_map() # optional - sage.rings.number_field + sage: phi.base_map() Composite map: From: Number Field in i with defining polynomial x^2 + 1 To: Univariate Polynomial Ring in y over Number Field in i @@ -1965,52 +1993,53 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism): A single variate quotient over `\QQ`:: + sage: # needs sage.libs.pari sage: R. = QQ[] - sage: Q. = R.quotient(x^2 + x + 1) # optional - sage.libs.pari - sage: f1 = R.hom([a]) # optional - sage.libs.pari - sage: f2 = R.hom([a + a^2 + a + 1]) # optional - sage.libs.pari - sage: f1 == f2 # optional - sage.libs.pari + sage: Q. = R.quotient(x^2 + x + 1) + sage: f1 = R.hom([a]) + sage: f2 = R.hom([a + a^2 + a + 1]) + sage: f1 == f2 True - sage: f1 == R.hom([a^2]) # optional - sage.libs.pari + sage: f1 == R.hom([a^2]) False - sage: f1(x^3 + x) # optional - sage.libs.pari + sage: f1(x^3 + x) a + 1 - sage: f2(x^3 + x) # optional - sage.libs.pari + sage: f2(x^3 + x) a + 1 TESTS:: - sage: loads(dumps(f2)) == f2 # optional - sage.libs.pari + sage: loads(dumps(f2)) == f2 # needs sage.libs.pari True :: - sage: R. = QQ[]; f = R.hom([x, x + y]); g = R.hom([y, x]) # optional - sage.libs.pari - sage: f == g # indirect doctest # optional - sage.libs.pari + sage: R. = QQ[]; f = R.hom([x, x + y]); g = R.hom([y, x]) + sage: f == g # indirect doctest False EXAMPLES: A multivariate quotient over a finite field:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) # optional - sage.rings.finite_rings - sage: f1 = R.hom([a, b]) # optional - sage.rings.finite_rings - sage: f2 = R.hom([a + a^2 + a + 1, b + b^2 + b + 1]) # optional - sage.rings.finite_rings - sage: f1 == f2 # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) + sage: f1 = R.hom([a, b]) + sage: f2 = R.hom([a + a^2 + a + 1, b + b^2 + b + 1]) + sage: f1 == f2 True - sage: f1 == R.hom([b, a]) # optional - sage.rings.finite_rings + sage: f1 == R.hom([b, a]) False - sage: x^3 + x + y^2 # optional - sage.rings.finite_rings + sage: x^3 + x + y^2 x^3 + y^2 + x - sage: f1(x^3 + x + y^2) # optional - sage.rings.finite_rings + sage: f1(x^3 + x + y^2) a - b - sage: f2(x^3 + x + y^2) # optional - sage.rings.finite_rings + sage: f2(x^3 + x + y^2) a - b TESTS:: - sage: loads(dumps(f2)) == f2 # optional - sage.rings.finite_rings + sage: loads(dumps(f2)) == f2 # needs sage.rings.finite_rings True This was fixed in :trac:`24277`:: @@ -2119,12 +2148,13 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): Similarly, we can construct the induced homomorphism on a matrix ring over our polynomial rings:: - sage: MR = MatrixSpace(R, 2, 2) # optional - sage.modules - sage: MS = MatrixSpace(S, 2, 2) # optional - sage.modules - sage: M = MR([x^2 + 1/7*x*y - y^2, -1/2*y^2 + 2*y + 1/6, # optional - sage.modules + sage: # needs sage.modules + sage: MR = MatrixSpace(R, 2, 2) + sage: MS = MatrixSpace(S, 2, 2) + sage: M = MR([x^2 + 1/7*x*y - y^2, -1/2*y^2 + 2*y + 1/6, ....: 4*x^2 - 14*x, 1/2*y^2 + 13/4*x - 2/11*y]) - sage: Mf = MR.hom(f, MS) # optional - sage.modules - sage: Mf # optional - sage.modules + sage: Mf = MR.hom(f, MS) + sage: Mf Ring morphism: From: Full MatrixSpace of 2 by 2 dense matrices over Multivariate Polynomial Ring in x, y over Rational Field @@ -2136,19 +2166,20 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): To: Univariate Polynomial Ring in z over Rational Field Defn: x |--> 2*z y |--> 3*z - sage: Mf(M) # optional - sage.modules + sage: Mf(M) [ -29/7*z^2 -9/2*z^2 + 6*z + 1/6] [ 16*z^2 - 28*z 9/2*z^2 + 131/22*z] The construction of induced homomorphisms is recursive, and so we have:: - sage: MPR = MatrixSpace(PR, 2) # optional - sage.modules - sage: MPS = MatrixSpace(PS, 2) # optional - sage.modules - sage: M = MPR([(-x + y)*t^2 + 58*t - 3*x^2 + x*y, # optional - sage.modules + sage: # needs sage.modules + sage: MPR = MatrixSpace(PR, 2) + sage: MPS = MatrixSpace(PS, 2) + sage: M = MPR([(-x + y)*t^2 + 58*t - 3*x^2 + x*y, ....: (- 1/7*x*y - 1/40*x)*t^2 + (5*x^2 + y^2)*t + 2*y, ....: (- 1/3*y + 1)*t^2 + 1/3*x*y + y^2 + 5/2*y + 1/4, ....: (x + 6*y + 1)*t^2]) - sage: MPf = MPR.hom(f, MPS); MPf # optional - sage.modules + sage: MPf = MPR.hom(f, MPS); MPf Ring morphism: From: Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in t over Multivariate Polynomial Ring in x, y over Rational Field @@ -2166,7 +2197,7 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): To: Univariate Polynomial Ring in z over Rational Field Defn: x |--> 2*z y |--> 3*z - sage: MPf(M) # optional - sage.modules + sage: MPf(M) [ z*t^2 + 58*t - 6*z^2 (-6/7*z^2 - 1/20*z)*t^2 + 29*z^2*t + 6*z] [ (-z + 1)*t^2 + 11*z^2 + 15/2*z + 1/4 (20*z + 1)*t^2] """ @@ -2179,9 +2210,9 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): sage: from sage.rings.morphism import RingHomomorphism_from_base sage: R. = ZZ[] sage: f = R.hom([2*x], R) - sage: P = MatrixSpace(R, 2).Hom(MatrixSpace(R, 2)) # optional - sage.modules - sage: g = RingHomomorphism_from_base(P, f) # optional - sage.modules - sage: g # optional - sage.modules + sage: P = MatrixSpace(R, 2).Hom(MatrixSpace(R, 2)) # needs sage.modules + sage: g = RingHomomorphism_from_base(P, f) # needs sage.modules + sage: g # needs sage.modules Ring endomorphism of Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring Defn: Induced from base ring by @@ -2192,8 +2223,8 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): codomain are constructed in a compatible way. So, the following results in an error:: - sage: P = MatrixSpace(R, 2).Hom(R['t']) # optional - sage.modules - sage: g = RingHomomorphism_from_base(P, f) # optional - sage.modules + sage: P = MatrixSpace(R, 2).Hom(R['t']) # needs sage.modules + sage: g = RingHomomorphism_from_base(P, f) # needs sage.modules Traceback (most recent call last): ... ValueError: domain (Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring) @@ -2215,13 +2246,14 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): EXAMPLES:: + sage: # needs sage.modules sage: R. = QQ[] sage: S. = QQ[] sage: f = R.hom([2*z, 3*z], S) - sage: MR = MatrixSpace(R, 2) # optional - sage.modules - sage: MS = MatrixSpace(S, 2) # optional - sage.modules - sage: g = MR.hom(f, MS) # optional - sage.modules - sage: g.underlying_map() == f # optional - sage.modules + sage: MR = MatrixSpace(R, 2) + sage: MS = MatrixSpace(S, 2) + sage: g = MR.hom(f, MS) + sage: g.underlying_map() == f True """ return self._underlying @@ -2294,20 +2326,21 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): A multivariate polynomial ring over a single variate quotient over `\QQ`:: + sage: # needs sage.libs.pari sage.libs.singular sage.modules sage: R. = QQ[] - sage: Q. = R.quotient(x^2 + x + 1) # optional - sage.libs.pari sage.modules - sage: f1 = R.hom([a]) # optional - sage.libs.pari sage.libs.singular sage.modules - sage: f2 = R.hom([a + a^2 + a + 1]) # optional - sage.libs.pari sage.libs.singular sage.modules - sage: PR. = R[] # optional - sage.libs.pari sage.libs.singular sage.modules - sage: PQ = Q['s','t'] # optional - sage.libs.pari sage.libs.singular sage.modules - sage: f1P = PR.hom(f1,PQ) # optional - sage.libs.pari sage.libs.singular sage.modules - sage: f2P = PR.hom(f2,PQ) # optional - sage.libs.pari sage.libs.singular sage.modules - sage: f1P == f2P # optional - sage.libs.pari sage.libs.singular sage.modules + sage: Q. = R.quotient(x^2 + x + 1) + sage: f1 = R.hom([a]) + sage: f2 = R.hom([a + a^2 + a + 1]) + sage: PR. = R[] + sage: PQ = Q['s','t'] + sage: f1P = PR.hom(f1,PQ) + sage: f2P = PR.hom(f2,PQ) + sage: f1P == f2P True TESTS:: - sage: f1P == loads(dumps(f1P)) # optional - sage.libs.pari sage.libs.singular sage.modules + sage: f1P == loads(dumps(f1P)) # needs sage.libs.pari sage.libs.singular sage.modules True sage: R. = QQ[]; f = R.hom([x, x + y]); g = R.hom([y, x]) @@ -2320,20 +2353,21 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): A matrix ring over a multivariate quotient over a finite field:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) # optional - sage.rings.finite_rings - sage: f1 = R.hom([a, b]) # optional - sage.rings.finite_rings - sage: f2 = R.hom([a + a^2 + a + 1, b + b^2 + b + 1]) # optional - sage.rings.finite_rings - sage: MR = MatrixSpace(R, 2) # optional - sage.rings.finite_rings sage.modules - sage: MQ = MatrixSpace(Q, 2) # optional - sage.rings.finite_rings sage.modules - sage: f1M = MR.hom(f1, MQ) # optional - sage.rings.finite_rings sage.modules - sage: f2M = MR.hom(f2, MQ) # optional - sage.rings.finite_rings sage.modules - sage: f1M == f2M # optional - sage.rings.finite_rings sage.modules + sage: # needs sage.modules + sage: R. = GF(7)[] + sage: Q. = R.quotient([x^2 + x + 1, y^2 + y + 1]) + sage: f1 = R.hom([a, b]) + sage: f2 = R.hom([a + a^2 + a + 1, b + b^2 + b + 1]) + sage: MR = MatrixSpace(R, 2) + sage: MQ = MatrixSpace(Q, 2) + sage: f1M = MR.hom(f1, MQ) + sage: f2M = MR.hom(f2, MQ) + sage: f1M == f2M True TESTS:: - sage: f1M == loads(dumps(f1M)) # optional - sage.rings.finite_rings sage.modules + sage: f1M == loads(dumps(f1M)) # needs sage.modules True """ if not isinstance(other, RingHomomorphism_from_base): @@ -2354,9 +2388,9 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): sage: R1. = ZZ[] sage: f = R1.hom([x + y, x - y]) - sage: R2 = MatrixSpace(FractionField(R1)['t'], 2) # optional - sage.modules - sage: g = R2.hom(f, R2) # optional - sage.modules - sage: g #indirect doctest # optional - sage.modules + sage: R2 = MatrixSpace(FractionField(R1)['t'], 2) # needs sage.modules + sage: g = R2.hom(f, R2) # needs sage.modules + sage: g # indirect doctest # needs sage.modules Ring endomorphism of Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in t over Fraction Field of Multivariate Polynomial Ring in x, y over Integer Ring Defn: Induced from base ring by @@ -2404,11 +2438,11 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): sage: R. = QQ[] sage: S. = QQ[] - sage: f = R.hom([a + b, a - b], S) # optional - sage.libs.singular + sage: f = R.hom([a + b, a - b], S) sage: PR. = R[] sage: PS = S['t'] - sage: Pf = PR.hom(f, PS) # optional - sage.libs.singular - sage: Pf.inverse() # optional - sage.libs.singular + sage: Pf = PR.hom(f, PS) + sage: Pf.inverse() # needs sage.libs.singular Ring morphism: From: Univariate Polynomial Ring in t over Multivariate Polynomial Ring in a, b over Rational Field @@ -2420,7 +2454,7 @@ cdef class RingHomomorphism_from_base(RingHomomorphism): To: Multivariate Polynomial Ring in x, y over Rational Field Defn: a |--> 1/2*x + 1/2*y b |--> 1/2*x - 1/2*y - sage: Pf.inverse()(Pf(x*t^2 + y*t)) # optional - sage.libs.singular + sage: Pf.inverse()(Pf(x*t^2 + y*t)) # needs sage.libs.singular x*t^2 + y*t """ return self.parent().reversed()(self._underlying.inverse()) @@ -2434,8 +2468,8 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): sage: S. = QQ[] sage: f = S.hom([x^2]) - sage: g = f.extend_to_fraction_field() # optional - sage.libs.singular - sage: type(g) # optional - sage.libs.singular + sage: g = f.extend_to_fraction_field() # needs sage.libs.singular + sage: type(g) # needs sage.libs.singular """ def __init__(self, parent, morphism): @@ -2444,11 +2478,12 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): TESTS:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: A. = ZZ.extension(x^2 - 2) # optional - sage.rings.number_field - sage: f = A.coerce_map_from(ZZ) # optional - sage.rings.number_field - sage: g = f.extend_to_fraction_field() # indirect doctest # optional - sage.rings.number_field - sage: g # optional - sage.rings.number_field + sage: A. = ZZ.extension(x^2 - 2) + sage: f = A.coerce_map_from(ZZ) + sage: g = f.extend_to_fraction_field() # indirect doctest + sage: g Ring morphism: From: Rational Field To: Number Field in a with defining polynomial x^2 - 2 @@ -2463,11 +2498,11 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): EXAMPLES:: sage: S. = QQ[] - sage: f = S.hom([x^2]).extend_to_fraction_field() # optional - sage.libs.singular - sage: f # optional - sage.libs.singular + sage: f = S.hom([x^2]).extend_to_fraction_field() # needs sage.libs.singular + sage: f # needs sage.libs.singular Ring endomorphism of Fraction Field of Univariate Polynomial Ring in x over Rational Field Defn: x |--> x^2 - sage: f._repr_defn() # optional - sage.libs.singular + sage: f._repr_defn() # needs sage.libs.singular 'x |--> x^2' """ return self._morphism._repr_defn() @@ -2483,10 +2518,10 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): EXAMPLES:: sage: S. = QQ[] - sage: f = S.hom([x + 1]).extend_to_fraction_field() # optional - sage.libs.singular - sage: f(1/x) # optional - sage.libs.singular + sage: f = S.hom([x + 1]).extend_to_fraction_field() # needs sage.libs.singular + sage: f(1/x) # needs sage.libs.singular 1/(x + 1) - sage: f(1/(x-1)) # optional - sage.libs.singular + sage: f(1/(x-1)) # needs sage.libs.singular 1/x """ return self._morphism(x.numerator()) / self._morphism(x.denominator()) @@ -2497,13 +2532,14 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): TESTS:: + sage: # needs sage.libs.singular sage: S. = QQ[] - sage: f = S.hom([x + 1]).extend_to_fraction_field() # optional - sage.libs.singular + sage: f = S.hom([x + 1]).extend_to_fraction_field() - sage: g = copy(f) # indirect doctest # optional - sage.libs.singular - sage: f == g # optional - sage.libs.singular + sage: g = copy(f) # indirect doctest # needs sage.libs.singular + sage: f == g # needs sage.libs.singular True - sage: f is g # optional - sage.libs.singular + sage: f is g # needs sage.libs.singular False """ self._morphism = _slots['_morphism'] @@ -2516,8 +2552,8 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): TESTS:: sage: S. = QQ[] - sage: f = S.hom([x + 1]).extend_to_fraction_field() # optional - sage.libs.singular - sage: loads(dumps(f)) == f # optional - sage.libs.singular + sage: f = S.hom([x + 1]).extend_to_fraction_field() # needs sage.libs.singular + sage: loads(dumps(f)) == f # needs sage.libs.singular True """ slots = RingHomomorphism._extra_slots(self) @@ -2533,8 +2569,8 @@ cdef class RingHomomorphism_from_fraction_field(RingHomomorphism): sage: S. = QQ[] sage: f = S.hom([2*x - 1]) - sage: g = f.extend_to_fraction_field() # optional - sage.libs.singular - sage: g.inverse() # optional - sage.libs.singular + sage: g = f.extend_to_fraction_field() # needs sage.libs.singular + sage: g.inverse() # needs sage.libs.singular Ring endomorphism of Fraction Field of Univariate Polynomial Ring in x over Rational Field Defn: x |--> 1/2*x + 1/2 @@ -2549,14 +2585,14 @@ cdef class RingHomomorphism_cover(RingHomomorphism): EXAMPLES:: sage: R. = PolynomialRing(QQ, 2) - sage: S. = R.quo(x^2 + y^2) # optional - sage.libs.singular - sage: phi = S.cover(); phi # optional - sage.libs.singular + sage: S. = R.quo(x^2 + y^2) # needs sage.libs.singular + sage: phi = S.cover(); phi # needs sage.libs.singular Ring morphism: From: Multivariate Polynomial Ring in x, y over Rational Field To: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) Defn: Natural quotient map - sage: phi(x + y) # optional - sage.libs.singular + sage: phi(x + y) # needs sage.libs.singular a + b """ def __init__(self, parent): @@ -2641,12 +2677,13 @@ cdef class RingHomomorphism_cover(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) - sage: S. = R.quo(x^2 + y^2) # optional - sage.libs.singular - sage: phi = S.cover() # optional - sage.libs.singular - sage: phi == loads(dumps(phi)) # optional - sage.libs.singular + sage: S. = R.quo(x^2 + y^2) + sage: phi = S.cover() + sage: phi == loads(dumps(phi)) True - sage: phi == R.quo(x^2 + y^3).cover() # optional - sage.libs.singular + sage: phi == R.quo(x^2 + y^3).cover() False """ if not isinstance(other, RingHomomorphism_cover): @@ -2661,14 +2698,15 @@ cdef class RingHomomorphism_cover(RingHomomorphism): TESTS:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) - sage: S. = R.quo(x^2 + y^2) # optional - sage.libs.singular - sage: phi = S.cover() # optional - sage.libs.singular - sage: type(phi) # optional - sage.libs.singular + sage: S. = R.quo(x^2 + y^2) + sage: phi = S.cover() + sage: type(phi) - sage: hash(phi) == hash(phi) # optional - sage.libs.singular + sage: hash(phi) == hash(phi) True - sage: {phi: 1}[phi] # optional - sage.libs.singular + sage: {phi: 1}[phi] 1 """ return hash((self.domain(), self.codomain())) @@ -2683,12 +2721,13 @@ cdef class RingHomomorphism_cover(RingHomomorphism): EXAMPLES:: - sage: R. = QQ['x,y'].quotient('x^2 * y^2') # optional - sage.libs.singular - sage: R.cover().inverse_image(R.ideal(x^3, y^3 + 1)) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: R. = QQ['x,y'].quotient('x^2 * y^2') + sage: R.cover().inverse_image(R.ideal(x^3, y^3 + 1)) Ideal (x^2*y^2, x^3, y^3 + 1) of Multivariate Polynomial Ring in x, y over Rational Field - sage: S. = QQbar['u,v'].quotient('u^4 - 1') # optional - sage.libs.singular - sage: S.cover().inverse_image(S.ideal(u^2 - 1)) # optional - sage.libs.singular + sage: S. = QQbar['u,v'].quotient('u^4 - 1') + sage: S.cover().inverse_image(S.ideal(u^2 - 1)) Ideal (u^4 - 1, u^2 - 1) of Multivariate Polynomial Ring in u, v over Algebraic Field """ @@ -2703,8 +2742,8 @@ cdef class RingHomomorphism_cover(RingHomomorphism): EXAMPLES:: - sage: Q. = QQ['x,y'].quotient('x + y') # optional - sage.libs.singular - sage: Q.cover().inverse_image(u) # optional - sage.libs.singular + sage: Q. = QQ['x,y'].quotient('x + y') # needs sage.libs.singular + sage: Q.cover().inverse_image(u) # needs sage.libs.singular -y """ return b.lift() @@ -2732,24 +2771,25 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 3) - sage: S. = R.quo(x^3 + y^3 + z^3) # optional - sage.libs.singular - sage: phi = S.hom([b, c, a]); phi # optional - sage.libs.singular + sage: S. = R.quo(x^3 + y^3 + z^3) + sage: phi = S.hom([b, c, a]); phi Ring endomorphism of Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (x^3 + y^3 + z^3) Defn: a |--> b b |--> c c |--> a - sage: phi(a + b + c) # optional - sage.libs.singular + sage: phi(a + b + c) a + b + c - sage: loads(dumps(phi)) == phi # optional - sage.libs.singular + sage: loads(dumps(phi)) == phi True Validity of the homomorphism is determined, when possible, and a ``TypeError`` is raised if there is no homomorphism sending the generators to the given images:: - sage: S.hom([b^2, c^2, a^2]) # optional - sage.libs.singular + sage: S.hom([b^2, c^2, a^2]) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: relations do not all (canonically) map to 0 @@ -2761,7 +2801,7 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo([x^2,y^2]); S.hom([yy,xx]) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo([x^2,y^2]); S.hom([yy,xx]) # needs sage.libs.singular Ring endomorphism of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y^2) Defn: xx |--> yy @@ -2788,22 +2828,23 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 3) - sage: S. = R.quo(x^3 + y^3 + z^3) # optional - sage.libs.singular - sage: phi = S.hom([b, c, a]); phi # optional - sage.libs.singular + sage: S. = R.quo(x^3 + y^3 + z^3) + sage: phi = S.hom([b, c, a]); phi Ring endomorphism of Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (x^3 + y^3 + z^3) Defn: a |--> b b |--> c c |--> a - sage: phi(a + b + c) # optional - sage.libs.singular + sage: phi(a + b + c) a + b + c - sage: psi = copy(phi) # indirect doctest # optional - sage.libs.singular - sage: psi == phi # optional - sage.libs.singular + sage: psi = copy(phi) # indirect doctest + sage: psi == phi True - sage: psi is phi # optional - sage.libs.singular + sage: psi is phi False - sage: psi(a) == phi(a) # optional - sage.libs.singular + sage: psi(a) == phi(a) True """ @@ -2816,22 +2857,23 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 3) - sage: S. = R.quo(x^3 + y^3 + z^3) # optional - sage.libs.singular - sage: phi = S.hom([b, c, a]); phi # optional - sage.libs.singular + sage: S. = R.quo(x^3 + y^3 + z^3) + sage: phi = S.hom([b, c, a]); phi Ring endomorphism of Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (x^3 + y^3 + z^3) Defn: a |--> b b |--> c c |--> a - sage: phi(a + b + c) # optional - sage.libs.singular + sage: phi(a + b + c) a + b + c - sage: psi = copy(phi) # indirect doctest # optional - sage.libs.singular - sage: psi == phi # optional - sage.libs.singular + sage: psi = copy(phi) # indirect doctest + sage: psi == phi True - sage: psi is phi # optional - sage.libs.singular + sage: psi is phi False - sage: psi(a) == phi(a) # optional - sage.libs.singular + sage: psi(a) == phi(a) True """ slots = RingHomomorphism._extra_slots(self) @@ -2845,8 +2887,8 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo([x^2, y^2]); f = S.hom([yy,xx]) # optional - sage.libs.singular - sage: f._phi() # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo([x^2, y^2]); f = S.hom([yy,xx]) # needs sage.libs.singular + sage: f._phi() # needs sage.libs.singular Ring morphism: From: Multivariate Polynomial Ring in x, y over Rational Field To: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y^2) @@ -2862,8 +2904,8 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo([x^2, y^2]) # optional - sage.libs.singular - sage: S.hom([yy,xx]).morphism_from_cover() # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo([x^2, y^2]) # needs sage.libs.singular + sage: S.hom([yy,xx]).morphism_from_cover() # needs sage.libs.singular Ring morphism: From: Multivariate Polynomial Ring in x, y over Rational Field To: Quotient of Multivariate Polynomial Ring in x, y @@ -2879,14 +2921,15 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: R. = PolynomialRing(GF(19), 3) # optional - sage.rings.finite_rings - sage: S. = R.quo(x^3 + y^3 + z^3) # optional - sage.rings.finite_rings - sage: phi = S.hom([b, c, a]) # optional - sage.rings.finite_rings - sage: psi = S.hom([c, b, a]) # optional - sage.rings.finite_rings - sage: f = S.hom([b, c, a + a^3 + b^3 + c^3]) # optional - sage.rings.finite_rings - sage: phi == psi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = PolynomialRing(GF(19), 3) + sage: S. = R.quo(x^3 + y^3 + z^3) + sage: phi = S.hom([b, c, a]) + sage: psi = S.hom([c, b, a]) + sage: f = S.hom([b, c, a + a^3 + b^3 + c^3]) + sage: phi == psi False - sage: phi == f # optional - sage.rings.finite_rings + sage: phi == f True """ if not isinstance(other, RingHomomorphism_from_quotient): @@ -2903,14 +2946,15 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: R. = PolynomialRing(GF(19), 3) # optional - sage.rings.finite_rings - sage: S. = R.quo(x^3 + y^3 + z^3) # optional - sage.rings.finite_rings - sage: phi = S.hom([b, c, a]) # optional - sage.rings.finite_rings - sage: type(phi) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = PolynomialRing(GF(19), 3) + sage: S. = R.quo(x^3 + y^3 + z^3) + sage: phi = S.hom([b, c, a]) + sage: type(phi) - sage: hash(phi) == hash(phi) # optional - sage.rings.finite_rings + sage: hash(phi) == hash(phi) True - sage: {phi: 1}[phi] # optional - sage.rings.finite_rings + sage: {phi: 1}[phi] 1 """ return hash(self.phi) @@ -2921,9 +2965,9 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo([x^2,y^2]) # optional - sage.libs.singular - sage: f = S.hom([yy, xx]) # optional - sage.libs.singular - sage: print(f._repr_defn()) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo([x^2,y^2]) # needs sage.libs.singular + sage: f = S.hom([yy, xx]) # needs sage.libs.singular + sage: print(f._repr_defn()) # needs sage.libs.singular xx |--> yy yy |--> xx """ @@ -2938,8 +2982,8 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo([x^2, y^2]); f = S.hom([yy, xx]) # optional - sage.libs.singular - sage: f(3*x + (1/2)*y) # indirect doctest # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo([x^2, y^2]); f = S.hom([yy, xx]) # needs sage.libs.singular + sage: f(3*x + (1/2)*y) # indirect doctest # needs sage.libs.singular 1/2*xx + 3*yy """ return self.phi(self.lift(x)) @@ -2966,11 +3010,11 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): TESTS:: sage: from sage.rings.morphism import FrobeniusEndomorphism_generic - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: FrobeniusEndomorphism_generic(K) # optional - sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: FrobeniusEndomorphism_generic(K) Frobenius endomorphism x |--> x^5 of Power Series Ring in u over Finite Field of size 5 - sage: FrobeniusEndomorphism_generic(K, 2) # optional - sage.rings.finite_rings + sage: FrobeniusEndomorphism_generic(K, 2) Frobenius endomorphism x |--> x^(5^2) of Power Series Ring in u over Finite Field of size 5 """ @@ -2999,10 +3043,11 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): EXAMPLES:: - sage: K = Frac(GF(5)['T']) # optional - sage.rings.finite_rings - sage: phi = K.frobenius_endomorphism() # optional - sage.rings.finite_rings - sage: psi = copy(phi) # optional - sage.rings.finite_rings - sage: phi == psi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = Frac(GF(5)['T']) + sage: phi = K.frobenius_endomorphism() + sage: psi = copy(phi) + sage: phi == psi True """ self._p = _slots['_domain'].characteristic() @@ -3019,16 +3064,16 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): EXAMPLES:: - sage: K = Frac(GF(25)['T']) # optional - sage.rings.finite_rings - sage: phi = K.frobenius_endomorphism(2) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = Frac(GF(25)['T']) + sage: phi = K.frobenius_endomorphism(2) + sage: phi Frobenius endomorphism x |--> x^(5^2) of Fraction Field of Univariate Polynomial Ring in T over Finite Field in z2 of size 5^2 - - sage: psi = loads(dumps(phi)); psi # optional - sage.rings.finite_rings + sage: psi = loads(dumps(phi)); psi Frobenius endomorphism x |--> x^(5^2) of Fraction Field of Univariate Polynomial Ring in T over Finite Field in z2 of size 5^2 - sage: phi == psi # optional - sage.rings.finite_rings + sage: phi == psi True """ slots = RingHomomorphism._extra_slots(self) @@ -3041,12 +3086,12 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): EXAMPLES:: - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: Frob = K.frobenius_endomorphism(); Frob # optional - sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: Frob = K.frobenius_endomorphism(); Frob Frobenius endomorphism x |--> x^5 of Power Series Ring in u over Finite Field of size 5 - sage: Frob._repr_() # optional - sage.rings.finite_rings + sage: Frob._repr_() 'Frobenius endomorphism x |--> x^5 of Power Series Ring in u over Finite Field of size 5' """ @@ -3065,11 +3110,12 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): EXAMPLES:: - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: Frob = K.frobenius_endomorphism() # optional - sage.rings.finite_rings - sage: Frob._repr_short() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: Frob = K.frobenius_endomorphism() + sage: Frob._repr_short() 'Frob' - sage: (Frob^2)._repr_short() # optional - sage.rings.finite_rings + sage: (Frob^2)._repr_short() 'Frob^2' """ if self._power == 0: @@ -3086,9 +3132,9 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): EXAMPLES:: - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: Frob = K.frobenius_endomorphism(2) # optional - sage.rings.finite_rings - sage: Frob._latex_() # optional - sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: Frob = K.frobenius_endomorphism(2) + sage: Frob._latex_() '\\verb"Frob"^{2}' """ if self._power == 0: @@ -3103,11 +3149,12 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): """ TESTS:: - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: Frob = K.frobenius_endomorphism() # optional - sage.rings.finite_rings - sage: Frob(u) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: Frob = K.frobenius_endomorphism() + sage: Frob(u) u^5 - sage: (Frob^2)(1 + u) # optional - sage.rings.finite_rings + sage: (Frob^2)(1 + u) 1 + u^25 """ return x ** self._q @@ -3120,11 +3167,12 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): EXAMPLES:: - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: Frob = K.frobenius_endomorphism() # optional - sage.rings.finite_rings - sage: Frob.power() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: Frob = K.frobenius_endomorphism() + sage: Frob.power() 1 - sage: (Frob^9).power() # optional - sage.rings.finite_rings + sage: (Frob^9).power() 9 """ return self._power @@ -3135,11 +3183,11 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): EXAMPLES:: - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: Frob = K.frobenius_endomorphism(); Frob # optional - sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: Frob = K.frobenius_endomorphism(); Frob Frobenius endomorphism x |--> x^5 of Power Series Ring in u over Finite Field of size 5 - sage: Frob^2 # optional - sage.rings.finite_rings + sage: Frob^2 Frobenius endomorphism x |--> x^(5^2) of Power Series Ring in u over Finite Field of size 5 """ @@ -3151,14 +3199,15 @@ cdef class FrobeniusEndomorphism_generic(RingHomomorphism): EXAMPLES:: - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: f = K.frobenius_endomorphism(); f # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: f = K.frobenius_endomorphism(); f Frobenius endomorphism x |--> x^5 of Power Series Ring in u over Finite Field of size 5 - sage: g = K.frobenius_endomorphism(2); g # optional - sage.rings.finite_rings + sage: g = K.frobenius_endomorphism(2); g Frobenius endomorphism x |--> x^(5^2) of Power Series Ring in u over Finite Field of size 5 - sage: f * g # optional - sage.rings.finite_rings + sage: f * g Frobenius endomorphism x |--> x^(5^3) of Power Series Ring in u over Finite Field of size 5 """ @@ -3200,15 +3249,15 @@ def _tensor_product_ring(B, A): sage: from sage.rings.morphism import _tensor_product_ring sage: R. = QQ[] - sage: S. = R.quotient(x^2 + y^2) # optional - sage.libs.singular - sage: Q = _tensor_product_ring(S, R); Q # optional - sage.libs.singular + sage: S. = R.quotient(x^2 + y^2) # needs sage.libs.singular + sage: Q = _tensor_product_ring(S, R); Q # needs sage.libs.singular Quotient of Multivariate Polynomial Ring in u, v, x, y over Rational Field by the ideal (u^2 + v^2) - sage: Q.term_order() # optional - sage.libs.singular + sage: Q.term_order() # needs sage.libs.singular Block term order with blocks: (Degree reverse lexicographic term order of length 2, Degree reverse lexicographic term order of length 2) - sage: _tensor_product_ring(R, R) # optional - sage.libs.singular + sage: _tensor_product_ring(R, R) Multivariate Polynomial Ring in y0, y1, x0, x1 over Rational Field TESTS: diff --git a/src/sage/rings/multi_power_series_ring.py b/src/sage/rings/multi_power_series_ring.py index 410de0bbff0..3d96666e222 100644 --- a/src/sage/rings/multi_power_series_ring.py +++ b/src/sage/rings/multi_power_series_ring.py @@ -75,21 +75,22 @@ - Use angle-bracket notation:: - sage: S. = PowerSeriesRing(GF(65537)); S # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: S. = PowerSeriesRing(GF(65537)); S Multivariate Power Series Ring in x, y over Finite Field of size 65537 - sage: s = -30077*x + 9485*x*y - 6260*y^3 + 12870*x^2*y^2 - 20289*y^4 + S.O(5); s # optional - sage.rings.finite_rings + sage: s = -30077*x + 9485*x*y - 6260*y^3 + 12870*x^2*y^2 - 20289*y^4 + S.O(5); s -30077*x + 9485*x*y - 6260*y^3 + 12870*x^2*y^2 - 20289*y^4 + O(x, y)^5 - sage: s in S # optional - sage.rings.finite_rings + sage: s in S True - sage: TestSuite(S).run() # optional - sage.rings.finite_rings - sage: loads(dumps(S)) is S # optional - sage.rings.finite_rings + sage: TestSuite(S).run() + sage: loads(dumps(S)) is S True - Use double square bracket notation:: sage: ZZ[['s,t,u']] Multivariate Power Series Ring in s, t, u over Integer Ring - sage: GF(127931)[['x,y']] # optional - sage.rings.finite_rings + sage: GF(127931)[['x,y']] # needs sage.rings.finite_rings Multivariate Power Series Ring in x, y over Finite Field of size 127931 Variable ordering determines how series are displayed. @@ -117,16 +118,16 @@ sage: R. = PowerSeriesRing(QQ); R Multivariate Power Series Ring in t, u, v over Rational Field - sage: R.base_extend(RR) + sage: R.base_extend(RR) # needs sage.rings.real_mpfr Multivariate Power Series Ring in t, u, v over Real Field with 53 bits of precision sage: R.change_ring(IntegerModRing(10)) Multivariate Power Series Ring in t, u, v over Ring of integers modulo 10 - sage: S = PowerSeriesRing(GF(65537),2,'x,y'); S # optional - sage.rings.finite_rings + sage: S = PowerSeriesRing(GF(65537),2,'x,y'); S # needs sage.rings.finite_rings Multivariate Power Series Ring in x, y over Finite Field of size 65537 - sage: S.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: S.change_ring(GF(5)) # needs sage.rings.finite_rings Multivariate Power Series Ring in x, y over Finite Field of size 5 Coercion from polynomial ring:: @@ -159,19 +160,19 @@ Coercion from symbolic ring:: - sage: x,y = var('x,y') # optional - sage.symbolic - sage: S = PowerSeriesRing(GF(11),2,'x,y'); S # optional - sage.rings.finite_rings + sage: # needs sage.symbolic + sage: x,y = var('x,y') + sage: S = PowerSeriesRing(GF(11),2,'x,y'); S Multivariate Power Series Ring in x, y over Finite Field of size 11 - sage: type(x) # optional - sage.symbolic + sage: type(x) - sage: type(S(x)) # optional - sage.rings.finite_rings sage.symbolic + sage: type(S(x)) - - sage: f = S(2/7 -100*x^2 + 1/3*x*y + y^2).O(3); f # optional - sage.rings.finite_rings sage.symbolic + sage: f = S(2/7 -100*x^2 + 1/3*x*y + y^2).O(3); f 5 - x^2 + 4*x*y + y^2 + O(x, y)^3 - sage: f.parent() # optional - sage.rings.finite_rings sage.symbolic + sage: f.parent() Multivariate Power Series Ring in x, y over Finite Field of size 11 - sage: f.parent() == S # optional - sage.rings.finite_rings sage.symbolic + sage: f.parent() == S True The implementation of the multivariate power series ring uses a combination @@ -390,11 +391,11 @@ def _repr_(self): EXAMPLES:: - sage: R. = PowerSeriesRing(GF(17)) # optional - sage.rings.finite_rings - sage: R #indirect doctest # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(17)) + sage: R #indirect doctest Multivariate Power Series Ring in x, y over Finite Field of size 17 - sage: R.rename('my multivariate power series ring') # optional - sage.rings.finite_rings - sage: R # optional - sage.rings.finite_rings + sage: R.rename('my multivariate power series ring') + sage: R my multivariate power series ring """ if self.ngens() == 0: @@ -402,7 +403,7 @@ def _repr_(self): else: generators_rep = ", ".join(self.variable_names()) - s = "Multivariate Power Series Ring in %s over %s"%(generators_rep, self.base_ring()) + s = "Multivariate Power Series Ring in %s over %s" % (generators_rep, self.base_ring()) if self.is_sparse(): s = 'Sparse ' + s return s @@ -419,7 +420,7 @@ def _latex_(self): '\\Bold{Q}[[v_{0}, v_{1}, v_{2}, v_{3}]]' """ generators_latex = ", ".join(self.latex_variable_names()) - return "%s[[%s]]"%(latex.latex(self.base_ring()), generators_latex) + return "%s[[%s]]" % (latex.latex(self.base_ring()), generators_latex) def is_integral_domain(self, proof=False): """ @@ -479,10 +480,10 @@ def characteristic(self): EXAMPLES:: - sage: H = PowerSeriesRing(GF(65537),4,'f'); H # optional - sage.rings.finite_rings + sage: H = PowerSeriesRing(GF(65537),4,'f'); H # needs sage.rings.finite_rings Multivariate Power Series Ring in f0, f1, f2, f3 over Finite Field of size 65537 - sage: H.characteristic() # optional - sage.rings.finite_rings + sage: H.characteristic() # needs sage.rings.finite_rings 65537 """ return self.base_ring().characteristic() @@ -543,7 +544,7 @@ def change_ring(self, R): sage: R. = PowerSeriesRing(QQ); R Multivariate Power Series Ring in t, u, v over Rational Field - sage: R.base_extend(RR) + sage: R.base_extend(RR) # needs sage.rings.real_mpfr Multivariate Power Series Ring in t, u, v over Real Field with 53 bits of precision sage: R.change_ring(IntegerModRing(10)) @@ -555,10 +556,10 @@ def change_ring(self, R): TypeError: no base extension defined - sage: S = PowerSeriesRing(GF(65537),2,'x,y'); S # optional - sage.rings.finite_rings + sage: S = PowerSeriesRing(GF(65537),2,'x,y'); S # needs sage.rings.finite_rings Multivariate Power Series Ring in x, y over Finite Field of size 65537 - sage: S.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: S.change_ring(GF(5)) # needs sage.rings.finite_rings Multivariate Power Series Ring in x, y over Finite Field of size 5 """ return PowerSeriesRing(R, names=self.variable_names(), default_prec=self.default_prec()) @@ -576,16 +577,16 @@ def remove_var(self, *var): Power Series Ring in u over Integer Ring - sage: M = PowerSeriesRing(GF(5),5,'t'); M # optional - sage.rings.finite_rings + sage: M = PowerSeriesRing(GF(5),5,'t'); M Multivariate Power Series Ring in t0, t1, t2, t3, t4 over Finite Field of size 5 - sage: M.remove_var(M.gens()[3]) # optional - sage.rings.finite_rings + sage: M.remove_var(M.gens()[3]) Multivariate Power Series Ring in t0, t1, t2, t4 over Finite Field of size 5 Removing all variables results in the base ring:: - sage: M.remove_var(*M.gens()) # optional - sage.rings.finite_rings + sage: M.remove_var(*M.gens()) Finite Field of size 5 """ @@ -634,10 +635,10 @@ def _coerce_impl(self, f): sage: R(f2) -2*v^2 + 5*u*v^2 + O(t, u, v)^6 - sage: R2 = R.change_ring(GF(2)) # optional - sage.rings.finite_rings - sage: R2(f1) # optional - sage.rings.finite_rings + sage: R2 = R.change_ring(GF(2)) + sage: R2(f1) v + t*v - sage: R2(f2) # optional - sage.rings.finite_rings + sage: R2(f2) u*v^2 + O(t, u, v)^6 TESTS:: @@ -708,14 +709,15 @@ def _is_valid_homomorphism_(self, codomain, im_gens, base_map=None): You must either give a base map or there must be a coercion from the base ring to the codomain:: + sage: # needs sage.rings.number_field sage: T. = ZZ[] - sage: K. = NumberField(t^2 + 1) # optional - sage.rings.number_field - sage: Q8. = CyclotomicField(8) # optional - sage.rings.number_field - sage: X. = PowerSeriesRing(Q8) # optional - sage.rings.number_field - sage: M. = PowerSeriesRing(K) # optional - sage.rings.number_field - sage: M._is_valid_homomorphism_(X, [x,x,x+x^2]) # no coercion # optional - sage.rings.number_field + sage: K. = NumberField(t^2 + 1) + sage: Q8. = CyclotomicField(8) + sage: X. = PowerSeriesRing(Q8) + sage: M. = PowerSeriesRing(K) + sage: M._is_valid_homomorphism_(X, [x,x,x+x^2]) # no coercion False - sage: M._is_valid_homomorphism_(X, [x,x,x+x^2], base_map=K.hom([z^2])) # optional - sage.rings.number_field + sage: M._is_valid_homomorphism_(X, [x,x,x+x^2], base_map=K.hom([z^2])) True """ try: @@ -757,22 +759,23 @@ def _coerce_map_from_(self, P): EXAMPLES:: - sage: A = GF(17)[['x','y']] # optional - sage.rings.finite_rings - sage: A.has_coerce_map_from(ZZ) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: A = GF(17)[['x','y']] + sage: A.has_coerce_map_from(ZZ) True - sage: A.has_coerce_map_from(ZZ['x']) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(ZZ['x']) True - sage: A.has_coerce_map_from(ZZ['y','x']) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(ZZ['y','x']) True - sage: A.has_coerce_map_from(ZZ[['x']]) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(ZZ[['x']]) True - sage: A.has_coerce_map_from(ZZ[['y','x']]) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(ZZ[['y','x']]) True - sage: A.has_coerce_map_from(ZZ['x','z']) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(ZZ['x','z']) False - sage: A.has_coerce_map_from(GF(3)['x','y']) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(GF(3)['x','y']) False - sage: A.has_coerce_map_from(Frac(ZZ['y','x'])) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(Frac(ZZ['y','x'])) False TESTS:: @@ -780,9 +783,9 @@ def _coerce_map_from_(self, P): sage: M = PowerSeriesRing(ZZ, 3, 'x,y,z') sage: M._coerce_map_from_(M) True - sage: M._coerce_map_from_(M.remove_var(x)) # optional - sage.symbolic + sage: M._coerce_map_from_(M.remove_var(x)) # needs sage.symbolic True - sage: M._coerce_map_from_(PowerSeriesRing(ZZ,x)) # optional - sage.symbolic + sage: M._coerce_map_from_(PowerSeriesRing(ZZ,x)) # needs sage.symbolic True sage: M._coerce_map_from_(PolynomialRing(ZZ,'x,z')) True diff --git a/src/sage/rings/multi_power_series_ring_element.py b/src/sage/rings/multi_power_series_ring_element.py index 9aa3f6ea5a4..2a5c4261800 100644 --- a/src/sage/rings/multi_power_series_ring_element.py +++ b/src/sage/rings/multi_power_series_ring_element.py @@ -252,42 +252,42 @@ class MPowerSeries(PowerSeries): sage: g = 1 + s + t - s*t + S.O(5); g 1 + s + t - s*t + O(s, t)^5 - - sage: T = PowerSeriesRing(GF(3),5,'t'); T # optional - sage.rings.finite_rings + sage: T = PowerSeriesRing(GF(3),5,'t'); T Multivariate Power Series Ring in t0, t1, t2, t3, t4 over Finite Field of size 3 - sage: t = T.gens() # optional - sage.rings.finite_rings - sage: w = t[0] - 2*t[1]*t[3] + 5*t[4]^3 - t[0]^3*t[2]^2; w # optional - sage.rings.finite_rings + sage: t = T.gens() + sage: w = t[0] - 2*t[1]*t[3] + 5*t[4]^3 - t[0]^3*t[2]^2; w t0 + t1*t3 - t4^3 - t0^3*t2^2 - sage: w = w.add_bigoh(5); w # optional - sage.rings.finite_rings + sage: w = w.add_bigoh(5); w t0 + t1*t3 - t4^3 + O(t0, t1, t2, t3, t4)^5 - sage: w in T # optional - sage.rings.finite_rings + sage: w in T True - sage: w = t[0] - 2*t[0]*t[2] + 5*t[4]^3 - t[0]^3*t[2]^2 + T.O(6) # optional - sage.rings.finite_rings - sage: w # optional - sage.rings.finite_rings + sage: w = t[0] - 2*t[0]*t[2] + 5*t[4]^3 - t[0]^3*t[2]^2 + T.O(6) + sage: w t0 + t0*t2 - t4^3 - t0^3*t2^2 + O(t0, t1, t2, t3, t4)^6 Get random elements:: - sage: S.random_element(4) # random + sage: S.random_element(4) # random -2*t + t^2 - 12*s^3 + O(s, t)^4 - sage: T.random_element(10) # random # optional - sage.rings.finite_rings + sage: T.random_element(10) # random -t1^2*t3^2*t4^2 + t1^5*t3^3*t4 + O(t0, t1, t2, t3, t4)^10 Convert elements from polynomial rings:: - sage: R = PolynomialRing(ZZ, 5, T.variable_names()) # optional - sage.libs.pari - sage: t = R.gens() # optional - sage.libs.pari - sage: r = -t[2]*t[3] + t[3]^2 + t[4]^2 # optional - sage.libs.pari - sage: T(r) # optional - sage.libs.pari + sage: # needs sage.rings.finite_rings + sage: R = PolynomialRing(ZZ, 5, T.variable_names()) + sage: t = R.gens() + sage: r = -t[2]*t[3] + t[3]^2 + t[4]^2 + sage: T(r) -t2*t3 + t3^2 + t4^2 - sage: r.parent() # optional - sage.libs.pari + sage: r.parent() Multivariate Polynomial Ring in t0, t1, t2, t3, t4 over Integer Ring - sage: r in T # optional - sage.libs.pari + sage: r in T True """ @@ -314,9 +314,9 @@ def __init__(self, parent, x=0, prec=infinity, is_gen=False, check=False): Multivariate Power Series Ring in s, t over Rational Field sage: x = polygen(ZZ, 'x') - sage: K = NumberField(x - 3,'a') # optional - sage.rings.number_field - sage: g = K.random_element()*f # optional - sage.rings.number_field - sage: g.parent() # optional - sage.rings.number_field + sage: K = NumberField(x - 3,'a') # needs sage.rings.number_field + sage: g = K.random_element()*f # needs sage.rings.number_field + sage: g.parent() # needs sage.rings.number_field Multivariate Power Series Ring in s, t over Number Field in a with defining polynomial x - 3 @@ -451,20 +451,21 @@ def __call__(self, *x, **kwds): Checking that :trac:`15059` is fixed:: - sage: M. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: s = M.hom([u, u+v]) # optional - sage.rings.finite_rings - sage: s(M.one()) # optional - sage.rings.finite_rings + sage: M. = PowerSeriesRing(GF(5)) + sage: s = M.hom([u, u+v]) + sage: s(M.one()) 1 Since :trac:`26105` you can specify a map on the base ring:: + sage: # needs sage.rings.number_field sage: Zx. = ZZ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: cc = K.hom([-i]) # optional - sage.rings.number_field - sage: R. = PowerSeriesRing(K) # optional - sage.rings.number_field - sage: f = s^2 + i*s*t + (3+4*i)*s^3 + R.O(4); f # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: cc = K.hom([-i]) + sage: R. = PowerSeriesRing(K) + sage: f = s^2 + i*s*t + (3+4*i)*s^3 + R.O(4); f s^2 + i*s*t + (4*i + 3)*s^3 + O(s, t)^4 - sage: f(t, s, base_map=cc) # optional - sage.rings.number_field + sage: f(t, s, base_map=cc) (-i)*s*t + t^2 + (-4*i + 3)*t^3 + O(s, t)^4 """ if len(x) != self.parent().ngens(): @@ -512,33 +513,33 @@ def _subs_formal(self, *x, **kwds): z sage: f = -2/33*s*t^2 - 1/5*t^5 - s^5*t + s^2*t^4 - sage: f(z,z) #indirect doctest + sage: f(z,z) # indirect doctest -2/33*z^3 - 1/5*z^5 - sage: f(z,1) #indirect doctest + sage: f(z,1) # indirect doctest -1/5 - 2/33*z + z^2 - z^5 - sage: RF = RealField(10) - sage: f(z,RF(1)) #indirect doctest + sage: RF = RealField(10) # needs sage.rings.real_mpfr + sage: f(z, RF(1)) # indirect doctest # needs sage.rings.real_mpfr -0.20 - 0.061*z + 1.0*z^2 - 0.00*z^3 - 0.00*z^4 - 1.0*z^5 - sage: m = matrix(QQ,[[1,0,1],[0,2,1],[-1,0,0]]) - sage: m + sage: m = matrix(QQ,[[1,0,1],[0,2,1],[-1,0,0]]); m # needs sage.modules [ 1 0 1] [ 0 2 1] [-1 0 0] - sage: f(m,m) #indirect doctest + sage: f(m,m) # indirect doctest # needs sage.modules [ 2/33 0 1/5] [ 131/55 -1136/165 -24/11] [ -1/5 0 -23/165] - sage: f(m,m) == -2/33*m^3 - 1/5*m^5 #indirect doctest + sage: f(m,m) == -2/33*m^3 - 1/5*m^5 # indirect doctest # needs sage.modules True sage: f = f.add_bigoh(10) sage: f(z,z) -2/33*z^3 - 1/5*z^5 + O(z^10) - sage: f(m,m) + sage: f(m,m) # needs sage.modules Traceback (most recent call last): ... - AttributeError: 'sage.matrix.matrix_rational_dense.Matrix_rational_dense' object has no attribute 'add_bigoh' + AttributeError: 'sage.matrix.matrix_rational_dense.Matrix_rational_dense' + object has no attribute 'add_bigoh' """ from sage.misc.misc_c import prod @@ -567,14 +568,14 @@ def _value(self): EXAMPLES:: - sage: R. = PowerSeriesRing(GF(5)); R # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(5)); R Multivariate Power Series Ring in a, b, c over Finite Field of size 5 - sage: f = 1 + a + b - a*b + R.O(3); f # optional - sage.rings.finite_rings + sage: f = 1 + a + b - a*b + R.O(3); f 1 + a + b - a*b + O(a, b, c)^3 - sage: f._value() # optional - sage.rings.finite_rings + sage: f._value() 1 + a + b - a*b - sage: f._value().parent() # optional - sage.rings.finite_rings + sage: f._value().parent() Multivariate Polynomial Ring in a, b, c over Finite Field of size 5 """ return self._go_to_fg(self._bg_value) @@ -593,7 +594,7 @@ def _repr_(self): if self._prec == infinity: return "%s" % self._value() return "%(val)s + O(%(gens)s)^%(prec)s" \ - %{'val':self._value(), + % {'val':self._value(), 'gens':', '.join(str(g) for g in self.parent().gens()), 'prec':self._prec} @@ -603,15 +604,15 @@ def _latex_(self): EXAMPLES:: - sage: M = PowerSeriesRing(GF(5),3,'t'); M # optional - sage.rings.finite_rings + sage: M = PowerSeriesRing(GF(5),3,'t'); M Multivariate Power Series Ring in t0, t1, t2 over Finite Field of size 5 - sage: t = M.gens() # optional - sage.rings.finite_rings - sage: f = (-t[0]^4*t[1]^3*t[2]^4 - 2*t[0]*t[1]^4*t[2]^7 # optional - sage.rings.finite_rings + sage: t = M.gens() + sage: f = (-t[0]^4*t[1]^3*t[2]^4 - 2*t[0]*t[1]^4*t[2]^7 ....: + 2*t[1]*t[2]^12 + 2*t[0]^7*t[1]^5*t[2]^2 + M.O(15)) - sage: f # optional - sage.rings.finite_rings + sage: f -t0^4*t1^3*t2^4 - 2*t0*t1^4*t2^7 + 2*t1*t2^12 + 2*t0^7*t1^5*t2^2 + O(t0, t1, t2)^15 - sage: f._latex_() # optional - sage.rings.finite_rings + sage: f._latex_() '-t_{0}^{4} t_{1}^{3} t_{2}^{4} + 3 t_{0} t_{1}^{4} t_{2}^{7} + 2 t_{1} t_{2}^{12} + 2 t_{0}^{7} t_{1}^{5} t_{2}^{2} + O(t_{0}, t_{1}, t_{2})^{15}' @@ -628,7 +629,7 @@ def _latex_(self): if self._prec == infinity: return "%s" % self._value()._latex_() return "%(val)s + O(%(gens)s)^{%(prec)s}" \ - %{'val':self._value()._latex_(), + % {'val':self._value()._latex_(), 'gens':', '.join(g._latex_() for g in self.parent().gens()), 'prec':self._prec} @@ -709,30 +710,30 @@ def _richcmp_(self, other, op): EXAMPLES:: - sage: R. = PowerSeriesRing(GF(5)); R # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(5)); R Multivariate Power Series Ring in a, b, c over Finite Field of size 5 - sage: f = a + b + c + a^2*c # optional - sage.rings.finite_rings - sage: f == f^2 # optional - sage.rings.finite_rings + sage: f = a + b + c + a^2*c + sage: f == f^2 False - sage: f = f.truncate() # optional - sage.rings.finite_rings - sage: f == f.O(4) # optional - sage.rings.finite_rings + sage: f = f.truncate() + sage: f == f.O(4) True Ordering is determined by underlying polynomial ring:: - sage: a > b # optional - sage.rings.finite_rings + sage: a > b True - sage: a > a^2 # optional - sage.rings.finite_rings + sage: a > a^2 True - sage: b > a^2 # optional - sage.rings.finite_rings + sage: b > a^2 True - sage: (f^2).O(3) # optional - sage.rings.finite_rings + sage: (f^2).O(3) a^2 + 2*a*b + 2*a*c + b^2 + 2*b*c + c^2 + O(a, b, c)^3 - sage: f < f^2 # optional - sage.rings.finite_rings + sage: f < f^2 False - sage: f > f^2 # optional - sage.rings.finite_rings + sage: f > f^2 True - sage: f < 2*f # optional - sage.rings.finite_rings + sage: f < 2*f True """ return richcmp(self._bg_value, other._bg_value, op) @@ -891,27 +892,25 @@ def quo_rem(self, other, precision=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PowerSeriesRing(ZZ) sage: f = 1 + a + b - a*b + R.O(3) sage: g = 1 + 2*a - 3*a*b + R.O(3) - sage: q, r = f.quo_rem(g); q, r # optional - sage.libs.singular + sage: q, r = f.quo_rem(g); q, r (1 - a + b + 2*a^2 + O(a, b, c)^3, 0 + O(a, b, c)^3) - sage: f == q*g + r # optional - sage.libs.singular + sage: f == q*g + r True - - sage: q, r = (a*f).quo_rem(g); q, r # optional - sage.libs.singular + sage: q, r = (a*f).quo_rem(g); q, r (a - a^2 + a*b + 2*a^3 + O(a, b, c)^4, 0 + O(a, b, c)^4) - sage: a*f == q*g + r # optional - sage.libs.singular + sage: a*f == q*g + r True - - sage: q, r = (a*f).quo_rem(a*g); q, r # optional - sage.libs.singular + sage: q, r = (a*f).quo_rem(a*g); q, r (1 - a + b + 2*a^2 + O(a, b, c)^3, 0 + O(a, b, c)^4) - sage: a*f == q*(a*g) + r # optional - sage.libs.singular + sage: a*f == q*(a*g) + r True - - sage: q, r = (a*f).quo_rem(b*g); q, r # optional - sage.libs.singular + sage: q, r = (a*f).quo_rem(b*g); q, r (a - 3*a^2 + O(a, b, c)^3, a + a^2 + O(a, b, c)^4) - sage: a*f == q*(b*g) + r # optional - sage.libs.singular + sage: a*f == q*(b*g) + r True Trying to divide two polynomials, we run into the issue that @@ -920,61 +919,58 @@ def quo_rem(self, other, precision=None): algorithm would never terminate). Here, default precision comes to our help:: - sage: (1 + a^3).quo_rem(a + a^2) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: (1 + a^3).quo_rem(a + a^2) (a^2 - a^3 + a^4 - a^5 + a^6 - a^7 + a^8 - a^9 + a^10 + O(a, b, c)^11, 1 + O(a, b, c)^12) - - sage: (1 + a^3 + a*b).quo_rem(b + c) # optional - sage.libs.singular + sage: (1 + a^3 + a*b).quo_rem(b + c) (a + O(a, b, c)^11, 1 - a*c + a^3 + O(a, b, c)^12) - sage: (1 + a^3 + a*b).quo_rem(b + c, precision=17) # optional - sage.libs.singular + sage: (1 + a^3 + a*b).quo_rem(b + c, precision=17) (a + O(a, b, c)^16, 1 - a*c + a^3 + O(a, b, c)^17) - - sage: (a^2 + b^2 + c^2).quo_rem(a + b + c) # optional - sage.libs.singular + sage: (a^2 + b^2 + c^2).quo_rem(a + b + c) (a - b - c + O(a, b, c)^11, 2*b^2 + 2*b*c + 2*c^2 + O(a, b, c)^12) - - sage: (a^2 + b^2 + c^2).quo_rem(1/(1+a+b+c)) # optional - sage.libs.singular + sage: (a^2 + b^2 + c^2).quo_rem(1/(1+a+b+c)) (a^2 + b^2 + c^2 + a^3 + a^2*b + a^2*c + a*b^2 + a*c^2 + b^3 + b^2*c + b*c^2 + c^3 + O(a, b, c)^14, 0) - - sage: (a^2 + b^2 + c^2).quo_rem(a/(1+a+b+c)) # optional - sage.libs.singular + sage: (a^2 + b^2 + c^2).quo_rem(a/(1+a+b+c)) (a + a^2 + a*b + a*c + O(a, b, c)^13, b^2 + c^2) - - sage: (1 + a + a^15).quo_rem(a^2) # optional - sage.libs.singular + sage: (1 + a + a^15).quo_rem(a^2) (0 + O(a, b, c)^10, 1 + a + O(a, b, c)^12) - sage: (1 + a + a^15).quo_rem(a^2, precision=15) # optional - sage.libs.singular + sage: (1 + a + a^15).quo_rem(a^2, precision=15) (0 + O(a, b, c)^13, 1 + a + O(a, b, c)^15) - sage: (1 + a + a^15).quo_rem(a^2, precision=16) # optional - sage.libs.singular + sage: (1 + a + a^15).quo_rem(a^2, precision=16) (a^13 + O(a, b, c)^14, 1 + a + O(a, b, c)^16) Illustrating the dependency on the ordering of variables:: - sage: (1 + a + b).quo_rem(b + c) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: (1 + a + b).quo_rem(b + c) (1 + O(a, b, c)^11, 1 + a - c + O(a, b, c)^12) - sage: (1 + b + c).quo_rem(c + a) # optional - sage.libs.singular + sage: (1 + b + c).quo_rem(c + a) (0 + O(a, b, c)^11, 1 + b + c + O(a, b, c)^12) - sage: (1 + c + a).quo_rem(a + b) # optional - sage.libs.singular + sage: (1 + c + a).quo_rem(a + b) (1 + O(a, b, c)^11, 1 - b + c + O(a, b, c)^12) TESTS:: - sage: (f).quo_rem(R.zero()) # optional - sage.libs.singular + sage: (f).quo_rem(R.zero()) # needs sage.libs.singular Traceback (most recent call last): ... ZeroDivisionError - sage: (f).quo_rem(R.zero().add_bigoh(2)) # optional - sage.libs.singular + sage: (f).quo_rem(R.zero().add_bigoh(2)) # needs sage.libs.singular Traceback (most recent call last): ... ZeroDivisionError Coercion is applied on ``other``:: - sage: (a + b).quo_rem(1) # optional - sage.libs.singular + sage: (a + b).quo_rem(1) # needs sage.libs.singular (a + b + O(a, b, c)^12, 0 + O(a, b, c)^12) sage: R. = PowerSeriesRing(QQ) - sage: R(3).quo_rem(2) # optional - sage.libs.singular + sage: R(3).quo_rem(2) (3/2 + O(a, b, c)^12, 0 + O(a, b, c)^12) """ parent = self.parent() @@ -1038,30 +1034,30 @@ def _div_(self, denom_r): When possible, division by non-units also works:: - sage: a/(a*f) # optional - sage.libs.singular + sage: a/(a*f) # needs sage.libs.singular 1 - a - b + a^2 + 3*a*b + b^2 + O(a, b, c)^3 - sage: a/(R.zero()) # optional - sage.libs.singular + sage: a/(R.zero()) Traceback (most recent call last): ZeroDivisionError - sage: (a*f)/f # optional - sage.libs.singular + sage: (a*f)/f a + O(a, b, c)^4 - sage: f/(a*f) # optional - sage.libs.singular + sage: f/(a*f) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: not divisible An example where one loses precision:: - sage: ((1+a)*f - f) / a*f # optional - sage.libs.singular + sage: ((1+a)*f - f) / a*f # needs sage.libs.singular 1 + 2*a + 2*b + O(a, b, c)^2 TESTS:: - sage: ((a+b)*f) / f == (a+b) # optional - sage.libs.singular + sage: ((a+b)*f) / f == (a+b) True - sage: ((a+b)*f) / (a+b) == f # optional - sage.libs.singular + sage: ((a+b)*f) / (a+b) == f # needs sage.libs.singular True """ if denom_r.is_unit(): # faster if denom_r is a unit @@ -1084,7 +1080,7 @@ def __mod__(self, other): False sage: g in R.base_extend(Zmod(2)) True - sage: g.polynomial() == f.polynomial() % 2 # optional - sage.libs.singular + sage: g.polynomial() == f.polynomial() % 2 # needs sage.libs.singular True """ if isinstance(other, (int, Integer)): @@ -1159,14 +1155,14 @@ def variables(self): EXAMPLES:: - sage: T = PowerSeriesRing(GF(3),5,'t'); T # optional - sage.rings.finite_rings + sage: T = PowerSeriesRing(GF(3),5,'t'); T Multivariate Power Series Ring in t0, t1, t2, t3, t4 over Finite Field of size 3 - sage: t = T.gens() # optional - sage.rings.finite_rings - sage: w = t[0] - 2*t[0]*t[2] + 5*t[4]^3 - t[0]^3*t[2]^2 + T.O(6) # optional - sage.rings.finite_rings - sage: w # optional - sage.rings.finite_rings + sage: t = T.gens() + sage: w = t[0] - 2*t[0]*t[2] + 5*t[4]^3 - t[0]^3*t[2]^2 + T.O(6) + sage: w t0 + t0*t2 - t4^3 - t0^3*t2^2 + O(t0, t1, t2, t3, t4)^6 - sage: w.variables() # optional - sage.rings.finite_rings + sage: w.variables() (t0, t2, t4) """ return tuple(self.parent(v) for v in self._value().variables()) @@ -1220,7 +1216,7 @@ def coefficients(self): tmp = {} for j in self._bg_value.coefficients(): for m in j.monomials(): - tmp[self.parent(m)]=j.monomial_coefficient(self.parent()._poly_ring(m)) + tmp[self.parent(m)] = j.monomial_coefficient(self.parent()._poly_ring(m)) return tmp def constant_coefficient(self): @@ -1396,16 +1392,17 @@ def valuation(self): EXAMPLES:: - sage: R. = PowerSeriesRing(GF(4949717)); R # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(4949717)); R Multivariate Power Series Ring in a, b over Finite Field of size 4949717 - sage: f = a^2 + a*b + a^3 + R.O(9) # optional - sage.rings.finite_rings - sage: f.valuation() # optional - sage.rings.finite_rings + sage: f = a^2 + a*b + a^3 + R.O(9) + sage: f.valuation() 2 - sage: g = 1 + a + a^3 # optional - sage.rings.finite_rings - sage: g.valuation() # optional - sage.rings.finite_rings + sage: g = 1 + a + a^3 + sage: g.valuation() 0 - sage: R.zero().valuation() # optional - sage.rings.finite_rings + sage: R.zero().valuation() +Infinity """ try: @@ -1898,13 +1895,13 @@ def exp(self, prec=infinity): sage: T. = PowerSeriesRing(ZZ, 2) sage: f = a + b + a*b + T.O(3) - sage: exp(f) # optional - sage.symbolic + sage: exp(f) 1 + a + b + 1/2*a^2 + 2*a*b + 1/2*b^2 + O(a, b)^3 - sage: f.exp() # optional - sage.symbolic + sage: f.exp() 1 + a + b + 1/2*a^2 + 2*a*b + 1/2*b^2 + O(a, b)^3 - sage: f.exp(prec=2) # optional - sage.symbolic + sage: f.exp(prec=2) 1 + a + b + O(a, b)^2 - sage: log(exp(f)) - f # optional - sage.symbolic + sage: log(exp(f)) - f 0 + O(a, b)^3 If the power series has a constant coefficient `c` and @@ -1913,7 +1910,7 @@ def exp(self, prec=infinity): are not yet implemented and therefore such cases raise an error:: sage: g = 2 + f - sage: exp(g) # optional - sage.symbolic + sage: exp(g) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for *: 'Symbolic Ring' and @@ -1923,7 +1920,7 @@ def exp(self, prec=infinity): Another workaround for this limitation is to change base ring to one which is closed under exponentiation, such as `\RR` or `\CC`:: - sage: exp(g.change_ring(RDF)) # optional - sage.symbolic + sage: exp(g.change_ring(RDF)) 7.38905609... + 7.38905609...*a + 7.38905609...*b + 3.69452804...*a^2 + 14.7781121...*a*b + 3.69452804...*b^2 + O(a, b)^3 @@ -1931,17 +1928,17 @@ def exp(self, prec=infinity): sage: T.default_prec() 12 - sage: exp(a) # optional - sage.symbolic + sage: exp(a) 1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + 1/120*a^5 + 1/720*a^6 + 1/5040*a^7 + 1/40320*a^8 + 1/362880*a^9 + 1/3628800*a^10 + 1/39916800*a^11 + O(a, b)^12 sage: a.exp(prec=5) 1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + O(a, b)^5 - sage: exp(a + T.O(5)) # optional - sage.symbolic + sage: exp(a + T.O(5)) 1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + O(a, b)^5 TESTS:: - sage: exp(a^2 + T.O(5)) # optional - sage.symbolic + sage: exp(a^2 + T.O(5)) 1 + a^2 + 1/2*a^4 + O(a, b)^5 """ R = self.parent() @@ -1990,11 +1987,11 @@ def log(self, prec=infinity): sage: T. = PowerSeriesRing(ZZ, 2) sage: f = 1 + a + b + a*b + T.O(5) - sage: f.log() # optional - sage.symbolic + sage: f.log() a + b - 1/2*a^2 - 1/2*b^2 + 1/3*a^3 + 1/3*b^3 - 1/4*a^4 - 1/4*b^4 + O(a, b)^5 - sage: log(f) # optional - sage.symbolic + sage: log(f) a + b - 1/2*a^2 - 1/2*b^2 + 1/3*a^3 + 1/3*b^3 - 1/4*a^4 - 1/4*b^4 + O(a, b)^5 - sage: exp(log(f)) - f # optional - sage.symbolic + sage: exp(log(f)) - f 0 + O(a, b)^5 If the power series has a constant coefficient `c` and @@ -2002,8 +1999,8 @@ def log(self, prec=infinity): power series over the :class:`~sage.symbolic.ring.SymbolicRing`. These are not yet implemented and therefore such cases raise an error:: - sage: g = 2 + f # optional - sage.symbolic - sage: log(g) # optional - sage.symbolic + sage: g = 2 + f + sage: log(g) Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for -: 'Symbolic Ring' and 'Power @@ -2012,7 +2009,7 @@ def log(self, prec=infinity): Another workaround for this limitation is to change base ring to one which is closed under exponentiation, such as `\RR` or `\CC`:: - sage: log(g.change_ring(RDF)) # optional - sage.symbolic + sage: log(g.change_ring(RDF)) 1.09861228... + 0.333333333...*a + 0.333333333...*b - 0.0555555555...*a^2 + 0.222222222...*a*b - 0.0555555555...*b^2 + 0.0123456790...*a^3 - 0.0740740740...*a^2*b - 0.0740740740...*a*b^2 + 0.0123456790...*b^3 @@ -2021,17 +2018,17 @@ def log(self, prec=infinity): TESTS:: - sage: (1+a).log(prec=10).exp() # optional - sage.symbolic + sage: (1+a).log(prec=10).exp() 1 + a + O(a, b)^10 - sage: a.exp(prec=10).log() # optional - sage.symbolic + sage: a.exp(prec=10).log() a + O(a, b)^10 - sage: log(1+a) # optional - sage.symbolic + sage: log(1+a) a - 1/2*a^2 + 1/3*a^3 - 1/4*a^4 + 1/5*a^5 - 1/6*a^6 + 1/7*a^7 - 1/8*a^8 + 1/9*a^9 - 1/10*a^10 + 1/11*a^11 + O(a, b)^12 - sage: -log(1-a+T.O(5)) # optional - sage.symbolic + sage: -log(1-a+T.O(5)) a + 1/2*a^2 + 1/3*a^3 + 1/4*a^4 + O(a, b)^5 - sage: a.log(prec=10) # optional - sage.symbolic + sage: a.log(prec=10) Traceback (most recent call last): ... ValueError: Can only take formal power series for non-zero constant term. diff --git a/src/sage/rings/noncommutative_ideals.pyx b/src/sage/rings/noncommutative_ideals.pyx index af27882313d..6965f1c6c61 100644 --- a/src/sage/rings/noncommutative_ideals.pyx +++ b/src/sage/rings/noncommutative_ideals.pyx @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.modules +# sage.doctest: needs sage.modules """ Ideals of non-commutative rings @@ -39,6 +39,7 @@ algebras. TESTS:: + sage: # needs sage.combinat sage: A = SteenrodAlgebra(2) sage: IL = A*[A.1+A.2,A.1^2]; IL Left Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis @@ -115,6 +116,7 @@ class IdealMonoid_nc(IdealMonoid_c): TESTS:: + sage: # needs sage.combinat sage: A = SteenrodAlgebra(2) # indirect doctest sage: IL = A*[A.1+A.2,A.1^2]; IL Left Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis @@ -128,6 +130,7 @@ class IdealMonoid_nc(IdealMonoid_c): :: + sage: # needs sage.combinat sage: IL == loads(dumps(IL)) True sage: IR == loads(dumps(IR)) @@ -244,6 +247,7 @@ class Ideal_nc(Ideal_generic): TESTS:: + sage: # needs sage.combinat sage: A = SteenrodAlgebra(2) sage: A*[A.1+A.2,A.1^2] # indirect doctest Left Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis @@ -263,14 +267,15 @@ class Ideal_nc(Ideal_generic): EXAMPLES:: - sage: A = SteenrodAlgebra(2) - sage: IR = [A.1+A.2,A.1^2]*A - sage: IL = A*[A.1+A.2,A.1^2] - sage: IT = A*[A.1+A.2,A.1^2]*A - sage: IT == IL - False - sage: IR == [A.1+A.2,A.1^2]*A - True + sage: # needs sage.combinat + sage: A = SteenrodAlgebra(2) + sage: IR = [A.1+A.2,A.1^2]*A + sage: IL = A*[A.1+A.2,A.1^2] + sage: IT = A*[A.1+A.2,A.1^2]*A + sage: IT == IL + False + sage: IR == [A.1+A.2,A.1^2]*A + True """ if not isinstance(right, Ideal_nc): return False @@ -289,14 +294,15 @@ class Ideal_nc(Ideal_generic): EXAMPLES:: - sage: A = SteenrodAlgebra(2) - sage: IR = [A.1+A.2,A.1^2]*A - sage: IL = A*[A.1+A.2,A.1^2] - sage: IT = A*[A.1+A.2,A.1^2]*A - sage: IT != IL - True - sage: IR != [A.1+A.2,A.1^2]*A - False + sage: # needs sage.combinat + sage: A = SteenrodAlgebra(2) + sage: IR = [A.1+A.2,A.1^2]*A + sage: IL = A*[A.1+A.2,A.1^2] + sage: IT = A*[A.1+A.2,A.1^2]*A + sage: IT != IL + True + sage: IR != [A.1+A.2,A.1^2]*A + False """ return not self.__eq__(right) @@ -306,14 +312,15 @@ class Ideal_nc(Ideal_generic): EXAMPLES:: - sage: A = SteenrodAlgebra(2) - sage: IR = [A.1+A.2,A.1^2]*A - sage: IL = A*[A.1+A.2,A.1^2] - sage: IT = A*[A.1+A.2,A.1^2]*A - sage: hash(IT) == hash(IL) - False - sage: hash(IR) == hash([A.1^2,A.1+A.2]*A) - True + sage: # needs sage.combinat + sage: A = SteenrodAlgebra(2) + sage: IR = [A.1+A.2,A.1^2]*A + sage: IL = A*[A.1+A.2,A.1^2] + sage: IT = A*[A.1+A.2,A.1^2]*A + sage: hash(IT) == hash(IL) + False + sage: hash(IR) == hash([A.1^2,A.1+A.2]*A) + True """ return hash((self.parent(), self.__side, frozenset(self.gens()))) @@ -323,6 +330,7 @@ class Ideal_nc(Ideal_generic): EXAMPLES:: + sage: # needs sage.combinat sage: A = SteenrodAlgebra(2) sage: IL = A*[A.1+A.2,A.1^2] sage: IR = [A.1+A.2,A.1^2]*A diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py index a986e3c513c..92f7af1bf19 100644 --- a/src/sage/rings/number_field/S_unit_solver.py +++ b/src/sage/rings/number_field/S_unit_solver.py @@ -278,7 +278,7 @@ def mus(SUK, v): """ betas = SUK.fundamental_units() beta_and_ns = [[beta,beta.valuation(v)] for beta in betas] - if all(pair[1]==0 for pair in beta_and_ns): + if all(pair[1] == 0 for pair in beta_and_ns): return betas else: good_pair = beta_k(beta_and_ns) @@ -397,7 +397,7 @@ def Yu_a1_kappa1_c1(p, dK, ep): c1 = 1473 else: c1 = 319 - elif p%4 == 1: + elif p % 4 == 1: if ep == 1: c1 = 1473 else: @@ -461,10 +461,10 @@ def Yu_condition_115(K, v): if q == 2: if p**f % 4 == 1: return True - if w%4 == 0: + if w % 4 == 0: return True else: - if w%3 == 0: + if w % 3 == 0: return True return False @@ -1342,7 +1342,7 @@ def log_p_series_part(a, prime, prec): divisor = q.divisors() order = min(d for d in divisor if (a**d - 1).valuation(prime) > 0) - gamma= a**order + gamma = a**order t = 0 while (gamma-1).valuation(prime) <= e: t += 1 @@ -2461,7 +2461,7 @@ def compatible_vectors(a, m0, m1, g): 27 """ # recall that the 0th entry must be an exact match. - ranges = [[a[0]]] + [range(a[i]%g, (a[i]%g) + m1, g) for i in range(1, len(a))] + ranges = [[a[0]]] + [range(a[i] % g, (a[i] % g) + m1, g) for i in range(1, len(a))] return itertools.product(*ranges) diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py index 5be046865f6..2bae4dd2df0 100644 --- a/src/sage/rings/number_field/class_group.py +++ b/src/sage/rings/number_field/class_group.py @@ -102,7 +102,7 @@ def _repr_(self): """ if self.is_principal(): return 'Trivial principal fractional ideal class' - return 'Fractional ideal class %s'%self._value._repr_short() + return 'Fractional ideal class %s' % self._value._repr_short() def _mul_(self, other): r""" @@ -301,7 +301,7 @@ def representative_prime(self, norm_bound=1000): K = Cl.number_field() from sage.rings.real_mpfr import RR for P in K.primes_of_bounded_norm_iter(RR(norm_bound)): - if Cl(P)==c: + if Cl(P) == c: return P raise RuntimeError("No prime of norm less than %s found in class %s" % (norm_bound, c)) @@ -607,10 +607,10 @@ def _repr_(self): sage: C._repr_() 'Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23' """ - s = 'Class group of order %s '%self.order() + s = 'Class group of order %s ' % self.order() if self.order() > 1: - s += 'with structure %s '%self._group_notation(self.gens_orders()) - s += 'of %s'%self.number_field() + s += 'with structure %s ' % self._group_notation(self.gens_orders()) + s += 'of %s' % self.number_field() return s def number_field(self): diff --git a/src/sage/rings/number_field/homset.py b/src/sage/rings/number_field/homset.py index a28660ca5d0..cb61df73344 100644 --- a/src/sage/rings/number_field/homset.py +++ b/src/sage/rings/number_field/homset.py @@ -143,7 +143,7 @@ def _an_element_(self): else: from sage.categories.sets_cat import EmptySetError raise EmptySetError("There is no morphism from {} to {}".format( - self.domain(), self.codomain())) + self.domain(), self.codomain())) def _repr_(self): r""" @@ -238,7 +238,7 @@ def list(self): v = [D.hom([r], codomain=C, check=False) for r in roots] else: v = [] - return Sequence(v, universe=self, check=False, immutable=True, cr=v!=[]) + return Sequence(v, universe=self, check=False, immutable=True, cr=bool(v)) def __getitem__(self, n): r""" @@ -389,7 +389,7 @@ def _element_constructor_(self, x, base_map=None, base_hom=None, check=True): raise ValueError("codomain of absolute homomorphism must be codomain of this homset.") return self.element_class(self, x) if (isinstance(x, RelativeNumberFieldHomomorphism_from_abs) - and x.parent() == self): + and x.parent() == self): return self.element_class(self, x.abs_hom()) if base_map is None: base_map = self.default_base_hom() @@ -519,7 +519,7 @@ def list(self): C = self.codomain() D_abs = D.absolute_field('a') v = [self(f, check=False) for f in D_abs.Hom(C).list()] - return Sequence(v, universe=self, check=False, immutable=True, cr=v!=[]) + return Sequence(v, universe=self, check=False, immutable=True, cr=bool(v)) class CyclotomicFieldHomset(NumberFieldHomset): @@ -579,7 +579,7 @@ def _element_constructor_(self, x, check=True): x^2 + b """ if (isinstance(x, CyclotomicFieldHomomorphism_im_gens) - and x.parent() == self): + and x.parent() == self): return self.element_class(self, x.im_gens()) return self.element_class(self, x, check=check) @@ -615,11 +615,11 @@ def list(self): z = D.gen() n = z.multiplicative_order() if not n.divides(C.zeta_order()): - v =[] + v = [] else: if D == C: w = z else: w = C.zeta(n) v = [self([w**k], check=False) for k in Zmod(n) if k.is_unit()] - return Sequence(v, universe=self, check=False, immutable=True, cr=v!=[]) + return Sequence(v, universe=self, check=False, immutable=True, cr=bool(v)) diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index d44fc55b70c..fb37690f280 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -36,7 +36,7 @@ AUTHORS: import operator -from cpython.int cimport * +from cpython.long cimport * from cysignals.signals cimport sig_on, sig_off from sage.ext.stdsage cimport PY_NEW @@ -2941,32 +2941,33 @@ cdef class NumberFieldElement(NumberFieldElement_base): EXAMPLES:: + sage: # needs sage.symbolic sage: K. = QuadraticField(2) - sage: SR(a) # indirect doctest # needs sage.symbolic + sage: SR(a) # indirect doctest sqrt(2) - sage: SR(3*a-5) # indirect doctest # needs sage.symbolic + sage: SR(3*a - 5) # indirect doctest 3*sqrt(2) - 5 sage: K. = QuadraticField(2, embedding=-1.4) - sage: SR(a) # indirect doctest # needs sage.symbolic + sage: SR(a) # indirect doctest -sqrt(2) sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 2) - sage: SR(a) # indirect doctest # needs sage.symbolic + sage: SR(a) # indirect doctest Traceback (most recent call last): ... TypeError: an embedding into RR or CC must be specified Now a more complicated example:: - sage: K. = NumberField(x^3 + x - 1, embedding=0.68) - sage: b = SR(a); b # indirect doctest # needs sage.symbolic + sage: K. = NumberField(x^3 + x - 1, embedding=0.68) # needs sage.symbolic + sage: b = SR(a); b # indirect doctest # needs sage.symbolic (1/18*sqrt(31)*sqrt(3) + 1/2)^(1/3) - 1/3/(1/18*sqrt(31)*sqrt(3) + 1/2)^(1/3) sage: (b^3 + b - 1).canonicalize_radical() # needs sage.symbolic 0 Make sure we got the right one:: - sage: CC(a) + sage: CC(a) # needs sage.symbolic 0.682327803828019 sage: CC(b) # needs sage.symbolic 0.682327803828019 @@ -2974,7 +2975,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): Special case for cyclotomic fields:: sage: K. = CyclotomicField(19) - sage: SR(zeta) # indirect doctest # needs sage.symbolic + sage: SR(zeta) # indirect doctest # needs sage.symbolic e^(2/19*I*pi) sage: CC(zeta) 0.945817241700635 + 0.324699469204683*I @@ -2989,20 +2990,20 @@ cdef class NumberFieldElement(NumberFieldElement_base): embedded into the symbolic ring, which will usually get printed as a numerical approximation:: - sage: K. = NumberField(x^5-x+1, embedding=-1) + sage: K. = NumberField(x^5-x+1, embedding=-1) # needs sage.symbolic sage: SR(a) # needs sage.symbolic -1.167303978261419? :: - sage: K. = NumberField(x^6-x^3-1, embedding=1) + sage: K. = NumberField(x^6-x^3-1, embedding=1) # needs sage.symbolic sage: SR(a) # needs sage.symbolic (1/2*sqrt(5) + 1/2)^(1/3) In this field, general elements cannot be written in terms of radicals, but particular elements might be:: - sage: K. = NumberField(x^10 + 6*x^6 + 9*x^2 + 1, embedding=CC(0.332*I)) + sage: K. = NumberField(x^10 + 6*x^6 + 9*x^2 + 1, embedding=CC(0.332*I)) # needs sage.symbolic sage: SR(a) # needs sage.symbolic 0.3319890295845093?*I sage: SR(a^5+3*a) # needs sage.symbolic diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py index b5e724a0ab4..161ef40a842 100644 --- a/src/sage/rings/number_field/number_field_ideal.py +++ b/src/sage/rings/number_field/number_field_ideal.py @@ -18,6 +18,7 @@ We test that pickling works:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 - 5) sage: I = K.ideal(2/(5+a)) sage: I == loads(dumps(I)) @@ -78,6 +79,7 @@ def __init__(self, field, gens, coerce=True): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: K.ideal(7) Fractional ideal (7) @@ -133,7 +135,7 @@ def __init__(self, field, gens, coerce=True): else: # Assume one element of the field gens = [field(gens, check=False)] - if len(gens)==0: + if len(gens) == 0: raise ValueError("gens must have length at least 1 (zero ideal is not a fractional ideal)") Ideal_generic.__init__(self, field, gens, coerce) if field.absolute_degree() == 2: @@ -154,6 +156,7 @@ def _magma_init_(self, magma): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 2) # optional - magma sage: I = K.ideal(5) # optional - magma sage: I._magma_init_(magma) # optional - magma @@ -171,6 +174,7 @@ def __hash__(self): """ EXAMPLES:: + sage: x = polygen(ZZ) sage: NumberField(x^2 + 1, 'a').ideal(7).__hash__() # random 7806919040325273549 """ @@ -186,6 +190,7 @@ def _latex_(self): r""" EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 23) sage: K.ideal([2, 1/2*a - 1/2])._latex_() '\\left(2, \\frac{1}{2} a - \\frac{1}{2}\\right)' @@ -232,6 +237,7 @@ def _richcmp_(self, other, op): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 3); K Number Field in a with defining polynomial x^2 + 3 sage: f = K.factor(15); f @@ -288,8 +294,8 @@ def _mul_(self, other): if self.ngens() == 1 and other.ngens() == 1: return self.ring().ideal(self.gen(0) * other.gen(0)) - K=self.ring() - K_pari=K.pari_nf() + K = self.ring() + K_pari = K.pari_nf() return K.ideal(K_pari.idealmul(self, other)) def coordinates(self, x): @@ -354,6 +360,7 @@ def _contains_(self, x): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 23); K Number Field in a with defining polynomial x^2 + 23 sage: I = K.factor(13)[0][0]; I @@ -406,6 +413,7 @@ def __elements_from_hnf(self, hnf): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 389); K Number Field in a with defining polynomial x^3 + 389 sage: I = K.factor(17)[0][0] @@ -433,7 +441,8 @@ def __repr__(self): EXAMPLES:: - sage: K. = NumberField(x^3-2) + sage: x = polygen(ZZ) + sage: K. = NumberField(x^3 - 2) sage: I = K.ideal(0); I Ideal (0) of Number Field in a with defining polynomial x^3 - 2 sage: type(I) @@ -466,6 +475,7 @@ def _repr_short(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^4 + 389); K Number Field in a with defining polynomial x^4 + 389 sage: I = K.factor(17)[0][0]; I @@ -502,6 +512,7 @@ def _gens_repr(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: sage.rings.number_field.number_field_ideal.SMALL_DISC 1000000 sage: K. = NumberField(x^4 + 3*x^2 - 17) @@ -536,6 +547,7 @@ def __pari__(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 23) sage: I = K.class_group().0.ideal(); I Fractional ideal (2, 1/2*w - 1/2) @@ -550,6 +562,7 @@ def _pari_init_(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 23) sage: I = K.class_group().0.ideal() sage: I._pari_init_() @@ -563,6 +576,7 @@ def pari_hnf(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^3 - 2) sage: I = K.ideal(2/(5+a)) @@ -610,6 +624,7 @@ def basis(self): Number fields defined by non-monic and non-integral polynomials are supported (:trac:`252`):: + sage: x = polygen(ZZ) sage: K. = NumberField(2*x^2 - 1/3) sage: K.ideal(a).basis() [1, a] @@ -665,6 +680,7 @@ def free_module(self): This also works for relative extensions:: + sage: x = polygen(ZZ) sage: K. = NumberField([x^2 + 1, x^2 + 2]) sage: I = K.fractional_ideal(4) sage: I.free_module() @@ -721,6 +737,7 @@ def reduce_equiv(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 23) sage: I = ideal(w*23^5); I Fractional ideal (6436343*w) @@ -748,6 +765,7 @@ def gens_reduced(self, proof=None): EXAMPLES:: + sage: x = polygen(ZZ) sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^2 + 5) sage: K.ideal(0).gens_reduced() @@ -810,6 +828,7 @@ def gens_two(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^2 + 5) sage: J = K.ideal([a + 2, 9]) @@ -861,6 +880,7 @@ def integral_basis(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^2 + 1) sage: J = K.ideal(i + 1) @@ -877,6 +897,7 @@ def integral_split(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^2 - 5) sage: I = K.ideal(2/(5+a)) @@ -923,6 +944,7 @@ def intersection(self, other): An example with non-principal ideals:: + sage: x = polygen(ZZ) sage: L. = NumberField(x^3 - 7) sage: p = L.ideal(a^2 + a + 1, 2) sage: q = L.ideal(a + 1) @@ -1152,7 +1174,7 @@ def is_principal(self, proof=None): sage: I = P^5 sage: I.is_principal() True - sage: I # random + sage: I # random Fractional ideal (-1/2*a + 3/2) sage: P = K.ideal([2]).factor()[1][0] sage: I = P^5 @@ -1197,6 +1219,7 @@ def ideal_class_log(self, proof=None): An example with a more complicated class group:: + sage: x = polygen(ZZ) sage: K. = NumberField([x^3 - x + 1, x^2 + 26]) sage: K.class_group() Class group of order 18 with structure C6 x C3 of @@ -1254,6 +1277,7 @@ def is_zero(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 2); K Number Field in a with defining polynomial x^2 + 2 sage: K.ideal(3).is_zero() @@ -1271,6 +1295,7 @@ def norm(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^4 + 23); K Number Field in a with defining polynomial x^4 + 23 sage: I = K.ideal(19); I @@ -1296,6 +1321,7 @@ def absolute_norm(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: K.ideal(1 + 2*i).absolute_norm() 5 @@ -1308,6 +1334,7 @@ def relative_norm(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: K.ideal(1 + 2*i).relative_norm() 5 @@ -1320,6 +1347,7 @@ def absolute_ramification_index(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: K.ideal(1 + i).absolute_ramification_index() 2 @@ -1332,6 +1360,7 @@ def relative_ramification_index(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: K.ideal(1 + i).relative_ramification_index() 2 @@ -1344,6 +1373,7 @@ def number_field(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 2); K Number Field in a with defining polynomial x^2 + 2 sage: K.ideal(3).number_field() @@ -1426,6 +1456,7 @@ def valuation(self, p): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^5 + 2); K Number Field in a with defining polynomial x^5 + 2 sage: i = K.ideal(38); i @@ -1520,6 +1551,7 @@ def random_element(self, *args, **kwds): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 2) sage: I = K.ideal(1 - a) sage: I.random_element() # random output @@ -1599,6 +1631,7 @@ def residue_symbol(self, e, m, check=True): Quadratic Residue (7 is not a square modulo 11):: + sage: x = polygen(ZZ) sage: K. = NumberField(x - 1) sage: K.ideal(11).residue_symbol(7,2) -1 @@ -1693,8 +1726,8 @@ def _quadratic_form(self): This is not defined for higher-degree extensions:: - sage: x = var('x') - sage: K. = NumberField(x**3-x-1) + sage: x = polygen(ZZ) + sage: K. = NumberField(x**3 - x - 1) sage: K.ideal(a)._quadratic_form() Traceback (most recent call last): ... @@ -1732,6 +1765,7 @@ def basis_to_module(B, K): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^4 + 1) sage: from sage.rings.number_field.number_field_ideal import basis_to_module sage: basis_to_module([K.0, K.0^2 + 3], K) @@ -1756,6 +1790,8 @@ def is_NumberFieldIdeal(x): False sage: is_NumberFieldIdeal(ideal(5)) False + + sage: x = polygen(ZZ) sage: k. = NumberField(x^2 + 2) sage: I = k.ideal([a + 1]); I Fractional ideal (a + 1) @@ -1775,6 +1811,7 @@ class NumberFieldFractionalIdeal(MultiplicativeGroupElement, NumberFieldIdeal, I EXAMPLES:: + sage: x = polygen(ZZ) sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^3 - 2) sage: I = K.ideal(2/(5+a)) @@ -1799,6 +1836,7 @@ def __init__(self, field, gens, coerce=True): EXAMPLES:: + sage: x = polygen(ZZ) sage: NumberField(x^2 + 1, 'a').ideal(7) Fractional ideal (7) """ @@ -1826,6 +1864,7 @@ def __repr__(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 5) sage: I = K.ideal([2,1+a]); I Fractional ideal (2, a + 1) @@ -1861,6 +1900,7 @@ def factor(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^4 + 23); K Number Field in a with defining polynomial x^4 + 23 sage: I = K.ideal(19); I @@ -1916,6 +1956,7 @@ def prime_factors(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 23) sage: I = ideal(w+1) sage: I.prime_factors() @@ -1933,6 +1974,7 @@ def _div_(self, other): EXAMPLES:: + sage: x = polygen(ZZ) sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^2 - 5) sage: I = K.ideal(2/(5+a)) @@ -1953,6 +1995,7 @@ def __invert__(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: R. = PolynomialRing(QQ) sage: K. = NumberField(x^3 - 2) sage: I = K.ideal(2/(5+a)) @@ -1977,6 +2020,7 @@ def is_maximal(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 3); K Number Field in a with defining polynomial x^3 + 3 sage: K.ideal(5).is_maximal() @@ -1999,7 +2043,7 @@ def is_trivial(self, proof=None): sage: J = F.ideal(5) sage: J.is_trivial() False - sage: (I+J).is_trivial() + sage: (I + J).is_trivial() True """ return self == self.number_field().ideal(1) @@ -2015,6 +2059,7 @@ def ramification_index(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 2); K Number Field in a with defining polynomial x^2 + 2 sage: f = K.factor(2); f @@ -2061,6 +2106,7 @@ def reduce(self, f): EXAMPLES:: + sage: x = polygen(ZZ) sage: k. = NumberField(x^3 + 11) sage: I = k.ideal(5, a^2 - a + 1) sage: c = 4*a + 9 @@ -2152,7 +2198,8 @@ def residues(self): EXAMPLES:: - sage: K.=NumberField(x^2 + 1) + sage: x = polygen(ZZ) + sage: K. = NumberField(x^2 + 1) sage: res = K.ideal(2).residues(); res xmrange_iter([[0, 1], [0, 1]], at 0x...>) sage: list(res) @@ -2216,6 +2263,7 @@ def invertible_residues(self, reduce=True): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: ires = K.ideal(2).invertible_residues(); ires xmrange_iter([[0, 1]], at 0x...>) @@ -2286,6 +2334,7 @@ def invertible_residues_mod(self, subgp_gens=[], reduce=True): :: + sage: x = polygen(ZZ) sage: k. = NumberField(x^2 + 23) sage: I = k.ideal(a) sage: list(I.invertible_residues_mod([-1])) @@ -2356,7 +2405,8 @@ def denominator(self): EXAMPLES:: - sage: K.=NumberField(x^2 + 1) + sage: x = polygen(ZZ) + sage: K. = NumberField(x^2 + 1) sage: I = K.ideal((3+4*i)/5); I Fractional ideal (4/5*i + 3/5) sage: I.denominator() @@ -2386,7 +2436,8 @@ def numerator(self): EXAMPLES:: - sage: K.=NumberField(x^2 + 1) + sage: x = polygen(ZZ) + sage: K. = NumberField(x^2 + 1) sage: I = K.ideal((3+4*i)/5); I Fractional ideal (4/5*i + 3/5) sage: I.denominator() @@ -2429,6 +2480,7 @@ def is_coprime(self, other): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: I = K.ideal(2 + i) sage: J = K.ideal(2 - i) @@ -2472,7 +2524,7 @@ def is_coprime(self, other): N1 = self.numerator() D2 = other.denominator() N2 = other.numerator() - return N1+N2==one and N1+D2==one and D1+N2==one and D1+D2==one + return N1+N2 == one and N1+D2 == one and D1+N2 == one and D1+D2 == one def idealcoprime(self, J): """ @@ -2492,6 +2544,7 @@ def idealcoprime(self, J): EXAMPLES:: + sage: x = polygen(ZZ) sage: k. = NumberField(x^2 + 23) sage: A = k.ideal(a + 1) sage: B = k.ideal(3) @@ -2542,6 +2595,7 @@ def small_residue(self, f): :: + sage: x = polygen(ZZ) sage: k. = NumberField(x^2 + 5) sage: I = k.ideal(a) sage: I.small_residue(14) @@ -2576,6 +2630,7 @@ def _pari_bid_(self, flag=1): EXAMPLES:: + sage: x = polygen(ZZ) sage: k. = NumberField(x^4 + 13) sage: I = k.ideal(2, a^2 + 1) sage: hasattr(I, '_bid') @@ -2627,6 +2682,7 @@ def idealstar(self, flag=1): EXAMPLES:: + sage: x = polygen(ZZ) sage: k. = NumberField(x^3 - 11) sage: A = k.ideal(5) sage: G = A.idealstar(); G @@ -2651,7 +2707,7 @@ def idealstar(self, flag=1): ALGORITHM: Uses Pari function :pari:`idealstar` """ k = self.number_field() - if flag==0 and not hasattr(self, '_bid'): + if flag == 0 and not hasattr(self, '_bid'): G = k.pari_nf().idealstar(self.pari_hnf(), 0) else: G = self._pari_bid_(flag) @@ -2699,6 +2755,7 @@ def ideallog(self, x, gens=None, check=True): EXAMPLES:: + sage: x = polygen(ZZ) sage: k. = NumberField(x^3 - 11) sage: A = k.ideal(5) sage: G = A.idealstar(2) @@ -2810,6 +2867,7 @@ def element_1_mod(self, other): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 - 2) sage: A = K.ideal(a + 1); A; A.norm() Fractional ideal (a + 1) @@ -2870,6 +2928,7 @@ def euler_phi(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1) sage: I = K.ideal(2 + i) sage: [r for r in I.residues() if I.is_coprime(r)] @@ -2918,6 +2977,7 @@ def prime_to_S_part(self, S): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 - 23) sage: I = K.ideal(24) sage: S = [K.ideal(-a + 5), K.ideal(5)] @@ -2963,7 +3023,8 @@ def is_S_unit(self, S): EXAMPLES:: - sage: K. = NumberField(x^2+23) + sage: x = polygen(ZZ) + sage: K. = NumberField(x^2 + 23) sage: I = K.ideal(2) sage: P = I.factor()[0][0] sage: I.is_S_unit([P]) @@ -2994,9 +3055,10 @@ def is_S_integral(self, S): EXAMPLES:: - sage: K. = NumberField(x^2+23) + sage: x = polygen(ZZ) + sage: K. = NumberField(x^2 + 23) sage: I = K.ideal(1/2) - sage: P = K.ideal(2,1/2*a - 1/2) + sage: P = K.ideal(2, 1/2*a - 1/2) sage: I.is_S_integral([P]) False @@ -3025,6 +3087,7 @@ def prime_to_idealM_part(self, M): EXAMPLES:: + sage: x = polygen(ZZ) sage: k. = NumberField(x^2 + 23) sage: I = k.ideal(a + 1) sage: M = k.ideal(2, 1/2*a - 1/2) @@ -3072,6 +3135,7 @@ def _p_quotient(self, p): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1); O = K.maximal_order() sage: I = K.factor(3)[0][0] sage: Q, quo, lift = I._p_quotient(3); Q @@ -3120,6 +3184,7 @@ def residue_field(self, names=None): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 - 7) sage: P = K.ideal(29).factor()[0][0] sage: P.residue_field() @@ -3208,6 +3273,7 @@ def residue_class_degree(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^5 + 2); K Number Field in a with defining polynomial x^5 + 2 sage: f = K.factor(19); f @@ -3252,6 +3318,7 @@ def is_NumberFieldFractionalIdeal(x): False sage: is_NumberFieldFractionalIdeal(ideal(5)) False + sage: x = polygen(ZZ) sage: k. = NumberField(x^2 + 2) sage: I = k.ideal([a + 1]); I Fractional ideal (a + 1) @@ -3278,6 +3345,7 @@ def __init__(self, K, M_OK_change, Q, I): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 4) sage: f = K.ideal(1 + a^2/2).residue_field().reduction_map(); f # indirect doctest Partially defined reduction map: @@ -3302,6 +3370,7 @@ def __call__(self, x): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 4) sage: f = K.ideal(1 + a^2/2).residue_field().reduction_map() sage: f(a) @@ -3317,6 +3386,7 @@ def __repr__(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 4) sage: f = K.ideal(1 + a^2/2).residue_field().reduction_map() sage: repr(f) @@ -3336,6 +3406,7 @@ def __init__(self, OK, M_OK_map, Q, I): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 4) sage: I = K.ideal(1 + a^2/2) sage: f = I.residue_field().lift_map() @@ -3354,6 +3425,7 @@ def __call__(self, x): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 4) sage: R = K.ideal(1 + a^2/2).residue_field() sage: f = R.lift_map() @@ -3382,6 +3454,7 @@ def __repr__(self): EXAMPLES:: + sage: x = polygen(ZZ) sage: K. = NumberField(x^3 + 4) sage: R = K.ideal(1 + a^2/2).residue_field() sage: repr(R.lift_map()) @@ -3400,6 +3473,7 @@ def quotient_char_p(I, p): sage: from sage.rings.number_field.number_field_ideal import quotient_char_p + sage: x = polygen(ZZ) sage: K. = NumberField(x^2 + 1); O = K.maximal_order(); I = K.fractional_ideal(15) sage: quotient_char_p(I, 5)[0] Vector space quotient V/W of dimension 2 over Finite Field of size 5 where diff --git a/src/sage/rings/number_field/number_field_ideal_rel.py b/src/sage/rings/number_field/number_field_ideal_rel.py index e19d0df9c1c..5ef403e7e23 100644 --- a/src/sage/rings/number_field/number_field_ideal_rel.py +++ b/src/sage/rings/number_field/number_field_ideal_rel.py @@ -687,7 +687,7 @@ def absolute_ramification_index(self): """ if self.is_prime(): return self.absolute_ideal().ramification_index() - raise ValueError("the fractional ideal (= %s) is not prime"%self) + raise ValueError("the fractional ideal (= %s) is not prime" % self) def relative_ramification_index(self): """ @@ -722,7 +722,7 @@ def relative_ramification_index(self): abs_index = self.absolute_ramification_index() base_ideal = self.ideal_below() return ZZ(abs_index/base_ideal.absolute_ramification_index()) - raise ValueError("the fractional ideal (= %s) is not prime"%self) + raise ValueError("the fractional ideal (= %s) is not prime" % self) def ramification_index(self): r""" @@ -758,7 +758,7 @@ def residue_class_degree(self): """ if self.is_prime(): return self.absolute_ideal().residue_class_degree() - raise ValueError("the ideal (= %s) is not prime"%self) + raise ValueError("the ideal (= %s) is not prime" % self) def residues(self): """ @@ -815,14 +815,14 @@ def element_1_mod(self, other): # Catch invalid inputs by making sure that we can make an ideal out of other. K = self.number_field() if not self.is_integral(): - raise TypeError("%s is not an integral ideal"%self) + raise TypeError("%s is not an integral ideal" % self) other = K.ideal(other) if not other.is_integral(): - raise TypeError("%s is not an integral ideal"%other) + raise TypeError("%s is not an integral ideal" % other) if not self.is_coprime(other): - raise TypeError("%s and %s are not coprime ideals"%(self, other)) + raise TypeError("%s and %s are not coprime ideals" % (self, other)) to_K = K.absolute_field('a').structure()[0] return to_K(self.absolute_ideal().element_1_mod(other.absolute_ideal())) @@ -874,13 +874,13 @@ def valuation(self, p): ValueError: p (= Fractional ideal (5)) must be a prime """ if p == 0: - raise ValueError("p (= %s) must be nonzero"%p) + raise ValueError("p (= %s) must be nonzero" % p) if not isinstance(p, NumberFieldFractionalIdeal): p = self.number_field().ideal(p) if not p.is_prime(): - raise ValueError("p (= %s) must be a prime"%p) + raise ValueError("p (= %s) must be a prime" % p) if p.ring() != self.number_field(): - raise ValueError("p (= %s) must be an ideal in %s"%self.number_field()) + raise ValueError("p (= %s) must be an ideal in %s" % self.number_field()) return self.absolute_ideal().valuation(p.absolute_ideal()) def is_NumberFieldFractionalIdeal_rel(x): diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py index 2e2989d413f..1e8a6a17fe1 100644 --- a/src/sage/rings/number_field/number_field_rel.py +++ b/src/sage/rings/number_field/number_field_rel.py @@ -281,7 +281,7 @@ def __init__(self, base, polynomial, name, if names is not None: name = names if not isinstance(base, NumberField_base): - raise TypeError("base (=%s) must be a number field"%base) + raise TypeError("base (=%s) must be a number field" % base) if not isinstance(polynomial, polynomial_element.Polynomial): try: polynomial = polynomial.polynomial(base) @@ -313,7 +313,7 @@ def __init__(self, base, polynomial, name, self._element_class = number_field_element.NumberFieldElement_relative if check and not self.pari_relative_polynomial().polisirreducible(): - raise ValueError("defining polynomial (%s) must be irreducible"%polynomial) + raise ValueError("defining polynomial (%s) must be irreducible" % polynomial) names = (name,) + base.variable_names() self._assign_names(tuple(names), normalize=False) @@ -463,7 +463,7 @@ def subfields(self, degree=0, name=None): if to_K is not None: to_K = RelativeNumberFieldHomomorphism_from_abs(self.Hom(K), to_K*to_abs) ans.append((K, from_K, to_K)) - ans = Sequence(ans, immutable=True, cr=ans!=[]) + ans = Sequence(ans, immutable=True, cr=bool(ans)) return ans def is_absolute(self): @@ -753,7 +753,7 @@ def _repr_(self): Number Field in b with defining polynomial x^7 + 3 """ - return "Number Field in %s with defining polynomial %s over its base field"%(self.variable_name(), self.relative_polynomial()) + return "Number Field in %s with defining polynomial %s over its base field" % (self.variable_name(), self.relative_polynomial()) def _Hom_(self, codomain, category=None): """ @@ -798,7 +798,7 @@ def _latex_(self): '( \\Bold{Q}[a]/(a^{3} - 2) )[b]/(b^{2} + b + a)' """ latex_name = self.latex_variable_names()[0] - return "( %s )[%s]/(%s)"%(latex(self.base_field()), latex_name, + return "( %s )[%s]/(%s)" % (latex(self.base_field()), latex_name, self.relative_polynomial()._latex_(latex_name)) def _coerce_from_other_number_field(self, x): @@ -2077,7 +2077,7 @@ def embeddings(self, K): # then it is most natural, so we put it first. put_natural_embedding_first(v) - self.__embeddings[K] = Sequence(v, cr=v!=[], immutable=True, check=False, universe=self.Hom(K)) + self.__embeddings[K] = Sequence(v, cr=bool(v), immutable=True, check=False, universe=self.Hom(K)) return self.__embeddings[K] def automorphisms(self): @@ -2152,13 +2152,14 @@ def automorphisms(self): L = self.absolute_field('a') L_into_self, self_into_L = L.structure() - aas = L.automorphisms() # absolute automorphisms + aas = L.automorphisms() # absolute automorphisms a = self_into_L(self.gen()) abs_base_gens = [self_into_L(_) for _ in self.base_field().gens()] - v = sorted([ self.hom([ L_into_self(aa(a)) ]) for aa in aas if all(aa(g) == g for g in abs_base_gens) ]) + v = sorted([self.hom([L_into_self(aa(a))]) for aa in aas + if all(aa(g) == g for g in abs_base_gens)]) put_natural_embedding_first(v) - self.__automorphisms = Sequence(v, cr=(v != []), immutable=True, + self.__automorphisms = Sequence(v, cr=bool(v), immutable=True, check=False, universe=self.Hom(self)) return self.__automorphisms @@ -2576,7 +2577,7 @@ def lift_to_base(self, element): # Now we should have a polynomial in the variable y. # Otherwise we're not in the base field. if r.type() != "t_POL" or str(r.variable()) != 'y': - raise ValueError("The element %s is not in the base field"%element) + raise ValueError("The element %s is not in the base field" % element) return self.base_field()(r, check=False) def relativize(self, alpha, names): @@ -2711,7 +2712,7 @@ def uniformizer(self, P, others="positive"): if not is_NumberFieldIdeal(P): P = self.ideal(P) if not P.is_maximal(): - raise ValueError("P (=%s) must be a nonzero prime."%P) + raise ValueError("P (=%s) must be a nonzero prime." % P) abs = self.absolute_field('a') from_abs = abs.structure()[0] return from_abs(abs.uniformizer(P.absolute_ideal(), others=others)) diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py index 77e1f4a84d8..37abe43101e 100644 --- a/src/sage/rings/number_field/selmer_group.py +++ b/src/sage/rings/number_field/selmer_group.py @@ -286,7 +286,7 @@ def coords_in_U_mod_p(u, U, p): """ coords = U.log(u) start = 1 - int(p.divides(U.zeta_order())) # 0 or 1 - return [c%p for c in coords[start:]] + return [c % p for c in coords[start:]] def basis_for_p_cokernel(S, C, p): r""" @@ -548,7 +548,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False): hK = 1 if K == QQ else K.class_number(proof=proof) C = K.class_group() if K == QQ else K.class_group(proof=proof) - hKp = (hK%p == 0) # flag whether the class number is divisible by p + hKp = (hK % p == 0) # flag whether the class number is divisible by p if K == QQ: if p == 2: @@ -684,7 +684,7 @@ def to_KSp(a): if debug: print("B={}".format(B)) - a3 = B if K==QQ else _ideal_generator(B) + a3 = B if K == QQ else _ideal_generator(B) if debug: print("a3={}".format(a3)) a /= a3 ** p @@ -699,7 +699,7 @@ def to_KSp(a): if debug: if K == QQ: - assert a.abs()==1 + assert a.abs() == 1 else: assert K.ideal(a).is_one() diff --git a/src/sage/rings/number_field/splitting_field.py b/src/sage/rings/number_field/splitting_field.py index 448adc6b529..927ecb3b5fb 100644 --- a/src/sage/rings/number_field/splitting_field.py +++ b/src/sage/rings/number_field/splitting_field.py @@ -109,7 +109,7 @@ def __repr__(self): sage: print(SplittingData(pari("polcyclo(24)"), 2)) SplittingData(x^8 - x^4 + 1, 2) """ - return "SplittingData(%s, %s)"%(self.pol, self.dm) + return "SplittingData(%s, %s)" % (self.pol, self.dm) def _repr_tuple(self): """ @@ -391,7 +391,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No # (only needed if map=True) if map: Fgen = F.gen().__pari__() - verbose("Starting field: %s"%Kpol) + verbose("Starting field: %s" % Kpol) # L and Lred are lists of SplittingData. # L contains polynomials which are irreducible over K, @@ -415,7 +415,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No raise SplittingFieldAbort(absolute_degree * rel_degree_divisor, degree_multiple) # First, factor polynomials in Lred and store the result in L - verbose("SplittingData to factor: %s"%[s._repr_tuple() for s in Lred]) + verbose("SplittingData to factor: %s" % [s._repr_tuple() for s in Lred]) t = cputime() for splitting in Lred: m = splitting.dm.gcd(degree_multiple).gcd(factorial(splitting.poldegree())) @@ -455,7 +455,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No # Compute cubic resolvent a0, a1, a2, a3, a4 = (q/q.pollead()).Vecrev() assert a4 == 1 - cubicpol = pari([4*a0*a2 - a1*a1 -a0*a3*a3, a1*a3 - 4*a0, -a2, 1]).Polrev() + cubicpol = pari([4*a0*a2 - a1*a1 - a0*a3*a3, a1*a3 - 4*a0, -a2, 1]).Polrev() cubicfactors = Kpol.nffactor(cubicpol)[0] if len(cubicfactors) == 1: # A4 or S4 # After adding a root of the cubic resolvent, @@ -505,8 +505,8 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No # Sort according to degree to handle low degrees first L.sort(key=lambda x: x.key()) - verbose("SplittingData to handle: %s"%[s._repr_tuple() for s in L]) - verbose("Bounds for absolute degree: [%s, %s]"%(degree_divisor,degree_multiple)) + verbose("SplittingData to handle: %s" % [s._repr_tuple() for s in L]) + verbose("Bounds for absolute degree: [%s, %s]" % (degree_divisor,degree_multiple)) # Check consistency if degree_multiple % degree_divisor != 0: @@ -525,7 +525,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No # Add a root of f = L[0] to construct the field N = K[x]/f(x) splitting = L[0] f = splitting.pol - verbose("Handling polynomial %s"%(f.lift()), level=2) + verbose("Handling polynomial %s" % (f.lift()), level=2) t = cputime() Npol, KtoN, k = Kpol.rnfequation(f, flag=1) @@ -547,7 +547,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No if simplify_all or (simplify and not finished): # Find a simpler defining polynomial Lpol for Mpol - verbose("New field before simplifying: %s"%Mpol, t) + verbose("New field before simplifying: %s" % Mpol, t) t = cputime() M = Mpol.polred(flag=3) n = len(M[0])-1 @@ -562,7 +562,7 @@ def splitting_field(poly, name, map=False, degree_multiple=None, abort_degree=No NtoL = MtoL/Mdiv KtoL = KtoN.lift().subst("x", NtoL).Mod(Lpol) Kpol = Lpol # New Kpol (for next iteration) - verbose("New field: %s"%Kpol, t) + verbose("New field: %s" % Kpol, t) if map: t = cputime() Fgen = Fgen.lift().subst("y", KtoL) diff --git a/src/sage/rings/number_field/totallyreal_phc.py b/src/sage/rings/number_field/totallyreal_phc.py index 890a0a2f469..4143feb67b3 100644 --- a/src/sage/rings/number_field/totallyreal_phc.py +++ b/src/sage/rings/number_field/totallyreal_phc.py @@ -126,12 +126,12 @@ def __lagrange_bounds_phc(n, m, a, tmpfile=None): for P in sage.combinat.partition.Partitions(n-1,length=m-1): f = open(tmpfile, 'w') # First line: number of variables/equations - f.write('%d'%m + '\n') + f.write('%d' % m + '\n') # In the next m-1 lines, write the equation S_j(x) = S[j] for j in range(1,m+1): for i in range(m-1): - f.write('%d'%P[i] + '*x%d'%i + '**%d'%j + ' + ') - f.write('xn**%d'%j + ' - (%d'%S[j] + ');\n') + f.write('%d' % P[i] + '*x%d' % i + '**%d' % j + ' + ') + f.write('xn**%d' % j + ' - (%d' % S[j] + ');\n') f.close() os.remove(tmpfile + '.phc') diff --git a/src/sage/rings/number_field/totallyreal_rel.py b/src/sage/rings/number_field/totallyreal_rel.py index 65026b38885..d7039c26c86 100644 --- a/src/sage/rings/number_field/totallyreal_rel.py +++ b/src/sage/rings/number_field/totallyreal_rel.py @@ -300,7 +300,7 @@ def __init__(self, F, m, B, a=None): import numpy for i in range(len(anm1s)): Q = [[v(m*x) for v in self.Foo] + [0] for x in Z_Fbasis] + [[v(anm1s[i]) for v in self.Foo] + [10**6]] - pari_string = '['+';'.join([','.join(["%s"%ii for ii in row]) for row in zip(*Q)])+']' + pari_string = '['+';'.join([','.join(["%s" % ii for ii in row]) for row in zip(*Q)])+']' adj = pari(pari_string).qflll()[self.d] anm1s[i] += sum([m*Z_Fbasis[ii]*int(adj[ii])//int(adj[self.d]) for ii in range(self.d)]) @@ -322,7 +322,7 @@ def __init__(self, F, m, B, a=None): # currently unknown; e.g., if k == -1, then we can iterate # over polynomials, and if k == n-1, then we have finished iterating. if a[len(a)-1] != 1: - raise ValueError("a[len(a)-1](=%s) must be 1 so polynomial is monic"%a[len(a)-1]) + raise ValueError("a[len(a)-1](=%s) must be 1 so polynomial is monic" % a[len(a)-1]) raise NotImplementedError("These have not been checked.") diff --git a/src/sage/rings/number_field/unit_group.py b/src/sage/rings/number_field/unit_group.py index 42c3933219b..5f9d5c0654c 100644 --- a/src/sage/rings/number_field/unit_group.py +++ b/src/sage/rings/number_field/unit_group.py @@ -321,12 +321,12 @@ def __init__(self, number_field, proof=True, S=None): try: S = tuple(K.ideal(S).prime_factors()) except (NameError, TypeError, ValueError): - raise ValueError("Cannot make a set of primes from %s"%(S,)) + raise ValueError("Cannot make a set of primes from %s" % (S,)) else: try: S = tuple(K.ideal(P) for P in S) except (NameError, TypeError, ValueError): - raise ValueError("Cannot make a set of primes from %s"%(S,)) + raise ValueError("Cannot make a set of primes from %s" % (S,)) if not all(P.is_prime() for P in S): raise ValueError("Not all elements of %s are prime ideals" % (S,)) self.__S = S @@ -398,14 +398,14 @@ def _element_constructor_(self, u): try: u = K(u) except TypeError: - raise ValueError("%s is not an element of %s"%(u,K)) + raise ValueError("%s is not an element of %s" % (u,K)) if self.__S: m = pK.bnfisunit(pari(u), self.__S_unit_data).mattranspose() if m.ncols() == 0: - raise ValueError("%s is not an S-unit"%u) + raise ValueError("%s is not an S-unit" % u) else: if not u.is_integral() or u.norm().abs() != 1: - raise ValueError("%s is not a unit"%u) + raise ValueError("%s is not a unit" % u) m = pK.bnfisunit(pari(u)).mattranspose() # convert column matrix to a list: @@ -448,11 +448,11 @@ def _repr_(self): with S = (Fractional ideal (a),) """ if self.__S: - return 'S-unit group with structure %s of %s with S = %s'%( + return 'S-unit group with structure %s of %s with S = %s' % ( self._group_notation(self.gens_orders()), self.number_field(), self.primes()) - return 'Unit group with structure %s of %s'%( + return 'Unit group with structure %s of %s' % ( self._group_notation(self.gens_orders()), self.number_field()) @@ -561,7 +561,7 @@ def zeta(self, n=2, all=False): K = self.number_field() n = ZZ(n) if n <= 0: - raise ValueError("n (=%s) must be positive"%n) + raise ValueError("n (=%s) must be positive" % n) if n == 1: if all: return [K(1)] @@ -582,7 +582,7 @@ def zeta(self, n=2, all=False): if all: return [] else: - raise ValueError("n (=%s) does not divide order of generator"%n) + raise ValueError("n (=%s) does not divide order of generator" % n) def number_field(self): """ diff --git a/src/sage/rings/numbers_abc.py b/src/sage/rings/numbers_abc.py index 6bbcddccf40..a28021dd7db 100644 --- a/src/sage/rings/numbers_abc.py +++ b/src/sage/rings/numbers_abc.py @@ -41,26 +41,26 @@ def register_sage_classes(): True sage: isinstance(CDF(1.3, 4), numbers.Complex) True - sage: isinstance(AA(sqrt(2)), numbers.Real) + sage: isinstance(AA(sqrt(2)), numbers.Real) # needs sage.rings.number_field sage.symbolic True - sage: isinstance(QQbar(I), numbers.Complex) + sage: isinstance(QQbar(I), numbers.Complex) # needs sage.rings.number_field True This doesn't work with symbolic expressions at all:: - sage: isinstance(pi, numbers.Real) + sage: isinstance(pi, numbers.Real) # needs sage.symbolic False - sage: isinstance(I, numbers.Complex) + sage: isinstance(I, numbers.Complex) # needs sage.rings.number_field False - sage: isinstance(sqrt(2), numbers.Real) + sage: isinstance(sqrt(2), numbers.Real) # needs sage.rings.number_field sage.symbolic False Because we do this, NumPy's ``isscalar()`` recognizes Sage types:: - sage: from numpy import isscalar # optional - numpy - sage: isscalar(3.141) # optional - numpy + sage: from numpy import isscalar # needs numpy + sage: isscalar(3.141) # needs numpy True - sage: isscalar(4/17) # optional - numpy + sage: isscalar(4/17) # needs numpy True """ from sage.misc.superseded import deprecation diff --git a/src/sage/rings/padics/FM_template.pxi b/src/sage/rings/padics/FM_template.pxi index f47200074ea..3bae827a08c 100644 --- a/src/sage/rings/padics/FM_template.pxi +++ b/src/sage/rings/padics/FM_template.pxi @@ -34,7 +34,7 @@ AUTHORS: #***************************************************************************** include "padic_template_element.pxi" -from cpython.int cimport * +from cpython.long cimport * from sage.structure.element cimport Element from sage.rings.padics.common_conversion cimport comb_prec, _process_args_and_kwds diff --git a/src/sage/rings/padics/FP_template.pxi b/src/sage/rings/padics/FP_template.pxi index c718c0a5f8d..d253d208410 100644 --- a/src/sage/rings/padics/FP_template.pxi +++ b/src/sage/rings/padics/FP_template.pxi @@ -35,7 +35,7 @@ AUTHORS: from sage.ext.stdsage cimport PY_NEW include "padic_template_element.pxi" -from cpython.int cimport * +from cpython.long cimport * from sage.structure.element cimport Element from sage.rings.padics.common_conversion cimport comb_prec, _process_args_and_kwds diff --git a/src/sage/rings/padics/common_conversion.pyx b/src/sage/rings/padics/common_conversion.pyx index 4ed5570d306..0afddcc30a4 100644 --- a/src/sage/rings/padics/common_conversion.pyx +++ b/src/sage/rings/padics/common_conversion.pyx @@ -26,7 +26,7 @@ AUTHORS: # https://www.gnu.org/licenses/ # **************************************************************************** -from cpython.int cimport * +from cpython.long cimport * from sage.ext.stdsage cimport PY_NEW from sage.libs.gmp.all cimport * from sage.arith.rational_reconstruction cimport mpq_rational_reconstruction @@ -84,7 +84,7 @@ cdef long get_ordp(x, PowComputer_class prime_pow) except? -10000: if x == 0: return maxordp try: - n = PyInt_AsLong(x) + n = PyLong_AsLong(x) except OverflowError: return get_ordp(Integer(x), prime_pow) else: @@ -250,7 +250,7 @@ cdef long comb_prec(iprec, long prec) except? -10000: raise OverflowError("precision overflow") return mpz_get_si(intprec.value) if isinstance(iprec, int): - return min(PyInt_AS_LONG(iprec), prec) + return min(PyLong_AsLong(iprec), prec) return comb_prec(Integer(iprec), prec) cdef int _process_args_and_kwds(long *aprec, long *rprec, args, kwds, bint absolute, PowComputer_class prime_pow) except -1: @@ -405,7 +405,7 @@ cdef inline int cconv_shared(mpz_t out, x, long prec, long valshift, PowComputer - ``prime_pow`` -- a PowComputer for the ring. """ - if PyInt_Check(x): + if PyLong_Check(x): x = Integer(x) elif isinstance(x, pari_gen): x = x.sage() diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py index e001b9e5086..d8d7c7e3c3b 100644 --- a/src/sage/rings/padics/factory.py +++ b/src/sage/rings/padics/factory.py @@ -301,7 +301,7 @@ def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_se if not isinstance(print_ram_name, str): print_ram_name = str(print_ram_name) if names != print_ram_name: - raise ValueError("If both names (%s) and print_ram_name (%s) are specified, they must agree"%(names, print_ram_name)) + raise ValueError("If both names (%s) and print_ram_name (%s) are specified, they must agree" % (names, print_ram_name)) name = names else: if names is None: @@ -311,7 +311,7 @@ def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_se else: name = str(names) if type not in valid_types: - raise ValueError("type must be %s"%(", ".join(valid_types))) + raise ValueError("type must be %s" % (", ".join(valid_types))) show_prec = _canonicalize_show_prec(type, print_mode, show_prec) key = (p, prec, type, print_mode, name, print_pos, print_sep, tuple(print_alphabet), print_max_terms, show_prec, label) return key @@ -1343,7 +1343,7 @@ def Qq(q, prec=None, type='capped-rel', modulus=None, names=None, k = Integer(k) if check: - if not p.is_prime() or k <=0: + if not p.is_prime() or k <= 0: raise ValueError("q must be a prime power") if prec is not None and not isinstance(prec, Integer): diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py index c3d9dce2ded..0832f317b4d 100644 --- a/src/sage/rings/padics/generic_nodes.py +++ b/src/sage/rings/padics/generic_nodes.py @@ -1471,7 +1471,7 @@ def random_element(self, algorithm='default'): else: return self(ZZ.random_element(self.prime_pow.pow_Integer_Integer(self.precision_cap()))) else: - raise NotImplementedError("Don't know %s algorithm"%algorithm) + raise NotImplementedError("Don't know %s algorithm" % algorithm) #def unit_group(self): # raise NotImplementedError diff --git a/src/sage/rings/padics/lattice_precision.py b/src/sage/rings/padics/lattice_precision.py index d2ad57b869d..9c76ff88362 100644 --- a/src/sage/rings/padics/lattice_precision.py +++ b/src/sage/rings/padics/lattice_precision.py @@ -676,9 +676,9 @@ def _repr_(self): sage: R.precision() Precision lattice on 0 objects (label: mylabel) """ - label = "" if self._label is None else " (label: %s)"%(self._label,) - count = "1 object" if len(self._elements) == 1 else "%s objects"%len(self._elements) - return "%s on %s%s"%(self._repr_type, count, label) + label = "" if self._label is None else " (label: %s)" % (self._label,) + count = "1 object" if len(self._elements) == 1 else "%s objects" % len(self._elements) + return "%s on %s%s" % (self._repr_type, count, label) def threshold_deletion(self, threshold=None): r""" @@ -2786,7 +2786,7 @@ def __init__(self, element, callback=None): """ if not hasattr(element, '_proxy_id'): element._proxy_id = pAdicLatticeElementWeakProxy._next_id - pAdicLatticeElementWeakProxy._next_id +=1 + pAdicLatticeElementWeakProxy._next_id += 1 self._id = element._proxy_id from weakref import ref proxy_callback = callback @@ -2856,7 +2856,7 @@ def __repr__(self): [WeakProxy#...] """ - return "WeakProxy#%s"%(self._id,) + return "WeakProxy#%s" % (self._id,) def list_of_padics(elements): r""" diff --git a/src/sage/rings/padics/local_generic.py b/src/sage/rings/padics/local_generic.py index 6dbebfb5347..5726055d2be 100644 --- a/src/sage/rings/padics/local_generic.py +++ b/src/sage/rings/padics/local_generic.py @@ -452,7 +452,7 @@ def get_unramified_modulus(q, res_name): functor.extras = copy(functor.extras) functor.extras['print_mode'] = copy(functor.extras['print_mode']) if 'type' in kwds and kwds['type'] not in functor._dvr_types: - raise ValueError("completion type must be one of %s"%(", ".join(functor._dvr_types[1:]))) + raise ValueError("completion type must be one of %s" % (", ".join(functor._dvr_types[1:]))) if 'field' in kwds: field = kwds.pop('field') if field: @@ -493,7 +493,7 @@ def get_unramified_modulus(q, res_name): if atr in kwds: functor.extras['print_mode'][atr] = kwds.pop(atr) if kwds: - raise ValueError("Extra arguments received: %s"%(", ".join(kwds.keys()))) + raise ValueError("Extra arguments received: %s" % (", ".join(kwds.keys()))) if q is not None: # Create an unramified extension base = functor(ring) diff --git a/src/sage/rings/padics/misc.py b/src/sage/rings/padics/misc.py index 46b261c95dc..b535dbb07c5 100644 --- a/src/sage/rings/padics/misc.py +++ b/src/sage/rings/padics/misc.py @@ -201,10 +201,10 @@ def precprint(prec_type, prec_cap, p): sage: precprint('fixed-mod', 1, 17) 'of fixed modulus 17^1' """ - precD = {'capped-rel':'with capped relative precision %s'%prec_cap, - 'capped-abs':'with capped absolute precision %s'%prec_cap, - 'floating-point':'with floating precision %s'%prec_cap, - 'fixed-mod':'of fixed modulus %s^%s'%(p, prec_cap), + precD = {'capped-rel':'with capped relative precision %s' % prec_cap, + 'capped-abs':'with capped absolute precision %s' % prec_cap, + 'floating-point':'with floating precision %s' % prec_cap, + 'fixed-mod':'of fixed modulus %s^%s' % (p, prec_cap), 'lattice-cap':'with lattice-cap precision', 'lattice-float':'with lattice-float precision', 'relaxed':'handled with relaxed arithmetics'} diff --git a/src/sage/rings/padics/padic_base_generic.py b/src/sage/rings/padics/padic_base_generic.py index 56f241fd777..6fb5f464a7f 100644 --- a/src/sage/rings/padics/padic_base_generic.py +++ b/src/sage/rings/padics/padic_base_generic.py @@ -133,12 +133,12 @@ def _repr_(self, do_latex=False): else: s = r"\Bold{Z}_{%s}" % self.prime() if hasattr(self, '_label') and self._label: - s = r"\verb'%s' (\simeq %s)"%(self._label, s) + s = r"\verb'%s' (\simeq %s)" % (self._label, s) else: s = "Field " if self.is_field() else "Ring " - s = "%s-adic "%self.prime() + s + precprint(self._prec_type(), self.precision_cap(), self.prime()) + s = "%s-adic " % self.prime() + s + precprint(self._prec_type(), self.precision_cap(), self.prime()) if hasattr(self, '_label') and self._label: - s+= " (label: %s)"%self._label + s += " (label: %s)" % self._label return s def exact_field(self): @@ -387,7 +387,7 @@ def zeta(self, n=None): if n == 1: return self(1) else: - raise ValueError("No, %sth root of unity in self"%n) + raise ValueError("No, %sth root of unity in self" % n) else: from sage.rings.finite_rings.finite_field_constructor import GF return self.teichmuller(GF(self.prime()).zeta(n).lift()) diff --git a/src/sage/rings/padics/padic_base_leaves.py b/src/sage/rings/padics/padic_base_leaves.py index 8c4636e2904..1c47b0083c2 100644 --- a/src/sage/rings/padics/padic_base_leaves.py +++ b/src/sage/rings/padics/padic_base_leaves.py @@ -731,7 +731,7 @@ def random_element(self, algorithm='default'): a = ZZ.random_element(self.prime()**self.precision_cap()) return self(self.prime()**k * a, absprec=k + self.precision_cap()) else: - raise NotImplementedError("Don't know %s algorithm"%algorithm) + raise NotImplementedError("Don't know %s algorithm" % algorithm) class pAdicFieldFloatingPoint(pAdicFieldBaseGeneric, pAdicFloatingPointFieldGeneric): r""" diff --git a/src/sage/rings/padics/padic_generic.py b/src/sage/rings/padics/padic_generic.py index 769b8500c7d..a929ee60a75 100644 --- a/src/sage/rings/padics/padic_generic.py +++ b/src/sage/rings/padics/padic_generic.py @@ -1045,7 +1045,7 @@ def _test_teichmuller(self, **options): try: y = self.teichmuller(x) except ValueError: - tester.assertTrue(x.valuation() < 0 or x.precision_absolute()==0) + tester.assertTrue(x.valuation() < 0 or x.precision_absolute() == 0) else: try: tester.assertEqual(x.residue(), y.residue()) diff --git a/src/sage/rings/padics/padic_template_element.pxi b/src/sage/rings/padics/padic_template_element.pxi index a21494e5479..06cc00e73f0 100644 --- a/src/sage/rings/padics/padic_template_element.pxi +++ b/src/sage/rings/padics/padic_template_element.pxi @@ -22,7 +22,7 @@ AUTHORS: # https://www.gnu.org/licenses/ # **************************************************************************** -from cpython.int cimport * +from cpython.long cimport * from sage.libs.gmp.all cimport * import sage.rings.finite_rings.integer_mod @@ -253,7 +253,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): # The "verify that shift is an integer" part could be shared cdef long s if isinstance(shift, int): - s = PyInt_AS_LONG(shift) + s = PyLong_AsLong(shift) else: if not isinstance(shift, Integer): shift = Integer(shift) @@ -301,7 +301,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement): """ cdef long s if isinstance(shift, int): - s = PyInt_AS_LONG(shift) + s = PyLong_AsLong(shift) else: if not isinstance(shift, Integer): shift = Integer(shift) diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py index dbd8830a4d4..b6ea2ea75ee 100644 --- a/src/sage/rings/padics/padic_valuation.py +++ b/src/sage/rings/padics/padic_valuation.py @@ -136,7 +136,7 @@ def create_key_and_extra_args(self, R, prime=None, approximants=None): elif isinstance(R.fraction_field(), NumberField) or is_PolynomialQuotientRing(R): return self.create_key_and_extra_args_for_number_field(R, prime, approximants=approximants) else: - raise NotImplementedError("p-adic valuations not implemented for %r"%(R,)) + raise NotImplementedError("p-adic valuations not implemented for %r" % (R,)) def create_key_for_integers(self, R, prime): r""" @@ -156,7 +156,7 @@ def create_key_for_integers(self, R, prime): if isinstance(prime, DiscretePseudoValuation): prime = prime.uniformizer() if prime not in ZZ or not ZZ(prime).is_prime(): - raise ValueError("prime must be a prime in the integers but %s is not"%(prime,)) + raise ValueError("prime must be a prime in the integers but %s is not" % (prime,)) return R, prime def create_key_for_local_ring(self, R, prime): @@ -254,7 +254,7 @@ def create_key_and_extra_args_for_number_field_from_valuation(self, R, v, prime, # v is defined on a ring whose field of fractions is L v = v._base_valuation._initial_approximation.change_domain(G.parent()) else: - raise NotImplementedError("cannot rewrite %r which is defined on %r as a pseudo-valuation on %r"%(v, v.domain(), G.parent())) + raise NotImplementedError("cannot rewrite %r which is defined on %r as a pseudo-valuation on %r" % (v, v.domain(), G.parent())) assert(v.domain() is G.parent()) @@ -315,7 +315,7 @@ def create_key_and_extra_args_for_number_field_from_ideal(self, R, I, prime): p = I.relative_norm() F = p.factor() if len(F) != 1: - raise ValueError("%r does not lie over a single prime of %r"%(I, K)) + raise ValueError("%r does not lie over a single prime of %r" % (I, K)) vK = K.valuation(F[0][0]) approximants = vK.mac_lane_approximants(G, require_incomparability=True) @@ -336,7 +336,7 @@ def create_key_and_extra_args_for_number_field_from_ideal(self, R, I, prime): match = [i for (i, v) in enumerate(candidates) if v and all(v(g) > 0 for g in gens)] if len(match) > 1: - raise ValueError("%s does not single out a unique extension of %s to %s"%(prime, vK, L)) + raise ValueError("%s does not single out a unique extension of %s to %s" % (prime, vK, L)) if len(match) == 1: return (R, approximants[match[0]]), {'approximants': approximants} @@ -369,7 +369,7 @@ def _normalize_number_field_data(self, R): elif is_PolynomialQuotientRing(R): from sage.categories.number_fields import NumberFields if R.base_ring().fraction_field() not in NumberFields(): - raise NotImplementedError("cannot normalize quotients over %r"%(R.base_ring(),)) + raise NotImplementedError("cannot normalize quotients over %r" % (R.base_ring(),)) L = R.fraction_field() K = R.base_ring().fraction_field() G = R.modulus().change_ring(K) @@ -397,11 +397,11 @@ def create_object(self, version, key, **extra_args): R = key[0] parent = DiscretePseudoValuationSpace(R) if isinstance(R, pAdicGeneric): - assert(len(key)==1) + assert(len(key) == 1) return parent.__make_element_class__(pAdicValuation_padic)(parent) elif R is ZZ or R is QQ: prime = key[1] - assert(len(key)==2) + assert(len(key) == 2) return parent.__make_element_class__(pAdicValuation_int)(parent, prime) else: v = key[1] @@ -592,7 +592,7 @@ def is_unramified(self, G, include_steps=False, assume_squarefree=False): break next = v.mac_lane_step(G, assume_squarefree=True) - if len(next)>1: + if len(next) > 1: ret = False break steps.append(next[0]) @@ -689,7 +689,7 @@ def is_totally_ramified(self, G, include_steps=False, assume_squarefree=False): break next = v.mac_lane_step(G, assume_squarefree=True) - if len(next)>1: + if len(next) > 1: ret = False break steps.append(next[0]) @@ -828,7 +828,7 @@ def restriction(self, ring): return self if not ring.is_subring(self.domain()): - raise ValueError("ring must be a subring of the domain of this valuation but %r is not a subring of %r"%(ring, self.domain())) + raise ValueError("ring must be a subring of the domain of this valuation but %r is not a subring of %r" % (ring, self.domain())) return pAdicValuation(ring, self.p()) @@ -963,7 +963,7 @@ def element_with_valuation(self, v): from sage.rings.rational_field import QQ v = QQ(v) if v not in self.value_semigroup(): - raise ValueError("%r is not in the value semigroup of %r"%(v, self)) + raise ValueError("%r is not in the value semigroup of %r" % (v, self)) v = ZZ(v * self.domain().absolute_e()) return self.domain().one() << v @@ -977,7 +977,7 @@ def _repr_(self): '3-adic valuation' """ - return "%s-adic valuation"%(self.p()) + return "%s-adic valuation" % (self.p()) def _call_(self, x): r""" @@ -1102,7 +1102,7 @@ def _repr_(self): '3-adic valuation' """ - return "%s-adic valuation"%(self.p()) + return "%s-adic valuation" % (self.p()) def _call_(self, x): """ @@ -1281,7 +1281,7 @@ def simplify(self, x, error=None, force=False, size_heuristic_bound=32): if self._relative_size(rational) < self._relative_size(best): best = rational - assert(self(x-best)>error) + assert(self(x-best) > error) return best diff --git a/src/sage/rings/polynomial/ideal.py b/src/sage/rings/polynomial/ideal.py index a117c7bd663..1ab86736d5b 100644 --- a/src/sage/rings/polynomial/ideal.py +++ b/src/sage/rings/polynomial/ideal.py @@ -54,7 +54,7 @@ def residue_field(self, names=None, check=True): if not self.ring().base_ring().is_finite(): raise TypeError("residue fields only supported for polynomial rings over finite fields.") if not self.is_prime(): - raise ValueError("%s is not a prime ideal"%self) + raise ValueError("%s is not a prime ideal" % self) from sage.rings.finite_rings.residue_field import ResidueField return ResidueField(self, names, check=False) diff --git a/src/sage/rings/polynomial/infinite_polynomial_ring.py b/src/sage/rings/polynomial/infinite_polynomial_ring.py index a6f2e44c7b5..f1db4c7d275 100644 --- a/src/sage/rings/polynomial/infinite_polynomial_ring.py +++ b/src/sage/rings/polynomial/infinite_polynomial_ring.py @@ -1364,7 +1364,7 @@ def key_basis(self): EXAMPLES:: sage: R. = InfinitePolynomialRing(GF(2)) - sage: R.key_basis() # needs sage.combinat + sage: R.key_basis() # needs sage.combinat sage.modules Key polynomial basis over Finite Field of size 2 """ from sage.combinat.key_polynomial import KeyPolynomialBasis diff --git a/src/sage/rings/polynomial/laurent_polynomial_ring.py b/src/sage/rings/polynomial/laurent_polynomial_ring.py index d922a1a57fc..ac40e815724 100644 --- a/src/sage/rings/polynomial/laurent_polynomial_ring.py +++ b/src/sage/rings/polynomial/laurent_polynomial_ring.py @@ -459,7 +459,7 @@ def _repr_(self): sage: LaurentPolynomialRing(QQ,'x') # indirect doctest Univariate Laurent Polynomial Ring in x over Rational Field """ - return "Univariate Laurent Polynomial Ring in %s over %s"%(self._R.variable_name(), self._R.base_ring()) + return "Univariate Laurent Polynomial Ring in %s over %s" % (self._R.variable_name(), self._R.base_ring()) def _element_constructor_(self, x): """ @@ -607,7 +607,7 @@ def _repr_(self): sage: LaurentPolynomialRing(QQ,1,'x').__repr__() # needs sage.modules 'Multivariate Laurent Polynomial Ring in x over Rational Field' """ - return "Multivariate Laurent Polynomial Ring in %s over %s"%(", ".join(self._R.variable_names()), self._R.base_ring()) + return "Multivariate Laurent Polynomial Ring in %s over %s" % (", ".join(self._R.variable_names()), self._R.base_ring()) def monomial(self, *args): r""" diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index 27b6f577f16..0c510df8d59 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -114,7 +114,7 @@ def _repr_(self): sage: x + QQbar(sqrt(2) - 1/2*I) # indirect doctest # needs sage.rings.number_field sage.symbolic x + 1.414213562373095? - 0.50000000000000000?*I """ - return "%s"%self.__element + return "%s" % self.__element #################### @@ -220,7 +220,7 @@ def _im_gens_(self, codomain, im_gens, base_map=None): sage: R. = PolynomialRing(QQbar, 2) # needs sage.rings.number_field sage: f = R.hom([y, x], R) # needs sage.rings.number_field - sage: f(x^2 + 3*y^5) # indirect doctest # needs sage.rings.number_field + sage: f(x^2 + 3*y^5) # indirect doctest # needs sage.rings.number_field 3*x^5 + y^2 You can specify a map on the base ring:: @@ -1455,7 +1455,7 @@ def subs(self, fixed=None, **kw): variables = list(self.parent().gens()) for i in range(0,len(variables)): if str(variables[i]) in kw: - variables[i]=kw[str(variables[i])] + variables[i] = kw[str(variables[i])] elif fixed and variables[i] in fixed: variables[i] = fixed[variables[i]] return self(tuple(variables)) diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 28d93c1aa6c..66dd4a6db3d 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -300,7 +300,7 @@ def __call__(self, *args, **kwds): """ R = self._instance.ring() if not R.base_ring().is_field(): - raise ValueError("Coefficient ring must be a field for function '%s'."%(self.f.__name__)) + raise ValueError("Coefficient ring must be a field for function '%s'." % (self.f.__name__)) return self.f(self._instance, *args, **kwds) @@ -367,7 +367,7 @@ def _magma_init_(self, magma): """ P = magma(self.ring()) G = magma(self.gens()) - return 'ideal<%s|%s>'%(P.name(), G._ref()) + return 'ideal<%s|%s>' % (P.name(), G._ref()) @magma_gb_standard_options def _groebner_basis_magma(self, deg_bound=None, prot=False, magma=magma_default): @@ -416,7 +416,7 @@ def _groebner_basis_magma(self, deg_bound=None, prot=False, magma=magma_default) from sage.interfaces.magma import MagmaGBLogPrettyPrinter if prot: - log_parser = MagmaGBLogPrettyPrinter(verbosity=get_verbose()+ 1, style="sage" if prot=="sage" else "magma") + log_parser = MagmaGBLogPrettyPrinter(verbosity=get_verbose() + 1, style="sage" if prot == "sage" else "magma") else: log_parser = None @@ -538,7 +538,7 @@ def _groebner_basis_libsingular(self, algorithm="groebner", *args, **kwds): from sage.libs.singular.function_factory import ff groebner = ff.groebner - if get_verbose()>=2: + if get_verbose() >= 2: opt['prot'] = True for name, value in kwds.items(): if value is not None: @@ -555,7 +555,7 @@ def _groebner_basis_libsingular(self, algorithm="groebner", *args, **kwds): fnc = singular_function(algorithm) S = fnc(self) except NameError: - raise NameError("Algorithm '%s' unknown"%algorithm) + raise NameError("Algorithm '%s' unknown" % algorithm) return S @libsingular_gb_standard_options @@ -1154,7 +1154,7 @@ def triangular_decomposition(self, algorithm=None, singular=singular_default): f = singular_function(algorithm[9:]) Tbar = f(I, attributes={I:{'isSB':1}}) else: - raise TypeError("algorithm '%s' unknown"%algorithm) + raise TypeError("algorithm '%s' unknown" % algorithm) T = Sequence([ MPolynomialIdeal(Q,t) for t in Tbar]) return sorted(T, key=lambda x: x.gens()) @@ -1393,7 +1393,7 @@ def _groebner_basis_ginv(self, algorithm="TQ", criteria='CritPartially', divisio try: im = ginv.MonomInterface(term_order_map[T.name()], st, list(P.variable_names())) except KeyError: - raise NotImplementedError("Term order '%s' not supported by Sage's GINV interface or GINV"%T.term_order()) + raise NotImplementedError("Term order '%s' not supported by Sage's GINV interface or GINV" % T.term_order()) from sage.rings.rational_field import QQ if K is QQ: @@ -1401,7 +1401,7 @@ def _groebner_basis_ginv(self, algorithm="TQ", criteria='CritPartially', divisio elif K.order() <= 2**16 and K.order().is_prime(): ic = ginv.CoeffInterface("ModularShort", st, modularShort=K.order()) else: - raise NotImplementedError("GINV interface for base ring '%s' is not implemented."%K) + raise NotImplementedError("GINV interface for base ring '%s' is not implemented." % K) ip = ginv.PolyInterface("PolyList", st, im, ic) iw = ginv.WrapInterface(criteria, ip) @@ -1519,7 +1519,7 @@ def _groebner_basis_singular_raw(self, algorithm="groebner", singular=singular_d o = _options_py_to_singular.get(o,o) if v: if o in ['degBound','multBound']: - singular.eval(o+'=%d'%v) + singular.eval(o+'=%d' % v) else: singular.option(o) else: @@ -1554,7 +1554,7 @@ def _groebner_basis_singular_raw(self, algorithm="groebner", singular=singular_d elif algorithm == "stdfglm": S = obj.stdfglm() else: - raise TypeError("algorithm '%s' unknown"%algorithm) + raise TypeError("algorithm '%s' unknown" % algorithm) self.__gb_singular = S if prot == "sage": print("") @@ -2140,7 +2140,7 @@ def basis_is_groebner(self, singular=singular_default): M = (F * LTF.syz()).reduce(self._singular_()) for i in range(M.ncols()): - if int(singular.eval("%s[1,%s+1]!=0"%(M.name(),i))): + if int(singular.eval("%s[1,%s+1]!=0" % (M.name(),i))): return False self._singular_().attrib('isSB',1) return True @@ -2821,7 +2821,7 @@ def _variety(T, V, v=None): d = self.dimension() if d > 0: - raise ValueError("The dimension of the ideal is %s, but it should be 0"%d) + raise ValueError("The dimension of the ideal is %s, but it should be 0" % d) if d == -1: return [] @@ -3458,7 +3458,7 @@ def _reduce_using_macaulay2(self, f): """ I = self._macaulay2_() M2 = I.parent() - k = M2('(%r) %% %s'%(f, I.name())) + k = M2('(%r) %% %s' % (f, I.name())) R = self.ring() return R(k) @@ -4716,7 +4716,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal ginv,alg = algorithm.split(":") gb = self._groebner_basis_ginv(algorithm=alg,*args, **kwds) else: - raise NameError("Algorithm '%s' unknown."%algorithm) + raise NameError("Algorithm '%s' unknown." % algorithm) elif algorithm == 'giac:gbasis': from sage.libs.giac import groebner_basis as groebner_basis_libgiac gb = groebner_basis_libgiac(self, prot=prot, *args, **kwds) @@ -4729,7 +4729,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal from . import msolve return msolve.groebner_basis_degrevlex(self, *args, **kwds) else: - raise NameError("Algorithm '%s' unknown."%algorithm) + raise NameError("Algorithm '%s' unknown." % algorithm) gb = sorted(gb, reverse=True) if self.ring().base_ring().is_field(): @@ -5139,7 +5139,7 @@ def degree_of_semi_regularity(self): semi-regular sequences. For more details about semi-regular sequences see [BFS2004]_. """ - degs = [f.degree() for f in self.gens() if f!=0] # we ignore zeroes + degs = [f.degree() for f in self.gens() if f != 0] # we ignore zeroes m, n = self.ngens(), len(set(sum([f.variables() for f in self.gens()],()))) if m <= n: raise ValueError("This function requires an overdefined system of polynomials.") @@ -5238,7 +5238,7 @@ def plot(self, *args, **kwds): V = [(variables[0], None, None), (variables[1], None, None)] if len(args) > 2: - raise TypeError("Expected up to 2 optional parameters but got %d."%len(args)) + raise TypeError("Expected up to 2 optional parameters but got %d." % len(args)) # first check whether user supplied boundaries for e in args: diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py index 1cfabbeda6e..19c53c392b2 100644 --- a/src/sage/rings/polynomial/multi_polynomial_sequence.py +++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py @@ -229,7 +229,7 @@ def PolynomialSequence(arg1, arg2=None, immutable=False, cr=False, cr_str=None): If a list of tuples is provided, those form the parts:: - sage: F = Sequence([I.gens(),I.gens()], I.ring()); F # indirect doctest # needs sage.libs.singular + sage: F = Sequence([I.gens(),I.gens()], I.ring()); F # indirect doctest # needs sage.libs.singular [a + 2*b + 2*c + 2*d - 1, a^2 + 2*b^2 + 2*c^2 + 2*d^2 - a, 2*a*b + 2*b*c + 2*c*d - b, @@ -316,7 +316,7 @@ def PolynomialSequence(arg1, arg2=None, immutable=False, cr=False, cr_str=None): if arg2: ring = arg2 if not is_ring(ring): - raise TypeError("Ring '%s' not supported."%ring) + raise TypeError("Ring '%s' not supported." % ring) else: try: e = next(iter(gens)) @@ -396,7 +396,7 @@ def __init__(self, parts, ring, immutable=False, cr=False, cr_str=None): sage: P. = PolynomialRing(GF(127), 4) sage: I = sage.rings.ideal.Katsura(P) # needs sage.rings.finite_rings - sage: Sequence([I.gens()], I.ring()) # indirect doctest # needs sage.rings.finite_rings + sage: Sequence([I.gens()], I.ring()) # indirect doctest # needs sage.rings.finite_rings [a + 2*b + 2*c + 2*d - 1, a^2 + 2*b^2 + 2*c^2 + 2*d^2 - a, 2*a*b + 2*b*c + 2*c*d - b, b^2 + 2*a*c + 2*b*d - c] @@ -842,7 +842,7 @@ def _magma_init_(self, magma): """ P = magma(self.ring()).name() v = [x._magma_init_(magma) for x in list(self)] - return 'ideal<%s|%s>'%(P, ','.join(v)) + return 'ideal<%s|%s>' % (P, ','.join(v)) def _repr_(self): """ @@ -870,7 +870,7 @@ def _repr_(self): if len(self) < 20: return Sequence_generic._repr_(self) else: - return "Polynomial Sequence with %d Polynomials in %d Variables"%(len(self),self.nvariables()) + return "Polynomial Sequence with %d Polynomials in %d Variables" % (len(self),self.nvariables()) def __add__(self, right): """ @@ -1276,13 +1276,14 @@ def eliminate_linear_variables(self, maxlength=Infinity, skip=None, return_reduc If the input system is detected to be inconsistent then ``[1]`` is returned, and the list of reductors is empty:: - sage: R. = BooleanPolynomialRing() # needs sage.rings.polynomial.pbori - sage: S = Sequence([x*y*z + x*y + z*y + x*z, x + y + z + 1, x + y + z]) # needs sage.rings.polynomial.pbori - sage: S.eliminate_linear_variables() # needs sage.rings.polynomial.pbori + sage: # needs sage.rings.polynomial.pbori + sage: R. = BooleanPolynomialRing() + sage: S = Sequence([x*y*z + x*y + z*y + x*z, x + y + z + 1, x + y + z]) + sage: S.eliminate_linear_variables() [1] - sage: R. = BooleanPolynomialRing() # needs sage.rings.polynomial.pbori - sage: S = Sequence([x*y*z + x*y + z*y + x*z, x + y + z + 1, x + y + z]) # needs sage.rings.polynomial.pbori - sage: S.eliminate_linear_variables(return_reductors=True) # needs sage.rings.polynomial.pbori + sage: R. = BooleanPolynomialRing() + sage: S = Sequence([x*y*z + x*y + z*y + x*z, x + y + z + 1, x + y + z]) + sage: S.eliminate_linear_variables(return_reductors=True) ([1], []) @@ -1306,13 +1307,14 @@ def eliminate_linear_variables(self, maxlength=Infinity, skip=None, return_reduc We test a case which would increase the degree with ``polybori=True``:: - sage: B. = BooleanPolynomialRing() # needs sage.rings.polynomial.pbori - sage: f = a*d + a + b*d + c*d + 1 # needs sage.rings.polynomial.pbori - sage: Sequence([f, a + b*c + c+d + 1]).eliminate_linear_variables() # needs sage.rings.polynomial.pbori + sage: # needs sage.rings.polynomial.pbori + sage: B. = BooleanPolynomialRing() + sage: f = a*d + a + b*d + c*d + 1 + sage: Sequence([f, a + b*c + c+d + 1]).eliminate_linear_variables() [a*d + a + b*d + c*d + 1, a + b*c + c + d + 1] - sage: B. = BooleanPolynomialRing() # needs sage.rings.polynomial.pbori - sage: f = a*d + a + b*d + c*d + 1 # needs sage.rings.polynomial.pbori - sage: Sequence([f, a + b*c + c+d + 1]).eliminate_linear_variables(use_polybori=True) # needs sage.rings.polynomial.pbori + sage: B. = BooleanPolynomialRing() + sage: f = a*d + a + b*d + c*d + 1 + sage: Sequence([f, a + b*c + c+d + 1]).eliminate_linear_variables(use_polybori=True) [b*c*d + b*c + b*d + c + d] .. NOTE:: @@ -1417,7 +1419,7 @@ def _groebner_strategy(self): g = GroebnerStrategy(R) for p in self: g.add_as_you_wish(p) - g.reduction_strategy.opt_red_tail=True + g.reduction_strategy.opt_red_tail = True return g def solve(self, algorithm='polybori', n=1, eliminate_linear_variables=True, verbose=False, **kwds): @@ -1620,7 +1622,7 @@ def reduced(self): if isinstance(R, BooleanPolynomialRing_base): from sage.rings.polynomial.pbori.interred import interred as inter_red - l = [p for p in self if not p==0] + l = [p for p in self if not p == 0] l = sorted(inter_red(l, completely=True), reverse=True) return PolynomialSequence(l, R, immutable=True) else: diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 7515bd0ae9d..ad1af634588 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -9848,13 +9848,13 @@ cdef class Polynomial(CommutativePolynomial): sage: # needs sage.libs.pari sage: R. = ZZ[] - sage: (2*x).is_squarefree() # needs sage.libs.pari + sage: (2*x).is_squarefree() True - sage: (4*x).is_squarefree() # needs sage.libs.pari + sage: (4*x).is_squarefree() False - sage: (2*x^2).is_squarefree() # needs sage.libs.pari + sage: (2*x^2).is_squarefree() False - sage: R(0).is_squarefree() # needs sage.libs.pari + sage: R(0).is_squarefree() False sage: S. = QQ[] diff --git a/src/sage/rings/polynomial/polynomial_element_generic.py b/src/sage/rings/polynomial/polynomial_element_generic.py index f7b4ba226b9..1f447fc1287 100644 --- a/src/sage/rings/polynomial/polynomial_element_generic.py +++ b/src/sage/rings/polynomial/polynomial_element_generic.py @@ -395,18 +395,18 @@ def _repr(self, name=None): if y.find("-") == 0: y = y[1:] if not atomic_repr and n > 0 and (y.find("+") != -1 or y.find("-") != -1): - x = "(%s)"%x + x = "(%s)" % x if n > 1: - var = "*%s^%s"%(name,n) - elif n==1: - var = "*%s"%name + var = "*%s^%s" % (name,n) + elif n == 1: + var = "*%s" % name else: var = "" - s += "%s%s"%(x,var) + s += "%s%s" % (x,var) s = s.replace(" + -", " - ") s = s.replace(" 1*"," ") s = s.replace(" -1*", " -") - if s==" ": + if s == " ": return "0" return s[1:] @@ -962,22 +962,22 @@ def gcd(self,other,algorithm=None): algorithm = "dense" else: algorithm = "generic" - if algorithm=="dense": + if algorithm == "dense": S = self.parent() # FLINT is faster but a bug makes the conversion extremely slow, # so NTL is used in those cases where the conversion is too slow. Cf # sd = self.degree() od = other.degree() - if max(sd,od)<100 or \ - min(len(self.__coeffs)/sd, len(other.__coeffs)/od)>.06: - implementation="FLINT" + if max(sd,od) < 100 or \ + min(len(self.__coeffs)/sd, len(other.__coeffs)/od) > .06: + implementation = "FLINT" else: - implementation="NTL" + implementation = "NTL" D = PolynomialRing(S.base_ring(),'x',implementation=implementation) g = D(self).gcd(D(other)) return S(g) - elif algorithm=="generic": + elif algorithm == "generic": return Polynomial.gcd(self,other) else: raise ValueError("Unknown algorithm '%s'" % algorithm) @@ -1002,7 +1002,7 @@ def reverse(self, degree=None): if degree is None: degree = self.degree() if not isinstance(degree, (int,Integer)): - raise ValueError("degree argument must be a nonnegative integer, got %s"%degree) + raise ValueError("degree argument must be a nonnegative integer, got %s" % degree) d = {degree-k: v for k,v in self.__coeffs.items() if degree >= k} return self.parent()(d, check=False) @@ -1098,7 +1098,7 @@ def quo_rem(self, other): Q = P.zero() while R.degree() >= B.degree(): aaa = R.leading_coefficient()/B.leading_coefficient() - diff_deg=R.degree()-B.degree() + diff_deg = R.degree()-B.degree() Q += P(aaa).shift(diff_deg) # We know that S*B exactly cancels the leading coefficient of R. # Thus, we skip the computation of this leading coefficient. diff --git a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx index 194eb9263b2..7bb023e8452 100644 --- a/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx @@ -42,7 +42,7 @@ from cysignals.signals cimport sig_on, sig_off include "sage/libs/ntl/decl.pxi" -from cpython.int cimport PyInt_AS_LONG +from cpython.long cimport PyLong_AsLong from sage.libs.gmp.mpz cimport * from sage.arith.long cimport pyobject_to_long, is_small_python_int @@ -421,7 +421,7 @@ cdef class Polynomial_integer_dense_flint(Polynomial): sig_on() fmpz_init(a_fmpz) fmpz_init(z_fmpz) - fmpz_set_si(a_fmpz, PyInt_AS_LONG(x0)) + fmpz_set_si(a_fmpz, PyLong_AsLong(x0)) fmpz_poly_evaluate_fmpz(z_fmpz, self._poly, a_fmpz) fmpz_get_mpz(z.value, z_fmpz) fmpz_clear(a_fmpz) diff --git a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx index d69d5e09018..a8f08f5bc6c 100644 --- a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx @@ -553,7 +553,7 @@ def small_roots(self, X=None, beta=1.0, epsilon=None, **kwds): sage: from sage.misc.verbose import set_verbose sage: set_verbose(2) - sage: d = f.small_roots(X=2^hidden-1, beta=0.5)[0] # time random # needs sage.symbolic + sage: d = f.small_roots(X=2^hidden-1, beta=0.5)[0] # time random # needs sage.symbolic verbose 2 () m = 4 verbose 2 () t = 4 verbose 2 () X = 1298074214633706907132624082305023 diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 2a6a155b5ae..e372be888ee 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -548,7 +548,7 @@ def _element_constructor_(self, x): try: return self.element_class(self, self.__ring(x), check=False) except TypeError: - raise TypeError("unable to convert %r to an element of %s"%(x, self)) + raise TypeError("unable to convert %r to an element of %s" % (x, self)) def _coerce_map_from_(self, R): r""" @@ -770,11 +770,11 @@ def _singular_init_(self, S=None): modulus = S(self.modulus()) # should live in Rpoly Rtmp = S(self.polynomial_ring().change_var(self.variable_name())) Rtmp.set_ring() - self.__singular = S("ideal(fetch(%s,%s))"%(Rpoly.name(),modulus.name()),"qring") + self.__singular = S("ideal(fetch(%s,%s))" % (Rpoly.name(),modulus.name()),"qring") return self.__singular def _repr_(self): - return "Univariate Quotient Polynomial Ring in %s over %s with modulus %s"%( + return "Univariate Quotient Polynomial Ring in %s over %s with modulus %s" % ( self.variable_name(), self.base_ring(), self.modulus()) def construction(self): @@ -1460,7 +1460,7 @@ def S_class_group(self, S, proof=True): `x^2 + 31` from 12 to 2, i.e. we lose a generator of order 6 (this was fixed in :trac:`14489`):: - sage: S.S_class_group([K.ideal(a)]) # representation varies # not tested, needs sage.rings.number_field + sage: S.S_class_group([K.ideal(a)]) # representation varies # not tested, needs sage.rings.number_field [((1/4*xbar^2 + 31/4, (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8, 1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16, -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8), @@ -2127,7 +2127,7 @@ def _isomorphic_ring(self): to_isomorphic_ring = self.hom([isomorphic_ring.gen()]) return from_isomorphic_ring, to_isomorphic_ring, isomorphic_ring - raise NotImplementedError("cannot rewrite %r as an isomorphic ring"%(self,)) + raise NotImplementedError("cannot rewrite %r as an isomorphic ring" % (self,)) def _test_isomorphic_ring(self, **options): r""" diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py index 2f7d825dbf8..4185f0d1455 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring_element.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring_element.py @@ -424,7 +424,7 @@ def __invert__(self): 11 """ if self._polynomial.is_zero(): - raise ZeroDivisionError("element %s of quotient polynomial ring not invertible"%self) + raise ZeroDivisionError("element %s of quotient polynomial ring not invertible" % self) if self._polynomial.is_one(): return self @@ -442,7 +442,7 @@ def __invert__(self): raise NotImplementedError("The base ring (=%s) is not a field" % base) g, _, a = parent.modulus().xgcd(self._polynomial) if g.degree() != 0: - raise ZeroDivisionError("element %s of quotient polynomial ring not invertible"%self) + raise ZeroDivisionError("element %s of quotient polynomial ring not invertible" % self) c = g[0] return self.__class__(self.parent(), (~c)*a, check=False) diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx index 26d070ac77f..b888b31d214 100644 --- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx @@ -25,7 +25,7 @@ AUTHOR: from cysignals.memory cimport check_allocarray, sig_free from cysignals.signals cimport sig_on, sig_str, sig_off -from cpython.int cimport PyInt_AS_LONG +from cpython.long cimport PyLong_AsLong from sage.arith.long cimport pyobject_to_long from sage.libs.arb.acb cimport acb_div_fmpz @@ -522,7 +522,7 @@ cdef class Polynomial_rational_flint(Polynomial): sig_str("FLINT exception") fmpz_init(tmpfz) fmpq_init(tmpfq) - fmpz_set_si(tmpfz, PyInt_AS_LONG(a)) + fmpz_set_si(tmpfz, PyLong_AsLong(a)) fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz) fmpq_get_mpq(r.value, tmpfq) fmpq_clear(tmpfq) diff --git a/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx b/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx index 955f83468e4..da5462cddd4 100644 --- a/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx +++ b/src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx @@ -26,7 +26,7 @@ Check that operations with numpy elements work well (see :trac:`18076` and from cysignals.memory cimport check_allocarray, check_reallocarray, sig_free from cysignals.signals cimport sig_on, sig_off -from cpython.int cimport PyInt_AS_LONG +from cpython.long cimport PyLong_AsLong from cpython.float cimport PyFloat_AS_DOUBLE from sage.structure.parent cimport Parent @@ -151,7 +151,7 @@ cdef class PolynomialRealDense(Polynomial): if type(a) is RealNumber: mpfr_set(coeffs[i], (a).value, rnd) elif type(a) is int: - mpfr_set_si(coeffs[i], PyInt_AS_LONG(a), rnd) + mpfr_set_si(coeffs[i], PyLong_AsLong(a), rnd) elif type(a) is float: mpfr_set_d(coeffs[i], PyFloat_AS_DOUBLE(a), rnd) elif type(a) is Integer: diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index 968330c9288..af37b6d9fd7 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -840,7 +840,7 @@ def _coerce_map_from_(self, P): from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing if is_MPolynomialRing(P) and self.variable_name() in P.variable_names(): P_ = P.remove_var(self.variable_name()) - return self.base_ring()!=P_ and self.base_ring().has_coerce_map_from(P_) + return self.base_ring() != P_ and self.base_ring().has_coerce_map_from(P_) def _magma_init_(self, magma): """ @@ -889,7 +889,7 @@ def _magma_init_(self, magma): """ B = magma(self.base_ring()) Bref = B._ref() - s = 'PolynomialRing(%s)'%(Bref) + s = 'PolynomialRing(%s)' % (Bref) return magma._with_names(s, self.variable_names()) def _gap_init_(self, gap=None): @@ -927,7 +927,7 @@ def _gap_init_(self, gap=None): base_ring = gap(self.base_ring()).name() else: base_ring = self.base_ring()._gap_init_() - return 'PolynomialRing(%s, ["%s"])'%(base_ring, self.variable_name()) + return 'PolynomialRing(%s, ["%s"])' % (base_ring, self.variable_name()) def _sage_input_(self, sib, coerced): r""" @@ -1009,7 +1009,7 @@ def _repr_(self): return self._cached_repr except AttributeError: pass - s = "Univariate Polynomial Ring in %s over %s"%( + s = "Univariate Polynomial Ring in %s over %s" % ( self.variable_name(), self.base_ring()) if self.is_sparse(): s = "Sparse " + s @@ -1024,7 +1024,7 @@ def _latex_(self): sage: latex(S) \Bold{Z}[\alpha_{12}] """ - return "%s[%s]"%(latex.latex(self.base_ring()), self.latex_variable_names()[0]) + return "%s[%s]" % (latex.latex(self.base_ring()), self.latex_variable_names()[0]) def base_extend(self, R): """ @@ -1202,7 +1202,7 @@ def cyclotomic_polynomial(self, n): x - 1 """ if n <= 0: - raise ArithmeticError("n=%s must be positive"%n) + raise ArithmeticError("n=%s must be positive" % n) elif n == 1: return self.gen() - 1 else: @@ -1712,7 +1712,7 @@ class PolynomialRing_commutative(PolynomialRing_general, ring.CommutativeAlgebra def __init__(self, base_ring, name=None, sparse=False, implementation=None, element_class=None, category=None): if base_ring not in _CommutativeRings: - raise TypeError("Base ring %s must be a commutative ring."%repr(base_ring)) + raise TypeError("Base ring %s must be a commutative ring." % repr(base_ring)) # We trust that, if a category is given, that it is useful. if category is None: if base_ring.is_zero(): @@ -2799,7 +2799,7 @@ def alekh_rec(p, k, degree_bound, lvl): - ``degree_bound`` -- the current degree bound - ``lvl`` -- the level in the recursion tree """ - if k<=0: + if k <= 0: return [ (self.zero(),0) ] elif degree_bound < 0: # The only possible root of (current) p, if any, is y = 0 diff --git a/src/sage/rings/polynomial/polynomial_ring_constructor.py b/src/sage/rings/polynomial/polynomial_ring_constructor.py index acaea2e3a16..ecccc51519e 100644 --- a/src/sage/rings/polynomial/polynomial_ring_constructor.py +++ b/src/sage/rings/polynomial/polynomial_ring_constructor.py @@ -578,7 +578,7 @@ def PolynomialRing(base_ring, *args, **kwds): sage: R. = PolynomialRing(PolynomialRing(GF(7),'k')); TestSuite(R).run(); R Univariate Polynomial Ring in w over Univariate Polynomial Ring in k over Finite Field of size 7 - sage: ZxNTL = PolynomialRing(ZZ, 'x', implementation='NTL'); TestSuite(ZxNTL).run(skip='_test_pickling'); ZxNTL + sage: ZxNTL = PolynomialRing(ZZ, 'x', implementation='NTL'); TestSuite(ZxNTL).run(skip='_test_pickling'); ZxNTL # needs sage.libs.ntl Univariate Polynomial Ring in x over Integer Ring (using NTL) sage: ZxFLINT = PolynomialRing(ZZ, 'x', implementation='FLINT'); TestSuite(ZxFLINT).run(); ZxFLINT Univariate Polynomial Ring in x over Integer Ring diff --git a/src/sage/rings/polynomial/symmetric_ideal.py b/src/sage/rings/polynomial/symmetric_ideal.py index 84138cd8975..12a629ad741 100644 --- a/src/sage/rings/polynomial/symmetric_ideal.py +++ b/src/sage/rings/polynomial/symmetric_ideal.py @@ -210,7 +210,7 @@ def __repr__(self): Symmetric Ideal (x_1^2 + y_2^2, x_2*x_1*y_3 + x_1*y_4) of Infinite polynomial ring in x, y over Rational Field """ - return "Symmetric Ideal %s of %s"%(self._repr_short(), self.ring()) + return "Symmetric Ideal %s of %s" % (self._repr_short(), self.ring()) def _latex_(self): r""" @@ -242,7 +242,7 @@ def _contains_(self, p): sage: I # needs sage.combinat Symmetric Ideal (x_1^2 + x_1, x_2 - x_1) of Infinite polynomial ring in x over Rational Field - sage: x[2]^2 + x[3] in I # indirect doctest # needs sage.combinat + sage: x[2]^2 + x[3] in I # indirect doctest # needs sage.combinat True """ try: @@ -269,7 +269,7 @@ def __mul__(self, other): """ # determine maximal generator index PARENT = self.ring() - if (not isinstance(other, self.__class__)) or self.ring()!=other.ring(): + if (not isinstance(other, self.__class__)) or self.ring() != other.ring(): if hasattr(other,'gens'): other = SymmetricIdeal(PARENT, other.gens(), coerce=True) other = other.symmetrisation() @@ -355,7 +355,7 @@ def is_maximal(self): if self.is_trivial() and not self.is_zero(): return True V = [p.variables() for p in self.gens()] - V = [x for x in V if len(x)==1] + V = [x for x in V if len(x) == 1] V = [str(x[0]).split('_')[0] for x in V] return set(V) == set(self.ring().variable_names()) @@ -555,11 +555,11 @@ def interreduction(self, tailreduce=True, sorted=False, report=None, RStrat=None if DONE == TODO: break else: - if len(TODO)==len(DONE): + if len(TODO) == len(DONE): import copy bla = copy.copy(TODO) bla.sort() - if bla==DONE: + if bla == DONE: break TODO = DONE return SymmetricIdeal(self.ring(),DONE, coerce=False) @@ -640,7 +640,7 @@ def symmetrisation(self, N=None, tailreduce=False, report=None, use_full_group=F N = max([Y.max_index() for Y in newOUT.gens()]+[1]) else: N = Integer(N) - if hasattr(R,'_max') and R._max %d"%(t.macaulay2_str(), len(t))) + singular_str.append("%s(%d)" % (t.singular_str(), len(t))) + macaulay2_str.append("%s => %d" % (t.macaulay2_str(), len(t))) length += len(t) self._singular_moreblocks += t.singular_moreblocks() @@ -809,8 +809,8 @@ def __init__(self, name='lex', n=0, force=False): block_length = int(block_length) if block_length > 0: # ignore blocks with length 0 blocks.append( TermOrder(block_name, block_length, force=force) ) - singular_str.append("%s(%d)"%(singular_name_mapping.get(block_name, block_name), block_length)) - macaulay2_str.append("%s => %d"%(macaulay2_name_mapping.get(block_name, block_name), block_length)) + singular_str.append("%s(%d)" % (singular_name_mapping.get(block_name, block_name), block_length)) + macaulay2_str.append("%s => %d" % (macaulay2_name_mapping.get(block_name, block_name), block_length)) length += block_length except ValueError: block_name = block.strip() @@ -847,7 +847,7 @@ def __init__(self, name='lex', n=0, force=False): self._name = "matrix" self._singular_str = "M(%s)" % (int_str,) self._macaulay2_str = "" # Macaulay2 does not support matrix term order directly - self._magma_str = '"weight",[%s]'%(int_str,) + self._magma_str = '"weight",[%s]' % (int_str,) from sage.matrix.constructor import matrix self._matrix = matrix(n,name) # defined only for matrix term order @@ -857,7 +857,7 @@ def __init__(self, name='lex', n=0, force=False): raise ValueError("{!r} is not a valid term order".format(name)) if self._length != 0: - self._singular_str = self._singular_str%dict(ngens=self._length) + self._singular_str = self._singular_str % dict(ngens=self._length) if self._name == 'degneglex': self._singular_moreblocks += 1 @@ -932,7 +932,7 @@ def sortkey_matrix(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='m(1,3,1,0)') # needs sage.rings.number_field - sage: y > x^2 # indirect doctest # needs sage.rings.number_field + sage: y > x^2 # indirect doctest # needs sage.rings.number_field True sage: y > x^3 # needs sage.rings.number_field False @@ -952,7 +952,7 @@ def sortkey_lex(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='lex') # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field True sage: x > 1 # needs sage.rings.number_field True @@ -971,7 +971,7 @@ def sortkey_invlex(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='invlex') # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field False sage: x > 1 # needs sage.rings.number_field True @@ -990,7 +990,7 @@ def sortkey_deglex(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='deglex') # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field False sage: x > 1 # needs sage.rings.number_field True @@ -1010,7 +1010,7 @@ def sortkey_degrevlex(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='degrevlex') # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field False sage: x > 1 # needs sage.rings.number_field True @@ -1032,7 +1032,7 @@ def sortkey_neglex(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='neglex') # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field False sage: x > 1 # needs sage.rings.number_field False @@ -1051,7 +1051,7 @@ def sortkey_negdegrevlex(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='negdegrevlex') # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field True sage: x > 1 # needs sage.rings.number_field False @@ -1071,7 +1071,7 @@ def sortkey_negdeglex(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='negdeglex') # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field True sage: x > 1 # needs sage.rings.number_field False @@ -1090,7 +1090,7 @@ def sortkey_degneglex(self, f): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='degneglex') # needs sage.rings.number_field - sage: x*y > y*z # indirect doctest # needs sage.rings.number_field + sage: x*y > y*z # indirect doctest # needs sage.rings.number_field False sage: x*y > x # needs sage.rings.number_field True @@ -1110,7 +1110,7 @@ def sortkey_wdegrevlex(self, f): sage: t = TermOrder('wdegrevlex',(3,2)) sage: P. = PolynomialRing(QQbar, 2, order=t) # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field False sage: x^2 > y^3 # needs sage.rings.number_field True @@ -1131,7 +1131,7 @@ def sortkey_wdeglex(self, f): sage: t = TermOrder('wdeglex',(3,2)) sage: P. = PolynomialRing(QQbar, 2, order=t) # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field False sage: x > y # needs sage.rings.number_field True @@ -1151,7 +1151,7 @@ def sortkey_negwdeglex(self, f): sage: t = TermOrder('negwdeglex',(3,2)) sage: P. = PolynomialRing(QQbar, 2, order=t) # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field True sage: x^2 > y^3 # needs sage.rings.number_field True @@ -1171,7 +1171,7 @@ def sortkey_negwdegrevlex(self, f): sage: t = TermOrder('negwdegrevlex',(3,2)) sage: P. = PolynomialRing(QQbar, 2, order=t) # needs sage.rings.number_field - sage: x > y^2 # indirect doctest # needs sage.rings.number_field + sage: x > y^2 # indirect doctest # needs sage.rings.number_field True sage: x^2 > y^3 # needs sage.rings.number_field True @@ -1192,7 +1192,7 @@ def sortkey_block(self, f): sage: P. = PolynomialRing(QQbar, 6, # needs sage.rings.number_field ....: order='degrevlex(3),degrevlex(3)') - sage: a > c^4 # indirect doctest # needs sage.rings.number_field + sage: a > c^4 # indirect doctest # needs sage.rings.number_field False sage: a > e^4 # needs sage.rings.number_field True @@ -1227,7 +1227,7 @@ def greater_tuple_matrix(self,f,g): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 2, order='m(1,3,1,0)') # needs sage.rings.number_field - sage: y > x^2 # indirect doctest # needs sage.rings.number_field + sage: y > x^2 # indirect doctest # needs sage.rings.number_field True sage: y > x^3 # needs sage.rings.number_field False @@ -1256,7 +1256,7 @@ def greater_tuple_lex(self,f,g): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='lex') # needs sage.rings.number_field - sage: f = x + y^2; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = x + y^2; f.lm() # indirect doctest # needs sage.rings.number_field x This method is called by the lm/lc/lt methods of @@ -1278,7 +1278,7 @@ def greater_tuple_invlex(self,f,g): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='invlex') # needs sage.rings.number_field - sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field y sage: f = y + x^2; f.lm() # needs sage.rings.number_field y @@ -1302,7 +1302,7 @@ def greater_tuple_deglex(self,f,g): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='deglex') # needs sage.rings.number_field - sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field x sage: f = x + y^2*z; f.lm() # needs sage.rings.number_field y^2*z @@ -1328,7 +1328,7 @@ def greater_tuple_degrevlex(self,f,g): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='degrevlex') # needs sage.rings.number_field - sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field x sage: f = x + y^2*z; f.lm() # needs sage.rings.number_field y^2*z @@ -1412,7 +1412,7 @@ def greater_tuple_degneglex(self,f,g): EXAMPLES:: sage: P. = PolynomialRing(QQbar, 3, order='degneglex') # needs sage.rings.number_field - sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field y sage: f = x + y^2*z; f.lm() # needs sage.rings.number_field y^2*z @@ -1442,7 +1442,7 @@ def greater_tuple_neglex(self,f,g): sage: P. = PolynomialRing(QQbar, 6, # needs sage.rings.number_field ....: order='degrevlex(3),degrevlex(3)') - sage: f = a + c^4; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = a + c^4; f.lm() # indirect doctest # needs sage.rings.number_field c^4 sage: g = a + e^4; g.lm() # needs sage.rings.number_field a @@ -1464,7 +1464,7 @@ def greater_tuple_wdeglex(self,f,g): sage: t = TermOrder('wdeglex',(1,2,3)) sage: P. = PolynomialRing(QQbar, 3, order=t) # needs sage.rings.number_field - sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field y sage: f = x*y + z; f.lm() # needs sage.rings.number_field x*y @@ -1491,7 +1491,7 @@ def greater_tuple_wdegrevlex(self,f,g): sage: t = TermOrder('wdegrevlex',(1,2,3)) sage: P. = PolynomialRing(QQbar, 3, order=t) # needs sage.rings.number_field - sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = x + y; f.lm() # indirect doctest # needs sage.rings.number_field y sage: f = x + y^2*z; f.lm() # needs sage.rings.number_field y^2*z @@ -1581,7 +1581,7 @@ def greater_tuple_block(self, f,g): sage: P. = PolynomialRing(QQbar, 6, # needs sage.rings.number_field ....: order='degrevlex(3),degrevlex(3)') - sage: f = a + c^4; f.lm() # indirect doctest # needs sage.rings.number_field + sage: f = a + c^4; f.lm() # indirect doctest # needs sage.rings.number_field c^4 sage: g = a + e^4; g.lm() # needs sage.rings.number_field a @@ -1633,19 +1633,19 @@ def _repr_(self): Lexicographic term order """ if self._name == 'matrix': - return 'Matrix term order with matrix\n%s'%(self._matrix,) + return 'Matrix term order with matrix\n%s' % (self._matrix,) elif self._name == 'block': s = [] for t in self._blocks: if not t.is_weighted_degree_order(): - s.append('%s of length %d'%(t,len(t))) + s.append('%s of length %d' % (t,len(t))) else: # includes matrix order - s.append('%s'%(t,)) - return 'Block term order with blocks:\n(%s)'%(',\n '.join(s),) + s.append('%s' % (t,)) + return 'Block term order with blocks:\n(%s)' % (',\n '.join(s),) else: s = print_name_mapping.get(self._name,self._name) + ' term order' if self.is_weighted_degree_order(): - s = s + ' with weights %s'%(self._weights,) + s = s + ' with weights %s' % (self._weights,) return s def singular_str(self): @@ -2244,7 +2244,7 @@ def termorder_from_singular(S): ringorder_column = None weights_one_block = False for idx, block in enumerate(T): - blocktype = singular.eval('%s[1]'%block.name()) + blocktype = singular.eval('%s[1]' % block.name()) if blocktype in ['a']: weights = list(block[2].sage()) weights_one_block = all(w == 1 for w in weights) @@ -2266,7 +2266,7 @@ def termorder_from_singular(S): elif blocktype[0] in ['w','W']: order.append(TermOrder(inv_singular_name_mapping[blocktype], list(block[2].sage()))) else: - order.append(TermOrder(inv_singular_name_mapping[blocktype], ZZ(singular.eval("size(%s[2])"%block.name())))) + order.append(TermOrder(inv_singular_name_mapping[blocktype], ZZ(singular.eval("size(%s[2])" % block.name())))) weights_one_block = False if not order: diff --git a/src/sage/rings/power_series_pari.pyx b/src/sage/rings/power_series_pari.pyx index 24f4fde5be3..94a6d1baacb 100644 --- a/src/sage/rings/power_series_pari.pyx +++ b/src/sage/rings/power_series_pari.pyx @@ -347,16 +347,14 @@ cdef class PowerSeries_pari(PowerSeries): Substituting `p`-adic numbers:: + sage: # needs sage.rings.padics sage: f(100 + O(5^7)) 5^4 + 3*5^5 + 4*5^6 + 2*5^7 + 2*5^8 + O(5^9) - sage: ff = PowerSeriesRing(pAdicRing(5), 't', implementation='pari')(f) sage: ff (1 + O(5^20))*t^2 + (1 + O(5^20))*t^3 + O(t^6) - sage: ff(100 + O(5^7)) 5^4 + 3*5^5 + 4*5^6 + 2*5^7 + 2*5^8 + O(5^9) - sage: ff(100 + O(2^7)) Traceback (most recent call last): ... @@ -373,17 +371,14 @@ cdef class PowerSeries_pari(PowerSeries): Traceback (most recent call last): ... ValueError: can only substitute elements of positive valuation - sage: f(t^-2) Traceback (most recent call last): ... ValueError: can only substitute elements of positive valuation - - sage: f(2 + O(5^3)) + sage: f(2 + O(5^3)) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: can only substitute elements of positive valuation - sage: g = t^2 + t^3 sage: g(1 + t + O(t^2)) 2 + 5*t + O(t^2) @@ -492,7 +487,7 @@ cdef class PowerSeries_pari(PowerSeries): sage: f[:4] 32 - 80*t + 80*t^2 - 40*t^3 - sage: f = 1 + t^3 - 4*t^4 + O(t^7) ; f + sage: f = 1 + t^3 - 4*t^4 + O(t^7); f 1 + t^3 - 4*t^4 + O(t^7) sage: f[:4] 1 + t^3 + O(t^7) diff --git a/src/sage/rings/power_series_poly.pyx b/src/sage/rings/power_series_poly.pyx index 6cacab1f0c8..c7cd78db093 100644 --- a/src/sage/rings/power_series_poly.pyx +++ b/src/sage/rings/power_series_poly.pyx @@ -16,10 +16,9 @@ cdef class PowerSeries_poly(PowerSeries): """ EXAMPLES:: - sage: R. = PowerSeriesRing(CC) - sage: R + sage: R. = PowerSeriesRing(CC); R # needs sage.rings.real_mpfr Power Series Ring in q over Complex Field with 53 bits of precision - sage: loads(q.dumps()) == q + sage: loads(q.dumps()) == q # needs sage.rings.real_mpfr True sage: R. = QQ[[]] @@ -34,9 +33,9 @@ cdef class PowerSeries_poly(PowerSeries): Check that :trac:`22216` is fixed:: sage: R. = PowerSeriesRing(QQ) - sage: R(pari('1 + O(T)')) + sage: R(pari('1 + O(T)')) # needs sage.libs.pari 1 + O(T) - sage: R(pari('1/T + O(T)')) + sage: R(pari('1/T + O(T)')) # needs sage.libs.pari Traceback (most recent call last): ... ValueError: series has negative valuation @@ -105,9 +104,9 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: - sage: R. = GF(7)[[]] # optional - sage.rings.finite_rings - sage: f = 3 - t^3 + O(t^5) # optional - sage.rings.finite_rings - sage: f.polynomial() # optional - sage.rings.finite_rings + sage: R. = GF(7)[[]] + sage: f = 3 - t^3 + O(t^5) + sage: f.polynomial() 6*t^3 + 3 """ return self.__f @@ -159,12 +158,12 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: - sage: R. = GF(11)[[]] # optional - sage.rings.finite_rings - sage: bool(1 + t + O(t^18)) # optional - sage.rings.finite_rings + sage: R. = GF(11)[[]] + sage: bool(1 + t + O(t^18)) True - sage: bool(R(0)) # optional - sage.rings.finite_rings + sage: bool(R(0)) False - sage: bool(O(t^18)) # optional - sage.rings.finite_rings + sage: bool(O(t^18)) False """ return not not self.__f @@ -225,17 +224,17 @@ cdef class PowerSeries_poly(PowerSeries): A series defined over another ring can be substituted:: - sage: S. = GF(7)[[]] # optional - sage.rings.finite_rings - sage: f(2*u + u^3 + O(u^5)) # optional - sage.rings.finite_rings + sage: S. = GF(7)[[]] + sage: f(2*u + u^3 + O(u^5)) 4*u^2 + u^3 + 4*u^4 + 5*u^5 + O(u^6) As can a p-adic integer as long as the coefficient ring is compatible:: - sage: f(100 + O(5^7)) # optional - sage.rings.padics + sage: f(100 + O(5^7)) # needs sage.rings.padics 5^4 + 3*5^5 + 4*5^6 + 2*5^7 + 2*5^8 + O(5^9) - sage: f.change_ring(Zp(5))(100 + O(5^7)) # optional - sage.rings.padics + sage: f.change_ring(Zp(5))(100 + O(5^7)) # needs sage.rings.padics 5^4 + 3*5^5 + 4*5^6 + 2*5^7 + 2*5^8 + O(5^9) - sage: f.change_ring(Zp(5))(100 + O(2^7)) # optional - sage.rings.padics + sage: f.change_ring(Zp(5))(100 + O(2^7)) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: Cannot substitute this value @@ -248,7 +247,7 @@ cdef class PowerSeries_poly(PowerSeries): Traceback (most recent call last): ... ValueError: Can only substitute elements of positive valuation - sage: f(2 + O(5^3)) # optional - sage.rings.padics + sage: f(2 + O(5^3)) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: Can only substitute elements of positive valuation @@ -268,18 +267,18 @@ cdef class PowerSeries_poly(PowerSeries): Arguments beyond the first can refer to the base ring:: - sage: P. = GF(5)[] # optional - sage.rings.finite_rings - sage: Q. = P[[]] # optional - sage.rings.finite_rings - sage: h = (1 - x*y)^-1 + O(y^7); h # optional - sage.rings.finite_rings + sage: P. = GF(5)[] + sage: Q. = P[[]] + sage: h = (1 - x*y)^-1 + O(y^7); h 1 + x*y + x^2*y^2 + x^3*y^3 + x^4*y^4 + x^5*y^5 + x^6*y^6 + O(y^7) - sage: h(y^2, 3) # optional - sage.rings.finite_rings + sage: h(y^2, 3) 1 + 3*y^2 + 4*y^4 + 2*y^6 + y^8 + 3*y^10 + 4*y^12 + O(y^14) These secondary values can also be specified using keywords:: - sage: h(y=y^2, x=3) # optional - sage.rings.finite_rings + sage: h(y=y^2, x=3) 1 + 3*y^2 + 4*y^4 + 2*y^6 + y^8 + 3*y^10 + 4*y^12 + O(y^14) - sage: h(y^2, x=3) # optional - sage.rings.finite_rings + sage: h(y^2, x=3) 1 + 3*y^2 + 4*y^4 + 2*y^6 + y^8 + 3*y^10 + 4*y^12 + O(y^14) """ P = self.parent() @@ -375,27 +374,27 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: - sage: R. = GF(7)[[]] # optional - sage.rings.finite_rings - sage: f = 3 + 6*t^3 + O(t^5) # optional - sage.rings.finite_rings - sage: f._unsafe_mutate(0, 5) # optional - sage.rings.finite_rings - sage: f # optional - sage.rings.finite_rings + sage: R. = GF(7)[[]] + sage: f = 3 + 6*t^3 + O(t^5) + sage: f._unsafe_mutate(0, 5) + sage: f 5 + 6*t^3 + O(t^5) - sage: f._unsafe_mutate(2, 1) ; f # optional - sage.rings.finite_rings + sage: f._unsafe_mutate(2, 1); f 5 + t^2 + 6*t^3 + O(t^5) - Mutating can even bump up the precision:: - sage: f._unsafe_mutate(6, 1) ; f # optional - sage.rings.finite_rings + sage: f._unsafe_mutate(6, 1); f 5 + t^2 + 6*t^3 + t^6 + O(t^7) - sage: f._unsafe_mutate(0, 0) ; f # optional - sage.rings.finite_rings + sage: f._unsafe_mutate(0, 0); f t^2 + 6*t^3 + t^6 + O(t^7) - sage: f._unsafe_mutate(1, 0) ; f # optional - sage.rings.finite_rings + sage: f._unsafe_mutate(1, 0); f t^2 + 6*t^3 + t^6 + O(t^7) - sage: f._unsafe_mutate(11,0) ; f # optional - sage.rings.finite_rings + sage: f._unsafe_mutate(11,0); f t^2 + 6*t^3 + t^6 + O(t^12) - sage: g = t + O(t^7) # optional - sage.rings.finite_rings - sage: g._unsafe_mutate(1,0) ; g # optional - sage.rings.finite_rings + sage: g = t + O(t^7) + sage: g._unsafe_mutate(1,0); g O(t^7) """ self.__f._unsafe_mutate(i, value) @@ -435,7 +434,7 @@ cdef class PowerSeries_poly(PowerSeries): 32 - 80*t + 80*t^2 - 40*t^3 + 10*t^4 - t^5 sage: f[:4] 32 - 80*t + 80*t^2 - 40*t^3 - sage: f = 1 + t^3 - 4*t^4 + O(t^7) ; f + sage: f = 1 + t^3 - 4*t^4 + O(t^7); f 1 + t^3 - 4*t^4 + O(t^7) sage: f[:4] 1 + t^3 + O(t^7) @@ -554,9 +553,9 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: - sage: R. = GF(7)[[]] # optional - sage.rings.finite_rings - sage: f = t + 3*t^4 + O(t^11) # optional - sage.rings.finite_rings - sage: f * GF(7)(3) # optional - sage.rings.finite_rings + sage: R. = GF(7)[[]] + sage: f = t + 3*t^4 + O(t^11) + sage: f * GF(7)(3) 3*t + 2*t^4 + O(t^11) """ return PowerSeries_poly(self._parent, self.__f * c, self._prec, check=False) @@ -567,9 +566,9 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: - sage: R. = GF(11)[[]] # optional - sage.rings.finite_rings - sage: f = 1 + 3*t^4 + O(t^120) # optional - sage.rings.finite_rings - sage: 2 * f # optional - sage.rings.finite_rings + sage: R. = GF(11)[[]] + sage: f = 1 + 3*t^4 + O(t^120) + sage: 2 * f 2 + 6*t^4 + O(t^120) """ return PowerSeries_poly(self._parent, c * self.__f, self._prec, check=False) @@ -597,11 +596,12 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: - sage: R. = GF(2)[[]] # optional - sage.rings.finite_rings - sage: f = t + t^4 + O(t^7) # optional - sage.rings.finite_rings - sage: f >> 1 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(2)[[]] + sage: f = t + t^4 + O(t^7) + sage: f >> 1 1 + t^3 + O(t^6) - sage: f >> 10 # optional - sage.rings.finite_rings + sage: f >> 10 O(t^0) """ if n: @@ -733,10 +733,10 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: - sage: R. = GF(2)[[]] # optional - sage.rings.finite_rings - sage: f = 1/(1+I+O(I^8)); f # optional - sage.rings.finite_rings + sage: R. = GF(2)[[]] + sage: f = 1/(1+I+O(I^8)); f 1 + I + I^2 + I^3 + I^4 + I^5 + I^6 + I^7 + O(I^8) - sage: f.truncate(5) # optional - sage.rings.finite_rings + sage: f.truncate(5) I^4 + I^3 + I^2 + I + 1 """ if prec is infinity: @@ -764,10 +764,10 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: - sage: R. = GF(2)[[]] # optional - sage.rings.finite_rings - sage: f = 1/(1+I+O(I^8)); f # optional - sage.rings.finite_rings + sage: R. = GF(2)[[]] + sage: f = 1/(1+I+O(I^8)); f 1 + I + I^2 + I^3 + I^4 + I^5 + I^6 + I^7 + O(I^8) - sage: f.truncate_powerseries(5) # optional - sage.rings.finite_rings + sage: f.truncate_powerseries(5) 1 + I + I^2 + I^3 + I^4 + O(I^5) """ return PowerSeries_poly(self._parent, self.__f.truncate(prec), @@ -845,8 +845,8 @@ cdef class PowerSeries_poly(PowerSeries): TESTS:: sage: R. = PowerSeriesRing(QQ, sparse=True) - sage: x = var('x') # optional - sage.symbolic - sage: t.derivative(x) # optional - sage.symbolic + sage: x = var('x') # needs sage.symbolic + sage: t.derivative(x) Traceback (most recent call last): ... ValueError: cannot differentiate with respect to x @@ -891,7 +891,7 @@ cdef class PowerSeries_poly(PowerSeries): sage: t = PowerSeriesRing(QQ,'t').gen() sage: f = t + 5*t^2 + 21*t^3 - sage: g = f.integral() ; g + sage: g = f.integral(); g 1/2*t^2 + 5/3*t^3 + 21/4*t^4 sage: g.parent() Power Series Ring in t over Rational Field @@ -1035,10 +1035,10 @@ cdef class PowerSeries_poly(PowerSeries): ... ValueError: Series must have valuation one for reversion. - sage: Series = PowerSeriesRing(SR, 'x') # optional - sage.symbolic - sage: ser = Series([0, pi]); ser # optional - sage.symbolic + sage: Series = PowerSeriesRing(SR, 'x') # needs sage.symbolic + sage: ser = Series([0, pi]); ser # needs sage.symbolic pi*x - sage: ser.reverse() # optional - sage.symbolic + sage: ser.reverse() # needs sage.symbolic 1/pi*x + O(x^20) """ if self.valuation() != 1: @@ -1191,20 +1191,21 @@ cdef class PowerSeries_poly(PowerSeries): EXAMPLES:: + sage: # needs sage.symbolic sage: R. = PowerSeriesRing(QQ) sage: s = R([1,2,3,4,5], prec=10); s 1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 + O(x^10) - sage: SR(s) # optional - sage.symbolic + sage: SR(s) 1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 + Order(x^10) - sage: SR(s).is_terminating_series() # optional - sage.symbolic + sage: SR(s).is_terminating_series() False - sage: SR(s).variables() # optional - sage.symbolic + sage: SR(s).variables() (x,) sage: s = R([1,2,3,4,5]); s 1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 - sage: SR(s) # optional - sage.symbolic + sage: SR(s) 1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 - sage: _.is_terminating_series() # optional - sage.symbolic + sage: _.is_terminating_series() True TESTS: @@ -1212,7 +1213,7 @@ cdef class PowerSeries_poly(PowerSeries): Check that :trac:`18094` is fixed:: sage: R. = PolynomialRing(ZZ) - sage: SR(R(0).add_bigoh(20)) # optional - sage.symbolic + sage: SR(R(0).add_bigoh(20)) # needs sage.symbolic Order(x^20) """ from sage.symbolic.ring import SR diff --git a/src/sage/rings/power_series_ring.py b/src/sage/rings/power_series_ring.py index e023867b67e..b43306adb36 100644 --- a/src/sage/rings/power_series_ring.py +++ b/src/sage/rings/power_series_ring.py @@ -59,13 +59,14 @@ :: - sage: K. = PowerSeriesRing(SR, default_prec=5) # optional - sage.symbolic - sage: a, b, c = var('a,b,c') # optional - sage.symbolic - sage: f = a + b*t + c*t^2 + O(t^3) # optional - sage.symbolic - sage: f*f # optional - sage.symbolic + sage: # needs sage.symbolic + sage: K. = PowerSeriesRing(SR, default_prec=5) + sage: a, b, c = var('a,b,c') + sage: f = a + b*t + c*t^2 + O(t^3) + sage: f*f a^2 + 2*a*b*t + (b^2 + 2*a*c)*t^2 + O(t^3) - sage: f = sqrt(2) + sqrt(3)*t + O(t^3) # optional - sage.symbolic - sage: f^2 # optional - sage.symbolic + sage: f = sqrt(2) + sqrt(3)*t + O(t^3) + sage: f^2 2 + 2*sqrt(3)*sqrt(2)*t + 3*t^2 + O(t^3) Elements are first coerced to constants in ``base_ring``, then coerced @@ -97,10 +98,10 @@ Choose another implementation of the attached polynomial ring:: sage: R. = PowerSeriesRing(ZZ) - sage: type(t.polynomial()) + sage: type(t.polynomial()) # needs sage.libs.flint <... 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'> - sage: S. = PowerSeriesRing(ZZ, implementation='NTL') - sage: type(s.polynomial()) + sage: S. = PowerSeriesRing(ZZ, implementation='NTL') # needs sage.libs.ntl + sage: type(s.polynomial()) # needs sage.libs.ntl <... 'sage.rings.polynomial.polynomial_integer_dense_ntl.Polynomial_integer_dense_ntl'> AUTHORS: @@ -258,13 +259,13 @@ def PowerSeriesRing(base_ring, name=None, arg2=None, names=None, Power series ring over finite field:: - sage: S = PowerSeriesRing(GF(65537),'x,y'); S # optional - sage.rings.finite_rings + sage: S = PowerSeriesRing(GF(65537),'x,y'); S # needs sage.rings.finite_rings Multivariate Power Series Ring in x, y over Finite Field of size 65537 Power series ring with many variables:: - sage: R = PowerSeriesRing(ZZ, ['x%s'%p for p in primes(100)]); R # optional - sage.libs.pari + sage: R = PowerSeriesRing(ZZ, ['x%s'%p for p in primes(100)]); R # needs sage.libs.pari Multivariate Power Series Ring in x2, x3, x5, x7, x11, x13, x17, x19, x23, x29, x31, x37, x41, x43, x47, x53, x59, x61, x67, x71, x73, x79, x83, x89, x97 over Integer Ring @@ -274,12 +275,12 @@ def PowerSeriesRing(base_ring, name=None, arg2=None, names=None, :: - sage: R.inject_variables() # optional - sage.libs.pari + sage: R.inject_variables() # needs sage.libs.pari Defining x2, x3, x5, x7, x11, x13, x17, x19, x23, x29, x31, x37, x41, x43, x47, x53, x59, x61, x67, x71, x73, x79, x83, x89, x97 - sage: f = x47 + 3*x11*x29 - x19 + R.O(3) # optional - sage.libs.pari - sage: f in R # optional - sage.libs.pari + sage: f = x47 + 3*x11*x29 - x19 + R.O(3) # needs sage.libs.pari + sage: f in R # needs sage.libs.pari True @@ -519,11 +520,11 @@ def __init__(self, base_ring, name=None, default_prec=None, sparse=False, commutative ring, but also a complete discrete valuation ring (CDVR). The appropriate (sub)category is automatically set in this case:: - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: R. = k[[]] # optional - sage.rings.finite_rings - sage: R.category() # optional - sage.rings.finite_rings + sage: k = GF(11) + sage: R. = k[[]] + sage: R.category() Category of complete discrete valuation rings - sage: TestSuite(R).run() # optional - sage.rings.finite_rings + sage: TestSuite(R).run() It is checked that the default precision is non-negative (see :trac:`19409`):: @@ -615,16 +616,16 @@ def _repr_(self): EXAMPLES:: - sage: R = GF(17)[['y']] # optional - sage.rings.finite_rings - sage: R # optional - sage.rings.finite_rings + sage: R = GF(17)[['y']] + sage: R Power Series Ring in y over Finite Field of size 17 - sage: R.__repr__() # optional - sage.rings.finite_rings + sage: R.__repr__() 'Power Series Ring in y over Finite Field of size 17' - sage: R.rename('my power series ring') # optional - sage.rings.finite_rings - sage: R # optional - sage.rings.finite_rings + sage: R.rename('my power series ring') + sage: R my power series ring """ - s = "Power Series Ring in %s over %s"%(self.variable_name(), self.base_ring()) + s = "Power Series Ring in %s over %s" % (self.variable_name(), self.base_ring()) if self.is_sparse(): s = 'Sparse ' + s return s @@ -661,14 +662,14 @@ def _latex_(self): EXAMPLES:: - sage: R = GF(17)[['y']] # optional - sage.rings.finite_rings - sage: latex(R) # indirect doctest # optional - sage.rings.finite_rings + sage: R = GF(17)[['y']] + sage: latex(R) # indirect doctest \Bold{F}_{17}[[y]] - sage: R = GF(17)[['y12']] # optional - sage.rings.finite_rings - sage: latex(R) # optional - sage.rings.finite_rings + sage: R = GF(17)[['y12']] + sage: latex(R) \Bold{F}_{17}[[y_{12}]] """ - return "%s[[%s]]"%(latex.latex(self.base_ring()), self.latex_variable_names()[0]) + return "%s[[%s]]" % (latex.latex(self.base_ring()), self.latex_variable_names()[0]) def _coerce_map_from_(self, S): """ @@ -679,21 +680,21 @@ def _coerce_map_from_(self, S): EXAMPLES:: - sage: A = GF(17)[['x']] # optional - sage.rings.finite_rings - sage: A.has_coerce_map_from(ZZ) # indirect doctest # optional - sage.rings.finite_rings + sage: A = GF(17)[['x']] + sage: A.has_coerce_map_from(ZZ) # indirect doctest True - sage: A.has_coerce_map_from(ZZ['x']) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(ZZ['x']) True - sage: A.has_coerce_map_from(ZZ['y']) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(ZZ['y']) False - sage: A.has_coerce_map_from(ZZ[['x']]) # optional - sage.rings.finite_rings + sage: A.has_coerce_map_from(ZZ[['x']]) True """ if self.base_ring().has_coerce_map_from(S): return True if (is_PolynomialRing(S) or is_PowerSeriesRing(S)) and self.base_ring().has_coerce_map_from(S.base_ring()) \ - and self.variable_names()==S.variable_names(): + and self.variable_names() == S.variable_names(): return True def _element_constructor_(self, f, prec=infinity, check=True): @@ -759,15 +760,16 @@ def _element_constructor_(self, f, prec=infinity, check=True): Conversion from symbolic series:: - sage: x,y = var('x,y') # optional - sage.symbolic - sage: s = (1/(1-x)).series(x,3); s # optional - sage.symbolic + sage: # needs sage.symbolic + sage: x,y = var('x,y') + sage: s = (1/(1-x)).series(x,3); s 1 + 1*x + 1*x^2 + Order(x^3) - sage: R. = PowerSeriesRing(QQ) # optional - sage.symbolic - sage: R(s) # optional - sage.symbolic + sage: R. = PowerSeriesRing(QQ) + sage: R(s) 1 + x + x^2 + O(x^3) - sage: ex = (gamma(1-y)).series(y,3) # optional - sage.symbolic - sage: R. = PowerSeriesRing(SR) # optional - sage.symbolic - sage: R(ex) # optional - sage.symbolic + sage: ex = (gamma(1-y)).series(y,3) + sage: R. = PowerSeriesRing(SR) + sage: R(ex) 1 + euler_gamma*y + (1/2*euler_gamma^2 + 1/12*pi^2)*y^2 + O(y^3) Laurent series with non-negative valuation are accepted (see @@ -891,16 +893,16 @@ def _coerce_impl(self, x): We illustrate canonical coercion between power series rings with compatible base rings:: - sage: R. = PowerSeriesRing(GF(7)['w']) # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(7)['w']) sage: S = PowerSeriesRing(ZZ, 't') sage: f = S([1,2,3,4]); f 1 + 2*t + 3*t^2 + 4*t^3 - sage: g = R.coerce(f); g # optional - sage.rings.finite_rings + sage: g = R.coerce(f); g 1 + 2*t + 3*t^2 + 4*t^3 - sage: parent(g) # optional - sage.rings.finite_rings + sage: parent(g) Power Series Ring in t over Univariate Polynomial Ring in w over Finite Field of size 7 - sage: S.coerce(g) # optional - sage.rings.finite_rings + sage: S.coerce(g) Traceback (most recent call last): ... TypeError: no canonical coercion @@ -981,11 +983,11 @@ def base_extend(self, R): EXAMPLES:: - sage: R. = GF(7)[[]]; R # optional - sage.rings.finite_rings + sage: R. = GF(7)[[]]; R Power Series Ring in T over Finite Field of size 7 - sage: R.change_ring(ZZ) # optional - sage.rings.finite_rings + sage: R.change_ring(ZZ) Power Series Ring in T over Integer Ring - sage: R.base_extend(ZZ) # optional - sage.rings.finite_rings + sage: R.base_extend(ZZ) Traceback (most recent call last): ... TypeError: no base extension defined @@ -1003,13 +1005,13 @@ def change_ring(self, R): sage: R. = QQ[[]]; R Power Series Ring in T over Rational Field - sage: R.change_ring(GF(7)) # optional - sage.rings.finite_rings + sage: R.change_ring(GF(7)) Power Series Ring in T over Finite Field of size 7 - sage: R.base_extend(GF(7)) # optional - sage.rings.finite_rings + sage: R.base_extend(GF(7)) Traceback (most recent call last): ... TypeError: no base extension defined - sage: R.base_extend(QuadraticField(3,'a')) # optional - sage.rings.number_field + sage: R.base_extend(QuadraticField(3,'a')) # needs sage.rings.number_field Power Series Ring in T over Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878? """ @@ -1234,11 +1236,11 @@ def residue_field(self): EXAMPLES:: - sage: R. = PowerSeriesRing(GF(17)) # optional - sage.rings.finite_rings - sage: R.residue_field() # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(17)) + sage: R.residue_field() Finite Field of size 17 - sage: R. = PowerSeriesRing(Zp(5)) # optional - sage.rings.padics - sage: R.residue_field() # optional - sage.rings.padics + sage: R. = PowerSeriesRing(Zp(5)) # needs sage.rings.padics + sage: R.residue_field() # needs sage.rings.padics Finite Field of size 5 """ if self.base_ring().is_field(): @@ -1331,10 +1333,10 @@ def fraction_field(self): EXAMPLES:: - sage: R. = PowerSeriesRing(GF(7)) # optional - sage.rings.finite_rings - sage: R.fraction_field() # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(7)) + sage: R.fraction_field() Laurent Series Ring in t over Finite Field of size 7 - sage: Frac(R) # optional - sage.rings.finite_rings + sage: Frac(R) Laurent Series Ring in t over Finite Field of size 7 """ return self.laurent_series_ring() diff --git a/src/sage/rings/power_series_ring_element.pyx b/src/sage/rings/power_series_ring_element.pyx index e5e2df79e1b..2436db7af1d 100644 --- a/src/sage/rings/power_series_ring_element.pyx +++ b/src/sage/rings/power_series_ring_element.pyx @@ -130,9 +130,9 @@ def is_PowerSeries(x): True sage: is_PowerSeries(0) False - sage: var('x') # optional - sage.symbolic + sage: var('x') # needs sage.symbolic x - sage: is_PowerSeries(1 + x^2) # optional - sage.symbolic + sage: is_PowerSeries(1 + x^2) # needs sage.symbolic False """ return isinstance(x, PowerSeries) @@ -152,9 +152,9 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: - sage: PowerSeriesRing(CC, 'q') + sage: PowerSeriesRing(CC, 'q') # needs sage.rings.real_mpfr Power Series Ring in q over Complex Field with 53 bits of precision - sage: T = PowerSeriesRing(GF(3), 5, 't'); T # optional - sage.rings.finite_rings + sage: T = PowerSeriesRing(GF(3), 5, 't'); T Multivariate Power Series Ring in t0, t1, t2, t3, t4 over Finite Field of size 3 """ @@ -276,13 +276,13 @@ cdef class PowerSeries(AlgebraElement): sage: R. = QQ[[]]; R Power Series Ring in T over Rational Field sage: f = 1 - 1/2*T + 1/3*T^2 + O(T^3) - sage: f.base_extend(GF(5)) # optional - sage.rings.finite_rings + sage: f.base_extend(GF(5)) Traceback (most recent call last): ... TypeError: no base extension defined - sage: f.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: f.change_ring(GF(5)) 1 + 2*T + 2*T^2 + O(T^3) - sage: f.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: f.change_ring(GF(3)) Traceback (most recent call last): ... ZeroDivisionError: inverse of Mod(0, 3) does not exist @@ -292,18 +292,18 @@ cdef class PowerSeries(AlgebraElement): :: - sage: K. = NumberField(cyclotomic_polynomial(3), 'a') # optional - sage.rings.number_field - sage: R. = K[['t']] # optional - sage.rings.number_field - sage: (4*t).change_ring(ZZ) # optional - sage.rings.number_field + sage: K. = NumberField(cyclotomic_polynomial(3), 'a') # needs sage.rings.number_field + sage: R. = K[['t']] # needs sage.rings.number_field + sage: (4*t).change_ring(ZZ) # needs sage.rings.number_field 4*t This does not succeed because ``ZZ(K(a+1))`` is not defined. :: - sage: K. = NumberField(cyclotomic_polynomial(3), 'a') # optional - sage.rings.number_field - sage: R. = K[['t']] # optional - sage.rings.number_field - sage: ((a+1)*t).change_ring(ZZ) # optional - sage.rings.number_field + sage: K. = NumberField(cyclotomic_polynomial(3), 'a') # needs sage.rings.number_field + sage: R. = K[['t']] # needs sage.rings.number_field + sage: ((a+1)*t).change_ring(ZZ) # needs sage.rings.number_field Traceback (most recent call last): ... TypeError: Unable to coerce a + 1 to an integer @@ -483,11 +483,11 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: - sage: A. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: x = t + t^2 + O(t^5) # optional - sage.rings.finite_rings - sage: x.lift_to_precision(10) # optional - sage.rings.finite_rings + sage: A. = PowerSeriesRing(GF(5)) + sage: x = t + t^2 + O(t^5) + sage: x.lift_to_precision(10) t + t^2 + O(t^10) - sage: x.lift_to_precision() # optional - sage.rings.finite_rings + sage: x.lift_to_precision() t + t^2 """ @@ -521,8 +521,8 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: - sage: R. = GF(49,'alpha')[[]] # optional - sage.rings.finite_rings - sage: (t^2 + O(t^3)).base_ring() # optional - sage.rings.finite_rings + sage: R. = GF(49,'alpha')[[]] # needs sage.rings.finite_rings + sage: (t^2 + O(t^3)).base_ring() # needs sage.rings.finite_rings Finite Field in alpha of size 7^2 """ return self._parent.base_ring() @@ -799,10 +799,10 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: - sage: R. = GF(2)[[]] # optional - sage.rings.finite_rings - sage: f = 1/(1+I+O(I^8)); f # optional - sage.rings.finite_rings + sage: R. = GF(2)[[]] + sage: f = 1/(1+I+O(I^8)); f 1 + I + I^2 + I^3 + I^4 + I^5 + I^6 + I^7 + O(I^8) - sage: f.truncate(5) # optional - sage.rings.finite_rings + sage: f.truncate(5) I^4 + I^3 + I^2 + I + 1 """ if prec is infinity: @@ -845,6 +845,7 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: + sage: # needs sage.rings.complex_double sage.symbolic sage: R. = CDF[[]] sage: f = CDF(pi)^2 + m^3 + CDF(e)*m^4 + O(m^10); f # abs tol 5e-16 9.869604401089358 + 0.0*m + 0.0*m^2 + 1.0*m^3 + 2.718281828459045*m^4 + O(m^10) @@ -1104,9 +1105,9 @@ cdef class PowerSeries(AlgebraElement): """ EXAMPLES:: - sage: R. = Qp(7)[[]] # optional - sage.rings.padics - sage: f = (48*67 + 46*67^2)*T + (1 + 42*67 + 5*67^3)*T^2 + O(T^3) # optional - sage.rings.padics - sage: f % 67 # optional - sage.rings.padics + sage: R. = Qp(7)[[]] # needs sage.rings.padics + sage: f = (48*67 + 46*67^2)*T + (1 + 42*67 + 5*67^3)*T^2 + O(T^3) # needs sage.rings.padics + sage: f % 67 # needs sage.rings.padics T^2 + O(T^3) """ from sage.rings.power_series_ring import PowerSeriesRing @@ -1194,12 +1195,13 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: - sage: R. = PowerSeriesRing(QQ, implementation='pari') # optional - sage.libs.pari - sage: f = exp(x) + O(x^7); f # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: R. = PowerSeriesRing(QQ, implementation='pari') + sage: f = exp(x) + O(x^7); f 1 + x + 1/2*x^2 + 1/6*x^3 + 1/24*x^4 + 1/120*x^5 + 1/720*x^6 + O(x^7) - sage: f << 2 # optional - sage.libs.pari + sage: f << 2 x^2 + x^3 + 1/2*x^4 + 1/6*x^5 + 1/24*x^6 + 1/120*x^7 + 1/720*x^8 + O(x^9) - sage: (f << 99) >> 99 # optional - sage.libs.pari + sage: (f << 99) >> 99 1 + x + 1/2*x^2 + 1/6*x^3 + 1/24*x^4 + 1/120*x^5 + 1/720*x^6 + O(x^7) """ return self.shift(n) @@ -1212,15 +1214,16 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: - sage: R. = PowerSeriesRing(QQ, implementation='pari') # optional - sage.libs.pari - sage: f = exp(x) + O(x^7) # optional - sage.libs.pari - sage: f >> 3 # optional - sage.libs.pari + sage: # needs sage.libs.pari + sage: R. = PowerSeriesRing(QQ, implementation='pari') + sage: f = exp(x) + O(x^7) + sage: f >> 3 1/6 + 1/24*x + 1/120*x^2 + 1/720*x^3 + O(x^4) - sage: f >> 7 # optional - sage.libs.pari + sage: f >> 7 O(x^0) - sage: f >> 99 # optional - sage.libs.pari + sage: f >> 99 O(x^0) - sage: (f >> 99) << 99 # optional - sage.libs.pari + sage: (f >> 99) << 99 O(x^99) """ return self.shift(-n) @@ -1266,9 +1269,9 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: - sage: R. = SR[[]] # optional - sage.symbolic - sage: f = (1+I)*x^2 + 3*x - I # optional - sage.symbolic - sage: f.map_coefficients(lambda z: z.conjugate()) # optional - sage.symbolic + sage: R. = SR[[]] # needs sage.symbolic + sage: f = (1+I)*x^2 + 3*x - I # needs sage.symbolic + sage: f.map_coefficients(lambda z: z.conjugate()) # needs sage.symbolic I + 3*x + (-I + 1)*x^2 sage: R. = ZZ[[]] sage: f = x^2 + 2 @@ -1278,28 +1281,28 @@ cdef class PowerSeries(AlgebraElement): Examples with different base ring:: sage: R. = ZZ[[]] - sage: k = GF(2) # optional - sage.rings.finite_rings - sage: residue = lambda x: k(x) # optional - sage.rings.finite_rings - sage: f = 4*x^2+x+3 # optional - sage.rings.finite_rings - sage: g = f.map_coefficients(residue); g # optional - sage.rings.finite_rings + sage: k = GF(2) + sage: residue = lambda x: k(x) + sage: f = 4*x^2+x+3 + sage: g = f.map_coefficients(residue); g 1 + x - sage: g.parent() # optional - sage.rings.finite_rings + sage: g.parent() Power Series Ring in x over Integer Ring - sage: g = f.map_coefficients(residue, new_base_ring=k); g # optional - sage.rings.finite_rings + sage: g = f.map_coefficients(residue, new_base_ring=k); g 1 + x - sage: g.parent() # optional - sage.rings.finite_rings + sage: g.parent() Power Series Ring in x over Finite Field of size 2 - sage: residue = k.coerce_map_from(ZZ) # optional - sage.rings.finite_rings - sage: g = f.map_coefficients(residue); g # optional - sage.rings.finite_rings + sage: residue = k.coerce_map_from(ZZ) + sage: g = f.map_coefficients(residue); g 1 + x - sage: g.parent() # optional - sage.rings.finite_rings + sage: g.parent() Power Series Ring in x over Finite Field of size 2 Tests other implementations:: - sage: R. = PowerSeriesRing(GF(11), implementation='pari') # optional - sage.rings.finite_rings - sage: f = q - q^3 + O(q^10) # optional - sage.rings.finite_rings - sage: f.map_coefficients(lambda c: c - 2) # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(11), implementation='pari') + sage: f = q - q^3 + O(q^10) + sage: f.map_coefficients(lambda c: c - 2) 10*q + 8*q^3 + O(q^10) """ pol = self.polynomial() @@ -1336,13 +1339,13 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: sage: t = PowerSeriesRing(QQ, 't').gen() - sage: s = sum(factorial(k) * t**k for k in range(12)).O(12) - sage: s.jacobi_continued_fraction() + sage: s = sum(factorial(k) * t**k for k in range(12)).O(12) # needs sage.rings.complex_double + sage: s.jacobi_continued_fraction() # needs sage.rings.complex_double ((-1, -1), (-3, -4), (-5, -9), (-7, -16), (-9, -25)) Another example:: - sage: (log(1+t)/t).jacobi_continued_fraction() # optional - sage.symbolic + sage: (log(1+t)/t).jacobi_continued_fraction() ((1/2, -1/12), (1/2, -1/15), (1/2, -9/140), @@ -1401,13 +1404,13 @@ cdef class PowerSeries(AlgebraElement): EXAMPLES:: sage: t = PowerSeriesRing(QQ, 't').gen() - sage: s = sum(catalan_number(k) * t**k for k in range(12)).O(12) # optional - sage.combinat - sage: s.stieltjes_continued_fraction() # optional - sage.combinat + sage: s = sum(catalan_number(k) * t**k for k in range(12)).O(12) + sage: s.stieltjes_continued_fraction() (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) Another example:: - sage: (exp(t)).stieltjes_continued_fraction() # optional - sage.symbolic + sage: (exp(t)).stieltjes_continued_fraction() (1, -1/2, 1/6, @@ -1557,7 +1560,7 @@ cdef class PowerSeries(AlgebraElement): :: - sage: K. = PowerSeriesRing(CDF, 5) + sage: K. = PowerSeriesRing(CDF, 5) # needs sage.rings.complex_double sage: v = sqrt(-1 + t + t^3, all=True); v [1.0*I - 0.5*I*t - 0.125*I*t^2 - 0.5625*I*t^3 - 0.2890625*I*t^4 + O(t^5), -1.0*I + 0.5*I*t + 0.125*I*t^2 + 0.5625*I*t^3 + 0.2890625*I*t^4 + O(t^5)] @@ -1764,11 +1767,11 @@ cdef class PowerSeries(AlgebraElement): Positive characteristic:: - sage: R. = GF(3)[[]] # optional - sage.rings.finite_rings - sage: p = 1 + 2 * u^2 # optional - sage.rings.finite_rings - sage: p.nth_root(4) # optional - sage.rings.finite_rings + sage: R. = GF(3)[[]] + sage: p = 1 + 2 * u^2 + sage: p.nth_root(4) 1 + 2*u^2 + u^6 + 2*u^8 + u^12 + 2*u^14 + O(u^20) - sage: p.nth_root(4)**4 # optional - sage.rings.finite_rings + sage: p.nth_root(4)**4 1 + 2*u^2 + O(u^20) TESTS: @@ -1839,14 +1842,14 @@ cdef class PowerSeries(AlgebraElement): sage: t = PowerSeriesRing(QQ, 't').gen() sage: f = (t + t**2).O(4) - sage: cos(f) # optional - sage.symbolic + sage: cos(f) 1 - 1/2*t^2 - t^3 + O(t^4) For several variables:: sage: T. = PowerSeriesRing(ZZ,2) sage: f = a + b + a*b + T.O(3) - sage: cos(f) # optional - sage.symbolic + sage: cos(f) 1 - 1/2*a^2 - a*b - 1/2*b^2 + O(a, b)^3 sage: f.cos() 1 - 1/2*a^2 - a*b - 1/2*b^2 + O(a, b)^3 @@ -1857,7 +1860,7 @@ cdef class PowerSeries(AlgebraElement): one raises an error:: sage: g = 2+f - sage: cos(g) # optional - sage.symbolic + sage: cos(g) Traceback (most recent call last): ... ValueError: can only apply cos to formal power series with zero constant term @@ -1866,16 +1869,16 @@ cdef class PowerSeries(AlgebraElement): sage: T.default_prec() 12 - sage: cos(a) # optional - sage.symbolic + sage: cos(a) 1 - 1/2*a^2 + 1/24*a^4 - 1/720*a^6 + 1/40320*a^8 - 1/3628800*a^10 + O(a, b)^12 sage: a.cos(prec=5) 1 - 1/2*a^2 + 1/24*a^4 + O(a, b)^5 - sage: cos(a + T.O(5)) # optional - sage.symbolic + sage: cos(a + T.O(5)) 1 - 1/2*a^2 + 1/24*a^4 + O(a, b)^5 TESTS:: - sage: cos(a^2 + T.O(5)) # optional - sage.symbolic + sage: cos(a^2 + T.O(5)) 1 - 1/2*a^4 + O(a, b)^5 """ R = self.parent() @@ -1924,14 +1927,14 @@ cdef class PowerSeries(AlgebraElement): sage: t = PowerSeriesRing(QQ, 't').gen() sage: f = (t + t**2).O(4) - sage: sin(f) # optional - sage.symbolic + sage: sin(f) t + t^2 - 1/6*t^3 + O(t^4) For several variables:: sage: T. = PowerSeriesRing(ZZ,2) sage: f = a + b + a*b + T.O(3) - sage: sin(f) # optional - sage.symbolic + sage: sin(f) a + b + a*b + O(a, b)^3 sage: f.sin() a + b + a*b + O(a, b)^3 @@ -1942,7 +1945,7 @@ cdef class PowerSeries(AlgebraElement): one raises an error:: sage: g = 2+f - sage: sin(g) # optional - sage.symbolic + sage: sin(g) Traceback (most recent call last): ... ValueError: can only apply sin to formal power series with zero constant term @@ -1951,16 +1954,16 @@ cdef class PowerSeries(AlgebraElement): sage: T.default_prec() 12 - sage: sin(a) # optional - sage.symbolic + sage: sin(a) a - 1/6*a^3 + 1/120*a^5 - 1/5040*a^7 + 1/362880*a^9 - 1/39916800*a^11 + O(a, b)^12 sage: a.sin(prec=5) a - 1/6*a^3 + O(a, b)^5 - sage: sin(a + T.O(5)) # optional - sage.symbolic + sage: sin(a + T.O(5)) a - 1/6*a^3 + O(a, b)^5 TESTS:: - sage: sin(a^2 + T.O(5)) # optional - sage.symbolic + sage: sin(a^2 + T.O(5)) a^2 + O(a, b)^5 """ R = self.parent() @@ -2010,14 +2013,14 @@ cdef class PowerSeries(AlgebraElement): sage: t = PowerSeriesRing(QQ, 't').gen() sage: f = (t + t**2).O(4) - sage: tan(f) # optional - sage.symbolic + sage: tan(f) t + t^2 + 1/3*t^3 + O(t^4) For several variables:: sage: T. = PowerSeriesRing(ZZ,2) sage: f = a + b + a*b + T.O(3) - sage: tan(f) # optional - sage.symbolic + sage: tan(f) a + b + a*b + O(a, b)^3 sage: f.tan() a + b + a*b + O(a, b)^3 @@ -2028,7 +2031,7 @@ cdef class PowerSeries(AlgebraElement): one raises an error:: sage: g = 2 + f - sage: tan(g) # optional - sage.symbolic + sage: tan(g) Traceback (most recent call last): ... ValueError: can only apply tan to formal power series with zero constant term @@ -2037,16 +2040,16 @@ cdef class PowerSeries(AlgebraElement): sage: T.default_prec() 12 - sage: tan(a) # optional - sage.symbolic + sage: tan(a) a + 1/3*a^3 + 2/15*a^5 + 17/315*a^7 + 62/2835*a^9 + 1382/155925*a^11 + O(a, b)^12 sage: a.tan(prec=5) a + 1/3*a^3 + O(a, b)^5 - sage: tan(a + T.O(5)) # optional - sage.symbolic + sage: tan(a + T.O(5)) a + 1/3*a^3 + O(a, b)^5 TESTS:: - sage: tan(a^2 + T.O(5)) # optional - sage.symbolic + sage: tan(a^2 + T.O(5)) a^2 + O(a, b)^5 """ if not self[0].is_zero(): @@ -2074,14 +2077,14 @@ cdef class PowerSeries(AlgebraElement): sage: t = PowerSeriesRing(QQ, 't').gen() sage: f = (t + t**2).O(4) - sage: sinh(f) # optional - sage.symbolic + sage: sinh(f) t + t^2 + 1/6*t^3 + O(t^4) For several variables:: sage: T. = PowerSeriesRing(ZZ,2) sage: f = a + b + a*b + T.O(3) - sage: sinh(f) # optional - sage.symbolic + sage: sinh(f) a + b + a*b + O(a, b)^3 sage: f.sinh() a + b + a*b + O(a, b)^3 @@ -2092,7 +2095,7 @@ cdef class PowerSeries(AlgebraElement): one raises an error:: sage: g = 2 + f - sage: sinh(g) # optional - sage.symbolic + sage: sinh(g) Traceback (most recent call last): ... ValueError: can only apply sinh to formal power series with zero @@ -2102,17 +2105,17 @@ cdef class PowerSeries(AlgebraElement): sage: T.default_prec() 12 - sage: sinh(a) # optional - sage.symbolic + sage: sinh(a) a + 1/6*a^3 + 1/120*a^5 + 1/5040*a^7 + 1/362880*a^9 + 1/39916800*a^11 + O(a, b)^12 sage: a.sinh(prec=5) a + 1/6*a^3 + O(a, b)^5 - sage: sinh(a + T.O(5)) # optional - sage.symbolic + sage: sinh(a + T.O(5)) a + 1/6*a^3 + O(a, b)^5 TESTS:: - sage: sinh(a^2 + T.O(5)) # optional - sage.symbolic + sage: sinh(a^2 + T.O(5)) a^2 + O(a, b)^5 """ @@ -2163,14 +2166,14 @@ cdef class PowerSeries(AlgebraElement): sage: t = PowerSeriesRing(QQ, 't').gen() sage: f = (t + t**2).O(4) - sage: cosh(f) # optional - sage.symbolic + sage: cosh(f) 1 + 1/2*t^2 + t^3 + O(t^4) For several variables:: sage: T. = PowerSeriesRing(ZZ,2) sage: f = a + b + a*b + T.O(3) - sage: cosh(f) # optional - sage.symbolic + sage: cosh(f) 1 + 1/2*a^2 + a*b + 1/2*b^2 + O(a, b)^3 sage: f.cosh() 1 + 1/2*a^2 + a*b + 1/2*b^2 + O(a, b)^3 @@ -2181,7 +2184,7 @@ cdef class PowerSeries(AlgebraElement): one raises an error:: sage: g = 2 + f - sage: cosh(g) # optional - sage.symbolic + sage: cosh(g) Traceback (most recent call last): ... ValueError: can only apply cosh to formal power series with zero @@ -2191,17 +2194,17 @@ cdef class PowerSeries(AlgebraElement): sage: T.default_prec() 12 - sage: cosh(a) # optional - sage.symbolic + sage: cosh(a) 1 + 1/2*a^2 + 1/24*a^4 + 1/720*a^6 + 1/40320*a^8 + 1/3628800*a^10 + O(a, b)^12 sage: a.cosh(prec=5) 1 + 1/2*a^2 + 1/24*a^4 + O(a, b)^5 - sage: cosh(a + T.O(5)) # optional - sage.symbolic + sage: cosh(a + T.O(5)) 1 + 1/2*a^2 + 1/24*a^4 + O(a, b)^5 TESTS:: - sage: cosh(a^2 + T.O(5)) # optional - sage.symbolic + sage: cosh(a^2 + T.O(5)) 1 + 1/2*a^4 + O(a, b)^5 """ @@ -2251,14 +2254,14 @@ cdef class PowerSeries(AlgebraElement): sage: t = PowerSeriesRing(QQ, 't').gen() sage: f = (t + t**2).O(4) - sage: tanh(f) # optional - sage.symbolic + sage: tanh(f) t + t^2 - 1/3*t^3 + O(t^4) For several variables:: sage: T. = PowerSeriesRing(ZZ,2) sage: f = a + b + a*b + T.O(3) - sage: tanh(f) # optional - sage.symbolic + sage: tanh(f) a + b + a*b + O(a, b)^3 sage: f.tanh() a + b + a*b + O(a, b)^3 @@ -2269,7 +2272,7 @@ cdef class PowerSeries(AlgebraElement): one raises an error:: sage: g = 2 + f - sage: tanh(g) # optional - sage.symbolic + sage: tanh(g) Traceback (most recent call last): ... ValueError: can only apply tanh to formal power series with zero @@ -2279,17 +2282,17 @@ cdef class PowerSeries(AlgebraElement): sage: T.default_prec() 12 - sage: tanh(a) # optional - sage.symbolic + sage: tanh(a) a - 1/3*a^3 + 2/15*a^5 - 17/315*a^7 + 62/2835*a^9 - 1382/155925*a^11 + O(a, b)^12 sage: a.tanh(prec=5) a - 1/3*a^3 + O(a, b)^5 - sage: tanh(a + T.O(5)) # optional - sage.symbolic + sage: tanh(a + T.O(5)) a - 1/3*a^3 + O(a, b)^5 TESTS:: - sage: tanh(a^2 + T.O(5)) # optional - sage.symbolic + sage: tanh(a^2 + T.O(5)) a^2 + O(a, b)^5 """ @@ -2511,15 +2514,15 @@ cdef class PowerSeries(AlgebraElement): :: sage: R. = PowerSeriesRing(ZZ) - sage: (1 + x + O(x^2)).exp() + sage: (1 + x + O(x^2)).exp() # needs sage.symbolic Traceback (most recent call last): ... ArithmeticError: exponential of constant term does not belong to coefficient ring (consider working in a larger ring) :: - sage: R. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: (1 + x + O(x^2)).exp() # optional - sage.rings.finite_rings + sage: R. = PowerSeriesRing(GF(5)) + sage: (1 + x + O(x^2)).exp() Traceback (most recent call last): ... ArithmeticError: constant term of power series does not support exponentiation @@ -2787,21 +2790,21 @@ cdef class PowerSeries(AlgebraElement): sage: k. = QQ[[]] sage: f = 1 + 17*w + 15*w^3 + O(w^5) - sage: pari(f) # indirect doctest # optional - sage.libs.pari + sage: pari(f) # indirect doctest # needs sage.libs.pari 1 + 17*w + 15*w^3 + O(w^5) - sage: pari(1 - 19*w + w^5) # indirect doctest # optional - sage.libs.pari + sage: pari(1 - 19*w + w^5) # indirect doctest # needs sage.libs.pari w^5 - 19*w + 1 sage: R. = Zmod(6)[[]] - sage: pari(1 + x + 8*x^3 + O(x^8)) # indirect doctest # optional - sage.libs.pari + sage: pari(1 + x + 8*x^3 + O(x^8)) # indirect doctest # needs sage.libs.pari Mod(1, 6) + Mod(1, 6)*x + Mod(2, 6)*x^3 + O(x^8) TESTS:: - sage: pari(1 + O(x^1)) # optional - sage.libs.pari + sage: pari(1 + O(x^1)) # needs sage.libs.pari Mod(1, 6) + O(x) - sage: pari(O(x^1)) # optional - sage.libs.pari + sage: pari(O(x^1)) # needs sage.libs.pari O(x) - sage: pari(O(x^0)) # optional - sage.libs.pari + sage: pari(O(x^0)) # needs sage.libs.pari O(x^0) """ n = self.prec() diff --git a/src/sage/rings/puiseux_series_ring.py b/src/sage/rings/puiseux_series_ring.py index 27a91d6a187..2f761c51925 100644 --- a/src/sage/rings/puiseux_series_ring.py +++ b/src/sage/rings/puiseux_series_ring.py @@ -111,7 +111,7 @@ def _repr_(self): EXAMPLES:: - sage: PuiseuxSeriesRing(AA, 'y') + sage: PuiseuxSeriesRing(AA, 'y') # needs sage.rings.number_field Puiseux Series Ring in y over Algebraic Real Field """ s = "Puiseux Series Ring in {} over {}".format(self.variable_name(), @@ -302,8 +302,8 @@ def _element_constructor_(self, x, e=1, prec=infinity): sage: P(z) + y**(1/2) 3 + y^(1/2) + 2*y + y^2 + 2*y^3 + O(y^5) - sage: from sage.modular.etaproducts import qexp_eta - sage: y^(1/24)*qexp_eta(P, prec=30) + sage: from sage.modular.etaproducts import qexp_eta # needs sage.modular + sage: y^(1/24)*qexp_eta(P, prec=30) # needs sage.modular y^(1/24) - y^(25/24) - y^(49/24) + y^(121/24) + y^(169/24) - y^(289/24) - y^(361/24) + y^(529/24) + y^(625/24) + O(y^(721/24)) """ P = parent(x) @@ -395,8 +395,8 @@ def gen(self, n=0): EXAMPLES:: - sage: A = PuiseuxSeriesRing(AA, 'z') - sage: A.gen() + sage: A = PuiseuxSeriesRing(AA, 'z') # needs sage.rings.number_field + sage: A.gen() # needs sage.rings.number_field z """ if n != 0: @@ -409,8 +409,8 @@ def ngens(self): EXAMPLES:: - sage: A = PuiseuxSeriesRing(AA, 'z') - sage: A.ngens() + sage: A = PuiseuxSeriesRing(AA, 'z') # needs sage.rings.number_field + sage: A.ngens() # needs sage.rings.number_field 1 """ return 1 @@ -421,8 +421,8 @@ def laurent_series_ring(self): EXAMPLES:: - sage: A = PuiseuxSeriesRing(AA, 'z') - sage: A.laurent_series_ring() + sage: A = PuiseuxSeriesRing(AA, 'z') # needs sage.rings.number_field + sage: A.laurent_series_ring() # needs sage.rings.number_field Laurent Series Ring in z over Algebraic Real Field """ return self._laurent_series_ring @@ -433,8 +433,8 @@ def default_prec(self): EXAMPLES:: - sage: A = PuiseuxSeriesRing(AA, 'z') - sage: A.default_prec() + sage: A = PuiseuxSeriesRing(AA, 'z') # needs sage.rings.number_field + sage: A.default_prec() # needs sage.rings.number_field 20 """ return self.laurent_series_ring().default_prec() diff --git a/src/sage/rings/puiseux_series_ring_element.pyx b/src/sage/rings/puiseux_series_ring_element.pyx index 9543ce5a24a..503d11ee975 100644 --- a/src/sage/rings/puiseux_series_ring_element.pyx +++ b/src/sage/rings/puiseux_series_ring_element.pyx @@ -46,7 +46,7 @@ Other arithmetic can be performed with Puiseux Series:: Mind the base ring. However, the base ring can be changed:: - sage: I*q + sage: I*q # needs sage.rings.number_field Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for *: 'Number Field in I with defining polynomial x^2 + 1 with I = 1*I' and 'Puiseux Series Ring in x over Rational Field' @@ -218,10 +218,11 @@ cdef class PuiseuxSeries(AlgebraElement): """ EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = PuiseuxSeriesRing(ZZ) sage: p = x^(1/3) + x**3 sage: t = p._im_gens_(QQbar, [2]) - sage: t in QQbar + sage: t in QQbar True sage: f = R.hom([QQbar(2)], check=False) sage: t == f(p) @@ -241,8 +242,8 @@ cdef class PuiseuxSeries(AlgebraElement): sage: R.zero() 0 - sage: S. = PuiseuxSeriesRing(Zp(5)) - sage: t**(1/2) + 5 * t^(1/3) + sage: S. = PuiseuxSeriesRing(Zp(5)) # needs sage.rings.padics + sage: t**(1/2) + 5 * t^(1/3) # needs sage.rings.padics (5 + O(5^21))*t^(1/3) + (1 + O(5^20))*t^(1/2) """ laurent = self.laurent_part() @@ -300,7 +301,7 @@ cdef class PuiseuxSeries(AlgebraElement): sage: p = x^(1/2) + x**3-x**(-1/4) sage: p(16) 8199/2 - sage: p(pi.n()) + sage: p(pi.n()) # needs sage.symbolic 32.0276049867404 """ # use x.nth_root since x**(1/self._e) returns oo when x = 0 @@ -438,9 +439,9 @@ cdef class PuiseuxSeries(AlgebraElement): EXAMPLES:: - sage: P. = PuiseuxSeriesRing(Zp(3)) - sage: t = y^(2/5) + O(y) - sage: 5*t # indirect doctest + sage: P. = PuiseuxSeriesRing(Zp(3)) # needs sage.rings.padics + sage: t = y^(2/5) + O(y) # needs sage.rings.padics + sage: 5*t # indirect doctest # needs sage.rings.padics (2 + 3 + O(3^20))*y^(2/5) + O(y) """ return type(self)(self._parent, self._l._lmul_(c), self._e) @@ -1018,6 +1019,7 @@ cdef class PuiseuxSeries(AlgebraElement): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = PuiseuxSeriesRing(QQbar) sage: p = x**(3/2) - QQbar(I)*x**(1/2) sage: p.power_series() diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index 4ffa5704e83..ed3b1071b04 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -68,7 +68,7 @@ True sage: (sqrt(5 + 2*sqrt(QQbar(6))) - sqrt(QQbar(3)))^2 == 2 True - sage: AA((sqrt(5 + 2*sqrt(6)) - sqrt(3))^2) == 2 + sage: AA((sqrt(5 + 2*sqrt(6)) - sqrt(3))^2) == 2 # needs sage.symbolic True For a monic cubic polynomial `x^3 + bx^2 + cx + d` with roots `s1`, @@ -109,6 +109,7 @@ We can convert from symbolic expressions:: + sage: # needs sage.symbolic sage: QQbar(sqrt(-5)) 2.236067977499790?*I sage: AA(sqrt(2) + sqrt(3)) @@ -133,9 +134,9 @@ The coercion, however, goes in the other direction, since not all symbolic expressions are algebraic numbers:: - sage: QQbar(sqrt(2)) + sqrt(3) + sage: QQbar(sqrt(2)) + sqrt(3) # needs sage.symbolic sqrt(3) + 1.414213562373095? - sage: QQbar(sqrt(2) + QQbar(sqrt(3))) + sage: QQbar(sqrt(2) + QQbar(sqrt(3))) # needs sage.symbolic 3.146264369941973? Note the different behavior in taking roots: for ``AA`` we prefer real @@ -202,10 +203,11 @@ The Sage rings ``AA`` and ``QQbar`` can decide equalities between radical expressions (over the reals and complex numbers respectively):: - sage: a = AA((2/(3*sqrt(3)) + 10/27)^(1/3) - 2/(9*(2/(3*sqrt(3)) + 10/27)^(1/3)) + 1/3) - sage: a + sage: a = AA((2/(3*sqrt(3)) + 10/27)^(1/3) # needs sage.symbolic + ....: - 2/(9*(2/(3*sqrt(3)) + 10/27)^(1/3)) + 1/3) + sage: a # needs sage.symbolic 1.000000000000000? - sage: a == 1 + sage: a == 1 # needs sage.symbolic True Algebraic numbers which are known to be rational print as rationals; @@ -261,9 +263,9 @@ We can compute the multiplicative order of an algebraic number:: - sage: QQbar(-1/2 + I*sqrt(3)/2).multiplicative_order() + sage: QQbar(-1/2 + I*sqrt(3)/2).multiplicative_order() # needs sage.symbolic 3 - sage: QQbar(-sqrt(3)/2 + I/2).multiplicative_order() + sage: QQbar(-sqrt(3)/2 + I/2).multiplicative_order() # needs sage.symbolic 12 sage: (QQbar.zeta(23)**5).multiplicative_order() 23 @@ -332,6 +334,7 @@ on ``n`` will also trigger exact computation on ``rt2``, as you can see by the fact that the third output is different than the first:: + sage: # needs sage.symbolic sage: rt2 = AA(sqrt(2)) sage: n = rt2^2 sage: sage_input(n, verify=True) @@ -383,21 +386,19 @@ sage: loads(dumps(QQbar.zeta(5))) == QQbar.zeta(5) True + sage: # needs sage.symbolic sage: t = QQbar(sqrt(2)); type(t._descr) sage: loads(dumps(t)) == QQbar(sqrt(2)) True - sage: t.exactify(); type(t._descr) sage: loads(dumps(t)) == QQbar(sqrt(2)) True - sage: t = ~QQbar(sqrt(2)); type(t._descr) sage: loads(dumps(t)) == 1/QQbar(sqrt(2)) True - sage: t = QQbar(sqrt(2)) + QQbar(sqrt(3)); type(t._descr) sage: loads(dumps(t)) == QQbar(sqrt(2)) + QQbar(sqrt(3)) @@ -418,7 +419,9 @@ Here are examples of all of these conversions:: - sage: all_vals = [AA(42), AA(22/7), AA(golden_ratio), QQbar(-13), QQbar(89/55), QQbar(-sqrt(7)), QQbar.zeta(5)] + sage: # needs sage.symbolic + sage: all_vals = [AA(42), AA(22/7), AA(golden_ratio), + ....: QQbar(-13), QQbar(89/55), QQbar(-sqrt(7)), QQbar.zeta(5)] sage: def convert_test_all(ty): ....: def convert_test(v): ....: try: @@ -666,13 +669,14 @@ def common_polynomial(self, poly): sage: phi * tau == -1 True - sage: x = polygen(SR) # optional - sage.symbolic - sage: p = (x - sqrt(-5)) * (x - sqrt(3)); p # optional - sage.symbolic + sage: # needs sage.symbolic + sage: x = polygen(SR) + sage: p = (x - sqrt(-5)) * (x - sqrt(3)); p x^2 + (-sqrt(3) - sqrt(-5))*x + sqrt(3)*sqrt(-5) - sage: p = QQbar.common_polynomial(p) # optional - sage.symbolic - sage: a = QQbar.polynomial_root(p, CIF(RIF(-0.1, 0.1), RIF(2, 3))); a # optional - sage.symbolic + sage: p = QQbar.common_polynomial(p) + sage: a = QQbar.polynomial_root(p, CIF(RIF(-0.1, 0.1), RIF(2, 3))); a 0.?e-18 + 2.236067977499790?*I - sage: b = QQbar.polynomial_root(p, RIF(1, 2)); b # optional - sage.symbolic + sage: b = QQbar.polynomial_root(p, RIF(1, 2)); b 1.732050807568878? These "common polynomials" can be shared between real and @@ -785,6 +789,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test requiring us to further extend a number field that was used to specify the polynomial:: + sage: # needs sage.symbolic sage: p = x^2 + QQbar(sqrt(2))*y^2 sage: F = QQbar._factor_multivariate_polynomial(p) sage: F @@ -792,6 +797,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): sage: F.value() == p True + sage: # needs sage.symbolic sage: p = u^2 + AA(sqrt(2))*v^2 sage: F = AA._factor_multivariate_polynomial(p) sage: F @@ -802,6 +808,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test requiring a number field different from the number field used to specify the polynomial:: + sage: # needs sage.symbolic sage: p = QQbar(sqrt(2))*(x^2+y^2) sage: F = QQbar._factor_multivariate_polynomial(p) sage: F @@ -809,6 +816,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): sage: F.value() == p True + sage: # needs sage.symbolic sage: p = AA(sqrt(2))*(u^2+v^2) sage: F = AA._factor_multivariate_polynomial(p) sage: F @@ -819,6 +827,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test where a factor introduces a number field that was already used to specify the polynomial:: + sage: # needs sage.symbolic sage: p = QQbar(sqrt(2))*(x^2-2*y^2)^2 sage: F = QQbar._factor_multivariate_polynomial(p) sage: F @@ -827,6 +836,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): sage: F.value() == p True + sage: # needs sage.symbolic sage: p = AA(sqrt(2))*(u^2-2*v^2)^2 sage: F = AA._factor_multivariate_polynomial(p) sage: F @@ -837,6 +847,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): A test where two factors produce the same factor in the norm:: + sage: # needs sage.symbolic sage: p = (x^2+QQbar(sqrt(2))*y^2)*(x^4-2*y^4) sage: F = QQbar._factor_multivariate_polynomial(p) sage: F @@ -845,6 +856,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): sage: F.value() == p True + sage: # needs sage.symbolic sage: p = (u^2+AA(sqrt(2))*v^2)*(u^4-2*v^4) sage: F = AA._factor_multivariate_polynomial(p) sage: F @@ -868,9 +880,9 @@ def _factor_multivariate_polynomial(self, f, proof=True): number field generator:: sage: S. = QQbar[] - sage: p = a^2 + QQbar(sqrt(2))*b^2 - sage: F = QQbar._factor_multivariate_polynomial(p) - sage: F + sage: p = a^2 + QQbar(sqrt(2))*b^2 # needs sage.symbolic + sage: F = QQbar._factor_multivariate_polynomial(p) # needs sage.symbolic + sage: F # needs sage.symbolic (a + (-1.189207115002722?*I)*b) * (a + 1.189207115002722?*I*b) A test that led to :trac:`26898`:: @@ -1088,7 +1100,7 @@ def _element_constructor_(self, x): EXAMPLES:: - sage: QQbar(sqrt(2)) in AA # indirect doctest + sage: QQbar(sqrt(2)) in AA # indirect doctest # needs sage.symbolic True sage: QQbar(I) in AA False @@ -1097,7 +1109,7 @@ def _element_constructor_(self, x): The following should both return ``True`` (this is a bug). :: - sage: sqrt(2) in AA # known bug + sage: sqrt(2) in AA # known bug # needs sage.symbolic False sage: K. = CyclotomicField(5); z + 1/z in AA # known bug False @@ -1178,7 +1190,7 @@ def _coerce_map_from_(self, from_par): True sage: a + AA(3) 5.645751311064590? - sage: AA.has_coerce_map_from(SR) # optional - sage.symbolic + sage: AA.has_coerce_map_from(SR) # needs sage.symbolic False sage: x = polygen(ZZ, 'x') @@ -1623,11 +1635,11 @@ def _element_constructor_(self, x): EXAMPLES:: - sage: sqrt(2) in QQbar # indirect doctest + sage: sqrt(2) in QQbar # indirect doctest # needs sage.symbolic True sage: 22/7 in QQbar True - sage: pi in QQbar + sage: pi in QQbar # needs sage.symbolic False """ if isinstance(x, AlgebraicNumber): @@ -1685,7 +1697,7 @@ def _coerce_map_from_(self, from_par): True sage: QQbar.has_coerce_map_from(CC) False - sage: QQbar.has_coerce_map_from(SR) # optional - sage.symbolic + sage: QQbar.has_coerce_map_from(SR) # needs sage.symbolic False sage: i + QQbar(2) @@ -2567,7 +2579,11 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal sage: splitting = number_field_elements_from_algebraics(rts)[0]; splitting Number Field in a with defining polynomial y^6 - 40*y^4 - 22*y^3 + 873*y^2 + 1386*y + 594 sage: p.roots(ring=splitting) - [(361/29286*a^5 - 19/3254*a^4 - 14359/29286*a^3 + 401/29286*a^2 + 18183/1627*a + 15930/1627, 1), (49/117144*a^5 - 179/39048*a^4 - 3247/117144*a^3 + 22553/117144*a^2 + 1744/4881*a - 17195/6508, 1), (-1493/117144*a^5 + 407/39048*a^4 + 60683/117144*a^3 - 24157/117144*a^2 - 56293/4881*a - 53033/6508, 1)] + [(361/29286*a^5 - 19/3254*a^4 - 14359/29286*a^3 + 401/29286*a^2 + 18183/1627*a + 15930/1627, 1), + (49/117144*a^5 - 179/39048*a^4 - 3247/117144*a^3 + 22553/117144*a^2 + 1744/4881*a - 17195/6508, 1), + (-1493/117144*a^5 + 407/39048*a^4 + 60683/117144*a^3 - 24157/117144*a^2 - 56293/4881*a - 53033/6508, 1)] + + sage: # needs sage.symbolic sage: rt2 = AA(sqrt(2)); rt2 1.414213562373095? sage: rt3 = AA(sqrt(3)); rt3 @@ -2582,15 +2598,15 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal 1.414213562373095? sage: rt2c = z3 + rt2 - z3; rt2c 1.414213562373095? + 0.?e-19*I - sage: number_field_elements_from_algebraics(rt2) - (Number Field in a with defining polynomial y^2 - 2, a, Ring morphism: + (Number Field in a with defining polynomial y^2 - 2, a, + Ring morphism: From: Number Field in a with defining polynomial y^2 - 2 To: Algebraic Real Field Defn: a |--> 1.414213562373095?) - sage: number_field_elements_from_algebraics((rt2,rt3)) - (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism: + (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], + Ring morphism: From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1 To: Algebraic Real Field Defn: a |--> -1.931851652578137?) @@ -2599,14 +2615,16 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal to ``AA`` (because all elements are real), but if we specify ``same_field=True``, we'll get a homomorphism back to ``QQbar``:: - sage: number_field_elements_from_algebraics(rt3a) - (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism: + sage: number_field_elements_from_algebraics(rt3a) # needs sage.symbolic + (Number Field in a with defining polynomial y^2 - 3, a, + Ring morphism: From: Number Field in a with defining polynomial y^2 - 3 To: Algebraic Real Field Defn: a |--> 1.732050807568878?) - sage: number_field_elements_from_algebraics(rt3a, same_field=True) - (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism: + sage: number_field_elements_from_algebraics(rt3a, same_field=True) # needs sage.symbolic + (Number Field in a with defining polynomial y^2 - 3, a, + Ring morphism: From: Number Field in a with defining polynomial y^2 - 3 To: Algebraic Field Defn: a |--> 1.732050807568878?) @@ -2614,15 +2632,16 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal We've created ``rt2b`` in such a way that \sage does not initially know that it's in a degree-2 extension of `\QQ`:: - sage: number_field_elements_from_algebraics(rt2b) - (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism: + sage: number_field_elements_from_algebraics(rt2b) # needs sage.symbolic + (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, + Ring morphism: From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1 To: Algebraic Real Field Defn: a |--> -1.931851652578137?) We can specify ``minimal=True`` if we want the smallest number field:: - sage: number_field_elements_from_algebraics(rt2b, minimal=True) + sage: number_field_elements_from_algebraics(rt2b, minimal=True) # needs sage.symbolic (Number Field in a with defining polynomial y^2 - 2, a, Ring morphism: From: Number Field in a with defining polynomial y^2 - 2 To: Algebraic Real Field @@ -2639,8 +2658,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal Or we can just pass in symbolic expressions, as long as they can be coerced into ``QQbar``:: - sage: number_field_elements_from_algebraics((sqrt(7), sqrt(9), sqrt(11))) - (Number Field in a with defining polynomial y^4 - 9*y^2 + 1, [-a^3 + 8*a, 3, -a^3 + 10*a], Ring morphism: + sage: number_field_elements_from_algebraics((sqrt(7), sqrt(9), sqrt(11))) # needs sage.symbolic + (Number Field in a with defining polynomial y^4 - 9*y^2 + 1, + [-a^3 + 8*a, 3, -a^3 + 10*a], + Ring morphism: From: Number Field in a with defining polynomial y^4 - 9*y^2 + 1 To: Algebraic Real Field Defn: a |--> 0.3354367396454047?) @@ -2648,12 +2669,16 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal Here we see an example of doing some computations with number field elements, and then mapping them back into ``QQbar``:: - sage: (fld,nums,hom) = number_field_elements_from_algebraics((rt2, rt3, qqI, z3)) + sage: # needs sage.symbolic + sage: algebraics = (rt2, rt3, qqI, z3) + sage: fld,nums,hom = number_field_elements_from_algebraics(algebraics) sage: fld,nums,hom # random - (Number Field in a with defining polynomial y^8 - y^4 + 1, [-a^5 + a^3 + a, a^6 - 2*a^2, a^6, -a^4], Ring morphism: - From: Number Field in a with defining polynomial y^8 - y^4 + 1 - To: Algebraic Field - Defn: a |--> -0.2588190451025208? - 0.9659258262890683?*I) + (Number Field in a with defining polynomial y^8 - y^4 + 1, + [-a^5 + a^3 + a, a^6 - 2*a^2, a^6, -a^4], + Ring morphism: + From: Number Field in a with defining polynomial y^8 - y^4 + 1 + To: Algebraic Field + Defn: a |--> -0.2588190451025208? - 0.9659258262890683?*I) sage: (nfrt2, nfrt3, nfI, nfz3) = nums sage: hom(nfrt2) 1.414213562373095? + 0.?e-18*I @@ -2689,38 +2714,50 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal :: - sage: nf,nums,hom = number_field_elements_from_algebraics([2^(1/3),3^(1/5)],embedded=True) + sage: # needs sage.symbolic + sage: elems = [2^(1/3), 3^(1/5)] + sage: nf, nums, hom = number_field_elements_from_algebraics(elems, + ....: embedded=True) sage: nf - Number Field in a with defining polynomial y^15 - 9*y^10 + 21*y^5 - 3 with a = 0.6866813218928813? + Number Field in a with defining polynomial y^15 - 9*y^10 + 21*y^5 - 3 + with a = 0.6866813218928813? sage: nums [a^10 - 5*a^5 + 2, -a^8 + 4*a^3] sage: hom Ring morphism: - From: Number Field in a with defining polynomial y^15 - 9*y^10 + 21*y^5 - 3 with a = 0.6866813218928813? + From: Number Field in a with defining polynomial y^15 - 9*y^10 + 21*y^5 - 3 + with a = 0.6866813218928813? To: Algebraic Real Field Defn: a |--> 0.6866813218928813? Complex embeddings are possible as well:: + sage: # needs sage.symbolic sage: elems = [sqrt(5), 2^(1/3)+sqrt(3)*I, 3/4] - sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True) - sage: nf # random (polynomial and root not unique) + sage: nf, nums, hom = number_field_elements_from_algebraics(elems, + ....: embedded=True) + sage: nf # random (polynomial and root not unique) Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1 with a = 0.2598679? + 0.0572892?*I - sage: nf.is_isomorphic(NumberField(x^24 - 9*x^22 + 135*x^20 - 720*x^18 + 1821*x^16 - 3015*x^14 + 3974*x^12 - 3015*x^10 + 1821*x^8 - 720*x^6 + 135*x^4 - 9*x^2 + 1, 'a')) + sage: nf.is_isomorphic(NumberField( + ....: x^24 - 9*x^22 + 135*x^20 - 720*x^18 + 1821*x^16 + ....: - 3015*x^14 + 3974*x^12 - 3015*x^10 + 1821*x^8 + ....: - 720*x^6 + 135*x^4 - 9*x^2 + 1, 'a')) True sage: list(map(QQbar, nums)) == elems == list(map(hom, nums)) True TESTS:: - sage: number_field_elements_from_algebraics(rt3) - (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism: + sage: number_field_elements_from_algebraics(rt3) # needs sage.symbolic + (Number Field in a with defining polynomial y^2 - 3, a, + Ring morphism: From: Number Field in a with defining polynomial y^2 - 3 To: Algebraic Real Field Defn: a |--> 1.732050807568878?) - sage: number_field_elements_from_algebraics((rt2,qqI)) - (Number Field in a with defining polynomial y^4 + 1, [-a^3 + a, a^2], Ring morphism: + sage: number_field_elements_from_algebraics((rt2,qqI)) # needs sage.symbolic + (Number Field in a with defining polynomial y^4 + 1, [-a^3 + a, a^2], + Ring morphism: From: Number Field in a with defining polynomial y^4 + 1 To: Algebraic Field Defn: a |--> 0.7071067811865475? + 0.7071067811865475?*I) @@ -2728,16 +2765,18 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal Note that for the first example, where \sage does not realize that the number is real, we get a homomorphism to ``QQbar``:: - sage: number_field_elements_from_algebraics(rt2c) # random - (Number Field in a with defining polynomial y^4 + 2*y^2 + 4, 1/2*a^3, Ring morphism: + sage: number_field_elements_from_algebraics(rt2c) # random # needs sage.symbolic + (Number Field in a with defining polynomial y^4 + 2*y^2 + 4, 1/2*a^3, + Ring morphism: From: Number Field in a with defining polynomial y^4 + 2*y^2 + 4 To: Algebraic Field Defn: a |--> -0.7071067811865475? - 1.224744871391589?*I) But with ``minimal=True``, we get a homomorphism to ``AA``:: - sage: number_field_elements_from_algebraics(rt2c, minimal=True) - (Number Field in a with defining polynomial y^2 - 2, a, Ring morphism: + sage: number_field_elements_from_algebraics(rt2c, minimal=True) # needs sage.symbolic + (Number Field in a with defining polynomial y^2 - 2, a, + Ring morphism: From: Number Field in a with defining polynomial y^2 - 2 To: Algebraic Real Field Defn: a |--> 1.414213562373095?) @@ -2745,8 +2784,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal If we specify both ``minimal=True`` and ``same_field=True``, we get a second degree extension (minimal) that maps back to ``QQbar``:: - sage: number_field_elements_from_algebraics(rt2c, minimal=True, same_field=True) - (Number Field in a with defining polynomial y^2 - 2, a, Ring morphism: + sage: number_field_elements_from_algebraics(rt2c, minimal=True, # needs sage.symbolic + ....: same_field=True) + (Number Field in a with defining polynomial y^2 - 2, a, + Ring morphism: From: Number Field in a with defining polynomial y^2 - 2 To: Algebraic Field Defn: a |--> 1.414213562373095?) @@ -2770,12 +2811,13 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal sage: E = UCF.gen(5) sage: L. = NumberField(x^2-189*x+16, embedding=200) sage: x = polygen(ZZ) - sage: my_nums = [-52*E - 136*E^2 - 136*E^3 - 52*E^4, \ - L.gen()._algebraic_(AA), \ - sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1] - sage: res = number_field_elements_from_algebraics(my_nums, embedded=True) - sage: res[0] - Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420? + sage: my_nums = [-52*E - 136*E^2 - 136*E^3 - 52*E^4, # needs sage.symbolic + ....: L.gen()._algebraic_(AA), + ....: sqrt(2), AA.polynomial_root(x^3 - 3, RIF(0,3)), 11/9, 1] + sage: res = number_field_elements_from_algebraics(my_nums, embedded=True) # needs sage.symbolic + sage: res[0] # needs sage.symbolic + Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420? """ gen = qq_generator @@ -3030,6 +3072,7 @@ def __reduce__(self): EXAMPLES:: + sage: # needs sage.symbolic sage: t = QQbar(sqrt(2)) + QQbar(sqrt(3)) sage: t.exactify() sage: type(t._descr._generator) @@ -3456,6 +3499,8 @@ def is_simple(self): sage: from sage.rings.qqbar import ANRational sage: ANRational(1/2).is_simple() True + + sage: # needs sage.symbolic sage: rt2 = AA(sqrt(2)) sage: rt3 = AA(sqrt(3)) sage: rt2b = rt3 + rt2 - rt3 @@ -3480,9 +3525,9 @@ def neg(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(2)) - sage: b = a._descr - sage: b.neg(a) + sage: a = QQbar(sqrt(2)) # needs sage.symbolic + sage: b = a._descr # needs sage.symbolic + sage: b.neg(a) # needs sage.symbolic """ return ANUnaryExpr(n, '-') @@ -3493,9 +3538,9 @@ def invert(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(2)) - sage: b = a._descr - sage: b.invert(a) + sage: a = QQbar(sqrt(2)) # needs sage.symbolic + sage: b = a._descr # needs sage.symbolic + sage: b.invert(a) # needs sage.symbolic """ return ANUnaryExpr(n, '~') @@ -3506,9 +3551,9 @@ def abs(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(2)) - sage: b = a._descr - sage: b.abs(a) + sage: a = QQbar(sqrt(2)) # needs sage.symbolic + sage: b = a._descr # needs sage.symbolic + sage: b.abs(a) # needs sage.symbolic """ return ANUnaryExpr(n, 'abs') @@ -3519,9 +3564,9 @@ def real(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-7)) - sage: b = a._descr - sage: b.real(a) + sage: a = QQbar(sqrt(-7)) # needs sage.symbolic + sage: b = a._descr # needs sage.symbolic + sage: b.real(a) # needs sage.symbolic """ if self.is_complex(): @@ -3535,9 +3580,9 @@ def imag(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-7)) - sage: b = a._descr - sage: b.imag(a) + sage: a = QQbar(sqrt(-7)) # needs sage.symbolic + sage: b = a._descr # needs sage.symbolic + sage: b.imag(a) # needs sage.symbolic """ if self.is_complex(): @@ -3551,9 +3596,9 @@ def conjugate(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-7)) - sage: b = a._descr - sage: b.conjugate(a) + sage: a = QQbar(sqrt(-7)) # needs sage.symbolic + sage: b = a._descr # needs sage.symbolic + sage: b.conjugate(a) # needs sage.symbolic """ if self.is_complex(): @@ -3568,9 +3613,9 @@ def norm(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-7)) - sage: b = a._descr - sage: b.norm(a) + sage: a = QQbar(sqrt(-7)) # needs sage.symbolic + sage: b = a._descr # needs sage.symbolic + sage: b.norm(a) # needs sage.symbolic """ if self.is_complex(): @@ -3635,7 +3680,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement): 1.618033988749895? sage: phi^2 == phi+1 True - sage: AA(sqrt(65537)) + sage: AA(sqrt(65537)) # needs sage.symbolic 256.0019531175495? """ @@ -3695,9 +3740,9 @@ def _repr_(self): sage: AA(19).sqrt() 4.358898943540674? sage: AA.options.display_format = 'radical' - sage: AA(19).sqrt() + sage: AA(19).sqrt() # needs sage.symbolic sqrt(19) - sage: QQbar.zeta(6) + sage: QQbar.zeta(6) # needs sage.symbolic 1/2*I*sqrt(3) + 1/2 sage: QQbar.zeta(17) 0.9324722294043558? + 0.3612416661871530?*I @@ -3813,7 +3858,7 @@ def _mul_(self, other): """ TESTS:: - sage: AA(sqrt(2)) * AA(sqrt(8)) # indirect doctest + sage: AA(sqrt(2)) * AA(sqrt(8)) # indirect doctest # needs sage.symbolic 4.000000000000000? """ sk = type(self._descr) @@ -3824,7 +3869,7 @@ def _div_(self, other): """ TESTS:: - sage: AA(sqrt(2)) / AA(sqrt(8)) # indirect doctest + sage: AA(sqrt(2)) / AA(sqrt(8)) # indirect doctest # needs sage.symbolic 0.500000000000000? sage: z = QQbar(I).real() @@ -3843,7 +3888,7 @@ def __invert__(self): """ TESTS:: - sage: ~AA(sqrt(~2)) + sage: ~AA(sqrt(~2)) # needs sage.symbolic 1.414213562373095? sage: z = QQbar(I).real() @@ -3873,7 +3918,7 @@ def _sub_(self, other): """ TESTS:: - sage: AA(golden_ratio) * 2 - AA(5).sqrt() # indirect doctest + sage: AA(golden_ratio) * 2 - AA(5).sqrt() # indirect doctest # needs sage.symbolic 1.000000000000000? """ sk = type(self._descr) @@ -3893,7 +3938,7 @@ def __abs__(self): """ TESTS:: - sage: abs(AA(sqrt(2) - sqrt(3))) + sage: abs(AA(sqrt(2) - sqrt(3))) # needs sage.symbolic 0.3178372451957823? sage: abs(QQbar(3+4*I)) 5 @@ -3929,8 +3974,8 @@ def __hash__(self): True sage: h1 = hash(QQbar.zeta(6)) - sage: h2 = hash(QQbar(1/2 + I*sqrt(3)/2)) - sage: h1 == h2 + sage: h2 = hash(QQbar(1/2 + I*sqrt(3)/2)) # needs sage.symbolic + sage: h1 == h2 # needs sage.symbolic True Unfortunately, the hash code for algebraic numbers which are close @@ -4003,6 +4048,8 @@ def __bool__(self): sage: a = QQbar(2).sqrt() - 16616132878186749607/11749380235262596085 sage: b = QQbar(2).sqrt() - 6882627592338442563/4866752642924153522 sage: c = QQbar(3).sqrt() - 142437039878091970439/82236063316189858921 + + sage: # needs sage.symbolic sage: d = (59/2)**(1000/7) sage: e = (a + b + c) * (a + b - c) * (a - b) * (a - b - c) / d sage: bool(e) @@ -4315,8 +4362,9 @@ def as_number_field_element(self, minimal=False, embedded=False, prec=53): EXAMPLES:: - sage: QQbar(sqrt(8)).as_number_field_element() - (Number Field in a with defining polynomial y^2 - 2, 2*a, Ring morphism: + sage: QQbar(sqrt(8)).as_number_field_element() # needs sage.symbolic + (Number Field in a with defining polynomial y^2 - 2, 2*a, + Ring morphism: From: Number Field in a with defining polynomial y^2 - 2 To: Algebraic Real Field Defn: a |--> 1.414213562373095?) @@ -4368,6 +4416,7 @@ def as_number_field_element(self, minimal=False, embedded=False, prec=53): A complex algebraic number as an element of an embedded number field:: + sage: # needs sage.symbolic sage: num = QQbar(sqrt(2) + 3^(1/3)*I) sage: nf, elt, hom = num.as_number_field_element(embedded=True) sage: hom(elt).parent() is QQbar @@ -4380,16 +4429,19 @@ def as_number_field_element(self, minimal=False, embedded=False, prec=53): We see an example where we do not get the minimal number field unless we specify ``minimal=True``:: + sage: # needs sage.symbolic sage: rt2 = AA(sqrt(2)) sage: rt3 = AA(sqrt(3)) sage: rt3b = rt2 + rt3 - rt2 sage: rt3b.as_number_field_element() - (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism: + (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, + Ring morphism: From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1 To: Algebraic Real Field Defn: a |--> -1.931851652578137?) sage: rt3b.as_number_field_element(minimal=True) - (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism: + (Number Field in a with defining polynomial y^2 - 3, a, + Ring morphism: From: Number Field in a with defining polynomial y^2 - 3 To: Algebraic Real Field Defn: a |--> 1.732050807568878?) @@ -4444,6 +4496,7 @@ def simplify(self): EXAMPLES:: + sage: # needs sage.symbolic sage: rt2 = AA(sqrt(2)) sage: rt3 = AA(sqrt(3)) sage: rt2b = rt3 + rt2 - rt3 @@ -4697,28 +4750,29 @@ def radical_expression(self): EXAMPLES:: - sage: AA(1/sqrt(5)).radical_expression() # optional - sage.symbolic + sage: # needs sage.symbolic + sage: AA(1/sqrt(5)).radical_expression() sqrt(1/5) - sage: AA(sqrt(5 + sqrt(5))).radical_expression() # optional - sage.symbolic + sage: AA(sqrt(5 + sqrt(5))).radical_expression() sqrt(sqrt(5) + 5) - sage: QQbar.zeta(5).radical_expression() # optional - sage.symbolic + sage: QQbar.zeta(5).radical_expression() 1/4*sqrt(5) + 1/2*sqrt(-1/2*sqrt(5) - 5/2) - 1/4 sage: x = polygen(QQ, 'x') sage: a = (x^7 - x - 1).roots(AA, False)[0] - sage: a.radical_expression() # optional - sage.symbolic + sage: a.radical_expression() 1.112775684278706? - sage: a.radical_expression().parent() == SR # optional - sage.symbolic + sage: a.radical_expression().parent() == SR False sage: a = sorted((x^7-x-1).roots(QQbar, False), key=imag)[0] - sage: a.radical_expression() # optional - sage.symbolic + sage: a.radical_expression() -0.3636235193291805? - 0.9525611952610331?*I - sage: QQbar.zeta(5).imag().radical_expression() # optional - sage.symbolic + sage: QQbar.zeta(5).imag().radical_expression() 1/2*sqrt(1/2*sqrt(5) + 5/2) - sage: AA(5/3).radical_expression() # optional - sage.symbolic + sage: AA(5/3).radical_expression() 5/3 - sage: AA(5/3).radical_expression().parent() == SR # optional - sage.symbolic + sage: AA(5/3).radical_expression().parent() == SR True - sage: QQbar(0).radical_expression() # optional - sage.symbolic + sage: QQbar(0).radical_expression() 0 TESTS: @@ -4729,15 +4783,16 @@ def radical_expression(self): :: - sage: a = AA(sqrt(2) + 10^25) # optional - sage.symbolic - sage: p = a.minpoly() # optional - sage.symbolic - sage: v = a._value # optional - sage.symbolic - sage: f = ComplexIntervalField(v.prec()) # optional - sage.symbolic - sage: var('x') # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = AA(sqrt(2) + 10^25) + sage: p = a.minpoly() + sage: v = a._value + sage: f = ComplexIntervalField(v.prec()) + sage: var('x') x - sage: [f(b.rhs()).overlaps(f(v)) for b in SR(p).solve(x)] # optional - sage.symbolic + sage: [f(b.rhs()).overlaps(f(v)) for b in SR(p).solve(x)] [True, True] - sage: a.radical_expression() # optional - sage.symbolic + sage: a.radical_expression() sqrt(2) + 10000000000000000000000000 """ from sage.symbolic.ring import SR # Lazy to avoid cyclic dependency @@ -4765,17 +4820,18 @@ def _maxima_init_(self, I=None): r""" EXAMPLES:: + sage: # needs sage.symbolic sage: maxima(AA(7)) 7 - sage: maxima(QQbar(sqrt(5/2))) # optional - sage.symbolic + sage: maxima(QQbar(sqrt(5/2))) sqrt(10)/2 - sage: maxima(AA(-sqrt(5))) # optional - sage.symbolic + sage: maxima(AA(-sqrt(5))) -sqrt(5) - sage: maxima(QQbar(sqrt(-2))) # optional - sage.symbolic + sage: maxima(QQbar(sqrt(-2))) sqrt(2)*%i - sage: maxima(AA(2+sqrt(5))) # optional - sage.symbolic + sage: maxima(AA(2+sqrt(5))) sqrt(5)+2 - sage: maxima(QQ[x](x^7 - x - 1).roots(AA, False)[0]) # optional - sage.symbolic + sage: maxima(QQ[x](x^7 - x - 1).roots(AA, False)[0]) Traceback (most recent call last): ... NotImplementedError: cannot find radical expression @@ -4889,24 +4945,24 @@ def _richcmp_(self, other, op): TESTS:: - sage: QQbar.zeta(6) == QQbar(1/2 + I*sqrt(3)/2) # optional - sage.symbolic + sage: QQbar.zeta(6) == QQbar(1/2 + I*sqrt(3)/2) # needs sage.symbolic True sage: QQbar(I) == QQbar(I * (2^100+1)/(2^100)) False sage: QQbar(2) == 2 True - sage: QQbar(2) == GF(7)(2) # optional - sage.rings.finite_rings + sage: QQbar(2) == GF(7)(2) False - sage: GF(7)(2) in QQbar # optional - sage.rings.finite_rings + sage: GF(7)(2) in QQbar False - sage: QQbar.zeta(6) != QQbar(1/2 + I*sqrt(3)/2) # optional - sage.symbolic + sage: QQbar.zeta(6) != QQbar(1/2 + I*sqrt(3)/2) # needs sage.symbolic False sage: QQbar(I) != QQbar(I * (2^100+1)/(2^100)) True sage: QQbar(2) != 2 False - sage: QQbar(2) != GF(7)(2) # optional - sage.rings.finite_rings + sage: QQbar(2) != GF(7)(2) True sage: QQbar.zeta(3).real() == -1/2 @@ -4926,13 +4982,13 @@ def _richcmp_(self, other, op): Check that :trac:`29220` is fixed:: + sage: # needs sage.symbolic sage: a = AA(2**(1/2) - 2**(1/3)) sage: b = 808620184/5240825825 sage: a < b True sage: a < b True - sage: a = AA(2^(1/3)) sage: r = 3085094589/2448641198 sage: a < r @@ -5000,7 +5056,7 @@ def _mpfr_(self, field): EXAMPLES:: - sage: QQbar(sqrt(2))._mpfr_(RR) + sage: QQbar(sqrt(2))._mpfr_(RR) # needs sage.symbolic 1.41421356237309 sage: QQbar(-22/7)._mpfr_(RR) -3.14285714285714 @@ -5019,7 +5075,7 @@ def __float__(self): EXAMPLES:: - sage: QQbar(sqrt(2)).__float__() + sage: QQbar(sqrt(2)).__float__() # needs sage.symbolic 1.414213562373095 sage: float(QQbar(-22/7)) -3.1428571428571432 @@ -5036,7 +5092,7 @@ def __complex__(self): EXAMPLES:: - sage: QQbar(sqrt(2)).__complex__() + sage: QQbar(sqrt(2)).__complex__() # needs sage.symbolic (1.414213562373095+0j) sage: complex(QQbar.zeta(3)) (-0.5+0.8660254037844386j) @@ -5049,7 +5105,7 @@ def _complex_double_(self, cdf): EXAMPLES:: - sage: QQbar(sqrt(-5))._complex_double_(CDF) + sage: QQbar(sqrt(-5))._complex_double_(CDF) # needs sage.symbolic 2.23606797749979*I sage: CDF(QQbar.zeta(12)) 0.8660254037844386 + 0.5*I @@ -5062,7 +5118,7 @@ def _interval_fast(self, prec): EXAMPLES:: - sage: QQbar(sqrt(-5))._interval_fast(100) + sage: QQbar(sqrt(-5))._interval_fast(100) # needs sage.symbolic 2.236067977499789696409173...?*I """ return self.interval_fast(ComplexIntervalField(prec)) @@ -5081,6 +5137,8 @@ def _integer_(self, ZZ=None): Traceback (most recent call last): ... ValueError: Cannot coerce algebraic number with non-zero imaginary part to algebraic real + + sage: # needs sage.symbolic sage: QQbar(sqrt(17))._integer_() Traceback (most recent call last): ... @@ -5108,6 +5166,8 @@ def _rational_(self): Traceback (most recent call last): ... ValueError: Cannot coerce algebraic number with non-zero imaginary part to algebraic real + + sage: # needs sage.symbolic sage: QQbar(sqrt(2))._rational_() Traceback (most recent call last): ... @@ -5191,10 +5251,10 @@ def interval_exact(self, field): 0.7071067811865475? + 0.7071067811865475?*I sage: a.interval_exact(CIF) 0.7071067811865475? + 0.7071067811865475?*I - sage: b = QQbar((1+I)*sqrt(2)/2) # optional - sage.symbolic - sage: (a - b).interval(CIF) # optional - sage.symbolic + sage: b = QQbar((1+I)*sqrt(2)/2) # needs sage.symbolic + sage: (a - b).interval(CIF) # needs sage.symbolic 0.?e-19 + 0.?e-18*I - sage: (a - b).interval_exact(CIF) # optional - sage.symbolic + sage: (a - b).interval_exact(CIF) # needs sage.symbolic 0 """ if not isinstance(field, sage.rings.abc.ComplexIntervalField): @@ -5274,7 +5334,7 @@ def multiplicative_order(self): EXAMPLES:: - sage: QQbar(-sqrt(3)/2 - I/2).multiplicative_order() # optional - sage.symbolic + sage: QQbar(-sqrt(3)/2 - I/2).multiplicative_order() # needs sage.symbolic 12 sage: QQbar(1).multiplicative_order() 1 @@ -5300,11 +5360,11 @@ def rational_argument(self): EXAMPLES:: - sage: QQbar((1+I)*(sqrt(2)+sqrt(5))).rational_argument() # optional - sage.symbolic + sage: QQbar((1+I)*(sqrt(2)+sqrt(5))).rational_argument() # needs sage.symbolic 1/8 - sage: QQbar(-1 + I*sqrt(3)).rational_argument() # optional - sage.symbolic + sage: QQbar(-1 + I*sqrt(3)).rational_argument() # needs sage.symbolic 1/3 - sage: QQbar(-1 - I*sqrt(3)).rational_argument() # optional - sage.symbolic + sage: QQbar(-1 - I*sqrt(3)).rational_argument() # needs sage.symbolic -1/3 sage: QQbar(3+4*I).rational_argument() is None True @@ -5334,9 +5394,9 @@ def _pow_(self, other): EXAMPLES:: - sage: QQbar(1) ^ QQbar(sqrt(2)) # optional - sage.symbolic + sage: QQbar(1) ^ QQbar(sqrt(2)) # needs sage.symbolic 1 - sage: 1 ^ QQbar(sqrt(2)) # optional - sage.symbolic + sage: 1 ^ QQbar(sqrt(2)) # needs sage.symbolic 1 sage: QQbar(2) ^ QQbar(2) Traceback (most recent call last): @@ -5371,8 +5431,9 @@ def __init__(self, x): sometimes a very small (e.g., 1e-17) complex part appears in a complex interval used to create an AlgebraicReal.:: - sage: a = QQbar((-1)^(1/4)); b = AA(a^3-a); t = b.as_number_field_element() - sage: b*1 + sage: a = QQbar((-1)^(1/4)); b = AA(a^3-a) # needs sage.symbolic + sage: t = b.as_number_field_element() # needs sage.symbolic + sage: b*1 # needs sage.symbolic -1.414213562373095? """ AlgebraicNumber_base.__init__(self, AA, x) @@ -5386,6 +5447,7 @@ def _ensure_real(self): EXAMPLES:: + sage: # needs sage.symbolic sage: a = QQbar((-1)^(1/4)); b = AA(a^3-a); b._value -1.4142135623730950488? sage: b._value = a._value; b._value @@ -5406,8 +5468,8 @@ def _more_precision(self): EXAMPLES:: - sage: a = QQbar(sqrt(2)) # optional - sage.symbolic - sage: a._more_precision() # optional - sage.symbolic + sage: a = QQbar(sqrt(2)) # needs sage.symbolic + sage: a._more_precision() # needs sage.symbolic TESTS: @@ -5432,8 +5494,8 @@ def __reduce__(self): EXAMPLES:: - sage: t = AA(sqrt(2)) # optional - sage.symbolic - sage: loads(dumps(t)) == t # optional - sage.symbolic + sage: t = AA(sqrt(2)) # needs sage.symbolic + sage: loads(dumps(t)) == t # needs sage.symbolic True """ return (AlgebraicReal, (self._descr, )) @@ -5453,32 +5515,31 @@ def _richcmp_(self, other, op): TESTS:: - sage: AA(golden_ratio) < AA(sqrt(5)) # optional - sage.symbolic + sage: AA(golden_ratio) < AA(sqrt(5)) # needs sage.symbolic True - sage: AA(golden_ratio) == AA((sqrt(5)+1)/2) # optional - sage.symbolic + sage: AA(golden_ratio) == AA((sqrt(5)+1)/2) # needs sage.symbolic True sage: AA(7) >= AA(50/7) False Check for trivial equality with identical elements:: - sage: x1 = AA(2^(1/50)) # optional - sage.symbolic - sage: x2 = AA(2^(1/50)) # optional - sage.symbolic - sage: y = x1 - x2 # optional - sage.symbolic - sage: y == y # optional - sage.symbolic + sage: # needs sage.symbolic + sage: x1 = AA(2^(1/50)) + sage: x2 = AA(2^(1/50)) + sage: y = x1 - x2 + sage: y == y True - sage: y >= y # optional - sage.symbolic + sage: y >= y True - sage: y < y # optional - sage.symbolic + sage: y < y False - - sage: z = x1 - x2 # optional - sage.symbolic - sage: z == 0 # optional - sage.symbolic + sage: z = x1 - x2 + sage: z == 0 True - - sage: a = x1 - x2 # optional - sage.symbolic - sage: b = x1 - x2 # optional - sage.symbolic - sage: a == b # optional - sage.symbolic + sage: a = x1 - x2 + sage: b = x1 - x2 + sage: a == b True """ if self is other: @@ -5552,11 +5613,11 @@ def _integer_(self, Z=None): 42 sage: AA(42)._integer_().parent() Integer Ring - sage: AA(golden_ratio)._integer_() + sage: AA(golden_ratio)._integer_() # needs sage.symbolic Traceback (most recent call last): ... ValueError: Cannot coerce non-integral Algebraic Real 1.618033988749895? to Integer - sage: (AA(golden_ratio)^10 + AA(1-golden_ratio)^10)._integer_() + sage: (AA(golden_ratio)^10 + AA(1-golden_ratio)^10)._integer_() # needs sage.symbolic 123 sage: AA(-22/7)._integer_() Traceback (most recent call last): @@ -5614,9 +5675,9 @@ def floor(self): EXAMPLES:: - sage: AA(sqrt(2)).floor() # optional - sage.symbolic + sage: AA(sqrt(2)).floor() # needs sage.symbolic 1 - sage: AA(-sqrt(2)).floor() # optional - sage.symbolic + sage: AA(-sqrt(2)).floor() # needs sage.symbolic -2 sage: AA(42).floor() 42 @@ -5625,8 +5686,8 @@ def floor(self): Check that :trac:`15501` is fixed:: - sage: a = QQbar((-1)^(1/4)).real() # optional - sage.symbolic - sage: (floor(a-a) + a).parent() # optional - sage.symbolic + sage: a = QQbar((-1)^(1/4)).real() # needs sage.symbolic + sage: (floor(a-a) + a).parent() # needs sage.symbolic Algebraic Real Field """ return self._floor_ceil(lambda x: x.floor()) @@ -5637,9 +5698,9 @@ def ceil(self): EXAMPLES:: - sage: AA(sqrt(2)).ceil() # optional - sage.symbolic + sage: AA(sqrt(2)).ceil() # needs sage.symbolic 2 - sage: AA(-sqrt(2)).ceil() # optional - sage.symbolic + sage: AA(-sqrt(2)).ceil() # needs sage.symbolic -1 sage: AA(42).ceil() 42 @@ -5652,7 +5713,7 @@ def round(self): EXAMPLES:: - sage: AA(sqrt(2)).round() # optional - sage.symbolic + sage: AA(sqrt(2)).round() # needs sage.symbolic 1 sage: AA(1/2).round() 1 @@ -5667,9 +5728,9 @@ def trunc(self): EXAMPLES:: - sage: AA(sqrt(2)).trunc() # optional - sage.symbolic + sage: AA(sqrt(2)).trunc() # needs sage.symbolic 1 - sage: AA(-sqrt(2)).trunc() # optional - sage.symbolic + sage: AA(-sqrt(2)).trunc() # needs sage.symbolic -1 sage: AA(1).trunc() 1 @@ -5688,13 +5749,13 @@ def _rational_(self): Rational Field sage: AA(-22/7)._rational_() -22/7 - sage: AA(sqrt(7))._rational_() # optional - sage.symbolic + sage: AA(sqrt(7))._rational_() # needs sage.symbolic Traceback (most recent call last): ... ValueError: Cannot coerce irrational Algebraic Real 2.645751311064591? to Rational - sage: v = AA(1/2 + sqrt(2))^3 - AA(11/4*sqrt(2)); v # optional - sage.symbolic + sage: v = AA(1/2 + sqrt(2))^3 - AA(11/4*sqrt(2)); v # needs sage.symbolic 3.125000000000000? - sage: v._rational_() + sage: v._rational_() # needs sage.symbolic 25/8 """ self.exactify() @@ -5711,10 +5772,10 @@ def real(self): EXAMPLES:: - sage: a = AA(sqrt(2) + sqrt(3)) # optional - sage.symbolic - sage: a.real() # optional - sage.symbolic + sage: a = AA(sqrt(2) + sqrt(3)) # needs sage.symbolic + sage: a.real() # needs sage.symbolic 3.146264369941973? - sage: a.real() is a # optional - sage.symbolic + sage: a.real() is a # needs sage.symbolic True """ return self @@ -5727,10 +5788,10 @@ def imag(self): EXAMPLES:: - sage: a = AA(sqrt(2) + sqrt(3)) # optional - sage.symbolic - sage: a.imag() # optional - sage.symbolic + sage: a = AA(sqrt(2) + sqrt(3)) # needs sage.symbolic + sage: a.imag() # needs sage.symbolic 0 - sage: parent(a.imag()) # optional - sage.symbolic + sage: parent(a.imag()) # needs sage.symbolic Algebraic Real Field """ return AA_0 @@ -5741,10 +5802,10 @@ def conjugate(self): EXAMPLES:: - sage: a = AA(sqrt(2) + sqrt(3)) # optional - sage.symbolic - sage: a.conjugate() # optional - sage.symbolic + sage: a = AA(sqrt(2) + sqrt(3)) # needs sage.symbolic + sage: a.conjugate() # needs sage.symbolic 3.146264369941973? - sage: a.conjugate() is a # optional - sage.symbolic + sage: a.conjugate() is a # needs sage.symbolic True """ return self @@ -5817,9 +5878,9 @@ def sign(self): sage: (a*b - b*a).sign() 0 - sage: a = AA(sqrt(1/2)) # optional - sage.symbolic - sage: b = AA(-sqrt(1/2)) # optional - sage.symbolic - sage: (a + b).sign() # optional - sage.symbolic + sage: a = AA(sqrt(1/2)) # needs sage.symbolic + sage: b = AA(-sqrt(1/2)) # needs sage.symbolic + sage: (a + b).sign() # needs sage.symbolic 0 TESTS: @@ -5828,17 +5889,18 @@ def sign(self): following example will take a long time (more than 5 seconds) when calling ``y.exactify()``:: - sage: x1 = AA(2^(1/50)) # optional - sage.symbolic - sage: x2 = AA(2^(1/50)) # optional - sage.symbolic - sage: y = x1 - x2 # optional - sage.symbolic - sage: y.sign() # optional - sage.symbolic + sage: # needs sage.symbolic + sage: x1 = AA(2^(1/50)) + sage: x2 = AA(2^(1/50)) + sage: y = x1 - x2 + sage: y.sign() 0 Simplify to rationals for binary operations when computing the sign:: - sage: a = AA(2^(1/60)) # optional - sage.symbolic - sage: b = a - (a + 1) # optional - sage.symbolic - sage: (b + 1).sign() # optional - sage.symbolic + sage: a = AA(2^(1/60)) # needs sage.symbolic + sage: b = a - (a + 1) # needs sage.symbolic + sage: (b + 1).sign() # needs sage.symbolic 0 """ if not self._value.contains_zero(): @@ -5934,8 +5996,8 @@ def _interval_fast(self, prec): EXAMPLES:: - sage: t = AA(sqrt(7)) # optional - sage.symbolic - sage: t._interval_fast(100) # optional - sage.symbolic + sage: t = AA(sqrt(7)) # needs sage.symbolic + sage: t._interval_fast(100) # needs sage.symbolic 2.64575131106459059050161575364? """ return self.interval_fast(RealIntervalField(prec)) @@ -6071,9 +6133,9 @@ def __float__(self): EXAMPLES:: - sage: AA(golden_ratio).__float__() + sage: AA(golden_ratio).__float__() # needs sage.symbolic 1.618033988749895 - sage: float(AA(sqrt(11))) + sage: float(AA(sqrt(11))) # needs sage.symbolic 3.3166247903554 """ return float(RR(self)) @@ -6090,9 +6152,9 @@ def _complex_mpfr_field_(self, field): EXAMPLES:: - sage: AA(golden_ratio)._complex_mpfr_field_(ComplexIntervalField(100)) + sage: AA(golden_ratio)._complex_mpfr_field_(ComplexIntervalField(100)) # needs sage.symbolic 1.618033988749894848204586834365? - sage: AA(golden_ratio)._complex_mpfr_field_(ComplexField(100)) + sage: AA(golden_ratio)._complex_mpfr_field_(ComplexField(100)) # needs sage.symbolic 1.6180339887498948482045868344 """ if isinstance(field, sage.rings.abc.ComplexIntervalField): @@ -6660,9 +6722,9 @@ def is_AlgebraicReal(x): EXAMPLES:: sage: from sage.rings.qqbar import is_AlgebraicReal - sage: is_AlgebraicReal(AA(sqrt(2))) + sage: is_AlgebraicReal(AA(sqrt(2))) # needs sage.symbolic True - sage: is_AlgebraicReal(QQbar(sqrt(2))) + sage: is_AlgebraicReal(QQbar(sqrt(2))) # needs sage.symbolic False sage: is_AlgebraicReal("spam") False @@ -6677,9 +6739,9 @@ def is_AlgebraicNumber(x): EXAMPLES:: sage: from sage.rings.qqbar import is_AlgebraicNumber - sage: is_AlgebraicNumber(AA(sqrt(2))) + sage: is_AlgebraicNumber(AA(sqrt(2))) # needs sage.symbolic False - sage: is_AlgebraicNumber(QQbar(sqrt(2))) + sage: is_AlgebraicNumber(QQbar(sqrt(2))) # needs sage.symbolic True sage: is_AlgebraicNumber("spam") False @@ -7085,13 +7147,14 @@ def conjugate(self, n): EXAMPLES:: - sage: a = (x^2 + 23).roots(ring=QQbar, multiplicities=False)[0] # optional - sage.symbolic - sage: b = a._descr # optional - sage.symbolic - sage: type(b) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = (x^2 + 23).roots(ring=QQbar, multiplicities=False)[0] + sage: b = a._descr + sage: type(b) - sage: c = b.conjugate(a); c # optional - sage.symbolic + sage: c = b.conjugate(a); c - sage: c.exactify() # optional - sage.symbolic + sage: c.exactify() -2*a + 1 where a^2 - a + 6 = 0 and a in 0.50000000000000000? - 2.397915761656360?*I """ if not self._complex: @@ -7486,10 +7549,10 @@ def exactify(self): Verify that :trac:`12727` is fixed:: - sage: m = sqrt(sin(pi/5)); a = QQbar(m); b = AA(m) # optional - sage.symbolic - sage: a.minpoly() # optional - sage.symbolic + sage: m = sqrt(sin(pi/5)); a = QQbar(m); b = AA(m) # needs sage.symbolic + sage: a.minpoly() # needs sage.symbolic x^8 - 5/4*x^4 + 5/16 - sage: b.minpoly() # optional - sage.symbolic + sage: b.minpoly() # needs sage.symbolic x^8 - 5/4*x^4 + 5/16 """ gen = self._poly.generator() @@ -7751,16 +7814,17 @@ def is_complex(self): EXAMPLES:: - sage: rt2 = QQbar(sqrt(2)) # optional - sage.symbolic - sage: rtm3 = QQbar(sqrt(-3)) # optional - sage.symbolic - sage: x = rtm3 + rt2 - rtm3 # optional - sage.symbolic - sage: x.exactify() # optional - sage.symbolic - sage: y = x._descr # optional - sage.symbolic - sage: type(y) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: rt2 = QQbar(sqrt(2)) + sage: rtm3 = QQbar(sqrt(-3)) + sage: x = rtm3 + rt2 - rtm3 + sage: x.exactify() + sage: y = x._descr + sage: type(y) - sage: y.is_complex() # optional - sage.symbolic + sage: y.is_complex() True - sage: x.imag() == 0 # optional - sage.symbolic + sage: x.imag() == 0 True """ return not self._exactly_real @@ -7776,19 +7840,20 @@ def is_simple(self): EXAMPLES:: - sage: rt2 = AA(sqrt(2)) # optional - sage.symbolic - sage: rt3 = AA(sqrt(3)) # optional - sage.symbolic - sage: rt2b = rt3 + rt2 - rt3 # optional - sage.symbolic - sage: rt2.exactify() # optional - sage.symbolic - sage: rt2._descr # optional - sage.symbolic + sage: # needs sage.symbolic + sage: rt2 = AA(sqrt(2)) + sage: rt3 = AA(sqrt(3)) + sage: rt2b = rt3 + rt2 - rt3 + sage: rt2.exactify() + sage: rt2._descr a where a^2 - 2 = 0 and a in 1.414213562373095? - sage: rt2._descr.is_simple() # optional - sage.symbolic + sage: rt2._descr.is_simple() True - sage: rt2b.exactify() # optional - sage.symbolic - sage: rt2b._descr # optional - sage.symbolic + sage: rt2b.exactify() # needs sage.symbolic + sage: rt2b._descr # needs sage.symbolic a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415? - sage: rt2b._descr.is_simple() # optional - sage.symbolic + sage: rt2b._descr.is_simple() # needs sage.symbolic False """ try: @@ -7871,13 +7936,14 @@ def simplify(self, n): EXAMPLES:: - sage: rt2 = AA(sqrt(2)) # optional - sage.symbolic - sage: rt3 = AA(sqrt(3)) # optional - sage.symbolic - sage: rt2b = rt3 + rt2 - rt3 # optional - sage.symbolic - sage: rt2b.exactify() # optional - sage.symbolic - sage: rt2b._descr # optional - sage.symbolic + sage: # needs sage.symbolic + sage: rt2 = AA(sqrt(2)) + sage: rt3 = AA(sqrt(3)) + sage: rt2b = rt3 + rt2 - rt3 + sage: rt2b.exactify() + sage: rt2b._descr a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415? - sage: rt2b._descr.simplify(rt2b) # optional - sage.symbolic + sage: rt2b._descr.simplify(rt2b) a where a^2 - 2 = 0 and a in 1.414213562373095? """ @@ -7909,21 +7975,22 @@ def neg(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) # optional - sage.symbolic - sage: a.exactify() # optional - sage.symbolic - sage: b = a._descr # optional - sage.symbolic - sage: type(b) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) + sage: a.exactify() + sage: b = a._descr + sage: type(b) - sage: c = b.neg(None); c # random (not uniquely represented) # optional - sage.symbolic + sage: c = b.neg(None); c # random (not uniquely represented) -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I - sage: (c.generator() == b.generator() # optional - sage.symbolic + sage: (c.generator() == b.generator() ....: and c.field_element_value() + b.field_element_value() == 0) True The parameter is ignored:: - sage: (b.neg("random").generator() == c.generator() # optional - sage.symbolic + sage: (b.neg("random").generator() == c.generator() # needs sage.symbolic ....: and b.neg("random").field_element_value() == c.field_element_value()) True """ @@ -7935,21 +8002,22 @@ def invert(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) # optional - sage.symbolic - sage: a.exactify() # optional - sage.symbolic - sage: b = a._descr # optional - sage.symbolic - sage: type(b) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) + sage: a.exactify() + sage: b = a._descr + sage: type(b) - sage: c = b.invert(None); c # random (not uniquely represented) # optional - sage.symbolic + sage: c = b.invert(None); c # random (not uniquely represented) -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I - sage: (c.generator() == b.generator() # optional - sage.symbolic + sage: (c.generator() == b.generator() ....: and c.field_element_value() * b.field_element_value() == 1) True The parameter is ignored:: - sage: (b.invert("random").generator() == c.generator() # optional - sage.symbolic + sage: (b.invert("random").generator() == c.generator() # needs sage.symbolic ....: and b.invert("random").field_element_value() == c.field_element_value()) True """ @@ -7961,12 +8029,13 @@ def conjugate(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) # optional - sage.symbolic - sage: a.exactify() # optional - sage.symbolic - sage: b = a._descr # optional - sage.symbolic - sage: type(b) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) + sage: a.exactify() + sage: b = a._descr + sage: type(b) - sage: c = b.conjugate(None); c # random (not uniquely represented) # optional - sage.symbolic + sage: c = b.conjugate(None); c # random (not uniquely represented) 1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I @@ -7974,14 +8043,14 @@ def conjugate(self, n): same abstract field element but conjugating the complex embedding of the field:: - sage: c.generator() == b.generator().conjugate() # optional - sage.symbolic + sage: c.generator() == b.generator().conjugate() # needs sage.symbolic True - sage: c.field_element_value() == b.field_element_value() # optional - sage.symbolic + sage: c.field_element_value() == b.field_element_value() # needs sage.symbolic True The parameter is ignored:: - sage: (b.conjugate("random").generator() == c.generator() # optional - sage.symbolic + sage: (b.conjugate("random").generator() == c.generator() # needs sage.symbolic ....: and b.conjugate("random").field_element_value() == c.field_element_value()) True @@ -8000,12 +8069,13 @@ def norm(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) # optional - sage.symbolic - sage: a.exactify() # optional - sage.symbolic - sage: b = a._descr # optional - sage.symbolic - sage: type(b) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) + sage: a.exactify() + sage: b = a._descr + sage: type(b) - sage: b.norm(a) # optional - sage.symbolic + sage: b.norm(a) """ if self._exactly_real: @@ -8021,12 +8091,13 @@ def abs(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) # optional - sage.symbolic - sage: a.exactify() # optional - sage.symbolic - sage: b = a._descr # optional - sage.symbolic - sage: type(b) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(-3)) + sage: a.exactify() + sage: b = a._descr + sage: type(b) - sage: b.abs(a) # optional - sage.symbolic + sage: b.abs(a) Root 3.146264369941972342? of x^2 - 9.89897948556636? """ return AlgebraicReal(self.norm(n)).sqrt()._descr @@ -8038,13 +8109,15 @@ def rational_argument(self, n): EXAMPLES:: - sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(3)) # optional - sage.symbolic - sage: a.exactify() # optional - sage.symbolic - sage: b = a._descr # optional - sage.symbolic - sage: type(b) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = QQbar(sqrt(-2)) + QQbar(sqrt(3)) + sage: a.exactify() + sage: b = a._descr + sage: type(b) - sage: b.rational_argument(a) is None # optional - sage.symbolic + sage: b.rational_argument(a) is None True + sage: x = polygen(QQ) sage: a = (x^4 + 1).roots(QQbar, multiplicities=False)[0] sage: a.exactify() @@ -8094,7 +8167,7 @@ def __init__(self, arg, op): EXAMPLES:: - sage: t = ~QQbar(sqrt(2)); type(t._descr) # indirect doctest # optional - sage.symbolic + sage: t = ~QQbar(sqrt(2)); type(t._descr) # indirect doctest # needs sage.symbolic """ self._arg = arg @@ -8107,9 +8180,9 @@ def __reduce__(self): EXAMPLES:: - sage: t = ~QQbar(sqrt(2)); type(t._descr) # optional - sage.symbolic + sage: t = ~QQbar(sqrt(2)); type(t._descr) # needs sage.symbolic - sage: loads(dumps(t)) == 1/QQbar(sqrt(2)) # optional - sage.symbolic + sage: loads(dumps(t)) == 1/QQbar(sqrt(2)) # needs sage.symbolic True """ return (ANUnaryExpr, (self._arg, self._op)) @@ -8208,13 +8281,14 @@ def is_complex(self): EXAMPLES:: - sage: t = AA(sqrt(2)) # optional - sage.symbolic - sage: s = (-t)._descr # optional - sage.symbolic - sage: s # optional - sage.symbolic + sage: # needs sage.symbolic + sage: t = AA(sqrt(2)) + sage: s = (-t)._descr + sage: s - sage: s.is_complex() # optional - sage.symbolic + sage: s.is_complex() False - sage: QQbar(-sqrt(2))._descr.is_complex() # optional - sage.symbolic + sage: QQbar(-sqrt(2))._descr.is_complex() True """ return self._complex @@ -8225,11 +8299,12 @@ def _interval_fast(self, prec): EXAMPLES:: - sage: t = AA(sqrt(2)) # optional - sage.symbolic - sage: s = (-t)._descr # optional - sage.symbolic - sage: s # optional - sage.symbolic + sage: # needs sage.symbolic + sage: t = AA(sqrt(2)) + sage: s = (-t)._descr + sage: s - sage: s._interval_fast(150) # optional - sage.symbolic + sage: s._interval_fast(150) -1.414213562373095048801688724209698078569671876? """ op = self._op @@ -8282,10 +8357,10 @@ def exactify(self): EXAMPLES:: - sage: v = (-QQbar(sqrt(2)))._descr # optional - sage.symbolic - sage: type(v) # optional - sage.symbolic + sage: v = (-QQbar(sqrt(2)))._descr # needs sage.symbolic + sage: type(v) # needs sage.symbolic - sage: v.exactify() # optional - sage.symbolic + sage: v.exactify() # needs sage.symbolic -a where a^2 - 2 = 0 and a in 1.414213562373095? """ op = self._op @@ -8349,7 +8424,7 @@ def __init__(self, left, right, op): EXAMPLES:: - sage: t = QQbar(sqrt(2)) + QQbar(sqrt(3)); type(t._descr) # indirect doctest # optional - sage.symbolic + sage: t = QQbar(sqrt(2)) + QQbar(sqrt(3)); type(t._descr) # indirect doctest # needs sage.symbolic """ self._left = left @@ -8363,9 +8438,9 @@ def __reduce__(self): EXAMPLES:: - sage: t = QQbar(sqrt(2)) + QQbar(sqrt(3)); type(t._descr) # optional - sage.symbolic + sage: t = QQbar(sqrt(2)) + QQbar(sqrt(3)); type(t._descr) # needs sage.symbolic - sage: loads(dumps(t)) == QQbar(sqrt(2)) + QQbar(sqrt(3)) # optional - sage.symbolic + sage: loads(dumps(t)) == QQbar(sqrt(2)) + QQbar(sqrt(3)) # needs sage.symbolic True """ return (ANBinaryExpr, (self._left, self._right, self._op)) @@ -8413,10 +8488,10 @@ def handle_sage_input(self, sib, coerce, is_qqbar): True sage: sage_input(n) 1 + AA(3) - sage: rt3 = QQbar(sqrt(3)) # optional - sage.symbolic - sage: one = rt3/rt3 # optional - sage.symbolic + sage: rt3 = QQbar(sqrt(3)) # needs sage.symbolic + sage: one = rt3/rt3 # needs sage.symbolic sage: n = sqrt(AA(2)) + one - sage: one == 1 # optional - sage.symbolic + sage: one == 1 # needs sage.symbolic True sage: sage_input(n) R. = AA[] @@ -8487,8 +8562,8 @@ def is_complex(self): EXAMPLES:: - sage: x = (QQbar(sqrt(-2)) / QQbar(sqrt(-5)))._descr # optional - sage.symbolic - sage: x.is_complex() # optional - sage.symbolic + sage: x = (QQbar(sqrt(-2)) / QQbar(sqrt(-5)))._descr # needs sage.symbolic + sage: x.is_complex() # needs sage.symbolic True """ return self._complex @@ -8499,10 +8574,10 @@ def _interval_fast(self, prec): EXAMPLES:: - sage: x = (QQbar(sqrt(-2)) / QQbar(sqrt(-5)))._descr # optional - sage.symbolic - sage: y= x._interval_fast(64); y # optional - sage.symbolic + sage: x = (QQbar(sqrt(-2)) / QQbar(sqrt(-5)))._descr # needs sage.symbolic + sage: y= x._interval_fast(64); y # needs sage.symbolic 0.632455532033675867? - sage: y.parent() # optional - sage.symbolic + sage: y.parent() # needs sage.symbolic Complex Interval Field with 64 bits of precision """ op = self._op @@ -8519,8 +8594,8 @@ def exactify(self): """ TESTS:: - sage: rt2c = QQbar.zeta(3) + AA(sqrt(2)) - QQbar.zeta(3) # optional - sage.symbolic - sage: rt2c.exactify() # optional - sage.symbolic + sage: rt2c = QQbar.zeta(3) + AA(sqrt(2)) - QQbar.zeta(3) # needs sage.symbolic + sage: rt2c.exactify() # needs sage.symbolic We check to make sure that this method still works even. We do this by increasing the recursion level at each step and @@ -8605,25 +8680,27 @@ def an_binop_expr(a, b, op): EXAMPLES:: - sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3)) # optional - sage.symbolic - sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5)) # optional - sage.symbolic - sage: type(a._descr); type(b._descr) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3)) + sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5)) + sage: type(a._descr); type(b._descr) sage: from sage.rings.qqbar import an_binop_expr - sage: x = an_binop_expr(a, b, operator.add); x # optional - sage.symbolic + sage: x = an_binop_expr(a, b, operator.add); x - sage: x.exactify() # optional - sage.symbolic + sage: x.exactify() 6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997? - sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3)) # optional - sage.symbolic - sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5)) # optional - sage.symbolic - sage: type(a._descr) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3)) + sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5)) + sage: type(a._descr) - sage: x = an_binop_expr(a, b, operator.mul); x # optional - sage.symbolic + sage: x = an_binop_expr(a, b, operator.mul); x - sage: x.exactify() # optional - sage.symbolic + sage: x.exactify() 2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997? """ @@ -8757,7 +8834,7 @@ def get_AA_golden_ratio(): EXAMPLES:: - sage: AA(golden_ratio) # indirect doctest # optional - sage.symbolic + sage: AA(golden_ratio) # indirect doctest # needs sage.symbolic 1.618033988749895? """ global AA_golden_ratio diff --git a/src/sage/rings/qqbar_decorators.py b/src/sage/rings/qqbar_decorators.py index 27448c2def6..c0505b11e8b 100644 --- a/src/sage/rings/qqbar_decorators.py +++ b/src/sage/rings/qqbar_decorators.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field """ QQbar decorators diff --git a/src/sage/rings/quotient_ring.py b/src/sage/rings/quotient_ring.py index 178cae67a22..7dc4e0803c8 100644 --- a/src/sage/rings/quotient_ring.py +++ b/src/sage/rings/quotient_ring.py @@ -38,8 +38,8 @@ ....: def reduce(self,x): ....: R = self.ring() ....: return add([c*R(m) for m,c in x if len(m) = FreeAlgebra(QQ, 3) # optional - sage.combinat sage.modules - sage: I3 = PowerIdeal(F,3); I3 # optional - sage.combinat sage.modules + sage: F. = FreeAlgebra(QQ, 3) # needs sage.combinat sage.modules + sage: I3 = PowerIdeal(F,3); I3 # needs sage.combinat sage.modules Twosided Ideal (x^3, x^2*y, x^2*z, x*y*x, x*y^2, x*y*z, x*z*x, x*z*y, x*z^2, y*x^2, y*x*y, y*x*z, y^2*x, y^3, y^2*z, y*z*x, y*z*y, y*z^2, z*x^2, z*x*y, z*x*z, z*y*x, z*y^2, z*y*z, z^2*x, z^2*y, z^3) of @@ -49,33 +49,35 @@ finite dimensional quotients defined by multiplication matrices. We are bypassing it, so that we obtain the default quotient:: - sage: Q3. = F.quotient(I3) # optional - sage.combinat sage.modules - sage: Q3 # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.modules + sage: Q3. = F.quotient(I3) + sage: Q3 Quotient of Free Algebra on 3 generators (x, y, z) over Rational Field by the ideal (x^3, x^2*y, x^2*z, x*y*x, x*y^2, x*y*z, x*z*x, x*z*y, x*z^2, y*x^2, y*x*y, y*x*z, y^2*x, y^3, y^2*z, y*z*x, y*z*y, y*z^2, z*x^2, z*x*y, z*x*z, z*y*x, z*y^2, z*y*z, z^2*x, z^2*y, z^3) - sage: (a+b+2)^4 # optional - sage.combinat sage.modules + sage: (a+b+2)^4 16 + 32*a + 32*b + 24*a^2 + 24*a*b + 24*b*a + 24*b^2 - sage: Q3.is_commutative() # optional - sage.combinat sage.modules + sage: Q3.is_commutative() False Even though `Q_3` is not commutative, there is commutativity for products of degree three:: - sage: a*(b*c)-(b*c)*a==F.zero() # optional - sage.combinat sage.modules + sage: a*(b*c)-(b*c)*a==F.zero() # needs sage.combinat sage.modules True If we quotient out all terms of degree two then of course the resulting quotient ring is commutative:: - sage: I2 = PowerIdeal(F,2); I2 # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.modules + sage: I2 = PowerIdeal(F,2); I2 Twosided Ideal (x^2, x*y, x*z, y*x, y^2, y*z, z*x, z*y, z^2) of Free Algebra on 3 generators (x, y, z) over Rational Field - sage: Q2. = F.quotient(I2) # optional - sage.combinat sage.modules - sage: Q2.is_commutative() # optional - sage.combinat sage.modules + sage: Q2. = F.quotient(I2) + sage: Q2.is_commutative() True - sage: (a+b+2)^4 # optional - sage.combinat sage.modules + sage: (a+b+2)^4 16 + 32*a + 32*b Since :trac:`7797`, there is an implementation of free algebras @@ -83,18 +85,21 @@ letterplace wrapper allows to provide the above toy example more easily:: + sage: # needs sage.combinat sage.libs.singular sage.modules sage: from itertools import product - sage: F. = FreeAlgebra(QQ, implementation='letterplace') # optional - sage.combinat sage.modules - sage: Q3 = F.quo(F*[F.prod(m) for m in product(F.gens(), repeat=3)]*F) # optional - sage.combinat sage.modules - sage: Q3 # optional - sage.combinat sage.modules + sage: F. = FreeAlgebra(QQ, implementation='letterplace') + sage: Q3 = F.quo(F*[F.prod(m) for m in product(F.gens(), repeat=3)]*F) + sage: Q3 Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) - over Rational Field by the ideal (x*x*x, x*x*y, x*x*z, x*y*x, x*y*y, x*y*z, x*z*x, x*z*y, x*z*z, y*x*x, y*x*y, y*x*z, y*y*x, y*y*y, y*y*z, y*z*x, y*z*y, y*z*z, z*x*x, z*x*y, z*x*z, z*y*x, z*y*y, z*y*z, z*z*x, z*z*y, z*z*z) - sage: Q3.0*Q3.1 - Q3.1*Q3.0 # optional - sage.combinat sage.modules + over Rational Field by the ideal (x*x*x, x*x*y, x*x*z, x*y*x, x*y*y, x*y*z, + x*z*x, x*z*y, x*z*z, y*x*x, y*x*y, y*x*z, y*y*x, y*y*y, y*y*z, y*z*x, y*z*y, + y*z*z, z*x*x, z*x*y, z*x*z, z*y*x, z*y*y, z*y*z, z*z*x, z*z*y, z*z*z) + sage: Q3.0*Q3.1 - Q3.1*Q3.0 xbar*ybar - ybar*xbar - sage: Q3.0*(Q3.1*Q3.2) - (Q3.1*Q3.2)*Q3.0 # optional - sage.combinat sage.modules + sage: Q3.0*(Q3.1*Q3.2) - (Q3.1*Q3.2)*Q3.0 0 - sage: Q2 = F.quo(F*[F.prod(m) for m in product(F.gens(), repeat=2)]*F) # optional - sage.combinat sage.modules - sage: Q2.is_commutative() # optional - sage.combinat sage.modules + sage: Q2 = F.quo(F*[F.prod(m) for m in product(F.gens(), repeat=2)]*F) + sage: Q2.is_commutative() True """ @@ -177,15 +182,16 @@ def QuotientRing(R, I, names=None, **kwds): With polynomial rings (note that the variable name of the quotient ring can be specified as shown below):: + sage: # needs sage.libs.pari sage: P. = QQ[] - sage: R. = QuotientRing(P, P.ideal(x^2 + 1)) # optional - sage.libs.pari - sage: R # optional - sage.libs.pari + sage: R. = QuotientRing(P, P.ideal(x^2 + 1)) + sage: R Univariate Quotient Polynomial Ring in xx over Rational Field with modulus x^2 + 1 - sage: R.gens(); R.gen() # optional - sage.libs.pari + sage: R.gens(); R.gen() (xx,) xx - sage: for n in range(4): xx^n # optional - sage.libs.pari + sage: for n in range(4): xx^n 1 xx -1 @@ -193,14 +199,15 @@ def QuotientRing(R, I, names=None, **kwds): :: + sage: # needs sage.libs.pari sage: P. = QQ[] - sage: S = QuotientRing(P, P.ideal(x^2 - 2)) # optional - sage.libs.pari - sage: S # optional - sage.libs.pari + sage: S = QuotientRing(P, P.ideal(x^2 - 2)) + sage: S Univariate Quotient Polynomial Ring in xbar over Rational Field with modulus x^2 - 2 - sage: xbar = S.gen(); S.gen() # optional - sage.libs.pari + sage: xbar = S.gen(); S.gen() xbar - sage: for n in range(3): xbar^n # optional - sage.libs.pari + sage: for n in range(3): xbar^n 1 xbar 2 @@ -208,7 +215,7 @@ def QuotientRing(R, I, names=None, **kwds): Sage coerces objects into ideals when possible:: sage: P. = QQ[] - sage: R = QuotientRing(P, x^2 + 1); R # optional - sage.libs.pari + sage: R = QuotientRing(P, x^2 + 1); R # needs sage.libs.pari Univariate Quotient Polynomial Ring in xbar over Rational Field with modulus x^2 + 1 @@ -217,17 +224,18 @@ def QuotientRing(R, I, names=None, **kwds): example, we end up modding out the ideal `(x)` from the ring `\QQ[x,y]`:: + sage: # needs sage.libs.pari sage.libs.singular sage: R. = PolynomialRing(QQ, 2) - sage: S. = QuotientRing(R, R.ideal(1 + y^2)) # optional - sage.libs.pari - sage: T. = QuotientRing(S, S.ideal(a)) # optional - sage.libs.pari - sage: T # optional - sage.libs.pari + sage: S. = QuotientRing(R, R.ideal(1 + y^2)) + sage: T. = QuotientRing(S, S.ideal(a)) + sage: T Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x, y^2 + 1) - sage: R.gens(); S.gens(); T.gens() # optional - sage.libs.pari + sage: R.gens(); S.gens(); T.gens() (x, y) (a, b) (0, d) - sage: for n in range(4): d^n # optional - sage.libs.pari + sage: for n in range(4): d^n 1 d -1 @@ -246,23 +254,24 @@ def QuotientRing(R, I, names=None, **kwds): Here is an example of the quotient of a free algebra by a twosided homogeneous ideal (see :trac:`7797`):: - sage: F. = FreeAlgebra(QQ, implementation='letterplace') # optional - sage.combinat sage.modules - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F # optional - sage.combinat sage.modules - sage: Q. = F.quo(I); Q # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: F. = FreeAlgebra(QQ, implementation='letterplace') + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F + sage: Q. = F.quo(I); Q Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field by the ideal (x*y + y*z, x*x + x*y - y*x - y*y) - sage: a*b # optional - sage.combinat sage.modules + sage: a*b -b*c - sage: a^3 # optional - sage.combinat sage.modules + sage: a^3 -b*c*a - b*c*b - b*c*c - sage: J = Q * [a^3 - b^3] * Q # optional - sage.combinat sage.modules - sage: R. = Q.quo(J); R # optional - sage.combinat sage.modules + sage: J = Q * [a^3 - b^3] * Q + sage: R. = Q.quo(J); R Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field by the ideal (-y*y*z - y*z*x - 2*y*z*z, x*y + y*z, x*x + x*y - y*x - y*y) - sage: i^3 # optional - sage.combinat sage.modules + sage: i^3 -j*k*i - j*k*j - j*k*k - sage: j^3 # optional - sage.combinat sage.modules + sage: j^3 -j*k*i - j*k*j - j*k*k Check that :trac:`5978` is fixed by if we quotient by the zero ideal `(0)` @@ -348,12 +357,13 @@ def is_QuotientRing(x): :: - sage: F. = FreeAlgebra(QQ, implementation='letterplace') # optional - sage.combinat sage.modules - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F # optional - sage.combinat sage.modules - sage: Q = F.quo(I) # optional - sage.combinat sage.modules - sage: is_QuotientRing(Q) # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: F. = FreeAlgebra(QQ, implementation='letterplace') + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F + sage: Q = F.quo(I) + sage: is_QuotientRing(Q) True - sage: is_QuotientRing(F) # optional - sage.combinat sage.modules + sage: is_QuotientRing(F) False """ return isinstance(x, QuotientRing_nc) @@ -376,26 +386,29 @@ class QuotientRing_nc(ring.Ring, sage.structure.parent_gens.ParentWithGens): Here is a quotient of a free algebra by a twosided homogeneous ideal:: - sage: F. = FreeAlgebra(QQ, implementation='letterplace') # optional - sage.combinat sage.modules - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2]*F # optional - sage.combinat sage.modules - sage: Q. = F.quo(I); Q # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: F. = FreeAlgebra(QQ, implementation='letterplace') + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2]*F + sage: Q. = F.quo(I); Q Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field by the ideal (x*y + y*z, x*x + x*y - y*x - y*y) - sage: a*b # optional - sage.combinat sage.modules + sage: a*b -b*c - sage: a^3 # optional - sage.combinat sage.modules + sage: a^3 -b*c*a - b*c*b - b*c*c A quotient of a quotient is just the quotient of the original top ring by the sum of two ideals:: - sage: J = Q * [a^3 - b^3] * Q # optional - sage.combinat sage.modules - sage: R. = Q.quo(J); R # optional - sage.combinat sage.modules - Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: J = Q * [a^3 - b^3] * Q + sage: R. = Q.quo(J); R + Quotient of + Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field by the ideal (-y*y*z - y*z*x - 2*y*z*z, x*y + y*z, x*x + x*y - y*x - y*y) - sage: i^3 # optional - sage.combinat sage.modules + sage: i^3 -j*k*i - j*k*j - j*k*k - sage: j^3 # optional - sage.combinat sage.modules + sage: j^3 -j*k*i - j*k*j - j*k*k For rings that *do* inherit from :class:`~sage.rings.ring.CommutativeRing`, @@ -413,10 +426,10 @@ class QuotientRing_nc(ring.Ring, sage.structure.parent_gens.ParentWithGens): :: sage: R. = PolynomialRing(QQ) - sage: S. = R.quo(x^2 + y^2) # optional - sage.libs.singular - sage: a^2 + b^2 == 0 # optional - sage.libs.singular + sage: S. = R.quo(x^2 + y^2) # needs sage.libs.singular + sage: a^2 + b^2 == 0 # needs sage.libs.singular True - sage: S(0) == a^2 + b^2 # optional - sage.libs.singular + sage: S(0) == a^2 + b^2 # needs sage.libs.singular True Again, a quotient of a quotient is just the quotient of the original top @@ -424,13 +437,14 @@ class QuotientRing_nc(ring.Ring, sage.structure.parent_gens.ParentWithGens): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) - sage: S. = R.quo(1 + y^2) # optional - sage.libs.singular - sage: T. = S.quo(a) # optional - sage.libs.singular - sage: T # optional - sage.libs.singular + sage: S. = R.quo(1 + y^2) + sage: T. = S.quo(a) + sage: T Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x, y^2 + 1) - sage: T.gens() # optional - sage.libs.singular + sage: T.gens() (0, d) """ Element = quotient_ring_element.QuotientRingElement @@ -449,20 +463,21 @@ def __init__(self, R, I, names, category=None): EXAMPLES:: - sage: F. = FreeAlgebra(QQ, implementation='letterplace') # optional - sage.combinat sage.modules - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F # optional - sage.combinat sage.modules - sage: Q. = F.quo(I); Q # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: F. = FreeAlgebra(QQ, implementation='letterplace') + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F + sage: Q. = F.quo(I); Q Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field by the ideal (x*y + y*z, x*x + x*y - y*x - y*y) - sage: a*b # optional - sage.combinat sage.modules + sage: a*b -b*c - sage: a^3 # optional - sage.combinat sage.modules + sage: a^3 -b*c*a - b*c*b - b*c*c """ if R not in _Rings: - raise TypeError("The first argument must be a ring, but %s is not"%R) + raise TypeError("The first argument must be a ring, but %s is not" % R) # workaround to silence warning from #34806 from sage.rings.number_field.order import Order if isinstance(R, Order): @@ -470,7 +485,7 @@ def __init__(self, R, I, names, category=None): else: M = R.ideal_monoid() if I not in M: - raise TypeError("The second argument must be an ideal of the given ring, but %s is not"%I) + raise TypeError("The second argument must be an ideal of the given ring, but %s is not" % I) self.__R = R self.__I = I #sage.structure.parent_gens.ParentWithGens.__init__(self, R.base_ring(), names) @@ -504,10 +519,12 @@ def construction(self): sage: I = R.ideal([4 + 3*x + x^2, 1 + x^2]) sage: R.quotient_ring(I).construction() (QuotientFunctor, Univariate Polynomial Ring in x over Integer Ring) - sage: F. = FreeAlgebra(QQ, implementation='letterplace') # optional - sage.combinat sage.modules - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F # optional - sage.combinat sage.modules - sage: Q = F.quo(I) # optional - sage.combinat sage.modules - sage: Q.construction() # optional - sage.combinat sage.modules + + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: F. = FreeAlgebra(QQ, implementation='letterplace') + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F + sage: Q = F.quo(I) + sage: Q.construction() (QuotientFunctor, Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field) @@ -516,8 +533,8 @@ def construction(self): sage: F, R = Integers(5).construction() sage: F(R) Ring of integers modulo 5 - sage: F, R = GF(5).construction() # optional - sage.rings.finite_rings - sage: F(R) # optional - sage.rings.finite_rings + sage: F, R = GF(5).construction() + sage: F(R) Finite Field of size 5 """ from sage.categories.pushout import QuotientFunctor @@ -549,7 +566,7 @@ def _repr_(self): sage: R.quotient_ring(I)._repr_() 'Quotient of Univariate Polynomial Ring in x over Integer Ring by the ideal (x^2 + 3*x + 4, x^2 + 1)' """ - return "Quotient of %s by the ideal %s"%(self.cover_ring(), self.defining_ideal()._repr_short()) + return "Quotient of %s by the ideal %s" % (self.cover_ring(), self.defining_ideal()._repr_short()) def _latex_(self): """ @@ -562,7 +579,7 @@ def _latex_(self): sage: R.quotient_ring(I)._latex_() '\\Bold{Z}[x]/\\left(x^{2} + 3x + 4, x^{2} + 1\\right)\\Bold{Z}[x]' """ - return "%s/%s"%(latex.latex(self.cover_ring()), latex.latex(self.defining_ideal())) + return "%s/%s" % (latex.latex(self.cover_ring()), latex.latex(self.defining_ideal())) def is_commutative(self): """ @@ -589,19 +606,21 @@ def is_commutative(self): The non-commutative case is more interesting:: - sage: F. = FreeAlgebra(QQ, implementation='letterplace') # optional - sage.combinat sage.modules - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F # optional - sage.combinat sage.modules - sage: Q = F.quo(I) # optional - sage.combinat sage.modules - sage: Q.is_commutative() # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: F. = FreeAlgebra(QQ, implementation='letterplace') + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F + sage: Q = F.quo(I) + sage: Q.is_commutative() False - sage: Q.1*Q.2 == Q.2*Q.1 # optional - sage.combinat sage.modules + sage: Q.1*Q.2 == Q.2*Q.1 False In the next example, the generators apparently commute:: - sage: J = F * [x*y - y*x, x*z - z*x, y*z - z*y, x^3 - y^3] * F # optional - sage.combinat sage.modules - sage: R = F.quo(J) # optional - sage.combinat sage.modules - sage: R.is_commutative() # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: J = F * [x*y - y*x, x*z - z*x, y*z - z*y, x^3 - y^3] * F + sage: R = F.quo(J) + sage: R.is_commutative() True """ @@ -641,21 +660,22 @@ def cover(self): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ) sage: Q = R.quo((x^2, y^2)) - sage: pi = Q.cover() # optional - sage.libs.singular - sage: pi(x^3 + y) # optional - sage.libs.singular + sage: pi = Q.cover() + sage: pi(x^3 + y) ybar - sage: l = pi.lift(x + y^3) # optional - sage.libs.singular - sage: l # optional - sage.libs.singular + sage: l = pi.lift(x + y^3) + sage: l x - sage: l = pi.lift(); l # optional - sage.libs.singular + sage: l = pi.lift(); l Set-theoretic ring morphism: From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2, y^2) To: Multivariate Polynomial Ring in x, y over Rational Field Defn: Choice of lifting map - sage: l(x + y^3) # optional - sage.libs.singular + sage: l(x + y^3) x """ try: @@ -675,42 +695,44 @@ def lifting_map(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) sage: S = R.quotient(x^2 + y^2) - sage: pi = S.cover(); pi # optional - sage.libs.singular + sage: pi = S.cover(); pi Ring morphism: From: Multivariate Polynomial Ring in x, y over Rational Field To: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) Defn: Natural quotient map - sage: L = S.lifting_map(); L # optional - sage.libs.singular + sage: L = S.lifting_map(); L Set-theoretic ring morphism: From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) To: Multivariate Polynomial Ring in x, y over Rational Field Defn: Choice of lifting map - sage: L(S.0) # optional - sage.libs.singular + sage: L(S.0) x - sage: L(S.1) # optional - sage.libs.singular + sage: L(S.1) y Note that some reduction may be applied so that the lift of a reduction need not equal the original element:: - sage: z = pi(x^3 + 2*y^2); z # optional - sage.libs.singular + sage: z = pi(x^3 + 2*y^2); z # needs sage.libs.singular -xbar*ybar^2 + 2*ybar^2 - sage: L(z) # optional - sage.libs.singular + sage: L(z) # needs sage.libs.singular -x*y^2 + 2*y^2 - sage: L(z) == x^3 + 2*y^2 # optional - sage.libs.singular + sage: L(z) == x^3 + 2*y^2 # needs sage.libs.singular False Test that there also is a lift for rings that are no instances of :class:`~sage.rings.ring.Ring` (see :trac:`11068`):: - sage: MS = MatrixSpace(GF(5), 2, 2) # optional - sage.modules sage.rings.finite_rings - sage: I = MS * [MS.0*MS.1, MS.2 + MS.3] * MS # optional - sage.modules sage.rings.finite_rings - sage: Q = MS.quo(I) # optional - sage.modules sage.rings.finite_rings - sage: Q.lift() # optional - sage.modules sage.rings.finite_rings + sage: # needs sage.modules + sage: MS = MatrixSpace(GF(5), 2, 2) + sage: I = MS * [MS.0*MS.1, MS.2 + MS.3] * MS + sage: Q = MS.quo(I) + sage: Q.lift() Set-theoretic ring morphism: From: Quotient of Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 5 by the ideal @@ -752,13 +774,13 @@ def lift(self, x=None): sage: R. = PolynomialRing(QQ, 2) sage: S = R.quotient(x^2 + y^2) - sage: S.lift() # optional - sage.libs.singular + sage: S.lift() # needs sage.libs.singular Set-theoretic ring morphism: From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) To: Multivariate Polynomial Ring in x, y over Rational Field Defn: Choice of lifting map - sage: S.lift(S.0) == x # optional - sage.libs.singular + sage: S.lift(S.0) == x # needs sage.libs.singular True """ @@ -782,7 +804,7 @@ def retract(self,x): sage: R. = PolynomialRing(QQ, 2) sage: S = R.quotient(x^2 + y^2) - sage: S.retract((x+y)^2) # optional - sage.libs.singular + sage: S.retract((x+y)^2) # needs sage.libs.singular 2*xbar*ybar """ @@ -822,12 +844,13 @@ def defining_ideal(self): homomorphism theorems, this is actually a quotient by a sum of two ideals:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) - sage: S. = QuotientRing(R, R.ideal(1 + y^2)) # optional - sage.libs.singular - sage: T. = QuotientRing(S, S.ideal(a)) # optional - sage.libs.singular - sage: S.defining_ideal() # optional - sage.libs.singular + sage: S. = QuotientRing(R, R.ideal(1 + y^2)) + sage: T. = QuotientRing(S, S.ideal(a)) + sage: S.defining_ideal() Ideal (y^2 + 1) of Multivariate Polynomial Ring in x, y over Rational Field - sage: T.defining_ideal() # optional - sage.libs.singular + sage: T.defining_ideal() Ideal (x, y^2 + 1) of Multivariate Polynomial Ring in x, y over Rational Field """ return self.__I @@ -841,14 +864,14 @@ def is_field(self, proof=True): TESTS:: sage: Q = QuotientRing(ZZ, 7*ZZ) - sage: Q.is_field() # optional - sage.libs.pari + sage: Q.is_field() True Requires the ``is_maximal`` method of the defining ideal to be implemented:: sage: R. = ZZ[] - sage: R.quotient_ring(R.ideal([2, 4 + x])).is_field() # optional - sage.libs.pari + sage: R.quotient_ring(R.ideal([2, 4 + x])).is_field() Traceback (most recent call last): ... NotImplementedError @@ -875,19 +898,19 @@ def is_integral_domain(self, proof=True): EXAMPLES:: sage: R. = QQ[] - sage: R.quo(x^2 - y).is_integral_domain() # optional - sage.singular + sage: R.quo(x^2 - y).is_integral_domain() # needs sage.libs.singular True - sage: R.quo(x^2 - y^2).is_integral_domain() # optional - sage.singular + sage: R.quo(x^2 - y^2).is_integral_domain() # needs sage.libs.singular False - sage: R.quo(x^2 - y^2).is_integral_domain(proof=False) # optional - sage.singular + sage: R.quo(x^2 - y^2).is_integral_domain(proof=False) # needs sage.libs.singular False - sage: R. = ZZ[] # optional - sage.singular - sage: Q = R.quotient_ring([a, b]) # optional - sage.singular - sage: Q.is_integral_domain() # optional - sage.singular + sage: R. = ZZ[] + sage: Q = R.quotient_ring([a, b]) + sage: Q.is_integral_domain() Traceback (most recent call last): ... NotImplementedError - sage: Q.is_integral_domain(proof=False) # optional - sage.singular + sage: Q.is_integral_domain(proof=False) False """ if proof: @@ -909,8 +932,8 @@ def is_noetherian(self): True sage: P. = QQ[] - sage: R = QuotientRing(P, x^2 + 1) # optional - sage.libs.pari - sage: R.is_noetherian() # optional - sage.libs.pari + sage: R = QuotientRing(P, x^2 + 1) # needs sage.libs.pari + sage: R.is_noetherian() True If the cover ring of ``self`` is not Noetherian, we currently @@ -921,8 +944,8 @@ def is_noetherian(self): sage: R.is_noetherian() False sage: I = R.ideal([x[1]^2, x[2]]) - sage: S = R.quotient(I) # optional - sage.libs.pari - sage: S.is_noetherian() # optional - sage.libs.pari + sage: S = R.quotient(I) + sage: S.is_noetherian() Traceback (most recent call last): ... NotImplementedError @@ -948,8 +971,8 @@ def cover_ring(self): :: sage: P. = QQ[] - sage: Q = QuotientRing(P, x^2 + 1) # optional - sage.libs.pari - sage: Q.cover_ring() # optional - sage.libs.pari + sage: Q = QuotientRing(P, x^2 + 1) # needs sage.libs.pari + sage: Q.cover_ring() # needs sage.libs.pari Univariate Polynomial Ring in x over Rational Field """ return self.__R @@ -965,10 +988,10 @@ def ideal(self, *gens, **kwds): sage: R. = PolynomialRing(QQ) sage: S = R.quotient_ring(x^2 + y^2) - sage: S.ideal() # optional - sage.libs.pari + sage: S.ideal() # needs sage.libs.singular Ideal (0) of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) - sage: S.ideal(x + y + 1) # optional - sage.libs.pari + sage: S.ideal(x + y + 1) # needs sage.libs.singular Ideal (xbar + ybar + 1) of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) @@ -1007,9 +1030,9 @@ def _element_constructor_(self, x, coerce=True): sage: R. = PolynomialRing(QQ) sage: S = R.quotient_ring(x^2 + y^2) - sage: S(x) # indirect doctest # optional - sage.libs.singular + sage: S(x) # indirect doctest # needs sage.libs.singular xbar - sage: S(x^2 + y^2) # optional - sage.libs.singular + sage: S(x^2 + y^2) # needs sage.libs.singular 0 The rings that coerce into the quotient ring canonically, are: @@ -1021,15 +1044,16 @@ def _element_constructor_(self, x, coerce=True): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) - sage: S. = R.quotient(x^2 + y^2) # optional - sage.libs.singular - sage: S.coerce(0) # optional - sage.libs.singular + sage: S. = R.quotient(x^2 + y^2) + sage: S.coerce(0) 0 - sage: S.coerce(2/3) # optional - sage.libs.singular + sage: S.coerce(2/3) 2/3 - sage: S.coerce(a^2 - b) # optional - sage.libs.singular + sage: S.coerce(a^2 - b) -b^2 - b - sage: S.coerce(GF(7)(3)) # optional - sage.rings.finite_rings sage.libs.singular + sage: S.coerce(GF(7)(3)) Traceback (most recent call last): ... TypeError: no canonical coercion from Finite Field of size 7 @@ -1037,7 +1061,7 @@ def _element_constructor_(self, x, coerce=True): TESTS:: - sage: S(x, coerce=False) # optional - sage.libs.singular + sage: S(x, coerce=False) # needs sage.libs.singular a """ if isinstance(x, quotient_ring_element.QuotientRingElement): @@ -1061,14 +1085,14 @@ def _coerce_map_from_(self, R): sage: R. = PolynomialRing(QQ) sage: S = R.quotient_ring(x^2 + y^2) - sage: S.has_coerce_map_from(R) # indirect doctest + sage: S.has_coerce_map_from(R) # indirect doctest True sage: S.has_coerce_map_from(QQ) True - sage: T = S.quotient_ring(x^3 - y) # optional - sage.libs.singular - sage: S.has_coerce_map_from(T) # optional - sage.libs.singular + sage: T = S.quotient_ring(x^3 - y) # needs sage.libs.singular + sage: S.has_coerce_map_from(T) # needs sage.libs.singular False - sage: T.has_coerce_map_from(R) # optional - sage.libs.singular + sage: T.has_coerce_map_from(R) # needs sage.libs.singular True TESTS: @@ -1078,15 +1102,17 @@ def _coerce_map_from_(self, R): sage: R. = PolynomialRing(QQ) sage: I = R.ideal(x^2 + y^2) sage: J = R.ideal(x^2 + y^2, x^3 - y) - sage: I < J # optional - sage.libs.singular + sage: S = R.quotient(I) + sage: T = R.quotient(J) + + sage: # needs sage.libs.singular + sage: I < J True - sage: S = R.quotient(I) # optional - sage.libs.singular - sage: T = R.quotient(J) # optional - sage.libs.singular - sage: T.has_coerce_map_from(S) # optional - sage.libs.singular + sage: T.has_coerce_map_from(S) True - sage: S.quotient_ring(x^4 - x*y + 1).has_coerce_map_from(S) # optional - sage.libs.singular + sage: S.quotient_ring(x^4 - x*y + 1).has_coerce_map_from(S) True - sage: S.has_coerce_map_from(T) # optional - sage.libs.singular + sage: S.has_coerce_map_from(T) False We also allow coercions with the cover rings:: @@ -1094,15 +1120,15 @@ def _coerce_map_from_(self, R): sage: Rp. = PolynomialRing(ZZ) sage: Ip = Rp.ideal(x^2 + y^2) sage: Jp = Rp.ideal(x^2 + y^2, x^3 - y) - sage: Sp = Rp.quotient(Ip) # optional - sage.libs.singular - sage: Tp = Rp.quotient(Jp) # optional - sage.libs.singular - sage: R.has_coerce_map_from(Rp) # optional - sage.libs.singular + sage: Sp = Rp.quotient(Ip) + sage: Tp = Rp.quotient(Jp) + sage: R.has_coerce_map_from(Rp) True - sage: Sp.has_coerce_map_from(Sp) # optional - sage.libs.singular + sage: Sp.has_coerce_map_from(Sp) True - sage: T.has_coerce_map_from(Sp) # optional - sage.libs.singular + sage: T.has_coerce_map_from(Sp) # needs sage.libs.singular True - sage: Sp.has_coerce_map_from(T) # optional - sage.libs.singular + sage: Sp.has_coerce_map_from(T) # needs sage.libs.singular False """ C = self.cover_ring() @@ -1134,9 +1160,9 @@ def __richcmp__(self, other, op): equal, but since the generators are different, the corresponding quotient rings are not equal:: - sage: R.ideal(x^2 + y^2) == R.ideal(-x^2 - y^2) # optional - sage.libs.singular + sage: R.ideal(x^2 + y^2) == R.ideal(-x^2 - y^2) # needs sage.libs.singular True - sage: R.quotient_ring(x^2 + y^2) == R.quotient_ring(-x^2 - y^2) # optional - sage.libs.singular + sage: R.quotient_ring(x^2 + y^2) == R.quotient_ring(-x^2 - y^2) False """ if not isinstance(other, QuotientRing_nc): @@ -1165,17 +1191,18 @@ def ngens(self): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ,2) - sage: S. = QuotientRing(R, R.ideal(1 + y^2)) # optional - sage.libs.singular - sage: T. = QuotientRing(S, S.ideal(a)) # optional - sage.libs.singular - sage: T # optional - sage.libs.singular + sage: S. = QuotientRing(R, R.ideal(1 + y^2)) + sage: T. = QuotientRing(S, S.ideal(a)) + sage: T Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x, y^2 + 1) - sage: R.gens(); S.gens(); T.gens() # optional - sage.libs.singular + sage: R.gens(); S.gens(); T.gens() (x, y) (a, b) (0, d) - sage: R.ngens(); S.ngens(); T.ngens() # optional - sage.libs.singular + sage: R.ngens(); S.ngens(); T.ngens() 2 2 2 @@ -1194,19 +1221,20 @@ def gen(self, i=0): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ,2) - sage: S. = QuotientRing(R, R.ideal(1 + y^2)) # optional - sage.libs.singular - sage: T. = QuotientRing(S, S.ideal(a)) # optional - sage.libs.singular - sage: T # optional - sage.libs.singular + sage: S. = QuotientRing(R, R.ideal(1 + y^2)) + sage: T. = QuotientRing(S, S.ideal(a)) + sage: T Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x, y^2 + 1) - sage: R.gen(0); R.gen(1) # optional - sage.libs.singular + sage: R.gen(0); R.gen(1) x y - sage: S.gen(0); S.gen(1) # optional - sage.libs.singular + sage: S.gen(0); S.gen(1) a b - sage: T.gen(0); T.gen(1) # optional - sage.libs.singular + sage: T.gen(0); T.gen(1) 0 d """ @@ -1233,7 +1261,7 @@ def _singular_(self, singular=None): sage: R. = PolynomialRing(QQ) sage: S = R.quotient_ring(x^2 + y^2) - sage: S._singular_() # optional - sage.libs.singular + sage: S._singular_() # needs sage.libs.singular polynomial ring, over a field, global ordering // coefficients: QQ // number of vars : 2 @@ -1267,16 +1295,16 @@ def _singular_init_(self, singular=None): sage: R. = PolynomialRing(QQ) sage: S = R.quotient_ring(x^2 + y^2) - sage: T = S._singular_init_() # optional - sage.libs.singular - sage: parent(S) # optional - sage.libs.singular + sage: T = S._singular_init_() # needs sage.libs.singular + sage: parent(S) - sage: parent(T) # optional - sage.libs.singular + sage: parent(T) # needs sage.libs.singular Singular """ if singular is None: from sage.interfaces.singular import singular self.__R._singular_().set_ring() - self.__singular = singular("%s"%self.__I._singular_().name(),"qring") + self.__singular = singular("%s" % self.__I._singular_().name(),"qring") return self.__singular def _magma_init_(self, magma): @@ -1290,9 +1318,9 @@ def _magma_init_(self, magma): EXAMPLES:: - sage: P. = PolynomialRing(GF(2)) # optional - sage.rings.finite_rings - sage: Q = P.quotient(sage.rings.ideal.FieldIdeal(P)) # optional - sage.rings.finite_rings - sage: magma(Q) # optional - magma # indirect doctest # optional - sage.rings.finite_rings + sage: P. = PolynomialRing(GF(2)) + sage: Q = P.quotient(sage.rings.ideal.FieldIdeal(P)) + sage: magma(Q) # indirect doctest # optional - magma Affine Algebra of rank 2 over GF(2) Graded Reverse Lexicographical Order Variables: x, y @@ -1304,7 +1332,7 @@ def _magma_init_(self, magma): """ R = magma(self.__R) I = magma(self.__I.gens()) - return "quo<%s|%s>"%(R.name(), I._ref()) + return "quo<%s|%s>" % (R.name(), I._ref()) def term_order(self): """ @@ -1376,7 +1404,7 @@ def _macaulay2_init_(self, macaulay2=None): x - y sage: R. = PolynomialRing(ZZ, 4) - sage: I = R.ideal([x*y-z^2, y^2-w^2]) + sage: I = R.ideal([x*y - z^2, y^2 - w^2]) sage: Q = R.quotient(I); Q Quotient of Multivariate Polynomial Ring in x, y, z, w over Integer Ring by the ideal (x*y - z^2, y^2 - w^2) sage: Q._macaulay2_init_() # optional - macaulay2 @@ -1385,12 +1413,12 @@ def _macaulay2_init_(self, macaulay2=None): 2 2 2 (x*y - z , y - w ) - sage: R. = PolynomialRing(GF(101), 2) # optional - sage.rings.finite_rings - sage: I = R.ideal([x^2 + x, y^2 + y]) # optional - sage.rings.finite_rings - sage: Q = R.quotient_ring(I); Q # optional - sage.rings.finite_rings + sage: R. = PolynomialRing(GF(101), 2) + sage: I = R.ideal([x^2 + x, y^2 + y]) + sage: Q = R.quotient_ring(I); Q Quotient of Multivariate Polynomial Ring in x, y over Finite Field of size 101 by the ideal (x^2 + x, y^2 + y) - sage: Q._macaulay2_init_() # optional - macaulay2 # optional - sage.rings.finite_rings + sage: Q._macaulay2_init_() # optional - macaulay2 ZZ ---[x...y] 101 @@ -1463,13 +1491,14 @@ def _contains_(self, other): :: + sage: # needs sage.libs.pari sage: R. = QQ[] - sage: S. = R.quotient(T^3 - 1) # optional - sage.libs.pari - sage: 1 in S.ideal(t^2 - 1) # optional - sage.libs.pari + sage: S. = R.quotient(T^3 - 1) + sage: 1 in S.ideal(t^2 - 1) False - sage: 7 in S.ideal(t^2 + 1) # optional - sage.libs.pari + sage: 7 in S.ideal(t^2 + 1) True - sage: 5-5*t in S.ideal(t^2 - 1) # optional - sage.libs.pari + sage: 5-5*t in S.ideal(t^2 - 1) True """ R = self.ring() diff --git a/src/sage/rings/quotient_ring_element.py b/src/sage/rings/quotient_ring_element.py index 27ceb3ceaf9..f67c7192f11 100644 --- a/src/sage/rings/quotient_ring_element.py +++ b/src/sage/rings/quotient_ring_element.py @@ -61,23 +61,24 @@ class QuotientRingElement(RingElement): sage: S = R.quo(x^2 + y^2); S Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) - sage: S.gens() # optional - sage.libs.singular + sage: S.gens() # needs sage.libs.singular (xbar, ybar) We name each of the generators. :: - sage: S. = R.quotient(x^2 + y^2) # optional - sage.libs.singular - sage: a # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: S. = R.quotient(x^2 + y^2) + sage: a a - sage: b # optional - sage.libs.singular + sage: b b - sage: a^2 + b^2 == 0 # optional - sage.libs.singular + sage: a^2 + b^2 == 0 True - sage: b.lift() # optional - sage.libs.singular + sage: b.lift() y - sage: (a^3 + b^2).lift() # optional - sage.libs.singular + sage: (a^3 + b^2).lift() -x*y^2 + y^2 """ def __init__(self, parent, rep, reduce=True): @@ -109,10 +110,10 @@ def _reduce_(self): TESTS:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: a._reduce_() # optional - sage.libs.singular - sage: a._QuotientRingElement__rep # optional - sage.libs.singular + sage: a._reduce_() # needs sage.libs.singular + sage: a._QuotientRingElement__rep # needs sage.libs.singular x """ I = self.parent().defining_ideal() @@ -125,11 +126,11 @@ def lift(self): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: a.lift() # optional - sage.libs.singular + sage: a.lift() # needs sage.libs.singular x - sage: (3/5*(a + a^2 + b^2)).lift() # optional - sage.libs.singular + sage: (3/5*(a + a^2 + b^2)).lift() # needs sage.libs.singular 3/5*x """ return self.__rep @@ -142,16 +143,16 @@ def __bool__(self): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: bool(a) # indirect doctest # optional - sage.libs.singular + sage: bool(a) # indirect doctest # needs sage.libs.singular True - sage: bool(S(0)) # optional - sage.libs.singular + sage: bool(S(0)) # needs sage.libs.singular False TESTS:: - sage: bool(a - a) # optional - sage.libs.singular + sage: bool(a - a) # needs sage.libs.singular False """ return self.__rep not in self.parent().defining_ideal() @@ -162,18 +163,18 @@ def is_unit(self): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(1 - x*y); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(1 - x*y); type(a) # needs sage.libs.singular - sage: a*b # optional - sage.libs.singular + sage: a*b # needs sage.libs.singular 1 - sage: S(2).is_unit() # optional - sage.libs.singular + sage: S(2).is_unit() # needs sage.libs.singular True Check that :trac:`29469` is fixed:: - sage: a.is_unit() # optional - sage.libs.singular + sage: a.is_unit() # needs sage.libs.singular True - sage: (a+b).is_unit() # optional - sage.libs.singular + sage: (a+b).is_unit() # needs sage.libs.singular False """ if self.__rep.is_unit(): @@ -194,18 +195,19 @@ def _repr_(self): TESTS:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: a-2*a*b # indirect doctest # optional - sage.libs.singular + sage: a-2*a*b # indirect doctest # needs sage.libs.singular -2*a*b + a In :trac:`11068`, the case of quotient rings without assigned names has been covered as well:: - sage: S = SteenrodAlgebra(2) # optional - sage.libs.singular - sage: I = S * [S.0 + S.1] * S # optional - sage.libs.singular - sage: Q = S.quo(I) # optional - sage.libs.singular - sage: Q.0 # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: S = SteenrodAlgebra(2) + sage: I = S * [S.0 + S.1] * S + sage: Q = S.quo(I) + sage: Q.0 Sq(1) """ @@ -235,8 +237,8 @@ def _latex_(self): sage: a = R.gen(0) sage: I = R.ideal(a**2 + a + 1) sage: S = R.quotient(I, names=R.variable_names()) - sage: a = S.gen(0) # optional - sage.libs.singular - sage: latex(a) # optional - sage.libs.singular + sage: a = S.gen(0) # needs sage.libs.singular + sage: latex(a) a """ from sage.structure.parent_gens import localvars @@ -261,8 +263,8 @@ def __pari__(self): sage: R. = QQ[] sage: I = R.ideal(x^3, y^3) - sage: S. = R.quo(I) # optional - sage.libs.singular - sage: pari(xb) # optional - sage.libs.pari sage.libs.singular + sage: S. = R.quo(I) # needs sage.libs.singular + sage: pari(xb) # needs sage.libs.pari sage.libs.singular Traceback (most recent call last): ... ValueError: Pari does not support quotients by non-principal ideals @@ -270,10 +272,10 @@ def __pari__(self): Note that the quotient does work in the case that the ideal is principal:: sage: I = R.ideal(x^3 + y^3) - sage: S. = R.quo(I) # optional - sage.libs.singular - sage: pari(xb)^4 # optional - sage.libs.pari sage.libs.singular + sage: S. = R.quo(I) # needs sage.libs.singular + sage: pari(xb)^4 # needs sage.libs.pari sage.libs.singular Mod(-y^3*x, x^3 + y^3) - sage: pari(yb)^4 # optional - sage.libs.pari sage.libs.singular + sage: pari(yb)^4 # needs sage.libs.pari sage.libs.singular Mod(y^4, x^3 + y^3) """ gens = self.parent().defining_ideal().gens() @@ -289,14 +291,14 @@ def _add_(self, right): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: a + b # optional - sage.libs.singular + sage: a + b # needs sage.libs.singular a + b TESTS:: - sage: a._add_(b) # optional - sage.libs.singular + sage: a._add_(b) # needs sage.libs.singular a + b """ return self.__class__(self.parent(), self.__rep + right.__rep) @@ -309,14 +311,14 @@ def _sub_(self, right): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: a - b # optional - sage.libs.singular + sage: a - b # needs sage.libs.singular a - b TESTS:: - sage: a._sub_(b) # optional - sage.libs.singular + sage: a._sub_(b) # needs sage.libs.singular a - b """ return self.__class__(self.parent(), self.__rep - right.__rep) @@ -329,16 +331,16 @@ def _mul_(self, right): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: a * b # optional - sage.libs.singular + sage: a * b # needs sage.libs.singular a*b TESTS:: - sage: a._mul_(b) # optional - sage.libs.singular + sage: a._mul_(b) # needs sage.libs.singular a*b - sage: a._mul_(a) # optional - sage.libs.singular + sage: a._mul_(a) # needs sage.libs.singular -b^2 """ return self.__class__(self.parent(), self.__rep * right.__rep) @@ -353,30 +355,30 @@ def _div_(self, right): sage: R. = QQ[] sage: I = R.ideal([x^2 + 1, y^3 - 2]) - sage: S. = R.quotient(I) # optional - sage.libs.singular - sage: 1/(1+i) # optional - sage.libs.singular + sage: S. = R.quotient(I) # needs sage.libs.singular + sage: 1/(1+i) # needs sage.libs.singular -1/2*i + 1/2 Confirm via symbolic computation:: - sage: 1/(1+sqrt(-1)) # optional - sage.symbolic + sage: 1/(1+sqrt(-1)) # needs sage.symbolic -1/2*I + 1/2 Another more complicated quotient:: - sage: b = 1/(i+cuberoot); b # optional - sage.libs.singular + sage: b = 1/(i+cuberoot); b # needs sage.libs.singular 1/5*i*cuberoot^2 - 2/5*i*cuberoot + 2/5*cuberoot^2 - 1/5*i + 1/5*cuberoot - 2/5 - sage: b*(i+cuberoot) # optional - sage.libs.singular + sage: b*(i+cuberoot) # needs sage.libs.singular 1 Another really easy example:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: a / S(2) # optional - sage.libs.singular + sage: a / S(2) # needs sage.libs.singular 1/2*a - sage: (a*b)._div_(b) # optional - sage.libs.singular + sage: (a*b)._div_(b) # needs sage.libs.singular a An example in which we try to divide in a ring that is not a @@ -384,18 +386,18 @@ def _div_(self, right): sage: R. = QQ[] sage: I = R.ideal([x^2 - 1, y^3 - 2]) - sage: S. = R.quotient(I) # optional - sage.libs.singular - sage: 1/cuberoot # optional - sage.libs.singular + sage: S. = R.quotient(I) # needs sage.libs.singular + sage: 1/cuberoot # needs sage.libs.singular 1/2*cuberoot^2 - sage: 1/a # optional - sage.libs.singular + sage: 1/a # needs sage.libs.singular a Check that :trac:`13670` is fixed (i.e. that the error message actually describes what happens when the result of division is not defined):: sage: R. = QQ[] - sage: S = R.quotient_ring( R.ideal(x2**2 + x1 - 2, x1**2 - 1) ) # optional - sage.libs.singular - sage: 1 / S(x1 + x2) # optional - sage.libs.singular + sage: S = R.quotient_ring( R.ideal(x2**2 + x1 - 2, x1**2 - 1) ) + sage: 1 / S(x1 + x2) # needs sage.libs.singular Traceback (most recent call last): ... ArithmeticError: Division failed. The numerator is not a multiple of the denominator. @@ -407,7 +409,7 @@ def _div_(self, right): sage: R. = QQ[] sage: S. = R[] - sage: Z. = S.quotient([y^2 - 2, z^2 - 3]) # optional - sage.libs.singular + sage: Z. = S.quotient([y^2 - 2, z^2 - 3]) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: Can only reduce polynomials over fields. @@ -474,16 +476,17 @@ def _im_gens_(self, codomain, im_gens, base_map=None): Ring homomorphisms whose domain is the fraction field of a quotient ring work correctly (see :trac:`16135`):: + sage: # needs sage.libs.singular sage: R. = QQ[] - sage: K = R.quotient(x^2 - y^3).fraction_field() # optional - sage.libs.singular + sage: K = R.quotient(x^2 - y^3).fraction_field() sage: L. = FunctionField(QQ) - sage: f = K.hom((t^3, t^2)) # optional - sage.libs.singular - sage: list(map(f, K.gens())) # optional - sage.libs.singular + sage: f = K.hom((t^3, t^2)) + sage: list(map(f, K.gens())) [t^3, t^2] - sage: xbar, ybar = K.gens() # optional - sage.libs.singular - sage: f(1/ybar) # optional - sage.libs.singular + sage: xbar, ybar = K.gens() + sage: f(1/ybar) 1/t^2 - sage: f(xbar/ybar) # optional - sage.libs.singular + sage: f(xbar/ybar) t """ return self.lift()._im_gens_(codomain, im_gens, base_map=base_map) @@ -496,13 +499,14 @@ def __int__(self): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) - sage: int(S(-3)) # indirect doctest # optional - sage.libs.singular + sage: int(S(-3)) # indirect doctest -3 - sage: type(int(S(-3))) # optional - sage.libs.singular + sage: type(int(S(-3))) <... 'int'> - sage: int(a) # optional - sage.libs.singular + sage: int(a) Traceback (most recent call last): ... TypeError: unable to convert non-constant polynomial x to @@ -513,14 +517,14 @@ def _integer_(self, Z): """ EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: ZZ(S(-3)) # optional - sage.libs.singular + sage: ZZ(S(-3)) # needs sage.libs.singular -3 TESTS:: - sage: type(ZZ(S(-3))) # optional - sage.libs.singular + sage: type(ZZ(S(-3))) # needs sage.libs.singular """ return Z(self.lift()) @@ -529,14 +533,14 @@ def _rational_(self): """ EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: QQ(S(-2/3)) # optional - sage.libs.singular + sage: QQ(S(-2/3)) # needs sage.libs.singular -2/3 TESTS:: - sage: type(S(-2/3)._rational_()) # optional - sage.libs.singular + sage: type(S(-2/3)._rational_()) # needs sage.libs.singular """ from sage.rings.rational_field import QQ @@ -546,11 +550,11 @@ def __neg__(self): """ EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: -a # indirect doctest # optional - sage.libs.singular + sage: -a # indirect doctest # needs sage.libs.singular -a - sage: -(a+b) # optional - sage.libs.singular + sage: -(a+b) # needs sage.libs.singular -a - b """ return self.__class__(self.parent(), -self.__rep) @@ -559,11 +563,11 @@ def __pos__(self): """ TESTS:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: (a+b).__pos__() # optional - sage.libs.singular + sage: (a+b).__pos__() # needs sage.libs.singular a + b - sage: c = a+b; c.__pos__() is c # optional - sage.libs.singular + sage: c = a+b; c.__pos__() is c # needs sage.libs.singular True """ return self @@ -572,19 +576,19 @@ def __invert__(self): """ EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: ~S(2/3) # optional - sage.libs.singular + sage: ~S(2/3) # needs sage.libs.singular 3/2 TESTS:: - sage: S(2/3).__invert__() # optional - sage.libs.singular + sage: S(2/3).__invert__() # needs sage.libs.singular 3/2 Note that a is not invertible as an element of R:: - sage: a.__invert__() # optional - sage.libs.singular + sage: a.__invert__() # needs sage.libs.singular Traceback (most recent call last): ... ArithmeticError: element is non-invertible @@ -599,11 +603,11 @@ def __float__(self): """ EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: float(S(2/3)) # optional - sage.libs.singular + sage: float(S(2/3)) # needs sage.libs.singular 0.6666666666666666 - sage: float(a) # optional - sage.libs.singular + sage: float(a) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: unable to convert non-constant polynomial x to @@ -614,10 +618,11 @@ def __hash__(self): r""" TESTS:: - sage: R. = QQ[] # optional - sage.libs.singular - sage: S. = R.quo(x^2 + y^2) # optional - sage.libs.singular - sage: c = a*a + b # optional - sage.libs.singular - sage: hash(a) != hash(b) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: R. = QQ[] + sage: S. = R.quo(x^2 + y^2) + sage: c = a*a + b + sage: hash(a) != hash(b) True """ return hash(self.__rep) @@ -626,38 +631,41 @@ def _richcmp_(self, other, op): """ EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) - sage: a > b # indirect doctest # optional - sage.libs.singular + sage: a > b # indirect doctest True - sage: b > a # optional - sage.libs.singular + sage: b > a False - sage: a == loads(dumps(a)) # optional - sage.libs.singular + sage: a == loads(dumps(a)) True TESTS:: - sage: a == (a+1-1) # optional - sage.libs.singular + sage: a == (a+1-1) # needs sage.libs.singular True - sage: a > b # optional - sage.libs.singular + sage: a > b # needs sage.libs.singular True See :trac:`7797`:: - sage: F. = FreeAlgebra(QQ, implementation='letterplace') # optional - sage.combinat - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F # optional - sage.combinat - sage: Q = F.quo(I) # optional - sage.combinat sage.libs.singular - sage: Q.0^4 # indirect doctest # optional - sage.combinat sage.libs.singular + sage: # needs sage.combinat sage.libs.singular sage.modules + sage: F. = FreeAlgebra(QQ, implementation='letterplace') + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F + sage: Q = F.quo(I) + sage: Q.0^4 # indirect doctest ybar*zbar*zbar*xbar + ybar*zbar*zbar*ybar + ybar*zbar*zbar*zbar The issue from :trac:`8005` was most likely fixed as part of :trac:`9138`:: - sage: F = GF(5) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: I = Ideal(R, [x, y]) # optional - sage.rings.finite_rings - sage: S. = QuotientRing(R, I) # optional - sage.rings.finite_rings - sage: x1^4 # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: F = GF(5) + sage: R. = F[] + sage: I = Ideal(R, [x, y]) + sage: S. = QuotientRing(R, I) + sage: x1^4 0 """ # A containment test is not implemented for univariate polynomial @@ -680,18 +688,19 @@ def lt(self): EXAMPLES:: - sage: R. = PolynomialRing(GF(7), 3, order='lex') # optional - sage.rings.finite_rings - sage: I = sage.rings.ideal.FieldIdeal(R) # optional - sage.rings.finite_rings - sage: Q = R.quo(I) # optional - sage.rings.finite_rings - sage: f = Q(z*y + 2*x) # optional - sage.rings.finite_rings - sage: f.lt() # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: R. = PolynomialRing(GF(7), 3, order='lex') + sage: I = sage.rings.ideal.FieldIdeal(R) + sage: Q = R.quo(I) + sage: f = Q(z*y + 2*x) + sage: f.lt() 2*xbar TESTS:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: (a + 3*a*b + b).lt() # optional - sage.libs.singular + sage: (a + 3*a*b + b).lt() # needs sage.libs.singular 3*a*b """ return self.__class__(self.parent(), self.__rep.lt()) @@ -702,18 +711,19 @@ def lm(self): EXAMPLES:: - sage: R. = PolynomialRing(GF(7), 3, order='lex') # optional - sage.rings.finite_rings - sage: I = sage.rings.ideal.FieldIdeal(R) # optional - sage.rings.finite_rings - sage: Q = R.quo(I) # optional - sage.rings.finite_rings - sage: f = Q(z*y + 2*x) # optional - sage.rings.finite_rings - sage: f.lm() # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: R. = PolynomialRing(GF(7), 3, order='lex') + sage: I = sage.rings.ideal.FieldIdeal(R) + sage: Q = R.quo(I) + sage: f = Q(z*y + 2*x) + sage: f.lm() xbar TESTS:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: (a+3*a*b+b).lm() # optional - sage.libs.singular + sage: (a+3*a*b+b).lm() # needs sage.libs.singular a*b """ @@ -725,18 +735,19 @@ def lc(self): EXAMPLES:: - sage: R. = PolynomialRing(GF(7), 3, order='lex') # optional - sage.rings.finite_rings - sage: I = sage.rings.ideal.FieldIdeal(R) # optional - sage.rings.finite_rings - sage: Q = R.quo(I) # optional - sage.rings.finite_rings - sage: f = Q(z*y + 2*x) # optional - sage.rings.finite_rings - sage: f.lc() # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: R. = PolynomialRing(GF(7), 3, order='lex') + sage: I = sage.rings.ideal.FieldIdeal(R) + sage: Q = R.quo(I) + sage: f = Q(z*y + 2*x) + sage: f.lc() 2 TESTS:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # needs sage.libs.singular - sage: (a + 3*a*b + b).lc() # optional - sage.libs.singular + sage: (a + 3*a*b + b).lc() # needs sage.libs.singular 3 """ return self.__rep.lc() @@ -752,17 +763,18 @@ def variables(self): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) - sage: a.variables() # optional - sage.libs.singular + sage: a.variables() (a,) - sage: b.variables() # optional - sage.libs.singular + sage: b.variables() (b,) - sage: s = a^2 + b^2 + 1; s # optional - sage.libs.singular + sage: s = a^2 + b^2 + 1; s 1 - sage: s.variables() # optional - sage.libs.singular + sage: s.variables() () - sage: (a + b).variables() # optional - sage.libs.singular + sage: (a + b).variables() (a, b) """ return tuple(self.__class__(self.parent(), v) for v in self.__rep.variables()) @@ -777,13 +789,14 @@ def monomials(self): EXAMPLES:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) - sage: a.monomials() # optional - sage.libs.singular + sage: a.monomials() [a] - sage: (a + a*b).monomials() # optional - sage.libs.singular + sage: (a + a*b).monomials() [a*b, a] - sage: R.zero().monomials() # optional - sage.libs.singular + sage: R.zero().monomials() [] """ return [self.__class__(self.parent(), m) for m in self.__rep.monomials()] @@ -799,10 +812,11 @@ def _singular_(self, singular=singular_default): EXAMPLES:: - sage: P. = PolynomialRing(GF(2), 2) # optional - sage.rings.finite_rings - sage: I = sage.rings.ideal.FieldIdeal(P) # optional - sage.rings.finite_rings - sage: Q = P.quo(I) # optional - sage.rings.finite_rings - sage: Q._singular_() # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: P. = PolynomialRing(GF(2), 2) + sage: I = sage.rings.ideal.FieldIdeal(P) + sage: Q = P.quo(I) + sage: Q._singular_() polynomial ring, over a field, global ordering // coefficients: ZZ/2 // number of vars : 2 @@ -812,20 +826,21 @@ def _singular_(self, singular=singular_default): // quotient ring from ideal _[1]=x2+x _[2]=y2+y - sage: xbar = Q(x); xbar # optional - sage.rings.finite_rings + sage: xbar = Q(x); xbar xbar - sage: xbar._singular_() # optional - sage.rings.finite_rings + sage: xbar._singular_() x - sage: Q(xbar._singular_()) # a round-trip # optional - sage.rings.finite_rings + sage: Q(xbar._singular_()) # a round-trip xbar TESTS:: - sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) # optional - sage.libs.singular + sage: # needs sage.libs.singular + sage: R. = QQ[]; S. = R.quo(x^2 + y^2); type(a) - sage: (a - 2/3*b)._singular_() # optional - sage.libs.singular + sage: (a - 2/3*b)._singular_() x-2/3*y - sage: S((a - 2/3*b)._singular_()) # optional - sage.libs.singular + sage: S((a - 2/3*b)._singular_()) a - 2/3*b """ if singular is None: @@ -838,12 +853,13 @@ def _magma_init_(self, magma): EXAMPLES:: - sage: P. = PolynomialRing(GF(2)) # optional - sage.rings.finite_rings - sage: Q = P.quotient(sage.rings.ideal.FieldIdeal(P)) # optional - sage.rings.finite_rings - sage: xbar, ybar = Q.gens() # optional - sage.rings.finite_rings - sage: magma(xbar) # optional - magma # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: P. = PolynomialRing(GF(2)) + sage: Q = P.quotient(sage.rings.ideal.FieldIdeal(P)) + sage: xbar, ybar = Q.gens() + sage: magma(xbar) # optional - magma x - sage: xbar._magma_init_(magma) # optional - magma # optional - sage.rings.finite_rings + sage: xbar._magma_init_(magma) # optional - magma '_sage_[...]!_sage_ref...' """ g = magma(self.__rep) @@ -856,19 +872,20 @@ def _macaulay2_(self, macaulay2=None): EXAMPLES:: - sage: R. = PolynomialRing(GF(7), 2) # optional - sage.rings.finite_rings - sage: Q = R.quotient([x^2 - y]) # optional - sage.rings.finite_rings - sage: x, y = Q.gens() # optional - sage.rings.finite_rings - sage: f = (x^3 + 2*y^2*x)^7; f # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: R. = PolynomialRing(GF(7), 2) + sage: Q = R.quotient([x^2 - y]) + sage: x, y = Q.gens() + sage: f = (x^3 + 2*y^2*x)^7; f 2*xbar*ybar^17 + xbar*ybar^10 - sage: mf = macaulay2(f); mf # optional - macaulay2 # optional - sage.rings.finite_rings + sage: mf = macaulay2(f); mf # optional - macaulay2 17 10 2x*y + x*y - sage: mf.sage() # optional - macaulay2 # optional - sage.rings.finite_rings + sage: mf.sage() # optional - macaulay2 2*x*y^17 + x*y^10 - sage: mf.sage() == f # optional - macaulay2 # optional - sage.rings.finite_rings + sage: mf.sage() == f # optional - macaulay2 True - sage: Q(mf) # optional - macaulay2 # optional - sage.rings.finite_rings + sage: Q(mf) # optional - macaulay2 2*xbar*ybar^17 + xbar*ybar^10 In Macaulay2, the variable names for a quotient ring are inherited from @@ -880,15 +897,16 @@ def _macaulay2_(self, macaulay2=None): :: - sage: R. = PolynomialRing(GF(7), 2) # optional - sage.rings.finite_rings - sage: Q = R.quotient([x^2 - y], names=R.gens()) # optional - sage.rings.finite_rings - sage: x, y = Q.gens() # optional - sage.rings.finite_rings - sage: f = (x^3 + 2*y^2*x)^7; f # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: R. = PolynomialRing(GF(7), 2) + sage: Q = R.quotient([x^2 - y], names=R.gens()) + sage: x, y = Q.gens() + sage: f = (x^3 + 2*y^2*x)^7; f 2*x*y^17 + x*y^10 - sage: macaulay2(f) # optional - macaulay2 # optional - sage.rings.finite_rings + sage: macaulay2(f) # optional - macaulay2 17 10 2x*y + x*y - sage: _.sage() # optional - macaulay2 # optional - sage.rings.finite_rings + sage: _.sage() # optional - macaulay2 2*x*y^17 + x*y^10 TESTS: @@ -896,15 +914,16 @@ def _macaulay2_(self, macaulay2=None): Check that changing the currently defined global variables (`x`, `y`, ...) in Macaulay2 does not affect the result of this conversion:: - sage: R. = PolynomialRing(GF(7), 2) # optional - sage.rings.finite_rings - sage: Q = R.quotient([x^2 - y], names=R.gens()) # optional - sage.rings.finite_rings - sage: x, y = Q.gens() # optional - sage.rings.finite_rings - sage: f = (x^3 + 2*y^2*x)^7 # optional - sage.rings.finite_rings - sage: macaulay2(f) # optional - macaulay2 # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: R. = PolynomialRing(GF(7), 2) + sage: Q = R.quotient([x^2 - y], names=R.gens()) + sage: x, y = Q.gens() + sage: f = (x^3 + 2*y^2*x)^7 + sage: macaulay2(f) # optional - macaulay2 17 10 2x*y + x*y - sage: macaulay2.use(R.quotient([x, y])) # optional - macaulay2 # optional - sage.rings.finite_rings - sage: macaulay2(f) # optional - macaulay2 # optional - sage.rings.finite_rings + sage: macaulay2.use(R.quotient([x, y])) # optional - macaulay2 + sage: macaulay2(f) # optional - macaulay2 17 10 2x*y + x*y """ @@ -933,18 +952,19 @@ def reduce(self, G): EXAMPLES:: - sage: P. = PolynomialRing(GF(2), 5, order='lex') # optional - sage.rings.finite_rings - sage: I1 = ideal([a*b + c*d + 1, a*c*e + d*e, # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: P. = PolynomialRing(GF(2), 5, order='lex') + sage: I1 = ideal([a*b + c*d + 1, a*c*e + d*e, ....: a*b*e + c*e, b*c + c*d*e + 1]) - sage: Q = P.quotient(sage.rings.ideal.FieldIdeal(P)) # optional - sage.rings.finite_rings - sage: I2 = ideal([Q(f) for f in I1.gens()]) # optional - sage.rings.finite_rings - sage: f = Q((a*b + c*d + 1)^2 + e) # optional - sage.rings.finite_rings - sage: f.reduce(I2.gens()) # optional - sage.rings.finite_rings + sage: Q = P.quotient(sage.rings.ideal.FieldIdeal(P)) + sage: I2 = ideal([Q(f) for f in I1.gens()]) + sage: f = Q((a*b + c*d + 1)^2 + e) + sage: f.reduce(I2.gens()) ebar Notice that the result above is not minimal:: - sage: I2.reduce(f) # optional - sage.rings.finite_rings + sage: I2.reduce(f) # needs sage.libs.singular 0 """ try: diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 313ace10d98..f8843a2cee7 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -293,30 +293,32 @@ cpdef rational_power_parts(a, Rational b, factor_limit=10**5): sage: rational_power_parts(3/4, -1/2) (2, 3) - sage: t = (3/4)^(-1/2); t # optional - sage.symbolic + sage: t = (3/4)^(-1/2); t # needs sage.symbolic 2/3*sqrt(3) - sage: t^2 # optional - sage.symbolic + sage: t^2 # needs sage.symbolic 4/3 Check if :trac:`15605` is fixed:: sage: rational_power_parts(-1, -1/3) (1, -1) - sage: (-1)^(-1/3) # optional - sage.symbolic - -(-1)^(2/3) - sage: 1 / ((-1)^(1/3)) # optional - sage.symbolic - -(-1)^(2/3) sage: rational_power_parts(-1, 2/3) (1, -1) - sage: (-1)^(2/3) # optional - sage.symbolic - (-1)^(2/3) sage: all(rational_power_parts(-1, i/77) == (1,-1) for i in range(1,9)) True - sage: (-1)^(1/3)*(-1)^(1/5) # optional - sage.symbolic + + sage: # needs sage.symbolic + sage: (-1)^(-1/3) + -(-1)^(2/3) + sage: 1 / ((-1)^(1/3)) + -(-1)^(2/3) + sage: (-1)^(2/3) + (-1)^(2/3) + sage: (-1)^(1/3)*(-1)^(1/5) (-1)^(8/15) - sage: bool((-1)^(2/3) == -1/2 + sqrt(3)/2*I) # optional - sage.symbolic + sage: bool((-1)^(2/3) == -1/2 + sqrt(3)/2*I) True - sage: all((-1)^(p/q) == cos(p*pi/q) + I * sin(p*pi/q) # optional - sage.symbolic + sage: all((-1)^(p/q) == cos(p*pi/q) + I * sin(p*pi/q) ....: for p in srange(1, 6) for q in srange(1, 6)) True @@ -416,9 +418,9 @@ cdef class Rational(sage.structure.element.FieldElement): 1/2 sage: Rational(("2", "10"), 16) 1/8 - sage: Rational(QQbar(125/8).nth_root(3)) # optional - sage.rings.number_field + sage: Rational(QQbar(125/8).nth_root(3)) # needs sage.rings.number_field 5/2 - sage: Rational(AA(209735/343 - 17910/49*golden_ratio).nth_root(3) # optional - sage.rings.number_field + sage: Rational(AA(209735/343 - 17910/49*golden_ratio).nth_root(3) # needs sage.rings.number_field sage.symbolic ....: + 3*AA(golden_ratio)) 53/7 sage: QQ(float(1.5)) @@ -435,24 +437,25 @@ cdef class Rational(sage.structure.element.FieldElement): Conversion from PARI:: - sage: Rational(pari('-939082/3992923')) # optional - sage.libs.pari + sage: Rational(pari('-939082/3992923')) # needs sage.libs.pari -939082/3992923 - sage: Rational(pari('Pol([-1/2])')) #9595 # optional - sage.libs.pari + sage: Rational(pari('Pol([-1/2])')) #9595 # needs sage.libs.pari -1/2 Conversions from numpy:: - sage: import numpy as np # optional - numpy - sage: QQ(np.int8('-15')) # optional - numpy + sage: # needs numpy + sage: import numpy as np + sage: QQ(np.int8('-15')) -15 - sage: QQ(np.int16('-32')) # optional - numpy + sage: QQ(np.int16('-32')) -32 - sage: QQ(np.int32('-19')) # optional - numpy + sage: QQ(np.int32('-19')) -19 - sage: QQ(np.uint32('1412')) # optional - numpy + sage: QQ(np.uint32('1412')) 1412 - sage: QQ(np.float16('12')) # optional - numpy + sage: QQ(np.float16('12')) # needs numpy 12 Conversions from gmpy2:: @@ -507,7 +510,7 @@ cdef class Rational(sage.structure.element.FieldElement): 7 sage: a.__init__('70', base=8); a 56 - sage: a.__init__(pari('2/3')); a # optional - sage.libs.pari + sage: a.__init__(pari('2/3')); a # needs sage.libs.pari 2/3 sage: a.__init__('-h/3ki', 32); a -17/3730 @@ -718,7 +721,7 @@ cdef class Rational(sage.structure.element.FieldElement): sage: 1 + 1/(2 + 1/(3 + 1/(4 + 1/5))) 225/157 - sage: (fibonacci(20)/fibonacci(19)).continued_fraction_list() + sage: (fibonacci(20)/fibonacci(19)).continued_fraction_list() # needs sage.libs.pari [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2] sage: (-1/3).continued_fraction_list() @@ -805,9 +808,9 @@ cdef class Rational(sage.structure.element.FieldElement): sage: a = (355/113).continued_fraction(); a [3; 7, 16] - sage: a.n(digits=10) + sage: a.n(digits=10) # needs sage.rings.real_mpfr 3.141592920 - sage: pi.n(digits=10) + sage: pi.n(digits=10) # needs sage.rings.real_mpfr sage.symbolic 3.141592654 It's almost pi! @@ -958,9 +961,9 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: - sage: ex = SR(QQ(7)/3); ex # optional - sage.symbolic + sage: ex = SR(QQ(7)/3); ex # needs sage.symbolic 7/3 - sage: parent(ex) # optional - sage.symbolic + sage: parent(ex) # needs sage.symbolic Symbolic Ring """ return sring._force_pyobject(self, force=True) @@ -971,12 +974,13 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: - sage: n = 1/2; n._sympy_() # optional - sympy + sage: # needs sympy + sage: n = 1/2; n._sympy_() 1/2 - sage: n = -1/5; n._sympy_() # optional - sympy + sage: n = -1/5; n._sympy_() -1/5 - sage: from sympy import Symbol # optional - sympy - sage: QQ(1) + Symbol('x')*QQ(2) # optional - sympy + sage: from sympy import Symbol + sage: QQ(1) + Symbol('x')*QQ(2) 2*x + 1 """ import sympy @@ -1044,16 +1048,15 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: - sage: import numpy # optional - numpy - sage: numpy.array([1, 2, 3/1]) # optional - numpy + sage: # needs numpy + sage: import numpy + sage: numpy.array([1, 2, 3/1]) array([1, 2, 3]) - - sage: numpy.array(QQ(2**40)).dtype # optional - numpy + sage: numpy.array(QQ(2**40)).dtype dtype('int64') - sage: numpy.array(QQ(2**400)).dtype # optional - numpy + sage: numpy.array(QQ(2**400)).dtype dtype('O') - - sage: numpy.array([1, 1/2, 3/4]) # optional - numpy + sage: numpy.array([1, 1/2, 3/4]) array([1. , 0.5 , 0.75]) """ if mpz_cmp_ui(mpq_denref(self.value), 1) == 0: @@ -1196,11 +1199,11 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: sage: a = QQ(25/6) - sage: a.local_height(2) + sage: a.local_height(2) # needs sage.rings.real_mpfr 0.693147180559945 - sage: a.local_height(3) + sage: a.local_height(3) # needs sage.rings.real_mpfr 1.09861228866811 - sage: a.local_height(5) + sage: a.local_height(5) # needs sage.rings.real_mpfr 0.000000000000000 """ from sage.rings.real_mpfr import RealField @@ -1234,11 +1237,11 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: sage: a = QQ(6/25) - sage: a.local_height_arch() + sage: a.local_height_arch() # needs sage.rings.real_mpfr 0.000000000000000 - sage: (1/a).local_height_arch() + sage: (1/a).local_height_arch() # needs sage.rings.real_mpfr 1.42711635564015 - sage: (1/a).local_height_arch(100) + sage: (1/a).local_height_arch(100) # needs sage.rings.real_mpfr 1.4271163556401457483890413081 """ from sage.rings.real_mpfr import RealField @@ -1277,11 +1280,11 @@ cdef class Rational(sage.structure.element.FieldElement): sage: a = QQ(5/6) sage: a.support() [2, 3, 5] - sage: a.global_height_non_arch() + sage: a.global_height_non_arch() # needs sage.rings.real_mpfr 1.79175946922805 - sage: [a.local_height(p) for p in a.support()] + sage: [a.local_height(p) for p in a.support()] # needs sage.rings.real_mpfr [0.693147180559945, 1.09861228866811, 0.000000000000000] - sage: sum([a.local_height(p) for p in a.support()]) + sage: sum([a.local_height(p) for p in a.support()]) # needs sage.rings.real_mpfr 1.79175946922805 """ from sage.rings.real_mpfr import RealField @@ -1318,11 +1321,11 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: sage: a = QQ(6/25) - sage: a.global_height_arch() + sage: a.global_height_arch() # needs sage.rings.real_mpfr 0.000000000000000 - sage: (1/a).global_height_arch() + sage: (1/a).global_height_arch() # needs sage.rings.real_mpfr 1.42711635564015 - sage: (1/a).global_height_arch(100) + sage: (1/a).global_height_arch(100) # needs sage.rings.real_mpfr 1.4271163556401457483890413081 """ return self.local_height_arch(prec) @@ -1349,6 +1352,7 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: a = QQ(6/25) sage: a.global_height_arch() + a.global_height_non_arch() 3.21887582486820 @@ -1417,44 +1421,45 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ, 'x') - sage: K = NumberField(x^2 - 2, 'beta') # optional - sage.rings.number_field - sage: (1/7).is_norm(K) # optional - sage.rings.number_field + sage: K = NumberField(x^2 - 2, 'beta') + sage: (1/7).is_norm(K) True - sage: (1/10).is_norm(K) # optional - sage.rings.number_field + sage: (1/10).is_norm(K) False - sage: 0.is_norm(K) # optional - sage.rings.number_field + sage: 0.is_norm(K) True - sage: (1/7).is_norm(K, element=True) # optional - sage.rings.number_field + sage: (1/7).is_norm(K, element=True) (True, 1/7*beta + 3/7) - sage: (1/10).is_norm(K, element=True) # optional - sage.rings.number_field + sage: (1/10).is_norm(K, element=True) (False, None) - sage: (1/691).is_norm(QQ, element=True) # optional - sage.rings.number_field + sage: (1/691).is_norm(QQ, element=True) (True, 1/691) The number field doesn't have to be defined by an integral polynomial:: - sage: B, e = (1/5).is_norm(QuadraticField(5/4, 'a'), element=True) # optional - sage.rings.number_field - sage: B # optional - sage.rings.number_field + sage: B, e = (1/5).is_norm(QuadraticField(5/4, 'a'), element=True) # needs sage.rings.number_field + sage: B # needs sage.rings.number_field True - sage: e.norm() # optional - sage.rings.number_field + sage: e.norm() # needs sage.rings.number_field 1/5 A non-Galois number field:: - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: B, e = (3/5).is_norm(K, element=True); B # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: B, e = (3/5).is_norm(K, element=True); B True - sage: e.norm() # optional - sage.rings.number_field + sage: e.norm() 3/5 - - sage: 7.is_norm(K) # optional - sage.rings.number_field + sage: 7.is_norm(K) Traceback (most recent call last): ... NotImplementedError: is_norm is not implemented unconditionally for norms from non-Galois number fields - sage: 7.is_norm(K, proof=False) # optional - sage.rings.number_field + sage: 7.is_norm(K, proof=False) False AUTHORS: @@ -1537,10 +1542,10 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: - sage: QQ(2)._bnfisnorm(QuadraticField(-1, 'i')) # optional - sage.rings.number_field + sage: QQ(2)._bnfisnorm(QuadraticField(-1, 'i')) # needs sage.rings.number_field (i + 1, 1) sage: x = polygen(QQ, 'x') - sage: 7._bnfisnorm(NumberField(x^3 - 2, 'b')) # optional - sage.rings.number_field + sage: 7._bnfisnorm(NumberField(x^3 - 2, 'b')) # needs sage.rings.number_field (1, 7) AUTHORS: @@ -1899,17 +1904,19 @@ cdef class Rational(sage.structure.element.FieldElement): sage: x.sqrt(all=True) [10, -10] sage: x = 81/5 - sage: x.sqrt() # optional - sage.symbolic + sage: x.sqrt() # needs sage.symbolic 9*sqrt(1/5) sage: x = -81/3 - sage: x.sqrt() # optional - sage.symbolic + sage: x.sqrt() # needs sage.symbolic 3*sqrt(-3) :: sage: n = 2/3 - sage: n.sqrt() # optional - sage.symbolic + sage: n.sqrt() # needs sage.symbolic sqrt(2/3) + + sage: # needs sage.rings.real_mpfr sage: n.sqrt(prec=10) 0.82 sage: n.sqrt(prec=100) @@ -1918,16 +1925,17 @@ cdef class Rational(sage.structure.element.FieldElement): 0.66666666666666666666666666667 sage: n.sqrt(prec=53, all=True) [0.816496580927726, -0.816496580927726] + sage: sqrt(-2/3, prec=53) + 0.816496580927726*I + sage: sqrt(-2/3, prec=53, all=True) + [0.816496580927726*I, -0.816496580927726*I] + sage: n.sqrt(extend=False, all=True) Traceback (most recent call last): ... ValueError: square root of 2/3 not a rational number - sage: sqrt(-2/3, all=True) # optional - sage.symbolic + sage: sqrt(-2/3, all=True) # needs sage.symbolic [sqrt(-2/3), -sqrt(-2/3)] - sage: sqrt(-2/3, prec=53) - 0.816496580927726*I - sage: sqrt(-2/3, prec=53, all=True) - [0.816496580927726*I, -0.816496580927726*I] AUTHORS: @@ -1988,22 +1996,22 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: - sage: (1/7).period() # optional - sage.libs.pari + sage: (1/7).period() # needs sage.libs.pari 6 - sage: RR(1/7) + sage: RR(1/7) # needs sage.rings.real_mpfr 0.142857142857143 - sage: (1/8).period() # optional - sage.libs.pari + sage: (1/8).period() # needs sage.libs.pari 1 - sage: RR(1/8) + sage: RR(1/8) # needs sage.rings.real_mpfr 0.125000000000000 - sage: RR(1/6) + sage: RR(1/6) # needs sage.rings.real_mpfr 0.166666666666667 - sage: (1/6).period() # optional - sage.libs.pari + sage: (1/6).period() # needs sage.libs.pari 1 sage: x = 333/106 - sage: x.period() # optional - sage.libs.pari + sage: x.period() # needs sage.libs.pari 13 - sage: RealField(200)(x) + sage: RealField(200)(x) # needs sage.rings.real_mpfr 3.1415094339622641509433962264150943396226415094339622641509 """ cdef unsigned int alpha, beta @@ -2198,22 +2206,22 @@ cdef class Rational(sage.structure.element.FieldElement): Test that the conversion has correct rounding on simple rationals:: - sage: for p in [-100..100]: + sage: for p in [-100..100]: # needs sage.rings.real_mpfr ....: for q in [1..100]: ....: r = RDF(p/q) ....: assert (RR(r).exact_rational() - p/q) <= r.ulp()/2 Test larger rationals:: - sage: Q = continued_fraction(pi).convergents()[:100] + sage: Q = continued_fraction(pi).convergents()[:100] # needs sage.symbolic sage: all(RDF(q) == RR(q) for q in Q) True At some point, the continued fraction and direct conversion to ``RDF`` should agree:: - sage: RDFpi = RDF(pi) - sage: all(RDF(q) == RDFpi for q in Q[20:]) + sage: RDFpi = RDF(pi) # needs sage.symbolic + sage: all(RDF(q) == RDFpi for q in Q[20:]) # needs sage.symbolic True """ return mpq_get_d_nearest(self.value) @@ -2513,9 +2521,9 @@ cdef class Rational(sage.structure.element.FieldElement): sage: (2/3)^5 32/243 - sage: (-1/1)^(1/3) # optional - sage.symbolic + sage: (-1/1)^(1/3) # needs sage.symbolic (-1)^(1/3) - sage: (2/3)^(3/4) # optional - sage.symbolic + sage: (2/3)^(3/4) # needs sage.symbolic (2/3)^(3/4) sage: (-1/3)^0 1 @@ -2530,18 +2538,18 @@ cdef class Rational(sage.structure.element.FieldElement): 2/3 sage: parent(a) Rational Field - sage: (-27/125)^(1/3) # optional - sage.symbolic + sage: (-27/125)^(1/3) # needs sage.symbolic 3/5*(-1)^(1/3) - sage: (-27/125)^(1/2) # optional - sage.symbolic + sage: (-27/125)^(1/2) # needs sage.symbolic 3/5*sqrt(-3/5) The result is normalized to have the rational power in the numerator:: - sage: 2^(-1/2) # optional - sage.symbolic + sage: 2^(-1/2) # needs sage.symbolic 1/2*sqrt(2) - sage: 8^(-1/5) # optional - sage.symbolic + sage: 8^(-1/5) # needs sage.symbolic 1/8*8^(4/5) - sage: 3^(-3/2) # optional - sage.symbolic + sage: 3^(-3/2) # needs sage.symbolic 1/9*sqrt(3) TESTS:: @@ -2553,7 +2561,7 @@ cdef class Rational(sage.structure.element.FieldElement): This works even if the base is a Python integer:: - sage: int(2)^(1/2) # optional - sage.symbolic + sage: int(2)^(1/2) # needs sage.symbolic sqrt(2) sage: a = int(2)^(3/1); a 8 @@ -2572,7 +2580,7 @@ cdef class Rational(sage.structure.element.FieldElement): ... OverflowError: exponent must be at most 2147483647 # 32-bit OverflowError: exponent must be at most 9223372036854775807 # 64-bit - sage: QQ(-1)^(2^100) # optional - sage.symbolic + sage: QQ(-1)^(2^100) # needs sage.symbolic 1 """ n = other @@ -3119,15 +3127,15 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: - sage: (124/345).log(5) # optional - sage.symbolic + sage: (124/345).log(5) # needs sage.symbolic log(124/345)/log(5) - sage: (124/345).log(5, 100) + sage: (124/345).log(5, 100) # needs sage.rings.real_mpfr -0.63578895682825611710391773754 - sage: log(QQ(125)) # optional - sage.symbolic + sage: log(QQ(125)) # needs sage.symbolic 3*log(5) sage: log(QQ(125), 5) 3 - sage: log(QQ(125), 3) # optional - sage.symbolic + sage: log(QQ(125), 3) # needs sage.symbolic 3*log(5)/log(3) sage: QQ(8).log(1/2) -3 @@ -3137,24 +3145,24 @@ cdef class Rational(sage.structure.element.FieldElement): 1/3 sage: (1/2).log(8) -1/3 - sage: (16/81).log(8/27) + sage: (16/81).log(8/27) # needs sage.libs.pari 4/3 - sage: (8/27).log(16/81) + sage: (8/27).log(16/81) # needs sage.libs.pari 3/4 - sage: log(27/8, 16/81) + sage: log(27/8, 16/81) # needs sage.libs.pari -3/4 - sage: log(16/81, 27/8) + sage: log(16/81, 27/8) # needs sage.libs.pari -4/3 - sage: (125/8).log(5/2) + sage: (125/8).log(5/2) # needs sage.libs.pari 3 - sage: (125/8).log(5/2, prec=53) + sage: (125/8).log(5/2, prec=53) # needs sage.rings.real_mpfr 3.00000000000000 TESTS:: - sage: (25/2).log(5/2) # optional - sage.symbolic + sage: (25/2).log(5/2) # needs sage.symbolic log(25/2)/log(5/2) - sage: (-1/2).log(3) # optional - sage.symbolic + sage: (-1/2).log(3) # needs sage.symbolic (I*pi + log(1/2))/log(3) """ cdef int self_sgn @@ -3223,22 +3231,23 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: - sage: gamma(1/2) # optional - sage.symbolic + sage: # needs sage.symbolic + sage: gamma(1/2) sqrt(pi) - sage: gamma(7/2) # optional - sage.symbolic + sage: gamma(7/2) 15/8*sqrt(pi) - sage: gamma(-3/2) # optional - sage.symbolic + sage: gamma(-3/2) 4/3*sqrt(pi) - sage: gamma(6/1) # optional - sage.symbolic + sage: gamma(6/1) 120 - sage: gamma(1/3) # optional - sage.symbolic + sage: gamma(1/3) gamma(1/3) This function accepts an optional precision argument:: - sage: (1/3).gamma(prec=100) + sage: (1/3).gamma(prec=100) # needs sage.rings.real_mpfr 2.6789385347077476336556929410 - sage: (1/2).gamma(prec=100) + sage: (1/2).gamma(prec=100) # needs sage.rings.real_mpfr 1.7724538509055160272981674833 TESTS: @@ -3774,11 +3783,11 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: sage: n = 9390823/17 - sage: m = n.__pari__(); m # optional - sage.libs.pari + sage: m = n.__pari__(); m # needs sage.libs.pari 9390823/17 - sage: type(m) # optional - sage.libs.pari + sage: type(m) # needs sage.libs.pari - sage: m.type() # optional - sage.libs.pari + sage: m.type() # needs sage.libs.pari 't_FRAC' """ global new_gen_from_rational diff --git a/src/sage/rings/rational_field.py b/src/sage/rings/rational_field.py index 642f95dc232..104c5463bf5 100644 --- a/src/sage/rings/rational_field.py +++ b/src/sage/rings/rational_field.py @@ -16,17 +16,17 @@ :: - sage: RealField(9).pi() + sage: RealField(9).pi() # needs sage.rings.real_mpfr 3.1 - sage: QQ(RealField(9).pi()) + sage: QQ(RealField(9).pi()) # needs sage.rings.real_mpfr 22/7 - sage: QQ(RealField().pi()) + sage: QQ(RealField().pi()) # needs sage.rings.real_mpfr 245850922/78256779 sage: QQ(35) 35 sage: QQ('12/347') 12/347 - sage: QQ(exp(pi*I)) + sage: QQ(exp(pi*I)) # needs sage.symbolic -1 sage: x = polygen(ZZ) sage: QQ((3*x)/(4*x)) @@ -86,7 +86,7 @@ class RationalField(Singleton, number_field_base.NumberField): -930482/9320842317 sage: QQ([9320842317]) 9320842317 - sage: QQ(pari(39029384023840928309482842098430284398243982394)) # optional - sage.libs.pari + sage: QQ(pari(39029384023840928309482842098430284398243982394)) # needs sage.libs.pari 39029384023840928309482842098430284398243982394 sage: QQ('sage') Traceback (most recent call last): @@ -102,7 +102,7 @@ class RationalField(Singleton, number_field_base.NumberField): 3929329/32 sage: QQ(-RR(3929329/32)) -3929329/32 - sage: QQ(RR(1/7)) - 1/7 + sage: QQ(RR(1/7)) - 1/7 # needs sage.rings.real_mpfr 0 If you specify the optional second argument ``base``, then the string @@ -110,6 +110,7 @@ class RationalField(Singleton, number_field_base.NumberField): :: + sage: # needs sage.rings.real_mpfr sage: QQ(23.2, 2) 6530219459687219/281474976710656 sage: 6530219459687219.0/281474976710656 @@ -121,6 +122,7 @@ class RationalField(Singleton, number_field_base.NumberField): Here's a nice example involving elliptic curves:: + sage: # needs sage.rings.real_mpfr sage.schemes sage: E = EllipticCurve('11a') sage: L = E.lseries().at1(300)[0]; L 0.2538418608559106843377589233... @@ -324,9 +326,9 @@ def completion(self, p, prec, extras={}): EXAMPLES:: - sage: QQ.completion(infinity, 53) + sage: QQ.completion(infinity, 53) # needs sage.rings.real_mpfr Real Field with 53 bits of precision - sage: QQ.completion(5, 15, {'print_mode': 'bars'}) + sage: QQ.completion(5, 15, {'print_mode': 'bars'}) # needs sage.rings.padics 5-adic Field with capped relative precision 15 """ from sage.rings.infinity import Infinity @@ -441,7 +443,7 @@ def __truediv__(self, I): EXAMPLES:: - sage: QQ / ZZ # optional - sage.groups + sage: QQ / ZZ # needs sage.modules Q/Z """ from sage.rings.ideal import Ideal_generic @@ -526,9 +528,9 @@ def primes_of_bounded_norm_iter(self, B): EXAMPLES:: sage: it = QQ.primes_of_bounded_norm_iter(10) - sage: list(it) # optional - sage.libs.pari + sage: list(it) # needs sage.libs.pari [2, 3, 5, 7] - sage: list(QQ.primes_of_bounded_norm_iter(1)) # optional - sage.libs.pari + sage: list(QQ.primes_of_bounded_norm_iter(1)) [] """ try: @@ -606,14 +608,14 @@ def embeddings(self, K): sage: QQ.embeddings(QQ) [Identity endomorphism of Rational Field] - sage: QQ.embeddings(CyclotomicField(5)) # optional - sage.rings.number_field + sage: QQ.embeddings(CyclotomicField(5)) # needs sage.rings.number_field [Coercion map: From: Rational Field To: Cyclotomic Field of order 5 and degree 4] `K` must have characteristic 0:: - sage: QQ.embeddings(GF(3)) # optional - sage.rings.finite_rings + sage: QQ.embeddings(GF(3)) Traceback (most recent call last): ... ValueError: no embeddings of the rational field into K. @@ -657,7 +659,7 @@ def places(self, all_complex=False, prec=None): EXAMPLES:: - sage: QQ.places() + sage: QQ.places() # needs sage.rings.real_mpfr [Ring morphism: From: Rational Field To: Real Field with 53 bits of precision @@ -667,7 +669,7 @@ def places(self, all_complex=False, prec=None): From: Rational Field To: Real Double Field Defn: 1 |--> 1.0] - sage: QQ.places(prec=200, all_complex=True) + sage: QQ.places(prec=200, all_complex=True) # needs sage.rings.real_mpfr [Ring morphism: From: Rational Field To: Complex Field with 200 bits of precision @@ -675,19 +677,27 @@ def places(self, all_complex=False, prec=None): """ from sage.rings.infinity import Infinity if prec is None: - from sage.rings.real_mpfr import RR as R - from sage.rings.cc import CC as C + if all_complex: + from sage.rings.cc import CC as domain + else: + from sage.rings.real_mpfr import RR as domain elif prec == 53: - from sage.rings.real_double import RDF as R - from sage.rings.complex_double import CDF as C + if all_complex: + from sage.rings.complex_double import CDF as domain + else: + from sage.rings.real_double import RDF as domain elif prec == Infinity: - from sage.rings.qqbar import AA as R, QQbar as C + if all_complex: + from sage.rings.qqbar import QQbar as domain + else: + from sage.rings.qqbar import AA as domain else: - from sage.rings.real_mpfr import RealField - from sage.rings.complex_mpfr import ComplexField - R = RealField(prec) - C = ComplexField(prec) - domain = C if all_complex else R + if all_complex: + from sage.rings.complex_mpfr import ComplexField + domain = ComplexField(prec) + else: + from sage.rings.real_mpfr import RealField + domain = RealField(prec) return [self.hom([domain(1)])] def complex_embedding(self, prec=53): @@ -696,12 +706,12 @@ def complex_embedding(self, prec=53): EXAMPLES:: - sage: QQ.complex_embedding() + sage: QQ.complex_embedding() # needs sage.rings.real_mpfr Ring morphism: From: Rational Field To: Complex Field with 53 bits of precision Defn: 1 |--> 1.00000000000000 - sage: QQ.complex_embedding(20) + sage: QQ.complex_embedding(20) # needs sage.rings.real_mpfr Ring morphism: From: Rational Field To: Complex Field with 20 bits of precision @@ -718,9 +728,9 @@ def residue_field(self, p, check=True): INPUT: - - ``p`` - a prime integer. + - ``p`` -- a prime integer. - - ``check`` (default ``True``) - if ``True``, check the primality of + - ``check`` (default ``True``) -- if ``True``, check the primality of `p`, else do not. OUTPUT: The residue field at this prime. @@ -729,7 +739,7 @@ def residue_field(self, p, check=True): sage: QQ.residue_field(5) Residue field of Integers modulo 5 - sage: QQ.residue_field(next_prime(10^9)) + sage: QQ.residue_field(next_prime(10^9)) # needs sage.rings.finite_rings Residue field of Integers modulo 1000000007 """ from sage.rings.finite_rings.residue_field import ResidueField @@ -760,37 +770,37 @@ def hilbert_symbol_negative_at_S(self, S, b, check=True): EXAMPLES:: - sage: QQ.hilbert_symbol_negative_at_S([-1,5,3,2,7,11,13,23], -10/7) # optional - sage.rings.padics + sage: QQ.hilbert_symbol_negative_at_S([-1,5,3,2,7,11,13,23], -10/7) # needs sage.rings.padics -9867 - sage: QQ.hilbert_symbol_negative_at_S([3, 5, QQ.places()[0], 11], -15) # optional - sage.rings.padics + sage: QQ.hilbert_symbol_negative_at_S([3, 5, QQ.places()[0], 11], -15) # needs sage.rings.padics -33 - sage: QQ.hilbert_symbol_negative_at_S([3, 5], 2) # optional - sage.rings.padics + sage: QQ.hilbert_symbol_negative_at_S([3, 5], 2) # needs sage.rings.padics 15 TESTS:: - sage: QQ.hilbert_symbol_negative_at_S(5/2, -2) # optional - sage.libs.pari sage.modules + sage: QQ.hilbert_symbol_negative_at_S(5/2, -2) # needs sage.modules Traceback (most recent call last): ... TypeError: first argument must be a list or integer :: - sage: QQ.hilbert_symbol_negative_at_S([1, 3], 0) # optional - sage.libs.pari sage.modules + sage: QQ.hilbert_symbol_negative_at_S([1, 3], 0) # needs sage.modules Traceback (most recent call last): ... ValueError: second argument must be nonzero :: - sage: QQ.hilbert_symbol_negative_at_S([-1, 3, 5], 2) # optional - sage.libs.pari sage.modules + sage: QQ.hilbert_symbol_negative_at_S([-1, 3, 5], 2) # needs sage.modules Traceback (most recent call last): ... ValueError: list should be of even cardinality :: - sage: QQ.hilbert_symbol_negative_at_S([1, 3], 2) # optional - sage.libs.pari sage.modules + sage: QQ.hilbert_symbol_negative_at_S([1, 3], 2) # needs sage.modules Traceback (most recent call last): ... ValueError: all entries in list must be prime or -1 for @@ -798,7 +808,7 @@ def hilbert_symbol_negative_at_S(self, S, b, check=True): :: - sage: QQ.hilbert_symbol_negative_at_S([5, 7], 2) # optional - sage.libs.pari sage.modules + sage: QQ.hilbert_symbol_negative_at_S([5, 7], 2) # needs sage.libs.pari sage.modules Traceback (most recent call last): ... ValueError: second argument must be a nonsquare with @@ -806,14 +816,14 @@ def hilbert_symbol_negative_at_S(self, S, b, check=True): :: - sage: QQ.hilbert_symbol_negative_at_S([1, 3], sqrt(2)) # optional - sage.libs.pari sage.modules + sage: QQ.hilbert_symbol_negative_at_S([1, 3], sqrt(2)) # needs sage.libs.pari sage.modules sage.symbolic Traceback (most recent call last): ... TypeError: second argument must be a rational number :: - sage: QQ.hilbert_symbol_negative_at_S([-1, 3], 2) # optional - sage.libs.pari sage.modules + sage: QQ.hilbert_symbol_negative_at_S([-1, 3], 2) # needs sage.modules Traceback (most recent call last): ... ValueError: if the infinite place is in the list, the second @@ -1054,16 +1064,16 @@ def extension(self, poly, names, **kwds): We make a single absolute extension:: sage: x = polygen(QQ, 'x') - sage: K. = QQ.extension(x^3 + 5); K # optional - sage.rings.number_field + sage: K. = QQ.extension(x^3 + 5); K # needs sage.rings.number_field Number Field in a with defining polynomial x^3 + 5 We make an extension generated by roots of two polynomials:: - sage: K. = QQ.extension([x^3 + 5, x^2 + 3]); K # optional - sage.rings.number_field + sage: K. = QQ.extension([x^3 + 5, x^2 + 3]); K # needs sage.rings.number_field Number Field in a with defining polynomial x^3 + 5 over its base field - sage: b^2 # optional - sage.rings.number_field + sage: b^2 # needs sage.rings.number_field -3 - sage: a^3 # optional - sage.rings.number_field + sage: a^3 # needs sage.rings.number_field -5 """ from sage.rings.number_field.number_field import NumberField @@ -1075,7 +1085,7 @@ def algebraic_closure(self): EXAMPLES:: - sage: QQ.algebraic_closure() # optional - sage.rings.number_field + sage: QQ.algebraic_closure() # needs sage.rings.number_field Algebraic Field """ from sage.rings.qqbar import QQbar @@ -1408,43 +1418,44 @@ def selmer_space(self, S, p, proof=None): When `S` is empty, `\QQ(S,p)` is only nontrivial for `p=2`:: - sage: QS2, QS2gens, fromQS2, toQS2 = QQ.selmer_space([], 2) # optional - sage.rings.number_field - sage: QS2 # optional - sage.rings.number_field + sage: QS2, QS2gens, fromQS2, toQS2 = QQ.selmer_space([], 2) # needs sage.rings.number_field + sage: QS2 # needs sage.rings.number_field Vector space of dimension 1 over Finite Field of size 2 - sage: QS2gens # optional - sage.rings.number_field + sage: QS2gens # needs sage.rings.number_field [-1] - sage: all(QQ.selmer_space([], p)[0].dimension() == 0 # optional - sage.libs.pari + sage: all(QQ.selmer_space([], p)[0].dimension() == 0 # needs sage.libs.pari ....: for p in primes(3, 10)) True In general there is one generator for each `p\in S`, and an additional generator of `-1` when `p=2`:: - sage: QS2, QS2gens, fromQS2, toQS2 = QQ.selmer_space([5,7], 2) # optional - sage.modules - sage: QS2 # optional - sage.modules + sage: # needs sage.modules sage.rings.number_field + sage: QS2, QS2gens, fromQS2, toQS2 = QQ.selmer_space([5,7], 2) + sage: QS2 Vector space of dimension 3 over Finite Field of size 2 - sage: QS2gens # optional - sage.modules + sage: QS2gens [5, 7, -1] - sage: toQS2(-7) # optional - sage.modules + sage: toQS2(-7) (0, 1, 1) - sage: fromQS2((0,1,1)) # optional - sage.modules + sage: fromQS2((0,1,1)) -7 The map ``fromQS2`` is only well-defined modulo `p`'th powers (in this case, modulo squares):: - sage: toQS2(-5/7) # optional - sage.modules + sage: toQS2(-5/7) # needs sage.modules sage.rings.number_field (1, 1, 1) - sage: fromQS2((1,1,1)) # optional - sage.modules + sage: fromQS2((1,1,1)) # needs sage.modules sage.rings.number_field -35 - sage: ((-5/7)/(-35)).is_square() # optional - sage.modules + sage: ((-5/7)/(-35)).is_square() True The map ``toQS2`` is not defined on all of `\QQ^*`, only on those numbers which are squares away from `5` and `7`:: - sage: toQS2(210) # optional - sage.modules + sage: toQS2(210) # needs sage.modules sage.rings.number_field Traceback (most recent call last): ... ValueError: argument 210 should have valuations divisible by 2 @@ -1514,7 +1525,7 @@ def _gap_init_(self): EXAMPLES:: - sage: gap(QQ) # indirect doctest # optional - sage.libs.gap + sage: gap(QQ) # indirect doctest # needs sage.libs.gap Rationals """ return 'Rationals' @@ -1582,7 +1593,7 @@ def _sympy_(self): EXAMPLES:: - sage: QQ._sympy_() # optional - sympy + sage: QQ._sympy_() # needs sympy Rationals """ from sympy import Rationals @@ -1627,21 +1638,22 @@ def _factor_univariate_polynomial(self, f): TESTS:: + sage: # needs sage.libs.pari sage: R. = QQ[] - sage: QQ._factor_univariate_polynomial(x) # optional - sage.libs.pari + sage: QQ._factor_univariate_polynomial(x) x - sage: QQ._factor_univariate_polynomial(2*x) # optional - sage.libs.pari + sage: QQ._factor_univariate_polynomial(2*x) (2) * x - sage: QQ._factor_univariate_polynomial((x^2 - 1/4)^4) # optional - sage.libs.pari + sage: QQ._factor_univariate_polynomial((x^2 - 1/4)^4) (x - 1/2)^4 * (x + 1/2)^4 - sage: QQ._factor_univariate_polynomial((2*x + 1) * (3*x^2 - 5)^2) # optional - sage.libs.pari + sage: QQ._factor_univariate_polynomial((2*x + 1) * (3*x^2 - 5)^2) (18) * (x + 1/2) * (x^2 - 5/3)^2 - sage: f = prod((k^2*x^k + k)^(k-1) for k in primes(10)) # optional - sage.libs.pari - sage: QQ._factor_univariate_polynomial(f) # optional - sage.libs.pari + sage: f = prod((k^2*x^k + k)^(k-1) for k in primes(10)) + sage: QQ._factor_univariate_polynomial(f) (1751787911376562500) * (x^2 + 1/2) * (x^3 + 1/3)^2 * (x^5 + 1/5)^4 * (x^7 + 1/7)^6 - sage: QQ._factor_univariate_polynomial(10*x^5 - 1) # optional - sage.libs.pari + sage: QQ._factor_univariate_polynomial(10*x^5 - 1) (10) * (x^5 - 1/10) - sage: QQ._factor_univariate_polynomial(10*x^5 - 10) # optional - sage.libs.pari + sage: QQ._factor_univariate_polynomial(10*x^5 - 10) (10) * (x - 1) * (x^4 + x^3 + x^2 + x + 1) """ @@ -1659,9 +1671,9 @@ def valuation(self, p): EXAMPLES:: - sage: v = QQ.valuation(3); v # optional - sage.rings.padics + sage: v = QQ.valuation(3); v # needs sage.rings.padics 3-adic valuation - sage: v(1/3) # optional - sage.rings.padics + sage: v(1/3) # needs sage.rings.padics -1 .. SEEALSO:: diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx index 9eec35e882e..17859068273 100644 --- a/src/sage/rings/real_arb.pyx +++ b/src/sage/rings/real_arb.pyx @@ -28,9 +28,9 @@ Sage :class:`RealBall` objects wrap Arb objects of type ``arb_t``. A real ball represents a ball over the real numbers, that is, an interval `[m-r,m+r]` where the midpoint `m` and the radius `r` are (extended) real numbers:: - sage: RBF(pi) + sage: RBF(pi) # needs sage.symbolic [3.141592653589793 +/- ...e-16] - sage: RBF(pi).mid(), RBF(pi).rad() + sage: RBF(pi).mid(), RBF(pi).rad() # needs sage.symbolic (3.14159265358979, ...e-16) The midpoint is represented as an arbitrary-precision floating-point number @@ -147,7 +147,7 @@ Comparisons with Sage symbolic infinities work with some limitations:: True sage: RBF(infinity) < infinity False - sage: RBF(NaN) < infinity + sage: RBF(NaN) < infinity # needs sage.symbolic Traceback (most recent call last): ... ValueError: infinite but not with +/- phase @@ -159,14 +159,14 @@ Comparisons with Sage symbolic infinities work with some limitations:: Comparisons between elements of real ball fields, however, support special values and should be preferred:: - sage: RBF(NaN) < RBF(infinity) + sage: RBF(NaN) < RBF(infinity) # needs sage.symbolic False sage: RBF(0).add_error(infinity) <= RBF(infinity) True TESTS:: - sage: (RBF(pi) * identity_matrix(QQ, 3)).parent() + sage: (RBF(pi) * identity_matrix(QQ, 3)).parent() # needs sage.symbolic Full MatrixSpace of 3 by 3 dense matrices over Real ball field with 53 bits of precision @@ -175,11 +175,11 @@ TESTS:: :: - sage: SR.coerce(RBF(0.42)) # optional - sage.symbolic + sage: SR.coerce(RBF(0.42)) # needs sage.symbolic [0.4200000000000000 +/- ...e-17] - sage: RBF(0.42) + SR(1) # optional - sage.symbolic + sage: RBF(0.42) + SR(1) # needs sage.symbolic [1.420000000000000 +/- ...e-16] - sage: _.parent() # optional - sage.symbolic + sage: _.parent() # needs sage.symbolic Symbolic Ring Classes and Methods @@ -200,7 +200,7 @@ Classes and Methods from cysignals.signals cimport sig_on, sig_str, sig_off from cpython.float cimport PyFloat_AS_DOUBLE -from cpython.int cimport PyInt_AS_LONG +from cpython.long cimport PyLong_AsLong from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from libc.stdlib cimport abort @@ -338,7 +338,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): :: - sage: (1/2*RBF(1)) + AA(sqrt(2)) - 1 + polygen(QQ, 'x') # optional - sage.symbolic + sage: (1/2*RBF(1)) + AA(sqrt(2)) - 1 + polygen(QQ, 'x') # needs sage.symbolic x + [0.914213562373095 +/- ...e-16] TESTS:: @@ -362,9 +362,9 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): sage: RBF.zero() 0 - sage: NF. = QuadraticField(2, embedding=AA(2).sqrt()) - sage: a = (sqrt2 - 1)^1000 - sage: RBF(a) + sage: NF. = QuadraticField(2, embedding=AA(2).sqrt()) # needs sage.rings.number_field + sage: a = (sqrt2 - 1)^1000 # needs sage.rings.number_field + sage: RBF(a) # needs sage.rings.number_field [1.676156872756536e-383 +/- ...e-399] sage: RealBallField().is_finite() @@ -456,7 +456,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): False sage: RealBallField().has_coerce_map_from(RIF) False - sage: RealBallField().has_coerce_map_from(SR) # optional - sage.symbolic + sage: RealBallField().has_coerce_map_from(SR) # needs sage.symbolic False sage: RealBallField().has_coerce_map_from(RR) False @@ -509,34 +509,34 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): [+/- 1.01] sage: RBF(1) 1.000000000000000 - sage: RBF(x) + sage: RBF(x) # needs sage.symbolic Traceback (most recent call last): ... TypeError: unable to convert x to a RealBall Various symbolic constants are supported:: - sage: RBF(e) + sage: RBF(e) # needs sage.symbolic [2.718281828459045 +/- ...e-16] - sage: RBF(pi) + sage: RBF(pi) # needs sage.symbolic [3.141592653589793 +/- ...e-16] Symbolic expressions are parsed :: - sage: RBF(4*zeta(3)) + sage: RBF(4*zeta(3)) # needs sage.symbolic [4.8082276126383...] - sage: RBF(exp(1), 0.01) + sage: RBF(exp(1), 0.01) # needs sage.symbolic [2.7 +/- ...] TESTS: The following conversions used to yield incorrect results:: - sage: RBF(airy_ai(1)) + sage: RBF(airy_ai(1)) # needs sage.symbolic [0.135292416312881...] - sage: v = RBF(zetaderiv(1, 3/2)); v + sage: v = RBF(zetaderiv(1, 3/2)); v # needs sage.symbolic [-3.932239737431101 +/- 5.58e-16] - sage: v.overlaps(RealBallField(100)(3/2).zetaderiv(1)) + sage: v.overlaps(RealBallField(100)(3/2).zetaderiv(1)) # needs sage.symbolic True """ @@ -816,7 +816,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): TESTS:: - sage: RBF.sinpi(RLF(sqrt(2))) + sage: RBF.sinpi(RLF(sqrt(2))) # needs sage.symbolic [-0.963902532849877 +/- ...e-16] """ cdef RealBall res, x_as_ball @@ -860,7 +860,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): TESTS:: - sage: RBF.cospi(RLF(sqrt(2))) + sage: RBF.cospi(RLF(sqrt(2))) # needs sage.symbolic [-0.26625534204142 +/- ...e-15] """ cdef RealBall res, x_as_ball @@ -908,7 +908,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField): TESTS:: - sage: RBF.gamma(RLF(pi)) # abs tol 1e-13 + sage: RBF.gamma(RLF(pi)) # abs tol 1e-13 # needs sage.symbolic [2.28803779534003 +/- 4.12e-15] """ cdef RealBall res @@ -1258,7 +1258,7 @@ cdef class RealBall(RingElement): sage: RBF(3, 0.125) [3e+0 +/- 0.126] - sage: RBF(pi, 0.125r) + sage: RBF(pi, 0.125r) # needs sage.symbolic [3e+0 +/- 0.267] sage: RBF(3, 1/8) [3e+0 +/- 0.126] @@ -1267,8 +1267,8 @@ cdef class RealBall(RingElement): :: - sage: NF. = QuadraticField(2) - sage: RBF(1/5 + sqrt2/2) + sage: NF. = QuadraticField(2) # needs sage.rings.number_field + sage: RBF(1/5 + sqrt2/2) # needs sage.rings.number_field [0.907106781186547 +/- ...e-16] Note that integers and floating-point numbers are ''not'' rounded to @@ -1385,7 +1385,7 @@ cdef class RealBall(RingElement): elif isinstance(mid, RealBall): arb_set(self.value, ( mid).value) # no rounding! elif is_small_python_int(mid): - arb_set_si(self.value, PyInt_AS_LONG(mid)) # no rounding! + arb_set_si(self.value, PyLong_AsLong(mid)) # no rounding! elif isinstance(mid, Integer): if _do_sig(prec(self)): sig_on() fmpz_init(tmpz) @@ -1535,9 +1535,11 @@ cdef class RealBall(RingElement): TESTS:: - sage: [loads(dumps(b)).identical(b) for b in - ....: [RealBallField(60).pi(), RBF(infinity), RBF(NaN)]] - [True, True, True] + sage: [loads(dumps(b)).identical(b) + ....: for b in [RealBallField(60).pi(), RBF(infinity)]] + [True, True] + sage: b = RBF(NaN); loads(dumps(b)).identical(b) # needs sage.symbolic + True """ cdef bytes py_val sig_on() @@ -1582,7 +1584,7 @@ cdef class RealBall(RingElement): Traceback (most recent call last): ... ValueError: [+/- 2.01] does not contain a unique integer - sage: ZZ(RBF(pi)) + sage: ZZ(RBF(pi)) # needs sage.symbolic Traceback (most recent call last): ... ValueError: [3.141592653589793 +/- ...e-16] does not contain a unique integer @@ -1629,6 +1631,7 @@ cdef class RealBall(RingElement): EXAMPLES:: + sage: # needs sage.symbolic sage: mypi = RBF(pi) sage: RR(mypi) 3.14159265358979 @@ -2069,13 +2072,13 @@ cdef class RealBall(RingElement): their parent's nominal precision (see :mod:`~sage.rings.real_arb` for more information):: - sage: b = RBF(pi.n(100)) - sage: b.mid() + sage: b = RBF(pi.n(100)) # needs sage.symbolic + sage: b.mid() # needs sage.symbolic 3.141592653589793238462643383 The ``round()`` method rounds such a ball to its parent's precision:: - sage: b.round().mid() + sage: b.round().mid() # needs sage.symbolic 3.14159265358979 .. SEEALSO:: :meth:`trim` @@ -2097,11 +2100,11 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: RBF(pi).accuracy() + sage: RBF(pi).accuracy() # needs sage.symbolic 52 sage: RBF(1).accuracy() == RBF.maximal_accuracy() True - sage: RBF(NaN).accuracy() == -RBF.maximal_accuracy() + sage: RBF(NaN).accuracy() == -RBF.maximal_accuracy() # needs sage.symbolic True .. SEEALSO:: :meth:`~RealBallField.maximal_accuracy` @@ -2204,7 +2207,7 @@ cdef class RealBall(RingElement): EXAMPLES:: sage: RBF = RealBallField() - sage: RBF(pi).is_nonzero() + sage: RBF(pi).is_nonzero() # needs sage.symbolic True sage: RBF(RIF(-0.5, 0.5)).is_nonzero() False @@ -2563,9 +2566,9 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: RBF(pi).overlaps(RBF(pi) + 2**(-100)) + sage: RBF(pi).overlaps(RBF(pi) + 2**(-100)) # needs sage.symbolic True - sage: RBF(pi).overlaps(RBF(3)) + sage: RBF(pi).overlaps(RBF(3)) # needs sage.symbolic False """ return arb_overlaps(self.value, other.value) @@ -2599,7 +2602,7 @@ cdef class RealBall(RingElement): sage: RBF(1/3).contains_exact(1/3) True - sage: RBF(sqrt(2)).contains_exact(sqrt(2)) + sage: RBF(sqrt(2)).contains_exact(sqrt(2)) # needs sage.symbolic Traceback (most recent call last): ... TypeError: unsupported type: @@ -2617,7 +2620,7 @@ cdef class RealBall(RingElement): if isinstance(other, RealBall): res = arb_contains(self.value, ( other).value) elif is_small_python_int(other): - res = arb_contains_si(self.value, PyInt_AS_LONG(other)) + res = arb_contains_si(self.value, PyLong_AsLong(other)) elif isinstance(other, Integer): fmpz_init(tmpz) fmpz_set_mpz(tmpz, ( other).value) @@ -2645,12 +2648,12 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: sqrt(2) in RBF(sqrt(2)) + sage: sqrt(2) in RBF(sqrt(2)) # needs sage.symbolic True A false negative:: - sage: sqrt(2) in RBF(RealBallField(100)(sqrt(2))) + sage: sqrt(2) in RBF(RealBallField(100)(sqrt(2))) # needs sage.symbolic False .. SEEALSO:: :meth:`contains_exact` @@ -2730,7 +2733,7 @@ cdef class RealBall(RingElement): True sage: RBF(-infinity).is_infinity() True - sage: RBF(NaN).is_infinity() + sage: RBF(NaN).is_infinity() # needs sage.symbolic True sage: (~RBF(0)).is_infinity() True @@ -2745,7 +2748,7 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: RBF(NaN).is_NaN() + sage: RBF(NaN).is_NaN() # needs sage.symbolic True sage: RBF(-5).gamma().is_NaN() True @@ -2860,7 +2863,7 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: RBF(pi)/RBF(e) + sage: RBF(pi)/RBF(e) # needs sage.symbolic [1.155727349790922 +/- ...e-16] sage: RBF(2)/RBF(0) nan @@ -2875,6 +2878,7 @@ cdef class RealBall(RingElement): """ EXAMPLES:: + sage: # needs sage.symbolic sage: RBF(e)^17 [24154952.7535753 +/- ...e-8] sage: RBF(e)^(-1) @@ -2890,14 +2894,14 @@ cdef class RealBall(RingElement): nan sage: RBF(0)^(-1) nan - sage: RBF(-e)**RBF(pi) + sage: RBF(-e)**RBF(pi) # needs sage.symbolic nan TESTS:: - sage: RBF(e)**(2r) + sage: RBF(e)**(2r) # needs sage.symbolic [7.38905609893065 +/- ...e-15] - sage: RBF(e)**(-1r) + sage: RBF(e)**(-1r) # needs sage.symbolic [0.367879441171442 +/- ...e-16] """ cdef fmpz_t tmpz @@ -2907,7 +2911,7 @@ cdef class RealBall(RingElement): cdef RealBall res = self._new() if is_small_python_int(expo) and expo > 0: if _do_sig(prec(self)): sig_on() - arb_pow_ui(res.value, self.value, PyInt_AS_LONG(expo), prec(self)) + arb_pow_ui(res.value, self.value, PyLong_AsLong(expo), prec(self)) if _do_sig(prec(self)): sig_off() elif isinstance(expo, Integer): if _do_sig(prec(self)): sig_on() @@ -3074,7 +3078,7 @@ cdef class RealBall(RingElement): cdef RealBall self = val cdef RealBall res = self._new() if is_small_python_int(shift): - arb_mul_2exp_si(res.value, self.value, PyInt_AS_LONG(shift)) + arb_mul_2exp_si(res.value, self.value, PyLong_AsLong(shift)) elif isinstance(shift, Integer): sig_on() fmpz_init(tmpz) @@ -3216,7 +3220,7 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: RBF(pi).sin() + sage: RBF(pi).sin() # needs sage.symbolic [+/- ...e-16] .. SEEALSO:: :meth:`~sage.rings.real_arb.RealBallField.sinpi` @@ -3233,7 +3237,7 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: RBF(pi).cos() + sage: RBF(pi).cos() # needs sage.symbolic [-1.00000000000000 +/- ...e-16] .. SEEALSO:: :meth:`~sage.rings.real_arb.RealBallField.cospi` @@ -3252,7 +3256,7 @@ cdef class RealBall(RingElement): sage: RBF(1).tan() [1.557407724654902 +/- ...e-16] - sage: RBF(pi/2).tan() + sage: RBF(pi/2).tan() # needs sage.symbolic nan """ cdef RealBall res = self._new() @@ -3269,7 +3273,7 @@ cdef class RealBall(RingElement): sage: RBF(1).cot() [0.642092615934331 +/- ...e-16] - sage: RBF(pi).cot() + sage: RBF(pi).cot() # needs sage.symbolic nan """ cdef RealBall res = self._new() @@ -3547,7 +3551,7 @@ cdef class RealBall(RingElement): TESTS:: - sage: RBF(Ei(1)) # abs tol 5e-16 + sage: RBF(Ei(1)) # abs tol 5e-16 # needs sage.symbolic [1.89511781635594 +/- 4.94e-15] """ cdef RealBall res = self._new() @@ -3567,7 +3571,7 @@ cdef class RealBall(RingElement): TESTS:: - sage: RBF(Si(1)) # abs tol 1e-15 + sage: RBF(Si(1)) # abs tol 1e-15 # needs sage.symbolic [0.946083070367183 +/- 9.22e-16] """ cdef RealBall res = self._new() @@ -3589,7 +3593,7 @@ cdef class RealBall(RingElement): TESTS:: - sage: RBF(Ci(1)) # abs tol 5e-16 + sage: RBF(Ci(1)) # abs tol 5e-16 # needs sage.symbolic [0.337403922900968 +/- 3.25e-16] """ cdef RealBall res = self._new() @@ -3611,7 +3615,7 @@ cdef class RealBall(RingElement): TESTS:: - sage: RBF(Shi(1)) + sage: RBF(Shi(1)) # needs sage.symbolic [1.05725087537573 +/- 2.77e-15] """ cdef RealBall res = self._new() @@ -3633,7 +3637,7 @@ cdef class RealBall(RingElement): TESTS:: - sage: RBF(Chi(1)) # abs tol 1e-17 + sage: RBF(Chi(1)) # abs tol 1e-17 # needs sage.symbolic [0.837866940980208 +/- 4.72e-16] """ cdef RealBall res = self._new() @@ -3655,9 +3659,9 @@ cdef class RealBall(RingElement): TESTS:: - sage: RBF(li(0)) + sage: RBF(li(0)) # needs sage.symbolic 0 - sage: RBF(Li(0)) + sage: RBF(Li(0)) # needs sage.symbolic [-1.04516378011749 +/- 4.23e-15] """ cdef RealBall res = self._new() @@ -3701,7 +3705,7 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: RBF(sin(3)).beta(RBF(2/3).sqrt()) # abs tol 1e-13 + sage: RBF(sin(3)).beta(RBF(2/3).sqrt()) # abs tol 1e-13 # needs sage.symbolic [7.407661629415 +/- 1.07e-13] sage: RealBallField(100)(7/2).beta(1) # abs tol 1e-30 [0.28571428571428571428571428571 +/- 5.23e-30] @@ -3936,11 +3940,11 @@ cdef class RealBall(RingElement): EXAMPLES:: - sage: polylog(0, -1) + sage: polylog(0, -1) # needs sage.symbolic -1/2 sage: RBF(-1).polylog(0) [-0.50000000000000 +/- ...e-16] - sage: polylog(1, 1/2) + sage: polylog(1, 1/2) # needs sage.symbolic -log(1/2) sage: RBF(1/2).polylog(1) [0.69314718055995 +/- ...e-15] @@ -3979,6 +3983,7 @@ cdef class RealBall(RingElement): EXAMPLES:: + sage: # needs sage.symbolic sage: RBF(pi).chebyshev_T(0) 1.000000000000000 sage: RBF(pi).chebyshev_T(1) @@ -4011,6 +4016,7 @@ cdef class RealBall(RingElement): EXAMPLES:: + sage: # needs sage.symbolic sage: RBF(pi).chebyshev_U(0) 1.000000000000000 sage: RBF(pi).chebyshev_U(1) @@ -4044,7 +4050,7 @@ cdef class RealBall(RingElement): sage: RBF(1).agm(1) 1.000000000000000 - sage: RBF(sqrt(2)).agm(1)^(-1) + sage: RBF(sqrt(2)).agm(1)^(-1) # needs sage.symbolic [0.8346268416740...] """ cdef RealBall other_as_ball diff --git a/src/sage/rings/real_double.pyx b/src/sage/rings/real_double.pyx index ec4af251254..bfa020f14b8 100644 --- a/src/sage/rings/real_double.pyx +++ b/src/sage/rings/real_double.pyx @@ -5,21 +5,21 @@ EXAMPLES: We create the real double vector space of dimension `3`:: - sage: V = RDF^3; V # optional - sage.modules + sage: V = RDF^3; V # needs sage.modules Vector space of dimension 3 over Real Double Field Notice that this space is unique:: - sage: V is RDF^3 # optional - sage.modules + sage: V is RDF^3 # needs sage.modules True - sage: V is FreeModule(RDF, 3) # optional - sage.modules + sage: V is FreeModule(RDF, 3) # needs sage.modules True - sage: V is VectorSpace(RDF, 3) # optional - sage.modules + sage: V is VectorSpace(RDF, 3) # needs sage.modules True Also, you can instantly create a space of large dimension:: - sage: V = RDF^10000 # optional - sage.modules + sage: V = RDF^10000 # needs sage.modules TESTS: @@ -27,8 +27,8 @@ Test NumPy conversions:: sage: RDF(1).__array_interface__ {'typestr': '=f8'} - sage: import numpy # optional - numpy - sage: numpy.array([RDF.pi()]).dtype # optional - numpy + sage: import numpy # needs numpy + sage: numpy.array([RDF.pi()]).dtype # needs numpy dtype('float64') """ @@ -84,7 +84,7 @@ def is_RealDoubleField(x): use isinstance(..., sage.rings.abc.RealDoubleField) instead See https://github.com/sagemath/sage/issues/32610 for details. True - sage: is_RealDoubleField(RealField(53)) + sage: is_RealDoubleField(RealField(53)) # needs sage.rings.real_mpfr False """ from sage.misc.superseded import deprecation @@ -103,7 +103,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: RR == RDF + sage: RR == RDF # needs sage.rings.real_mpfr False sage: RDF == RealDoubleField() # RDF is the shorthand True @@ -128,6 +128,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): numbers and higher-precision ones, though of course there may be loss of precision:: + sage: # needs sage.rings.real_mpfr sage: a = RealField(200)(2).sqrt(); a 1.4142135623730950488016887242096980785696718753769480731767 sage: b = RDF(a); b @@ -188,7 +189,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: latex(RDF) # indirect doctest + sage: latex(RDF) # indirect doctest \Bold{R} """ return "\\Bold{R}" @@ -214,7 +215,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: RealDoubleField() # indirect doctest + sage: RealDoubleField() # indirect doctest Real Double Field sage: RDF Real Double Field @@ -281,7 +282,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: RDF.complex_field() + sage: RDF.complex_field() # needs sage.rings.complex_double Complex Double Field """ from sage.rings.complex_double import CDF @@ -294,7 +295,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: RDF.algebraic_closure() + sage: RDF.algebraic_closure() # needs sage.rings.complex_double Complex Double Field """ from sage.rings.complex_double import CDF @@ -314,37 +315,37 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: RDF.coerce(5) # indirect doctest + sage: RDF.coerce(5) # indirect doctest 5.0 sage: RDF.coerce(9499294r) 9499294.0 sage: RDF.coerce(61/3) 20.333333333333332 - sage: parent(RDF(3) + CDF(5)) + sage: parent(RDF(3) + CDF(5)) # needs sage.rings.complex_double Complex Double Field - sage: parent(CDF(5) + RDF(3)) + sage: parent(CDF(5) + RDF(3)) # needs sage.rings.complex_double Complex Double Field - sage: CDF.gen(0) + 5.0 + sage: CDF.gen(0) + 5.0 # needs sage.rings.complex_double 5.0 + 1.0*I sage: RLF(2/3) + RDF(1) 1.6666666666666665 - sage: import numpy # optional - numpy - sage: RDF.coerce(numpy.int8('1')) # optional - numpy + sage: import numpy # needs numpy + sage: RDF.coerce(numpy.int8('1')) # needs numpy 1.0 - sage: RDF.coerce(numpy.float64('1')) # optional - numpy + sage: RDF.coerce(numpy.float64('1')) # needs numpy 1.0 - sage: RDF.coerce(pi) + sage: RDF.coerce(pi) # needs sage.symbolic Traceback (most recent call last): ... TypeError: no canonical coercion from Symbolic Ring to Real Double Field Test that :trac:`15695` is fixed (see also :trac:`18076`):: - sage: 1j + numpy.float64(2) + sage: 1j + numpy.float64(2) # needs numpy 2.00000000000000 + 1.00000000000000*I - sage: parent(_) + sage: parent(_) # needs numpy Complex Field with 53 bits of precision """ if S is int or S is float: @@ -388,7 +389,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): Magma handles precision in decimal digits, so we lose a bit:: - sage: magma(RDF) # optional - magma # indirect doctest + sage: magma(RDF) # indirect doctest # optional - magma Real field of precision 15 sage: 10^15 < 2^53 < 10^16 True @@ -396,7 +397,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): When we convert back from Magma, we convert to a generic real field that has 53 bits of precision:: - sage: magma(RDF).sage() # optional - magma + sage: magma(RDF).sage() # optional - magma Real Field with 53 bits of precision """ return "RealField(%s : Bits := true)" % self.prec() @@ -407,7 +408,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: fricas(RDF) # indirect doctest, optional - fricas + sage: fricas(RDF) # indirect doctest # optional - fricas DoubleFloat """ return "DoubleFloat" @@ -418,7 +419,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: polymake(RDF) #optional - jupymake # indirect doctest + sage: polymake(RDF) # indirect doctest # optional - jupymake Float """ return '"Float"' @@ -446,7 +447,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): EXAMPLES:: - sage: RDF.to_prec(52) + sage: RDF.to_prec(52) # needs sage.rings.real_mpfr Real Field with 52 bits of precision sage: RDF.to_prec(53) Real Double Field @@ -649,6 +650,7 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): TESTS:: + sage: # needs numpy sage: R. = RDF[] sage: RDF._factor_univariate_polynomial(x) x @@ -664,18 +666,19 @@ cdef class RealDoubleField_class(sage.rings.abc.RealDoubleField): The implementation relies on the ``roots()`` method which often reports roots not to be real even though they are:: - sage: f = (x-1)^3 - sage: f.roots(ring=CDF) # abs tol 2e-5 + sage: f = (x-1)^3 # needs numpy + sage: f.roots(ring=CDF) # abs tol 2e-5 # needs numpy [(1.0000065719436413, 1), (0.9999967140281792 - 5.691454546815028e-06*I, 1), (0.9999967140281792 + 5.691454546815028e-06*I, 1)] This leads to the following incorrect factorization:: - sage: f.factor() # abs tol 2e-5 + sage: f.factor() # abs tol 2e-5 # needs numpy (x - 1.0000065719436413) * (x^2 - 1.9999934280563585*x + 0.9999934280995487) """ - roots = f.roots(sage.rings.complex_double.CDF) + from sage.rings.complex_double import CDF + roots = f.roots(CDF) # collect real roots and conjugate pairs of non-real roots real_roots = [(r, e) for r, e in roots if r.imag().is_zero()] @@ -710,7 +713,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: RDF(2.3) # indirect doctest + sage: RDF(2.3) # indirect doctest 2.3 """ (self)._parent = _RDF @@ -744,7 +747,7 @@ cdef class RealDoubleElement(FieldElement): sage: RDF(10.5) 10.5 - sage: magma(RDF(10.5)) # optional - magma # indirect doctest + sage: magma(RDF(10.5)) # indirect doctest # optional - magma 10.5000000000000 """ return "%s!%s" % (self.parent()._magma_init_(magma), self) @@ -790,20 +793,21 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: a = RDF(pi) # optional - sage.symbolic - sage: a.ulp() # optional - sage.symbolic + sage: a = RDF(pi) # needs sage.symbolic + sage: a.ulp() # needs sage.symbolic 4.440892098500626e-16 - sage: b = a + a.ulp() # optional - sage.symbolic + sage: b = a + a.ulp() # needs sage.symbolic Adding or subtracting an ulp always gives a different number:: - sage: a + a.ulp() == a # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a + a.ulp() == a False - sage: a - a.ulp() == a # optional - sage.symbolic + sage: a - a.ulp() == a False - sage: b + b.ulp() == b # optional - sage.symbolic + sage: b + b.ulp() == b False - sage: b - b.ulp() == b # optional - sage.symbolic + sage: b - b.ulp() == b False Since the default rounding mode is round-to-nearest, adding or @@ -812,14 +816,16 @@ cdef class RealDoubleElement(FieldElement): can only happen if the input number is (up to sign) exactly a power of 2:: - sage: a - a.ulp()/3 == a # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a - a.ulp()/3 == a True - sage: a + a.ulp()/3 == a # optional - sage.symbolic + sage: a + a.ulp()/3 == a True - sage: b - b.ulp()/3 == b # optional - sage.symbolic + sage: b - b.ulp()/3 == b True - sage: b + b.ulp()/3 == b # optional - sage.symbolic + sage: b + b.ulp()/3 == b True + sage: c = RDF(1) sage: c - c.ulp()/3 == c False @@ -927,7 +933,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: ZZ(RDF(237.0)) # indirect doctest + sage: ZZ(RDF(237.0)) # indirect doctest 237 sage: ZZ(RDF(0.0/0.0)) Traceback (most recent call last): @@ -977,11 +983,11 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: s1 = RDF(sin(1)); s1 # optional - sage.symbolic + sage: s1 = RDF(sin(1)); s1 # needs sage.symbolic 0.8414709848078965 - sage: s1._interface_init_() # optional - sage.symbolic + sage: s1._interface_init_() # needs sage.symbolic '0.8414709848078965' - sage: s1 == RDF(gp(s1)) # optional - sage.libs.pari sage.symbolic + sage: s1 == RDF(gp(s1)) # needs sage.libs.pari sage.symbolic True """ return repr(self._value) @@ -1006,7 +1012,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: sage_input(RDF(NaN)) # optional - sage.symbolic + sage: sage_input(RDF(NaN)) # needs sage.symbolic RDF(NaN) sage: sage_input(RDF(-infinity), verify=True) # Verified @@ -1014,22 +1020,22 @@ cdef class RealDoubleElement(FieldElement): sage: sage_input(RDF(-infinity)*polygen(RDF)) R. = RDF[] -RDF(infinity)*x + RDF(NaN) - sage: sage_input(RDF(pi), verify=True) + sage: sage_input(RDF(pi), verify=True) # needs sage.symbolic # Verified RDF(3.1415926535897931) - sage: sage_input(RDF(-e), verify=True, preparse=False) + sage: sage_input(RDF(-e), verify=True, preparse=False) # needs sage.symbolic # Verified -RDF(2.718281828459045...) - sage: sage_input(RDF(pi)*polygen(RDF), verify=True, preparse=None) # optional - sage.symbolic + sage: sage_input(RDF(pi)*polygen(RDF), verify=True, preparse=None) # needs sage.symbolic # Verified R = RDF['x'] x = R.gen() 3.1415926535897931*x sage: from sage.misc.sage_input import SageInputBuilder sage: sib = SageInputBuilder() - sage: RDF(22/7)._sage_input_(sib, True) + sage: RDF(22/7)._sage_input_(sib, True) # needs sage.sage.rings.real_mpfr {atomic:3.1428571428571428} - sage: RDF(22/7)._sage_input_(sib, False) + sage: RDF(22/7)._sage_input_(sib, False) # needs sage.sage.rings.real_mpfr {call: {atomic:RDF}({atomic:3.1428571428571428})} """ cdef bint isinf = libc.math.isinf(self._value) @@ -1130,9 +1136,9 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: latex(RDF(3.4)) # indirect doctest + sage: latex(RDF(3.4)) # indirect doctest 3.4 - sage: latex(RDF(2e-100)) # indirect doctest + sage: latex(RDF(2e-100)) # indirect doctest 2 \times 10^{-100} """ s = self.str() @@ -1167,8 +1173,8 @@ cdef class RealDoubleElement(FieldElement): sage: RDF(2.1)._im_gens_(RR, [RR(1)]) 2.10000000000000 - sage: R = RealField(20) - sage: RDF(2.1)._im_gens_(R, [R(1)]) + sage: R = RealField(20) # needs sage.rings.real_mpfr + sage: RDF(2.1)._im_gens_(R, [R(1)]) # needs sage.rings.real_mpfr 2.1000 """ return codomain(self) # since 1 |--> 1 @@ -1265,24 +1271,25 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: a = RDF(exp(1.0)); a # optional - sage.symbolic + sage: # needs sage.symbolic + sage: a = RDF(exp(1.0)); a 2.718281828459045 - sage: sign,mantissa,exponent = RDF(exp(1.0)).sign_mantissa_exponent() # optional - sage.symbolic - sage: sign,mantissa,exponent # optional - sage.symbolic + sage: sign, mantissa, exponent = RDF(exp(1.0)).sign_mantissa_exponent() + sage: sign, mantissa, exponent (1, 6121026514868073, -51) - sage: sign*mantissa*(2**exponent) == a # optional - sage.symbolic + sage: sign*mantissa*(2**exponent) == a True The mantissa is always a nonnegative number:: - sage: RDF(-1).sign_mantissa_exponent() + sage: RDF(-1).sign_mantissa_exponent() # needs sage.rings.real_mpfr (-1, 4503599627370496, -52) TESTS:: - sage: RDF('+0').sign_mantissa_exponent() + sage: RDF('+0').sign_mantissa_exponent() # needs sage.rings.real_mpfr (1, 0, 0) - sage: RDF('-0').sign_mantissa_exponent() + sage: RDF('-0').sign_mantissa_exponent() # needs sage.rings.real_mpfr (-1, 0, 0) """ from sage.rings.real_mpfr import RR @@ -1332,7 +1339,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: RDF('-1.5') + RDF('2.5') # indirect doctest + sage: RDF('-1.5') + RDF('2.5') # indirect doctest 1.0 """ cdef RealDoubleElement x = PY_NEW(RealDoubleElement) @@ -1345,7 +1352,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: RDF('-1.5') - RDF('2.5') # indirect doctest + sage: RDF('-1.5') - RDF('2.5') # indirect doctest -4.0 """ cdef RealDoubleElement x = PY_NEW(RealDoubleElement) @@ -1358,7 +1365,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: RDF('-1.5') * RDF('2.5') # indirect doctest + sage: RDF('-1.5') * RDF('2.5') # indirect doctest -3.75 """ cdef RealDoubleElement x = PY_NEW(RealDoubleElement) @@ -1371,7 +1378,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: RDF('-1.5') / RDF('2.5') # indirect doctest + sage: RDF('-1.5') / RDF('2.5') # indirect doctest -0.6 sage: RDF(1)/RDF(0) +infinity @@ -1649,9 +1656,9 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: sage: a = RDF(1/3) - sage: CC(a) + sage: CC(a) # needs sage.rings.real_mpfr 0.333333333333333 - sage: a._complex_mpfr_field_(CC) + sage: a._complex_mpfr_field_(CC) # needs sage.rings.real_mpfr 0.333333333333333 If we coerce to a higher-precision field the extra bits appear @@ -1659,9 +1666,9 @@ cdef class RealDoubleElement(FieldElement): :: - sage: a._complex_mpfr_field_(ComplexField(100)) + sage: a._complex_mpfr_field_(ComplexField(100)) # needs sage.rings.real_mpfr 0.33333333333333331482961625625 - sage: a._complex_mpfr_field_(ComplexField(100)).str(2) + sage: a._complex_mpfr_field_(ComplexField(100)).str(2) # needs sage.rings.real_mpfr '0.01010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000' """ return CC(self._value) @@ -1672,7 +1679,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: CDF(RDF(1/3)) # indirect doctest + sage: CDF(RDF(1/3)) # indirect doctest # needs sage.rings.complex_double 0.3333333333333333 """ return CDF(self._value) @@ -1683,7 +1690,7 @@ cdef class RealDoubleElement(FieldElement): EXAMPLES:: - sage: RDF(1.5).__pari__() # optional - sage.libs.pari + sage: RDF(1.5).__pari__() # needs sage.libs.pari 1.50000000000000 """ global new_gen_from_real_double_element @@ -1846,7 +1853,7 @@ cdef class RealDoubleElement(FieldElement): :: sage: r = RDF(-2.0) - sage: r.sqrt() + sage: r.sqrt() # needs sage.rings.complex_double 1.4142135623730951*I :: @@ -1855,7 +1862,7 @@ cdef class RealDoubleElement(FieldElement): [1.4142135623730951, -1.4142135623730951] sage: RDF(0).sqrt(all=True) [0.0] - sage: RDF(-2).sqrt(all=True) + sage: RDF(-2).sqrt(all=True) # needs sage.rings.complex_double [1.4142135623730951*I, -1.4142135623730951*I] """ if self._value >= 0: @@ -1969,7 +1976,7 @@ cdef class RealDoubleElement(FieldElement): sage: r = sqrt(RDF(2)); r 1.4142135623730951 - sage: r.algebraic_dependency(5) # optional - sage.libs.pari + sage: r.algebraic_dependency(5) # needs sage.libs.pari x^2 - 2 """ return sage.arith.all.algdep(self,n) @@ -2022,7 +2029,7 @@ cdef class ToRDF(Morphism): EXAMPLES:: sage: f = RDF.coerce_map_from(float) - sage: f(3.5) # indirect doctest + sage: f(3.5) # indirect doctest 3.5 """ cdef RealDoubleElement r = PY_NEW(RealDoubleElement) @@ -2071,7 +2078,7 @@ def is_RealDoubleElement(x): sage: from sage.rings.real_double import is_RealDoubleElement sage: is_RealDoubleElement(RDF(3)) True - sage: is_RealDoubleElement(RIF(3)) + sage: is_RealDoubleElement(RIF(3)) # needs sage.rings.real_interval_field False """ return isinstance(x, RealDoubleElement) diff --git a/src/sage/rings/real_double_element_gsl.pyx b/src/sage/rings/real_double_element_gsl.pyx index d03c0271d1a..8b6b3671605 100644 --- a/src/sage/rings/real_double_element_gsl.pyx +++ b/src/sage/rings/real_double_element_gsl.pyx @@ -249,7 +249,7 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): 0.6931471805599453 sage: RDF(2).log(2) 1.0 - sage: RDF(2).log(pi) + sage: RDF(2).log(pi) # needs sage.symbolic 0.6055115613982801 sage: RDF(2).log(10) 0.30102999566398114 @@ -334,7 +334,7 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): sage: r = RDF('16.0'); r.log10() 1.2041199826559248 - sage: r.log() / RDF(log(10)) + sage: r.log() / RDF(log(10)) # needs sage.symbolic 1.2041199826559246 sage: r = RDF('39.9'); r.log10() 1.6009728956867482 @@ -355,7 +355,7 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): sage: r = RDF(16); r.logpi() 2.4220462455931204 - sage: r.log() / RDF(log(pi)) + sage: r.log() / RDF(log(pi)) # needs sage.symbolic 2.4220462455931204 sage: r = RDF('39.9'); r.logpi() 3.2203023346075152 @@ -508,11 +508,11 @@ cdef class RealDoubleElement_gsl(RealDoubleElement): EXAMPLES:: - sage: RDF(pi).restrict_angle() + sage: RDF(pi).restrict_angle() # needs sage.symbolic 3.141592653589793 - sage: RDF(pi + 1e-10).restrict_angle() + sage: RDF(pi + 1e-10).restrict_angle() # needs sage.symbolic -3.1415926534897936 - sage: RDF(1+10^10*pi).restrict_angle() + sage: RDF(1+10^10*pi).restrict_angle() # needs sage.symbolic 0.9999977606... """ return self._new_c(gsl_sf_angle_restrict_symm(self._value)) diff --git a/src/sage/rings/real_interval_absolute.pyx b/src/sage/rings/real_interval_absolute.pyx index 3d0dabaaa5f..5caf4ac40f1 100644 --- a/src/sage/rings/real_interval_absolute.pyx +++ b/src/sage/rings/real_interval_absolute.pyx @@ -1,3 +1,4 @@ +# sage.doctest: # needs sage.symbolic """ Real intervals with a fixed absolute precision """ diff --git a/src/sage/rings/real_lazy.pyx b/src/sage/rings/real_lazy.pyx index b6ff3f64015..fb96ae89407 100644 --- a/src/sage/rings/real_lazy.pyx +++ b/src/sage/rings/real_lazy.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.real_mpfr """ Lazy real and complex numbers @@ -14,9 +15,9 @@ TESTS: Bug :trac:`21991`:: - sage: a = QuadraticField(5).gen() - sage: u = -573147844013817084101/2*a + 1281597540372340914251/2 - sage: RealIntervalField(128)(RLF(u)).is_exact() + sage: a = QuadraticField(5).gen() # needs sage.rings.number_field + sage: u = -573147844013817084101/2*a + 1281597540372340914251/2 # needs sage.rings.number_field + sage: RealIntervalField(128)(RLF(u)).is_exact() # needs sage.rings.number_field False """ @@ -149,16 +150,16 @@ cdef class LazyField(Field): True sage: RLF.has_coerce_map_from(QQ) True - sage: RLF.has_coerce_map_from(AA) + sage: RLF.has_coerce_map_from(AA) # needs sage.rings.number_field True - sage: CLF.has_coerce_map_from(QQbar) + sage: CLF.has_coerce_map_from(QQbar) # needs sage.rings.number_field True sage: RLF.has_coerce_map_from(RDF) False sage: CLF.has_coerce_map_from(QQ) True - sage: CLF.has_coerce_map_from(QQbar) + sage: CLF.has_coerce_map_from(QQbar) # needs sage.rings.number_field True sage: CLF.has_coerce_map_from(CC) False @@ -406,7 +407,7 @@ class ComplexLazyField_class(LazyField): sage: CLF.interval_field() Complex Interval Field with 53 bits of precision - sage: CLF.interval_field(333) + sage: CLF.interval_field(333) # needs sage.rings.complex_interval_field Complex Interval Field with 333 bits of precision sage: CLF.interval_field() is CIF True @@ -426,7 +427,7 @@ class ComplexLazyField_class(LazyField): sage: CLF.gen() 1*I - sage: ComplexField(100)(CLF.gen()) + sage: ComplexField(100)(CLF.gen()) # needs sage.rings.number_field 1.0000000000000000000000000000*I """ if i == 0: @@ -746,6 +747,7 @@ cdef class LazyFieldElement(FieldElement): When the absolute value is involved, the result might be real:: + sage: # needs sage.symbolic sage: z = exp(CLF(1 + I/2)); z 2.38551673095914? + 1.303213729686996?*I sage: r = z.abs(); r @@ -853,7 +855,7 @@ cdef class LazyFieldElement(FieldElement): TESTS:: - sage: "log" in RLF(sqrt(8)).__dir__() + sage: "log" in RLF(sqrt(8)).__dir__() # needs sage.symbolic True """ @@ -868,7 +870,7 @@ cdef class LazyFieldElement(FieldElement): sage: a = RLF(3) sage: a.sqrt() 1.732050807568878? - sage: sin(a) + sage: sin(a) # needs sage.symbolic 0.1411200080598673? sage: RealField(160)(tanh(RLF(3))) 0.99505475368673045133188018525548847509781385470 @@ -884,6 +886,7 @@ cdef class LazyFieldElement(FieldElement): EXAMPLES:: + sage: # needs sage.symbolic sage: a = RLF(sqrt(2)) + RLF(sqrt(3)) sage: cf = a.continued_fraction() sage: cf @@ -901,8 +904,8 @@ def make_element(parent, *args): EXAMPLES:: - sage: a = RLF(pi) + RLF(sqrt(1/2)) # indirect doctest - sage: bool(loads(dumps(a)) == a) + sage: a = RLF(pi) + RLF(sqrt(1/2)) # indirect doctest # needs sage.symbolic + sage: bool(loads(dumps(a)) == a) # needs sage.symbolic True """ return parent(*args) @@ -1041,8 +1044,8 @@ cdef class LazyWrapper(LazyFieldElement): EXAMPLES:: - sage: a = RLF(sqrt(2)) - sage: a.continued_fraction() + sage: a = RLF(sqrt(2)) # needs sage.symbolic + sage: a.continued_fraction() # needs sage.symbolic [1; 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ...] """ from sage.rings.continued_fraction import ContinuedFraction_real, ContinuedFraction_infinite @@ -1244,7 +1247,7 @@ cdef class LazyUnop(LazyFieldElement): sage: from sage.rings.real_lazy import LazyUnop sage: a = LazyUnop(RLF, 3, sqrt) - sage: a.eval(ZZ) + sage: a.eval(ZZ) # needs sage.symbolic sqrt(3) """ arg = self._arg.eval(R) @@ -1260,7 +1263,7 @@ cdef class LazyUnop(LazyFieldElement): EXAMPLES:: - sage: hash(RLF(sin(1))) == hash(RLF(sin(1))) + sage: hash(RLF(sin(1))) == hash(RLF(sin(1))) # needs sage.symbolic True """ return hash(self._op(hash(self._arg))) @@ -1623,13 +1626,13 @@ cdef class LazyAlgebraic(LazyFieldElement): sage: a = LazyAlgebraic(CLF, QQ['x'].cyclotomic_polynomial(7), 0.6+0.8*CC.0) sage: a 0.6234898018587335? + 0.7818314824680299?*I - sage: ComplexField(150)(a) # indirect doctest + sage: ComplexField(150)(a) # indirect doctest # needs sage.rings.number_field 0.62348980185873353052500488400423981063227473 + 0.78183148246802980870844452667405775023233452*I sage: a = LazyAlgebraic(CLF, QQ['x'].0^2-7, -2.0) - sage: RR(a) + sage: RR(a) # needs sage.rings.number_field -2.64575131106459 - sage: RR(a)^2 + sage: RR(a)^2 # needs sage.rings.number_field 7.00000000000000 """ if isinstance(R, type): diff --git a/src/sage/rings/real_mpfi.pyx b/src/sage/rings/real_mpfi.pyx index 509f6f63da0..461b87db869 100644 --- a/src/sage/rings/real_mpfi.pyx +++ b/src/sage/rings/real_mpfi.pyx @@ -47,7 +47,7 @@ preceding digit is possibly wrong by `\pm 1`. :: - sage: RIF(sqrt(2)) + sage: RIF(sqrt(2)) # needs sage.symbolic 1.414213562373095? However, if the interval is precise (its lower bound is equal to @@ -81,11 +81,11 @@ it is taken to be 1. '125.?2' sage: RIF(123, 127).str(error_digits=1) '125.?2' - sage: v = RIF(-e, pi); v + sage: v = RIF(-e, pi); v # needs sage.symbolic 0.?e1 - sage: v.str(error_digits=1) + sage: v.str(error_digits=1) # needs sage.symbolic '1.?4' - sage: v.str(error_digits=5) + sage: v.str(error_digits=5) # needs sage.symbolic '0.2117?29300' Error digits also sometimes let us indicate that the interval is @@ -230,10 +230,10 @@ specified if given a non-interval and an interval:: TESTS:: - sage: import numpy # optional - numpy - sage: RIF(2) == numpy.int8('2') # optional - numpy + sage: import numpy # needs numpy + sage: RIF(2) == numpy.int8('2') # needs numpy True - sage: numpy.int8('2') == RIF(2) # optional - numpy + sage: numpy.int8('2') == RIF(2) # needs numpy True sage: RIF(0,1) < float('2') Traceback (most recent call last): @@ -389,7 +389,7 @@ cdef class RealIntervalField_class(sage.rings.abc.RealIntervalField): 3 sage: RIF(RIF(3)) 3 - sage: RIF(pi) + sage: RIF(pi) # needs sage.symbolic 3.141592653589794? sage: RIF(RealField(53)('1.5')) 1.5000000000000000? @@ -452,9 +452,9 @@ cdef class RealIntervalField_class(sage.rings.abc.RealIntervalField): sage: def check(x): ....: return (x, x.lower() == x.upper()) - sage: check(RIF(pi)) + sage: check(RIF(pi)) # needs sage.symbolic (3.141592653589794?, False) - sage: check(RIF(RR(pi))) + sage: check(RIF(RR(pi))) # needs sage.symbolic (3.1415926535897932?, True) sage: check(RIF(1.5)) (1.5000000000000000?, True) @@ -486,11 +486,11 @@ cdef class RealIntervalField_class(sage.rings.abc.RealIntervalField): 3 sage: R(R(3)) 3 - sage: R(pi) + sage: R(pi) # needs sage.symbolic 3.14159265358979323846264338328? sage: R(-2/19) -0.1052631578947368421052631578948? - sage: R(e,pi).str(style='brackets') + sage: R(e,pi).str(style='brackets') # needs sage.symbolic '[2.7182818284590452353602874713512 .. 3.1415926535897932384626433832825]' TESTS:: @@ -1050,7 +1050,7 @@ cdef class RealIntervalField_class(sage.rings.abc.RealIntervalField): sage: magma(RealIntervalField(80)) # optional - magma # indirect doctest Real field of precision 24 - sage: floor(RR(log(2**80, 10))) + sage: floor(RR(log(2**80, 10))) # needs sage.symbolic 24 """ return "RealField(%s : Bits := true)" % self.prec() @@ -1356,7 +1356,7 @@ cdef class RealIntervalFieldElement(RingElement): error:: sage: a = RealInterval('2.3') - sage: maxima(a) + sage: maxima(a) # needs sage.symbolic Traceback (most recent call last): ... TypeError @@ -1370,10 +1370,11 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: sage_input(RIF(e, pi), verify=True) + sage: sage_input(RIF(e, pi), verify=True) # needs sage.symbolic # Verified RIF(RR(2.7182818284590451), RR(3.1415926535897936)) - sage: sage_input(RealIntervalField(64)(sqrt(2)), preparse=False, verify=True) + sage: sage_input(RealIntervalField(64)(sqrt(2)), # needs sage.symbolic + ....: preparse=False, verify=True) # Verified RR64 = RealField(64) RealIntervalField(64)(RR64('1.41421356237309504876'), RR64('1.41421356237309504887')) @@ -1386,8 +1387,9 @@ cdef class RealIntervalFieldElement(RingElement): RealIntervalField(2)(RR2(12.), RR2(16.)) sage: from sage.misc.sage_input import SageInputBuilder sage: sib = SageInputBuilder() - sage: RIF(-sqrt(3), -sqrt(2))._sage_input_(sib, False) - {call: {atomic:RIF}({unop:- {call: {atomic:RR}({atomic:1.7320508075688774})}}, {unop:- {call: {atomic:RR}({atomic:1.4142135623730949})}})} + sage: RIF(-sqrt(3), -sqrt(2))._sage_input_(sib, False) # needs sage.symbolic + {call: {atomic:RIF}({unop:- {call: {atomic:RR}({atomic:1.7320508075688774})}}, + {unop:- {call: {atomic:RR}({atomic:1.4142135623730949})}})} """ # Interval printing could often be much prettier, # but I'm feeling lazy :) @@ -1406,7 +1408,7 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: hash(RIF(e)) == hash(RIF(e)) # indirect doctest + sage: hash(RIF(e)) == hash(RIF(e)) # indirect doctest # needs sage.symbolic True """ return hash(self.str(16)) @@ -1491,11 +1493,11 @@ cdef class RealIntervalFieldElement(RingElement): ``'brackets'`` style. In question style (the default), we print the "known correct" part of the number, followed by a question mark:: - sage: RIF(pi).str() + sage: RIF(pi).str() # needs sage.symbolic '3.141592653589794?' - sage: RIF(pi, 22/7).str() + sage: RIF(pi, 22/7).str() # needs sage.symbolic '3.142?' - sage: RIF(pi, 22/7).str(style='question') + sage: RIF(pi, 22/7).str(style='question') # needs sage.symbolic '3.142?' However, if the interval is precisely equal to some integer that's @@ -1545,9 +1547,9 @@ cdef class RealIntervalFieldElement(RingElement): We always use brackets style for ``NaN`` and infinities:: - sage: RIF(pi, infinity) + sage: RIF(pi, infinity) # needs sage.symbolic [3.1415926535897931 .. +infinity] - sage: RIF(NaN) + sage: RIF(NaN) # needs sage.symbolic [.. NaN ..] Let's take a closer, formal look at the question style. In its full @@ -1620,11 +1622,11 @@ cdef class RealIntervalFieldElement(RingElement): '3.14223?64' sage: pi_appr.str(base=36) '3.6?' - sage: RIF(NaN) + sage: RIF(NaN) # needs sage.symbolic [.. NaN ..] - sage: RIF(pi, infinity) + sage: RIF(pi, infinity) # needs sage.symbolic [3.1415926535897931 .. +infinity] - sage: RIF(-infinity, pi) + sage: RIF(-infinity, pi) # needs sage.symbolic [-infinity .. 3.1415926535897936] sage: RealIntervalField(210)(3).sqrt() 1.732050807568877293527446341505872366942805253810380628055806980? @@ -1632,7 +1634,7 @@ cdef class RealIntervalFieldElement(RingElement): 1.732050807568878? sage: RIF(3).sqrt() 1.732050807568878? - sage: RIF(0, 3^-150) + sage: RIF(0, 3^-150) # needs sage.symbolic 1.?e-71 TESTS: @@ -2311,7 +2313,7 @@ cdef class RealIntervalFieldElement(RingElement): sage: RIF(1,2).endpoints() (1.00000000000000, 2.00000000000000) - sage: RIF(pi).endpoints() + sage: RIF(pi).endpoints() # needs sage.symbolic (3.14159265358979, 3.14159265358980) sage: a = CIF(RIF(1,2), RIF(3,4)) sage: a.real().endpoints() @@ -2342,7 +2344,7 @@ cdef class RealIntervalFieldElement(RingElement): sage: RIF(1,2).edges() (1, 2) - sage: RIF(pi).edges() + sage: RIF(pi).edges() # needs sage.symbolic (3.1415926535897932?, 3.1415926535897936?) """ left = self._new() @@ -2363,7 +2365,7 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: RIF(1, pi).absolute_diameter() + sage: RIF(1, pi).absolute_diameter() # needs sage.symbolic 2.14159265358979 """ cdef RealNumber x @@ -2378,7 +2380,7 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: RIF(1, pi).relative_diameter() + sage: RIF(1, pi).relative_diameter() # needs sage.symbolic 1.03418797197910 """ cdef RealNumber x @@ -2399,6 +2401,8 @@ cdef class RealIntervalFieldElement(RingElement): 1.00000000000000 sage: RIF(1, 2).relative_diameter() 0.666666666666667 + + sage: # needs sage.symbolic sage: RIF(pi).diameter() 1.41357985842823e-16 sage: RIF(pi).absolute_diameter() @@ -2431,16 +2435,18 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: RIF(pi).fp_rank_diameter() - 1 sage: RIF(12345).fp_rank_diameter() 0 - sage: RIF(-sqrt(2)).fp_rank_diameter() - 1 sage: RIF(5/8).fp_rank_diameter() 0 sage: RIF(5/7).fp_rank_diameter() 1 + + sage: # needs sage.symbolic + sage: RIF(pi).fp_rank_diameter() + 1 + sage: RIF(-sqrt(2)).fp_rank_diameter() + 1 sage: a = RIF(pi)^12345; a 2.06622879260?e6137 sage: a.fp_rank_diameter() @@ -2452,10 +2458,10 @@ cdef class RealIntervalFieldElement(RingElement): Just because we have the best possible interval, doesn't mean the interval is actually small:: - sage: a = RIF(pi)^12345678901234567890; a + sage: a = RIF(pi)^12345678901234567890; a # needs sage.symbolic [2.0985787164673874e323228496 .. +infinity] # 32-bit [5.8756537891115869e1388255822130839282 .. +infinity] # 64-bit - sage: a.fp_rank_diameter() + sage: a.fp_rank_diameter() # needs sage.symbolic 1 """ return self.lower().fp_rank_delta(self.upper()) @@ -2469,7 +2475,7 @@ cdef class RealIntervalFieldElement(RingElement): sage: RIF(3).is_exact() True - sage: RIF(2*pi).is_exact() + sage: RIF(2*pi).is_exact() # needs sage.symbolic False """ return mpfr_equal_p(&self.value.left, &self.value.right) @@ -2543,6 +2549,7 @@ cdef class RealIntervalFieldElement(RingElement): sage: b.lower(), b.upper() (1.50000000000000, 2.00000000000000) + sage: # needs sage.symbolic sage: I = RIF(e, pi) sage: a, b = I.bisection() sage: a.intersection(b) == RIF(I.center()) @@ -3372,9 +3379,9 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: RIF(pi).unique_floor() + sage: RIF(pi).unique_floor() # needs sage.symbolic 3 - sage: RIF(100*pi).unique_floor() + sage: RIF(100*pi).unique_floor() # needs sage.symbolic 314 sage: RIF(100, 200).unique_floor() Traceback (most recent call last): @@ -3403,9 +3410,9 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: RIF(pi).unique_ceil() + sage: RIF(pi).unique_ceil() # needs sage.symbolic 4 - sage: RIF(100*pi).unique_ceil() + sage: RIF(100*pi).unique_ceil() # needs sage.symbolic 315 sage: RIF(100, 200).unique_ceil() Traceback (most recent call last): @@ -3434,9 +3441,9 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: RIF(pi).unique_round() + sage: RIF(pi).unique_round() # needs sage.symbolic 3 - sage: RIF(1000*pi).unique_round() + sage: RIF(1000*pi).unique_round() # needs sage.symbolic 3142 sage: RIF(100, 200).unique_round() Traceback (most recent call last): @@ -3448,7 +3455,7 @@ cdef class RealIntervalFieldElement(RingElement): ValueError: interval does not have a unique round (nearest integer) sage: RIF(0.7, 1.2).unique_round() 1 - sage: RIF(-pi).unique_round() + sage: RIF(-pi).unique_round() # needs sage.symbolic -3 sage: (RIF(4.5).unique_round(), RIF(-4.5).unique_round()) (5, -5) @@ -3521,13 +3528,13 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: RIF(pi).unique_integer() + sage: RIF(pi).unique_integer() # needs sage.symbolic Traceback (most recent call last): ... ValueError: interval contains no integer - sage: RIF(pi, pi+1).unique_integer() + sage: RIF(pi, pi+1).unique_integer() # needs sage.symbolic 4 - sage: RIF(pi, pi+2).unique_integer() + sage: RIF(pi, pi+2).unique_integer() # needs sage.symbolic Traceback (most recent call last): ... ValueError: interval contains more than one integer @@ -3577,9 +3584,9 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: RealIntervalField(10)(pi).simplest_rational() + sage: RealIntervalField(10)(pi).simplest_rational() # needs sage.symbolic 22/7 - sage: RealIntervalField(20)(pi).simplest_rational() + sage: RealIntervalField(20)(pi).simplest_rational() # needs sage.symbolic 355/113 sage: RIF(0.123, 0.567).simplest_rational() 1/2 @@ -3828,7 +3835,7 @@ cdef class RealIntervalFieldElement(RingElement): True sage: RIF(0) == RIF(0) True - sage: RIF(pi) == RIF(pi) + sage: RIF(pi) == RIF(pi) # needs sage.symbolic False sage: RIF(0, 1) == RIF(1, 2) False @@ -3852,7 +3859,7 @@ cdef class RealIntervalFieldElement(RingElement): False sage: RIF(0) != RIF(0) False - sage: RIF(pi) != RIF(pi) + sage: RIF(pi) != RIF(pi) # needs sage.symbolic False sage: RIF(0, 1) != RIF(1, 2) False @@ -3983,7 +3990,7 @@ cdef class RealIntervalFieldElement(RingElement): True sage: 1.0 in RIF(0, 2) True - sage: pi in RIF(3.1415, 3.1416) + sage: pi in RIF(3.1415, 3.1416) # needs sage.symbolic True sage: 22/7 in RIF(3.1415, 3.1416) False @@ -4115,7 +4122,7 @@ cdef class RealIntervalFieldElement(RingElement): sage: a = RIF(-1, 1).min(0).endpoints() sage: a[0] == -1.0 and a[1].abs() == 0.0 # in MPFI, the sign of 0.0 is not specified True - sage: RIF(-1, 1).min(pi).endpoints() + sage: RIF(-1, 1).min(pi).endpoints() # needs sage.symbolic (-1.00000000000000, 1.00000000000000) sage: RIF(-1, 1).min(RIF(-100, 100)).endpoints() (-100.000000000000, 1.00000000000000) @@ -4400,10 +4407,10 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: sage: R = RealIntervalField(17) - sage: x = R((-e,pi)) - sage: x2 = x^2; x2.lower(), x2.upper() + sage: x = R((-e, pi)) # needs sage.symbolic + sage: x2 = x^2; x2.lower(), x2.upper() # needs sage.symbolic (0.0000, 9.870) - sage: x3 = x^3; x3.lower(), x3.upper() + sage: x3 = x^3; x3.lower(), x3.upper() # needs sage.symbolic (-26.83, 31.01) """ if exponent == 2: @@ -4616,7 +4623,8 @@ cdef class RealIntervalFieldElement(RingElement): EXAMPLES:: - sage: t=RIF(pi)/2 + sage: # needs sage.symbolic + sage: t = RIF(pi)/2 sage: t.cos() 0.?e-15 sage: t.cos().str(style='brackets') @@ -5070,7 +5078,7 @@ cdef class RealIntervalFieldElement(RingElement): (2.00000000000000, 6.00000000000000) sage: RIF(-1/2).gamma() -3.54490770181104? - sage: gamma(-1/2).n(100) in RIF(-1/2).gamma() + sage: gamma(-1/2).n(100) in RIF(-1/2).gamma() # needs sage.symbolic True sage: RIF1000 = RealIntervalField(1000) sage: 0 in (RIF1000(RealField(2000)(-19/3).gamma()) - RIF1000(-19/3).gamma()) diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx index 7440fadd265..8ca68e35474 100644 --- a/src/sage/rings/real_mpfr.pyx +++ b/src/sage/rings/real_mpfr.pyx @@ -654,7 +654,7 @@ cdef class RealField_class(sage.rings.abc.RealField): Traceback (most recent call last): ... ValueError: can only convert signed infinity to RR - sage: R(CIF(NaN)) + sage: R(CIF(NaN)) # needs sage.symbolic NaN sage: R(complex(1.7)) 1.7000 @@ -719,7 +719,7 @@ cdef class RealField_class(sage.rings.abc.RealField): TESTS:: - sage: 1.0 - ZZ(1) - int(1) - 1 - QQ(1) - RealField(100)(1) - AA(1) - RLF(1) + sage: 1.0 - ZZ(1) - int(1) - 1 - QQ(1) - RealField(100)(1) - AA(1) - RLF(1) # needs sage.rings.number_field -6.00000000000000 sage: R = RR['x'] # Hold reference to avoid garbage collection, see Issue #24709 sage: R.get_action(ZZ) @@ -1438,12 +1438,13 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: - sage: import numpy # optional - numpy - sage: numpy.arange(10.0) # optional - numpy + sage: # needs numpy + sage: import numpy + sage: numpy.arange(10.0) array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) - sage: numpy.array([1.0, 1.1, 1.2]).dtype # optional - numpy + sage: numpy.array([1.0, 1.1, 1.2]).dtype dtype('float64') - sage: numpy.array([1.000000000000000000000000000000000000]).dtype # optional - numpy + sage: numpy.array([1.000000000000000000000000000000000000]).dtype dtype('O') """ if (self._parent)._prec <= 53: @@ -1604,7 +1605,7 @@ cdef class RealNumber(sage.structure.element.RingElement): 'Infinity' sage: format(RR(-oo), '.4') '-Infinity' - sage: format(RR(NaN), '.4') + sage: format(RR(NaN), '.4') # needs sage.symbolic 'NaN' sage: '{}'.format(RR(oo)) '+infinity' @@ -1652,11 +1653,11 @@ cdef class RealNumber(sage.structure.element.RingElement): sage: n = 1.3939494594 sage: n._interface_init_() '1.3939494593999999' - sage: s1 = RR(sin(1)); s1 + sage: s1 = RR(sin(1)); s1 # needs sage.symbolic 0.841470984807897 - sage: s1._interface_init_() + sage: s1._interface_init_() # needs sage.symbolic '0.84147098480789650' - sage: s1 == RR(gp(s1)) + sage: s1 == RR(gp(s1)) # needs sage.symbolic True """ return self.str(10, no_sci=True) @@ -1680,6 +1681,8 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: + sage: values = [-infinity, -20, 0, 1, 2^500, -2^4000, -2^-500, 2^-4000] + sage: values += [NaN, -e] # needs sage.symbolic sage: for prec in (2, 53, 200): ....: for rnd_dir in ('RNDN', 'RNDD', 'RNDU', 'RNDZ'): ....: fld = RealField(prec, rnd=rnd_dir) @@ -1694,7 +1697,7 @@ cdef class RealNumber(sage.structure.element.RingElement): sage: RR60 = RealField(60) sage: RR(-infinity)._sage_input_(sib, True) {unop:- {call: {atomic:RR}({atomic:Infinity})}} - sage: RR(NaN)._sage_input_(sib, True) + sage: RR(NaN)._sage_input_(sib, True) # needs sage.symbolic {call: {atomic:RR}({atomic:NaN})} sage: RR(12345)._sage_input_(sib, True) {atomic:12345} @@ -1712,9 +1715,9 @@ cdef class RealNumber(sage.structure.element.RingElement): {call: {atomic:RR}({atomic:1.579})} sage: RR(1.579)._sage_input_(sib_np, 2) {atomic:1.579} - sage: RealField(150)(pi)._sage_input_(sib, True) + sage: RealField(150)(pi)._sage_input_(sib, True) # needs sage.symbolic {atomic:3.1415926535897932384626433832795028841971694008} - sage: RealField(150)(pi)._sage_input_(sib_np, True) + sage: RealField(150)(pi)._sage_input_(sib_np, True) # needs sage.symbolic {call: {call: {atomic:RealField}({atomic:150})}({atomic:'3.1415926535897932384626433832795028841971694008'})} """ # We have a bewildering array of conditions to deal with: @@ -2336,7 +2339,7 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: - sage: [x.fp_rank_delta(x.nextabove()) for x in + sage: [x.fp_rank_delta(x.nextabove()) for x in # needs sage.symbolic ....: (RR(-infinity), -1.0, 0.0, 1.0, RR(pi), RR(infinity))] [1, 1, 1, 1, 1, 0] @@ -2385,7 +2388,10 @@ cdef class RealNumber(sage.structure.element.RingElement): """ if have_same_parent(left, right): return ( left)._add_(right) - from .real_mpfi import RealIntervalFieldElement + try: + from .real_mpfi import RealIntervalFieldElement + except ImportError: + RealIntervalFieldElement = None if type(right) is RealIntervalFieldElement: return right.__add__(left) elif isinstance(left, RealNumber): @@ -2406,7 +2412,10 @@ cdef class RealNumber(sage.structure.element.RingElement): """ if have_same_parent(left, right): return ( left)._sub_(right) - from .real_mpfi import RealIntervalFieldElement + try: + from .real_mpfi import RealIntervalFieldElement + except ImportError: + RealIntervalFieldElement = None if type(right) is RealIntervalFieldElement: return (-right).__add__(left) elif isinstance(left, RealNumber): @@ -2427,7 +2436,10 @@ cdef class RealNumber(sage.structure.element.RingElement): """ if have_same_parent(left, right): return ( left)._mul_(right) - from .real_mpfi import RealIntervalFieldElement + try: + from .real_mpfi import RealIntervalFieldElement + except ImportError: + RealIntervalFieldElement = None if type(right) is RealIntervalFieldElement: return right.__mul__(left) elif isinstance(left, RealNumber): @@ -2448,7 +2460,10 @@ cdef class RealNumber(sage.structure.element.RingElement): """ if have_same_parent(left, right): return ( left)._div_(right) - from .real_mpfi import RealIntervalFieldElement + try: + from .real_mpfi import RealIntervalFieldElement + except ImportError: + RealIntervalFieldElement = None if type(right) is RealIntervalFieldElement: return right.__rtruediv__(left) elif isinstance(left, RealNumber): @@ -2505,22 +2520,22 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: - sage: RealField(100)(1/7)._sympy_() + sage: RealField(100)(1/7)._sympy_() # needs sympy 0.14285714285714285714285714286 - sage: type(_) + sage: type(_) # needs sympy TESTS: An indirect doctest to check this (see :trac:`14915`):: - sage: x,y = var('x, y') - sage: integrate(y, y, 0.5, 8*log(x), algorithm='sympy') + sage: x,y = var('x, y') # needs sage.symbolic + sage: integrate(y, y, 0.5, 8*log(x), algorithm='sympy') # needs sympy sage.symbolic 32*log(x)^2 - 0.125000000000000 Check that :trac:`28903` is fixed:: - sage: (10.0^400)._sympy_() + sage: (10.0^400)._sympy_() # needs sympy 1.00000000000000e+400 """ import sympy @@ -3126,11 +3141,11 @@ cdef class RealNumber(sage.structure.element.RingElement): sage: RR(infinity).nexttoward(0) 2.09857871646739e323228496 # 32-bit 5.87565378911159e1388255822130839282 # 64-bit - sage: RR(pi).str() + sage: RR(pi).str() # needs sage.symbolic '3.1415926535897931' - sage: RR(pi).nexttoward(22/7).str() + sage: RR(pi).nexttoward(22/7).str() # needs sage.symbolic '3.1415926535897936' - sage: RR(pi).nexttoward(21/7).str() + sage: RR(pi).nexttoward(21/7).str() # needs sage.symbolic '3.1415926535897927' """ cdef RealNumber other_rn @@ -3160,9 +3175,9 @@ cdef class RealNumber(sage.structure.element.RingElement): 8.50969131174084e-1388255822130839284 # 64-bit sage: RR('+infinity').nextabove() +infinity - sage: RR(-sqrt(2)).str() + sage: RR(-sqrt(2)).str() # needs sage.symbolic '-1.4142135623730951' - sage: RR(-sqrt(2)).nextabove().str() + sage: RR(-sqrt(2)).nextabove().str() # needs sage.symbolic '-1.4142135623730949' """ @@ -3186,9 +3201,9 @@ cdef class RealNumber(sage.structure.element.RingElement): sage: RR('+infinity').nextbelow() 2.09857871646739e323228496 # 32-bit 5.87565378911159e1388255822130839282 # 64-bit - sage: RR(-sqrt(2)).str() + sage: RR(-sqrt(2)).str() # needs sage.symbolic '-1.4142135623730951' - sage: RR(-sqrt(2)).nextbelow().str() + sage: RR(-sqrt(2)).nextbelow().str() # needs sage.symbolic '-1.4142135623730954' """ @@ -3208,9 +3223,9 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: - sage: RR(pi).__float__() + sage: RR(pi).__float__() # needs sage.symbolic 3.141592653589793 - sage: type(RR(pi).__float__()) + sage: type(RR(pi).__float__()) # needs sage.symbolic <... 'float'> """ return mpfr_get_d(self.value, (self._parent).rnd) @@ -3236,9 +3251,9 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: - sage: RR(pi).__int__() + sage: RR(pi).__int__() # needs sage.symbolic 3 - sage: type(RR(pi).__int__()) + sage: type(RR(pi).__int__()) # needs sage.symbolic <... 'int'> """ if not mpfr_number_p(self.value): @@ -3254,9 +3269,9 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: - sage: RR(pi).__complex__() + sage: RR(pi).__complex__() # needs sage.symbolic (3.141592653589793+0j) - sage: type(RR(pi).__complex__()) + sage: type(RR(pi).__complex__()) # needs sage.symbolic <... 'complex'> """ @@ -3268,9 +3283,9 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: - sage: RR(pi)._complex_number_() + sage: RR(pi)._complex_number_() # needs sage.symbolic 3.14159265358979 - sage: parent(RR(pi)._complex_number_()) + sage: parent(RR(pi)._complex_number_()) # needs sage.symbolic Complex Field with 53 bits of precision """ from sage.rings.complex_mpfr import ComplexField @@ -3282,12 +3297,13 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: + sage: # needs sage.symbolic sage: R = RealField(100) sage: R(pi) 3.1415926535897932384626433833 - sage: axiom(R(pi)) # optional - axiom # indirect doctest + sage: axiom(R(pi)) # indirect doctest # optional - axiom 3.1415926535 8979323846 26433833 - sage: fricas(R(pi)) # optional - fricas + sage: fricas(R(pi)) # optional - fricas 3.1415926535_8979323846_26433833 """ @@ -3308,13 +3324,14 @@ cdef class RealNumber(sage.structure.element.RingElement): EXAMPLES:: - sage: RR(2.0).__pari__() + sage: RR(2.0).__pari__() # needs sage.libs.pari 2.00000000000000 The current Pari precision affects the printing of this number, but Pari does maintain the same 250-bit number on both 32-bit and 64-bit platforms:: + sage: # needs sage.libs.pari sage: RealField(250).pi().__pari__() 3.14159265358979 sage: RR(0.0).__pari__() @@ -3327,7 +3344,7 @@ cdef class RealNumber(sage.structure.element.RingElement): 1.41421356237309515 sage: RR(2.0).sqrt().__pari__().sage().prec() 64 - sage: RealField(70)(pi).__pari__().sage().prec() + sage: RealField(70)(pi).__pari__().sage().prec() # needs sage.symbolic 96 # 32-bit 128 # 64-bit sage: for i in range(100, 200): @@ -3337,14 +3354,15 @@ cdef class RealNumber(sage.structure.element.RingElement): Check that we create real zeros without mantissa:: - sage: RDF(0).__pari__().sizeword() + sage: RDF(0).__pari__().sizeword() # needs sage.libs.pari 2 - sage: RealField(100)(0.0).__pari__().sizeword() + sage: RealField(100)(0.0).__pari__().sizeword() # needs sage.libs.pari 2 Check that the largest and smallest exponents representable by PARI convert correctly:: + sage: # needs sage.libs.pari sage: a = pari(0.5) << (sys.maxsize+1)/4 sage: RR(a) >> (sys.maxsize+1)/4 0.500000000000000 @@ -3504,7 +3522,7 @@ cdef class RealNumber(sage.structure.element.RingElement): 42391158275216203520420085760 sage: RR(3^60).exact_rational() - 3^60 6125652559 - sage: RealField(5)(-pi).exact_rational() + sage: RealField(5)(-pi).exact_rational() # needs sage.symbolic -25/8 TESTS:: @@ -3608,9 +3626,9 @@ cdef class RealNumber(sage.structure.element.RingElement): -1/3 sage: check(RR(-1/3)) -1/3 - sage: check(RealField(20)(pi)) + sage: check(RealField(20)(pi)) # needs sage.symbolic 355/113 - sage: check(RR(pi)) + sage: check(RR(pi)) # needs sage.symbolic 245850922/78256779 sage: check(RR(2).sqrt()) 131836323/93222358 @@ -3774,6 +3792,8 @@ cdef class RealNumber(sage.structure.element.RingElement): -333/1000 sage: RR(3/4).nearby_rational(max_denominator=2) 1 + + sage: # needs sage.symbolic sage: RR(pi).nearby_rational(max_denominator=120) 355/113 sage: RR(pi).nearby_rational(max_denominator=10000) @@ -3782,6 +3802,7 @@ cdef class RealNumber(sage.structure.element.RingElement): 312689/99532 sage: RR(pi).nearby_rational(max_denominator=1) 3 + sage: RR(-3.5).nearby_rational(max_denominator=1) -3 @@ -4084,7 +4105,7 @@ cdef class RealNumber(sage.structure.element.RingElement): True sage: RR('-100').is_real() True - sage: RR(NaN).is_real() + sage: RR(NaN).is_real() # needs sage.symbolic False """ return not mpfr_nan_p(self.value) @@ -4229,7 +4250,7 @@ cdef class RealNumber(sage.structure.element.RingElement): :: sage: r = 4344 - sage: r.sqrt() + sage: r.sqrt() # needs sage.symbolic 2*sqrt(1086) :: @@ -4345,10 +4366,10 @@ cdef class RealNumber(sage.structure.element.RingElement): We raise a real number to a symbolic object:: - sage: x, y = var('x,y') - sage: 1.5^x + sage: x, y = var('x,y') # needs sage.symbolic + sage: 1.5^x # needs sage.symbolic 1.50000000000000^x - sage: -2.3^(x+y^3+sin(x)) + sage: -2.3^(x+y^3+sin(x)) # needs sage.symbolic -2.30000000000000^(y^3 + x + sin(x)) TESTS: @@ -4406,21 +4427,21 @@ cdef class RealNumber(sage.structure.element.RingElement): 0.693147180559945 sage: log(RR(2), "e") 0.693147180559945 - sage: log(RR(2), e) + sage: log(RR(2), e) # needs sage.symbolic 0.693147180559945 :: sage: r = R(-1); r.log() 3.14159265358979*I - sage: log(RR(-1),e) + sage: log(RR(-1), e) # needs sage.symbolic 3.14159265358979*I sage: r.log(2) 4.53236014182719*I For the error value NaN (Not A Number), log will return NaN:: - sage: r = R(NaN); r.log() + sage: r = R(NaN); r.log() # needs sage.symbolic NaN """ @@ -5109,8 +5130,8 @@ cdef class RealNumber(sage.structure.element.RingElement): :: sage: m = (a-b)^2/(a+b)^2 - sage: E = numerical_integral(1/sqrt(1-m*sin(x)^2), 0, RR.pi()/2)[0] - sage: RR.pi()/4 * (a+b)/E + sage: E = numerical_integral(1/sqrt(1-m*sin(x)^2), 0, RR.pi()/2)[0] # needs sage.symbolic + sage: RR.pi()/4 * (a+b)/E # needs sage.symbolic 1.96811775182478 TESTS:: @@ -5340,11 +5361,11 @@ cdef class RealNumber(sage.structure.element.RingElement): Computing zeta using PARI is much more efficient in difficult cases. Here's how to compute zeta with at least a given precision:: - sage: z = pari(2).zeta(precision=53); z + sage: z = pari(2).zeta(precision=53); z # needs sage.libs.pari 1.64493406684823 - sage: pari(2).zeta(precision=128).sage().prec() + sage: pari(2).zeta(precision=128).sage().prec() # needs sage.libs.pari 128 - sage: pari(2).zeta(precision=65).sage().prec() + sage: pari(2).zeta(precision=65).sage().prec() # needs sage.libs.pari 128 # 64-bit 96 # 32-bit @@ -5356,9 +5377,9 @@ cdef class RealNumber(sage.structure.element.RingElement): :: - sage: type(z) + sage: type(z) # needs sage.libs.pari - sage: R(z) + sage: R(z) # needs sage.libs.pari 1.64493406684823 """ cdef RealNumber x = self._new() @@ -5511,8 +5532,11 @@ cdef class RealNumber(sage.structure.element.RingElement): sage: check(RealField(20)(22/7), 19) [1.0621, 1.0621, 1.0622, 1.0621] - sage: check(RealField(200)(e), 4) - [1.2840254166877414840734205680624364583362808652814630892175, 1.2840254166877414840734205680624364583362808652814630892175, 1.2840254166877414840734205680624364583362808652814630892176, 1.2840254166877414840734205680624364583362808652814630892175] + sage: check(RealField(200)(e), 4) # needs sage.symbolic + [1.2840254166877414840734205680624364583362808652814630892175, + 1.2840254166877414840734205680624364583362808652814630892175, + 1.2840254166877414840734205680624364583362808652814630892176, + 1.2840254166877414840734205680624364583362808652814630892175] Check that :trac:`12105` is fixed:: @@ -5925,7 +5949,7 @@ def is_RealNumber(x): False sage: is_RealNumber(RDF(2)) False - sage: is_RealNumber(pi) + sage: is_RealNumber(pi) # needs sage.symbolic False """ return isinstance(x, RealNumber) diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx index 8acf4383270..5273891a5b0 100644 --- a/src/sage/rings/ring.pyx +++ b/src/sage/rings/ring.pyx @@ -132,9 +132,9 @@ cdef class Ring(ParentWithGens): running ._test_some_elements() . . . pass running ._test_zero() . . . pass running ._test_zero_divisors() . . . pass - sage: TestSuite(QQ['x','y']).run(skip='_test_elements') - sage: TestSuite(ZZ['x','y']).run(skip='_test_elements') - sage: TestSuite(ZZ['x','y']['t']).run() + sage: TestSuite(QQ['x','y']).run(skip='_test_elements') # needs sage.libs.singular + sage: TestSuite(ZZ['x','y']).run(skip='_test_elements') # needs sage.libs.singular + sage: TestSuite(ZZ['x','y']['t']).run() # needs sage.libs.singular Test against another bug fixed in :trac:`9944`:: @@ -142,36 +142,38 @@ cdef class Ring(ParentWithGens): Join of Category of euclidean domains and Category of commutative algebras over (number fields and quotient fields and metric spaces) and Category of infinite sets sage: QQ['x','y'].category() - Join of Category of unique factorization domains and Category of commutative algebras over - (number fields and quotient fields and metric spaces) and Category of infinite sets - sage: PolynomialRing(MatrixSpace(QQ,2),'x').category() + Join of Category of unique factorization domains + and Category of commutative algebras + over (number fields and quotient fields and metric spaces) + and Category of infinite sets + sage: PolynomialRing(MatrixSpace(QQ, 2),'x').category() # needs sage.modules Category of infinite algebras over (finite dimensional algebras with basis over (number fields and quotient fields and metric spaces) and infinite sets) - sage: PolynomialRing(SteenrodAlgebra(2),'x').category() + sage: PolynomialRing(SteenrodAlgebra(2),'x').category() # needs sage.combinat sage.modules Category of infinite algebras over (super hopf algebras with basis over Finite Field of size 2 and supercocommutative super coalgebras over Finite Field of size 2) TESTS:: - sage: Zp(7)._repr_option('element_is_atomic') + sage: Zp(7)._repr_option('element_is_atomic') # needs sage.rings.padics False sage: QQ._repr_option('element_is_atomic') True - sage: CDF._repr_option('element_is_atomic') + sage: CDF._repr_option('element_is_atomic') # needs sage.rings.complex_double False Check that categories correctly implement `is_finite` and `cardinality`:: sage: QQ.is_finite() False - sage: GF(2^10, 'a').is_finite() # optional - sage.rings.finite_rings + sage: GF(2^10, 'a').is_finite() # needs sage.rings.finite_rings True - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: R.is_finite() # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: R.is_finite() False - sage: S. = R.quo(x^2 + 1) # optional - sage.rings.finite_rings - sage: S.is_finite() # optional - sage.rings.finite_rings + sage: S. = R.quo(x^2 + 1) # needs sage.rings.finite_rings + sage: S.is_finite() # needs sage.rings.finite_rings True sage: Integers(7).cardinality() @@ -255,11 +257,11 @@ cdef class Ring(ParentWithGens): """ EXAMPLES:: - sage: QQ.base_extend(GF(7)) # optional - sage.rings.finite_rings + sage: QQ.base_extend(GF(7)) Traceback (most recent call last): ... TypeError: no base extension defined - sage: ZZ.base_extend(GF(7)) # optional - sage.rings.finite_rings + sage: ZZ.base_extend(GF(7)) Finite Field of size 7 """ if R.has_coerce_map_from(self): @@ -280,7 +282,7 @@ cdef class Ring(ParentWithGens): EXAMPLES:: - sage: FreeAlgebra(QQ, 3, 'x').category() # todo: use a ring which is not an algebra! # optional - sage.combinat sage.modules + sage: FreeAlgebra(QQ, 3, 'x').category() # todo: use a ring which is not an algebra! # needs sage.combinat sage.modules Category of algebras with basis over Rational Field Since a quotient of the integers is its own base ring, and during @@ -310,16 +312,17 @@ cdef class Ring(ParentWithGens): EXAMPLES:: - sage: F. = FreeAlgebra(ZZ, 3) # optional - sage.combinat sage.modules - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F # optional - sage.combinat sage.modules - sage: Q = F.quotient(I) # optional - sage.combinat sage.modules - sage: Q.ideal_monoid() # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.modules + sage: F. = FreeAlgebra(ZZ, 3) + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F + sage: Q = F.quotient(I) + sage: Q.ideal_monoid() Monoid of ideals of Quotient of Free Algebra on 3 generators (x, y, z) over Integer Ring by the ideal (x*y + y*z, x^2 + x*y - y*x - y^2) - sage: F. = FreeAlgebra(ZZ, implementation='letterplace') # optional - sage.combinat sage.modules - sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F # optional - sage.combinat sage.modules - sage: Q = F.quo(I) # optional - sage.combinat sage.modules - sage: Q.ideal_monoid() # optional - sage.combinat sage.modules + sage: F. = FreeAlgebra(ZZ, implementation='letterplace') + sage: I = F * [x*y + y*z, x^2 + x*y - y*x - y^2] * F + sage: Q = F.quo(I) + sage: Q.ideal_monoid() Monoid of ideals of Quotient of Free Associative Unital Algebra on 3 generators (x, y, z) over Integer Ring by the ideal (x*y + y*z, x*x + x*y - y*x - y*y) @@ -366,10 +369,10 @@ cdef class Ring(ParentWithGens): Here is an example over a non-commutative ring:: - sage: A = SteenrodAlgebra(2) # optional - sage.combinat sage.modules - sage: A.ideal(A.1, A.2^2) # optional - sage.combinat sage.modules + sage: A = SteenrodAlgebra(2) # needs sage.combinat sage.modules + sage: A.ideal(A.1, A.2^2) # needs sage.combinat sage.modules Twosided Ideal (Sq(2), Sq(2,2)) of mod 2 Steenrod algebra, milnor basis - sage: A.ideal(A.1, A.2^2, side='left') # optional - sage.combinat sage.modules + sage: A.ideal(A.1, A.2^2, side='left') # needs sage.combinat sage.modules Left Ideal (Sq(2), Sq(2,2)) of mod 2 Steenrod algebra, milnor basis TESTS: @@ -448,22 +451,23 @@ cdef class Ring(ParentWithGens): EXAMPLES:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: (x + y) * R # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: (x + y) * R Ideal (x + y) of Multivariate Polynomial Ring in x, y, z over Finite Field of size 7 - sage: (x + y, z + y^3) * R # optional - sage.rings.finite_rings + sage: (x + y, z + y^3) * R Ideal (x + y, y^3 + z) of Multivariate Polynomial Ring in x, y, z over Finite Field of size 7 The following was implemented in :trac:`7797`:: - sage: A = SteenrodAlgebra(2) # optional - sage.combinat sage.modules - sage: A * [A.1 + A.2, A.1^2] # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.modules + sage: A = SteenrodAlgebra(2) + sage: A * [A.1 + A.2, A.1^2] Left Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis - sage: [A.1 + A.2, A.1^2] * A # optional - sage.combinat sage.modules + sage: [A.1 + A.2, A.1^2] * A Right Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis - sage: A * [A.1 + A.2, A.1^2] * A # optional - sage.combinat sage.modules + sage: A * [A.1 + A.2, A.1^2] * A Twosided Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis """ @@ -521,24 +525,24 @@ cdef class Ring(ParentWithGens): sage: RR._ideal_class_() - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: R._ideal_class_(1) # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: R._ideal_class_(1) - sage: S = R.quo(x^3 - y^2) # optional - sage.rings.finite_rings - sage: S._ideal_class_(1) # optional - sage.rings.finite_rings + sage: S = R.quo(x^3 - y^2) + sage: S._ideal_class_(1) - sage: S._ideal_class_(2) # optional - sage.rings.finite_rings + sage: S._ideal_class_(2) - sage: T. = S[] # optional - sage.rings.finite_rings - sage: T._ideal_class_(5) # optional - sage.rings.finite_rings + sage: T. = S[] # needs sage.rings.finite_rings + sage: T._ideal_class_(5) # needs sage.rings.finite_rings - sage: T._ideal_class_(1) # optional - sage.rings.finite_rings + sage: T._ideal_class_(1) # needs sage.rings.finite_rings Since :trac:`7797`, non-commutative rings have ideals as well:: - sage: A = SteenrodAlgebra(2) - sage: A._ideal_class_() + sage: A = SteenrodAlgebra(2) # needs sage.combinat sage.modules + sage: A._ideal_class_() # needs sage.combinat sage.modules """ @@ -576,7 +580,7 @@ cdef class Ring(ParentWithGens): EXAMPLES:: - sage: Zp(7).unit_ideal() # optional - sage.rings.padics + sage: Zp(7).unit_ideal() # needs sage.rings.padics Principal ideal (1 + O(7^20)) of 7-adic Ring with capped relative precision 20 """ if self._unit_ideal is None: @@ -607,10 +611,11 @@ cdef class Ring(ParentWithGens): Make sure that :trac:`13644` is fixed:: - sage: K = Qp(3) # optional - sage.rings.padics - sage: R. = K[] # optional - sage.rings.padics - sage: L. = K.extension(a^2-3) # optional - sage.rings.padics - sage: L.ideal(a) # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: K = Qp(3) + sage: R. = K[] + sage: L. = K.extension(a^2-3) + sage: L.ideal(a) Principal ideal (1 + O(a^40)) of 3-adic Eisenstein Extension Field in a defined by a^2 - 3 """ @@ -678,8 +683,8 @@ cdef class Ring(ParentWithGens): True sage: QQ['x,y,z'].is_commutative() True - sage: Q. = QuaternionAlgebra(QQ, -1, -1) # optional - sage.combinat sage.modules - sage: Q.is_commutative() # optional - sage.combinat sage.modules + sage: Q. = QuaternionAlgebra(QQ, -1, -1) # needs sage.combinat sage.modules + sage: Q.is_commutative() # needs sage.combinat sage.modules False """ if self.is_zero(): @@ -706,7 +711,7 @@ cdef class Ring(ParentWithGens): sage: QQ.is_field() True - sage: GF(9, 'a').is_field() # optional - sage.rings.finite_rings + sage: GF(9, 'a').is_field() # needs sage.rings.finite_rings True sage: ZZ.is_field() False @@ -718,12 +723,12 @@ cdef class Ring(ParentWithGens): This illustrates the use of the ``proof`` parameter:: sage: R. = QQ[] - sage: S. = R.quo((b^3)) # optional - sage.libs.singular - sage: S.is_field(proof=True) # optional - sage.libs.singular + sage: S. = R.quo((b^3)) # needs sage.libs.singular + sage: S.is_field(proof=True) # needs sage.libs.singular Traceback (most recent call last): ... NotImplementedError - sage: S.is_field(proof=False) # optional - sage.libs.singular + sage: S.is_field(proof=False) # needs sage.libs.singular False """ if self.is_zero(): @@ -750,9 +755,9 @@ cdef class Ring(ParentWithGens): True sage: ZZ.is_exact() True - sage: Qp(7).is_exact() # optional - sage.rings.padics + sage: Qp(7).is_exact() # needs sage.rings.padics False - sage: Zp(7, type='capped-abs').is_exact() # optional - sage.rings.padics + sage: Zp(7, type='capped-abs').is_exact() # needs sage.rings.padics False """ return True @@ -768,31 +773,31 @@ cdef class Ring(ParentWithGens): sage: ZZ.is_subring(QQ) True - sage: ZZ.is_subring(GF(19)) # optional - sage.rings.finite_rings + sage: ZZ.is_subring(GF(19)) False TESTS:: sage: QQ.is_subring(QQ['x']) True - sage: QQ.is_subring(GF(7)) # optional - sage.rings.finite_rings + sage: QQ.is_subring(GF(7)) False - sage: QQ.is_subring(CyclotomicField(7)) # optional - sage.rings.number_field + sage: QQ.is_subring(CyclotomicField(7)) # needs sage.rings.number_field True sage: QQ.is_subring(ZZ) False Every ring is a subring of itself, :trac:`17287`:: - sage: QQbar.is_subring(QQbar) # optional - sage.rings.number_field + sage: QQbar.is_subring(QQbar) # needs sage.rings.number_field True sage: RR.is_subring(RR) True - sage: CC.is_subring(CC) + sage: CC.is_subring(CC) # needs sage.rings.real_mpfr True sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - x + 1/10) # optional - sage.rings.number_field - sage: K.is_subring(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - x + 1/10) # needs sage.rings.number_field + sage: K.is_subring(K) # needs sage.rings.number_field True sage: R. = RR[] sage: R.is_subring(R) @@ -814,15 +819,15 @@ cdef class Ring(ParentWithGens): sage: QQ.is_prime_field() True - sage: GF(3).is_prime_field() # optional - sage.rings.finite_rings + sage: GF(3).is_prime_field() True - sage: GF(9, 'a').is_prime_field() # optional - sage.rings.finite_rings + sage: GF(9, 'a').is_prime_field() # needs sage.rings.finite_rings False sage: ZZ.is_prime_field() False sage: QQ['x'].is_prime_field() False - sage: Qp(19).is_prime_field() # optional - sage.rings.padics + sage: Qp(19).is_prime_field() # needs sage.rings.padics False """ return False @@ -853,24 +858,24 @@ cdef class Ring(ParentWithGens): True sage: Integers(8).is_integral_domain() False - sage: Zp(7).is_integral_domain() # optional - sage.rings.padics + sage: Zp(7).is_integral_domain() # needs sage.rings.padics True - sage: Qp(7).is_integral_domain() # optional - sage.rings.padics + sage: Qp(7).is_integral_domain() # needs sage.rings.padics True sage: R. = QQ[] - sage: S. = R.quo((b^3)) # optional - sage.libs.singular - sage: S.is_integral_domain() # optional - sage.libs.singular + sage: S. = R.quo((b^3)) # needs sage.libs.singular + sage: S.is_integral_domain() # needs sage.libs.singular False This illustrates the use of the ``proof`` parameter:: sage: R. = ZZ[] - sage: S. = R.quo((b^3)) # optional - sage.libs.singular - sage: S.is_integral_domain(proof=True) # optional - sage.libs.singular + sage: S. = R.quo((b^3)) # needs sage.libs.singular + sage: S.is_integral_domain(proof=True) # needs sage.libs.singular Traceback (most recent call last): ... NotImplementedError - sage: S.is_integral_domain(proof=False) # optional - sage.libs.singular + sage: S.is_integral_domain(proof=False) # needs sage.libs.singular False TESTS: @@ -878,21 +883,22 @@ cdef class Ring(ParentWithGens): Make sure :trac:`10481` is fixed:: sage: x = polygen(ZZ, 'x') - sage: R. = ZZ['x'].quo(x^2) # optional - sage.libs.pari - sage: R.fraction_field() + sage: R. = ZZ['x'].quo(x^2) # needs sage.libs.pari + sage: R.fraction_field() # needs sage.libs.pari Traceback (most recent call last): ... TypeError: self must be an integral domain. - sage: R.is_integral_domain() + sage: R.is_integral_domain() # needs sage.libs.pari False Forward the proof flag to ``is_field``, see :trac:`22910`:: - sage: R1. = GF(5)[] # optional - sage.rings.finite_rings - sage: F1 = R1.quotient_ring(x^2 + x + 1) # optional - sage.rings.finite_rings - sage: R2. = F1[] # optional - sage.rings.finite_rings - sage: F2 = R2.quotient_ring(x^2 + x + 1) # optional - sage.rings.finite_rings - sage: F2.is_integral_domain(False) # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: R1. = GF(5)[] + sage: F1 = R1.quotient_ring(x^2 + x + 1) + sage: R2. = F1[] + sage: F2 = R2.quotient_ring(x^2 + x + 1) + sage: F2.is_integral_domain(False) False """ if self.is_field(proof): @@ -925,7 +931,7 @@ cdef class Ring(ParentWithGens): EXAMPLES:: - sage: GF(19).order() # optional - sage.rings.finite_rings + sage: GF(19).order() 19 sage: QQ.order() +Infinity @@ -957,29 +963,32 @@ cdef class Ring(ParentWithGens): -1 sage: QQ.zeta(1) 1 - sage: CyclotomicField(6).zeta(6) # optional - sage.rings.number_field + sage: CyclotomicField(6).zeta(6) # needs sage.rings.number_field zeta6 - sage: CyclotomicField(3).zeta(3) # optional - sage.rings.number_field + sage: CyclotomicField(3).zeta(3) # needs sage.rings.number_field zeta3 - sage: CyclotomicField(3).zeta(3).multiplicative_order() # optional - sage.rings.number_field + sage: CyclotomicField(3).zeta(3).multiplicative_order() # needs sage.rings.number_field 3 - sage: a = GF(7).zeta(); a # optional - sage.rings.finite_rings + + sage: # needs sage.rings.finite_rings + sage: a = GF(7).zeta(); a 3 - sage: a.multiplicative_order() # optional - sage.rings.finite_rings + sage: a.multiplicative_order() 6 - sage: a = GF(49,'z').zeta(); a # optional - sage.rings.finite_rings + sage: a = GF(49,'z').zeta(); a z - sage: a.multiplicative_order() # optional - sage.rings.finite_rings + sage: a.multiplicative_order() 48 - sage: a = GF(49,'z').zeta(2); a # optional - sage.rings.finite_rings + sage: a = GF(49,'z').zeta(2); a 6 - sage: a.multiplicative_order() # optional - sage.rings.finite_rings + sage: a.multiplicative_order() 2 + sage: QQ.zeta(3) Traceback (most recent call last): ... ValueError: no n-th root of unity in rational field - sage: Zp(7, prec=8).zeta() # optional - sage.rings.padics + sage: Zp(7, prec=8).zeta() # needs sage.rings.padics 3 + 4*7 + 6*7^2 + 3*7^3 + 2*7^5 + 6*7^6 + 2*7^7 + O(7^8) TESTS:: @@ -989,7 +998,7 @@ cdef class Ring(ParentWithGens): 1 sage: Ring.zeta(QQ, 2) -1 - sage: Ring.zeta(QQ, 3) # optional - sage.libs.pari + sage: Ring.zeta(QQ, 3) # needs sage.libs.pari Traceback (most recent call last): ... ValueError: no 3rd root of unity in Rational Field @@ -1026,13 +1035,13 @@ cdef class Ring(ParentWithGens): EXAMPLES:: - sage: CyclotomicField(19).zeta_order() # optional - sage.rings.number_field + sage: CyclotomicField(19).zeta_order() # needs sage.rings.number_field 38 - sage: GF(19).zeta_order() # optional - sage.rings.finite_rings + sage: GF(19).zeta_order() 18 - sage: GF(5^3,'a').zeta_order() # optional - sage.rings.finite_rings + sage: GF(5^3,'a').zeta_order() # needs sage.rings.finite_rings 124 - sage: Zp(7, prec=8).zeta_order() # optional - sage.rings.padics + sage: Zp(7, prec=8).zeta_order() # needs sage.rings.padics 6 """ return self.zeta().multiplicative_order() @@ -1123,9 +1132,9 @@ cdef class Ring(ParentWithGens): sage: RDF.epsilon() 2.220446049250313e-16 - sage: ComplexField(53).epsilon() + sage: ComplexField(53).epsilon() # needs sage.rings.real_mpfr 2.22044604925031e-16 - sage: RealField(10).epsilon() + sage: RealField(10).epsilon() # needs sage.rings.real_mpfr 0.0020 For exact rings, zero is returned:: @@ -1135,14 +1144,14 @@ cdef class Ring(ParentWithGens): This also works over derived rings:: - sage: RR['x'].epsilon() + sage: RR['x'].epsilon() # needs sage.rings.real_mpfr 2.22044604925031e-16 sage: QQ['x'].epsilon() 0 For the symbolic ring, there is no reasonable answer:: - sage: SR.epsilon() # optional - sage.symbolics + sage: SR.epsilon() # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError @@ -1200,11 +1209,11 @@ cdef class CommutativeRing(Ring): EXAMPLES:: - sage: R. = GF(3)[] # optional - sage.rings.finite_rings - sage: R.localization((x*y, x**2 + y**2)) # optional - sage.rings.finite_rings + sage: R. = GF(3)[] + sage: R.localization((x*y, x**2 + y**2)) # needs sage.rings.finite_rings Multivariate Polynomial Ring in x, y over Finite Field of size 3 localized at (y, x, x^2 + y^2) - sage: ~y in _ # optional - sage.rings.finite_rings + sage: ~y in _ # needs sage.rings.finite_rings True """ if not self.is_integral_domain(): @@ -1278,11 +1287,11 @@ cdef class CommutativeRing(Ring): sage: QQ.is_commutative() True - sage: ZpCA(7).is_commutative() # optional - sage.rings.padics + sage: ZpCA(7).is_commutative() # needs sage.rings.padics True - sage: A = QuaternionAlgebra(QQ, -1, -3, names=('i','j','k')); A # optional - sage.combinat sage.modules + sage: A = QuaternionAlgebra(QQ, -1, -3, names=('i','j','k')); A # needs sage.combinat sage.modules Quaternion Algebra (-1, -3) with base ring Rational Field - sage: A.is_commutative() # optional - sage.combinat sage.modules + sage: A.is_commutative() # needs sage.combinat sage.modules False """ return True @@ -1318,18 +1327,19 @@ cdef class CommutativeRing(Ring): All orders in number fields have Krull dimension 1, including non-maximal orders:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: R = K.maximal_order(); R # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: R = K.maximal_order(); R Gaussian Integers in Number Field in i with defining polynomial x^2 + 1 with i = 1*I - sage: R.krull_dimension() # optional - sage.rings.number_field + sage: R.krull_dimension() 1 - sage: R = K.order(2*i); R # optional - sage.rings.number_field + sage: R = K.order(2*i); R Order in Number Field in i with defining polynomial x^2 + 1 with i = 1*I - sage: R.is_maximal() # optional - sage.rings.number_field + sage: R.is_maximal() False - sage: R.krull_dimension() # optional - sage.rings.number_field + sage: R.krull_dimension() 1 """ raise NotImplementedError @@ -1374,16 +1384,17 @@ cdef class CommutativeRing(Ring): sage: R = QQ['x'] sage: y = polygen(R) - sage: R.extension(y^2 - 5, 'a') # optional - sage.libs.pari + sage: R.extension(y^2 - 5, 'a') # needs sage.libs.pari Univariate Quotient Polynomial Ring in a over Univariate Polynomial Ring in x over Rational Field with modulus a^2 - 5 :: - sage: P. = PolynomialRing(GF(5)) # optional - sage.rings.finite_rings - sage: F. = GF(5).extension(x^2 - 2) # optional - sage.rings.finite_rings - sage: P. = F[] # optional - sage.rings.finite_rings - sage: R. = F.extension(t^2 - a); R # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P. = PolynomialRing(GF(5)) + sage: F. = GF(5).extension(x^2 - 2) + sage: P. = F[] + sage: R. = F.extension(t^2 - a); R Univariate Quotient Polynomial Ring in b over Finite Field in a of size 5^2 with modulus b^2 + 4*a """ @@ -1421,19 +1432,19 @@ cdef class CommutativeRing(Ring): EXAMPLES:: - sage: K. = PowerSeriesRing(GF(5)) # optional - sage.rings.finite_rings - sage: Frob = K.frobenius_endomorphism(); Frob # optional - sage.rings.finite_rings + sage: K. = PowerSeriesRing(GF(5)) + sage: Frob = K.frobenius_endomorphism(); Frob Frobenius endomorphism x |--> x^5 of Power Series Ring in u over Finite Field of size 5 - sage: Frob(u) # optional - sage.rings.finite_rings + sage: Frob(u) u^5 We can specify a power:: - sage: f = K.frobenius_endomorphism(2); f # optional - sage.rings.finite_rings + sage: f = K.frobenius_endomorphism(2); f Frobenius endomorphism x |--> x^(5^2) of Power Series Ring in u over Finite Field of size 5 - sage: f(1+u) # optional - sage.rings.finite_rings + sage: f(1+u) 1 + u^25 """ from .morphism import FrobeniusEndomorphism_generic @@ -1468,21 +1479,21 @@ cdef class CommutativeRing(Ring): EXAMPLES:: sage: R. = QQ[] - sage: M = R.derivation_module(); M # optional - sage.modules + sage: M = R.derivation_module(); M # needs sage.modules Module of derivations over Multivariate Polynomial Ring in x, y, z over Rational Field - sage: M.gens() # optional - sage.modules + sage: M.gens() # needs sage.modules (d/dx, d/dy, d/dz) We can specify a different codomain:: sage: K = R.fraction_field() - sage: M = R.derivation_module(K); M # optional - sage.modules + sage: M = R.derivation_module(K); M # needs sage.modules Module of derivations from Multivariate Polynomial Ring in x, y, z over Rational Field to Fraction Field of Multivariate Polynomial Ring in x, y, z over Rational Field - sage: M.gen() / x # optional - sage.modules + sage: M.gen() / x # needs sage.modules 1/x*d/dx Here is an example with a non-canonical defining morphism:: @@ -1495,32 +1506,33 @@ cdef class CommutativeRing(Ring): Defn: x |--> 0 y |--> 1 z |--> 2 - sage: M = R.derivation_module(ev) # optional - sage.modules - sage: M # optional - sage.modules + sage: M = R.derivation_module(ev) # needs sage.modules + sage: M # needs sage.modules Module of derivations from Multivariate Polynomial Ring in x, y, z over Rational Field to Rational Field Elements in `M` acts as derivations at `(0,1,2)`:: - sage: Dx = M.gen(0); Dx # optional - sage.modules + sage: # needs sage.modules + sage: Dx = M.gen(0); Dx d/dx - sage: Dy = M.gen(1); Dy # optional - sage.modules + sage: Dy = M.gen(1); Dy d/dy - sage: Dz = M.gen(2); Dz # optional - sage.modules + sage: Dz = M.gen(2); Dz d/dz sage: f = x^2 + y^2 + z^2 - sage: Dx(f) # = 2*x evaluated at (0,1,2) # optional - sage.modules + sage: Dx(f) # = 2*x evaluated at (0,1,2) 0 - sage: Dy(f) # = 2*y evaluated at (0,1,2) # optional - sage.modules + sage: Dy(f) # = 2*y evaluated at (0,1,2) 2 - sage: Dz(f) # = 2*z evaluated at (0,1,2) # optional - sage.modules + sage: Dz(f) # = 2*z evaluated at (0,1,2) 4 An example with a twisting homomorphism:: sage: theta = R.hom([x^2, y^2, z^2]) - sage: M = R.derivation_module(twist=theta); M # optional - sage.modules + sage: M = R.derivation_module(twist=theta); M # needs sage.modules Module of twisted derivations over Multivariate Polynomial Ring in x, y, z over Rational Field (twisting morphism: x |--> x^2, y |--> y^2, z |--> z^2) @@ -1559,23 +1571,23 @@ cdef class CommutativeRing(Ring): EXAMPLES:: sage: R. = QQ[] - sage: R.derivation() # optional - sage.modules + sage: R.derivation() # needs sage.modules d/dx In that case, ``arg`` could be a generator:: - sage: R.derivation(y) # optional - sage.modules + sage: R.derivation(y) # needs sage.modules d/dy or a list of coefficients:: - sage: R.derivation([1,2,3]) # optional - sage.modules + sage: R.derivation([1,2,3]) # needs sage.modules d/dx + 2*d/dy + 3*d/dz It is not possible to define derivations with respect to a polynomial which is not a variable:: - sage: R.derivation(x^2) # optional - sage.modules + sage: R.derivation(x^2) # needs sage.modules Traceback (most recent call last): ... ValueError: unable to create the derivation @@ -1584,18 +1596,18 @@ cdef class CommutativeRing(Ring): sage: R. = QQ[] sage: theta = R.hom([x^2, y^2, z^2]) - sage: f = R.derivation(twist=theta); f # optional - sage.modules + sage: f = R.derivation(twist=theta); f # needs sage.modules 0 - sage: f.parent() # optional - sage.modules + sage: f.parent() # needs sage.modules Module of twisted derivations over Multivariate Polynomial Ring in x, y, z over Rational Field (twisting morphism: x |--> x^2, y |--> y^2, z |--> z^2) Specifying a scalar, the returned twisted derivation is the corresponding multiple of `\theta - id`:: - sage: R.derivation(1, twist=theta) # optional - sage.modules + sage: R.derivation(1, twist=theta) # needs sage.modules [x |--> x^2, y |--> y^2, z |--> z^2] - id - sage: R.derivation(x, twist=theta) # optional - sage.modules + sage: R.derivation(x, twist=theta) # needs sage.modules x*([x |--> x^2, y |--> y^2, z |--> z^2] - id) """ @@ -1713,9 +1725,9 @@ cdef class IntegralDomain(CommutativeRing): True sage: QQ.is_integrally_closed() True - sage: QQbar.is_integrally_closed() # optional - sage.rings.number_field + sage: QQbar.is_integrally_closed() # needs sage.rings.number_field True - sage: GF(5).is_integrally_closed() # optional - sage.rings.finite_rings + sage: GF(5).is_integrally_closed() True sage: Z5 = Integers(5); Z5 Ring of integers modulo 5 @@ -1732,7 +1744,7 @@ cdef class IntegralDomain(CommutativeRing): EXAMPLES:: - sage: GF(7).is_field() # optional - sage.rings.finite_rings + sage: GF(7).is_field() True The following examples have their own ``is_field`` implementations:: @@ -1803,9 +1815,9 @@ cdef class DedekindDomain(IntegralDomain): sage: ZZ.krull_dimension() 1 sage: x = polygen(ZZ, 'x') - sage: K = NumberField(x^2 + 1, 's') # optional - sage.rings.number_field - sage: OK = K.ring_of_integers() # optional - sage.rings.number_field - sage: OK.krull_dimension() # optional - sage.rings.number_field + sage: K = NumberField(x^2 + 1, 's') # needs sage.rings.number_field + sage: OK = K.ring_of_integers() # needs sage.rings.number_field + sage: OK.krull_dimension() # needs sage.rings.number_field 1 The following are not Dedekind domains but have @@ -1822,13 +1834,14 @@ cdef class DedekindDomain(IntegralDomain): sage: U.krull_dimension() 4 - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: R = K.order(2*i); R # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: R = K.order(2*i); R Order in Number Field in i with defining polynomial x^2 + 1 with i = 1*I - sage: R.is_maximal() # optional - sage.rings.number_field + sage: R.is_maximal() False - sage: R.krull_dimension() # optional - sage.rings.number_field + sage: R.krull_dimension() 1 """ return 1 @@ -1848,16 +1861,16 @@ cdef class DedekindDomain(IntegralDomain): sage: ZZ.is_integrally_closed() True sage: x = polygen(ZZ, 'x') - sage: K = NumberField(x^2 + 1, 's') # optional - sage.rings.number_field - sage: OK = K.ring_of_integers() # optional - sage.rings.number_field - sage: OK.is_integrally_closed() # optional - sage.rings.number_field + sage: K = NumberField(x^2 + 1, 's') # needs sage.rings.number_field + sage: OK = K.ring_of_integers() # needs sage.rings.number_field + sage: OK.is_integrally_closed() # needs sage.rings.number_field True These, however, are not Dedekind domains:: sage: QQ.is_integrally_closed() True - sage: S = ZZ[sqrt(5)]; S.is_integrally_closed() # optional - sage.rings.number_field sage.symbolic + sage: S = ZZ[sqrt(5)]; S.is_integrally_closed() # needs sage.rings.number_field sage.symbolic False sage: T. = PolynomialRing(QQ, 2); T Multivariate Polynomial Ring in x, y over Rational Field @@ -1872,13 +1885,14 @@ cdef class DedekindDomain(IntegralDomain): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K = NumberField(x^2 + 1, 's') # optional - sage.rings.number_field - sage: OK = K.ring_of_integers() # optional - sage.rings.number_field - sage: OK.integral_closure() # optional - sage.rings.number_field + sage: K = NumberField(x^2 + 1, 's') + sage: OK = K.ring_of_integers() + sage: OK.integral_closure() Gaussian Integers in Number Field in s with defining polynomial x^2 + 1 - sage: OK.integral_closure() == OK # optional - sage.rings.number_field + sage: OK.integral_closure() == OK True sage: QQ.integral_closure() == QQ @@ -1898,9 +1912,9 @@ cdef class DedekindDomain(IntegralDomain): sage: ZZ.is_noetherian() True sage: x = polygen(ZZ, 'x') - sage: K = NumberField(x^2 + 1, 's') # optional - sage.rings.number_field - sage: OK = K.ring_of_integers() # optional - sage.rings.number_field - sage: OK.is_noetherian() # optional - sage.rings.number_field + sage: K = NumberField(x^2 + 1, 's') # needs sage.rings.number_field + sage: OK = K.ring_of_integers() # needs sage.rings.number_field + sage: OK.is_noetherian() # needs sage.rings.number_field True sage: QQ.is_noetherian() True @@ -1924,7 +1938,7 @@ cdef class PrincipalIdealDomain(IntegralDomain): EXAMPLES:: - sage: Zp(5).is_noetherian() # optional - sage.rings.padics + sage: Zp(5).is_noetherian() # needs sage.rings.padics True """ return True @@ -1935,7 +1949,7 @@ cdef class PrincipalIdealDomain(IntegralDomain): EXAMPLES:: - sage: QQ.class_group() # optional - sage.groups + sage: QQ.class_group() # needs sage.groups Trivial Abelian group """ from sage.groups.abelian_gps.abelian_group import AbelianGroup @@ -1980,23 +1994,24 @@ cdef class PrincipalIdealDomain(IntegralDomain): over an extension ring. Note that ``gcd`` requires x and y to be coercible:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: S. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: f = (x - a)*(x + a); g = (x - a)*(x^2 - 2) # optional - sage.rings.number_field - sage: print(f); print(g) # optional - sage.rings.number_field + sage: S. = NumberField(x^2 - 2, 'a') + sage: f = (x - a)*(x + a); g = (x - a)*(x^2 - 2) + sage: print(f); print(g) x^2 - 2 x^3 - a*x^2 - 2*x + 2*a - sage: f in R # optional - sage.rings.number_field + sage: f in R True - sage: g in R # optional - sage.rings.number_field + sage: g in R False - sage: R.gcd(f, g) # optional - sage.rings.number_field + sage: R.gcd(f, g) Traceback (most recent call last): ... TypeError: Unable to coerce 2*a to a rational - sage: R.base_extend(S).gcd(f,g) # optional - sage.rings.number_field + sage: R.base_extend(S).gcd(f,g) x^2 - 2 - sage: R.base_extend(S).gcd(f, (x - a)*(x^2 - 3)) # optional - sage.rings.number_field + sage: R.base_extend(S).gcd(f, (x - a)*(x^2 - 3)) x - a """ if coerce: @@ -2089,7 +2104,7 @@ cpdef bint _is_Field(x) except -2: True sage: _is_Field(ZZ) False - sage: _is_Field(pAdicField(2)) # optional - sage.rings.padics + sage: _is_Field(pAdicField(2)) # needs sage.rings.padics True sage: _is_Field(5) False @@ -2131,14 +2146,14 @@ cdef class Field(PrincipalIdealDomain): sage: QQ.fraction_field() Rational Field - sage: RR.fraction_field() + sage: RR.fraction_field() # needs sage.rings.real_mpfr Real Field with 53 bits of precision - sage: CC.fraction_field() + sage: CC.fraction_field() # needs sage.rings.real_mpfr Complex Field with 53 bits of precision sage: x = polygen(ZZ, 'x') - sage: F = NumberField(x^2 + 1, 'i') # optional - sage.rings.number_field - sage: F.fraction_field() # optional - sage.rings.number_field + sage: F = NumberField(x^2 + 1, 'i') # needs sage.rings.number_field + sage: F.fraction_field() # needs sage.rings.number_field Number Field in i with defining polynomial x^2 + 1 """ return self @@ -2151,10 +2166,10 @@ cdef class Field(PrincipalIdealDomain): sage: QQ._pseudo_fraction_field() Rational Field - sage: K = GF(5) # optional - sage.rings.finite_rings - sage: K._pseudo_fraction_field() # optional - sage.rings.finite_rings + sage: K = GF(5) + sage: K._pseudo_fraction_field() Finite Field of size 5 - sage: K._pseudo_fraction_field() is K # optional - sage.rings.finite_rings + sage: K._pseudo_fraction_field() is K True """ return self @@ -2266,8 +2281,8 @@ cdef class Field(PrincipalIdealDomain): EXAMPLES:: - sage: k = GF(9, 'a') # optional - sage.rings.finite_rings - sage: k.prime_subfield() # optional - sage.rings.finite_rings + sage: k = GF(9, 'a') # needs sage.rings.finite_rings + sage: k.prime_subfield() # needs sage.rings.finite_rings Finite Field of size 3 """ if self.characteristic() == 0: @@ -2307,7 +2322,7 @@ cdef class Algebra(Ring): EXAMPLES:: - sage: A = Algebra(ZZ); A # optional - sage.modules + sage: A = Algebra(ZZ); A # needs sage.modules """ # This is a low-level class. For performance, we trust that the category @@ -2327,12 +2342,13 @@ cdef class Algebra(Ring): EXAMPLES:: - sage: A = Algebra(ZZ); A # optional - sage.modules + sage: # needs sage.modules + sage: A = Algebra(ZZ); A - sage: A.characteristic() # optional - sage.modules + sage: A.characteristic() 0 - sage: A = Algebra(GF(7^3, 'a')) # optional - sage.rings.finite_rings sage.modules - sage: A.characteristic() # optional - sage.rings.finite_rings sage.modules + sage: A = Algebra(GF(7^3, 'a')) # needs sage.rings.finite_rings + sage: A.characteristic() # needs sage.rings.finite_rings 7 """ return self.base_ring().characteristic() @@ -2347,16 +2363,17 @@ cdef class Algebra(Ring): EXAMPLES:: - sage: B = QuaternionAlgebra(2) # optional - sage.combinat sage.modules - sage: B.has_standard_involution() # optional - sage.combinat sage.modules + sage: # needs sage.combinat sage.modules + sage: B = QuaternionAlgebra(2) + sage: B.has_standard_involution() True sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x**2 - 2) # optional - sage.rings.number_field - sage: A = QuaternionAlgebra(K, -2, 5) # optional - sage.rings.number_field sage.combinat sage.modules - sage: A.has_standard_involution() # optional - sage.rings.number_field sage.combinat sage.modules + sage: K. = NumberField(x**2 - 2) # needs sage.rings.number_field + sage: A = QuaternionAlgebra(K, -2, 5) # needs sage.rings.number_field + sage: A.has_standard_involution() # needs sage.rings.number_field True - sage: L. = FreeAlgebra(QQ, 2) # optional - sage.combinat sage.modules - sage: L.has_standard_involution() # optional - sage.combinat sage.modules + sage: L. = FreeAlgebra(QQ, 2) + sage: L.has_standard_involution() Traceback (most recent call last): ... NotImplementedError: has_standard_involution is not implemented for this algebra @@ -2410,7 +2427,7 @@ cdef class CommutativeAlgebra(CommutativeRing): sage: sage.rings.ring.CommutativeAlgebra(QQ) - sage: sage.rings.ring.CommutativeAlgebra(QuaternionAlgebra(QQ, -1, -1)) # optional - sage.combinat sage.modules + sage: sage.rings.ring.CommutativeAlgebra(QuaternionAlgebra(QQ, -1, -1)) # needs sage.combinat sage.modules Traceback (most recent call last): ... TypeError: base ring must be a commutative ring @@ -2457,8 +2474,8 @@ def is_Ring(x): sage: from sage.rings.ring import is_Ring sage: is_Ring(ZZ) True - sage: MS = MatrixSpace(QQ, 2) # optional - sage.modules - sage: is_Ring(MS) # optional - sage.modules + sage: MS = MatrixSpace(QQ, 2) # needs sage.modules + sage: is_Ring(MS) # needs sage.modules True """ return x in _Rings diff --git a/src/sage/rings/ring_extension.pxd b/src/sage/rings/ring_extension.pxd index 1607dd6fc2e..9115f8d26f8 100644 --- a/src/sage/rings/ring_extension.pxd +++ b/src/sage/rings/ring_extension.pxd @@ -1,6 +1,5 @@ from sage.categories.map cimport Map from sage.rings.ring cimport CommutativeRing, CommutativeAlgebra -from sage.rings.ring_extension cimport RingExtension_generic cdef class RingExtension_generic(CommutativeAlgebra): diff --git a/src/sage/rings/ring_extension.pyx b/src/sage/rings/ring_extension.pyx index ddd675e8a3e..d9438aaa648 100644 --- a/src/sage/rings/ring_extension.pyx +++ b/src/sage/rings/ring_extension.pyx @@ -11,41 +11,40 @@ that is `L`. For example, the following line constructs the extension of finite fields `\mathbf{F}_{5^4}/\mathbf{F}_{5^2}`:: - sage: GF(5^4).over(GF(5^2)) + sage: GF(5^4).over(GF(5^2)) # needs sage.rings.finite_rings Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base By default, Sage reuses the canonical generator of the top ring (here `z_4 \in \mathbf{F}_{5^4}`), together with its name. However, the user can customize them by passing in appropriate arguments:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2) sage: k = GF(5^4) sage: z4 = k.gen() - sage: K. = k.over(F, gen = 1-z4) - sage: K + sage: K. = k.over(F, gen=1-z4); K Field in a with defining polynomial x^2 + z2*x + 4 over its base The base of the extension is available via the method :meth:`base` (or equivalently :meth:`base_ring`):: - sage: K.base() + sage: K.base() # needs sage.rings.finite_rings Finite Field in z2 of size 5^2 It is also possible to build an extension on top of another extension, obtaining this way a tower of extensions:: - sage: L. = GF(5^8).over(K) - sage: L + sage: L. = GF(5^8).over(K); L # needs sage.rings.finite_rings Field in b with defining polynomial x^2 + (4*z2 + 3*a)*x + 1 - a over its base - sage: L.base() + sage: L.base() # needs sage.rings.finite_rings Field in a with defining polynomial x^2 + z2*x + 4 over its base - sage: L.base().base() + sage: L.base().base() # needs sage.rings.finite_rings Finite Field in z2 of size 5^2 The method :meth:`bases` gives access to the complete list of rings in a tower:: - sage: L.bases() + sage: L.bases() # needs sage.rings.finite_rings [Field in b with defining polynomial x^2 + (4*z2 + 3*a)*x + 1 - a over its base, Field in a with defining polynomial x^2 + z2*x + 4 over its base, Finite Field in z2 of size 5^2] @@ -54,34 +53,34 @@ Once we have constructed an extension (or a tower of extensions), we have interesting methods attached to it. As a basic example, one can compute a basis of the top ring over any base in the tower:: - sage: L.basis_over(K) + sage: L.basis_over(K) # needs sage.rings.finite_rings [1, b] - sage: L.basis_over(F) + sage: L.basis_over(F) # needs sage.rings.finite_rings [1, a, b, a*b] When the base is omitted, the default is the natural base of the extension:: - sage: L.basis_over() + sage: L.basis_over() # needs sage.rings.finite_rings [1, b] The method :meth:`sage.rings.ring_extension_element.RingExtensionWithBasis.vector` computes the coordinates of an element according to the above basis:: - sage: u = a + 2*b + 3*a*b - sage: u.vector() # over K + sage: u = a + 2*b + 3*a*b # needs sage.rings.finite_rings + sage: u.vector() # over K # needs sage.rings.finite_rings (a, 2 + 3*a) - sage: u.vector(F) + sage: u.vector(F) # needs sage.rings.finite_rings (0, 1, 2, 3) One can also compute traces and norms with respect to any base of the tower:: + sage: # needs sage.rings.finite_rings sage: u.trace() # over K (2*z2 + 1) + (2*z2 + 1)*a sage: u.trace(F) z2 + 1 sage: u.trace().trace() # over K, then over F z2 + 1 - sage: u.norm() # over K (z2 + 1) + (4*z2 + 2)*a sage: u.norm(F) @@ -89,9 +88,9 @@ One can also compute traces and norms with respect to any base of the tower:: And minimal polynomials:: - sage: u.minpoly() + sage: u.minpoly() # needs sage.rings.finite_rings x^2 + ((3*z2 + 4) + (3*z2 + 4)*a)*x + (z2 + 1) + (4*z2 + 2)*a - sage: u.minpoly(F) + sage: u.minpoly(F) # needs sage.rings.finite_rings x^4 + (4*z2 + 4)*x^3 + x^2 + (z2 + 1)*x + 2*z2 + 2 @@ -157,17 +156,19 @@ def tower_bases(ring, degree): sage: S. = QQ[] sage: T. = S[] sage: tower_bases(T, False) - ([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, Univariate Polynomial Ring in x over Rational Field, Rational Field], []) sage: tower_bases(T, True) - ([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], [1]) - sage: K. = Qq(5^2) - sage: L. = K.extension(x^3 - 5) - sage: tower_bases(L, True) + sage: K. = Qq(5^2) # needs sage.rings.padics + sage: L. = K.extension(x^3 - 5) # needs sage.rings.padics + sage: tower_bases(L, True) # needs sage.rings.padics ([5-adic Eisenstein Extension Field in w defined by x^3 - 5 over its base field, 5-adic Unramified Extension Field in a defined by x^2 + 4*x + 2, 5-adic Field with capped relative precision 20], @@ -213,12 +214,12 @@ def common_base(K, L, degree): sage: from sage.rings.ring_extension import common_base - sage: common_base(GF(5^3), GF(5^7), False) + sage: common_base(GF(5^3), GF(5^7), False) # needs sage.rings.finite_rings Finite Field of size 5 - sage: common_base(GF(5^3), GF(5^7), True) + sage: common_base(GF(5^3), GF(5^7), True) # needs sage.rings.finite_rings (Finite Field of size 5, 3, 7) - sage: common_base(GF(5^3), GF(7^5), False) + sage: common_base(GF(5^3), GF(7^5), False) # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError: unable to find a common base @@ -336,13 +337,12 @@ class RingExtensionFactory(UniqueFactory): True sage: x = polygen(ZZ, 'x') - sage: K. = QQ.extension(x^2 - 2) - sage: E = K.over(QQ) - sage: E + sage: K. = QQ.extension(x^2 - 2) # needs sage.rings.number_field + sage: E = K.over(QQ); E # needs sage.rings.number_field Field in a with defining polynomial x^2 - 2 over its base - sage: E2. = K.over(QQ) - sage: E2 is E + sage: E2. = K.over(QQ) # needs sage.rings.number_field + sage: E2 is E # needs sage.rings.number_field False """ def create_key_and_extra_args(self, ring, defining_morphism=None, gens=None, names=None, constructors=None): @@ -378,16 +378,18 @@ class RingExtensionFactory(UniqueFactory): To: Rational Field Defn: 1 |--> 1, (), ()), {'constructors': [(, - {'is_backend_exposed': True, - 'print_options': {'print_elements_as': None, 'print_parent_as': None}})]}) + {'is_backend_exposed': True, + 'print_options': {'print_elements_as': None, + 'print_parent_as': None}})]}) - sage: RingExtension.create_key_and_extra_args(GF(5^4), GF(5^2), names=('a',)) + sage: RingExtension.create_key_and_extra_args(GF(5^4), GF(5^2), # needs sage.rings.finite_rings + ....: names=('a',)) ((Ring morphism: From: Finite Field in z2 of size 5^2 To: Finite Field in z4 of size 5^4 Defn: z2 |--> z4^3 + z4^2 + z4 + 3, (z4,), ('a',)), {'constructors': [(, - {'gen': z4, 'is_backend_exposed': True, 'names': ('a',)})]}) + {'gen': z4, 'is_backend_exposed': True, 'names': ('a',)})]}) """ use_generic_constructor = True is_backend_exposed = True @@ -536,9 +538,9 @@ cdef class RingExtension_generic(CommutativeAlgebra): .. NOTE: - The attribute `is_backend_exposed` is only used for printing; + The attribute ``is_backend_exposed`` is only used for printing; when it is ``False``, printing an element like its backend is - disabled (and a ``RuntimeError`` is raised when it would occur). + disabled (and a :class:`RuntimeError` is raised when it would occur). OUTPUT: @@ -560,8 +562,8 @@ cdef class RingExtension_generic(CommutativeAlgebra): ... TypeError: only commutative rings are accepted - sage: K = GF(5^3) - sage: K.over(K.frobenius_endomorphism()) + sage: K = GF(5^3) # needs sage.rings.finite_rings + sage: K.over(K.frobenius_endomorphism()) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: exotic defining morphism between two rings in the tower; consider using another variable name @@ -623,10 +625,10 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = QQ.extension(x^2 - 2) sage: E = K.over() # over QQ - sage: hasattr(E, 'automorphisms') True sage: E.automorphisms() @@ -661,10 +663,10 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: sage: x = polygen(ZZ, 'x') - sage: A. = QQ.extension(x^2 - 2) - sage: K. = A.over() + sage: A. = QQ.extension(x^2 - 2) # needs sage.rings.number_field + sage: K. = A.over() # needs sage.rings.number_field - sage: dir(K) + sage: dir(K) # needs sage.rings.number_field ['CartesianProduct', 'Element', 'Hom', @@ -693,8 +695,8 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES: - sage: E = GF(5^3).over() - sage: hash(E) # random + sage: E = GF(5^3).over() # needs sage.rings.finite_rings + sage: hash(E) # random # needs sage.rings.finite_rings 140257667982632 """ return hash_by_id(self) @@ -706,10 +708,10 @@ cdef class RingExtension_generic(CommutativeAlgebra): TESTS:: - sage: K = GF(7^3).over() - sage: type(K) + sage: K = GF(7^3).over() # needs sage.rings.finite_rings + sage: type(K) # needs sage.rings.finite_rings - sage: loads(dumps(K)) is K + sage: loads(dumps(K)) is K # needs sage.rings.finite_rings True """ (defining_morphism, gens, names) = self._factory_data[2] @@ -722,8 +724,8 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: - sage: E = GF(5^3).over() - sage: E.construction() + sage: E = GF(5^3).over() # needs sage.rings.finite_rings + sage: E.construction() # needs sage.rings.finite_rings """ # One could define a construction functor K' -> K' otimes_K L, but we leave this to another issue @@ -740,14 +742,15 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: - sage: K = GF(5^3) - sage: E = K.over() - sage: E - Field in z3 with defining polynomial x^3 + 3*x + 3 over its base - sage: E.backend() - Finite Field in z3 of size 5^3 - sage: E.backend() is K - True + sage: # needs sage.rings.finite_rings + sage: K = GF(5^3) + sage: E = K.over() + sage: E + Field in z3 with defining polynomial x^3 + 3*x + 3 over its base + sage: E.backend() + Finite Field in z3 of size 5^3 + sage: E.backend() is K + True """ if force or self._is_backend_exposed: @@ -764,15 +767,14 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: k = GF(5) sage: K. = GF(5^2).over(k) sage: L. = GF(5^4).over(K) - sage: x = L.from_base_ring(k(2)); x 2 sage: x.parent() Field in v with defining polynomial x^2 + (3 - u)*x + u over its base - sage: x = L.from_base_ring(u); x u sage: x.parent() @@ -797,6 +799,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: A. = GF(5^2).over() # over GF(5) sage: B. = GF(5^4).over(A) sage: C. = GF(5^12).over(B) @@ -804,15 +807,15 @@ cdef class RingExtension_generic(CommutativeAlgebra): Observe what happens when we modify the option ``over``:: + sage: # needs sage.rings.finite_rings sage: D - Field in d with defining polynomial x^2 + ((1 - a) + ((1 + 2*a) - b)*c + ((2 + a) + (1 - a)*b)*c^2)*x + c over its base - + Field in d with defining polynomial + x^2 + ((1 - a) + ((1 + 2*a) - b)*c + ((2 + a) + (1 - a)*b)*c^2)*x + c over its base sage: D.print_options(over=2) sage: D Field in d with defining polynomial x^2 + ((1 - a) + ((1 + 2*a) - b)*c + ((2 + a) + (1 - a)*b)*c^2)*x + c over Field in c with defining polynomial x^3 + (1 + (2 - a)*b)*x^2 + (2 + 2*b)*x - b over Field in b with defining polynomial x^2 + (3 - a)*x + a over its base - sage: D.print_options(over=Infinity) sage: D Field in d with defining polynomial x^2 + ((1 - a) + ((1 + 2*a) - b)*c + ((2 + a) + (1 - a)*b)*c^2)*x + c over @@ -823,15 +826,14 @@ cdef class RingExtension_generic(CommutativeAlgebra): Now the option ``base``:: + sage: # needs sage.rings.finite_rings sage: d^2 -c + ((-1 + a) + ((-1 + 3*a) + b)*c + ((3 - a) + (-1 + a)*b)*c^2)*d - sage: D.basis_over(B) [1, c, c^2, d, c*d, c^2*d] sage: D.print_options(base=B) sage: d^2 -c + (-1 + a)*d + ((-1 + 3*a) + b)*c*d + ((3 - a) + (-1 + a)*b)*c^2*d - sage: D.basis_over(A) [1, b, c, b*c, c^2, b*c^2, d, b*d, c*d, b*c*d, c^2*d, b*c^2*d] sage: D.print_options(base=A) @@ -1039,19 +1041,18 @@ cdef class RingExtension_generic(CommutativeAlgebra): TESTS:: + sage: # needs sage.rings.finite_rings sage: E1 = GF(3^6).over(GF(3^3)) sage: E1.coerce_map_from(GF(3^3)) # indirect doctest Ring morphism: From: Finite Field in z3 of size 3^3 To: Field in z6 with defining polynomial x^2 + (2*z3 + 1)*x + z3 over its base Defn: z3 |--> z3 - sage: E1.coerce_map_from(GF(3)) # indirect doctest Ring morphism: From: Finite Field of size 3 To: Field in z6 with defining polynomial x^2 + (2*z3 + 1)*x + z3 over its base Defn: 1 |--> 1 - sage: E2 = GF(3^18).over(GF(3^9)) sage: E2.coerce_map_from(E1) # indirect doctest Ring morphism: @@ -1061,6 +1062,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): A test with iterated extensions:: + sage: # needs sage.rings.finite_rings sage: A = GF(3^18).over(GF(3^3)) # simple extension GF(3^3) -> GF(3^18) sage: B = GF(3^18).over(E1) # iterated extension GF(3^3) -> GF(3^6) -> GF(3^18) sage: A.has_coerce_map_from(B) @@ -1085,17 +1087,17 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: - sage: F = GF(5^2) - sage: K = GF(5^4).over(F) - sage: K.base() + sage: F = GF(5^2) # needs sage.rings.finite_rings + sage: K = GF(5^4).over(F) # needs sage.rings.finite_rings + sage: K.base() # needs sage.rings.finite_rings Finite Field in z2 of size 5^2 In case of iterated extensions, the base is itself an extension:: - sage: L = GF(5^8).over(K) - sage: L.base() + sage: L = GF(5^8).over(K) # needs sage.rings.finite_rings + sage: L.base() # needs sage.rings.finite_rings Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base - sage: L.base() is K + sage: L.base() is K # needs sage.rings.finite_rings True .. SEEALSO:: @@ -1111,21 +1113,20 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2).over() # over GF(5) sage: K = GF(5^4).over(F) sage: L = GF(5^12).over(K) - sage: F.bases() [Field in z2 with defining polynomial x^2 + 4*x + 2 over its base, Finite Field of size 5] - sage: K.bases() [Field in z4 with defining polynomial x^2 + (3 - z2)*x + z2 over its base, Field in z2 with defining polynomial x^2 + 4*x + 2 over its base, Finite Field of size 5] - sage: L.bases() - [Field in z12 with defining polynomial x^3 + (1 + (2 - z2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base, + [Field in z12 with defining polynomial + x^3 + (1 + (2 - z2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base, Field in z4 with defining polynomial x^2 + (3 - z2)*x + z2 over its base, Field in z2 with defining polynomial x^2 + 4*x + 2 over its base, Finite Field of size 5] @@ -1150,10 +1151,10 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2).over() # over GF(5) sage: K = GF(5^4).over(F) sage: L = GF(5^12).over(K) - sage: F.absolute_base() Finite Field of size 5 sage: K.absolute_base() @@ -1179,14 +1180,15 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: A = GF(5^4).over(GF(5^2)) sage: B = GF(5^12).over(A) - sage: A.is_defined_over(GF(5^2)) True sage: A.is_defined_over(GF(5)) False + sage: # needs sage.rings.finite_rings sage: B.is_defined_over(A) True sage: B.is_defined_over(GF(5^4)) @@ -1198,9 +1200,9 @@ cdef class RingExtension_generic(CommutativeAlgebra): Note that an extension is defined over itself:: - sage: A.is_defined_over(A) + sage: A.is_defined_over(A) # needs sage.rings.finite_rings True - sage: A.is_defined_over(GF(5^4)) + sage: A.is_defined_over(GF(5^4)) # needs sage.rings.finite_rings True .. SEEALSO:: @@ -1231,6 +1233,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2) sage: K = GF(5^4).over(F) sage: L = GF(5^12).over(K) @@ -1238,7 +1241,6 @@ cdef class RingExtension_generic(CommutativeAlgebra): [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] - sage: L._check_base(K) Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base sage: L._check_base(GF(5^4)) @@ -1248,9 +1250,9 @@ cdef class RingExtension_generic(CommutativeAlgebra): When ``base`` is ``None``, the base of the extension is returned:: - sage: L._check_base(None) + sage: L._check_base(None) # needs sage.rings.finite_rings Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base - sage: L._check_base(None) is L.base() + sage: L._check_base(None) is L.base() # needs sage.rings.finite_rings True """ @@ -1276,32 +1278,32 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2) sage: K = GF(5^4).over(F) sage: L = GF(5^12).over(K) - sage: K.defining_morphism() Ring morphism: From: Finite Field in z2 of size 5^2 To: Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base Defn: z2 |--> z2 - sage: L.defining_morphism() Ring morphism: From: Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base - To: Field in z12 with defining polynomial x^3 + (1 + (4*z2 + 2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base + To: Field in z12 with defining polynomial + x^3 + (1 + (4*z2 + 2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base Defn: z4 |--> z4 One can also pass in a base over which the extension is explicitly defined (see also :meth:`is_defined_over`):: - sage: L.defining_morphism(F) + sage: L.defining_morphism(F) # needs sage.rings.finite_rings Ring morphism: From: Finite Field in z2 of size 5^2 - To: Field in z12 with defining polynomial x^3 + (1 + (4*z2 + 2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base + To: Field in z12 with defining polynomial + x^3 + (1 + (4*z2 + 2)*z4)*x^2 + (2 + 2*z4)*x - z4 over its base Defn: z2 |--> z2 - - sage: L.defining_morphism(GF(5)) + sage: L.defining_morphism(GF(5)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field of size 5 @@ -1338,6 +1340,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2).over() # over GF(5) sage: K.gens() (a,) @@ -1368,12 +1371,12 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^2).over() # over GF(5) sage: K.gens() (z2,) sage: K.ngens() 1 - sage: L = GF(5^4).over(K) sage: L.gens(GF(5)) (z4, z2) @@ -1388,15 +1391,15 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: - sage: K = GF(5^2).over() # over GF(5) - sage: x =K.gen(); x + sage: K = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: x = K.gen(); x # needs sage.rings.finite_rings z2 Observe that the generator lives in the extension:: - sage: x.parent() + sage: x.parent() # needs sage.rings.finite_rings Field in z2 with defining polynomial x^2 + 4*x + 2 over its base - sage: x.parent() is K + sage: x.parent() is K # needs sage.rings.finite_rings True """ return self.gens()[0] @@ -1407,10 +1410,10 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^2).over() # over GF(5) sage: x = K.random_element(); x # random 3 + z2 - sage: x.parent() Field in z2 with defining polynomial x^2 + 4*x + 2 over its base sage: x.parent() is K @@ -1430,10 +1433,10 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2) sage: K = GF(5^4).over(F) sage: L = GF(5^12).over(K) - sage: K.degree_over(F) 2 sage: L.degree_over(K) @@ -1444,15 +1447,15 @@ cdef class RingExtension_generic(CommutativeAlgebra): If ``base`` is omitted, the degree is computed over the base of the extension:: - sage: K.degree_over() + sage: K.degree_over() # needs sage.rings.finite_rings 2 - sage: L.degree_over() + sage: L.degree_over() # needs sage.rings.finite_rings 3 Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: K.degree_over(GF(5)) + sage: K.degree_over(GF(5)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field of size 5 @@ -1473,6 +1476,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): TESTS:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = QQ.extension(x^2 - 2) sage: B. = QQ.extension(x^6 - 2) @@ -1496,9 +1500,9 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: A = GF(5^4).over(GF(5^2)) sage: B = GF(5^12).over(A) - sage: A.degree(GF(5^2)) 2 sage: B.degree(A) @@ -1509,7 +1513,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: A.degree(GF(5)) + sage: A.degree(GF(5)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field of size 5 @@ -1526,8 +1530,8 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: - sage: A = GF(5^4).over(GF(5^2)) - sage: A.relative_degree() + sage: A = GF(5^4).over(GF(5^2)) # needs sage.rings.finite_rings + sage: A.relative_degree() # needs sage.rings.finite_rings 2 .. SEEALSO:: @@ -1542,9 +1546,9 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: A = GF(5^4).over(GF(5^2)) sage: B = GF(5^12).over(A) - sage: A.absolute_degree() 2 sage: B.absolute_degree() @@ -1567,9 +1571,9 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^2).over() # over GF(5) sage: L = GF(5^4).over(K) - sage: L.is_finite_over(K) True sage: L.is_finite_over(GF(5)) @@ -1578,7 +1582,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: L.is_finite_over() + sage: L.is_finite_over() # needs sage.rings.finite_rings True """ cdef CommutativeRing b @@ -1612,8 +1616,8 @@ cdef class RingExtension_generic(CommutativeAlgebra): TESTS:: - sage: K = GF(5^2).over() # over GF(5) - sage: K.is_finite_over() # indirect doctest + sage: K = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: K.is_finite_over() # indirect doctest # needs sage.rings.finite_rings True """ raise NotImplementedError @@ -1630,9 +1634,9 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^2).over() # over GF(5) sage: L = GF(5^4).over(K) - sage: L.is_free_over(K) True sage: L.is_free_over(GF(5)) @@ -1641,7 +1645,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: L.is_free_over() + sage: L.is_free_over() # needs sage.rings.finite_rings True """ cdef CommutativeRing b @@ -1675,8 +1679,8 @@ cdef class RingExtension_generic(CommutativeAlgebra): TESTS:: - sage: K = GF(5^2).over() # over GF(5) - sage: K.is_free_over() # indirect doctest + sage: K = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: K.is_free_over() # indirect doctest # needs sage.rings.finite_rings True """ raise NotImplementedError @@ -1691,8 +1695,8 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: - sage: K = GF(5^5).over() # over GF(5) - sage: K.is_field() + sage: K = GF(5^5).over() # over GF(5) # needs sage.rings.finite_rings + sage: K.is_field() # needs sage.rings.finite_rings True sage: S. = QQ[] @@ -1727,39 +1731,40 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = ZZ.extension(x^2 - 5) sage: OK = A.over() # over ZZ sage: OK Order in Number Field in a with defining polynomial x^2 - 5 over its base - - sage: K1 = OK.fraction_field() - sage: K1 - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base + sage: K1 = OK.fraction_field(); K1 + Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base sage: K1.bases() - [Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base, + [Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base, Order in Number Field in a with defining polynomial x^2 - 5 over its base, Integer Ring] - - sage: K2 = OK.fraction_field(extend_base=True) - sage: K2 - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base + sage: K2 = OK.fraction_field(extend_base=True); K2 + Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base sage: K2.bases() - [Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base, + [Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base, Rational Field] Note that there is no coercion between `K_1` and `K_2`:: - sage: K1.has_coerce_map_from(K2) + sage: K1.has_coerce_map_from(K2) # needs sage.rings.number_field False - sage: K2.has_coerce_map_from(K1) + sage: K2.has_coerce_map_from(K1) # needs sage.rings.number_field False We check that when the extension is a field, its fraction field does not change:: - sage: K1.fraction_field() is K1 + sage: K1.fraction_field() is K1 # needs sage.rings.number_field True - sage: K2.fraction_field() is K2 + sage: K2.fraction_field() is K2 # needs sage.rings.number_field True TESTS:: @@ -1790,8 +1795,8 @@ cdef class RingExtension_generic(CommutativeAlgebra): TESTS:: - sage: K = GF(5^2).over() - sage: K.fraction_field() # indirect doctest + sage: K = GF(5^2).over() # needs sage.rings.finite_rings + sage: K.fraction_field() # indirect doctest # needs sage.rings.finite_rings Field in z2 with defining polynomial x^2 + 4*x + 2 over its base sage: K = QQ.over(ZZ) @@ -1825,18 +1830,21 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2) sage: K = GF(5^4).over(F) sage: L = GF(5^12).over(F) - sage: K.Hom(L) # indirect doctest - Set of Homomorphisms from Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base - to Field in z12 with defining polynomial x^6 + (4*z2 + 3)*x^5 + x^4 + (3*z2 + 1)*x^3 + x^2 + (4*z2 + 1)*x + z2 over its base - + Set of Homomorphisms + from Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base + to Field in z12 with defining polynomial x^6 + (4*z2 + 3)*x^5 + x^4 + + (3*z2 + 1)*x^3 + x^2 + (4*z2 + 1)*x + z2 over its base sage: K.Hom(L, category=Sets()) - Set of Morphisms from Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base - to Field in z12 with defining polynomial x^6 + (4*z2 + 3)*x^5 + x^4 + (3*z2 + 1)*x^3 + x^2 + (4*z2 + 1)*x + z2 over its base - in Category of sets + Set of Morphisms + from Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base + to Field in z12 with defining polynomial x^6 + (4*z2 + 3)*x^5 + x^4 + + (3*z2 + 1)*x^3 + x^2 + (4*z2 + 1)*x + z2 over its base + in Category of sets """ from sage.rings.ring_extension_homset import RingExtensionHomset @@ -1869,43 +1877,44 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: - sage: K. = GF(5^2).over() # over GF(5) - sage: L. = GF(5^6).over(K) + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: L. = GF(5^6).over(K) # needs sage.rings.finite_rings We define (by hand) the relative Frobenius endomorphism of the extension `L/K`:: - sage: L.hom([b^25]) - Ring endomorphism of Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base + sage: L.hom([b^25]) # needs sage.rings.finite_rings + Ring endomorphism of + Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base Defn: b |--> 2 + 2*a*b + (2 - a)*b^2 Defining the absolute Frobenius of `L` is a bit more complicated because it is not a homomorphism of `K`-algebras. For this reason, the construction ``L.hom([b^5])`` fails:: - sage: L.hom([b^5]) + sage: L.hom([b^5]) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: images do not define a valid homomorphism What we need is to specify a base map:: - sage: FrobK = K.hom([a^5]) - sage: FrobL = L.hom([b^5], base_map=FrobK) - sage: FrobL - Ring endomorphism of Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base + sage: FrobK = K.hom([a^5]) # needs sage.rings.finite_rings + sage: FrobL = L.hom([b^5], base_map=FrobK); FrobL # needs sage.rings.finite_rings + Ring endomorphism of + Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base Defn: b |--> (-1 + a) + (1 + 2*a)*b + a*b^2 with map on base ring: a |--> 1 - a As a shortcut, we may use the following construction:: - sage: phi = L.hom([b^5, a^5]) - sage: phi - Ring endomorphism of Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base + sage: phi = L.hom([b^5, a^5]); phi # needs sage.rings.finite_rings + Ring endomorphism of + Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base Defn: b |--> (-1 + a) + (1 + 2*a)*b + a*b^2 with map on base ring: a |--> 1 - a - sage: phi == FrobL + sage: phi == FrobL # needs sage.rings.finite_rings True """ if codomain is None: @@ -1924,6 +1933,7 @@ cdef class RingExtension_generic(CommutativeAlgebra): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2).over() # over GF(5) sage: K = GF(5^4).over(F) sage: L = GF(5^12).over(K) @@ -1963,7 +1973,9 @@ cdef class RingExtension_generic(CommutativeAlgebra): sage: k = Frac(FqX) sage: K = k.over(FqX) sage: K.frobenius_endomorphism() - Frobenius endomorphism x |--> x^11 of Fraction Field of Univariate Polynomial Ring in X over Finite Field of size 11 over its base + Frobenius endomorphism x |--> x^11 of + Fraction Field of Univariate Polynomial Ring in X over + Finite Field of size 11 over its base """ return self._backend.characteristic() @@ -2003,13 +2015,13 @@ cdef class RingExtensionFractionField(RingExtension_generic): TESTS:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = ZZ.extension(x^2 - 2) sage: OK = A.over() - sage: K = OK.fraction_field() - sage: K - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 2 over its base - + sage: K = OK.fraction_field(); K + Fraction Field of + Order in Number Field in a with defining polynomial x^2 - 2 over its base sage: TestSuite(K).run() """ @@ -2025,13 +2037,13 @@ cdef class RingExtensionFractionField(RingExtension_generic): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = ZZ.extension(x^2 - 2) sage: OK = A.over() - sage: K = OK.fraction_field() - sage: K - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 2 over its base - + sage: K = OK.fraction_field(); K + Fraction Field of + Order in Number Field in a with defining polynomial x^2 - 2 over its base sage: K.ring() Order in Number Field in a with defining polynomial x^2 - 2 over its base sage: K.ring() is OK @@ -2045,11 +2057,11 @@ cdef class RingExtensionFractionField(RingExtension_generic): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = ZZ.extension(x^2 - 2) sage: OK = A.over() sage: K = OK.fraction_field() - sage: K._repr_topring() 'Fraction Field of Order in Number Field in a with defining polynomial x^2 - 2' """ @@ -2090,11 +2102,10 @@ cdef class RingExtensionWithBasis(RingExtension_generic): TESTS:: - sage: E = GF(5^4).over(GF(5^2)) - sage: E + sage: E = GF(5^4).over(GF(5^2)); E # needs sage.rings.finite_rings Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base - sage: TestSuite(E).run() + sage: TestSuite(E).run() # needs sage.rings.finite_rings """ Element = RingExtensionWithBasisElement @@ -2117,12 +2128,11 @@ cdef class RingExtensionWithBasis(RingExtension_generic): TESTS:: sage: x = polygen(ZZ, 'x') - sage: K. = QQ.extension(x^3 - 2) - sage: E = K.over() - sage: E + sage: K. = QQ.extension(x^3 - 2) # needs sage.rings.number_field + sage: E = K.over(); E # needs sage.rings.number_field Field in a with defining polynomial x^3 - 2 over its base - sage: TestSuite(E).run() + sage: TestSuite(E).run() # needs sage.rings.number_field """ RingExtension_generic.__init__(self, defining_morphism, **kwargs) self._basis = [ self(b) for b in basis ] @@ -2162,29 +2172,27 @@ cdef class RingExtensionWithBasis(RingExtension_generic): TESTS:: + sage: # needs sage.rings.finite_rings sage: F = GF(5) sage: K = GF(5^2).over(F) sage: L = GF(5^4).over(K) - sage: L._print_option_base(F) is F True sage: L._print_option_base(K) is K True sage: L._print_option_base(GF(5^2)) is K True - sage: L._print_option_base(None) is K True - sage: L._print_option_base(L) Traceback (most recent call last): ... ValueError: base must be strict - sage: K._print_option_base(L) Traceback (most recent call last): ... - ValueError: not (explicitly) defined over Field in z4 with defining polynomial x^2 + (3 - z2)*x + z2 over its base + ValueError: not (explicitly) defined over Field in z4 + with defining polynomial x^2 + (3 - z2)*x + z2 over its base """ if 'print_elements_as' in self._print_options: @@ -2210,6 +2218,7 @@ cdef class RingExtensionWithBasis(RingExtension_generic): TESTS:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = QQ.extension(x^2 - 2) sage: B. = QQ.extension(x^6 - 2) @@ -2236,8 +2245,8 @@ cdef class RingExtensionWithBasis(RingExtension_generic): TESTS:: - sage: K = GF(5^2).over() # over GF(5) - sage: K.is_finite_over() # indirect doctest + sage: K = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: K.is_finite_over() # indirect doctest # needs sage.rings.finite_rings True """ if base is self or base is self._base: @@ -2255,8 +2264,8 @@ cdef class RingExtensionWithBasis(RingExtension_generic): TESTS:: - sage: K = GF(5^2).over() # over GF(5) - sage: K.is_free_over() # indirect doctest + sage: K = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: K.is_free_over() # indirect doctest # needs sage.rings.finite_rings True """ if base is self or base is self._base: @@ -2274,32 +2283,30 @@ cdef class RingExtensionWithBasis(RingExtension_generic): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F. = GF(5^2).over() # over GF(5) sage: K. = GF(5^4).over(F) sage: L. = GF(5^12).over(K) - sage: L.basis_over(K) [1, c, c^2] - sage: L.basis_over(F) [1, b, c, b*c, c^2, b*c^2] - sage: L.basis_over(GF(5)) [1, a, b, a*b, c, a*c, b*c, a*b*c, c^2, a*c^2, b*c^2, a*b*c^2] If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: L.basis_over() + sage: L.basis_over() # needs sage.rings.finite_rings [1, c, c^2] - sage: K.basis_over() + sage: K.basis_over() # needs sage.rings.finite_rings [1, b] Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: L.degree_over(GF(5^6)) + sage: L.degree_over(GF(5^6)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z6 of size 5^6 @@ -2319,9 +2326,9 @@ cdef class RingExtensionWithBasis(RingExtension_generic): TESTS:: sage: x = polygen(ZZ, 'x') - sage: A. = QQ.extension(x^3 - 2) - sage: K. = A.over() - sage: K.basis_over() + sage: A. = QQ.extension(x^3 - 2) # needs sage.rings.number_field + sage: K. = A.over() # needs sage.rings.number_field + sage: K.basis_over() # needs sage.rings.number_field [1, u, u^2] """ if base is self: @@ -2359,25 +2366,30 @@ cdef class RingExtensionWithBasis(RingExtension_generic): EXAMPLES:: sage: F = GF(11) - sage: K. = GF(11^2).over() - sage: L. = GF(11^6).over(K) + sage: K. = GF(11^2).over() # needs sage.rings.finite_rings + sage: L. = GF(11^6).over(K) # needs sage.rings.finite_rings Forgetting a part of the multiplicative structure, the field L can be viewed as a vector space of dimension 3 over K, equipped with a distinguished basis, namely `(1, b, b^2)`:: + sage: # needs sage.rings.finite_rings sage: V, i, j = L.free_module(K) sage: V - Vector space of dimension 3 over Field in a with defining polynomial x^2 + 7*x + 2 over its base + Vector space of dimension 3 over + Field in a with defining polynomial x^2 + 7*x + 2 over its base sage: i Generic map: - From: Vector space of dimension 3 over Field in a with defining polynomial x^2 + 7*x + 2 over its base - To: Field in b with defining polynomial x^3 + (7 + 2*a)*x^2 + (2 - a)*x - a over its base + From: Vector space of dimension 3 over + Field in a with defining polynomial x^2 + 7*x + 2 over its base + To: Field in b with defining polynomial + x^3 + (7 + 2*a)*x^2 + (2 - a)*x - a over its base sage: j Generic map: - From: Field in b with defining polynomial x^3 + (7 + 2*a)*x^2 + (2 - a)*x - a over its base - To: Vector space of dimension 3 over Field in a with defining polynomial x^2 + 7*x + 2 over its base - + From: Field in b with defining polynomial + x^3 + (7 + 2*a)*x^2 + (2 - a)*x - a over its base + To: Vector space of dimension 3 over + Field in a with defining polynomial x^2 + 7*x + 2 over its base sage: j(b) (0, 1, 0) sage: i((1, a, a+1)) @@ -2385,27 +2397,28 @@ cdef class RingExtensionWithBasis(RingExtension_generic): Similarly, one can view L as a F-vector space of dimension 6:: - sage: V, i, j, = L.free_module(F) - sage: V + sage: V, i, j, = L.free_module(F) # needs sage.rings.finite_rings + sage: V # needs sage.rings.finite_rings Vector space of dimension 6 over Finite Field of size 11 In this case, the isomorphisms between `V` and `L` are given by the basis `(1, a, b, ab, b^2, ab^2)`: - sage: j(a*b) + sage: j(a*b) # needs sage.rings.finite_rings (0, 0, 0, 1, 0, 0) - sage: i((1,2,3,4,5,6)) + sage: i((1,2,3,4,5,6)) # needs sage.rings.finite_rings (1 + 2*a) + (3 + 4*a)*b + (5 + 6*a)*b^2 When ``base`` is omitted, the default is the base of this extension:: - sage: L.free_module(map=False) - Vector space of dimension 3 over Field in a with defining polynomial x^2 + 7*x + 2 over its base + sage: L.free_module(map=False) # needs sage.rings.finite_rings + Vector space of dimension 3 over + Field in a with defining polynomial x^2 + 7*x + 2 over its base Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: L.degree(GF(11^3)) + sage: L.degree(GF(11^3)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z3 of size 11^3 @@ -2441,9 +2454,9 @@ cdef class RingExtensionWithBasis(RingExtension_generic): TESTS:: - sage: K = GF(7^5).over() - sage: L = GF(7^15).over(K) - sage: for base in L.bases(): + sage: K = GF(7^5).over() # needs sage.rings.finite_rings + sage: L = GF(7^15).over(K) # needs sage.rings.finite_rings + sage: for base in L.bases(): # needs sage.rings.finite_rings ....: V, i, j = L.free_module(base) ....: assert([ i(v) for v in V.basis() ] == L.basis_over(base)) ....: assert([ j(x) for x in L.basis_over(base) ] == V.basis()) @@ -2476,39 +2489,40 @@ cdef class RingExtensionWithBasis(RingExtension_generic): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = ZZ.extension(x^2 - 5) sage: OK = A.over() # over ZZ sage: OK Order in Number Field in a with defining polynomial x^2 - 5 over its base - - sage: K1 = OK.fraction_field() - sage: K1 - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base + sage: K1 = OK.fraction_field(); K1 + Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base sage: K1.bases() - [Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base, + [Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base, Order in Number Field in a with defining polynomial x^2 - 5 over its base, Integer Ring] - - sage: K2 = OK.fraction_field(extend_base=True) - sage: K2 - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base + sage: K2 = OK.fraction_field(extend_base=True); K2 + Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base sage: K2.bases() - [Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base, + [Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base, Rational Field] Note that there is no coercion map between `K_1` and `K_2`:: - sage: K1.has_coerce_map_from(K2) + sage: K1.has_coerce_map_from(K2) # needs sage.rings.number_field False - sage: K2.has_coerce_map_from(K1) + sage: K2.has_coerce_map_from(K1) # needs sage.rings.number_field False We check that when the extension is a field, its fraction field does not change:: - sage: K1.fraction_field() is K1 + sage: K1.fraction_field() is K1 # needs sage.rings.number_field True - sage: K2.fraction_field() is K2 + sage: K2.fraction_field() is K2 # needs sage.rings.number_field True TESTS:: @@ -2543,13 +2557,12 @@ cdef class RingExtensionWithGen(RingExtensionWithBasis): TESTS:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = QQ.extension(x^3 - 7) sage: K = A.over() - sage: type(K) - sage: TestSuite(K).run() """ @@ -2572,12 +2585,11 @@ cdef class RingExtensionWithGen(RingExtensionWithBasis): TESTS:: sage: x = polygen(ZZ, 'x') - sage: K. = QQ.extension(x^3 + 3*x + 1) - sage: E = K.over() - sage: E + sage: K. = QQ.extension(x^3 + 3*x + 1) # needs sage.rings.number_field + sage: E = K.over(); E # needs sage.rings.number_field Field in a with defining polynomial x^3 + 3*x + 1 over its base - sage: TestSuite(E).run() + sage: TestSuite(E).run() # needs sage.rings.number_field """ self._name = names[0] backend_base = backend_parent(defining_morphism.domain()) @@ -2604,10 +2616,10 @@ cdef class RingExtensionWithGen(RingExtensionWithBasis): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^3).over() sage: K._repr_topring() 'Field in a with defining polynomial x^3 + 3*x + 3' - sage: L. = GF(5^9).over(K) sage: L._repr_topring() 'Field in b with defining polynomial x^3 + (1 + 3*a^2)*x^2 + (3 + 2*a + 2*a^2)*x - a' @@ -2622,10 +2634,10 @@ cdef class RingExtensionWithGen(RingExtensionWithBasis): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^3).over() sage: K._latex_topring() '\\Bold{F}_{5}[a]' - sage: L. = GF(5^9).over(K) sage: L._latex_topring() '\\Bold{F}_{5}[a][b]' @@ -2648,10 +2660,10 @@ cdef class RingExtensionWithGen(RingExtensionWithBasis): EXAMPLES:: - sage: K. = GF(7^10).over(GF(7^2)) - sage: K - Field in u with defining polynomial x^5 + (6*z2 + 4)*x^4 + (3*z2 + 5)*x^3 + (2*z2 + 2)*x^2 + 4*x + 6*z2 over its base - + sage: # needs sage.rings.finite_rings + sage: K. = GF(7^10).over(GF(7^2)); K + Field in u with defining polynomial x^5 + (6*z2 + 4)*x^4 + + (3*z2 + 5)*x^3 + (2*z2 + 2)*x^2 + 4*x + 6*z2 over its base sage: P = K.modulus(); P x^5 + (6*z2 + 4)*x^4 + (3*z2 + 5)*x^3 + (2*z2 + 2)*x^2 + 4*x + 6*z2 sage: P(u) @@ -2659,7 +2671,7 @@ cdef class RingExtensionWithGen(RingExtensionWithBasis): We can use a different variable name:: - sage: K.modulus('y') + sage: K.modulus('y') # needs sage.rings.finite_rings y^5 + (6*z2 + 4)*y^4 + (3*z2 + 5)*y^3 + (2*z2 + 2)*y^2 + 4*y + 6*z2 """ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing @@ -2680,10 +2692,10 @@ cdef class RingExtensionWithGen(RingExtensionWithBasis): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2).over() # over GF(5) sage: K.gens() (a,) - sage: L. = GF(5^4).over(K) sage: L.gens() (b,) @@ -2721,39 +2733,40 @@ cdef class RingExtensionWithGen(RingExtensionWithBasis): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = ZZ.extension(x^2 - 5) sage: OK = A.over() # over ZZ sage: OK Order in Number Field in a with defining polynomial x^2 - 5 over its base - - sage: K1 = OK.fraction_field() - sage: K1 - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base + sage: K1 = OK.fraction_field(); K1 + Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base sage: K1.bases() - [Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base, + [Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base, Order in Number Field in a with defining polynomial x^2 - 5 over its base, Integer Ring] - - sage: K2 = OK.fraction_field(extend_base=True) - sage: K2 - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base + sage: K2 = OK.fraction_field(extend_base=True); K2 + Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base sage: K2.bases() - [Fraction Field of Order in Number Field in a with defining polynomial x^2 - 5 over its base, + [Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 5 over its base, Rational Field] Note that there is no coercion map between `K_1` and `K_2`:: - sage: K1.has_coerce_map_from(K2) + sage: K1.has_coerce_map_from(K2) # needs sage.rings.number_field False - sage: K2.has_coerce_map_from(K1) + sage: K2.has_coerce_map_from(K1) # needs sage.rings.number_field False We check that when the extension is a field, its fraction field does not change:: - sage: K1.fraction_field() is K1 + sage: K1.fraction_field() is K1 # needs sage.rings.number_field True - sage: K2.fraction_field() is K2 + sage: K2.fraction_field() is K2 # needs sage.rings.number_field True TESTS:: diff --git a/src/sage/rings/ring_extension_conversion.pyx b/src/sage/rings/ring_extension_conversion.pyx index 9d94fb7567d..eeb6077cd0a 100644 --- a/src/sage/rings/ring_extension_conversion.pyx +++ b/src/sage/rings/ring_extension_conversion.pyx @@ -1,3 +1,5 @@ +# sage.doctest: needs sage.rings.finite_rings + ############################################################################# # Copyright (C) 2019 Xavier Caruso # diff --git a/src/sage/rings/ring_extension_element.pyx b/src/sage/rings/ring_extension_element.pyx index 4b1809a8db5..fb80ba84e6e 100644 --- a/src/sage/rings/ring_extension_element.pyx +++ b/src/sage/rings/ring_extension_element.pyx @@ -43,9 +43,9 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: - sage: K = GF(5^4).over() - sage: x = K.random_element() - sage: TestSuite(x).run() + sage: K = GF(5^4).over() # needs sage.rings.finite_rings + sage: x = K.random_element() # needs sage.rings.finite_rings + sage: TestSuite(x).run() # needs sage.rings.finite_rings """ def __init__(self, RingExtension_generic parent, x, *args, **kwds): @@ -86,6 +86,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^3).over() sage: x = K.random_element() sage: type(x) @@ -103,10 +104,10 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = QQ.extension(x^2 - 2) sage: K. = A.over() # over QQ - sage: hasattr(a, 'continued_fraction') True sage: a.continued_fraction() @@ -137,10 +138,10 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = QQ.extension(x^2 - 2) sage: K. = A.over() - sage: dir(a) ['__abs__', '__add__', @@ -173,8 +174,8 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES: - sage: E. = GF(5^3).over() - sage: hash(a) + sage: E. = GF(5^3).over() # needs sage.rings.finite_rings + sage: hash(a) # needs sage.rings.finite_rings 5 """ return hash(self._backend) @@ -188,9 +189,9 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: - sage: K. = GF(5^2).over() - sage: L. = GF(5^4).over(K) - sage: b._repr_() + sage: K. = GF(5^2).over() # needs sage.rings.finite_rings + sage: L. = GF(5^4).over(K) # needs sage.rings.finite_rings + sage: b._repr_() # needs sage.rings.finite_rings 'b' """ cdef RingExtension_generic parent = self._parent @@ -232,9 +233,9 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: - sage: K. = GF(5^2).over() - sage: L. = GF(5^4).over(K) - sage: b._latex_() + sage: K. = GF(5^2).over() # needs sage.rings.finite_rings + sage: L. = GF(5^4).over(K) # needs sage.rings.finite_rings + sage: b._latex_() # needs sage.rings.finite_rings 'b' """ cdef RingExtension_generic parent = self._parent @@ -278,6 +279,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2) sage: K. = GF(5^4).over(F) sage: x = z^10 @@ -300,6 +302,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2) sage: K. = GF(5^4).over(F) sage: x = z^3 + z^2 + z + 4 @@ -311,18 +314,18 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): When the element is not in the base, an error is raised:: - sage: z.in_base() + sage: z.in_base() # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: z is not in the base :: + sage: # needs sage.rings.finite_rings sage: S. = F[] sage: E = S.over(F) sage: f = E(1) - sage: g = f.in_base() - sage: g + sage: g = f.in_base(); g 1 sage: g.parent() Finite Field in z2 of size 5^2 @@ -331,6 +334,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): We check the case of a tower of extensions:: + sage: # needs sage.rings.finite_rings sage: F = GF(5^2) sage: K. = GF(5^4).over(F) sage: L. = GF(5^8).over(K) @@ -370,6 +374,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2).over() sage: x = K.random_element() sage: x == x @@ -387,10 +392,10 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^4).over(GF(5^2)) sage: x = K.random_element() sage: y = K.random_element() - sage: (x+y).parent() is K True sage: x + y == y + x @@ -407,9 +412,9 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^4).over(GF(5^2)) sage: x = K.random_element() - sage: y = -x sage: y.parent() is K True @@ -427,11 +432,11 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^4).over(GF(5^2)) sage: x = K.random_element() sage: y = K.random_element() - - sage: (x-y).parent() is K + sage: (x - y).parent() is K True sage: x - y == x + (-y) True @@ -447,10 +452,10 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^4).over(GF(5^2)) sage: x = K.random_element() sage: y = K.random_element() - sage: (x*y).parent() is K True sage: x * y == y * x @@ -468,15 +473,16 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): TESTS:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = ZZ.extension(x^2 - 2) sage: OK = A.over() sage: a = OK(a) - sage: b = 1/a; b a/2 sage: b.parent() - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 2 over its base + Fraction Field of + Order in Number Field in a with defining polynomial x^2 - 2 over its base sage: a*b 1 """ @@ -496,8 +502,8 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES:: - sage: K. = GF(5^4).over(GF(5^2)) - sage: a.additive_order() + sage: K. = GF(5^4).over(GF(5^2)) # needs sage.rings.finite_rings + sage: a.additive_order() # needs sage.rings.finite_rings 5 """ return self._backend.additive_order() @@ -508,8 +514,8 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES:: - sage: K. = GF(5^4).over(GF(5^2)) - sage: a.multiplicative_order() + sage: K. = GF(5^4).over(GF(5^2)) # needs sage.rings.finite_rings + sage: a.multiplicative_order() # needs sage.rings.finite_rings 624 """ return self._backend.multiplicative_order() @@ -552,9 +558,9 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): sage: A. = PolynomialRing(QQ) sage: E = A.over(QQ) - sage: E(x^2+1).is_prime() + sage: E(x^2 + 1).is_prime() # needs sage.libs.pari True - sage: E(x^2-1).is_prime() + sage: E(x^2 - 1).is_prime() # needs sage.libs.pari False """ return self._backend.is_prime() @@ -570,12 +576,12 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^3).over() sage: a.is_square() False sage: a.is_square(root=True) (False, None) - sage: b = a + 1 sage: b.is_square() True @@ -599,7 +605,7 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): - ``extend`` -- a boolean (default: ``True``); if "True", return a square root in an extension ring, if necessary. - Otherwise, raise a ``ValueError`` if the root is not in + Otherwise, raise a :class:`ValueError` if the root is not in the ring - ``all`` -- a boolean (default: ``False``); if ``True``, @@ -610,10 +616,11 @@ cdef class RingExtensionElement(CommutativeAlgebraElement): .. NOTE:: - The option `extend=True` is often not implemented. + The option ``extend=True`` is often not implemented. EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^3).over() sage: b = a + 1 sage: b.sqrt() @@ -664,8 +671,8 @@ cdef class RingExtensionFractionFieldElement(RingExtensionElement): EXAMPLES: - sage: E. = GF(5^3).over() - sage: hash(a) + sage: E. = GF(5^3).over() # needs sage.rings.finite_rings + sage: hash(a) # needs sage.rings.finite_rings 5 """ return hash(self._backend) @@ -744,13 +751,13 @@ cdef class RingExtensionFractionFieldElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = ZZ.extension(x^2 - 2) sage: OK = A.over() # over ZZ - sage: K = OK.fraction_field() - sage: K - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 2 over its base - + sage: K = OK.fraction_field(); K + Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 2 over its base sage: x = K(1/a); x a/2 sage: num = x.numerator(); num @@ -759,13 +766,14 @@ cdef class RingExtensionFractionFieldElement(RingExtensionElement): The numerator is an element of the ring which was used to construct the fraction field:: - sage: num.parent() + sage: num.parent() # needs sage.rings.number_field Order in Number Field in a with defining polynomial x^2 - 2 over its base - sage: num.parent() is OK + sage: num.parent() is OK # needs sage.rings.number_field True TESTS:: + sage: # needs sage.rings.number_field sage: x = K.random_element() sage: x == x.numerator() / x.denominator() True @@ -780,13 +788,13 @@ cdef class RingExtensionFractionFieldElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = ZZ[] sage: A. = ZZ.extension(x^2 - 2) sage: OK = A.over() # over ZZ - sage: K = OK.fraction_field() - sage: K - Fraction Field of Order in Number Field in a with defining polynomial x^2 - 2 over its base - + sage: K = OK.fraction_field(); K + Fraction Field of Order in Number Field in a + with defining polynomial x^2 - 2 over its base sage: x = K(1/a); x a/2 sage: denom = x.denominator(); denom @@ -795,13 +803,14 @@ cdef class RingExtensionFractionFieldElement(RingExtensionElement): The denominator is an element of the ring which was used to construct the fraction field:: - sage: denom.parent() + sage: denom.parent() # needs sage.rings.number_field Order in Number Field in a with defining polynomial x^2 - 2 over its base - sage: denom.parent() is OK + sage: denom.parent() is OK # needs sage.rings.number_field True TESTS:: + sage: # needs sage.rings.number_field sage: x = K.random_element() sage: x == x.numerator() / x.denominator() True @@ -820,6 +829,7 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^3).over() sage: L. = GF(5^9).over(K) sage: type(b) @@ -832,8 +842,8 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES: - sage: E. = GF(5^3).over() - sage: hash(a) + sage: E. = GF(5^3).over() # needs sage.rings.finite_rings + sage: hash(a) # needs sage.rings.finite_rings 5 """ return hash(self._backend) @@ -851,10 +861,10 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^3).over() sage: L. = GF(5^9).over(K) sage: u = 1/(a+b) - sage: u._repr_extension(base=K) '(2 + 2*a) + (-1 + a - a^2)*b + (2 + 3*a + 3*a^2)*b^2' sage: u._repr_extension(base=GF(5)) @@ -929,10 +939,10 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^3).over() sage: L. = GF(5^9).over(K) sage: u = 1/(a+b) - sage: u._latex_extension(base=K) \left( 2 + 2 a \right) + \left( -1 + a - a^{2} \right) b + \left( 2 + 3 a + 3 a^{2} \right) b^{2} sage: u._latex_extension(base=GF(5)) @@ -995,28 +1005,27 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5) sage: K. = GF(5^2).over() # over F sage: L. = GF(5^6).over(K) sage: x = (a+b)^4; x (-1 + a) + (3 + a)*b + (1 - a)*b^2 - - sage: x.vector(K) # basis is (1, b, b^2) + sage: x.vector(K) # basis is (1, b, b^2) (-1 + a, 3 + a, 1 - a) - - sage: x.vector(F) # basis is (1, a, b, a*b, b^2, a*b^2) + sage: x.vector(F) # basis is (1, a, b, a*b, b^2, a*b^2) (4, 1, 3, 1, 1, 4) If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: x.vector() + sage: x.vector() # needs sage.rings.finite_rings (-1 + a, 3 + a, 1 - a) Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: x.vector(GF(5^3)) + sage: x.vector(GF(5^3)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z3 of size 5^3 @@ -1036,6 +1045,7 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: K = GF(11^10).over(GF(11^2)) sage: x = K.random_element() sage: coeffs = x.vector() @@ -1059,12 +1069,12 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F. = GF(5^2).over() # over GF(5) sage: K. = GF(5^4).over(F) sage: L. = GF(5^12).over(K) sage: u = 1/(a + b + c); u (2 + (-1 - a)*b) + ((2 + 3*a) + (1 - a)*b)*c + ((-1 - a) - a*b)*c^2 - sage: P = u.polynomial(K); P ((-1 - a) - a*b)*x^2 + ((2 + 3*a) + (1 - a)*b)*x + 2 + (-1 - a)*b sage: P.base_ring() is K @@ -1074,40 +1084,40 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): When the base is `F`, we obtain a bivariate polynomial:: - sage: P = u.polynomial(F); P + sage: P = u.polynomial(F); P # needs sage.rings.finite_rings (-a)*x0^2*x1 + (-1 - a)*x0^2 + (1 - a)*x0*x1 + (2 + 3*a)*x0 + (-1 - a)*x1 + 2 We check that its value at the generators is the element we started with:: - sage: L.gens(F) + sage: L.gens(F) # needs sage.rings.finite_rings (c, b) - sage: P(c, b) == u + sage: P(c, b) == u # needs sage.rings.finite_rings True Similarly, when the base is ``GF(5)``, we get a trivariate polynomial: - sage: P = u.polynomial(GF(5)); P + sage: P = u.polynomial(GF(5)); P # needs sage.rings.finite_rings -x0^2*x1*x2 - x0^2*x2 - x0*x1*x2 - x0^2 + x0*x1 - 2*x0*x2 - x1*x2 + 2*x0 - x1 + 2 - sage: P(c, b, a) == u + sage: P(c, b, a) == u # needs sage.rings.finite_rings True Different variable names can be specified:: - sage: u.polynomial(GF(5), var='y') + sage: u.polynomial(GF(5), var='y') # needs sage.rings.finite_rings -y0^2*y1*y2 - y0^2*y2 - y0*y1*y2 - y0^2 + y0*y1 - 2*y0*y2 - y1*y2 + 2*y0 - y1 + 2 - sage: u.polynomial(GF(5), var=['x','y','z']) + sage: u.polynomial(GF(5), var=['x','y','z']) # needs sage.rings.finite_rings -x^2*y*z - x^2*z - x*y*z - x^2 + x*y - 2*x*z - y*z + 2*x - y + 2 If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: u.polynomial() + sage: u.polynomial() # needs sage.rings.finite_rings ((-1 - a) - a*b)*x^2 + ((2 + 3*a) + (1 - a)*b)*x + 2 + (-1 - a)*b Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: u.polynomial(GF(5^3)) + sage: u.polynomial(GF(5^3)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z3 of size 5^3 @@ -1148,10 +1158,10 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^3).over() # over GF(5) sage: L. = GF(5^6).over(K) sage: u = a/(1+b) - sage: u (2 + a + 3*a^2) + (3 + 3*a + a^2)*b sage: b*u @@ -1159,7 +1169,6 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): sage: u.matrix(K) [2 + a + 3*a^2 3 + 3*a + a^2] [ 3 + 2*a^2 2 + 2*a - a^2] - sage: u.matrix(GF(5)) [2 1 3 3 3 1] [1 3 1 2 0 3] @@ -1171,14 +1180,14 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: u.matrix() + sage: u.matrix() # needs sage.rings.finite_rings [2 + a + 3*a^2 3 + 3*a + a^2] [ 3 + 2*a^2 2 + 2*a - a^2] Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: u.matrix(GF(5^2)) + sage: u.matrix(GF(5^2)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z2 of size 5^2 @@ -1204,10 +1213,10 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: F = GF(11^2) sage: K = GF(11^6).over(F) sage: L = GF(11^18).over(K) - sage: for base in L.bases(): ....: x = L.random_element() ....: y = L.random_element() @@ -1232,41 +1241,41 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5) sage: K. = GF(5^3).over(F) sage: L. = GF(5^6).over(K) sage: u = a/(1+b) - sage: tr = u.trace(K); tr -1 + 3*a + 2*a^2 We check that the trace lives in the base ring:: - sage: tr.parent() + sage: tr.parent() # needs sage.rings.finite_rings Field in a with defining polynomial x^3 + 3*x + 3 over its base - sage: tr.parent() is K + sage: tr.parent() is K # needs sage.rings.finite_rings True Similarly, one can compute the trace over F:: - sage: u.trace(F) + sage: u.trace(F) # needs sage.rings.finite_rings 0 We check the transitivity of the trace:: - sage: u.trace(F) == tr.trace(F) + sage: u.trace(F) == tr.trace(F) # needs sage.rings.finite_rings True If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: u.trace() + sage: u.trace() # needs sage.rings.finite_rings -1 + 3*a + 2*a^2 Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: u.trace(GF(5^2)) + sage: u.trace(GF(5^2)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z2 of size 5^2 @@ -1291,14 +1300,13 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: F = GF(11^2) sage: K = GF(11^6).over(F) sage: L = GF(11^18).over(K) - sage: x = L.random_element() sage: x.trace(F) == x.trace().trace() True - sage: for base in L.bases(): ....: x = L.random_element() ....: y = L.random_element() @@ -1326,41 +1334,41 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5) sage: K. = GF(5^3).over(F) sage: L. = GF(5^6).over(K) sage: u = a/(1+b) - sage: nr = u.norm(K); nr 3 + 2*a^2 We check that the norm lives in the base ring:: - sage: nr.parent() + sage: nr.parent() # needs sage.rings.finite_rings Field in a with defining polynomial x^3 + 3*x + 3 over its base - sage: nr.parent() is K + sage: nr.parent() is K # needs sage.rings.finite_rings True Similarly, one can compute the norm over F:: - sage: u.norm(F) + sage: u.norm(F) # needs sage.rings.finite_rings 4 We check the transitivity of the norm:: - sage: u.norm(F) == nr.norm(F) + sage: u.norm(F) == nr.norm(F) # needs sage.rings.finite_rings True If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: u.norm() + sage: u.norm() # needs sage.rings.finite_rings 3 + 2*a^2 Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: u.norm(GF(5^2)) + sage: u.norm(GF(5^2)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z2 of size 5^2 @@ -1385,14 +1393,13 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): TESTS:: + sage: # needs sage.rings.finite_rings sage: F = GF(11^2) sage: K = GF(11^6).over(F) sage: L = GF(11^18).over(K) - sage: x = L.random_element() sage: x.norm(F) == x.norm().norm() True - sage: for base in L.bases(): ....: x = L.random_element() ....: y = L.random_element() @@ -1420,46 +1427,46 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5) sage: K. = GF(5^3).over(F) sage: L. = GF(5^6).over(K) sage: u = a/(1+b) - sage: chi = u.charpoly(K); chi x^2 + (1 + 2*a + 3*a^2)*x + 3 + 2*a^2 We check that the charpoly has coefficients in the base ring:: - sage: chi.base_ring() + sage: chi.base_ring() # needs sage.rings.finite_rings Field in a with defining polynomial x^3 + 3*x + 3 over its base - sage: chi.base_ring() is K + sage: chi.base_ring() is K # needs sage.rings.finite_rings True and that it annihilates u:: - sage: chi(u) + sage: chi(u) # needs sage.rings.finite_rings 0 Similarly, one can compute the characteristic polynomial over F:: - sage: u.charpoly(F) + sage: u.charpoly(F) # needs sage.rings.finite_rings x^6 + x^4 + 2*x^3 + 3*x + 4 A different variable name can be specified:: - sage: u.charpoly(F, var='t') + sage: u.charpoly(F, var='t') # needs sage.rings.finite_rings t^6 + t^4 + 2*t^3 + 3*t + 4 If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: u.charpoly() + sage: u.charpoly() # needs sage.rings.finite_rings x^2 + (1 + 2*a + 3*a^2)*x + 3 + 2*a^2 Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: u.charpoly(GF(5^2)) + sage: u.charpoly(GF(5^2)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z2 of size 5^2 @@ -1469,9 +1476,9 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): We check that the characteristic polynomial of an element in the base ring is a power of a polynomial of degree 1:: - sage: S. = K[] - sage: u = K.random_element() - sage: L(u).charpoly() == (x - u)^2 + sage: S. = K[] # needs sage.rings.finite_rings + sage: u = K.random_element() # needs sage.rings.finite_rings + sage: L(u).charpoly() == (x - u)^2 # needs sage.rings.finite_rings True """ return self.matrix(base).charpoly(var) @@ -1487,46 +1494,46 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F = GF(5) sage: K. = GF(5^3).over(F) sage: L. = GF(5^6).over(K) sage: u = 1 / (a+b) - sage: chi = u.minpoly(K); chi x^2 + (2*a + a^2)*x - 1 + a We check that the minimal polynomial has coefficients in the base ring:: - sage: chi.base_ring() + sage: chi.base_ring() # needs sage.rings.finite_rings Field in a with defining polynomial x^3 + 3*x + 3 over its base - sage: chi.base_ring() is K + sage: chi.base_ring() is K # needs sage.rings.finite_rings True and that it annihilates u:: - sage: chi(u) + sage: chi(u) # needs sage.rings.finite_rings 0 Similarly, one can compute the minimal polynomial over F:: - sage: u.minpoly(F) + sage: u.minpoly(F) # needs sage.rings.finite_rings x^6 + 4*x^5 + x^4 + 2*x^2 + 3 A different variable name can be specified:: - sage: u.minpoly(F, var='t') + sage: u.minpoly(F, var='t') # needs sage.rings.finite_rings t^6 + 4*t^5 + t^4 + 2*t^2 + 3 If ``base`` is omitted, it is set to its default which is the base of the extension:: - sage: u.minpoly() + sage: u.minpoly() # needs sage.rings.finite_rings x^2 + (2*a + a^2)*x - 1 + a Note that ``base`` must be an explicit base over which the extension has been defined (as listed by the method :meth:`bases`):: - sage: u.minpoly(GF(5^2)) + sage: u.minpoly(GF(5^2)) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: not (explicitly) defined over Finite Field in z2 of size 5^2 @@ -1536,15 +1543,15 @@ cdef class RingExtensionWithBasisElement(RingExtensionElement): We check that the minimal polynomial of an element in the base ring has degree 1:: - sage: S. = K[] - sage: u = K.random_element() - sage: L(u).minpoly() == x - u + sage: S. = K[] # needs sage.rings.finite_rings + sage: u = K.random_element() # needs sage.rings.finite_rings + sage: L(u).minpoly() == x - u # needs sage.rings.finite_rings True In a similar fashion, the minimal polynomial over `F` of an element of `K` should have degree 1 or 3:: - sage: L(u).minpoly(F).degree() in [ 1, 3 ] + sage: L(u).minpoly(F).degree() in [ 1, 3 ] # needs sage.rings.finite_rings True """ cdef RingExtensionWithBasis parent = self._parent diff --git a/src/sage/rings/ring_extension_homset.py b/src/sage/rings/ring_extension_homset.py index 28b2b736dd8..d2c13a11f0e 100644 --- a/src/sage/rings/ring_extension_homset.py +++ b/src/sage/rings/ring_extension_homset.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.finite_rings r""" Homset between extensions of rings @@ -29,7 +30,9 @@ class RingExtensionHomset(RingHomset_generic): sage: L = GF(5^8).over(K) sage: H = Hom(K,L) sage: H - Set of Homomorphisms from Field in z2 with defining polynomial x^2 + 4*x + 2 over its base to Field in z8 with defining polynomial x^4 + (3 - z2)*x + z2 over its base + Set of Homomorphisms + from Field in z2 with defining polynomial x^2 + 4*x + 2 over its base + to Field in z8 with defining polynomial x^4 + (3 - z2)*x + z2 over its base sage: type(H) <... 'sage.rings.ring_extension_homset.RingExtensionHomset_with_category'> @@ -44,7 +47,8 @@ def __call__(self, *args, **kwargs): sage: K. = GF(5^2).over() sage: L. = GF(5^4).over(K) sage: Hom(L,L)([b^5, a^5]) - Ring endomorphism of Field in b with defining polynomial x^2 + (3 - a)*x + a over its base + Ring endomorphism of + Field in b with defining polynomial x^2 + (3 - a)*x + a over its base Defn: b |--> (2 + a) + 2*b with map on base ring: a |--> 1 - a diff --git a/src/sage/rings/ring_extension_morphism.pyx b/src/sage/rings/ring_extension_morphism.pyx index 04d2aa4a650..f861d015a35 100644 --- a/src/sage/rings/ring_extension_morphism.pyx +++ b/src/sage/rings/ring_extension_morphism.pyx @@ -83,20 +83,18 @@ cdef class RingExtensionHomomorphism(RingMap): TESTS:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2).over() sage: L. = GF(5^4).over(K) - sage: phi = L.hom([b^5, a^5]) - sage: phi - Ring endomorphism of Field in b with defining polynomial x^2 + (3 - a)*x + a over its base + sage: phi = L.hom([b^5, a^5]); phi + Ring endomorphism of Field in b + with defining polynomial x^2 + (3 - a)*x + a over its base Defn: b |--> (2 + a) + 2*b with map on base ring: a |--> 1 - a - sage: type(phi) - sage: TestSuite(phi).run() - """ def __init__(self, parent, defn, base_map=None, check=True): r""" @@ -117,8 +115,7 @@ cdef class RingExtensionHomomorphism(RingMap): sage: S. = QQ[] sage: T. = QQ[] - sage: f = T.hom([x^2, y^2]) - sage: f + sage: f = T.hom([x^2, y^2]); f Ring endomorphism of Multivariate Polynomial Ring in x, y over Rational Field Defn: x |--> x^2 y |--> y^2 @@ -220,13 +217,12 @@ cdef class RingExtensionHomomorphism(RingMap): EXAMPLES:: - sage: K. = GF(5^2).over() # over GF(5) - sage: f = K.hom([a^5]) - sage: f + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: f = K.hom([a^5]); f # needs sage.rings.finite_rings Ring endomorphism of Field in a with defining polynomial x^2 + 4*x + 2 over its base Defn: a |--> 1 - a - sage: f._repr_type() + sage: f._repr_type() # needs sage.rings.finite_rings 'Ring' """ return "Ring" @@ -241,11 +237,11 @@ cdef class RingExtensionHomomorphism(RingMap): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ, 'x') sage: A. = QQ.extension(x^2 - 2) sage: K. = A.over() - sage: f = K.hom([-sqrt2]) - sage: f + sage: f = K.hom([-sqrt2]); f Ring endomorphism of Field in sqrt2 with defining polynomial x^2 - 2 over its base Defn: sqrt2 |--> -sqrt2 sage: f(sqrt2) @@ -255,7 +251,7 @@ cdef class RingExtensionHomomorphism(RingMap): sage: a = QQ.random_element() sage: b = QQ.random_element() - sage: f(a + b*sqrt2) == a - b*sqrt2 + sage: f(a + b*sqrt2) == a - b*sqrt2 # needs sage.rings.number_field True """ y = self._backend(backend_element(x)) @@ -272,18 +268,18 @@ cdef class RingExtensionHomomorphism(RingMap): EXAMPLES:: sage: F = GF(5) - sage: K. = GF(5^2).over(F) - sage: L. = GF(5^6).over(K) + sage: K. = GF(5^2).over(F) # needs sage.rings.finite_rings + sage: L. = GF(5^6).over(K) # needs sage.rings.finite_rings We define the absolute Frobenius of L:: - sage: FrobL = L.hom([b^5, a^5]) - sage: FrobL - Ring endomorphism of Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base + sage: FrobL = L.hom([b^5, a^5]); FrobL # needs sage.rings.finite_rings + Ring endomorphism of + Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base Defn: b |--> (-1 + a) + (1 + 2*a)*b + a*b^2 with map on base ring: a |--> 1 - a - sage: FrobL.base_map() + sage: FrobL.base_map() # needs sage.rings.finite_rings Ring morphism: From: Field in a with defining polynomial x^2 + 4*x + 2 over its base To: Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base @@ -292,11 +288,11 @@ cdef class RingExtensionHomomorphism(RingMap): The square of ``FrobL`` acts trivially on K; in other words, it has a trivial base map:: - sage: phi = FrobL^2 - sage: phi - Ring endomorphism of Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base + sage: phi = FrobL^2; phi # needs sage.rings.finite_rings + Ring endomorphism of + Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base Defn: b |--> 2 + 2*a*b + (2 - a)*b^2 - sage: phi.base_map() + sage: phi.base_map() # needs sage.rings.finite_rings """ domain = self.domain() @@ -335,12 +331,11 @@ cdef class RingExtensionHomomorphism(RingMap): TESTS:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2).over() # over GF(5) sage: L. = GF(5^6).over(K) - sage: FrobK = K.hom([a^5]) sage: FrobL = L.hom([b^5], base_map=FrobK) - sage: FrobK^2 == End(K).identity() True sage: FrobL^6 == End(L).identity() @@ -359,6 +354,7 @@ cdef class RingExtensionHomomorphism(RingMap): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2).over() # over GF(5) sage: FrobK = K.hom([a^5]) sage: FrobK.is_identity() @@ -368,9 +364,9 @@ cdef class RingExtensionHomomorphism(RingMap): Coercion maps are not considered as identity morphisms:: + sage: # needs sage.rings.finite_rings sage: L. = GF(5^6).over(K) - sage: iota = L.defining_morphism() - sage: iota + sage: iota = L.defining_morphism(); iota Ring morphism: From: Field in a with defining polynomial x^2 + 4*x + 2 over its base To: Field in b with defining polynomial x^3 + (2 + 2*a)*x - a over its base @@ -388,19 +384,19 @@ cdef class RingExtensionHomomorphism(RingMap): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^10).over(GF(5^5)) - sage: iota = K.defining_morphism() - sage: iota + sage: iota = K.defining_morphism(); iota Ring morphism: From: Finite Field in z5 of size 5^5 - To: Field in z10 with defining polynomial x^2 + (2*z5^3 + 2*z5^2 + 4*z5 + 4)*x + z5 over its base + To: Field in z10 with defining polynomial + x^2 + (2*z5^3 + 2*z5^2 + 4*z5 + 4)*x + z5 over its base Defn: z5 |--> z5 sage: iota.is_injective() True sage: K = GF(7).over(ZZ) - sage: iota = K.defining_morphism() - sage: iota + sage: iota = K.defining_morphism(); iota Ring morphism: From: Integer Ring To: Finite Field of size 7 over its base @@ -416,19 +412,19 @@ cdef class RingExtensionHomomorphism(RingMap): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K = GF(5^10).over(GF(5^5)) - sage: iota = K.defining_morphism() - sage: iota + sage: iota = K.defining_morphism(); iota Ring morphism: From: Finite Field in z5 of size 5^5 - To: Field in z10 with defining polynomial x^2 + (2*z5^3 + 2*z5^2 + 4*z5 + 4)*x + z5 over its base + To: Field in z10 with defining polynomial + x^2 + (2*z5^3 + 2*z5^2 + 4*z5 + 4)*x + z5 over its base Defn: z5 |--> z5 sage: iota.is_surjective() False sage: K = GF(7).over(ZZ) - sage: iota = K.defining_morphism() - sage: iota + sage: iota = K.defining_morphism(); iota Ring morphism: From: Integer Ring To: Finite Field of size 7 over its base @@ -447,10 +443,10 @@ cdef class RingExtensionHomomorphism(RingMap): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2).over() # over GF(5) sage: L. = GF(5^6).over(K) sage: FrobL = L.hom([b^5, a^5]) # absolute Frobenius - sage: print(FrobL._repr_defn()) b |--> (-1 + a) + (1 + 2*a)*b + a*b^2 with map on base ring: @@ -478,14 +474,13 @@ cdef class RingExtensionHomomorphism(RingMap): TESTS:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: A. = QQ.extension(x^2 - 5) sage: K. = A.over() - sage: f = K.hom([-sqrt5]) - sage: f + sage: f = K.hom([-sqrt5]); f Ring endomorphism of Field in sqrt5 with defining polynomial x^2 - 5 over its base Defn: sqrt5 |--> -sqrt5 - sage: f^2 # indirect doctest Ring endomorphism of Field in sqrt5 with defining polynomial x^2 - 5 over its base Defn: sqrt5 |--> sqrt5 @@ -505,9 +500,9 @@ cdef class RingExtensionHomomorphism(RingMap): TESTS:: + sage: # needs sage.rings.finite_rings sage: K. = GF(5^2).over() # over GF(5) sage: f = K.hom([a^5]) - sage: g = copy(f) # indirect doctest sage: f == g True @@ -523,9 +518,9 @@ cdef class RingExtensionHomomorphism(RingMap): TESTS:: - sage: K. = GF(5^2).over() # over GF(5) - sage: f = K.hom([a^5]) - sage: loads(dumps(f)) == f + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: f = K.hom([a^5]) # needs sage.rings.finite_rings + sage: loads(dumps(f)) == f # needs sage.rings.finite_rings True """ slots = RingMap._extra_slots(self) @@ -540,16 +535,15 @@ cdef class RingExtensionBackendIsomorphism(RingExtensionHomomorphism): TESTS:: + sage: # needs sage.rings.finite_rings sage: K = GF(11^9).over(GF(11^3)) - sage: f = K.coerce_map_from(GF(11^9)) - sage: f + sage: f = K.coerce_map_from(GF(11^9)); f Coercion morphism: From: Finite Field in z9 of size 11^9 - To: Field in z9 with defining polynomial x^3 + (9*z3^2 + 5*z3 + 1)*x^2 + (4*z3 + 3)*x + 10*z3 over its base - + To: Field in z9 with defining polynomial + x^3 + (9*z3^2 + 5*z3 + 1)*x^2 + (4*z3 + 3)*x + 10*z3 over its base sage: type(f) - sage: TestSuite(f).run() """ def __init__(self, parent): @@ -559,9 +553,9 @@ cdef class RingExtensionBackendIsomorphism(RingExtensionHomomorphism): TESTS:: sage: x = polygen(ZZ, 'x') - sage: A. = QQ.extension(x^2 - 5) - sage: K = A.over() - sage: K.coerce_map_from(A) + sage: A. = QQ.extension(x^2 - 5) # needs sage.rings.number_field + sage: K = A.over() # needs sage.rings.number_field + sage: K.coerce_map_from(A) # needs sage.rings.number_field Coercion morphism: From: Number Field in a with defining polynomial x^2 - 5 To: Field in a with defining polynomial x^2 - 5 over its base @@ -576,14 +570,13 @@ cdef class RingExtensionBackendIsomorphism(RingExtensionHomomorphism): EXAMPLES:: - sage: K. = GF(5^2).over() # over GF(5) - sage: f = K.coerce_map_from(GF(5^2)) - sage: f + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: f = K.coerce_map_from(GF(5^2)); f # needs sage.rings.finite_rings Coercion morphism: From: Finite Field in z2 of size 5^2 To: Field in a with defining polynomial x^2 + 4*x + 2 over its base - sage: f._repr_type() + sage: f._repr_type() # needs sage.rings.finite_rings 'Coercion' """ return "Coercion" @@ -594,14 +587,13 @@ cdef class RingExtensionBackendIsomorphism(RingExtensionHomomorphism): EXAMPLES:: - sage: K. = GF(5^2).over() # over GF(5) - sage: f = K.coerce_map_from(GF(5^2)) - sage: f + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: f = K.coerce_map_from(GF(5^2)); f # needs sage.rings.finite_rings Coercion morphism: From: Finite Field in z2 of size 5^2 To: Field in a with defining polynomial x^2 + 4*x + 2 over its base - sage: f._repr_defn() + sage: f._repr_defn() # needs sage.rings.finite_rings '' """ return "" @@ -616,9 +608,9 @@ cdef class RingExtensionBackendIsomorphism(RingExtensionHomomorphism): EXAMPLES:: - sage: K. = GF(5^2).over() # over GF(5) - sage: f = K.coerce_map_from(GF(5^2)) - sage: f(GF(5^2).gen()) + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: f = K.coerce_map_from(GF(5^2)) # needs sage.rings.finite_rings + sage: f(GF(5^2).gen()) # needs sage.rings.finite_rings a """ codomain = self.codomain() @@ -632,16 +624,15 @@ cdef class RingExtensionBackendReverseIsomorphism(RingExtensionHomomorphism): TESTS:: + sage: # needs sage.rings.finite_rings sage: K = GF(11^9).over(GF(11^3)) - sage: f = GF(11^9).convert_map_from(K) - sage: f + sage: f = GF(11^9).convert_map_from(K); f Canonical morphism: - From: Field in z9 with defining polynomial x^3 + (9*z3^2 + 5*z3 + 1)*x^2 + (4*z3 + 3)*x + 10*z3 over its base + From: Field in z9 with defining polynomial + x^3 + (9*z3^2 + 5*z3 + 1)*x^2 + (4*z3 + 3)*x + 10*z3 over its base To: Finite Field in z9 of size 11^9 - sage: type(f) - sage: TestSuite(f).run() """ @@ -652,9 +643,9 @@ cdef class RingExtensionBackendReverseIsomorphism(RingExtensionHomomorphism): TESTS:: sage: x = polygen(ZZ, 'x') - sage: A. = QQ.extension(x^2 - 5) - sage: K = A.over() - sage: A.convert_map_from(K) + sage: A. = QQ.extension(x^2 - 5) # needs sage.rings.number_field + sage: K = A.over() # needs sage.rings.number_field + sage: A.convert_map_from(K) # needs sage.rings.number_field Canonical morphism: From: Field in a with defining polynomial x^2 - 5 over its base To: Number Field in a with defining polynomial x^2 - 5 @@ -669,14 +660,13 @@ cdef class RingExtensionBackendReverseIsomorphism(RingExtensionHomomorphism): EXAMPLES:: - sage: K. = GF(5^2).over() # over GF(5) - sage: f = GF(5^2).convert_map_from(K) - sage: f + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: f = GF(5^2).convert_map_from(K); f # needs sage.rings.finite_rings Canonical morphism: From: Field in a with defining polynomial x^2 + 4*x + 2 over its base To: Finite Field in z2 of size 5^2 - sage: f._repr_type() + sage: f._repr_type() # needs sage.rings.finite_rings 'Canonical' """ return "Canonical" @@ -687,14 +677,13 @@ cdef class RingExtensionBackendReverseIsomorphism(RingExtensionHomomorphism): EXAMPLES:: - sage: K. = GF(5^2).over() # over GF(5) - sage: f = GF(5^2).convert_map_from(K) - sage: f + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: f = GF(5^2).convert_map_from(K); f # needs sage.rings.finite_rings Canonical morphism: From: Field in a with defining polynomial x^2 + 4*x + 2 over its base To: Finite Field in z2 of size 5^2 - sage: f._repr_defn() + sage: f._repr_defn() # needs sage.rings.finite_rings '' """ return "" @@ -709,9 +698,9 @@ cdef class RingExtensionBackendReverseIsomorphism(RingExtensionHomomorphism): EXAMPLES:: - sage: K. = GF(5^2).over() # over GF(5) - sage: f = GF(5^2).convert_map_from(K) - sage: f(a) + sage: K. = GF(5^2).over() # over GF(5) # needs sage.rings.finite_rings + sage: f = GF(5^2).convert_map_from(K) # needs sage.rings.finite_rings + sage: f(a) # needs sage.rings.finite_rings z2 """ return (x)._backend @@ -724,9 +713,9 @@ cdef class MapFreeModuleToRelativeRing(Map): TESTS:: - sage: K = GF(5^2).over() - sage: V, i, j = K.free_module() - sage: type(i) + sage: K = GF(5^2).over() # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: type(i) # needs sage.rings.finite_rings """ @@ -742,9 +731,9 @@ cdef class MapFreeModuleToRelativeRing(Map): TESTS:: - sage: K = GF(11^6).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: i + sage: K = GF(11^6).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: i # needs sage.rings.finite_rings Generic map: From: Vector space of dimension 2 over Finite Field in z3 of size 11^3 To: Field in z6 with defining polynomial x^2 + (10*z3^2 + z3 + 6)*x + z3 over its base @@ -762,9 +751,9 @@ cdef class MapFreeModuleToRelativeRing(Map): EXAMPLES:: - sage: K = GF(11^6).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: i.is_injective() + sage: K = GF(11^6).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: i.is_injective() # needs sage.rings.finite_rings True """ return True @@ -775,9 +764,9 @@ cdef class MapFreeModuleToRelativeRing(Map): EXAMPLES:: - sage: K = GF(11^6).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: i.is_surjective() + sage: K = GF(11^6).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: i.is_surjective() # needs sage.rings.finite_rings True """ return True @@ -792,9 +781,9 @@ cdef class MapFreeModuleToRelativeRing(Map): EXAMPLES:: - sage: K. = GF(11^6).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: i((0,1)) + sage: K. = GF(11^6).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: i((0,1)) # needs sage.rings.finite_rings a """ cdef Element elt @@ -811,9 +800,9 @@ cdef class MapRelativeRingToFreeModule(Map): TESTS:: - sage: K = GF(5^2).over() - sage: V, i, j = K.free_module() - sage: type(j) + sage: K = GF(5^2).over() # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: type(j) # needs sage.rings.finite_rings """ @@ -829,9 +818,9 @@ cdef class MapRelativeRingToFreeModule(Map): TESTS:: - sage: K = GF(11^6).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: j + sage: K = GF(11^6).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: j # needs sage.rings.finite_rings Generic map: From: Field in z6 with defining polynomial x^2 + (10*z3^2 + z3 + 6)*x + z3 over its base To: Vector space of dimension 2 over Finite Field in z3 of size 11^3 @@ -871,9 +860,9 @@ cdef class MapRelativeRingToFreeModule(Map): EXAMPLES:: - sage: K = GF(11^6).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: j.is_injective() + sage: K = GF(11^6).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: j.is_injective() # needs sage.rings.finite_rings True """ return True @@ -884,9 +873,9 @@ cdef class MapRelativeRingToFreeModule(Map): EXAMPLES:: - sage: K = GF(11^6).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: j.is_surjective() + sage: K = GF(11^6).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: j.is_surjective() # needs sage.rings.finite_rings True """ return True @@ -901,9 +890,9 @@ cdef class MapRelativeRingToFreeModule(Map): EXAMPLES:: - sage: K. = GF(11^6).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: j(a) + sage: K. = GF(11^6).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: j(a) # needs sage.rings.finite_rings (0, 1) """ coeffs = self.backend_coefficients(x) @@ -920,9 +909,9 @@ cdef class MapRelativeRingToFreeModule(Map): TESTS:: - sage: K. = GF(11^9).over(GF(11^3)) - sage: V, i, j = K.free_module() - sage: j(a + 2*a^2) # indirect doctest + sage: K. = GF(11^9).over(GF(11^3)) # needs sage.rings.finite_rings + sage: V, i, j = K.free_module() # needs sage.rings.finite_rings + sage: j(a + 2*a^2) # indirect doctest # needs sage.rings.finite_rings (0, 1, 2) """ cdef list coeffs = [ ] diff --git a/src/sage/rings/semirings/non_negative_integer_semiring.py b/src/sage/rings/semirings/non_negative_integer_semiring.py index 9d91e9cf777..1c01fc47eb5 100644 --- a/src/sage/rings/semirings/non_negative_integer_semiring.py +++ b/src/sage/rings/semirings/non_negative_integer_semiring.py @@ -37,15 +37,15 @@ class NonNegativeIntegerSemiring(NonNegativeIntegers): Here is a piece of the Cayley graph for the multiplicative structure:: - sage: G = NN.cayley_graph(elements=range(9), generators=[0,1,2,3,5,7]) # optional - sage.graphs - sage: G # optional - sage.graphs + sage: G = NN.cayley_graph(elements=range(9), generators=[0,1,2,3,5,7]) # needs sage.graphs + sage: G # needs sage.graphs Looped multi-digraph on 9 vertices - sage: G.plot() # optional - sage.graphs + sage: G.plot() # needs sage.graphs sage.plot Graphics object consisting of 48 graphics primitives This is the Hasse diagram of the divisibility order on ``NN``. - sage: Poset(NN.cayley_graph(elements=[1..12], generators=[2,3,5,7,11])).show() # optional - sage.combinat sage.graphs + sage: Poset(NN.cayley_graph(elements=[1..12], generators=[2,3,5,7,11])).show() # needs sage.combinat sage.graphs sage.plot Note: as for :class:`NonNegativeIntegers `, ``NN`` is diff --git a/src/sage/rings/semirings/tropical_semiring.pyx b/src/sage/rings/semirings/tropical_semiring.pyx index 5beff3cff55..2922298e286 100644 --- a/src/sage/rings/semirings/tropical_semiring.pyx +++ b/src/sage/rings/semirings/tropical_semiring.pyx @@ -555,17 +555,19 @@ class TropicalSemiring(Parent, UniqueRepresentation): EXAMPLES:: + sage: TQ = TropicalSemiring(QQ) + sage: TQ.has_coerce_map_from(TQ) + True + sage: TQ.has_coerce_map_from(TropicalSemiring(ZZ)) + True + + sage: # needs sage.rings.real_mpfr sage: TR = TropicalSemiring(RR) sage: T60 = TropicalSemiring(RealField(60)) sage: TR.has_coerce_map_from(T60) True - sage: TQ = TropicalSemiring(QQ) - sage: TQ.has_coerce_map_from(TropicalSemiring(ZZ)) - True sage: TR.has_coerce_map_from(TR) True - sage: TQ.has_coerce_map_from(TQ) - True sage: TR.has_coerce_map_from(TQ) True sage: TR.has_coerce_map_from(float) diff --git a/src/sage/rings/sum_of_squares.pyx b/src/sage/rings/sum_of_squares.pyx index 8c97f25b0df..b8f719d4dac 100644 --- a/src/sage/rings/sum_of_squares.pyx +++ b/src/sage/rings/sum_of_squares.pyx @@ -166,7 +166,7 @@ def two_squares_pyx(uint32_t n): TESTS:: sage: s = lambda t: sum(i^2 for i in t) - sage: for ij in Subsets(Subsets(45000, 15).random_element(), 2): # optional - sage.combinat + sage: for ij in Subsets(Subsets(45000, 15).random_element(), 2): # needs sage.combinat ....: if s(two_squares_pyx(s(ij))) != s(ij): ....: print("hey") @@ -254,7 +254,7 @@ def three_squares_pyx(uint32_t n): TESTS:: sage: s = lambda t: sum(i^2 for i in t) - sage: for ijk in Subsets(Subsets(35000,15).random_element(),3): # optional - sage.combinat + sage: for ijk in Subsets(Subsets(35000,15).random_element(),3): # needs sage.combinat ....: if s(three_squares_pyx(s(ijk))) != s(ijk): ....: print("hey") """ diff --git a/src/sage/rings/tate_algebra_ideal.pyx b/src/sage/rings/tate_algebra_ideal.pyx index e9b45049897..e230a411397 100644 --- a/src/sage/rings/tate_algebra_ideal.pyx +++ b/src/sage/rings/tate_algebra_ideal.pyx @@ -623,7 +623,7 @@ cdef TateAlgebraElement regular_reduce(sgb, TateAlgebraTerm s, TateAlgebraElemen TESTS:: - sage: cython( # optional - sage.misc.cython + sage: cython( # needs sage.misc.cython ....: ''' ....: from sage.rings.tate_algebra_ideal cimport regular_reduce ....: def python_regular_reduce(gb, s, v, stopval): @@ -638,11 +638,12 @@ cdef TateAlgebraElement regular_reduce(sgb, TateAlgebraTerm s, TateAlgebraElemen sage: p1 = (tx, x^3 + 9*x*y) sage: p2 = (ty, x*y + 3*x^2*y) - sage: python_regular_reduce([p1,p2], tx*ty, v, 8) # indirect doctest + sage: python_regular_reduce([p1,p2], tx*ty, v, 8) # indirect doctest # needs sage.misc.cython (2 + O(3^8))*x^2*y + (1 + O(3^8))*x + (1 + O(3^8))*y + O(3^8 * ) - sage: python_regular_reduce([p1,p2], tx, v, 8) # indirect doctest - (2 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + O(3^8))*x^3 + (2 + O(3^8))*x^2*y + (1 + O(3^8))*x + (1 + O(3^8))*y + O(3^8 * ) + sage: python_regular_reduce([p1,p2], tx, v, 8) # indirect doctest # needs sage.misc.cython + (2 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + O(3^8))*x^3 + + (2 + O(3^8))*x^2*y + (1 + O(3^8))*x + (1 + O(3^8))*y + O(3^8 * ) """ # We assume that the elements of the sgb are such that lt(g) = p^v lm(g) to # avoid performing divisions @@ -713,11 +714,12 @@ cdef TateAlgebraElement reduce(gb, TateAlgebraElement v, stopval): sage: v = (x + y + 2*x^2*y - x^3*y^2).add_bigoh(8) sage: g1 = x*y + 3*x^2*y sage: g2 = x^3 + 9*y - sage: python_reduce([g1,g2], v, 8) # indirect doctest + sage: python_reduce([g1,g2], v, 8) # indirect doctest # needs sage.misc.cython (1 + O(3^8))*x + (1 + O(3^8))*y + O(3^8 * ) - sage: python_reduce([g1,g2], v, 5) # indirect doctest - (1 + O(3^8))*x + (1 + O(3^8))*y + (3^5 + O(3^8))*x^8*y^2 + (3^5 + 2*3^6 + 2*3^7 + O(3^8))*x^7*y + O(3^8 * ) + sage: python_reduce([g1,g2], v, 5) # indirect doctest # needs sage.misc.cython + (1 + O(3^8))*x + (1 + O(3^8))*y + (3^5 + O(3^8))*x^8*y^2 + + (3^5 + 2*3^6 + 2*3^7 + O(3^8))*x^7*y + O(3^8 * ) """ cdef dict coeffs = { } cdef TateAlgebraElement f diff --git a/src/sage/rings/tests.py b/src/sage/rings/tests.py index d7d14aa4e0a..13a205195d5 100644 --- a/src/sage/rings/tests.py +++ b/src/sage/rings/tests.py @@ -23,9 +23,9 @@ def prime_finite_field(): EXAMPLES:: sage: import sage.rings.tests - sage: K = sage.rings.tests.prime_finite_field(); K # optional - sage.rings.finite_rings + sage: K = sage.rings.tests.prime_finite_field(); K # needs sage.rings.finite_rings Finite Field of size ... - sage: K.cardinality().is_prime() # optional - sage.rings.finite_rings + sage: K.cardinality().is_prime() # needs sage.rings.finite_rings True """ from sage.rings.integer_ring import ZZ @@ -42,11 +42,11 @@ def finite_field(): EXAMPLES:: sage: import sage.rings.tests - sage: K = sage.rings.tests.finite_field(); K # optional - sage.rings.finite_rings + sage: K = sage.rings.tests.finite_field(); K # needs sage.rings.finite_rings Finite Field...of size ... - sage: K.cardinality().is_prime_power() # optional - sage.rings.finite_rings + sage: K.cardinality().is_prime_power() # needs sage.rings.finite_rings True - sage: while K.cardinality().is_prime(): # optional - sage.rings.finite_rings + sage: while K.cardinality().is_prime(): # needs sage.rings.finite_rings ....: K = sage.rings.tests.finite_field() """ from sage.rings.integer_ring import ZZ @@ -64,13 +64,14 @@ def small_finite_field(): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: import sage.rings.tests - sage: K = sage.rings.tests.small_finite_field(); K # optional - sage.rings.finite_rings + sage: K = sage.rings.tests.small_finite_field(); K Finite Field...of size ... - sage: q = K.cardinality() # optional - sage.rings.finite_rings - sage: q.is_prime_power() # optional - sage.rings.finite_rings + sage: q = K.cardinality() + sage: q.is_prime_power() True - sage: q <= 2^16 # optional - sage.rings.finite_rings + sage: q <= 2^16 True """ from sage.rings.integer_ring import ZZ @@ -107,7 +108,7 @@ def padic_field(): EXAMPLES:: sage: import sage.rings.tests - sage: sage.rings.tests.padic_field() # optional - sage.rings.padics + sage: sage.rings.tests.padic_field() # needs sage.rings.padics ...-adic Field with capped relative precision ... """ from sage.rings.integer_ring import ZZ @@ -124,7 +125,7 @@ def quadratic_number_field(): EXAMPLES:: sage: import sage.rings.tests - sage: K = sage.rings.tests.quadratic_number_field(); K # optional - sage.rings.number_field + sage: K = sage.rings.tests.quadratic_number_field(); K # needs sage.rings.number_field Number Field in a with defining polynomial x^2 ... with a = ... """ from sage.rings.integer_ring import ZZ @@ -142,9 +143,9 @@ def absolute_number_field(maxdeg=10): EXAMPLES:: sage: import sage.rings.tests - sage: K = sage.rings.tests.absolute_number_field(); K # optional - sage.rings.number_field + sage: K = sage.rings.tests.absolute_number_field(); K # needs sage.rings.number_field Number Field in a with defining polynomial ... - sage: K.degree() <= 10 # optional - sage.rings.number_field + sage: K.degree() <= 10 # needs sage.rings.number_field True """ from sage.rings.integer_ring import ZZ @@ -166,27 +167,28 @@ def relative_number_field(n=2, maxdeg=2): EXAMPLES:: + sage: # needs sage.rings.number_field sage: import sage.rings.tests - sage: K = sage.rings.tests.relative_number_field(3); K # optional - sage.rings.number_field + sage: K = sage.rings.tests.relative_number_field(3); K Number Field in aaa with defining polynomial x^2 ... over its base field - sage: K.relative_degree() # optional - sage.rings.number_field + sage: K.relative_degree() 2 - sage: L = K.base_ring() # optional - sage.rings.number_field - sage: L.relative_degree() # optional - sage.rings.number_field + sage: L = K.base_ring() + sage: L.relative_degree() 2 - sage: M = L.base_ring() # optional - sage.rings.number_field - sage: M.relative_degree() # optional - sage.rings.number_field + sage: M = L.base_ring() + sage: M.relative_degree() 2 - sage: M.base_ring() is QQ # optional - sage.rings.number_field + sage: M.base_ring() is QQ True TESTS: Check that :trac:`32117` is fixed:: - sage: set_random_seed(3030) # optional - sage.rings.number_field - sage: from sage.rings.tests import relative_number_field # optional - sage.rings.number_field - sage: _ = relative_number_field(3) # optional - sage.rings.number_field + sage: set_random_seed(3030) + sage: from sage.rings.tests import relative_number_field + sage: _ = relative_number_field(3) # needs sage.rings.number_field """ from sage.rings.integer_ring import ZZ K = absolute_number_field(maxdeg) @@ -333,7 +335,7 @@ def test_random_elements(level=MAX_LEVEL, trials=1): EXAMPLES:: sage: import sage.rings.tests - sage: sage.rings.tests.test_random_elements(trials=2, seed=0) # optional - sage.rings.number_field + sage: sage.rings.tests.test_random_elements(trials=2, seed=0) # needs sage.rings.number_field survived 0 tests Rational Field -1/2 @@ -343,6 +345,7 @@ def test_random_elements(level=MAX_LEVEL, trials=1): -12 ---- + sage: # needs sage.rings.finite_rings sage.rings.number_field sage.rings.padics sage: sage.rings.tests.test_random_elements(trials=10) survived 0 tests... sage: sage.rings.tests.test_random_elements(trials=1000) # long time (5 seconds) @@ -363,8 +366,9 @@ def test_random_elements(level=MAX_LEVEL, trials=1): @random_testing def test_random_arith(level=MAX_LEVEL, trials=1): """ - Create random elements of random rings and does some arithmetic - with them, until a crash occurs, in which case an exception is + Create random elements of random rings and do some arithmetic with them. + + Repeats until a crash occurs, in which case an exception is raised. Defaults to running a single trial, but more can be specified. To run tests in an infinite loop, you could use:: @@ -372,17 +376,18 @@ def test_random_arith(level=MAX_LEVEL, trials=1): INPUT: - - level -- (default: MAX_LEVEL); controls the types of rings to use - - trials -- A positive integer (default 1); the number of trials + - ``level`` -- (default: ``MAX_LEVEL``); controls the types of rings to use + - ``trials`` -- A positive integer (default: 1); the number of trials to run. - - seed -- the random seed to use; if not specified, uses a truly + - ``seed`` -- the random seed to use; if not specified, uses a truly random seed. - - print_seed -- If True (default False), prints the random seed chosen. + - ``print_seed`` -- If ``True`` (default: ``False``), prints the random seed chosen. EXAMPLES:: + sage: # needs sage.rings.finite_rings sage.rings.number_field sage.rings.padics sage: import sage.rings.tests - sage: sage.rings.tests.test_random_arith(trials=2, seed=0) # optional - sage.rings.number_field + sage: sage.rings.tests.test_random_arith(trials=2, seed=0) survived 0 tests Rational Field -1/2 -1/95 @@ -391,7 +396,6 @@ def test_random_arith(level=MAX_LEVEL, trials=1): Number Field in a with defining polynomial x^2 - 15083 with a = 122.81286577553673? a -2*a - 1 2*a - 30164 - sage: sage.rings.tests.test_random_arith(trials=10) survived 0 tests... sage: sage.rings.tests.test_random_arith(trials=1000) # long time (5 seconds?) @@ -438,15 +442,15 @@ def test_karatsuba_multiplication(base_ring, maxdeg1, maxdeg2, Test Karatsuba multiplication of polynomials of small degree over some common rings:: sage: rings = [QQ] - sage: rings += [ZZ[I], ZZ[I, sqrt(2)]] # optional - sage.rings.number_field - sage: rings += [GF(49, 'a')] # optional - sage.rings.finite_rings - sage: rings += [MatrixSpace(GF(17), 3)] # optional - sage.rings.finite_rings sage.modules + sage: rings += [ZZ[I], ZZ[I, sqrt(2)]] # needs sage.rings.number_field sage.symbolic + sage: rings += [GF(49, 'a')] # needs sage.rings.finite_rings + sage: rings += [MatrixSpace(GF(17), 3)] # needs sage.modules sage: for C in rings: ....: test_karatsuba_multiplication(C, 10, 10) Zero-tests over ``QQbar`` are currently very slow, so we test only very small examples:: - sage: test_karatsuba_multiplication(QQbar, 3, 3, numtests=2) # long time # optional - sage.rings.number_field + sage: test_karatsuba_multiplication(QQbar, 3, 3, numtests=2) # long time, needs sage.rings.number_field Larger degrees (over ``ZZ``, using FLINT):: diff --git a/src/sage/rings/universal_cyclotomic_field.py b/src/sage/rings/universal_cyclotomic_field.py index 7e7b8d13b90..8afd960006c 100644 --- a/src/sage/rings/universal_cyclotomic_field.py +++ b/src/sage/rings/universal_cyclotomic_field.py @@ -523,14 +523,14 @@ def _symbolic_(self, R): r""" TESTS:: - sage: SR(E(7)) # optional - sage.symbolic + sage: SR(E(7)) # needs sage.symbolic e^(2/7*I*pi) - sage: SR(E(5) + 2*E(5,2) + 3*E(5,3)) # optional - sage.symbolic + sage: SR(E(5) + 2*E(5,2) + 3*E(5,3)) # needs sage.symbolic -sqrt(5) + 1/4*I*sqrt(2*sqrt(5) + 10) - 1/4*I*sqrt(-2*sqrt(5) + 10) - 3/2 Test that the bug reported in :trac:`19912` has been fixed:: - sage: SR(1+E(4)) # optional - sage.symbolic + sage: SR(1+E(4)) # needs sage.symbolic I + 1 """ from sage.symbolic.constants import pi, I @@ -582,7 +582,8 @@ def to_cyclotomic_field(self, R=None): Using a non-standard embedding:: - sage: CF = CyclotomicField(5,embedding=CC(exp(4*pi*i/5))) + sage: # needs sage.symbolic + sage: CF = CyclotomicField(5, embedding=CC(exp(4*pi*i/5))) sage: x = E(5) sage: CC(x) 0.309016994374947 + 0.951056516295154*I @@ -723,7 +724,7 @@ def _eval_real_(self, R): sage: RR(E(7) + E(7,6)) 1.24697960371747 - sage: 2*cos(2*pi/7).n() + sage: 2*cos(2*pi/7).n() # needs sage.symbolic 1.24697960371747 Check that units are evaluated correctly (:trac:`23775`):: @@ -1485,7 +1486,7 @@ def _element_constructor_(self, elt): Some conversions from symbolic functions are possible:: sage: UCF = UniversalCyclotomicField() - sage: [UCF(sin(pi/k, hold=True)) for k in range(1,10)] + sage: [UCF(sin(pi/k, hold=True)) for k in range(1,10)] # needs sage.symbolic [0, 1, -1/2*E(12)^7 + 1/2*E(12)^11, @@ -1495,7 +1496,7 @@ def _element_constructor_(self, elt): -1/2*E(28)^19 + 1/2*E(28)^23, 1/2*E(16)^3 - 1/2*E(16)^5, -1/2*E(36)^25 + 1/2*E(36)^29] - sage: [UCF(cos(pi/k, hold=True)) for k in range(1,10)] + sage: [UCF(cos(pi/k, hold=True)) for k in range(1,10)] # needs sage.symbolic [-1, 0, 1/2, @@ -1506,8 +1507,9 @@ def _element_constructor_(self, elt): 1/2*E(16) - 1/2*E(16)^7, -1/2*E(9)^4 - 1/2*E(9)^5] - sage: UCF(1 + sqrt(-3/5)) - 4/5*E(15) + 4/5*E(15)^2 + 4/5*E(15)^4 + 6/5*E(15)^7 + 4/5*E(15)^8 + 6/5*E(15)^11 + 6/5*E(15)^13 + 6/5*E(15)^14 + sage: UCF(1 + sqrt(-3/5)) # needs sage.symbolic + 4/5*E(15) + 4/5*E(15)^2 + 4/5*E(15)^4 + 6/5*E(15)^7 + 4/5*E(15)^8 + + 6/5*E(15)^11 + 6/5*E(15)^13 + 6/5*E(15)^14 .. TODO:: diff --git a/src/sage/rings/valuation/valuation.py b/src/sage/rings/valuation/valuation.py index c0e78efaf95..ec39b0d98ea 100644 --- a/src/sage/rings/valuation/valuation.py +++ b/src/sage/rings/valuation/valuation.py @@ -911,7 +911,7 @@ def mac_lane_approximant(self, G, valuation, approximants=None): v = valuation while not v.is_gauss_valuation(): if v(G) <= v._base_valuation(G): - raise ValueError("The valuation %r is not an approximant for a valuation which extends %r with respect to %r since the valuation of %r does not increase in every step"%(valuation, self, G, G)) + raise ValueError("The valuation %r is not an approximant for a valuation which extends %r with respect to %r since the valuation of %r does not increase in every step" % (valuation, self, G, G)) v = v._base_valuation if approximants is None: @@ -921,15 +921,15 @@ def mac_lane_approximant(self, G, valuation, approximants=None): greater_approximants = [w for w in approximants if w >= valuation] if len(greater_approximants) > 1: - raise ValueError("The valuation %r does not approximate a unique extension of %r with respect to %r"%(valuation, self, G)) + raise ValueError("The valuation %r does not approximate a unique extension of %r with respect to %r" % (valuation, self, G)) if len(greater_approximants) == 1: return greater_approximants[0] smaller_approximants = [w for w in approximants if w <= valuation] if len(smaller_approximants) > 1: - raise ValueError("The valuation %r is not approximated by a unique extension of %r with respect to %r"%(valuation, self, G)) + raise ValueError("The valuation %r is not approximated by a unique extension of %r with respect to %r" % (valuation, self, G)) if len(smaller_approximants) == 0: - raise ValueError("The valuation %r is not related to an extension of %r with respect to %r"%(valuation, self, G)) + raise ValueError("The valuation %r is not related to an extension of %r with respect to %r" % (valuation, self, G)) return smaller_approximants[0] def montes_factorization(self, G, assume_squarefree=False, required_precision=None): diff --git a/src/sage/rings/valuation/valuation_space.py b/src/sage/rings/valuation/valuation_space.py index 415a1197ed9..be0e9192c7c 100644 --- a/src/sage/rings/valuation/valuation_space.py +++ b/src/sage/rings/valuation/valuation_space.py @@ -486,7 +486,7 @@ def element_with_valuation(self, s): return self.domain().one() exp = s / self.value_group().gen() if exp not in ZZ: - raise NotImplementedError("s must be a multiple of %r but %r is not"%(self.value_group().gen(), s)) + raise NotImplementedError("s must be a multiple of %r but %r is not" % (self.value_group().gen(), s)) ret = self.domain()(self.uniformizer() ** ZZ(exp)) return self.simplify(ret, error=s) @@ -594,7 +594,7 @@ def extension(self, ring): extensions = self.extensions(ring) assert(extensions) if len(extensions) > 1: - raise ValueError("there is no unique extension of %r from %r to %r"%(self, self.domain(), ring)) + raise ValueError("there is no unique extension of %r from %r to %r" % (self, self.domain(), ring)) return extensions[0] def extensions(self, ring): @@ -610,7 +610,7 @@ def extensions(self, ring): """ if ring is self.domain(): return [self] - raise NotImplementedError("extending %r from %r to %r not implemented"%(self, self.domain(), ring)) + raise NotImplementedError("extending %r from %r to %r not implemented" % (self, self.domain(), ring)) def restriction(self, ring): r""" @@ -626,7 +626,7 @@ def restriction(self, ring): """ if ring is self.domain(): return self - raise NotImplementedError("restricting %r from %r to %r not implemented"%(self, self.domain(), ring)) + raise NotImplementedError("restricting %r from %r to %r not implemented" % (self, self.domain(), ring)) def change_domain(self, ring): r""" @@ -649,7 +649,7 @@ def change_domain(self, ring): return self.extension(ring) if ring.is_subring(self.domain()): return self.restriction(ring) - raise NotImplementedError("changing %r from %r to %r not implemented"%(self, self.domain(), ring)) + raise NotImplementedError("changing %r from %r to %r not implemented" % (self, self.domain(), ring)) def scale(self, scalar): r""" @@ -732,11 +732,11 @@ def separating_element(self, others): for other in others + [self]: if other.parent() is not self.parent(): - raise ValueError("all valuations must be valuations on %r but %r is a valuation on %r"%(self.domain(), other, other.domain())) + raise ValueError("all valuations must be valuations on %r but %r is a valuation on %r" % (self.domain(), other, other.domain())) if not other.is_discrete_valuation(): raise ValueError("all valuations must be discrete valuations but %r is not" % (other,)) if other.is_trivial(): - raise ValueError("all valuations must be non-trivial but %r is not"%(other,)) + raise ValueError("all valuations must be non-trivial but %r is not" % (other,)) if len(others) == 0: return self.uniformizer() @@ -882,7 +882,7 @@ def _weakly_separating_element(self, other): ret = self.uniformizer() if self(ret) > other(ret): return ret - raise NotImplementedError("weakly separating element for %r and %r"%(self, other)) + raise NotImplementedError("weakly separating element for %r and %r" % (self, other)) def shift(self, x, s): r""" diff --git a/src/sage/rings/valuation/value_group.py b/src/sage/rings/valuation/value_group.py index 816f142e0c7..57a6c1b2719 100644 --- a/src/sage/rings/valuation/value_group.py +++ b/src/sage/rings/valuation/value_group.py @@ -399,11 +399,11 @@ def _element_with_valuation(self, subgroup, s): """ if s not in self: - raise ValueError("s must be in the value group but %r is not in %r."%(s, self)) + raise ValueError("s must be in the value group but %r is not in %r." % (s, self)) i = self.index(subgroup) x = s/self.gen() - a = x%i + a = x % i if abs(a-i) < a: a -= i b = (x-a)/i @@ -593,7 +593,7 @@ def _repr_(self): """ if self.is_trivial(): return "Trivial Additive Abelian Semigroup" - return "Additive Abelian Semigroup generated by %s"%(', '.join([repr(g) for g in self._generators]),) + return "Additive Abelian Semigroup generated by %s" % (', '.join([repr(g) for g in self._generators]),) def __add__(self, other): r""" diff --git a/src/sage/schemes/affine/affine_homset.py b/src/sage/schemes/affine/affine_homset.py index 8c70602ad79..52ea3f83c85 100644 --- a/src/sage/schemes/affine/affine_homset.py +++ b/src/sage/schemes/affine/affine_homset.py @@ -211,8 +211,8 @@ def points(self, **kwds): EXAMPLES: The bug reported at #11526 is fixed:: sage: A2 = AffineSpace(ZZ, 2) - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: A2(F).points() # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: A2(F).points() [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)] :: @@ -228,23 +228,23 @@ def points(self, **kwds): :: sage: u = QQ['u'].0 - sage: K. = NumberField(u^2 + 3) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: len(A(K).points(bound=2)) # optional - sage.rings.number_field + sage: K. = NumberField(u^2 + 3) # needs sage.rings.number_field + sage: A. = AffineSpace(K, 2) # needs sage.rings.number_field + sage: len(A(K).points(bound=2)) # needs sage.rings.number_field 1849 :: sage: A. = AffineSpace(QQ, 2) sage: E = A.subscheme([x^2 + y^2 - 1, y^2 - x^3 + x^2 + x - 1]) - sage: E(A.base_ring()).points() + sage: E(A.base_ring()).points() # needs sage.libs.singular [(-1, 0), (0, -1), (0, 1), (1, 0)] :: - sage: A. = AffineSpace(CC, 2) + sage: A. = AffineSpace(CC, 2) # needs sage.rings.real_mpfr sage: E = A.subscheme([y^3 - x^3 - x^2, x*y]) - sage: E(A.base_ring()).points() + sage: E(A.base_ring()).points() # needs sage.libs.singular sage.rings.real_mpfr verbose 0 (...: affine_homset.py, points) Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly. @@ -253,9 +253,9 @@ def points(self, **kwds): :: - sage: A. = AffineSpace(CDF, 2) - sage: E = A.subscheme([x1^2 + x2^2 + x1*x2, x1 + x2]) - sage: E(A.base_ring()).points() + sage: A. = AffineSpace(CDF, 2) # needs sage.rings.complex_double + sage: E = A.subscheme([x1^2 + x2^2 + x1*x2, x1 + x2]) # needs sage.libs.singular sage.rings.complex_double + sage: E(A.base_ring()).points() # needs sage.libs.singular sage.rings.complex_double verbose 0 (...: affine_homset.py, points) Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly. @@ -393,28 +393,29 @@ def numerical_points(self, F=None, **kwds): EXAMPLES:: - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: X = A.subscheme([x^3 - v^2*y, y - v*x^2 + 3]) # optional - sage.rings.number_field - sage: L = X(K).numerical_points(F=RR); L # abs tol 1e-14 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: A. = AffineSpace(K, 2) + sage: X = A.subscheme([x^3 - v^2*y, y - v*x^2 + 3]) + sage: L = X(K).numerical_points(F=RR); L # abs tol 1e-14 [(-1.18738247880014, -0.558021142104134), (1.57693558184861, 1.30713548084184), (4.80659931965815, 37.0162574656220)] - sage: L[0].codomain() # optional - sage.rings.number_field + sage: L[0].codomain() Affine Space of dimension 2 over Real Field with 53 bits of precision :: sage: A. = AffineSpace(QQ, 2) sage: X = A.subscheme([y^2 - x^2 - 3*x, x^2 - 10*y]) - sage: len(X(QQ).numerical_points(F=ComplexField(100))) + sage: len(X(QQ).numerical_points(F=ComplexField(100))) # needs sage.libs.singular 4 :: sage: A. = AffineSpace(QQ, 2) sage: E = A.subscheme([30*x1^100 + 1000*x2^2 + 2000*x1*x2 + 1, x1 + x2]) - sage: len(E(A.base_ring()).numerical_points(F=CDF, zero_tolerance=1e-9)) + sage: len(E(A.base_ring()).numerical_points(F=CDF, zero_tolerance=1e-9)) # needs sage.libs.singular 100 TESTS:: @@ -430,7 +431,7 @@ def numerical_points(self, F=None, **kwds): sage: A. = AffineSpace(QQ, 2) sage: X = A.subscheme([y^2 - x^2 - 3*x, x^2 - 10*y]) - sage: X(QQ).numerical_points(F=CC, zero_tolerance=-1) + sage: X(QQ).numerical_points(F=CC, zero_tolerance=-1) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: tolerance must be positive diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py index d16d5ec37fc..1fc3f207464 100644 --- a/src/sage/schemes/affine/affine_morphism.py +++ b/src/sage/schemes/affine/affine_morphism.py @@ -156,8 +156,8 @@ def __init__(self, parent, polys, check=True): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([x - y]) sage: H = Hom(X, X) - sage: u,v,w = X.coordinate_ring().gens() - sage: H([u, v, u + v]) + sage: u,v,w = X.coordinate_ring().gens() # needs sage.libs.singular + sage: H([u, v, u + v]) # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: x - y Defn: Defined on coordinates by sending (x, y, z) to (y, y, 2*y) @@ -167,8 +167,8 @@ def __init__(self, parent, polys, check=True): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([x^2 - y^2]) sage: H = Hom(X, X) - sage: u,v,w = X.coordinate_ring().gens() - sage: H([u, v, (u+1)/v]) + sage: u,v,w = X.coordinate_ring().gens() # needs sage.libs.singular + sage: H([u, v, (u+1)/v]) # needs sage.libs.singular Traceback (most recent call last): ... ArithmeticError: Division failed. The numerator is not a multiple of the denominator. @@ -249,13 +249,14 @@ def __call__(self, x, check=True): Defn: Defined on coordinates by sending (u, v) to (u + v, u*v) - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P = T(F)(1, a) # optional - sage.rings.finite_rings - sage: h(P) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P = T(F)(1, a) + sage: h(P) (a + 1, a) - sage: h(P).domain() # optional - sage.rings.finite_rings + sage: h(P).domain() Spectrum of Finite Field in a of size 2^2 - sage: h.change_ring(F)(P) # optional - sage.rings.finite_rings + sage: h.change_ring(F)(P) (a + 1, a) """ from sage.schemes.affine.affine_point import SchemeMorphism_point_affine @@ -298,6 +299,7 @@ def __eq__(self, right): :: + sage: # needs sage.rings.real_mpfr sage: A. = AffineSpace(CC, 3) sage: H = End(A) sage: f = H([x^2 - CC.0*x*y + z*x, 1/z^2 - y^2, 5*x]) @@ -324,6 +326,7 @@ def __ne__(self, right): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: A. = AffineSpace(RR, 2) sage: H = End(A) sage: f = H([x^2 - y, y^2]) @@ -458,6 +461,7 @@ def homogenize(self, n): :: + sage: # needs sage.rings.real_mpfr sage: A. = AffineSpace(CC, 2) sage: H = Hom(A, A) sage: f = H([(x^2-2)/(x*y), y^2 - x]) @@ -473,7 +477,7 @@ def homogenize(self, n): sage: X = A.subscheme([x - y^2]) sage: H = Hom(X, X) sage: f = H([9*y^2, 3*y]) - sage: f.homogenize(2) + sage: f.homogenize(2) # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Integer Ring defined by: x1^2 - x0*x2 Defn: Defined on coordinates by sending (x0 : x1 : x2) to @@ -503,11 +507,12 @@ def homogenize(self, n): :: - sage: R. = PolynomialRing(QQbar) # optional - sage.rings.number_field - sage: A. = AffineSpace(R, 2) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([QQbar(sqrt(2))*x*y, a*x^2]) # optional - sage.rings.number_field sage.symbolic - sage: f.homogenize(2) # optional - sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field + sage: R. = PolynomialRing(QQbar) + sage: A. = AffineSpace(R, 2) + sage: H = End(A) + sage: f = H([QQbar(sqrt(2))*x*y, a*x^2]) # needs sage.symbolic + sage: f.homogenize(2) # needs sage.libs.singular sage.symbolic Scheme endomorphism of Projective Space of dimension 2 over Univariate Polynomial Ring in a over Algebraic Field Defn: Defined on coordinates by sending (x0 : x1 : x2) to @@ -534,10 +539,11 @@ def homogenize(self, n): :: - sage: A. = AffineSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([2*z / (z^2 + 2*z + 3)]) # optional - sage.rings.number_field - sage: f.homogenize(1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: A. = AffineSpace(QQbar, 1) + sage: H = End(A) + sage: f = H([2*z / (z^2 + 2*z + 3)]) + sage: f.homogenize(1) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x0 : x1) to @@ -545,11 +551,12 @@ def homogenize(self, n): :: - sage: R. = QQbar[] # optional - sage.rings.number_field - sage: A. = AffineSpace(R, 1) # optional - sage.rings.number_field - sage: H = Hom(A, A) # optional - sage.rings.number_field - sage: F = H([d*x^2 + c]) # optional - sage.rings.number_field - sage: F.homogenize(1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: R. = QQbar[] + sage: A. = AffineSpace(R, 1) + sage: H = Hom(A, A) + sage: F = H([d*x^2 + c]) + sage: F.homogenize(1) Scheme endomorphism of Projective Space of dimension 1 over Multivariate Polynomial Ring in c, d over Algebraic Field Defn: Defined on coordinates by sending (x0 : x1) to @@ -640,7 +647,7 @@ def as_dynamical_system(self): sage: A. = AffineSpace(ZZ, 3) sage: H = End(A) sage: f = H([x^2, y^2, z^2]) - sage: type(f.as_dynamical_system()) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: @@ -648,23 +655,23 @@ def as_dynamical_system(self): sage: A. = AffineSpace(ZZ, 2) sage: H = End(A) sage: f = H([x^2 - y^2, y^2]) - sage: type(f.as_dynamical_system()) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: - sage: A. = AffineSpace(GF(5), 1) # optional - sage.rings.finite_rings - sage: H = End(A) # optional - sage.rings.finite_rings - sage: f = H([x^2]) # optional - sage.rings.finite_rings - sage: type(f.as_dynamical_system()) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(5), 1) + sage: H = End(A) + sage: f = H([x^2]) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: sage: P. = AffineSpace(RR, 2) - sage: f = DynamicalSystem([x^2 + y^2, y^2], P) - sage: g = f.as_dynamical_system() - sage: g is f + sage: f = DynamicalSystem([x^2 + y^2, y^2], P) # needs sage.schemes + sage: g = f.as_dynamical_system() # needs sage.schemes + sage: g is f # needs sage.schemes True """ from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem @@ -699,17 +706,18 @@ def global_height(self, prec=None): sage: A. = AffineSpace(QQ, 1) sage: H = Hom(A, A) sage: f = H([1/1331*x^2 + 4000]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 15.4877354584971 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: k. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: A. = AffineSpace(k, 2) # optional - sage.rings.number_field - sage: H = Hom(A, A) # optional - sage.rings.number_field - sage: f = H([13*w*x^2 + 4*y, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.global_height(prec=2) # optional - sage.rings.number_field + sage: k. = NumberField(x^2 + 5) + sage: A. = AffineSpace(k, 2) + sage: H = Hom(A, A) + sage: f = H([13*w*x^2 + 4*y, 1/w*y^2]) + sage: f.global_height(prec=2) 4.0 :: @@ -717,7 +725,7 @@ def global_height(self, prec=None): sage: A. = AffineSpace(ZZ, 1) sage: H = Hom(A, A) sage: f = H([7*x^2 + 1513]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 7.32184971378836 :: @@ -726,7 +734,7 @@ def global_height(self, prec=None): sage: B. = AffineSpace(QQ, 2) sage: H = Hom(A, B) sage: f = H([1/3*x^2 + 10, 7*x^3]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 3.40119738166216 :: @@ -735,7 +743,7 @@ def global_height(self, prec=None): sage: A. = AffineSpace(QQ, 1) sage: H = Hom(P, A) sage: f = H([1/1331*x^2 + 4000*y]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 15.4877354584971 """ return self.homogenize(0).global_height(prec=prec) @@ -761,7 +769,7 @@ def local_height(self, v, prec=None): sage: P. = AffineSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height(1331) + sage: f.local_height(1331) # needs sage.rings.real_mpfr 7.19368581839511 :: @@ -769,7 +777,7 @@ def local_height(self, v, prec=None): sage: P. = AffineSpace(QQ, 3) sage: H = Hom(P, P) sage: f = H([4*x^2 + 3/100*y^2, 8/210*x*y, 1/10000*z^2]) - sage: f.local_height(2) + sage: f.local_height(2) # needs sage.rings.real_mpfr 2.77258872223978 :: @@ -777,17 +785,18 @@ def local_height(self, v, prec=None): sage: P. = AffineSpace(QQ, 3) sage: H = Hom(P, P) sage: f = H([4*x^2 + 3/100*y^2, 8/210*x*y, 1/10000*z^2]) - sage: f.local_height(2, prec=2) + sage: f.local_height(2, prec=2) # needs sage.rings.real_mpfr 3.0 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = AffineSpace(K, 2) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) + sage: f.local_height(K.ideal(3)) 1.09861228866811 """ K = FractionField(self.domain().base_ring()) @@ -816,7 +825,7 @@ def local_height_arch(self, i, prec=None): sage: P. = AffineSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]); - sage: f.local_height_arch(0) + sage: f.local_height_arch(0) # needs sage.rings.real_mpfr 5.34710753071747 :: @@ -824,17 +833,18 @@ def local_height_arch(self, i, prec=None): sage: P. = AffineSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]); - sage: f.local_height_arch(0, prec=5) + sage: f.local_height_arch(0, prec=5) # needs sage.rings.real_mpfr 5.2 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.local_height_arch(1) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = AffineSpace(K, 2) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) + sage: f.local_height_arch(1) 0.6931471805599453094172321214582 """ K = FractionField(self.domain().base_ring()) @@ -861,7 +871,7 @@ def jacobian(self): sage: A. = AffineSpace(QQ, 1) sage: H = End(A) sage: f = H([z^2 - 3/4]) - sage: f.jacobian() + sage: f.jacobian() # needs sage.modules [2*z] :: @@ -869,7 +879,7 @@ def jacobian(self): sage: A. = AffineSpace(QQ, 2) sage: H = End(A) sage: f = H([x^3 - 25*x + 12*y, 5*y^2*x - 53*y + 24]) - sage: f.jacobian() + sage: f.jacobian() # needs sage.modules [ 3*x^2 - 25 12] [ 5*y^2 10*x*y - 53] @@ -878,7 +888,7 @@ def jacobian(self): sage: A. = AffineSpace(ZZ, 2) sage: H = End(A) sage: f = H([(x^2 - x*y)/(1+y), (5+y)/(2+x)]) - sage: f.jacobian() + sage: f.jacobian() # needs sage.modules [ (2*x - y)/(y + 1) (-x^2 - x)/(y^2 + 2*y + 1)] [ (-y - 5)/(x^2 + 4*x + 4) 1/(x + 2)] """ @@ -904,7 +914,7 @@ def _matrix_times_polymap_(self, mat, h): sage: A. = AffineSpace(ZZ, 1) sage: H = Hom(A, A) sage: f = H([x^2 + 1]) - sage: matrix([[1,2], [0,1]]) * f + sage: matrix([[1,2], [0,1]]) * f # needs sage.modules Scheme endomorphism of Affine Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x) to (x^2 + 3) @@ -915,7 +925,7 @@ def _matrix_times_polymap_(self, mat, h): sage: A2 = AffineSpace(ZZ, 2) sage: H = Hom(A1, A2) sage: f = H([x^2 + 1, x^2 - 1]) - sage: matrix([[1,2,3], [0,1,2], [0,0,1]]) * f + sage: matrix([[1,2,3], [0,1,2], [0,0,1]]) * f # needs sage.modules Scheme morphism: From: Affine Space of dimension 1 over Integer Ring To: Affine Space of dimension 2 over Integer Ring @@ -948,7 +958,7 @@ def _polymap_times_matrix_(self, mat, h): sage: A. = AffineSpace(ZZ, 1) sage: H = Hom(A, A) sage: f = H([x^2 + 1]) - sage: f * matrix([[1,2], [0,1]]) + sage: f * matrix([[1,2], [0,1]]) # needs sage.modules Scheme endomorphism of Affine Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x) to (x^2 + 4*x + 5) @@ -959,7 +969,7 @@ def _polymap_times_matrix_(self, mat, h): sage: A2 = AffineSpace(ZZ, 2) sage: H = Hom(A1, A2) sage: f = H([x^2 + 1, x^2 - 1]) - sage: f * matrix([[1,2], [0,1]]) + sage: f * matrix([[1,2], [0,1]]) # needs sage.modules Scheme morphism: From: Affine Space of dimension 1 over Integer Ring To: Affine Space of dimension 2 over Integer Ring @@ -972,8 +982,8 @@ def _polymap_times_matrix_(self, mat, h): sage: P2. = AffineSpace(QQ, 3) sage: H = Hom(P2, P) sage: f = H([u^2 + v^2, w^2]) - sage: m = matrix([[1,1,1], [1,0,1], [0,0,1]]) - sage: m*f + sage: m = matrix([[1,1,1], [1,0,1], [0,0,1]]) # needs sage.modules + sage: m*f # needs sage.modules Scheme morphism: From: Affine Space of dimension 3 over Rational Field To: Affine Space of dimension 2 over Rational Field @@ -1053,25 +1063,27 @@ def weil_restriction(self): EXAMPLES:: - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([x^2 - y^2, y^2]) # optional - sage.rings.number_field - sage: f.weil_restriction() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: A. = AffineSpace(K, 2) + sage: H = End(A) + sage: f = H([x^2 - y^2, y^2]) + sage: f.weil_restriction() Scheme endomorphism of Affine Space of dimension 4 over Rational Field Defn: Defined on coordinates by sending (z0, z1, z2, z3) to (z0^2 + 5*z1^2 - z2^2 - 5*z3^2, 2*z0*z1 - 2*z2*z3, z2^2 + 5*z3^2, 2*z2*z3) :: - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: PS. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = Hom(PS, PS) # optional - sage.rings.number_field - sage: f = H([x, y]) # optional - sage.rings.number_field - sage: F = f.weil_restriction() # optional - sage.rings.number_field - sage: P = PS(2, 1) # optional - sage.rings.number_field - sage: Q = P.weil_restriction() # optional - sage.rings.number_field - sage: f(P).weil_restriction() == F(Q) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: PS. = AffineSpace(K, 2) + sage: H = Hom(PS, PS) + sage: f = H([x, y]) + sage: F = f.weil_restriction() + sage: P = PS(2, 1) + sage: Q = P.weil_restriction() + sage: f(P).weil_restriction() == F(Q) True """ if any(isinstance(f, FractionFieldElement) for f in self): @@ -1099,25 +1111,26 @@ def reduce_base_field(self): EXAMPLES:: - sage: K. = GF(5^4) # optional - sage.rings.finite_rings - sage: A. = AffineSpace(K, 1) # optional - sage.rings.finite_rings - sage: A2. = AffineSpace(K, 2) # optional - sage.rings.finite_rings - sage: H = End(A) # optional - sage.rings.finite_rings - sage: H2 = Hom(A, A2) # optional - sage.rings.finite_rings - sage: H3 = Hom(A2, A) # optional - sage.rings.finite_rings - sage: f = H([x^2 + 2*(t^3 + t^2 + t + 3)]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(5^4) + sage: A. = AffineSpace(K, 1) + sage: A2. = AffineSpace(K, 2) + sage: H = End(A) + sage: H2 = Hom(A, A2) + sage: H3 = Hom(A2, A) + sage: f = H([x^2 + 2*(t^3 + t^2 + t + 3)]) + sage: f.reduce_base_field() Scheme endomorphism of Affine Space of dimension 1 over Finite Field in t2 of size 5^2 Defn: Defined on coordinates by sending (x) to (x^2 + (2*t2)) - sage: f2 = H2([x^2 + 4, 2*x]) # optional - sage.rings.finite_rings - sage: f2.reduce_base_field() # optional - sage.rings.finite_rings + sage: f2 = H2([x^2 + 4, 2*x]) + sage: f2.reduce_base_field() Scheme morphism: From: Affine Space of dimension 1 over Finite Field of size 5 To: Affine Space of dimension 2 over Finite Field of size 5 Defn: Defined on coordinates by sending (x) to (x^2 - 1, 2*x) - sage: f3 = H3([a^2 + t*b]) # optional - sage.rings.finite_rings - sage: f3.reduce_base_field() # optional - sage.rings.finite_rings + sage: f3 = H3([a^2 + t*b]) + sage: f3.reduce_base_field() Scheme morphism: From: Affine Space of dimension 2 over Finite Field in t of size 5^4 To: Affine Space of dimension 1 over Finite Field in t of size 5^4 @@ -1125,23 +1138,25 @@ def reduce_base_field(self): :: - sage: K. = CyclotomicField(4) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([x^2 + v]) # optional - sage.rings.number_field - sage: g = f.reduce_base_field(); g # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(4) + sage: A. = AffineSpace(K, 1) + sage: H = End(A) + sage: f = H([x^2 + v]) + sage: g = f.reduce_base_field(); g Scheme endomorphism of Affine Space of dimension 1 over Cyclotomic Field of order 4 and degree 2 Defn: Defined on coordinates by sending (x) to (x^2 + v) - sage: g.base_ring() is K # optional - sage.rings.number_field + sage: g.base_ring() is K True :: - sage: A. = AffineSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: A. = AffineSpace(QQbar, 1) + sage: H = End(A) + sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)]) # needs sage.symbolic + sage: f.reduce_base_field() # needs sage.symbolic Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...? Defn: Defined on coordinates by sending (x) to @@ -1149,11 +1164,12 @@ def reduce_base_field(self): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: A. = AffineSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([QQbar(3^(1/3))*x^2 + QQbar(sqrt(-2))]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: A. = AffineSpace(QQbar, 1) + sage: H = End(A) + sage: f = H([QQbar(3^(1/3))*x^2 + QQbar(sqrt(-2))]) # needs sage.symbolic + sage: f.reduce_base_field() # needs sage.symbolic Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^6 + 6*y^4 - 6*y^3 + 12*y^2 + 36*y + 17 with a = 1.442249570307409? + 1.414213562373095?*I @@ -1164,14 +1180,15 @@ def reduce_base_field(self): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^3 - x + 1, # optional - sage.rings.number_field - ....: embedding=(x^3+x+1).roots(ring=CC)[0][0]) - sage: A. = AffineSpace(K, 1) # optional - sage.rings.number_field - sage: A2. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = Hom(A, A2) # optional - sage.rings.number_field - sage: f = H([x^2 + a*x + 3, 5*x]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - x + 1, + ....: embedding=(x^3 + x + 1).roots(ring=CC)[0][0]) + sage: A. = AffineSpace(K, 1) + sage: A2. = AffineSpace(K, 2) + sage: H = Hom(A, A2) + sage: f = H([x^2 + a*x + 3, 5*x]) + sage: f.reduce_base_field() Scheme morphism: From: Affine Space of dimension 1 over Number Field in a with defining polynomial x^3 - x + 1 with a = -1.324717957244746? @@ -1181,21 +1198,23 @@ def reduce_base_field(self): :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([3*x^2 + x + 1]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: A. = AffineSpace(K, 1) + sage: H = End(A) + sage: f = H([3*x^2 + x + 1]) + sage: f.reduce_base_field() Scheme endomorphism of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x) to (3*x^2 + x + 1) :: - sage: K. = GF(5^6) # optional - sage.rings.finite_rings - sage: A. = AffineSpace(K, 1) # optional - sage.rings.finite_rings - sage: H = End(A) # optional - sage.rings.finite_rings - sage: f = H([x^2 + x*(t^3 + 2*t^2 + 4*t) + (t^5 + 3*t^4 + t^2 + 4*t)]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(5^6) + sage: A. = AffineSpace(K, 1) + sage: H = End(A) + sage: f = H([x^2 + x*(t^3 + 2*t^2 + 4*t) + (t^5 + 3*t^4 + t^2 + 4*t)]) + sage: f.reduce_base_field() Scheme endomorphism of Affine Space of dimension 1 over Finite Field in t of size 5^6 Defn: Defined on coordinates by sending (x) to @@ -1229,7 +1248,7 @@ def indeterminacy_locus(self): sage: A. = AffineSpace(QQ, 2) sage: H = End(A) sage: f = H([x - y, x^2 - y^2]) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 1 @@ -1237,7 +1256,7 @@ def indeterminacy_locus(self): sage: A. = AffineSpace(QQ, 2) sage: f = A.hom([x, x/y], A) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: y """ @@ -1262,7 +1281,7 @@ def indeterminacy_points(self, F=None): sage: A. = AffineSpace(QQ, 2) sage: H = End(A) sage: f = H([x - y, x^2 - y^2]) - sage: f.indeterminacy_points() + sage: f.indeterminacy_points() # needs sage.libs.singular [] :: @@ -1270,7 +1289,7 @@ def indeterminacy_points(self, F=None): sage: A2. = AffineSpace(QQ, 2) sage: P2. = ProjectiveSpace(QQ, 2) sage: f = A2.hom([x*y, y, x], P2) - sage: f.indeterminacy_points() + sage: f.indeterminacy_points() # needs sage.libs.singular [(0, 0)] """ @@ -1296,6 +1315,7 @@ def image(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: A1. = AffineSpace(QQ, 1) sage: A2. = AffineSpace(QQ, 2) sage: f = A2.hom([x + y], A1) @@ -1329,18 +1349,18 @@ def _fast_eval(self, x): EXAMPLES:: - sage: P. = AffineSpace(GF(7), 3) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x^2 + y^2,y ^2, z^2 + y*z]) # optional - sage.rings.finite_rings - sage: f._fast_eval([1, 1, 1]) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(7), 3) + sage: H = Hom(P, P) + sage: f = H([x^2 + y^2,y ^2, z^2 + y*z]) + sage: f._fast_eval([1, 1, 1]) [2, 1, 2] :: - sage: P. = AffineSpace(GF(19), 3) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x/(y+1), y, (z^2 + y^2)/(x^2 + 1)]) # optional - sage.rings.finite_rings - sage: f._fast_eval([2, 1, 3]) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(19), 3) + sage: H = Hom(P, P) + sage: f = H([x/(y+1), y, (z^2 + y^2)/(x^2 + 1)]) + sage: f._fast_eval([2, 1, 3]) [1, 1, 2] """ R = self.domain().ambient_space().coordinate_ring() @@ -1376,7 +1396,7 @@ def representatives(self): sage: A2. = AffineSpace(QQ, 2) sage: X = A2.subscheme(0) sage: f = X.hom([x, x/y], A2) - sage: f.representatives() + sage: f.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 0 @@ -1385,6 +1405,7 @@ def representatives(self): :: + sage: # needs sage.libs.singular sage: A2. = AffineSpace(QQ, 2) sage: A1. = AffineSpace(QQ, 1) sage: X = A2.subscheme([x^2 - y^2 - y]) @@ -1419,7 +1440,7 @@ def representatives(self): sage: P1. = ProjectiveSpace(QQ, 1) sage: X = A2.subscheme([x^2 - y^2 - y]) sage: f = X.hom([x, y], P1) - sage: f.representatives() + sage: f.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y @@ -1465,7 +1486,7 @@ def indeterminacy_locus(self): sage: X = A2.subscheme(0) sage: A1. = AffineSpace(QQ, 1) sage: f = X.hom([x1/x2], A1) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x2 @@ -1475,17 +1496,17 @@ def indeterminacy_locus(self): sage: X = A2.subscheme(0) sage: P1. = ProjectiveSpace(QQ, 1) sage: f = X.hom([x1,x2], P1) - sage: L = f.indeterminacy_locus() - sage: L.rational_points() + sage: L = f.indeterminacy_locus() # needs sage.libs.singular + sage: L.rational_points() # needs sage.libs.singular [(0, 0)] :: sage: A2. = AffineSpace(QQ, 2) sage: X = A2.subscheme([x^2 - y^2 - y]) - sage: A1. = AffineSpace(QQ,1) + sage: A1. = AffineSpace(QQ, 1) sage: f = X.hom([x/y], A1) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: y, x @@ -1496,12 +1517,11 @@ def indeterminacy_locus(self): sage: X = A3.subscheme(x^2 - y*z - x) sage: A2. = AffineSpace(QQ, 2) sage: f = X.hom([y, y/x], A2) - sage: L = f.indeterminacy_locus() - sage: L + sage: L = f.indeterminacy_locus(); L # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: x, y*z - sage: L.dimension() + sage: L.dimension() # needs sage.libs.singular 1 """ @@ -1529,7 +1549,7 @@ def is_morphism(self): sage: P1. = ProjectiveSpace(QQ,1) sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: f = X.hom([x,y], P1) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True """ return self.indeterminacy_locus().dimension() < 0 @@ -1546,7 +1566,7 @@ def image(self): sage: A2. = AffineSpace(QQ, 2) sage: X = A2.subscheme(0) sage: f = X.hom([x + y], A1) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 1 over Rational Field defined by: (no polynomials) @@ -1555,7 +1575,7 @@ def image(self): sage: A2. = AffineSpace(QQ, 2) sage: X = A2.subscheme([x*y^2 - y^3 - 1]) sage: f = X.hom([y, y/x], A2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -x^3*y + x^3 - y """ diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py index e0cdab543fe..a665ba6881a 100644 --- a/src/sage/schemes/affine/affine_point.py +++ b/src/sage/schemes/affine/affine_point.py @@ -115,16 +115,16 @@ def _matrix_times_point_(self, mat, dom): sage: P = AffineSpace(QQ,2) sage: Q = P(1,2) - sage: m = matrix(ZZ, 3, 3, [0,1,1,0,0,1,1,1,1]) - sage: m*Q + sage: m = matrix(ZZ, 3, 3, [0,1,1,0,0,1,1,1,1]) # needs sage.modules + sage: m*Q # needs sage.modules (3/4, 1/4) :: sage: P = AffineSpace(QQ,1) sage: Q = P(0) - sage: m = matrix(RR, 2, 2, [0,1,1,0]) - sage: m*Q + sage: m = matrix(RR, 2, 2, [0,1,1,0]) # needs sage.modules + sage: m*Q # needs sage.modules Traceback (most recent call last): ... ValueError: resulting point not affine @@ -133,8 +133,8 @@ def _matrix_times_point_(self, mat, dom): sage: P = AffineSpace(QQ,2) sage: Q = P(1,1) - sage: m = matrix(RR, 2, 2, [0,1,1,0]) - sage: m*Q + sage: m = matrix(RR, 2, 2, [0,1,1,0]) # needs sage.modules + sage: m*Q # needs sage.modules Traceback (most recent call last): ... ValueError: matrix size is incompatible @@ -158,9 +158,9 @@ def __hash__(self): :: - sage: A. = AffineSpace(CC, 3) - sage: pt = A([1, 2, -i]) - sage: hash(pt) == hash(tuple(pt)) + sage: A. = AffineSpace(CC, 3) # needs sage.rings.real_mpfr + sage: pt = A([1, 2, -i]) # needs sage.rings.real_mpfr sage.symbolic + sage: hash(pt) == hash(tuple(pt)) # needs sage.rings.real_mpfr sage.symbolic True """ @@ -183,22 +183,22 @@ def global_height(self, prec=None): sage: P. = AffineSpace(QQ, 2) sage: Q = P(41, 1/12) - sage: Q.global_height() + sage: Q.global_height() # needs sage.rings.real_mpfr 3.71357206670431 :: sage: P = AffineSpace(ZZ, 4, 'x') sage: Q = P(3, 17, -51, 5) - sage: Q.global_height() + sage: Q.global_height() # needs sage.rings.real_mpfr 3.93182563272433 :: sage: R. = PolynomialRing(QQ) - sage: k. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: A = AffineSpace(k, 2, 'z') # optional - sage.rings.number_field - sage: A([3, 5*w + 1]).global_height(prec=100) # optional - sage.rings.number_field + sage: k. = NumberField(x^2 + 5) # needs sage.rings.number_field + sage: A = AffineSpace(k, 2, 'z') # needs sage.rings.number_field + sage: A([3, 5*w + 1]).global_height(prec=100) # needs sage.rings.number_field sage.rings.real_mpfr 2.4181409534757389986565376694 .. TODO:: @@ -291,24 +291,26 @@ def weil_restriction(self): EXAMPLES:: - sage: A. = AffineSpace(GF(5^3, 't'), 3) # optional - sage.rings.finite_rings - sage: X = A.subscheme([y^2 - x*z, z^2 + y]) # optional - sage.rings.finite_rings - sage: Y = X.weil_restriction() # optional - sage.rings.finite_rings - sage: P = X([1, -1, 1]) # optional - sage.rings.finite_rings - sage: Q = P.weil_restriction();Q # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular sage.rings.finite_rings + sage: A. = AffineSpace(GF(5^3, 't'), 3) + sage: X = A.subscheme([y^2 - x*z, z^2 + y]) + sage: Y = X.weil_restriction() + sage: P = X([1, -1, 1]) + sage: Q = P.weil_restriction();Q (1, 0, 0, 4, 0, 0, 1, 0, 0) - sage: Q.codomain() == Y # optional - sage.rings.finite_rings + sage: Q.codomain() == Y True :: + sage: # needs sage.libs.singular sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 - 2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(x^2 + w) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: P = A([w^3 - v, 1 + w + w*v]) # optional - sage.rings.number_field - sage: P.weil_restriction() # optional - sage.rings.number_field + sage: K. = NumberField(x^5 - 2) + sage: R. = K[] + sage: L. = K.extension(x^2 + w) + sage: A. = AffineSpace(L, 2) + sage: P = A([w^3 - v, 1 + w + w*v]) + sage: P.weil_restriction() (w^3, -1, w + 1, w) """ L = self.codomain().base_ring() @@ -358,14 +360,15 @@ def intersection_multiplicity(self, X): EXAMPLES:: - sage: A. = AffineSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: X = A.subscheme([y^2 - x^3 + 2*x^2 - x]) # optional - sage.rings.finite_rings - sage: Y = A.subscheme([y - 2*x + 2]) # optional - sage.rings.finite_rings - sage: Q1 = Y([1,0]) # optional - sage.rings.finite_rings - sage: Q1.intersection_multiplicity(X) # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: A. = AffineSpace(GF(17), 2) + sage: X = A.subscheme([y^2 - x^3 + 2*x^2 - x]) + sage: Y = A.subscheme([y - 2*x + 2]) + sage: Q1 = Y([1,0]) + sage: Q1.intersection_multiplicity(X) 2 - sage: Q2 = X([4,6]) # optional - sage.rings.finite_rings - sage: Q2.intersection_multiplicity(Y) # optional - sage.rings.finite_rings + sage: Q2 = X([4,6]) + sage: Q2.intersection_multiplicity(Y) 1 :: @@ -397,10 +400,10 @@ def multiplicity(self): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([y^2 - x^7*z]) sage: Q1 = X([1,1,1]) - sage: Q1.multiplicity() + sage: Q1.multiplicity() # needs sage.libs.singular 1 sage: Q2 = X([0,0,2]) - sage: Q2.multiplicity() + sage: Q2.multiplicity() # needs sage.libs.singular 2 """ from sage.schemes.affine.affine_space import is_AffineSpace @@ -419,27 +422,27 @@ def __hash__(self): EXAMPLES:: - sage: P. = AffineSpace(GF(5), 3) # optional - sage.rings.finite_rings - sage: hash(P(2, 1, 2)) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(5), 3) + sage: hash(P(2, 1, 2)) 57 :: - sage: P. = AffineSpace(GF(7), 3) # optional - sage.rings.finite_rings - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.finite_rings - sage: hash(X(1, 1, 2)) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(7), 3) + sage: X = P.subscheme(x^2 - y^2) + sage: hash(X(1, 1, 2)) 106 :: - sage: P. = AffineSpace(GF(13), 2) # optional - sage.rings.finite_rings - sage: hash(P(3, 4)) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(13), 2) + sage: hash(P(3, 4)) 55 :: - sage: P. = AffineSpace(GF(13^3, 't'), 2) # optional - sage.rings.finite_rings - sage: hash(P(3, 4)) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(13^3, 't'), 2) # needs sage.rings.finite_rings + sage: hash(P(3, 4)) # needs sage.rings.finite_rings 8791 """ p = self.codomain().base_ring().order() diff --git a/src/sage/schemes/affine/affine_rational_point.py b/src/sage/schemes/affine/affine_rational_point.py index 91ec84ffeab..739d1795086 100644 --- a/src/sage/schemes/affine/affine_rational_point.py +++ b/src/sage/schemes/affine/affine_rational_point.py @@ -25,8 +25,8 @@ Affine over a finite field:: sage: from sage.schemes.affine.affine_rational_point import enum_affine_finite_field - sage: A. = AffineSpace(4, GF(2)) # optional - sage.rings.finite_rings - sage: enum_affine_finite_field(A(GF(2))) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(4, GF(2)) + sage: enum_affine_finite_field(A(GF(2))) [(0, 0, 0, 0), (0, 0, 0, 1), (0, 0, 1, 0), (0, 0, 1, 1), (0, 1, 0, 0), (0, 1, 0, 1), (0, 1, 1, 0), (0, 1, 1, 1), (1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), @@ -94,8 +94,8 @@ def enum_affine_rational_field(X, B): :: sage: A. = AffineSpace(2, QQ) - sage: C = Curve(x^2 + y - x) - sage: enum_affine_rational_field(C, 10) # long time (3 s) + sage: C = Curve(x^2 + y - x) # needs sage.libs.singular + sage: enum_affine_rational_field(C, 10) # long time (3 s) # needs sage.libs.singular [(-2, -6), (-1, -2), (-2/3, -10/9), (-1/2, -3/4), (-1/3, -4/9), (0, 0), (1/3, 2/9), (1/2, 1/4), (2/3, 2/9), (1, 0), (4/3, -4/9), (3/2, -3/4), (5/3, -10/9), (2, -2), (3, -6)] @@ -188,12 +188,13 @@ def enum_affine_number_field(X, **kwds): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.affine.affine_rational_point import enum_affine_number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 2, 'v') # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 3) # optional - sage.rings.number_field - sage: X = A.subscheme([y^2 - x]) # optional - sage.rings.number_field - sage: enum_affine_number_field(X(K), bound=2**0.5) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 2, 'v') + sage: A. = AffineSpace(K, 3) + sage: X = A.subscheme([y^2 - x]) + sage: enum_affine_number_field(X(K), bound=2**0.5) [(0, 0, -1), (0, 0, -v), (0, 0, -1/2*v), (0, 0, 0), (0, 0, 1/2*v), (0, 0, v), (0, 0, 1), (1, -1, -1), (1, -1, -v), (1, -1, -1/2*v), (1, -1, 0), (1, -1, 1/2*v), (1, -1, v), (1, -1, 1), (1, 1, -1), @@ -201,12 +202,13 @@ def enum_affine_number_field(X, **kwds): :: + sage: # needs sage.rings.number_field sage: from sage.schemes.affine.affine_rational_point import enum_affine_number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 3, 'v') # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: X = A.subscheme(x - y) # optional - sage.rings.number_field - sage: enum_affine_number_field(X, bound=3**0.25) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 3, 'v') + sage: A. = AffineSpace(K, 2) + sage: X = A.subscheme(x - y) + sage: enum_affine_number_field(X, bound=3**0.25) [(-1, -1), (-1/2*v - 1/2, -1/2*v - 1/2), (1/2*v - 1/2, 1/2*v - 1/2), (0, 0), (-1/2*v + 1/2, -1/2*v + 1/2), (1/2*v + 1/2, 1/2*v + 1/2), (1, 1)] """ @@ -250,13 +252,13 @@ def enum_affine_finite_field(X): EXAMPLES:: sage: from sage.schemes.affine.affine_rational_point import enum_affine_finite_field - sage: F = GF(7) # optional - sage.rings.finite_rings - sage: A. = AffineSpace(4, F) # optional - sage.rings.finite_rings - sage: C = A.subscheme([w^2 + x + 4, y*z*x - 6, z*y + w*x]) # optional - sage.rings.finite_rings - sage: enum_affine_finite_field(C(F)) # optional - sage.rings.finite_rings + sage: F = GF(7) + sage: A. = AffineSpace(4, F) + sage: C = A.subscheme([w^2 + x + 4, y*z*x - 6, z*y + w*x]) + sage: enum_affine_finite_field(C(F)) [] - sage: C = A.subscheme([w^2 + x + 4, y*z*x - 6]) # optional - sage.rings.finite_rings - sage: enum_affine_finite_field(C(F)) # optional - sage.rings.finite_rings + sage: C = A.subscheme([w^2 + x + 4, y*z*x - 6]) + sage: enum_affine_finite_field(C(F)) [(0, 3, 1, 2), (0, 3, 2, 1), (0, 3, 3, 3), (0, 3, 4, 4), (0, 3, 5, 6), (0, 3, 6, 5), (1, 2, 1, 3), (1, 2, 2, 5), (1, 2, 3, 1), (1, 2, 4, 6), (1, 2, 5, 2), (1, 2, 6, 4), (2, 6, 1, 1), (2, 6, 2, 4), (2, 6, 3, 5), @@ -269,9 +271,9 @@ def enum_affine_finite_field(X): :: - sage: A. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: S = A.subscheme(x + y) # optional - sage.rings.finite_rings - sage: enum_affine_finite_field(S) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(3, GF(3)) + sage: S = A.subscheme(x + y) + sage: enum_affine_finite_field(S) [(0, 0, 0), (0, 0, 1), (0, 0, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2), (2, 1, 0), (2, 1, 1), (2, 1, 2)] diff --git a/src/sage/schemes/affine/affine_space.py b/src/sage/schemes/affine/affine_space.py index 2c8ebf0f39a..927a065cf60 100644 --- a/src/sage/schemes/affine/affine_space.py +++ b/src/sage/schemes/affine/affine_space.py @@ -49,7 +49,7 @@ def is_AffineSpace(x) -> bool: sage: from sage.schemes.affine.affine_space import is_AffineSpace sage: is_AffineSpace(AffineSpace(5, names='x')) True - sage: is_AffineSpace(AffineSpace(5, GF(9, 'alpha'), names='x')) # optional - sage.rings.finite_rings + sage: is_AffineSpace(AffineSpace(5, GF(9, 'alpha'), names='x')) # needs sage.rings.finite_rings True sage: is_AffineSpace(Spec(ZZ)) False @@ -77,7 +77,7 @@ def AffineSpace(n, R=None, names=None, ambient_projective_space=None, Use the divide operator for base extension:: - sage: AffineSpace(5, names='x')/GF(17) # optional - sage.rings.finite_rings + sage: AffineSpace(5, names='x')/GF(17) Affine Space of dimension 5 over Finite Field of size 17 The default base ring is `\ZZ`:: @@ -87,10 +87,10 @@ def AffineSpace(n, R=None, names=None, ambient_projective_space=None, There is also an affine space associated to each polynomial ring:: - sage: R = GF(7)['x, y, z'] # optional - sage.rings.finite_rings - sage: A = AffineSpace(R); A # optional - sage.rings.finite_rings + sage: R = GF(7)['x, y, z'] + sage: A = AffineSpace(R); A Affine Space of dimension 3 over Finite Field of size 7 - sage: A.coordinate_ring() is R # optional - sage.rings.finite_rings + sage: A.coordinate_ring() is R True TESTS:: @@ -170,10 +170,10 @@ class AffineSpace_generic(AmbientSpace, AffineScheme): sage: AffineSpace(5, PolynomialRing(QQ, 'z'), 'Z') Affine Space of dimension 5 over Univariate Polynomial Ring in z over Rational Field - sage: AffineSpace(RealField(), 3, 'Z') + sage: AffineSpace(RealField(), 3, 'Z') # needs sage.rings.real_mpfr Affine Space of dimension 3 over Real Field with 53 bits of precision - sage: AffineSpace(Qp(7), 2, 'x') # optional - sage.rings.padics + sage: AffineSpace(Qp(7), 2, 'x') # needs sage.rings.padics Affine Space of dimension 2 over 7-adic Field with capped relative precision 20 Even 0-dimensional affine spaces are supported:: @@ -185,7 +185,7 @@ def __init__(self, n, R, names, ambient_projective_space, default_embedding_inde """ EXAMPLES:: - sage: AffineSpace(3, Zp(5), 'y') # optional - sage.rings.padics + sage: AffineSpace(3, Zp(5), 'y') # needs sage.rings.padics Affine Space of dimension 3 over 5-adic Ring with capped relative precision 20 """ AmbientSpace.__init__(self, n, R) @@ -205,15 +205,15 @@ def __iter__(self): EXAMPLES:: - sage: FF = FiniteField(3) # optional - sage.rings.finite_rings - sage: AA = AffineSpace(FF, 0) # optional - sage.rings.finite_rings - sage: [ x for x in AA ] # optional - sage.rings.finite_rings + sage: FF = FiniteField(3) + sage: AA = AffineSpace(FF, 0) + sage: [ x for x in AA ] [()] - sage: AA = AffineSpace(FF, 1, 'Z') # optional - sage.rings.finite_rings - sage: [ x for x in AA ] # optional - sage.rings.finite_rings + sage: AA = AffineSpace(FF, 1, 'Z') + sage: [ x for x in AA ] [(0), (1), (2)] - sage: AA. = AffineSpace(FF, 2) # optional - sage.rings.finite_rings - sage: [ x for x in AA ] # optional - sage.rings.finite_rings + sage: AA. = AffineSpace(FF, 2) + sage: [ x for x in AA ] [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)] AUTHOR: @@ -249,13 +249,13 @@ def rational_points(self, F=None): EXAMPLES:: - sage: A = AffineSpace(1, GF(3)) # optional - sage.rings.finite_rings - sage: A.rational_points() # optional - sage.rings.finite_rings + sage: A = AffineSpace(1, GF(3)) + sage: A.rational_points() [(0), (1), (2)] - sage: A.rational_points(GF(3^2, 'b')) # optional - sage.rings.finite_rings + sage: A.rational_points(GF(3^2, 'b')) # needs sage.rings.finite_rings [(0), (b), (b + 1), (2*b + 1), (2), (2*b), (2*b + 2), (b + 2), (1)] - sage: AffineSpace(2, ZZ).rational_points(GF(2)) # optional - sage.rings.finite_rings + sage: AffineSpace(2, ZZ).rational_points(GF(2)) [(0, 0), (0, 1), (1, 0), (1, 1)] TESTS:: @@ -264,7 +264,7 @@ def rational_points(self, F=None): Traceback (most recent call last): ... TypeError: base ring (= Rational Field) must be a finite field - sage: AffineSpace(1, GF(3)).rational_points(ZZ) # optional - sage.rings.finite_rings + sage: AffineSpace(1, GF(3)).rational_points(ZZ) Traceback (most recent call last): ... TypeError: second argument (= Integer Ring) must be a finite field @@ -333,7 +333,7 @@ def _latex_(self): TESTS:: - sage: AffineSpace(3, Zp(5), 'y')._latex_() # optional - sage.rings.padics + sage: AffineSpace(3, Zp(5), 'y')._latex_() # needs sage.rings.padics '\\mathbf{A}_{\\Bold{Z}_{5}}^3' """ return "\\mathbf{A}_{%s}^%s" % (latex(self.base_ring()), self.dimension_relative()) @@ -434,7 +434,7 @@ def _repr_(self): TESTS:: - sage: AffineSpace(3, Zp(5), 'y')._repr_() # optional - sage.rings.padics + sage: AffineSpace(3, Zp(5), 'y')._repr_() # needs sage.rings.padics 'Affine Space of dimension 3 over 5-adic Ring with capped relative precision 20' """ return "Affine Space of dimension %s over %s" % (self.dimension_relative(), self.base_ring()) @@ -633,14 +633,14 @@ def change_ring(self, R): sage: A. = AffineSpace(3, ZZ) sage: AQ = A.change_ring(QQ); AQ Affine Space of dimension 3 over Rational Field - sage: AQ.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: AQ.change_ring(GF(5)) Affine Space of dimension 3 over Finite Field of size 5 :: - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: A = AffineSpace(K, 2, 't') # optional - sage.rings.number_field - sage: A.change_ring(K.embeddings(CC)[1]) # optional - sage.rings.number_field + sage: K. = QuadraticField(5) # needs sage.rings.number_field + sage: A = AffineSpace(K, 2, 't') # needs sage.rings.number_field + sage: A.change_ring(K.embeddings(CC)[1]) # needs sage.rings.number_field Affine Space of dimension 2 over Complex Field with 53 bits of precision """ if isinstance(R, Map): @@ -654,9 +654,9 @@ def coordinate_ring(self): EXAMPLES:: - sage: R = AffineSpace(2, GF(9,'alpha'), 'z').coordinate_ring(); R # optional - sage.rings.finite_rings + sage: R = AffineSpace(2, GF(9,'alpha'), 'z').coordinate_ring(); R # needs sage.rings.finite_rings Multivariate Polynomial Ring in z0, z1 over Finite Field in alpha of size 3^2 - sage: AffineSpace(3, R, 'x').coordinate_ring() # optional - sage.rings.finite_rings + sage: AffineSpace(3, R, 'x').coordinate_ring() # needs sage.rings.finite_rings Multivariate Polynomial Ring in x0, x1, x2 over Multivariate Polynomial Ring in z0, z1 over Finite Field in alpha of size 3^2 """ @@ -810,6 +810,7 @@ def subscheme(self, X, **kwds): :: + sage: # needs sage.libs.singular sage: X.defining_polynomials () (x, y^2, x*y^2) sage: I = X.defining_ideal(); I @@ -851,7 +852,7 @@ def _an_element_(self): sage: AffineSpace(ZZ, 2, 'x').an_element() (5, 4) - sage: AffineSpace(Qp(5), 2, 'x').an_element() # optional - sage.rings.padics + sage: AffineSpace(Qp(5), 2, 'x').an_element() # needs sage.rings.padics (5^2 + O(5^22), 4*5 + O(5^21)) """ n = self.dimension_relative() @@ -883,21 +884,21 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): EXAMPLES:: sage: A. = AffineSpace(QQ, 1) - sage: A.chebyshev_polynomial(5, 'first') + sage: A.chebyshev_polynomial(5, 'first') # needs sage.schemes Dynamical System of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x) to (16*x^5 - 20*x^3 + 5*x) :: sage: A. = AffineSpace(QQ, 1) - sage: A.chebyshev_polynomial(3, 'second') + sage: A.chebyshev_polynomial(3, 'second') # needs sage.schemes Dynamical System of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x) to (8*x^3 - 4*x) :: sage: A. = AffineSpace(QQ, 1) - sage: A.chebyshev_polynomial(3, 2) + sage: A.chebyshev_polynomial(3, 2) # needs sage.schemes Traceback (most recent call last): ... ValueError: keyword 'kind' must have a value of either 'first' or 'second' @@ -921,15 +922,15 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): :: sage: A. = AffineSpace(QQ, 1) - sage: A.chebyshev_polynomial(7, monic=True) + sage: A.chebyshev_polynomial(7, monic=True) # needs sage.schemes Dynamical System of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x) to (x^7 - 7*x^5 + 14*x^3 - 7*x) :: sage: F. = FunctionField(QQ) - sage: A. = AffineSpace(F,1) - sage: A.chebyshev_polynomial(4, monic=True) + sage: A. = AffineSpace(F, 1) + sage: A.chebyshev_polynomial(4, monic=True) # needs sage.schemes Dynamical System of Affine Space of dimension 1 over Rational function field in t over Rational Field Defn: Defined on coordinates by sending (x) to (x^4 + (-4)*x^2 + 2) @@ -983,9 +984,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1, 2, 3]) # optional - sage.rings.finite_rings + sage: P2. = AffineSpace(3, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1, 2, 3]) (1, 2, 0) """ return SchemeMorphism_point_affine_field(*args, **kwds) @@ -998,8 +999,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x, y, z]) # optional - sage.rings.finite_rings + sage: P2. = AffineSpace(3, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x, y, z]) Scheme endomorphism of Affine Space of dimension 3 over Finite Field of size 3 Defn: Defined on coordinates by sending (x, y, z) to (x, y, z) @@ -1051,8 +1052,8 @@ def points_of_bounded_height(self, **kwds): :: sage: u = QQ['u'].0 - sage: A. = AffineSpace(NumberField(u^2 - 2, 'v'), 2) # optional - sage.rings.number_field - sage: len(list(A.points_of_bounded_height(bound=2, tolerance=0.1))) # optional - sage.rings.number_field + sage: A. = AffineSpace(NumberField(u^2 - 2, 'v'), 2) # needs sage.rings.number_field + sage: len(list(A.points_of_bounded_height(bound=2, tolerance=0.1))) # needs sage.rings.number_field 529 """ if is_RationalField(self.base_ring()): @@ -1105,15 +1106,16 @@ def weil_restriction(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 - 2) # optional - sage.rings.number_field - sage: AK. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: AK.weil_restriction() # optional - sage.rings.number_field + sage: K. = NumberField(x^5 - 2) + sage: AK. = AffineSpace(K, 2) + sage: AK.weil_restriction() Affine Space of dimension 10 over Rational Field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(x^2 + 1) # optional - sage.rings.number_field - sage: AL. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: AL.weil_restriction() # optional - sage.rings.number_field + sage: R. = K[] + sage: L. = K.extension(x^2 + 1) + sage: AL. = AffineSpace(L, 2) + sage: AL.weil_restriction() Affine Space of dimension 4 over Number Field in w with defining polynomial x^5 - 2 """ @@ -1147,7 +1149,7 @@ def curve(self, F): EXAMPLES:: sage: A. = AffineSpace(QQ, 3) - sage: A.curve([y - x^4, z - y^5]) + sage: A.curve([y - x^4, z - y^5]) # needs sage.libs.pari Affine Curve over Rational Field defined by -x^4 + y, -y^5 + z """ from sage.schemes.curves.constructor import Curve @@ -1163,13 +1165,13 @@ def line_through(self, p, q): EXAMPLES:: + sage: # needs sage.libs.singular sage.schemes sage: A3. = AffineSpace(3, QQ) sage: p1 = A3(1, 2, 3) sage: p2 = A3(4, 5, 6) - sage: A3.line_through(p1, p2) + sage: L = A3.line_through(p1, p2); L Affine Curve over Rational Field defined by -1/6*x + 1/6*y - 1/6, -1/6*x + 1/6*z - 1/3, -1/6*y + 1/6*z - 1/6, -1/6*x + 1/3*y - 1/6*z - sage: L = _ sage: L(p1) (1, 2, 3) sage: L(p2) @@ -1236,9 +1238,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1, 2, 3]) # optional - sage.rings.finite_rings + sage: P2. = AffineSpace(3, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1, 2, 3]) (1, 2, 0) """ return SchemeMorphism_point_affine_finite_field(*args, **kwds) @@ -1251,8 +1253,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x, y, z]) # optional - sage.rings.finite_rings + sage: P2. = AffineSpace(3, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x, y, z]) Scheme endomorphism of Affine Space of dimension 3 over Finite Field of size 3 Defn: Defined on coordinates by sending (x, y, z) to (x, y, z) diff --git a/src/sage/schemes/affine/affine_subscheme.py b/src/sage/schemes/affine/affine_subscheme.py index a5a1c661c74..ed125a60193 100644 --- a/src/sage/schemes/affine/affine_subscheme.py +++ b/src/sage/schemes/affine/affine_subscheme.py @@ -59,7 +59,7 @@ def __init__(self, A, polynomials, embedding_center=None, EXAMPLES:: sage: A. = AffineSpace(QQ, 3) - sage: A.subscheme([y^2-x*z-x*y]) + sage: A.subscheme([y^2 - x*z - x*y]) Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x*y + y^2 - x*z """ @@ -98,6 +98,7 @@ def dimension(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: A. = AffineSpace(2, QQ) sage: A.subscheme([]).dimension() 2 @@ -120,7 +121,7 @@ def dimension(self): x^2*y^2 + z^2, z^2 - w^2, 10*x^2 - z^2 + w^2 - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular 1 """ try: @@ -152,7 +153,7 @@ def projective_embedding(self, i=None, PP=None): sage: A. = AffineSpace(3, ZZ) sage: S = A.subscheme([x*y - z]) - sage: S.projective_embedding() + sage: S.projective_embedding() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 3 over Integer Ring defined by: x*y - z @@ -165,7 +166,7 @@ def projective_embedding(self, i=None, PP=None): sage: A. = AffineSpace(3, ZZ) sage: P = ProjectiveSpace(3, ZZ, 'u') sage: S = A.subscheme([x^2 - y*z]) - sage: S.projective_embedding(1, P) + sage: S.projective_embedding(1, P) # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 3 over Integer Ring defined by: x^2 - y*z @@ -177,7 +178,7 @@ def projective_embedding(self, i=None, PP=None): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([y - x^2, z - x^3]) - sage: X.projective_embedding() + sage: X.projective_embedding() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x^2 + y, -x^3 + z @@ -189,17 +190,17 @@ def projective_embedding(self, i=None, PP=None): projective embedding, the subscheme inherits the embedding:: sage: A. = AffineSpace(2, QQ, default_embedding_index=1) - sage: X = A.subscheme(u - v) - sage: X.projective_embedding() + sage: X = A.subscheme(u - v) # needs sage.libs.singular + sage: X.projective_embedding() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: u - v To: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x0 - x2 Defn: Defined on coordinates by sending (u, v) to (u : 1 : v) - sage: phi = X.projective_embedding() + sage: phi = X.projective_embedding() # needs sage.libs.singular sage: psi = A.projective_embedding() - sage: phi(X(2, 2)) == psi(A(X(2, 2))) + sage: phi(X(2, 2)) == psi(A(X(2, 2))) # needs sage.libs.singular True """ AA = self.ambient_space() @@ -261,8 +262,9 @@ def projective_closure(self, i=None, PP=None): EXAMPLES:: sage: A. = AffineSpace(QQ, 4) - sage: X = A.subscheme([x^2 - y, x*y - z, y^2 - w, x*z - w, y*z - x*w, z^2 - y*w]) - sage: X.projective_closure() + sage: X = A.subscheme([x^2 - y, x*y - z, y^2 - w, + ....: x*z - w, y*z - x*w, z^2 - y*w]) + sage: X.projective_closure() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: x0^2 - x1*x4, @@ -277,7 +279,7 @@ def projective_closure(self, i=None, PP=None): sage: A. = AffineSpace(QQ, 3) sage: P. = ProjectiveSpace(QQ, 3) sage: X = A.subscheme([z - x^2 - y^2]) - sage: X.projective_closure(1, P).ambient_space() == P + sage: X.projective_closure(1, P).ambient_space() == P # needs sage.libs.singular True """ return self.projective_embedding(i, PP).codomain() @@ -310,11 +312,11 @@ def is_smooth(self, point=None): sage: singular_point = cuspidal_curve.point([0,0]) sage: singular_point in cuspidal_curve True - sage: cuspidal_curve.is_smooth(smooth_point) + sage: cuspidal_curve.is_smooth(smooth_point) # needs sage.libs.singular True - sage: cuspidal_curve.is_smooth(singular_point) + sage: cuspidal_curve.is_smooth(singular_point) # needs sage.libs.singular False - sage: cuspidal_curve.is_smooth() + sage: cuspidal_curve.is_smooth() # needs sage.libs.singular False """ R = self.ambient_space().coordinate_ring() @@ -354,24 +356,25 @@ def intersection_multiplicity(self, X, P): EXAMPLES:: sage: A. = AffineSpace(QQ, 2) - sage: C = Curve([y^2 - x^3 - x^2], A) - sage: D = Curve([y^2 + x^3], A) + sage: C = Curve([y^2 - x^3 - x^2], A) # needs sage.libs.singular + sage: D = Curve([y^2 + x^3], A) # needs sage.libs.singular sage: Q = A([0,0]) - sage: C.intersection_multiplicity(D, Q) + sage: C.intersection_multiplicity(D, Q) # needs sage.libs.singular 4 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^6 - 3*a^5 + 5*a^4 - 5*a^3 + 5*a^2 - 3*a + 1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 4) # optional - sage.rings.number_field - sage: X = A.subscheme([x*y, y*z + 7, w^3 - x^3]) # optional - sage.rings.number_field - sage: Y = A.subscheme([x - z^3 + z + 1]) # optional - sage.rings.number_field - sage: Q = A([0, # optional - sage.rings.number_field + sage: K. = NumberField(a^6 - 3*a^5 + 5*a^4 - 5*a^3 + 5*a^2 - 3*a + 1) + sage: A. = AffineSpace(K, 4) + sage: X = A.subscheme([x*y, y*z + 7, w^3 - x^3]) + sage: Y = A.subscheme([x - z^3 + z + 1]) + sage: Q = A([0, ....: -7*b^5 + 21*b^4 - 28*b^3 + 21*b^2 - 21*b + 14, ....: -b^5 + 2*b^4 - 3*b^3 + 2*b^2 - 2*b, ....: 0]) - sage: X.intersection_multiplicity(Y, Q) # optional - sage.rings.number_field + sage: X.intersection_multiplicity(Y, Q) 3 :: @@ -380,7 +383,7 @@ def intersection_multiplicity(self, X, P): sage: X = A.subscheme([z^2 - 1]) sage: Y = A.subscheme([z - 1, y - x^2]) sage: Q = A([1,1,1]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: the intersection of this subscheme and (=Closed subscheme of Affine Space of dimension 3 @@ -392,7 +395,7 @@ def intersection_multiplicity(self, X, P): sage: X = A.subscheme([x*y, t^2*w, w^3*z]) sage: Y = A.subscheme([y*w + z]) sage: Q = A([0,0,0,0,0]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: the intersection of this subscheme and (=Closed subscheme of Affine Space of dimension 5 @@ -446,30 +449,31 @@ def multiplicity(self, P): sage: A. = AffineSpace(QQ, 4) sage: X = A.subscheme([z*y - x^7, w - 2*z]) sage: Q1 = A([1,1/3,3,6]) - sage: X.multiplicity(Q1) + sage: X.multiplicity(Q1) # needs sage.libs.singular 1 sage: Q2 = A([0,0,0,0]) - sage: X.multiplicity(Q2) + sage: X.multiplicity(Q2) # needs sage.libs.singular 2 :: - sage: A. = AffineSpace(GF(23), 5) # optional - sage.rings.finite_rings - sage: C = A.curve([x^8 - y, y^7 - z, z^3 - 1, w^5 - v^3]) # optional - sage.rings.finite_rings - sage: Q = A([22,1,1,0,0]) # optional - sage.rings.finite_rings - sage: C.multiplicity(Q) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(23), 5) + sage: C = A.curve([x^8 - y, y^7 - z, z^3 - 1, w^5 - v^3]) # needs sage.libs.singular sage.schemes + sage: Q = A([22,1,1,0,0]) + sage: C.multiplicity(Q) # needs sage.libs.singular sage.schemes 3 :: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 5) # optional - sage.rings.number_field - sage: X = A.subscheme([y^7 - x^2*z^5 + z^3*t^8 - x^2*y^4*z - t^8]) # optional - sage.rings.number_field - sage: Q1 = A([1,1,0,1,-1]) # optional - sage.rings.number_field - sage: X.multiplicity(Q1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: A. = AffineSpace(K, 5) + sage: X = A.subscheme([y^7 - x^2*z^5 + z^3*t^8 - x^2*y^4*z - t^8]) + sage: Q1 = A([1,1,0,1,-1]) + sage: X.multiplicity(Q1) 1 - sage: Q2 = A([0,0,0,-a,0]) # optional - sage.rings.number_field - sage: X.multiplicity(Q2) # optional - sage.rings.number_field + sage: Q2 = A([0,0,0,-a,0]) + sage: X.multiplicity(Q2) 7 Check that :trac:`27479` is fixed:: @@ -477,7 +481,7 @@ def multiplicity(self, P): sage: A1. = AffineSpace(QQ, 1) sage: X = A1.subscheme([x^1789 + x]) sage: Q = X([0]) - sage: X.multiplicity(Q) + sage: X.multiplicity(Q) # needs sage.libs.singular 1 """ if not self.base_ring() in Fields(): @@ -543,11 +547,11 @@ def tangent_space(self, p): sage: A3. = AffineSpace(3, QQ) sage: X = A3.subscheme(z - x*y) - sage: X.tangent_space(A3.origin()) + sage: X.tangent_space(A3.origin()) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: z - sage: X.tangent_space(X(1,1,1)) + sage: X.tangent_space(X(1,1,1)) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x - y + z @@ -555,6 +559,7 @@ def tangent_space(self, p): Tangent space at a point may have higher dimension than the dimension of the point. :: + sage: # needs sage.libs.singular sage: C = Curve([x + y + z, x^2 - y^2*z^2 + z^3]) sage: C.singular_points() [(0, 0, 0)] diff --git a/src/sage/schemes/berkovich/berkovich_cp_element.py b/src/sage/schemes/berkovich/berkovich_cp_element.py index 4611d396fce..bc8307f29e5 100644 --- a/src/sage/schemes/berkovich/berkovich_cp_element.py +++ b/src/sage/schemes/berkovich/berkovich_cp_element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics r""" Elements of Berkovich space. @@ -62,13 +63,13 @@ class Berkovich_Element_Cp(Berkovich_Element): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(2) Type I point centered at 2 + O(3^20) :: - sage: B(0, 1) # optional - sage.rings.padics + sage: B(0, 1) Type II point centered at 0 of radius 3^0 """ @@ -78,8 +79,8 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, space_type= EXAMPLES:: - sage: B = Berkovich_Cp_Affine(5) # optional - sage.rings.padics - sage: B(4) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(5) + sage: B(4) Type I point centered at 4 + O(5^20) """ from sage.rings.function_field.element import is_FunctionFieldElement @@ -426,9 +427,9 @@ def _custom_abs(self, x): :: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: Q1 = B(9) # optional - sage.rings.padics - sage: Q1._custom_abs(Q1.center()) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: Q1 = B(9) + sage: Q1._custom_abs(Q1.center()) 1/9 """ if self._base_type == 'padic field': @@ -450,15 +451,15 @@ def center_function(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(5) # optional - sage.rings.padics - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(5) + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) sage: R. = RR[] sage: Y = FractionField(R) - sage: g = (40*pi)/x # optional - sage.symbolic - sage: Q1 = B(f, g) # optional - sage.rings.padics sage.symbolic - sage: Q1.center_function() # optional - sage.rings.padics sage.symbolic + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q1 = B(f, g) # needs sage.symbolic + sage: Q1.center_function() # needs sage.symbolic (1 + O(5^20))/((1 + O(5^20))*t) """ if self.type_of_point() != 4: @@ -478,15 +479,15 @@ def radius_function(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(5) # optional - sage.rings.padics - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(5) + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) sage: R. = RR[] sage: Y = FractionField(R) - sage: g = (40*pi)/x # optional - sage.symbolic - sage: Q1 = B(f, g) # optional - sage.rings.padics sage.symbolic - sage: Q1.radius_function() # optional - sage.rings.padics sage.symbolic + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q1 = B(f, g) # needs sage.symbolic + sage: Q1.radius_function() # needs sage.symbolic 40.0000000000000*pi/x """ if self.type_of_point() != 4: @@ -506,14 +507,14 @@ def precision(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: d = B([2, 2, 2], [1.761, 1.123, 1.112]) # optional - sage.rings.padics - sage: d.precision() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: d = B([2, 2, 2], [1.761, 1.123, 1.112]) + sage: d.precision() 3 TESTS:: - sage: d.precision == d.prec # optional - sage.rings.padics + sage: d.precision == d.prec True """ if self._type in [1, 2, 3]: @@ -537,8 +538,8 @@ def ideal(self): :: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B(0).ideal() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B(0).ideal() """ return self.parent().ideal() @@ -557,15 +558,15 @@ def power(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1, 9) # optional - sage.rings.padics - sage: Q1.power() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1, 9) + sage: Q1.power() 2 :: - sage: Q2 = B(1, 4) # optional - sage.rings.padics - sage: Q2.power() # optional - sage.rings.padics + sage: Q2 = B(1, 4) + sage: Q2.power() 1.26185950714291 """ if self._type in [1, 4]: @@ -583,15 +584,15 @@ def radius(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1, 2/5) # optional - sage.rings.padics - sage: Q1.radius() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1, 2/5) + sage: Q1.radius() 0.400000000000000 :: - sage: d = B([2, 2, 2], [1.761, 1.123, 1.112]) # optional - sage.rings.padics - sage: d.radius() # optional - sage.rings.padics + sage: d = B([2, 2, 2], [1.761, 1.123, 1.112]) + sage: d.radius() [1.76100000000000, 1.12300000000000, 1.11200000000000] """ if self._type == 4: @@ -618,38 +619,38 @@ def diameter(self, basepoint=Infinity): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(3) # optional - sage.rings.padics - sage: Q1.diameter() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(3) + sage: Q1.diameter() 0 :: - sage: Q2 = B(1/2, 9) # optional - sage.rings.padics - sage: Q2.diameter() # optional - sage.rings.padics + sage: Q2 = B(1/2, 9) + sage: Q2.diameter() 9.00000000000000 The diameter of a type IV point is the limit of the radii:: - sage: R. = PolynomialRing(Qp(3)) # optional - sage.rings.padics - sage: f = R(2) # optional - sage.rings.padics - sage: S. = PolynomialRing(RR) # optional - sage.rings.padics - sage: S = FractionField(S) # optional - sage.rings.padics - sage: g = (y+1)/y # optional - sage.rings.padics - sage: B(f,g).diameter() # optional - sage.rings.padics + sage: R. = PolynomialRing(Qp(3)) + sage: f = R(2) + sage: S. = PolynomialRing(RR) + sage: S = FractionField(S) + sage: g = (y+1)/y + sage: B(f,g).diameter() 1.0 :: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1/81, 1) # optional - sage.rings.padics - sage: Q2 = B(1/3) # optional - sage.rings.padics - sage: Q1.diameter(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1/81, 1) + sage: Q2 = B(1/3) + sage: Q1.diameter(Q2) 0.00137174211248285 :: - sage: Q2.diameter(Q2) # optional - sage.rings.padics + sage: Q2.diameter(Q2) +infinity """ if basepoint == Infinity: @@ -693,21 +694,21 @@ def path_distance_metric(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1/4, 4) # optional - sage.rings.padics - sage: Q2 = B(1/4, 6) # optional - sage.rings.padics - sage: Q1.path_distance_metric(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1/4, 4) + sage: Q2 = B(1/4, 6) + sage: Q1.path_distance_metric(Q2) 0.369070246428542 :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q3.path_distance_metric(Q1) # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q3.path_distance_metric(Q1) +infinity :: - sage: Q3.path_distance_metric(Q3) # optional - sage.rings.padics + sage: Q3.path_distance_metric(Q3) 0 """ if not isinstance(other, type(self)): @@ -744,20 +745,20 @@ def Hsia_kernel(self, other, basepoint): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 9) # optional - sage.rings.padics - sage: Q2 = B(1/27, 1/27) # optional - sage.rings.padics - sage: Q3 = B(1, 1/3) # optional - sage.rings.padics - sage: Q1.Hsia_kernel(Q2, Q3) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 9) + sage: Q2 = B(1/27, 1/27) + sage: Q3 = B(1, 1/3) + sage: Q1.Hsia_kernel(Q2, Q3) 0.111111111111111 :: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 9) # optional - sage.rings.padics - sage: Q2 = B(1/2) # optional - sage.rings.padics - sage: Q3 = B(1/2) # optional - sage.rings.padics - sage: Q1.Hsia_kernel(Q2, Q3) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 9) + sage: Q2 = B(1/2) + sage: Q3 = B(1/2) + sage: Q1.Hsia_kernel(Q2, Q3) +infinity """ @@ -790,10 +791,10 @@ def small_metric(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1/4, 4) # optional - sage.rings.padics - sage: Q2 = B(1/4, 6) # optional - sage.rings.padics - sage: Q1.small_metric(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1/4, 4) + sage: Q2 = B(1/4, 6) + sage: Q1.small_metric(Q2) 0.0833333333333333 :: @@ -853,20 +854,20 @@ def potential_kernel(self, other, basepoint): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(27, 1) # optional - sage.rings.padics - sage: Q2 = B(1/3, 2) # optional - sage.rings.padics - sage: Q3 = B(1/9, 1/2) # optional - sage.rings.padics - sage: Q3.potential_kernel(Q1, Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(27, 1) + sage: Q2 = B(1/3, 2) + sage: Q3 = B(1/9, 1/2) + sage: Q3.potential_kernel(Q1, Q2) 0.369070246428543 :: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(27, 1) # optional - sage.rings.padics - sage: Q2 = B(1/3, 2) # optional - sage.rings.padics - sage: Q3 = B(1/9, 1/2) # optional - sage.rings.padics - sage: Q3.potential_kernel(Q1, Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(27, 1) + sage: Q2 = B(1/3, 2) + sage: Q3 = B(1/9, 1/2) + sage: Q3.potential_kernel(Q1, Q2) 0.369070246428543 """ if not isinstance(other, type(self)): @@ -895,16 +896,16 @@ def spherical_kernel(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 2) # optional - sage.rings.padics - sage: Q2 = B(1/9, 1) # optional - sage.rings.padics - sage: Q1.spherical_kernel(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 2) + sage: Q2 = B(1/9, 1) + sage: Q1.spherical_kernel(Q2) 0.500000000000000 :: - sage: Q3 = B(2) # optional - sage.rings.padics - sage: Q3.spherical_kernel(Q3) # optional - sage.rings.padics + sage: Q3 = B(2) + sage: Q3.spherical_kernel(Q3) 0 """ if not isinstance(other, type(self)): @@ -933,21 +934,22 @@ def Hsia_kernel_infinity(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: Q1 = B(1/4, 4) # optional - sage.rings.padics - sage: Q2 = B(1/4, 6) # optional - sage.rings.padics - sage: Q1.Hsia_kernel_infinity(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: Q1 = B(1/4, 4) + sage: Q2 = B(1/4, 6) + sage: Q1.Hsia_kernel_infinity(Q2) 6.00000000000000 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q1 = B(4) # optional - sage.rings.number_field - sage: Q2 = B(0, 1.5) # optional - sage.rings.number_field - sage: Q1.Hsia_kernel_infinity(Q2) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: Q1 = B(4) + sage: Q2 = B(0, 1.5) + sage: Q1.Hsia_kernel_infinity(Q2) 1.50000000000000 """ return self.join(other).diameter() @@ -961,23 +963,24 @@ def center(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(3, 1).center() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(3, 1).center() 3 + O(3^21) :: - sage: C = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: C(3, 1).center() # optional - sage.rings.padics + sage: C = Berkovich_Cp_Projective(3) + sage: C(3, 1).center() (3 + O(3^21) : 1 + O(3^20)) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: B(a^2 + 4).center() # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: B(a^2 + 4).center() (a^2 + 4 : 1) """ if self._type == 4: @@ -992,13 +995,13 @@ def type_of_point(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(1).type_of_point() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(1).type_of_point() 1 :: - sage: B(0, 1).type_of_point() # optional - sage.rings.padics + sage: B(0, 1).type_of_point() 2 """ return ZZ(self._type) @@ -1011,8 +1014,8 @@ def prime(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(1).prime() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(1).prime() 3 """ return ZZ(self._p) @@ -1023,10 +1026,11 @@ def __ne__(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(3, 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(3, RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q1 != Q2 # optional - sage.rings.padics sage.symbolic + sage: # needs sage.symbolic + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(3, 3**(1/2)) + sage: Q2 = B(3, RR(3**(1/2))) + sage: Q1 != Q2 False """ return not (self == other) @@ -1037,8 +1041,8 @@ def _repr_(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B(2, 1) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B(2, 1) Type II point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 3^0 """ if self._type == 1: @@ -1067,8 +1071,8 @@ def _latex_(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: latex(B(2, 1)) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: latex(B(2, 1)) \text{type 2 Point of } \text{Projective Berkovich line over } \Bold{C}_{3} \text{equivalent to the disk centered at (2 + O(3^20) : 1 + O(3^20)) of radius 1.00000000000000 in } \Bold{C}_3 @@ -1132,122 +1136,113 @@ class Berkovich_Element_Cp_Affine(Berkovich_Element_Cp): Type I points can be created by specifying the corresponding point of ``Cp``:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: B(4) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: B(4) Type I point centered at 1 + 3 + O(3^20) The center of a point can be an element of a finite extension of ``Qp``:: - sage: A. = Qq(27) # optional - sage.rings.padics - sage: B(1 + t) # optional - sage.rings.padics + sage: A. = Qq(27) + sage: B(1 + t) Type I point centered at (t + 1) + O(3^20) Type II and III points can be created by specifying a center and a radius:: - sage: B(2, 3**(1/2)) # optional - sage.rings.padics sage.symbolic + sage: B(2, 3**(1/2)) # needs sage.symbolic Type II point centered at 2 + O(3^20) of radius 3^1/2 :: - sage: B(2, 1.6) # optional - sage.rings.padics + sage: B(2, 1.6) Type III point centered at 2 + O(3^20) of radius 1.60000000000000 Some type II points may be mistaken for type III points:: - sage: B(3, 3**0.5) #not tested # optional - sage.rings.padics + sage: B(3, 3**0.5) # not tested Type III point centered at 3 + O(3^21) of radius 1.73205080756888 To avoid these errors, specify the power instead of the radius:: - sage: B(3, power=RR(1/100000)) # optional - sage.rings.padics + sage: B(3, power=RR(1/100000)) Type II point centered at 3 + O(3^21) of radius 3^1/100000 Type IV points can be constructed in a number of ways, the first being from a list of centers and radii used to approximate the point:: - sage: B([Qp(3)(2), Qp(3)(2), Qp(3)(2)], [1.761, 1.123, 1.112]) # optional - sage.rings.padics + sage: B([Qp(3)(2), Qp(3)(2), Qp(3)(2)], [1.761, 1.123, 1.112]) Type IV point of precision 3, approximated by disks centered at [2 + O(3^20), 2 + O(3^20)] ... with radii [1.76100000000000, 1.12300000000000] ... Type IV points can be constructed from univariate functions, with arbitrary precision:: - sage: A. = Qq(27) # optional - sage.rings.padics - sage: R. = PolynomialRing(A) # optional - sage.rings.padics - sage: f = (1 + t)^2*x # optional - sage.rings.padics - sage: S. = PolynomialRing(RR) # optional - sage.rings.padics - sage: S = FractionField(S) # optional - sage.rings.padics - sage: g = (y + 1)/y # optional - sage.rings.padics - sage: d = B(f, g, prec=100); d # optional - sage.rings.padics + sage: A. = Qq(27) + sage: R. = PolynomialRing(A) + sage: f = (1 + t)^2*x + sage: S. = PolynomialRing(RR) + sage: S = FractionField(S) + sage: g = (y + 1)/y + sage: d = B(f, g, prec=100); d Type IV point of precision 100 with centers given by ((t^2 + 2*t + 1) + O(3^20))*x and radii given by (y + 1.00000000000000)/y For increased performance, ``error_check`` can be set to ``False``. WARNING: with error check set to ``False``, any error in the input will lead to incorrect results:: - sage: B(f, g, prec=100, error_check=False) # optional - sage.rings.padics + sage: B(f, g, prec=100, error_check=False) Type IV point of precision 100 with centers given by ((t^2 + 2*t + 1) + O(3^20))*x and radii given by (y + 1.00000000000000)/y When creating a Berkovich space backed by a number field, points can be created similarly:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q1 = B(a); Q1 # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: Q1 = B(a); Q1 Type I point centered at (a : 1) :: - sage: B(a + 1, 3) # optional - sage.rings.number_field + sage: B(a + 1, 3) # needs sage.rings.number_field Type II point centered at (a + 1 : 1) of radius 3^1 TESTS:: - sage: A = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = A(3, 1); Q1 # optional - sage.rings.padics + sage: A = Berkovich_Cp_Affine(3) + sage: Q1 = A(3, 1); Q1 Type II point centered at 3 + O(3^21) of radius 3^0 - - sage: Q2 = A(2.5, 1); Q2 # optional - sage.rings.padics + sage: Q2 = A(2.5, 1); Q2 Type II point centered at 1 + 2*3 + 3^2 + 3^3 + 3^4 + 3^5 + 3^6 + 3^7 + 3^8 + 3^9 + 3^10 + 3^11 + 3^12 + 3^13 + 3^14 + 3^15 + 3^16 + 3^17 + 3^18 + 3^19 + O(3^20) of radius 3^0 - - sage: Q5 = A(3, 0); Q5 # optional - sage.rings.padics + sage: Q5 = A(3, 0); Q5 Type I point centered at 3 + O(3^21) - - sage: A(Zp(3)(2), 2).center().parent() == A(Qp(3)(2), 2).center().parent() # optional - sage.rings.padics + sage: A(Zp(3)(2), 2).center().parent() == A(Qp(3)(2), 2).center().parent() True - - sage: Q1 == Q2 # optional - sage.rings.padics + sage: Q1 == Q2 True - - sage: Q1 == Q5 # optional - sage.rings.padics + sage: Q1 == Q5 False - - sage: Q3 = A(Qp(3)(3), power=0, error_check=False); Q3 # optional - sage.rings.padics + sage: Q3 = A(Qp(3)(3), power=0, error_check=False); Q3 Type II point centered at 3 + O(3^21) of radius 3^0 - - sage: Q4 = A(3, 3**0); Q4 # optional - sage.rings.padics + sage: Q4 = A(3, 3**0); Q4 Type II point centered at 3 + O(3^21) of radius 3^0 - - sage: Q5 = A(3, power=1/2); Q5 # optional - sage.rings.padics + sage: Q5 = A(3, power=1/2); Q5 Type II point centered at 3 + O(3^21) of radius 3^1/2 - - sage: Q6 = A(3, RR(3**(1/2))); Q6 # optional - sage.rings.padics sage.symbolic + sage: Q6 = A(3, RR(3**(1/2))); Q6 # needs sage.symbolic Type III point centered at 3 + O(3^21) of radius 1.73205080756888 - - sage: Q5 == Q6 # optional - sage.rings.padics sage.symbolic + sage: Q5 == Q6 # needs sage.symbolic True - sage: k = Qp(5) # optional - sage.rings.padics - sage: R. = k[] # optional - sage.rings.padics - sage: l. = k.extension(x^2 - 5) # optional - sage.rings.padics - sage: B = Berkovich_Cp_Affine(5) # optional - sage.rings.padics - sage: B(w, power=1) # optional - sage.rings.padics + sage: k = Qp(5) + sage: R. = k[] + sage: l. = k.extension(x^2 - 5) + sage: B = Berkovich_Cp_Affine(5) + sage: B(w, power=1) Type II point centered at w + O(w^41) of radius 5^1 - sage: TestSuite(Q5).run() # optional - sage.rings.padics + sage: TestSuite(Q5).run() """ def __init__(self, parent, center, radius=None, power=None, prec=20, error_check=True): @@ -1256,8 +1251,8 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, error_check EXAMPLES:: - sage: A = Berkovich_Cp_Affine(17) # optional - sage.rings.padics - sage: A(5, 1) # optional - sage.rings.padics + sage: A = Berkovich_Cp_Affine(17) + sage: A(5, 1) Type II point centered at 5 + O(17^20) of radius 17^0 """ # we call Berkovich_Element_Cp constructor which is shared with projective Berkovich space @@ -1283,25 +1278,25 @@ def as_projective_point(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(5) # optional - sage.rings.padics - sage: B(5).as_projective_point() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(5) + sage: B(5).as_projective_point() Type I point centered at (5 + O(5^21) : 1 + O(5^20)) :: - sage: B(0, 1).as_projective_point() # optional - sage.rings.padics + sage: B(0, 1).as_projective_point() Type II point centered at (0 : 1 + O(5^20)) of radius 5^0 :: - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics - sage: R. = RR[] # optional - sage.rings.padics - sage: Y = FractionField(R) # optional - sage.rings.padics - sage: g = (40*pi)/x # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(f, g) # optional - sage.rings.padics sage.symbolic - sage: Q2.as_projective_point() # optional - sage.rings.padics sage.symbolic + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) + sage: R. = RR[] + sage: Y = FractionField(R) + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q2 = B(f, g) # needs sage.symbolic + sage: Q2.as_projective_point() # needs sage.symbolic Type IV point of precision 20 with centers given by (1 + O(5^20))/((1 + O(5^20))*t) and radii given by 40.0000000000000*pi/x """ @@ -1329,28 +1324,28 @@ def __eq__(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(1, RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(1, 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: Q1 == Q2 # optional - sage.rings.padics sage.symbolic + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(1, RR(3**(1/2))) # needs sage.symbolic + sage: Q2 = B(1, 3**(1/2)) # needs sage.symbolic + sage: Q1 == Q2 # needs sage.symbolic True :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q4 = B(4) # optional - sage.rings.padics - sage: Q3 == Q4 # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q4 = B(4) + sage: Q3 == Q4 False :: - sage: Q5 = B(1, 4) # optional - sage.rings.padics - sage: Q1 == Q5 # optional - sage.rings.padics sage.symbolic + sage: Q5 = B(1, 4) + sage: Q1 == Q5 # needs sage.symbolic False :: - sage: Q1 == Q3 # optional - sage.rings.padics sage.symbolic + sage: Q1 == Q3 # needs sage.symbolic False """ if other is self: @@ -1379,21 +1374,22 @@ def __hash__(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1, RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(1, 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: hash(Q1) == hash(Q2) # optional - sage.rings.padics sage.symbolic + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1, RR(3**(1/2))) # needs sage.symbolic + sage: Q2 = B(1, 3**(1/2)) # needs sage.symbolic + sage: hash(Q1) == hash(Q2) # needs sage.symbolic True :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q1 = B(a^2 + 1, 2) # optional - sage.rings.number_field - sage: Q2 = B(0, 2) # optional - sage.rings.number_field - sage: hash(Q1) == hash(Q2) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: Q1 = B(a^2 + 1, 2) + sage: Q2 = B(0, 2) + sage: hash(Q1) == hash(Q2) True """ if self.type_of_point() == 1: @@ -1425,40 +1421,40 @@ def lt(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(5, 0.5) # optional - sage.rings.padics - sage: Q2 = B(5, 1) # optional - sage.rings.padics - sage: Q1.lt(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(5, 0.5) + sage: Q2 = B(5, 1) + sage: Q1.lt(Q2) True :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q1.lt(Q3) # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q1.lt(Q3) False TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(5) # optional - sage.rings.padics - sage: Q1.lt(Q1) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(5) + sage: Q1.lt(Q1) False :: - sage: Q2 = B([4, 1/3], [5, 1]) # optional - sage.rings.padics - sage: Q1.lt(Q2) # optional - sage.rings.padics + sage: Q2 = B([4, 1/3], [5, 1]) + sage: Q1.lt(Q2) False :: - sage: Q4 = B(0, 1) # optional - sage.rings.padics - sage: Q1.lt(Q4) # optional - sage.rings.padics + sage: Q4 = B(0, 1) + sage: Q1.lt(Q4) True :: - sage: Q2.lt(Q4) # optional - sage.rings.padics + sage: Q2.lt(Q4) False """ if not isinstance(other, Berkovich_Element_Cp_Affine): @@ -1569,40 +1565,40 @@ def join(self, other, basepoint=Infinity): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(2, 1) # optional - sage.rings.padics - sage: Q2 = B(2, 2) # optional - sage.rings.padics - sage: Q1.join(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(2, 1) + sage: Q2 = B(2, 2) + sage: Q1.join(Q2) Type III point centered at 2 + O(3^20) of radius 2.00000000000000 :: - sage: Q3 = B(5) # optional - sage.rings.padics - sage: Q3.join(Q1) # optional - sage.rings.padics + sage: Q3 = B(5) + sage: Q3.join(Q1) Type II point centered at 2 + 3 + O(3^20) of radius 3^0 :: - sage: Q3.join(Q1, basepoint=Q2) # optional - sage.rings.padics + sage: Q3.join(Q1, basepoint=Q2) Type II point centered at 2 + O(3^20) of radius 3^0 TESTS:: - sage: Q4 = B(1/3**8 + 2, 1) # optional - sage.rings.padics - sage: Q2.join(Q4, basepoint=Q1) # optional - sage.rings.padics + sage: Q4 = B(1/3**8 + 2, 1) + sage: Q2.join(Q4, basepoint=Q1) Type III point centered at 2 + O(3^20) of radius 2.00000000000000 :: - sage: Q5 = B(2, 1/9) # optional - sage.rings.padics - sage: Q6 = B(1, 1/27) # optional - sage.rings.padics - sage: Q4.join(Q5, basepoint=Q6) # optional - sage.rings.padics + sage: Q5 = B(2, 1/9) + sage: Q6 = B(1, 1/27) + sage: Q4.join(Q5, basepoint=Q6) Type II point centered at 1 + O(3^20) of radius 3^0 :: - sage: Q7 = B(1/27, 1/27) # optional - sage.rings.padics - sage: Q1.join(Q7, Q2) # optional - sage.rings.padics + sage: Q7 = B(1/27, 1/27) + sage: Q1.join(Q7, Q2) Type III point centered at 2 + O(3^20) of radius 2.00000000000000 """ # we error check and then pass to projective space to do the join @@ -1648,46 +1644,46 @@ def involution_map(self): The involution map is 1/z on type I points:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1/2) # optional - sage.rings.padics - sage: Q1.involution_map() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1/2) + sage: Q1.involution_map() Type I point centered at 2 + O(3^20) :: - sage: Q2 = B(0, 1/3) # optional - sage.rings.padics - sage: Q2.involution_map() # optional - sage.rings.padics + sage: Q2 = B(0, 1/3) + sage: Q2.involution_map() Type II point centered at 0 of radius 3^1 :: - sage: Q3 = B(1/3, 1/3) # optional - sage.rings.padics - sage: Q3.involution_map() # optional - sage.rings.padics + sage: Q3 = B(1/3, 1/3) + sage: Q3.involution_map() Type II point centered at 3 + O(3^21) of radius 3^-3 TESTS:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(0).involution_map() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(0).involution_map() Traceback (most recent call last): ... ValueError: involution map not defined on affine type I point centered at 0 :: - sage: B(1/81, 1.5).involution_map() # optional - sage.rings.padics + sage: B(1/81, 1.5).involution_map() Type III point centered at 3^4 + O(3^24) of radius 0.000228623685413809 :: - sage: B([1, 2], [3, 1]).involution_map() # optional - sage.rings.padics + sage: B([1, 2], [3, 1]).involution_map() Traceback (most recent call last): ... ValueError: precision of type IV is not high enough to define image :: - sage: B([1/81, 10/81], [10, 9]).involution_map() # optional - sage.rings.padics + sage: B([1/81, 10/81], [10, 9]).involution_map() Type IV point of precision 2, approximated by disks centered at [3^4 + O(3^24), 3^4 + 2*3^6 + 2*3^7 + 2*3^10 + 2*3^11 + 2*3^14 + 2*3^15 + 2*3^18 + 2*3^19 + 2*3^22 + 2*3^23 + O(3^24)] ... with radii [0.00152415790275873, 0.00137174211248285] ... @@ -1741,17 +1737,17 @@ def contained_in_interval(self, start, end): EXAMPLES:: - sage: B = Berkovich_Cp_Projective((3)) # optional - sage.rings.padics - sage: Q1 = B(2, 1) # optional - sage.rings.padics - sage: Q2 = B(2, 4) # optional - sage.rings.padics - sage: Q3 = B(1/3) # optional - sage.rings.padics - sage: Q2.contained_in_interval(Q1, Q3.join(Q1)) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective((3)) + sage: Q1 = B(2, 1) + sage: Q2 = B(2, 4) + sage: Q3 = B(1/3) + sage: Q2.contained_in_interval(Q1, Q3.join(Q1)) False :: - sage: Q4 = B(1/81, 1) # optional - sage.rings.padics - sage: Q2.contained_in_interval(Q1, Q4.join(Q1)) # optional - sage.rings.padics + sage: Q4 = B(1/81, 1) + sage: Q2.contained_in_interval(Q1, Q4.join(Q1)) True """ if not isinstance(start, Berkovich_Element_Cp_Affine): @@ -1821,39 +1817,39 @@ class Berkovich_Element_Cp_Projective(Berkovich_Element_Cp): Type I points can be created by specifying the corresponding point of `P^1(\CC_p)`:: - sage: S = ProjectiveSpace(Qp(5), 1) # optional - sage.rings.padics - sage: P = Berkovich_Cp_Projective(S); P # optional - sage.rings.padics + sage: S = ProjectiveSpace(Qp(5), 1) + sage: P = Berkovich_Cp_Projective(S); P Projective Berkovich line over Cp(5) of precision 20 :: - sage: a = S(0, 1) # optional - sage.rings.padics - sage: Q1 = P(a); Q1 # optional - sage.rings.padics + sage: a = S(0, 1) + sage: Q1 = P(a); Q1 Type I point centered at (0 : 1 + O(5^20)) :: - sage: Q2 = P((1,0)); Q2 # optional - sage.rings.padics + sage: Q2 = P((1,0)); Q2 Type I point centered at (1 + O(5^20) : 0) Type II and III points can be created by specifying a center and a radius:: - sage: Q3 = P((0,5), 5**(3/2)); Q3 # optional - sage.rings.padics sage.symbolic + sage: Q3 = P((0,5), 5**(3/2)); Q3 # needs sage.symbolic Type II point centered at (0 : 1 + O(5^20)) of radius 5^3/2 :: - sage: Q4 = P(0, 3**(3/2)); Q4 # optional - sage.rings.padics sage.symbolic + sage: Q4 = P(0, 3**(3/2)); Q4 # needs sage.symbolic Type III point centered at (0 : 1 + O(5^20)) of radius 5.19615242270663 Type IV points can be created from lists of centers and radii:: - sage: b = S((3,2)) # create centers # optional - sage.rings.padics - sage: c = S((4,3)) # optional - sage.rings.padics - sage: d = S((2,3)) # optional - sage.rings.padics - sage: L = [b, c, d] # optional - sage.rings.padics - sage: R = [1.761, 1.123, 1.112] # optional - sage.rings.padics - sage: Q5 = P(L, R); Q5 # optional - sage.rings.padics + sage: b = S((3,2)) # create centers + sage: c = S((4,3)) + sage: d = S((2,3)) + sage: L = [b, c, d] + sage: R = [1.761, 1.123, 1.112] + sage: Q5 = P(L, R); Q5 Type IV point of precision 3, approximated by disks centered at [(4 + 2*5 + 2*5^2 + 2*5^3 + 2*5^4 + 2*5^5 + 2*5^6 + 2*5^7 + 2*5^8 + 2*5^9 + 2*5^10 + 2*5^11 + 2*5^12 + 2*5^13 + 2*5^14 + 2*5^15 + 2*5^16 + 2*5^17 + 2*5^18 + 2*5^19 + O(5^20) : @@ -1865,26 +1861,26 @@ class Berkovich_Element_Cp_Projective(Berkovich_Element_Cp): the sequence of disks can not be the point at infinity in `P^1(\CC_p)`, only functions into `\CC_p` are supported:: - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) sage: R. = RR[] sage: Y = FractionField(R) - sage: g = (40*pi)/x # optional - sage.rings.padics sage.symbolic - sage: Q6 = P(f, g); Q6 # optional - sage.rings.padics sage.symbolic + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q6 = P(f, g); Q6 # needs sage.symbolic Type IV point of precision 20 with centers given by (1 + O(5^20))/((1 + O(5^20))*t) and radii given by 40.0000000000000*pi/x TESTS:: - sage: P((1,0), 3) # optional - sage.rings.padics + sage: P((1,0), 3) Traceback (most recent call last): ... ValueError: type II and III points can not be centered at infinity - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(3) # optional - sage.rings.padics - sage: TestSuite(Q1).run() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(3) + sage: TestSuite(Q1).run() """ def __init__(self, parent, center, radius=None, power=None, prec=20, error_check=True): @@ -1893,9 +1889,9 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, error_check EXAMPLES:: - sage: S = ProjectiveSpace(Qp(7), 1) # optional - sage.rings.padics - sage: P = Berkovich_Cp_Projective(S) # optional - sage.rings.padics - sage: P(0,1) # optional - sage.rings.padics + sage: S = ProjectiveSpace(Qp(7), 1) + sage: P = Berkovich_Cp_Projective(S) + sage: P(0,1) Type II point centered at (0 : 1 + O(7^20)) of radius 7^0 """ # if we are given a point of Affine Berkovich Space, we do the conversion @@ -1921,27 +1917,27 @@ def as_affine_point(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(5) # optional - sage.rings.padics - sage: B(5).as_affine_point() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(5) + sage: B(5).as_affine_point() Type I point centered at 5 + O(5^21) :: - sage: Q = B(0, 1).as_affine_point(); Q # optional - sage.rings.padics + sage: Q = B(0, 1).as_affine_point(); Q Type II point centered at 0 of radius 5^0 - sage: Q.parent() # optional - sage.rings.padics + sage: Q.parent() Affine Berkovich line over Cp(5) of precision 20 :: - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) sage: R. = RR[] sage: Y = FractionField(R) - sage: g = (40*pi)/x # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(f, g) # optional - sage.rings.padics sage.symbolic - sage: Q2.as_affine_point() # optional - sage.rings.padics sage.symbolic + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q2 = B(f, g) # needs sage.symbolic + sage: Q2.as_affine_point() # needs sage.symbolic Type IV point of precision 20 with centers given by (1 + O(5^20))/((1 + O(5^20))*t) and radii given by 40.0000000000000*pi/x """ @@ -1973,28 +1969,28 @@ def __eq__(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B([2, 2], RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B([1, 1], 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: Q1 == Q2 # optional - sage.rings.padics sage.symbolic + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B([2, 2], RR(3**(1/2))) # needs sage.symbolic + sage: Q2 = B([1, 1], 3**(1/2)) # needs sage.symbolic + sage: Q1 == Q2 # needs sage.symbolic True :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q4 = B(4) # optional - sage.rings.padics - sage: Q3 == Q4 # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q4 = B(4) + sage: Q3 == Q4 False :: - sage: Q5 = B(1, 4) # optional - sage.rings.padics - sage: Q1 == Q5 # optional - sage.rings.padics sage.symbolic + sage: Q5 = B(1, 4) + sage: Q1 == Q5 # needs sage.symbolic False :: - sage: Q1 == Q3 # optional - sage.rings.padics sage.symbolic + sage: Q1 == Q3 # needs sage.symbolic False """ if other is self: @@ -2025,22 +2021,23 @@ def __hash__(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: P = ProjectiveSpace(B.base_ring(), 1) # optional - sage.rings.padics - sage: Q1 = B(P.point([2, 2], False), RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B([1, 1], 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: hash(Q1) == hash(Q2) # optional - sage.rings.padics sage.symbolic + sage: B = Berkovich_Cp_Projective(3) + sage: P = ProjectiveSpace(B.base_ring(), 1) + sage: Q1 = B(P.point([2, 2], False), RR(3**(1/2))) # needs sage.symbolic + sage: Q2 = B([1, 1], 3**(1/2)) # needs sage.symbolic + sage: hash(Q1) == hash(Q2) # needs sage.symbolic True :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q1 = B(a^2 + 1, 2) # optional - sage.rings.number_field - sage: Q2 = B(0, 2) # optional - sage.rings.number_field - sage: hash(Q1) == hash(Q2) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: Q1 = B(a^2 + 1, 2) + sage: Q2 = B(0, 2) + sage: hash(Q1) == hash(Q2) True """ if self.type_of_point() == 1: @@ -2072,51 +2069,51 @@ def lt(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(5, 0.5) # optional - sage.rings.padics - sage: Q2 = B(5, 1) # optional - sage.rings.padics - sage: Q1.lt(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(5, 0.5) + sage: Q2 = B(5, 1) + sage: Q1.lt(Q2) True :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q1.lt(Q3) # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q1.lt(Q3) False TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(5) # optional - sage.rings.padics - sage: Q1.lt(Q1) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(5) + sage: Q1.lt(Q1) False :: - sage: Q2 = B([4, 1/3], [5, 1]) # optional - sage.rings.padics - sage: Q1.lt(Q2) # optional - sage.rings.padics + sage: Q2 = B([4, 1/3], [5, 1]) + sage: Q1.lt(Q2) False :: - sage: Q3 = B((1,0)) # optional - sage.rings.padics - sage: Q4 = B(0, 1) # optional - sage.rings.padics - sage: Q3.lt(Q4) # optional - sage.rings.padics + sage: Q3 = B((1,0)) + sage: Q4 = B(0, 1) + sage: Q3.lt(Q4) False :: - sage: Q4.lt(Q3) # optional - sage.rings.padics + sage: Q4.lt(Q3) True :: - sage: Q1.lt(Q4) # optional - sage.rings.padics + sage: Q1.lt(Q4) True :: - sage: Q2.lt(Q4) # optional - sage.rings.padics + sage: Q2.lt(Q4) False """ if not isinstance(other, Berkovich_Element_Cp_Projective): @@ -2251,58 +2248,54 @@ def join(self, other, basepoint=Infinity): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 1) # optional - sage.rings.padics - sage: Q2 = B(2, 2) # optional - sage.rings.padics - sage: Q1.join(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 1) + sage: Q2 = B(2, 2) + sage: Q1.join(Q2) Type III point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 2.00000000000000 :: - sage: Q3 = B(5) # optional - sage.rings.padics - sage: Q3.join(Q1) # optional - sage.rings.padics + sage: Q3 = B(5) + sage: Q3.join(Q1) Type II point centered at (2 + 3 + O(3^20) : 1 + O(3^20)) of radius 3^0 :: - sage: Q3.join(Q1, basepoint=Q2) # optional - sage.rings.padics + sage: Q3.join(Q1, basepoint=Q2) Type II point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 3^0 TESTS:: - sage: Q4 = B(1/3**8 + 2, 1) # optional - sage.rings.padics - sage: Q2.join(Q4, basepoint=Q1) # optional - sage.rings.padics + sage: Q4 = B(1/3**8 + 2, 1) + sage: Q2.join(Q4, basepoint=Q1) Type III point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 2.00000000000000 - - sage: Q5 = B(2, 1/9) # optional - sage.rings.padics - sage: Q6 = B(1, 1/27) # optional - sage.rings.padics - sage: Q4.join(Q5, basepoint=Q6) # optional - sage.rings.padics + sage: Q5 = B(2, 1/9) + sage: Q6 = B(1, 1/27) + sage: Q4.join(Q5, basepoint=Q6) Type II point centered at (1 + O(3^20) : 1 + O(3^20)) of radius 3^0 - - sage: Q7 = B(1/27, 1/27) # optional - sage.rings.padics - sage: Q1.join(Q7, Q2) # optional - sage.rings.padics + sage: Q7 = B(1/27, 1/27) + sage: Q1.join(Q7, Q2) Type III point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 2.00000000000000 - - sage: Q1.join(Q2, Q7) # optional - sage.rings.padics + sage: Q1.join(Q2, Q7) Type III point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 2.00000000000000 - - sage: Q8 = B(0, power=1/3) # optional - sage.rings.padics - sage: Q9 = B(0, power=1/2) # optional - sage.rings.padics - sage: Q8.join(Q9) # optional - sage.rings.padics + sage: Q8 = B(0, power=1/3) + sage: Q9 = B(0, power=1/2) + sage: Q8.join(Q9) Type II point centered at (0 : 1 + O(3^20)) of radius 3^1/2 + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: C = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q10 = C(a, 1/9) # optional - sage.rings.number_field - sage: Q10.join(Q9) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: C = Berkovich_Cp_Projective(A, ideal) + sage: Q10 = C(a, 1/9) + sage: Q10.join(Q9) Traceback (most recent call last): ... ValueError: other must be a point of the same projective Berkovich line - - sage: Q11 = C(0, 1/3) # optional - sage.rings.number_field - sage: Q11.join(Q10) # optional - sage.rings.number_field + sage: Q11 = C(0, 1/3) + sage: Q11.join(Q10) Type II point centered at (0 : 1) of radius 3^0 """ if not isinstance(other, Berkovich_Element_Cp_Projective): @@ -2415,49 +2408,49 @@ def involution_map(self): The involution map is 1/z on type I points:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(1/2) # optional - sage.rings.padics - sage: Q1.involution_map() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(1/2) + sage: Q1.involution_map() Type I point centered at (2 + O(3^20) : 1 + O(3^20)) :: - sage: Q2 = B(0, 1/3) # optional - sage.rings.padics - sage: Q2.involution_map() # optional - sage.rings.padics + sage: Q2 = B(0, 1/3) + sage: Q2.involution_map() Type II point centered at (0 : 1 + O(3^20)) of radius 3^1 :: - sage: Q3 = B(1/3, 1/3) # optional - sage.rings.padics - sage: Q3.involution_map() # optional - sage.rings.padics + sage: Q3 = B(1/3, 1/3) + sage: Q3.involution_map() Type II point centered at (3 + O(3^21) : 1 + O(3^20)) of radius 3^-3 TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B((1,0)).involution_map() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B((1,0)).involution_map() Type I point centered at (0 : 1 + O(3^20)) :: - sage: B(0).involution_map() # optional - sage.rings.padics + sage: B(0).involution_map() Type I point centered at (1 + O(3^20) : 0) :: - sage: B(1/81, 1.5).involution_map() # optional - sage.rings.padics + sage: B(1/81, 1.5).involution_map() Type III point centered at (3^4 + O(3^24) : 1 + O(3^20)) of radius 0.000228623685413809 :: - sage: B([1, 2], [3, 1]).involution_map() # optional - sage.rings.padics + sage: B([1, 2], [3, 1]).involution_map() Traceback (most recent call last): ... ValueError: precision of type IV is not high enough to define image :: - sage: B([1/81, 10/81], [10, 9]).involution_map() # optional - sage.rings.padics + sage: B([1/81, 10/81], [10, 9]).involution_map() Type IV point of precision 2, approximated by disks centered at [(3^4 + O(3^24) : 1 + O(3^20)), (3^4 + 2*3^6 + 2*3^7 + 2*3^10 + 2*3^11 + 2*3^14 + 2*3^15 + 2*3^18 + 2*3^19 + 2*3^22 + 2*3^23 + O(3^24) : 1 + O(3^20))] @@ -2514,48 +2507,48 @@ def contained_in_interval(self, start, end): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 1) # optional - sage.rings.padics - sage: Q2 = B(2, 4) # optional - sage.rings.padics - sage: Q3 = B(1/3) # optional - sage.rings.padics - sage: Q2.contained_in_interval(Q1, Q3.join(Q1)) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 1) + sage: Q2 = B(2, 4) + sage: Q3 = B(1/3) + sage: Q2.contained_in_interval(Q1, Q3.join(Q1)) False :: - sage: Q4 = B(1/81, 1) # optional - sage.rings.padics - sage: Q2.contained_in_interval(Q1, Q4.join(Q1)) # optional - sage.rings.padics + sage: Q4 = B(1/81, 1) + sage: Q2.contained_in_interval(Q1, Q4.join(Q1)) True TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: infty = B((1, 0)) # optional - sage.rings.padics - sage: zero = B(0) # optional - sage.rings.padics - sage: gauss = B(0, 1) # optional - sage.rings.padics - sage: infty.contained_in_interval(zero, gauss) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: infty = B((1, 0)) + sage: zero = B(0) + sage: gauss = B(0, 1) + sage: infty.contained_in_interval(zero, gauss) False :: - sage: Q1 = B(1, 3) # optional - sage.rings.padics - sage: infty.contained_in_interval(gauss, Q1) # optional - sage.rings.padics + sage: Q1 = B(1, 3) + sage: infty.contained_in_interval(gauss, Q1) False :: - sage: zero.contained_in_interval(infty, gauss) # optional - sage.rings.padics + sage: zero.contained_in_interval(infty, gauss) False :: - sage: gauss.contained_in_interval(zero, infty) # optional - sage.rings.padics + sage: gauss.contained_in_interval(zero, infty) True :: - sage: Q2 = B(81, 1/3) # optional - sage.rings.padics - sage: gauss.contained_in_interval(infty, Q2) # optional - sage.rings.padics + sage: Q2 = B(81, 1/3) + sage: gauss.contained_in_interval(infty, Q2) True """ if not isinstance(start, Berkovich_Element_Cp_Projective): diff --git a/src/sage/schemes/berkovich/berkovich_space.py b/src/sage/schemes/berkovich/berkovich_space.py index 9e04a0bb61d..100c2807b9d 100644 --- a/src/sage/schemes/berkovich/berkovich_space.py +++ b/src/sage/schemes/berkovich/berkovich_space.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics r""" Berkovich Space over `\CC_p` @@ -56,9 +57,9 @@ def is_Berkovich(space) -> bool: EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) sage: from sage.schemes.berkovich.berkovich_space import is_Berkovich - sage: is_Berkovich(B) # optional - sage.rings.padics + sage: is_Berkovich(B) True """ return isinstance(space, Berkovich) @@ -75,9 +76,9 @@ def is_Berkovich_Cp(space) -> bool: EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) sage: from sage.schemes.berkovich.berkovich_space import is_Berkovich - sage: is_Berkovich(B) # optional - sage.rings.padics + sage: is_Berkovich(B) True """ return isinstance(space, Berkovich_Cp) @@ -101,17 +102,18 @@ def residue_characteristic(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B.prime() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B.prime() 3 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Affine(A, ideal) # optional - sage.rings.number_field - sage: B.residue_characteristic() # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Affine(A, ideal) + sage: B.residue_characteristic() 7 """ return self._p @@ -129,8 +131,8 @@ def is_padic_base(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: B.is_padic_base() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: B.is_padic_base() True :: @@ -152,8 +154,8 @@ def is_number_field_base(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: B.is_number_field_base() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: B.is_number_field_base() False :: @@ -181,11 +183,12 @@ def ideal(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # optional - sage.rings.number_field - sage: ideal = A.prime_above(5) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: B.ideal() # optional - sage.rings.number_field + sage: A. = NumberField(z^2 + 1) + sage: ideal = A.prime_above(5) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: B.ideal() Fractional ideal (-a - 2) :: @@ -196,8 +199,8 @@ def ideal(self): :: - sage: B = Berkovich_Cp_Projective(Qp(3)) # optional - sage.rings.padics - sage: B.ideal() is None # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(Qp(3)) + sage: B.ideal() is None True """ return self._ideal @@ -208,36 +211,37 @@ def __eq__(self, right): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: A. = Qq(27) # optional - sage.rings.padics - sage: C = Berkovich_Cp_Affine(A) # optional - sage.rings.padics - sage: B == C # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: A. = Qq(27) + sage: C = Berkovich_Cp_Affine(A) + sage: B == C True :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: A_ideal = A.prime_above(2) # optional - sage.rings.number_field - sage: B. = NumberField(x^4 + 1) # optional - sage.rings.number_field - sage: B_ideal = B.prime_above(2) # optional - sage.rings.number_field - sage: C = Berkovich_Cp_Projective(A, A_ideal) # optional - sage.rings.number_field - sage: D = Berkovich_Cp_Projective(B, B_ideal) # optional - sage.rings.number_field - sage: C == D # optional - sage.rings.number_field + sage: A. = NumberField(x^2 + 1) + sage: A_ideal = A.prime_above(2) + sage: B. = NumberField(x^4 + 1) + sage: B_ideal = B.prime_above(2) + sage: C = Berkovich_Cp_Projective(A, A_ideal) + sage: D = Berkovich_Cp_Projective(B, B_ideal) + sage: C == D False :: - sage: C = Berkovich_Cp_Affine(A, A_ideal) # optional - sage.rings.number_field - sage: D = Berkovich_Cp_Affine(B, B_ideal) # optional - sage.rings.number_field - sage: C == D # optional - sage.rings.number_field + sage: C = Berkovich_Cp_Affine(A, A_ideal) # needs sage.rings.number_field + sage: D = Berkovich_Cp_Affine(B, B_ideal) # needs sage.rings.number_field + sage: C == D # needs sage.rings.number_field False :: - sage: A_ideal_2 = A.prime_above(5) # optional - sage.rings.number_field - sage: E = Berkovich_Cp_Affine(A, A_ideal_2) # optional - sage.rings.number_field - sage: C == E + sage: A_ideal_2 = A.prime_above(5) # needs sage.rings.number_field + sage: E = Berkovich_Cp_Affine(A, A_ideal_2) # needs sage.rings.number_field + sage: C == E # needs sage.rings.number_field False """ if not isinstance(right, Berkovich_Cp): @@ -255,10 +259,10 @@ def __ne__(self, right): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(5) # optional - sage.rings.padics - sage: A. = Qq(25) # optional - sage.rings.padics - sage: C = Berkovich_Cp_Affine(A) # optional - sage.rings.padics - sage: B != C # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(5) + sage: A. = Qq(25) + sage: C = Berkovich_Cp_Affine(A) + sage: B != C False """ return not (self == right) @@ -269,16 +273,17 @@ def __hash__(self): EXAMPLES:: - sage: hash(Berkovich_Cp_Projective(3)) # optional - sage.rings.padics + sage: hash(Berkovich_Cp_Projective(3)) 3 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, A.primes_above(5)[0]) # optional - sage.rings.number_field - sage: C = Berkovich_Cp_Projective(A, A.primes_above(5)[1]) # optional - sage.rings.number_field - sage: hash(B) != hash(C) # optional - sage.rings.number_field + sage: A. = NumberField(z^2 + 1) + sage: B = Berkovich_Cp_Projective(A, A.primes_above(5)[0]) + sage: C = Berkovich_Cp_Projective(A, A.primes_above(5)[1]) + sage: hash(B) != hash(C) True """ if self._base_type == 'padic field': @@ -319,57 +324,57 @@ class Berkovich_Cp_Affine(Berkovich_Cp): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3); B Affine Berkovich line over Cp(3) of precision 20 We can create elements:: - sage: B(-2) # optional - sage.rings.padics + sage: B(-2) Type I point centered at 1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + 2*3^8 + 2*3^9 + 2*3^10 + 2*3^11 + 2*3^12 + 2*3^13 + 2*3^14 + 2*3^15 + 2*3^16 + 2*3^17 + 2*3^18 + 2*3^19 + O(3^20) :: - sage: B(1, 2) # optional - sage.rings.padics + sage: B(1, 2) Type III point centered at 1 + O(3^20) of radius 2.00000000000000 For details on element creation, see the documentation of :class:`Berkovich_Element_Cp_Affine`. Initializing by passing in `\QQ_p` looks the same:: - sage: B = Berkovich_Cp_Affine(Qp(3)); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)); B Affine Berkovich line over Cp(3) of precision 20 However, this method allows for more control over behind-the-scenes conversion:: - sage: B = Berkovich_Cp_Affine(Qp(3, 1)); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3, 1)); B Affine Berkovich line over Cp(3) of precision 1 - sage: B(1/2) # optional - sage.rings.padics + sage: B(1/2) Type I point centered at 2 + O(3) Note that this point has very low precision, as ``B`` was initialized with a p-adic field of capped-relative precision one. For high precision, pass in a high precision p-adic field:: - sage: B = Berkovich_Cp_Affine(Qp(3, 1000)); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3, 1000)); B Affine Berkovich line over Cp(3) of precision 1000 Points of Berkovich space can be created from points of extensions of `\QQ_p`:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: A. = Qp(3).extension(x^3 - 3) # optional - sage.rings.padics - sage: B(a) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: A. = Qp(3).extension(x^3 - 3) + sage: B(a) Type I point centered at a + O(a^61) For exact computation, a number field can be used:: sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Affine(A, ideal); B # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) # needs sage.rings.number_field + sage: ideal = A.prime_above(3) # needs sage.rings.number_field + sage: B = Berkovich_Cp_Affine(A, ideal); B # needs sage.rings.number_field Affine Berkovich line over Cp(3), with base Number Field in a with defining polynomial x^3 + 20 @@ -386,12 +391,13 @@ class Berkovich_Cp_Affine(Berkovich_Cp): field, any point of a Berkovich space backed by a number field must be centered at a point of that number field:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Affine(A, ideal) # optional - sage.rings.number_field - sage: C. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: B(c) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: B = Berkovich_Cp_Affine(A, ideal) + sage: C. = NumberField(x^2 + 1) + sage: B(c) Traceback (most recent call last): ... ValueError: could not convert c to Number Field in a @@ -399,14 +405,14 @@ class Berkovich_Cp_Affine(Berkovich_Cp): TESTS:: - sage: A. = AffineSpace(Qp(3), 1) # optional - sage.rings.padics - sage: Berkovich_Cp_Affine(A) # optional - sage.rings.padics + sage: A. = AffineSpace(Qp(3), 1) + sage: Berkovich_Cp_Affine(A) Affine Berkovich line over Cp(3) of precision 20 :: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: TestSuite(B).run() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: TestSuite(B).run() """ Element = Berkovich_Element_Cp_Affine @@ -417,7 +423,7 @@ def __init__(self, base, ideal=None): EXAMPLES:: - sage: Berkovich_Cp_Affine(3) # optional - sage.rings.padics + sage: Berkovich_Cp_Affine(3) Affine Berkovich line over Cp(3) of precision 20 """ if base in ZZ: @@ -463,16 +469,15 @@ def _repr_(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3); B Affine Berkovich line over Cp(3) of precision 20 :: sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: Berkovich_Cp_Affine(A, ideal) # optional - sage.rings.number_field + sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field + sage: ideal = A.prime_above(3) # needs sage.rings.number_field + sage: Berkovich_Cp_Affine(A, ideal) # needs sage.rings.number_field Affine Berkovich line over Cp(3), with base Number Field in a with defining polynomial z^2 + 1 """ @@ -489,8 +494,8 @@ def _latex_(self): EXAMPLES: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: latex(B) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: latex(B) \text{Affine Berkovich line over } \Bold{C}_{3} """ return r"\text{Affine Berkovich line over } \Bold{C}_{%s}" % (self.prime()) @@ -529,36 +534,36 @@ class Berkovich_Cp_Projective(Berkovich_Cp): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3); B Projective Berkovich line over Cp(3) of precision 20 Elements can be constructed:: - sage: B(1/2) # optional - sage.rings.padics + sage: B(1/2) Type I point centered at (2 + 3 + 3^2 + 3^3 + 3^4 + 3^5 + 3^6 + 3^7 + 3^8 + 3^9 + 3^10 + 3^11 + 3^12 + 3^13 + 3^14 + 3^15 + 3^16 + 3^17 + 3^18 + 3^19 + O(3^20) : 1 + O(3^20)) :: - sage: B(2, 1) # optional - sage.rings.padics + sage: B(2, 1) Type II point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 3^0 For details about element construction, see the documentation of :class:`Berkovich_Element_Cp_Projective`. Initializing a Berkovich projective line by passing in a p-adic space looks the same:: - sage: B = Berkovich_Cp_Projective(Qp(3)); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(Qp(3)); B Projective Berkovich line over Cp(3) of precision 20 However, this method allows for more control over behind-the-scenes conversion:: - sage: S = Qp(3, 1) # optional - sage.rings.padics - sage: B = Berkovich_Cp_Projective(S); B # optional - sage.rings.padics + sage: S = Qp(3, 1) + sage: B = Berkovich_Cp_Projective(S); B Projective Berkovich line over Cp(3) of precision 1 - sage: Q1 = B(1/2); Q1 # optional - sage.rings.padics + sage: Q1 = B(1/2); Q1 Type I point centered at (2 + O(3) : 1 + O(3)) Note that this point has very low precision, as S has low @@ -566,9 +571,9 @@ class Berkovich_Cp_Projective(Berkovich_Cp): a number field, as long as an ideal is specified:: sage: R. = QQ[] - sage: A. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: ideal = A.prime_above(2) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal); B # optional - sage.rings.number_field + sage: A. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: ideal = A.prime_above(2) # needs sage.rings.number_field + sage: B = Berkovich_Cp_Projective(A, ideal); B # needs sage.rings.number_field Projective Berkovich line over Cp(2), with base Number Field in a with defining polynomial x^2 + 1 @@ -587,12 +592,13 @@ class Berkovich_Cp_Projective(Berkovich_Cp): field, any point of a Berkovich space backed by a number field must be centered at a point of that number field:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: C. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: B(c) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: C. = NumberField(x^2 + 1) + sage: B(c) Traceback (most recent call last): ... TypeError: could not convert c to Projective Space @@ -600,8 +606,8 @@ class Berkovich_Cp_Projective(Berkovich_Cp): TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: TestSuite(B).run() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: TestSuite(B).run() """ Element = Berkovich_Element_Cp_Projective @@ -612,7 +618,7 @@ def __init__(self, base, ideal=None): EXAMPLES:: - sage: Berkovich_Cp_Projective(3) # optional - sage.rings.padics + sage: Berkovich_Cp_Projective(3) Projective Berkovich line over Cp(3) of precision 20 """ if base in ZZ: @@ -669,23 +675,24 @@ def base_ring(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B.base_ring() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B.base_ring() 3-adic Field with capped relative precision 20 :: - sage: C = Berkovich_Cp_Projective(ProjectiveSpace(Qp(3, 1), 1)) # optional - sage.rings.padics - sage: C.base_ring() # optional - sage.rings.padics + sage: C = Berkovich_Cp_Projective(ProjectiveSpace(Qp(3, 1), 1)) + sage: C.base_ring() 3-adic Field with capped relative precision 1 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: D = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: D.base_ring() # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: D = Berkovich_Cp_Projective(A, ideal) + sage: D.base_ring() Number Field in a with defining polynomial x^3 + 20 """ return self.base().base_ring() @@ -696,16 +703,15 @@ def _repr_(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3); B Projective Berkovich line over Cp(3) of precision 20 :: sage: R. = QQ[] - sage: A. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: v = A.ideal(a + 1) # optional - sage.rings.number_field - sage: Berkovich_Cp_Projective(A, v) # optional - sage.rings.number_field + sage: A. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: v = A.ideal(a + 1) # needs sage.rings.number_field + sage: Berkovich_Cp_Projective(A, v) # needs sage.rings.number_field Projective Berkovich line over Cp(2), with base Number Field in a with defining polynomial x^2 + 1 """ @@ -722,8 +728,8 @@ def _latex_(self): EXAMPLES: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: latex(B) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: latex(B) \text{Projective Berkovich line over } \Bold{C}_{3} """ return r"\text{Projective Berkovich line over } \Bold{C}_{%s}" % (self.prime()) diff --git a/src/sage/schemes/curves/closed_point.py b/src/sage/schemes/curves/closed_point.py index 84cd5e84cc5..0b5952559c1 100644 --- a/src/sage/schemes/curves/closed_point.py +++ b/src/sage/schemes/curves/closed_point.py @@ -9,30 +9,30 @@ EXAMPLES:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: C.closed_points() [Point (x, y), Point (x, y + 1)] - sage: C.closed_points(2) # optional - sage.rings.finite_rings + sage: C.closed_points(2) [Point (y^2 + y + 1, x + 1), Point (y^2 + y + 1, x + y), Point (y^2 + y + 1, x + y + 1)] - sage: C.closed_points(3) # optional - sage.rings.finite_rings + sage: C.closed_points(3) [Point (x^2 + x + y, x*y + 1, y^2 + x + 1), Point (x^2 + x + y + 1, x*y + x + 1, y^2 + x)] Closed points of projective curves are represented by homogeneous maximal ideals:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^3*y + y^3*z + x*z^3) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: P. = ProjectiveSpace(F, 2) + sage: C = Curve(x^3*y + y^3*z + x*z^3) + sage: C.closed_points() [Point (x, z), Point (x, y), Point (y, z)] - sage: C.closed_points(2) # optional - sage.rings.finite_rings + sage: C.closed_points(2) [Point (y^2 + y*z + z^2, x + y + z)] - sage: C.closed_points(3) # optional - sage.rings.finite_rings + sage: C.closed_points(3) [Point (y^3 + y^2*z + z^3, x + y), Point (y^3 + y*z^2 + z^3, x + z), Point (x^2 + x*z + y*z + z^2, x*y + x*z + z^2, y^2 + x*z), @@ -44,19 +44,19 @@ Rational points are easily converted to closed points and vice versa if the closed point is of degree one:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^3*y + y^3*z + x*z^3) # optional - sage.rings.finite_rings - sage: p1, p2, p3 = C.closed_points() # optional - sage.rings.finite_rings - sage: p1.rational_point() # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: P. = ProjectiveSpace(F, 2) + sage: C = Curve(x^3*y + y^3*z + x*z^3) + sage: p1, p2, p3 = C.closed_points() + sage: p1.rational_point() (0 : 1 : 0) - sage: p2.rational_point() # optional - sage.rings.finite_rings + sage: p2.rational_point() (0 : 0 : 1) - sage: p3.rational_point() # optional - sage.rings.finite_rings + sage: p3.rational_point() (1 : 0 : 0) - sage: _.closed_point() # optional - sage.rings.finite_rings + sage: _.closed_point() Point (y, z) - sage: _ == p3 # optional - sage.rings.finite_rings + sage: _ == p3 True AUTHORS: @@ -99,10 +99,11 @@ class IntegralCurveClosedPoint(CurveClosedPoint): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: C.closed_points() [Point (x, y), Point (x, y + 1), Point (x + a, y + a), @@ -118,12 +119,13 @@ def __init__(self, curve, prime_ideal, degree): TESTS:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: p = C([0,0]); p # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: p = C([0,0]); p (0, 0) - sage: loads(dumps(p)) == p # optional - sage.rings.finite_rings + sage: loads(dumps(p)) == p True """ super().__init__(curve.ambient_space(), prime_ideal) @@ -137,12 +139,13 @@ def __hash__(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: {p: 1} # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: {p: 1} {Point (x, y): 1} """ return hash((self.parent(), self.prime_ideal())) @@ -159,11 +162,12 @@ def _richcmp_(self, other, op): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: pts[0] == pts[1] # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: pts[0] == pts[1] False """ return richcmp((self._curve, self.prime_ideal()), (other._curve, other.prime_ideal()), op) @@ -174,11 +178,12 @@ def _repr_(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: pts[0] # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: pts[0] Point (x, y) """ return "Point ({})".format(', '.join(repr(g) for g in self.prime_ideal().gens())) @@ -189,12 +194,13 @@ def curve(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: p.curve() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: p.curve() Affine Plane Curve over Finite Field in a of size 2^2 defined by x^3 + y^2 + y """ return self._curve @@ -205,12 +211,13 @@ def degree(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: p.degree() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: p.degree() 1 """ return self._degree @@ -221,12 +228,13 @@ def places(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: p.places() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: p.places() [Place (x, y)] """ return self._curve.places_on(self) @@ -239,12 +247,13 @@ def place(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: p.place() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: p.place() Place (x, y) """ return self._curve.places_on(self)[0] @@ -260,9 +269,10 @@ def rational_point(self): EXAMPLES:: - sage: A. = AffineSpace(GF(3^2), 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^5 - x^4 - 2*x^3 - 2*x - 2) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: A. = AffineSpace(GF(3^2), 2) + sage: C = Curve(y^2 - x^5 - x^4 - 2*x^3 - 2*x - 2) + sage: C.closed_points() [Point (x, y + (z2 + 1)), Point (x, y + (-z2 - 1)), Point (x + (z2 + 1), y + (z2 - 1)), @@ -273,7 +283,7 @@ def rational_point(self): Point (x + (-z2 - 1), y + (-z2)), Point (x + 1, y + 1), Point (x + 1, y - 1)] - sage: [p.rational_point() for p in _] # optional - sage.rings.finite_rings + sage: [p.rational_point() for p in _] [(0, 2*z2 + 2), (0, z2 + 1), (2*z2 + 2, 2*z2 + 1), @@ -284,7 +294,7 @@ def rational_point(self): (z2 + 1, z2), (2, 2), (2, 1)] - sage: set(_) == set(C.rational_points()) # optional - sage.rings.finite_rings + sage: set(_) == set(C.rational_points()) True """ if self.degree() != 1: @@ -305,21 +315,21 @@ def projective(self, i=0): EXAMPLES:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: A. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3, A) # optional - sage.rings.finite_rings - sage: p1, p2 = C.closed_points() # optional - sage.rings.finite_rings - sage: p1 # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: A. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3, A) + sage: p1, p2 = C.closed_points() + sage: p1 Point (x, y) - sage: p2 # optional - sage.rings.finite_rings + sage: p2 Point (x, y + 1) - sage: p1.projective() # optional - sage.rings.finite_rings + sage: p1.projective() Point (x1, x2) - sage: p2.projective(0) # optional - sage.rings.finite_rings + sage: p2.projective(0) Point (x1, x0 + x2) - sage: p2.projective(1) # optional - sage.rings.finite_rings + sage: p2.projective(1) Point (x0, x1 + x2) - sage: p2.projective(2) # optional - sage.rings.finite_rings + sage: p2.projective(2) Point (x0, x1 + x2) """ C = self.curve() @@ -349,18 +359,19 @@ def rational_point(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^3*y + y^3*z + x*z^3) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = ProjectiveSpace(F, 2) + sage: C = Curve(x^3*y + y^3*z + x*z^3) + sage: C.closed_points() [Point (x, z), Point (x, y), Point (y, z), Point (x + a*z, y + (a + 1)*z), Point (x + (a + 1)*z, y + a*z)] - sage: [p.rational_point() for p in _] # optional - sage.rings.finite_rings + sage: [p.rational_point() for p in _] [(0 : 1 : 0), (0 : 0 : 1), (1 : 0 : 0), (a : a + 1 : 1), (a + 1 : a : 1)] - sage: set(_) == set(C.rational_points()) # optional - sage.rings.finite_rings + sage: set(_) == set(C.rational_points()) True """ if self.degree() != 1: @@ -385,19 +396,19 @@ def affine(self, i=None): EXAMPLES:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^3*y + y^3*z + x*z^3) # optional - sage.rings.finite_rings - sage: p1, p2, p3 = C.closed_points() # optional - sage.rings.finite_rings - sage: p1.affine() # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: P. = ProjectiveSpace(F, 2) + sage: C = Curve(x^3*y + y^3*z + x*z^3) + sage: p1, p2, p3 = C.closed_points() + sage: p1.affine() Point (x, z) - sage: p2.affine() # optional - sage.rings.finite_rings + sage: p2.affine() Point (x, y) - sage: p3.affine() # optional - sage.rings.finite_rings + sage: p3.affine() Point (y, z) - sage: p3.affine(0) # optional - sage.rings.finite_rings + sage: p3.affine(0) Point (y, z) - sage: p3.affine(1) # optional - sage.rings.finite_rings + sage: p3.affine(1) Traceback (most recent call last): ... ValueError: not in the affine patch diff --git a/src/sage/schemes/curves/constructor.py b/src/sage/schemes/curves/constructor.py index cb77c914047..6fe15a2efc2 100644 --- a/src/sage/schemes/curves/constructor.py +++ b/src/sage/schemes/curves/constructor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.singular """ Curve constructor @@ -12,8 +13,8 @@ :: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: Curve(y^2*z^7 - x^9 - x*z^8) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: Curve(y^2*z^7 - x^9 - x*z^8) Projective Plane Curve over Finite Field of size 5 defined by -x^9 + y^2*z^7 - x*z^8 @@ -126,10 +127,10 @@ def Curve(F, A=None): Affine plane curves. :: - sage: x,y = GF(7)['x,y'].gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + x^3 + x^10); C # optional - sage.rings.finite_rings + sage: x,y = GF(7)['x,y'].gens() + sage: C = Curve(y^2 + x^3 + x^10); C Affine Plane Curve over Finite Field of size 7 defined by x^10 + x^3 + y^2 - sage: C.genus() # optional - sage.rings.finite_rings + sage: C.genus() 0 sage: x, y = QQ['x,y'].gens() sage: Curve(x^3 + y^3 + 1) @@ -207,11 +208,11 @@ def Curve(F, A=None): The defining polynomial must be nonzero unless the ambient space itself is of dimension 1. :: - sage: P1. = ProjectiveSpace(1, GF(5)) # optional - sage.rings.finite_rings - sage: S = P1.coordinate_ring() # optional - sage.rings.finite_rings - sage: Curve(S(0), P1) # optional - sage.rings.finite_rings + sage: P1. = ProjectiveSpace(1, GF(5)) + sage: S = P1.coordinate_ring() + sage: Curve(S(0), P1) Projective Line over Finite Field of size 5 - sage: Curve(P1) # optional - sage.rings.finite_rings + sage: Curve(P1) Projective Line over Finite Field of size 5 :: diff --git a/src/sage/schemes/curves/curve.py b/src/sage/schemes/curves/curve.py index eaab8e97067..0af6fff803b 100644 --- a/src/sage/schemes/curves/curve.py +++ b/src/sage/schemes/curves/curve.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.singular """ Base class of curves @@ -216,29 +217,29 @@ def geometric_genus(self): Examples of projective curves. :: - sage: P2 = ProjectiveSpace(2, GF(5), names=['x','y','z']) # optional - sage.rings.finite_rings - sage: x, y, z = P2.coordinate_ring().gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: P2 = ProjectiveSpace(2, GF(5), names=['x','y','z']) + sage: x, y, z = P2.coordinate_ring().gens() + sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2) + sage: C.geometric_genus() 1 - sage: C = Curve(y^2*z - x^3) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: C = Curve(y^2*z - x^3) + sage: C.geometric_genus() 0 - sage: C = Curve(x^10 + y^7*z^3 + z^10) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: C = Curve(x^10 + y^7*z^3 + z^10) + sage: C.geometric_genus() 3 Examples of affine curves. :: - sage: x, y = PolynomialRing(GF(5), 2, 'xy').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^3 - 17*x + y) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: x, y = PolynomialRing(GF(5), 2, 'xy').gens() + sage: C = Curve(y^2 - x^3 - 17*x + y) + sage: C.geometric_genus() 1 - sage: C = Curve(y^2 - x^3) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: C = Curve(y^2 - x^3) + sage: C.geometric_genus() 0 - sage: C = Curve(x^10 + y^7 + 1) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: C = Curve(x^10 + y^7 + 1) + sage: C.geometric_genus() 3 """ @@ -323,13 +324,14 @@ def singular_points(self, F=None): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^8 - a^4 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 2) # optional - sage.rings.number_field - sage: C = Curve([359/12*x*y^2*z^2 + 2*y*z^4 + 187/12*y^3*z^2 + x*z^4 # optional - sage.rings.number_field + sage: K. = NumberField(a^8 - a^4 + 1) + sage: P. = ProjectiveSpace(QQ, 2) + sage: C = Curve([359/12*x*y^2*z^2 + 2*y*z^4 + 187/12*y^3*z^2 + x*z^4 ....: + 67/3*x^2*y*z^2 + 117/4*y^5 + 9*x^5 + 6*x^3*z^2 ....: + 393/4*x*y^4 + 145*x^2*y^3 + 115*x^3*y^2 + 49*x^4*y], P) - sage: sorted(C.singular_points(K), key=str) # optional - sage.rings.number_field + sage: sorted(C.singular_points(K), key=str) [(-1/2*b^5 - 1/2*b^3 + 1/2*b - 1 : 1 : 0), (-2/3*b^4 + 1/3 : 0 : 1), (-b^6 : b^6 : 1), @@ -373,10 +375,10 @@ def is_singular(self, P=None): :: - sage: A. = AffineSpace(GF(11), 3) # optional - sage.rings.finite_rings - sage: C = A.curve([y^3 - z^5, x^5 - y + 1]) # optional - sage.rings.finite_rings - sage: Q = A([7,0,0]) # optional - sage.rings.finite_rings - sage: C.is_singular(Q) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(11), 3) + sage: C = A.curve([y^3 - z^5, x^5 - y + 1]) + sage: Q = A([7,0,0]) + sage: C.is_singular(Q) True """ return not self.is_smooth(P) @@ -406,14 +408,14 @@ def intersects_at(self, C, P): :: - sage: A. = AffineSpace(GF(13), 2) # optional - sage.rings.finite_rings - sage: C = Curve([y + 12*x^5 + 3*x^3 + 7], A) # optional - sage.rings.finite_rings - sage: D = Curve([y^2 + 7*x^2 + 8], A) # optional - sage.rings.finite_rings - sage: Q1 = A([9,6]) # optional - sage.rings.finite_rings - sage: C.intersects_at(D, Q1) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(13), 2) + sage: C = Curve([y + 12*x^5 + 3*x^3 + 7], A) + sage: D = Curve([y^2 + 7*x^2 + 8], A) + sage: Q1 = A([9,6]) + sage: C.intersects_at(D, Q1) True - sage: Q2 = A([3,7]) # optional - sage.rings.finite_rings - sage: C.intersects_at(D, Q2) # optional - sage.rings.finite_rings + sage: Q2 = A([3,7]) + sage: C.intersects_at(D, Q2) False """ if C.ambient_space() != self.ambient_space(): @@ -451,21 +453,22 @@ def intersection_points(self, C, F=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^2 + a + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 3) # optional - sage.rings.number_field - sage: C = Curve([y^2 - w*z, w^3 - y^3], P) # optional - sage.rings.number_field - sage: D = Curve([x*y - w*z, z^3 - y^3], P) # optional - sage.rings.number_field - sage: C.intersection_points(D, F=K) # optional - sage.rings.number_field + sage: K. = NumberField(a^2 + a + 1) + sage: P. = ProjectiveSpace(QQ, 3) + sage: C = Curve([y^2 - w*z, w^3 - y^3], P) + sage: D = Curve([x*y - w*z, z^3 - y^3], P) + sage: C.intersection_points(D, F=K) [(-b - 1 : -b - 1 : b : 1), (b : b : -b - 1 : 1), (1 : 0 : 0 : 0), (1 : 1 : 1 : 1)] :: - sage: A. = AffineSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: C = Curve([y^3 - x^3], A) # optional - sage.rings.finite_rings - sage: D = Curve([-x*y^3 + y^4 - 2*x^3 + 2*x^2*y], A) # optional - sage.rings.finite_rings - sage: C.intersection_points(D) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(7), 2) + sage: C = Curve([y^3 - x^3], A) + sage: D = Curve([-x*y^3 + y^4 - 2*x^3 + 2*x^2*y], A) + sage: C.intersection_points(D) [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 3), (5, 5), (5, 6), (6, 6)] :: @@ -506,19 +509,20 @@ def change_ring(self, R): sage: P. = ProjectiveSpace(QQ, 3) sage: C = Curve([x^2 - y^2, z*y - 4/5*w^2], P) - sage: C.change_ring(QuadraticField(-1)) # optional - sage.rings.number_field + sage: C.change_ring(QuadraticField(-1)) # needs sage.rings.number_field Projective Curve over Number Field in a with defining polynomial x^2 + 1 with a = 1*I defined by x^2 - y^2, y*z - 4/5*w^2 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^3 + a^2 - 1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: C = Curve([K.0*x^2 - x + y^3 - 11], A) # optional - sage.rings.number_field - sage: L = K.embeddings(QQbar) # optional - sage.rings.number_field + sage: K. = NumberField(a^3 + a^2 - 1) + sage: A. = AffineSpace(K, 2) + sage: C = Curve([K.0*x^2 - x + y^3 - 11], A) + sage: L = K.embeddings(QQbar) sage: set_verbose(-1) # suppress warnings for slow computation - sage: C.change_ring(L[0]) # optional - sage.rings.number_field + sage: C.change_ring(L[0]) Affine Plane Curve over Algebraic Field defined by y^3 + (-0.8774388331233464? - 0.744861766619745?*I)*x^2 - x - 11 @@ -526,7 +530,7 @@ def change_ring(self, R): sage: P. = ProjectiveSpace(QQ, 2) sage: C = P.curve([y*x - 18*x^2 + 17*z^2]) - sage: C.change_ring(GF(17)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(17)) Projective Plane Curve over Finite Field of size 17 defined by -x^2 + x*y """ new_AS = self.ambient_space().change_ring(R) diff --git a/src/sage/schemes/curves/point.py b/src/sage/schemes/curves/point.py index 0bfaeae3139..dcc78724497 100644 --- a/src/sage/schemes/curves/point.py +++ b/src/sage/schemes/curves/point.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.singular """ Rational points of curves @@ -12,10 +13,10 @@ or on affine curves:: - sage: A. = AffineSpace(GF(23), 2) # optional - sage.rings.finite_rings - sage: C = Curve([y - y^4 + 17*x^2 - 2*x + 22], A) # optional - sage.rings.finite_rings - sage: Q = C([22,21]) # optional - sage.rings.finite_rings - sage: Q.parent() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(23), 2) + sage: C = Curve([y - y^4 + 17*x^2 - 2*x + 22], A) + sage: Q = C([22,21]) + sage: Q.parent() Set of rational points of Affine Plane Curve over Finite Field of size 23 defined by -y^4 - 6*x^2 - 2*x + y - 1 @@ -71,10 +72,10 @@ def multiplicity(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([y^3*z - 16*x^4], P) # optional - sage.rings.finite_rings - sage: Q = C([0,0,1]) # optional - sage.rings.finite_rings - sage: Q.multiplicity() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([y^3*z - 16*x^4], P) + sage: Q = C([0,0,1]) + sage: Q.multiplicity() 3 """ return self.codomain().multiplicity(self) @@ -113,15 +114,16 @@ def is_ordinary_singularity(self): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^2 - 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: C = P.curve([x^2*y^3*z^4 - y^6*z^3 - 4*x^2*y^4*z^3 - # optional - sage.rings.number_field + sage: K. = NumberField(a^2 - 3) + sage: P. = ProjectiveSpace(K, 2) + sage: C = P.curve([x^2*y^3*z^4 - y^6*z^3 - 4*x^2*y^4*z^3 - ....: 4*x^4*y^2*z^3 + 3*y^7*z^2 + 10*x^2*y^5*z^2 + 9*x^4*y^3*z^2 + ....: 5*x^6*y*z^2 - 3*y^8*z - 9*x^2*y^6*z - 11*x^4*y^4*z - 7*x^6*y^2*z - ....: 2*x^8*z + y^9 + 2*x^2*y^7 + 3*x^4*y^5 + 4*x^6*y^3 + 2*x^8*y]) - sage: Q = C([-1/2, 1/2, 1]) # optional - sage.rings.number_field - sage: Q.is_ordinary_singularity() # optional - sage.rings.number_field + sage: Q = C([-1/2, 1/2, 1]) + sage: Q.is_ordinary_singularity() True """ return self.codomain().is_ordinary_singularity(self) @@ -146,11 +148,11 @@ def is_transverse(self, D): :: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - 16*y^3*z], P) # optional - sage.rings.finite_rings - sage: D = Curve([y^2 - z*x], P) # optional - sage.rings.finite_rings - sage: Q = C([0,0,1]) # optional - sage.rings.finite_rings - sage: Q.is_transverse(D) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([x^4 - 16*y^3*z], P) + sage: D = Curve([y^2 - z*x], P) + sage: Q = C([0,0,1]) + sage: Q.is_transverse(D) False """ return self.codomain().is_transverse(D, self) @@ -171,12 +173,12 @@ def closed_point(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - 16*y^3*z], P) # optional - sage.rings.finite_rings - sage: C.singular_points() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([x^4 - 16*y^3*z], P) + sage: C.singular_points() [(0 : 0 : 1)] - sage: p = _[0] # optional - sage.rings.finite_rings - sage: p.closed_point() # optional - sage.rings.finite_rings + sage: p = _[0] + sage: p.closed_point() Point (x, y) """ curve = self.codomain() @@ -199,12 +201,12 @@ def places(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - 16*y^3*z], P) # optional - sage.rings.finite_rings - sage: C.singular_points() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([x^4 - 16*y^3*z], P) + sage: C.singular_points() [(0 : 0 : 1)] - sage: p = _[0] # optional - sage.rings.finite_rings - sage: p.places() # optional - sage.rings.finite_rings + sage: p = _[0] + sage: p.places() [Place (y)] """ return self.closed_point().places() @@ -215,12 +217,12 @@ def place(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - 16*y^3*z], P) # optional - sage.rings.finite_rings - sage: C.singular_points() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([x^4 - 16*y^3*z], P) + sage: C.singular_points() [(0 : 0 : 1)] - sage: p = _[0] # optional - sage.rings.finite_rings - sage: p.place() # optional - sage.rings.finite_rings + sage: p = _[0] + sage: p.place() Place (y) """ return self.closed_point().place() @@ -255,14 +257,15 @@ def is_singular(self): EXAMPLES:: - sage: K = QuadraticField(-1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 3) # optional - sage.rings.number_field - sage: C = Curve([(x^4 + 2*z + 2)*y, z - y + 1]) # optional - sage.rings.number_field - sage: Q1 = C([0,0,-1]) # optional - sage.rings.number_field - sage: Q1.is_singular() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(-1) + sage: A. = AffineSpace(K, 3) + sage: C = Curve([(x^4 + 2*z + 2)*y, z - y + 1]) + sage: Q1 = C([0,0,-1]) + sage: Q1.is_singular() True - sage: Q2 = C([-K.gen(),0,-1]) # optional - sage.rings.number_field - sage: Q2.is_singular() # optional - sage.rings.number_field + sage: Q2 = C([-K.gen(),0,-1]) + sage: Q2.is_singular() False """ return self.codomain().is_singular(self) @@ -326,10 +329,10 @@ def is_ordinary_singularity(self): :: - sage: A. = AffineSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: C = A.curve([y^2 - x^7 - 6*x^3]) # optional - sage.rings.finite_rings - sage: Q = C([0,0]) # optional - sage.rings.finite_rings - sage: Q.is_ordinary_singularity() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(7), 2) + sage: C = A.curve([y^2 - x^7 - 6*x^3]) + sage: Q = C([0,0]) + sage: Q.is_ordinary_singularity() False """ return self.codomain().is_ordinary_singularity(self) @@ -354,13 +357,14 @@ def is_transverse(self, D): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^2 - 2) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: C = Curve([y^2 + x^2 - 1], A) # optional - sage.rings.number_field - sage: D = Curve([y - x], A) # optional - sage.rings.number_field - sage: Q = C([-1/2*b, -1/2*b]) # optional - sage.rings.number_field - sage: Q.is_transverse(D) # optional - sage.rings.number_field + sage: K. = NumberField(a^2 - 2) + sage: A. = AffineSpace(K, 2) + sage: C = Curve([y^2 + x^2 - 1], A) + sage: D = Curve([y - x], A) + sage: Q = C([-1/2*b, -1/2*b]) + sage: Q.is_transverse(D) True """ return self.codomain().is_transverse(D, self) @@ -383,10 +387,11 @@ def closed_point(self): EXAMPLES:: - sage: A. = AffineSpace(GF(8), 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^5 + y^5 + x*y + 1) # optional - sage.rings.finite_rings - sage: p = C([1,1]) # optional - sage.rings.finite_rings - sage: p.closed_point() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: A. = AffineSpace(GF(8), 2) + sage: C = Curve(x^5 + y^5 + x*y + 1) + sage: p = C([1,1]) + sage: p.closed_point() Point (x + 1, y + 1) """ curve = self.codomain() @@ -402,14 +407,14 @@ def places(self): EXAMPLES:: - sage: A. = AffineSpace(GF(2), 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^5 + y^5 + x*y + 1) # optional - sage.rings.finite_rings - sage: p = C(-1,-1) # optional - sage.rings.finite_rings - sage: p # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(2), 2) + sage: C = Curve(x^5 + y^5 + x*y + 1) + sage: p = C(-1,-1) + sage: p (1, 1) - sage: p.closed_point() # optional - sage.rings.finite_rings + sage: p.closed_point() Point (x + 1, y + 1) - sage: _.places() # optional - sage.rings.finite_rings + sage: _.places() [Place (x + 1, (1/(x^5 + 1))*y^4 + ((x^5 + x^4 + 1)/(x^5 + 1))*y^3 + ((x^5 + x^3 + 1)/(x^5 + 1))*y^2 + (x^2/(x^5 + 1))*y), Place (x + 1, (1/(x^5 + 1))*y^4 + ((x^5 + x^4 + 1)/(x^5 + 1))*y^3 @@ -423,14 +428,14 @@ def place(self): EXAMPLES:: - sage: A. = AffineSpace(GF(2), 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^5 + y^5 + x*y + 1) # optional - sage.rings.finite_rings - sage: p = C(-1,-1) # optional - sage.rings.finite_rings - sage: p # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(2), 2) + sage: C = Curve(x^5 + y^5 + x*y + 1) + sage: p = C(-1,-1) + sage: p (1, 1) - sage: p.closed_point() # optional - sage.rings.finite_rings + sage: p.closed_point() Point (x + 1, y + 1) - sage: _.place() # optional - sage.rings.finite_rings + sage: _.place() Place (x + 1, (1/(x^5 + 1))*y^4 + ((x^5 + x^4 + 1)/(x^5 + 1))*y^3 + ((x^5 + x^3 + 1)/(x^5 + 1))*y^2 + (x^2/(x^5 + 1))*y) """ diff --git a/src/sage/schemes/cyclic_covers/charpoly_frobenius.py b/src/sage/schemes/cyclic_covers/charpoly_frobenius.py index fc5cc3b1c3e..e28289e1d84 100644 --- a/src/sage/schemes/cyclic_covers/charpoly_frobenius.py +++ b/src/sage/schemes/cyclic_covers/charpoly_frobenius.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics r""" Computation of the Frobenius polynomial using Newton's identities """ diff --git a/src/sage/schemes/cyclic_covers/constructor.py b/src/sage/schemes/cyclic_covers/constructor.py index d2975336301..99250257121 100644 --- a/src/sage/schemes/cyclic_covers/constructor.py +++ b/src/sage/schemes/cyclic_covers/constructor.py @@ -64,11 +64,11 @@ def CyclicCover(r, f, names=None, check_smooth=True): sage: CyclicCover(15, x^9 + x + 1) Cyclic Cover of P^1 over Rational Field defined by y^15 = x^9 + x + 1 - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: CyclicCover(5, x^9 + x + 1) # optional - sage.rings.finite_rings + sage: k. = GF(9); R. = k[] # needs sage.rings.finite_rings + sage: CyclicCover(5, x^9 + x + 1) # needs sage.rings.finite_rings Cyclic Cover of P^1 over Finite Field in a of size 3^2 defined by y^5 = x^9 + x + 1 - sage: CyclicCover(15, x^9 + x + 1) # optional - sage.rings.finite_rings + sage: CyclicCover(15, x^9 + x + 1) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: As the characteristic divides the order of the cover, @@ -76,20 +76,20 @@ def CyclicCover(r, f, names=None, check_smooth=True): We can change the names of the variables in the output:: - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: CyclicCover(5, x^9 + x + 1, names=["A","B"]) # optional - sage.rings.finite_rings + sage: k. = GF(9); R. = k[] # needs sage.rings.finite_rings + sage: CyclicCover(5, x^9 + x + 1, names=["A","B"]) # needs sage.rings.finite_rings Cyclic Cover of P^1 over Finite Field in a of size 3^2 defined by B^5 = A^9 + A + 1 Double roots:: - sage: P. = GF(7)[] # optional - sage.rings.finite_rings - sage: CyclicCover(2, (x^3-x+2)^2*(x^6-1)) # optional - sage.rings.finite_rings + sage: P. = GF(7)[] + sage: CyclicCover(2, (x^3-x+2)^2*(x^6-1)) Traceback (most recent call last): ... ValueError: Not a smooth Cyclic Cover of P^1: singularity in the provided affine patch. - sage: CyclicCover(2, (x^3-x+2)^2*(x^6-1), check_smooth=False) # optional - sage.rings.finite_rings + sage: CyclicCover(2, (x^3-x+2)^2*(x^6-1), check_smooth=False) # needs sage.rings.finite_rings Cyclic Cover of P^1 over Finite Field of size 7 defined by y^2 = x^12 - 2*x^10 - 3*x^9 + x^8 + 3*x^7 + 3*x^6 + 2*x^4 + 3*x^3 - x^2 - 3*x + 3 diff --git a/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py b/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py index a3104af8175..82583c14cfc 100644 --- a/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py +++ b/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Cyclic covers over a finite field diff --git a/src/sage/schemes/cyclic_covers/cycliccover_generic.py b/src/sage/schemes/cyclic_covers/cycliccover_generic.py index ec852541ad3..9bca8814dad 100644 --- a/src/sage/schemes/cyclic_covers/cycliccover_generic.py +++ b/src/sage/schemes/cyclic_covers/cycliccover_generic.py @@ -12,18 +12,18 @@ Projective Plane Curve over Integer Ring defined by x0^5 + x0^4*x1 + x1^5 - x2^5 sage: D.change_ring(QQ).genus() 6 - sage: C.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(5)) Traceback (most recent call last): ... ValueError: As the characteristic divides the order of the cover, this model is not smooth. - sage: GF7x. = GF(7)[] # optional - sage.rings.finite_rings - sage: C = CyclicCover(3, x^9 + x + 1) # optional - sage.rings.finite_rings - sage: C # optional - sage.rings.finite_rings + sage: GF7x. = GF(7)[] + sage: C = CyclicCover(3, x^9 + x + 1) + sage: C Cyclic Cover of P^1 over Finite Field of size 7 defined by y^3 = x^9 + x + 1 - sage: C.genus() # optional - sage.rings.finite_rings + sage: C.genus() 7 - sage: C.projective_closure() # optional - sage.rings.finite_rings + sage: C.projective_closure() Traceback (most recent call last): ... NotImplementedError: Weighted Projective Space is not implemented @@ -71,20 +71,20 @@ def __init__(self, AA, r, f, names=None): Projective Plane Curve over Integer Ring defined by x0^5 + x0^4*x1 + x1^5 - x2^5 sage: D.change_ring(QQ).genus() 6 - sage: C.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(5)) Traceback (most recent call last): ... ValueError: As the characteristic divides the order of the cover, this model is not smooth. - sage: GF7x. = GF(7)[] # optional - sage.rings.finite_rings - sage: C = CyclicCover(3, x^9 + x + 1) # optional - sage.rings.finite_rings - sage: C # optional - sage.rings.finite_rings + sage: GF7x. = GF(7)[] + sage: C = CyclicCover(3, x^9 + x + 1) + sage: C Cyclic Cover of P^1 over Finite Field of size 7 defined by y^3 = x^9 + x + 1 - sage: C.genus() # optional - sage.rings.finite_rings + sage: C.genus() 7 - sage: C.projective_closure() # optional - sage.rings.finite_rings + sage: C.projective_closure() Traceback (most recent call last): ... NotImplementedError: Weighted Projective Space is not implemented @@ -115,17 +115,17 @@ def change_ring(self, R): sage: ZZx. = ZZ[] sage: C = CyclicCover(5, x^5 + x + 1) - sage: C.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(5)) Traceback (most recent call last): ... ValueError: As the characteristic divides the order of the cover, this model is not smooth. - sage: C.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(3)) Traceback (most recent call last): ... ValueError: Not a smooth Cyclic Cover of P^1: singularity in the provided affine patch. - sage: C.change_ring(GF(17)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(17)) Cyclic Cover of P^1 over Finite Field of size 17 defined by y^5 = x^5 + x + 1 """ from .constructor import CyclicCover @@ -241,8 +241,8 @@ def projective_closure(self, **kwds): EXAMPLES:: - sage: GF7x. = GF(7)[] # optional - sage.rings.finite_rings - sage: CyclicCover(3, x^9 + x + 1).projective_closure() # optional - sage.rings.finite_rings + sage: GF7x. = GF(7)[] + sage: CyclicCover(3, x^9 + x + 1).projective_closure() Traceback (most recent call last): ... NotImplementedError: Weighted Projective Space is not implemented diff --git a/src/sage/schemes/elliptic_curves/Qcurves.py b/src/sage/schemes/elliptic_curves/Qcurves.py index df577822cc2..45fb5c51293 100644 --- a/src/sage/schemes/elliptic_curves/Qcurves.py +++ b/src/sage/schemes/elliptic_curves/Qcurves.py @@ -130,10 +130,10 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): sage: from sage.schemes.elliptic_curves.Qcurves import is_Q_curve sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(R([3, 0, -5, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([-3,-4,1,1]), K([4,-1,-1,0]), K([-2,0,1,0]), # optional - sage.rings.number_field + sage: K. = NumberField(R([3, 0, -5, 0, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([-3,-4,1,1]), K([4,-1,-1,0]), K([-2,0,1,0]), # needs sage.rings.number_field ....: K([-621,778,138,-178]), K([9509,2046,-24728,10380])]) - sage: is_Q_curve(E, certificate=True, verbose=True) # optional - sage.rings.number_field + sage: is_Q_curve(E, certificate=True, verbose=True) # needs sage.rings.number_field Checking whether Elliptic Curve defined by y^2 + (a^3+a^2-4*a-3)*x*y + (a^2-2)*y = x^3 + (-a^2-a+4)*x^2 + (-178*a^3+138*a^2+778*a-621)*x + (10380*a^3-24728*a^2+2046*a+9509) over Number Field in a with defining polynomial x^4 - 5*x^2 + 3 is a Q-curve No: inconsistency at the 2 primes dividing 3 - potentially multiplicative: [True, False] @@ -143,10 +143,10 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): primes is consistent, but the local test at good primes above `13` is not:: - sage: K. = NumberField(R([-10, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([0,1]), K([-1,-1]), K([0,0]), # optional - sage.rings.number_field + sage: K. = NumberField(R([-10, 0, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([0,1]), K([-1,-1]), K([0,0]), # needs sage.rings.number_field ....: K([-236,40]), K([-1840,464])]) - sage: is_Q_curve(E, certificate=True, verbose=True) # optional - sage.rings.number_field + sage: is_Q_curve(E, certificate=True, verbose=True) # needs sage.rings.number_field Checking whether Elliptic Curve defined by y^2 + a*x*y = x^3 + (-a-1)*x^2 + (40*a-236)*x + (464*a-1840) over Number Field in a with defining polynomial x^2 - 10 is a Q-curve Applying local tests at good primes above p<=100 No: inconsistency at the 2 ordinary primes dividing 13 @@ -158,9 +158,9 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): sage: from sage.schemes.elliptic_curves.Qcurves import is_Q_curve sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(R([-1, -1, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([1,0]), K([-1,0]), K([0,1]), K([0,-2]), K([0,1])]) - sage: is_Q_curve(E, certificate=True, verbose=True) # optional - sage.rings.number_field + sage: K. = NumberField(R([-1, -1, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([1,0]), K([-1,0]), K([0,1]), K([0,-2]), K([0,1])]) # needs sage.rings.number_field + sage: is_Q_curve(E, certificate=True, verbose=True) # needs sage.rings.number_field Checking whether Elliptic Curve defined by y^2 + x*y + a*y = x^3 + (-1)*x^2 + (-2*a)*x + a over Number Field in a with defining polynomial x^2 - x - 1 is a Q-curve Yes: E is CM (discriminant -15) (True, {'CM': -15}) @@ -170,14 +170,15 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): in fact there is an isogenous curve with rational `j`, so we have a so-called rational `\QQ`-curve:: - sage: K. = NumberField(R([1, 0, -4, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([-2,-4,1,1]), K([0,1,0,0]), K([0,1,0,0]), # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(R([1, 0, -4, 0, 1])) + sage: E = EllipticCurve([K([-2,-4,1,1]), K([0,1,0,0]), K([0,1,0,0]), ....: K([-4780,9170,1265,-2463]), ....: K([163923,-316598,-43876,84852])]) - sage: flag, cert = is_Q_curve(E, certificate=True) # optional - sage.rings.number_field - sage: flag # optional - sage.rings.number_field + sage: flag, cert = is_Q_curve(E, certificate=True) + sage: flag True - sage: cert # optional - sage.rings.number_field + sage: cert {'CM': 0, 'N': 1, 'core_degs': [1], 'core_poly': x - 85184/3, 'r': 0, 'rho': 0} Over the same field, a so-called strict `\QQ`-curve which is not @@ -187,12 +188,13 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): quadratic conjugate `j`-invariants in `\QQ(\sqrt{3})` (but which are not base-changes from the quadratic subfield):: - sage: E = EllipticCurve([K([0,-3,0,1]), K([1,4,0,-1]), K([0,0,0,0]), # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve([K([0,-3,0,1]), K([1,4,0,-1]), K([0,0,0,0]), ....: K([-2,-16,0,4]), K([-19,-32,4,8])]) - sage: flag, cert = is_Q_curve(E, certificate=True) # optional - sage.rings.number_field - sage: flag # optional - sage.rings.number_field + sage: flag, cert = is_Q_curve(E, certificate=True) + sage: flag True - sage: cert # optional - sage.rings.number_field + sage: cert {'CM': 0, 'N': 2, 'core_degs': [1, 2], @@ -202,8 +204,8 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): TESTS:: - sage: E = EllipticCurve([GF(5)(t) for t in [2,3,5,7,11]]) # optional - sage.rings.finite_rings - sage: is_Q_curve(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(5)(t) for t in [2,3,5,7,11]]) + sage: is_Q_curve(E) Traceback (most recent call last): ... TypeError: Elliptic Curve defined by ... must be an elliptic curve @@ -431,10 +433,10 @@ def Step4Test(E, B, oldB=0, verbose=False): sage: from sage.schemes.elliptic_curves.Qcurves import Step4Test sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(R([3, 0, -5, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([-3,-4,1,1]), K([4,-1,-1,0]), K([-2,0,1,0]), # optional - sage.rings.number_field + sage: K. = NumberField(R([3, 0, -5, 0, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([-3,-4,1,1]), K([4,-1,-1,0]), K([-2,0,1,0]), # needs sage.rings.number_field ....: K([-621,778,138,-178]), K([9509,2046,-24728,10380])]) - sage: Step4Test(E, 100, verbose=True) # optional - sage.rings.number_field + sage: Step4Test(E, 100, verbose=True) # needs sage.rings.number_field No: inconsistency at the 2 ordinary primes dividing 13 - Frobenius discriminants mod squares: [-3, -1] (False, 13) @@ -444,11 +446,11 @@ def Step4Test(E, B, oldB=0, verbose=False): sage: from sage.schemes.elliptic_curves.Qcurves import Step4Test sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(R([-3, 0, 9, 0, -6, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([1,-3,0,1,0,0]), K([5,-3,-6,1,1,0]), + sage: K. = NumberField(R([-3, 0, 9, 0, -6, 0, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([1,-3,0,1,0,0]), K([5,-3,-6,1,1,0]), # needs sage.rings.number_field ....: K([1,-3,0,1,0,0]), K([-139,-129,331,277,-76,-63]), ....: K([2466,1898,-5916,-4582,1361,1055])]) - sage: Step4Test(E, 100, verbose=True) + sage: Step4Test(E, 100, verbose=True) # needs sage.rings.number_field (True, 0) """ from sage.arith.misc import primes @@ -506,32 +508,33 @@ def conjugacy_test(jlist, verbose=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.Qcurves import conjugacy_test sage: conjugacy_test([3]) [x - 3] - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: conjugacy_test([K(3), a]) # optional - sage.rings.number_field + sage: K. = QuadraticField(2) + sage: conjugacy_test([K(3), a]) [x - 3] - sage: conjugacy_test([K(3), 3 + a]) # optional - sage.rings.number_field + sage: conjugacy_test([K(3), 3 + a]) [x - 3] - sage: conjugacy_test([3 + a]) # optional - sage.rings.number_field + sage: conjugacy_test([3 + a]) [] - sage: conjugacy_test([3 + a, 3 - a]) # optional - sage.rings.number_field + sage: conjugacy_test([3 + a, 3 - a]) [x^2 - 6*x + 7] - sage: x = polygen(QQ) # optional - sage.rings.number_field + sage: x = polygen(QQ) sage: f = x^3 - 3 - sage: K. = f.splitting_field() # optional - sage.rings.number_field - sage: js = f.roots(K, multiplicities=False) # optional - sage.rings.number_field - sage: conjugacy_test(js) # optional - sage.rings.number_field + sage: K. = f.splitting_field() + sage: js = f.roots(K, multiplicities=False) + sage: conjugacy_test(js) [] - sage: f = x^4 - 3 # optional - sage.rings.number_field - sage: K. = NumberField(f) # optional - sage.rings.number_field - sage: js = f.roots(K, multiplicities=False) # optional - sage.rings.number_field - sage: conjugacy_test(js) # optional - sage.rings.number_field + sage: f = x^4 - 3 + sage: K. = NumberField(f) + sage: js = f.roots(K, multiplicities=False) + sage: conjugacy_test(js) [] - sage: K. = f.splitting_field() # optional - sage.rings.number_field - sage: js = f.roots(K, multiplicities=False) # optional - sage.rings.number_field - sage: conjugacy_test(js) # optional - sage.rings.number_field + sage: K. = f.splitting_field() + sage: js = f.roots(K, multiplicities=False) + sage: conjugacy_test(js) [x^4 - 3] """ from sage.sets.set import Set diff --git a/src/sage/schemes/elliptic_curves/cardinality.py b/src/sage/schemes/elliptic_curves/cardinality.py index 2a73de71a50..d871355c20a 100644 --- a/src/sage/schemes/elliptic_curves/cardinality.py +++ b/src/sage/schemes/elliptic_curves/cardinality.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings """ Specific algorithms to compute cardinality of elliptic curves over a finite field diff --git a/src/sage/schemes/elliptic_curves/cm.py b/src/sage/schemes/elliptic_curves/cm.py index f70f20a69d7..09a6b63f402 100644 --- a/src/sage/schemes/elliptic_curves/cm.py +++ b/src/sage/schemes/elliptic_curves/cm.py @@ -82,6 +82,7 @@ def hilbert_class_polynomial(D, algorithm=None): EXAMPLES:: + sage: # needs sage.libs.flint sage: hilbert_class_polynomial(-4) x - 1728 sage: hilbert_class_polynomial(-7) @@ -204,8 +205,10 @@ def is_HCP(f, check_monic_irreducible=True): sage: from sage.schemes.elliptic_curves.cm import is_HCP sage: D = -1856563 - sage: D.class_number() + sage: D.class_number() # needs sage.libs.pari 100 + + sage: # needs sage.libs.flint sage: H = hilbert_class_polynomial(D) sage: H.degree() 100 @@ -216,16 +219,19 @@ def is_HCP(f, check_monic_irreducible=True): Testing polynomials which are not HCPs is faster:: - sage: is_HCP(H+1) + sage: is_HCP(H+1) # needs sage.libs.flint 0 TESTS:: + sage: # needs sage.libs.flint sage: from sage.schemes.elliptic_curves.cm import is_HCP - sage: all(is_HCP(hilbert_class_polynomial(D))==D for D in srange(-4,-100,-1) if D.is_discriminant()) + sage: all(is_HCP(hilbert_class_polynomial(D)) == D + ....: for D in srange(-4,-100,-1) if D.is_discriminant()) True - sage: all(not is_HCP(hilbert_class_polynomial(D)+1) for D in srange(-4,-100,-1) if D.is_discriminant()) + sage: all(not is_HCP(hilbert_class_polynomial(D) + 1) + ....: for D in srange(-4,-100,-1) if D.is_discriminant()) True """ zero = ZZ(0) @@ -300,6 +306,7 @@ def OrderClassNumber(D0,h0,f): EXAMPLES:: + sage: # needs sage.libs.pari sage: from sage.schemes.elliptic_curves.cm import OrderClassNumber sage: D0 = -4 sage: h = D0.class_number() @@ -350,25 +357,26 @@ def cm_j_invariants(K, proof=None): Over imaginary quadratic fields there are no more than over `QQ`:: - sage: cm_j_invariants(QuadraticField(-1, 'i')) # optional - sage.rings.number_field + sage: cm_j_invariants(QuadraticField(-1, 'i')) # needs sage.rings.number_field [-262537412640768000, -147197952000, -884736000, -12288000, -884736, -32768, -3375, 0, 1728, 8000, 54000, 287496, 16581375] Over real quadratic fields there may be more, for example:: - sage: len(cm_j_invariants(QuadraticField(5, 'a'))) # optional - sage.rings.number_field + sage: len(cm_j_invariants(QuadraticField(5, 'a'))) # needs sage.rings.number_field 31 Over number fields K of many higher degrees this also works:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: cm_j_invariants(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: cm_j_invariants(K) [-262537412640768000, -147197952000, -884736000, -884736, -32768, 8000, -3375, 16581375, 1728, 287496, 0, 54000, -12288000, 31710790944000*a^2 + 39953093016000*a + 50337742902000] - sage: K. = NumberField(x^4 - 2) # optional - sage.rings.number_field - sage: len(cm_j_invariants(K)) # optional - sage.rings.number_field + sage: K. = NumberField(x^4 - 2) + sage: len(cm_j_invariants(K)) 23 """ return sorted(j for D, f, j in cm_j_invariants_and_orders(K, proof=proof)) @@ -400,7 +408,7 @@ def cm_j_invariants_and_orders(K, proof=None): Over an imaginary quadratic field there are no more than over `QQ`:: - sage: cm_j_invariants_and_orders(QuadraticField(-1, 'i')) # optional - sage.rings.number_field + sage: cm_j_invariants_and_orders(QuadraticField(-1, 'i')) # needs sage.rings.number_field [(-163, 1, -262537412640768000), (-67, 1, -147197952000), (-43, 1, -884736000), (-19, 1, -884736), (-11, 1, -32768), (-8, 1, 8000), (-7, 1, -3375), (-7, 2, 16581375), (-4, 1, 1728), @@ -408,9 +416,9 @@ def cm_j_invariants_and_orders(K, proof=None): Over real quadratic fields there may be more:: - sage: v = cm_j_invariants_and_orders(QuadraticField(5,'a')); len(v) # optional - sage.rings.number_field + sage: v = cm_j_invariants_and_orders(QuadraticField(5,'a')); len(v) # needs sage.rings.number_field 31 - sage: [(D, f) for D, f, j in v if j not in QQ] # optional - sage.rings.number_field + sage: [(D, f) for D, f, j in v if j not in QQ] # needs sage.rings.number_field [(-235, 1), (-235, 1), (-115, 1), (-115, 1), (-40, 1), (-40, 1), (-35, 1), (-35, 1), (-20, 1), (-20, 1), (-15, 1), (-15, 1), (-15, 2), (-15, 2), (-4, 5), (-4, 5), (-3, 5), (-3, 5)] @@ -418,8 +426,8 @@ def cm_j_invariants_and_orders(K, proof=None): Over number fields K of many higher degrees this also works:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: cm_j_invariants_and_orders(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: cm_j_invariants_and_orders(K) # needs sage.rings.number_field [(-163, 1, -262537412640768000), (-67, 1, -147197952000), (-43, 1, -884736000), (-19, 1, -884736), (-11, 1, -32768), (-8, 1, 8000), (-7, 1, -3375), (-7, 2, 16581375), (-4, 1, 1728), @@ -479,6 +487,7 @@ def cm_orders(h, proof=None): (-11, 1), (-19, 1), (-43, 1), (-67, 1), (-163, 1)] sage: type(v[0][0]), type(v[0][1]) (<... 'sage.rings.integer.Integer'>, <... 'sage.rings.integer.Integer'>) + sage: # needs sage.libs.pari sage: v = cm_orders(2); v [(-3, 4), (-3, 5), (-3, 7), (-4, 3), (-4, 4), (-4, 5), (-7, 4), (-8, 2), (-8, 3), (-11, 3), (-15, 1), (-15, 2), (-20, 1), (-24, 1), (-35, 1), @@ -491,6 +500,7 @@ def cm_orders(h, proof=None): Any degree up to 100 is implemented, but may be slow:: + sage: # needs sage.libs.pari sage: cm_orders(3) [(-3, 6), (-3, 9), (-11, 2), (-19, 2), (-23, 1), (-23, 2), (-31, 1), (-31, 2), (-43, 2), (-59, 1), (-67, 2), (-83, 1), (-107, 1), (-139, 1), (-163, 2), @@ -525,6 +535,7 @@ def cm_orders(h, proof=None): # quadratic field with class number h, and n is the number of such # fields. These are all *unconditional* (not dependent on GRH). + watkins_table = {1: (163, 9), 2: (427, 18), 3: (907, 16), 4: (1555, 54), 5: (2683, 25), 6: (3763, 51), 7: (5923, 31), 8: (6307, 131), 9: (10627, 34), 10: (13843, 87), 11: (15667, 41), 12: (17803, 206), 13: (20563, 37), 14: @@ -707,6 +718,7 @@ class number `h` is also the largest discriminant, but this is not # initialise it with h=1 only; other values will be added by calls to # discriminants_with_bounded_class_number(). + hDf_dict = {ZZ(1): [(ZZ(D), ZZ(h)) for D,h in [(-3, 1), (-3, 2), (-3, 3), (-4, 1), (-4, 2), (-7, 1), (-7, 2), (-8, 1), (-11, 1), (-19, 1), (-43, 1), (-67, 1), (-163, 1)]]} @@ -738,6 +750,7 @@ def discriminants_with_bounded_class_number(hmax, B=None, proof=None): EXAMPLES:: + sage: # needs sage.libs.pari sage: from sage.schemes.elliptic_curves.cm import discriminants_with_bounded_class_number sage: v = discriminants_with_bounded_class_number(3) sage: sorted(v) @@ -920,23 +933,24 @@ def is_cm_j_invariant(j, algorithm='CremonaSutherland', method=None): sage: is_cm_j_invariant(8000) (True, (-8, 1)) - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: is_cm_j_invariant(282880*a + 632000) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: is_cm_j_invariant(282880*a + 632000) (True, (-20, 1)) sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: is_cm_j_invariant(31710790944000*a^2 + 39953093016000*a + 50337742902000) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: is_cm_j_invariant(31710790944000*a^2 + 39953093016000*a + 50337742902000) (True, (-3, 6)) An example of large degree. This is only possible using the default algorithm:: sage: from sage.schemes.elliptic_curves.cm import is_cm_j_invariant sage: D = -1856563 - sage: H = hilbert_class_polynomial(D) - sage: H.degree() + sage: H = hilbert_class_polynomial(D) # needs sage.libs.flint + sage: H.degree() # needs sage.libs.flint 100 - sage: K. = NumberField(H) - sage: is_cm_j_invariant(j) + sage: K. = NumberField(H) # needs sage.libs.flint sage.rings.number_field + sage: is_cm_j_invariant(j) # needs sage.libs.flint sage.rings.number_field (True, (-1856563, 1)) TESTS:: diff --git a/src/sage/schemes/elliptic_curves/constructor.py b/src/sage/schemes/elliptic_curves/constructor.py index ca210ca6e2b..e7a1767cecb 100644 --- a/src/sage/schemes/elliptic_curves/constructor.py +++ b/src/sage/schemes/elliptic_curves/constructor.py @@ -115,9 +115,9 @@ class EllipticCurveFactory(UniqueFactory): We create curves over a finite field as follows:: - sage: EllipticCurve([GF(5)(0),0,1,-1,0]) # optional - sage.rings.finite_rings + sage: EllipticCurve([GF(5)(0),0,1,-1,0]) Elliptic Curve defined by y^2 + y = x^3 + 4*x over Finite Field of size 5 - sage: EllipticCurve(GF(5), [0, 0,1,-1,0]) # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(5), [0, 0,1,-1,0]) Elliptic Curve defined by y^2 + y = x^3 + 4*x over Finite Field of size 5 Elliptic curves over `\ZZ/N\ZZ` with `N` prime are of type @@ -159,8 +159,8 @@ class EllipticCurveFactory(UniqueFactory): sage: EllipticCurve(y^2 + y - ( x^3 + x - 9 )) Elliptic Curve defined by y^2 + y = x^3 + x - 9 over Rational Field - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: EllipticCurve(x^3 + x^2 + 2 - y^2 - y*x) # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: EllipticCurve(x^3 + x^2 + 2 - y^2 - y*x) Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 2 over Finite Field of size 5 We can also create elliptic curves by giving a smooth plane cubic with a rational point:: @@ -178,13 +178,13 @@ class EllipticCurveFactory(UniqueFactory): 1728 '32a2' - sage: E = EllipticCurve(j=GF(5)(2)); E; E.j_invariant() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(5)(2)); E; E.j_invariant() Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 2 See :trac:`6657` :: - sage: EllipticCurve(GF(144169), j=1728) # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(144169), j=1728) # needs sage.rings.finite_rings Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 144169 Elliptic curves over the same ring with the same Weierstrass @@ -231,10 +231,10 @@ class EllipticCurveFactory(UniqueFactory): We create a curve and a point over ``QQbar`` (see :trac:`6879`):: - sage: E = EllipticCurve(QQbar, [0,1]) # optional - sage.rings.number_field - sage: E(0) # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [0,1]) # needs sage.rings.number_field + sage: E(0) # needs sage.rings.number_field (0 : 1 : 0) - sage: E.base_field() # optional - sage.rings.number_field + sage: E.base_field() # needs sage.rings.number_field Algebraic Field sage: E = EllipticCurve(RR, [1,2]); E; E.base_field() @@ -245,7 +245,7 @@ class EllipticCurveFactory(UniqueFactory): Elliptic Curve defined by y^2 = x^3 + 3.00000000000000*x + 4.00000000000000 over Complex Field with 53 bits of precision Complex Field with 53 bits of precision - sage: E = EllipticCurve(QQbar, [5,6]); E; E.base_field() # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [5,6]); E; E.base_field() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + 5*x + 6 over Algebraic Field Algebraic Field @@ -256,7 +256,7 @@ class EllipticCurveFactory(UniqueFactory): ... ValueError: First parameter (if present) must be a ring when j is specified - sage: EllipticCurve(GF(5), j=3/5) # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(5), j=3/5) Traceback (most recent call last): ... ValueError: First parameter must be a ring containing 3/5 @@ -265,9 +265,9 @@ class EllipticCurveFactory(UniqueFactory): constructed has type :class:`EllipticCurve_field`. Otherwise it is :class:`EllipticCurve_generic`. See :trac:`9816` :: - sage: E = EllipticCurve([QQbar(1), 3]); E # optional - sage.rings.number_field + sage: E = EllipticCurve([QQbar(1), 3]); E # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + x + 3 over Algebraic Field - sage: type(E) # optional - sage.rings.number_field + sage: type(E) # needs sage.rings.number_field sage: E = EllipticCurve([RR(1), 3]); E @@ -276,13 +276,14 @@ class EllipticCurveFactory(UniqueFactory): sage: type(E) - sage: E = EllipticCurve([SR(i),i]); E # optional - sage.symbolic + sage: # needs sage.symbolic + sage: E = EllipticCurve([SR(i),i]); E Elliptic Curve defined by y^2 = x^3 + I*x + I over Symbolic Ring - sage: type(E) # optional - sage.symbolic + sage: type(E) - sage: E.category() # optional - sage.symbolic + sage: E.category() Category of schemes over Symbolic Ring - sage: SR in Fields() # optional - sage.symbolic + sage: SR in Fields() True sage: F = FractionField(PolynomialRing(QQ,'t')) @@ -389,6 +390,7 @@ def create_key_and_extra_args(self, x=None, y=None, j=None, minimal_twist=True, TESTS:: + sage: # needs sage.symbolic sage: var('x', 'y', 'v', 'w') (x, y, v, w) sage: EllipticCurve(y^2 + y > x^3 + x - 9) @@ -461,8 +463,8 @@ def create_object(self, version, key, **kwds): EXAMPLES:: - sage: E = EllipticCurve.create_object(0, (GF(3), (1, 2, 0, 1, 2))) # optional - sage.rings.finite_rings - sage: type(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve.create_object(0, (GF(3), (1, 2, 0, 1, 2))) + sage: type(E) .. NOTE:: @@ -1019,10 +1021,10 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): An example over a finite field, using a flex:: - sage: K = GF(17) # optional - sage.rings.finite_rings - sage: R. = K[] # optional - sage.rings.finite_rings - sage: cubic = 2*x^3 + 3*y^3 + 4*z^3 # optional - sage.rings.finite_rings - sage: EllipticCurve_from_cubic(cubic, [0,3,1]) # optional - sage.rings.finite_rings + sage: K = GF(17) + sage: R. = K[] + sage: cubic = 2*x^3 + 3*y^3 + 4*z^3 + sage: EllipticCurve_from_cubic(cubic, [0,3,1]) Scheme morphism: From: Projective Plane Curve over Finite Field of size 17 defined by 2*x^3 + 3*y^3 + 4*z^3 @@ -1032,10 +1034,10 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): An example in characteristic 3:: - sage: K = GF(3) # optional - sage.rings.finite_rings - sage: R. = K[] # optional - sage.rings.finite_rings - sage: cubic = x^3 + y^3 + z^3 + x*y*z # optional - sage.rings.finite_rings - sage: EllipticCurve_from_cubic(cubic, [0,1,-1]) # optional - sage.rings.finite_rings + sage: K = GF(3) + sage: R. = K[] + sage: cubic = x^3 + y^3 + z^3 + x*y*z + sage: EllipticCurve_from_cubic(cubic, [0,1,-1]) Scheme morphism: From: Projective Plane Curve over Finite Field of size 3 defined by x^3 + y^3 + x*y*z + z^3 @@ -1045,10 +1047,11 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): An example over a number field, using a non-flex and where there are no rational flexes:: - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: cubic = 2*x^3 + 3*y^3 + 5*z^3 # optional - sage.rings.number_field - sage: EllipticCurve_from_cubic(cubic, [1,1,-1]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: R. = K[] + sage: cubic = 2*x^3 + 3*y^3 + 5*z^3 + sage: EllipticCurve_from_cubic(cubic, [1,1,-1]) Scheme morphism: From: Projective Plane Curve over Number Field in a with defining polynomial x^2 + 3 with a = 1.732050807568878?*I @@ -1068,7 +1071,7 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): sage: K. = FunctionField(QQ) sage: R. = K[] sage: cubic = x^3 + t*y^3 + (1+t)*z^3 - sage: EllipticCurve_from_cubic(cubic, [1,1,-1], morphism=False) + sage: EllipticCurve_from_cubic(cubic, [1,1,-1], morphism=False) # needs sage.libs.singular Elliptic Curve defined by y^2 + ((162*t^6+486*t^5+810*t^4+810*t^3+486*t^2+162*t)/(t^6+12*t^5-3*t^4-20*t^3-3*t^2+12*t+1))*x*y + ((314928*t^14+4094064*t^13+23462136*t^12+78102144*t^11+167561379*t^10+243026001*t^9+243026001*t^8+167561379*t^7+78102144*t^6+23462136*t^5+4094064*t^4+314928*t^3)/(t^14+40*t^13+577*t^12+3524*t^11+8075*t^10+5288*t^9-8661*t^8-17688*t^7-8661*t^6+5288*t^5+8075*t^4+3524*t^3+577*t^2+40*t+1))*y = x^3 + ((2187*t^12+13122*t^11-17496*t^10-207765*t^9-516132*t^8-673596*t^7-516132*t^6-207765*t^5-17496*t^4+13122*t^3+2187*t^2)/(t^12+24*t^11+138*t^10-112*t^9-477*t^8+72*t^7+708*t^6+72*t^5-477*t^4-112*t^3+138*t^2+24*t+1))*x^2 over Rational function field in t over Rational Field @@ -1370,8 +1373,8 @@ def projective_point(p): sage: from sage.schemes.elliptic_curves.constructor import projective_point sage: projective_point([4/5, 6/5, 8/5]) [2, 3, 4] - sage: F = GF(11) # optional - sage.rings.finite_rings - sage: projective_point([F(4), F(8), F(2)]) # optional - sage.rings.finite_rings + sage: F = GF(11) + sage: projective_point([F(4), F(8), F(2)]) [4, 8, 2] """ from sage.rings.integer import GCD_list @@ -1461,13 +1464,14 @@ def EllipticCurves_with_good_reduction_outside_S(S=[], proof=None, verbose=False sage: ', '.join(e.label() for e in elist) # long time '11a1, 11a2, 11a3, 121a1, 121a2, 121b1, 121b2, 121c1, 121c2, 121d1, 121d2, 121d3' + sage: # long time sage: elist = EllipticCurves_with_good_reduction_outside_S([2,3]) # long time (26s on sage.math, 2011) - sage: len(elist) # long time + sage: len(elist) 752 - sage: conds = sorted(set([e.conductor() for e in elist])) # long time - sage: max(conds) # long time + sage: conds = sorted(set([e.conductor() for e in elist])) + sage: max(conds) 62208 - sage: [N.factor() for N in conds] # long time + sage: [N.factor() for N in conds] [2^3 * 3, 3^3, 2^5, diff --git a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx index 5fc182c8954..458ce65a61d 100644 --- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx +++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx @@ -1151,14 +1151,16 @@ def two_descent_by_two_isogeny(E, sage: n1, n2, n1_prime, n2_prime = two_descent_by_two_isogeny(E) sage: log(n1,2) + log(n1_prime,2) - 2 # the rank 1 + + sage: # needs sage.symbolic sage: x,y = var('x,y') sage: E = EllipticCurve(y^2 == x^3 + x^2 - 25*x + 39) sage: n1, n2, n1_prime, n2_prime = two_descent_by_two_isogeny(E) - sage: log(n1,2) + log(n1_prime,2) - 2 # the rank + sage: log(n1,2) + log(n1_prime,2) - 2 # the rank 2 sage: E = EllipticCurve(y^2 + x*y + y == x^3 - 131*x + 558) sage: n1, n2, n1_prime, n2_prime = two_descent_by_two_isogeny(E) - sage: log(n1,2) + log(n1_prime,2) - 2 # the rank + sage: log(n1,2) + log(n1_prime,2) - 2 # the rank 3 Using the verbosity option:: diff --git a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py index e5e35f2a139..383cc8e4fd7 100644 --- a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py +++ b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py @@ -13,21 +13,21 @@ The usual way to create and work with isogenies is illustrated with the following example:: - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,1]) # optional - sage.rings.finite_rings - sage: Q = E(6,5) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(Q) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: k = GF(11) + sage: E = EllipticCurve(k, [1,1]) + sage: Q = E(6,5) + sage: phi = E.isogeny(Q) + sage: phi Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 11 to Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 11 - sage: P = E(4,5) # optional - sage.rings.finite_rings - sage: phi(P) # optional - sage.rings.finite_rings + sage: P = E(4,5) + sage: phi(P) (10 : 0 : 1) - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 11 - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^7 + 4*x^6 - 3*x^5 - 2*x^4 - 3*x^3 + 3*x^2 + x - 2)/(x^6 + 4*x^5 - 4*x^4 - 5*x^3 + 5*x^2), (x^9*y - 5*x^8*y - x^7*y + x^5*y - x^4*y @@ -127,32 +127,32 @@ def _isogeny_determine_algorithm(E, kernel): This helper function will be implicitly called by the following examples:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(5), [0,0,0,1,0]) # indirect doctest # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: E = EllipticCurve(GF(5), [0,0,0,1,0]) # indirect doctest We can construct the same isogeny from a kernel polynomial:: - sage: phi = EllipticCurveIsogeny(E, x + 3) # indirect doctest # optional - sage.rings.finite_rings + sage: phi = EllipticCurveIsogeny(E, x + 3) # indirect doctest or from a list of coefficients of a kernel polynomial:: - sage: phi == EllipticCurveIsogeny(E, [3,1]) # indirect doctest # optional - sage.rings.finite_rings + sage: phi == EllipticCurveIsogeny(E, [3,1]) # indirect doctest True or from a rational point which generates the kernel:: - sage: phi == EllipticCurveIsogeny(E, E((2,0))) # indirect doctest # optional - sage.rings.finite_rings + sage: phi == EllipticCurveIsogeny(E, E((2,0))) # indirect doctest True In the first two cases, Kohel's algorithm will be used, while in the third case it is Vélu:: sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import _isogeny_determine_algorithm - sage: _isogeny_determine_algorithm(E, x + 3) # optional - sage.rings.finite_rings + sage: _isogeny_determine_algorithm(E, x + 3) 'kohel' - sage: _isogeny_determine_algorithm(E, [3, 1]) # optional - sage.rings.finite_rings + sage: _isogeny_determine_algorithm(E, [3, 1]) 'kohel' - sage: _isogeny_determine_algorithm(E, E((2,0))) # optional - sage.rings.finite_rings + sage: _isogeny_determine_algorithm(E, E((2,0))) 'velu' """ kernel_is_list = isinstance(kernel, list) @@ -171,6 +171,7 @@ def _isogeny_determine_algorithm(E, kernel): raise ValueError("invalid parameters to EllipticCurveIsogeny constructor") + from sage.misc.superseded import deprecated_function_alias isogeny_determine_algorithm = deprecated_function_alias(33619, _isogeny_determine_algorithm) @@ -194,24 +195,24 @@ def isogeny_codomain_from_kernel(E, kernel, degree=None): EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogeny_codomain_from_kernel - sage: E = EllipticCurve(GF(7), [1,0,1,0,1]) # optional - sage.rings.finite_rings - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: isogeny_codomain_from_kernel(E, [4,1]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [1,0,1,0,1]) + sage: R. = GF(7)[] + sage: isogeny_codomain_from_kernel(E, [4,1]) Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + 6 over Finite Field of size 7 - sage: (EllipticCurveIsogeny(E, [4,1]).codomain() # optional - sage.rings.finite_rings + sage: (EllipticCurveIsogeny(E, [4,1]).codomain() ....: == isogeny_codomain_from_kernel(E, [4,1])) True - sage: isogeny_codomain_from_kernel(E, x^3 + x^2 + 4*x + 3) # optional - sage.rings.finite_rings + sage: isogeny_codomain_from_kernel(E, x^3 + x^2 + 4*x + 3) Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + 6 over Finite Field of size 7 - sage: isogeny_codomain_from_kernel(E, x^3 + 2*x^2 + 4*x + 3) # optional - sage.rings.finite_rings + sage: isogeny_codomain_from_kernel(E, x^3 + 2*x^2 + 4*x + 3) Elliptic Curve defined by y^2 + x*y + y = x^3 + 5*x + 2 over Finite Field of size 7 - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: kernel_list = [E((15,10)), E((10,3)), E((6,5))] # optional - sage.rings.finite_rings - sage: isogeny_codomain_from_kernel(E, kernel_list) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: kernel_list = [E((15,10)), E((10,3)), E((6,5))] + sage: isogeny_codomain_from_kernel(E, kernel_list) Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 @@ -219,7 +220,7 @@ def isogeny_codomain_from_kernel(E, kernel, degree=None): Test deprecation warning for obsolete argument:: - sage: isogeny_codomain_from_kernel(E, kernel_list, degree=4) # optional - sage.rings.finite_rings + sage: isogeny_codomain_from_kernel(E, kernel_list, degree=4) doctest:warning ... DeprecationWarning: The "degree" argument to isogeny_codomain_from_kernel() does nothing and will be removed. @@ -265,15 +266,15 @@ def compute_codomain_formula(E, v, w): This formula is used by every invocation of the :class:`EllipticCurveIsogeny` constructor:: - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((1,2)) ) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: phi = EllipticCurveIsogeny(E, E((1,2)) ) + sage: phi.codomain() Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 13 over Finite Field of size 19 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_codomain_formula - sage: v = phi._EllipticCurveIsogeny__v # optional - sage.rings.finite_rings - sage: w = phi._EllipticCurveIsogeny__w # optional - sage.rings.finite_rings - sage: compute_codomain_formula(E, v, w) == phi.codomain() # optional - sage.rings.finite_rings + sage: v = phi._EllipticCurveIsogeny__v + sage: w = phi._EllipticCurveIsogeny__w + sage: compute_codomain_formula(E, v, w) == phi.codomain() True """ a1, a2, a3, a4, a6 = E.a_invariants() @@ -302,18 +303,18 @@ def compute_vw_kohel_even_deg1(x0, y0, a1, a2, a4): This function will be implicitly called by the following example:: - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [9,1]); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: phi = EllipticCurveIsogeny(E, [9,1]); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 19 to Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 8 over Finite Field of size 19 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_even_deg1 - sage: a1,a2,a3,a4,a6 = E.a_invariants() # optional - sage.rings.finite_rings - sage: x0 = -9 # optional - sage.rings.finite_rings - sage: y0 = -(a1*x0 + a3)/2 # optional - sage.rings.finite_rings - sage: compute_vw_kohel_even_deg1(x0, y0, a1, a2, a4) # optional - sage.rings.finite_rings + sage: a1,a2,a3,a4,a6 = E.a_invariants() + sage: x0 = -9 + sage: y0 = -(a1*x0 + a3)/2 + sage: compute_vw_kohel_even_deg1(x0, y0, a1, a2, a4) (18, 9) """ v = 3*x0**2 + 2*a2*x0 + a4 - a1*y0 @@ -340,18 +341,18 @@ def compute_vw_kohel_even_deg3(b2, b4, s1, s2, s3): This function will be implicitly called by the following example:: - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: R. = GF(19)[] + sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12); phi Isogeny of degree 4 from Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 19 to Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_even_deg3 - sage: b2,b4 = E.b2(), E.b4() # optional - sage.rings.finite_rings - sage: s1, s2, s3 = -7, 15, -12 # optional - sage.rings.finite_rings - sage: compute_vw_kohel_even_deg3(b2, b4, s1, s2, s3) # optional - sage.rings.finite_rings + sage: b2,b4 = E.b2(), E.b4() + sage: s1, s2, s3 = -7, 15, -12 + sage: compute_vw_kohel_even_deg3(b2, b4, s1, s2, s3) (4, 7) """ temp1 = s1**2 - 2*s2 @@ -381,18 +382,18 @@ def compute_vw_kohel_odd(b2, b4, b6, s1, s2, s3, n): This function will be implicitly called by the following example:: - sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) # optional - sage.rings.finite_rings - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) + sage: R. = GF(19)[] + sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11); phi Isogeny of degree 7 from Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 15*x + 14 over Finite Field of size 19 to Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 18*x + 18 over Finite Field of size 19 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_odd - sage: b2,b4,b6 = E.b2(), E.b4(), E.b6() # optional - sage.rings.finite_rings - sage: s1,s2,s3 = -14,3,-11 # optional - sage.rings.finite_rings - sage: compute_vw_kohel_odd(b2,b4,b6,s1,s2,s3,3) # optional - sage.rings.finite_rings + sage: b2,b4,b6 = E.b2(), E.b4(), E.b6() + sage: s1,s2,s3 = -14,3,-11 + sage: compute_vw_kohel_odd(b2,b4,b6,s1,s2,s3,3) (7, 1) """ v = 6*(s1**2 - 2*s2) + b2*s1 + n*b4 @@ -419,26 +420,26 @@ def compute_codomain_kohel(E, kernel): EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_codomain_kohel - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [9,1]) # optional - sage.rings.finite_rings - sage: phi.codomain() == isogeny_codomain_from_kernel(E, [9,1]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: phi = EllipticCurveIsogeny(E, [9,1]) + sage: phi.codomain() == isogeny_codomain_from_kernel(E, [9,1]) True - sage: compute_codomain_kohel(E, [9,1]) # optional - sage.rings.finite_rings + sage: compute_codomain_kohel(E, [9,1]) Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 8 over Finite Field of size 19 - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11) # optional - sage.rings.finite_rings - sage: phi.codomain() == isogeny_codomain_from_kernel(E, x^3 + 14*x^2 + 3*x + 11) # optional - sage.rings.finite_rings + sage: R. = GF(19)[] + sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) + sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11) + sage: phi.codomain() == isogeny_codomain_from_kernel(E, x^3 + 14*x^2 + 3*x + 11) True - sage: compute_codomain_kohel(E, x^3 + 14*x^2 + 3*x + 11) # optional - sage.rings.finite_rings + sage: compute_codomain_kohel(E, x^3 + 14*x^2 + 3*x + 11) Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 18*x + 18 over Finite Field of size 19 - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12) # optional - sage.rings.finite_rings - sage: isogeny_codomain_from_kernel(E, x^3 + 7*x^2 + 15*x + 12) == phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12) + sage: isogeny_codomain_from_kernel(E, x^3 + 7*x^2 + 15*x + 12) == phi.codomain() True - sage: compute_codomain_kohel(E, x^3 + 7*x^2 + 15*x + 12) # optional - sage.rings.finite_rings + sage: compute_codomain_kohel(E, x^3 + 7*x^2 + 15*x + 12) Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 @@ -529,13 +530,13 @@ def two_torsion_part(E, psi): Every function that computes the kernel polynomial via Kohel's formulas will call this function:: - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x + 13) # optional - sage.rings.finite_rings - sage: isogeny_codomain_from_kernel(E, x + 13) == phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: R. = GF(19)[] + sage: phi = EllipticCurveIsogeny(E, x + 13) + sage: isogeny_codomain_from_kernel(E, x + 13) == phi.codomain() True sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import two_torsion_part - sage: two_torsion_part(E, x + 13) # optional - sage.rings.finite_rings + sage: two_torsion_part(E, x + 13) x + 13 """ x = psi.parent().gen() # NB psi is univariate but could be constant @@ -612,105 +613,107 @@ class EllipticCurveIsogeny(EllipticCurveHom): A simple example of creating an isogeny of a field of small characteristic:: - sage: E = EllipticCurve(GF(7), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0)) ); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0)) ); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 - sage: phi.degree() == 2 # optional - sage.rings.finite_rings + sage: phi.degree() == 2 True - sage: phi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: phi.kernel_polynomial() x - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^2 + 1)/x, (x^2*y - y)/x^2) - sage: phi == loads(dumps(phi)) # known bug # optional - sage.rings.finite_rings + sage: phi == loads(dumps(phi)) # known bug True A more complicated example of a characteristic-2 field:: - sage: E = EllipticCurve(GF(2^4,'alpha'), [0,0,1,0,1]) # optional - sage.rings.finite_rings - sage: P = E((1,1)) # optional - sage.rings.finite_rings - sage: phi_v = EllipticCurveIsogeny(E, P); phi_v # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^4,'alpha'), [0,0,1,0,1]) + sage: P = E((1,1)) + sage: phi_v = EllipticCurveIsogeny(E, P); phi_v Isogeny of degree 3 from Elliptic Curve defined by y^2 + y = x^3 + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + y = x^3 over Finite Field in alpha of size 2^4 - sage: phi_ker_poly = phi_v.kernel_polynomial() # optional - sage.rings.finite_rings - sage: phi_ker_poly # optional - sage.rings.finite_rings + sage: phi_ker_poly = phi_v.kernel_polynomial() + sage: phi_ker_poly x + 1 - sage: phi_k = EllipticCurveIsogeny(E, phi_ker_poly) # optional - sage.rings.finite_rings - sage: phi_k == phi_v # optional - sage.rings.finite_rings + sage: phi_k = EllipticCurveIsogeny(E, phi_ker_poly) + sage: phi_k == phi_v True - sage: phi_k.rational_maps() # optional - sage.rings.finite_rings + sage: phi_k.rational_maps() ((x^3 + x + 1)/(x^2 + 1), (x^3*y + x^2*y + x*y + x + y)/(x^3 + x^2 + x + 1)) - sage: phi_v.rational_maps() # optional - sage.rings.finite_rings + sage: phi_v.rational_maps() ((x^3 + x + 1)/(x^2 + 1), (x^3*y + x^2*y + x*y + x + y)/(x^3 + x^2 + x + 1)) - sage: phi_k.degree() == phi_v.degree() == 3 # optional - sage.rings.finite_rings + sage: phi_k.degree() == phi_v.degree() == 3 True - sage: phi_k.is_separable() # optional - sage.rings.finite_rings + sage: phi_k.is_separable() True - sage: phi_v(E(0)) # optional - sage.rings.finite_rings + sage: phi_v(E(0)) (0 : 1 : 0) - sage: alpha = E.base_field().gen() # optional - sage.rings.finite_rings - sage: Q = E((0, alpha*(alpha + 1))) # optional - sage.rings.finite_rings - sage: phi_v(Q) # optional - sage.rings.finite_rings + sage: alpha = E.base_field().gen() + sage: Q = E((0, alpha*(alpha + 1))) + sage: phi_v(Q) (1 : alpha^2 + alpha : 1) - sage: phi_v(P) == phi_k(P) # optional - sage.rings.finite_rings + sage: phi_v(P) == phi_k(P) True - sage: phi_k(P) == phi_v.codomain()(0) # optional - sage.rings.finite_rings + sage: phi_k(P) == phi_v.codomain()(0) True We can create an isogeny whose kernel equals the full 2-torsion:: - sage: E = EllipticCurve(GF((3,2)), [0,0,0,1,1]) # optional - sage.rings.finite_rings - sage: ker_poly = E.division_polynomial(2) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, ker_poly); phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF((3,2)), [0,0,0,1,1]) + sage: ker_poly = E.division_polynomial(2) + sage: phi = EllipticCurveIsogeny(E, ker_poly); phi Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in z2 of size 3^2 to Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in z2 of size 3^2 - sage: P1,P2,P3 = filter(bool, E(0).division_points(2)) # optional - sage.rings.finite_rings - sage: phi(P1) # optional - sage.rings.finite_rings + sage: P1,P2,P3 = filter(bool, E(0).division_points(2)) + sage: phi(P1) (0 : 1 : 0) - sage: phi(P2) # optional - sage.rings.finite_rings + sage: phi(P2) (0 : 1 : 0) - sage: phi(P3) # optional - sage.rings.finite_rings + sage: phi(P3) (0 : 1 : 0) - sage: phi.degree() # optional - sage.rings.finite_rings + sage: phi.degree() 4 We can also create trivial isogenies with the trivial kernel:: - sage: E = EllipticCurve(GF(17), [11, 11, 4, 12, 10]) # optional - sage.rings.finite_rings - sage: phi_v = EllipticCurveIsogeny(E, E(0)) # optional - sage.rings.finite_rings - sage: phi_v.degree() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [11, 11, 4, 12, 10]) + sage: phi_v = EllipticCurveIsogeny(E, E(0)) + sage: phi_v.degree() 1 - sage: phi_v.rational_maps() # optional - sage.rings.finite_rings + sage: phi_v.rational_maps() (x, y) - sage: E == phi_v.codomain() # optional - sage.rings.finite_rings + sage: E == phi_v.codomain() True - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: phi_v(P) == P # optional - sage.rings.finite_rings + sage: P = E.random_point() + sage: phi_v(P) == P True - sage: E = EllipticCurve(GF(31), [23, 1, 22, 7, 18]) # optional - sage.rings.finite_rings - sage: phi_k = EllipticCurveIsogeny(E, [1]); phi_k # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [23, 1, 22, 7, 18]) + sage: phi_k = EllipticCurveIsogeny(E, [1]); phi_k Isogeny of degree 1 from Elliptic Curve defined by y^2 + 23*x*y + 22*y = x^3 + x^2 + 7*x + 18 over Finite Field of size 31 to Elliptic Curve defined by y^2 + 23*x*y + 22*y = x^3 + x^2 + 7*x + 18 over Finite Field of size 31 - sage: phi_k.degree() # optional - sage.rings.finite_rings + sage: phi_k.degree() 1 - sage: phi_k.rational_maps() # optional - sage.rings.finite_rings + sage: phi_k.rational_maps() (x, y) - sage: phi_k.codomain() == E # optional - sage.rings.finite_rings + sage: phi_k.codomain() == E True - sage: phi_k.kernel_polynomial() # optional - sage.rings.finite_rings + sage: phi_k.kernel_polynomial() 1 - sage: P = E.random_point(); P == phi_k(P) # optional - sage.rings.finite_rings + sage: P = E.random_point(); P == phi_k(P) True Vélu and Kohel also work in characteristic `0`:: @@ -767,39 +770,40 @@ class EllipticCurveIsogeny(EllipticCurveHom): We can also do this same example over the number field defined by the irreducible two-torsion polynomial of `E`:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('11a1') sage: P_list = E.torsion_points() sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2* x^2 - 40*x - 158) # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: P_list = [EK(P) for P in P_list] # optional - sage.rings.number_field - sage: phi_v = EllipticCurveIsogeny(EK, P_list); phi_v # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2* x^2 - 40*x - 158) + sage: EK = E.change_ring(K) + sage: P_list = [EK(P) for P in P_list] + sage: phi_v = EllipticCurveIsogeny(EK, P_list); phi_v Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-7820)*x + (-263580) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 - sage: P = EK((alpha/2,-1/2)) # optional - sage.rings.number_field - sage: phi_v(P) # optional - sage.rings.number_field + sage: P = EK((alpha/2,-1/2)) + sage: phi_v(P) (122/121*alpha^2 + 1633/242*alpha - 3920/121 : -1/2 : 1) - sage: ker_poly = phi_v.kernel_polynomial() # optional - sage.rings.number_field - sage: ker_poly # optional - sage.rings.number_field + sage: ker_poly = phi_v.kernel_polynomial() + sage: ker_poly x^2 - 21*x + 80 - sage: phi_k = EllipticCurveIsogeny(EK, ker_poly); phi_k # optional - sage.rings.number_field + sage: phi_k = EllipticCurveIsogeny(EK, ker_poly); phi_k Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-7820)*x + (-263580) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 - sage: phi_v == phi_k # optional - sage.rings.number_field + sage: phi_v == phi_k True - sage: phi_k(P) == phi_v(P) # optional - sage.rings.number_field + sage: phi_k(P) == phi_v(P) True - sage: phi_k == phi_v # optional - sage.rings.number_field + sage: phi_k == phi_v True - sage: phi_k.degree() # optional - sage.rings.number_field + sage: phi_k.degree() 5 - sage: phi_v.is_separable() # optional - sage.rings.number_field + sage: phi_v.is_separable() True The following example shows how to specify an isogeny from domain @@ -844,16 +848,17 @@ class EllipticCurveIsogeny(EllipticCurveHom): Here an example of a construction of a endomorphisms with cyclic kernel on a CM-curve:: - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1,0]) # optional - sage.rings.number_field - sage: RK. = K[] # optional - sage.rings.number_field - sage: f = X^2 - 2/5*i + 1/5 # optional - sage.rings.number_field - sage: phi= E.isogeny(f) # optional - sage.rings.number_field - sage: isom = phi.codomain().isomorphism_to(E) # optional - sage.rings.number_field - sage: phi = isom * phi # optional - sage.rings.number_field - sage: phi.codomain() == phi.domain() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [1,0]) + sage: RK. = K[] + sage: f = X^2 - 2/5*i + 1/5 + sage: phi= E.isogeny(f) + sage: isom = phi.codomain().isomorphism_to(E) + sage: phi = isom * phi + sage: phi.codomain() == phi.domain() True - sage: phi.rational_maps() # optional - sage.rings.number_field + sage: phi.rational_maps() (((4/25*i + 3/25)*x^5 + (4/5*i - 2/5)*x^3 - x)/(x^4 + (-4/5*i + 2/5)*x^2 + (-4/25*i - 3/25)), ((11/125*i + 2/125)*x^6*y + (-23/125*i + 64/125)*x^4*y + (141/125*i + 162/125)*x^2*y + (3/25*i - 4/25)*y)/(x^6 + (-6/5*i + 3/5)*x^4 + (-12/25*i - 9/25)*x^2 + (2/125*i - 11/125))) @@ -868,38 +873,39 @@ class EllipticCurveIsogeny(EllipticCurveHom): sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 - 4*x over Rational Field - sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [17, 1]) # optional - sage.rings.finite_rings - sage: phi.domain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) + sage: phi = EllipticCurveIsogeny(E, [17, 1]) + sage: phi.domain() Elliptic Curve defined by y^2 + x*y = x^3 + x + 2 over Finite Field of size 31 - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: phi.codomain() Elliptic Curve defined by y^2 + x*y = x^3 + 24*x + 6 over Finite Field of size 31 Composition tests (see :trac:`16245`, cf. :trac:`34410`):: - sage: E = EllipticCurve(j=GF(7)(0)) # optional - sage.rings.finite_rings - sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(0)) + sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 - sage: phi2 = phi * phi; phi2 # optional - sage.rings.finite_rings + sage: phi2 = phi * phi; phi2 Composite morphism of degree 9 = 3^2: From: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 To: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 Examples over relative number fields used not to work (see :trac:`16779`):: + sage: # long time, needs sage.rings.number_field sage: pol26 = hilbert_class_polynomial(-4*26) - sage: F = NumberField(pol26,'a') # long time # optional - sage.rings.number_field - sage: pol = F.optimized_representation()[0].polynomial() # long time # optional - sage.rings.number_field - sage: K. = NumberField(pol) # long time # optional - sage.rings.number_field - sage: j = pol26.roots(K)[0][0] # long time # optional - sage.rings.number_field - sage: E = EllipticCurve(j=j) # long time # optional - sage.rings.number_field - sage: L. = K.extension(x^2 + 26) # long time # optional - sage.rings.number_field - sage: EL = E.change_ring(L) # long time # optional - sage.rings.number_field - sage: iso2 = EL.isogenies_prime_degree(2); len(iso2) # long time # optional - sage.rings.number_field + sage: F = NumberField(pol26,'a') + sage: pol = F.optimized_representation()[0].polynomial() + sage: K. = NumberField(pol) + sage: j = pol26.roots(K)[0][0] + sage: E = EllipticCurve(j=j) + sage: L. = K.extension(x^2 + 26) + sage: EL = E.change_ring(L) + sage: iso2 = EL.isogenies_prime_degree(2); len(iso2) 1 - sage: iso3 = EL.isogenies_prime_degree(3); len(iso3) # long time # optional - sage.rings.number_field + sage: iso3 = EL.isogenies_prime_degree(3); len(iso3) 2 Examples over function fields used not to work (see :trac:`11327`):: @@ -1015,15 +1021,15 @@ def __init__(self, E, kernel, codomain=None, degree=None, model=None, check=True EXAMPLES:: - sage: E = EllipticCurve(GF(2), [0,0,1,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [1,1]); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(2), [0,0,1,0,1]) + sage: phi = EllipticCurveIsogeny(E, [1,1]); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 + y = x^3 + 1 over Finite Field of size 2 to Elliptic Curve defined by y^2 + y = x^3 over Finite Field of size 2 - sage: E = EllipticCurve(GF(31), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: P = E((2,17)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [0,0,0,1,0]) + sage: P = E((2,17)) + sage: phi = EllipticCurveIsogeny(E, P); phi Isogeny of degree 8 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 31 to Elliptic Curve defined by y^2 = x^3 + 10*x + 28 over Finite Field of size 31 @@ -1124,8 +1130,8 @@ def _eval(self, P): sage: E = EllipticCurve([1,0]); E Elliptic Curve defined by y^2 = x^3 + x over Rational Field sage: phi = E.isogeny(E(0,0)) - sage: P = E.change_ring(QQbar).lift_x(QQbar.random_element()) # optional - sage.rings.number_field - sage: phi._eval(P).curve() # optional - sage.rings.number_field + sage: P = E.change_ring(QQbar).lift_x(QQbar.random_element()) # needs sage.rings.number_field + sage: phi._eval(P).curve() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (-4)*x over Algebraic Field :: @@ -1133,8 +1139,8 @@ def _eval(self, P): sage: E = EllipticCurve(j=Mod(0,419)) sage: K = next(filter(bool, E(0).division_points(5))) sage: psi = E.isogeny(K) - sage: Ps = E.change_ring(GF(419**2))(0).division_points(5) # optional - sage.rings.number_field - sage: {psi._eval(P).curve() for P in Ps} # optional - sage.rings.number_field + sage: Ps = E.change_ring(GF(419**2))(0).division_points(5) # needs sage.rings.number_field + sage: {psi._eval(P).curve() for P in Ps} # needs sage.rings.number_field {Elliptic Curve defined by y^2 = x^3 + 140*x + 214 over Finite Field in z2 of size 419^2} """ if self._domain.defining_polynomial()(*P): @@ -1174,67 +1180,69 @@ def _call_(self, P): EXAMPLES:: - sage: E = EllipticCurve(GF(17), [1, 9, 5, 4, 3]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [6,13,1]) # optional - sage.rings.finite_rings - sage: phi(E((1,0))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [1, 9, 5, 4, 3]) + sage: phi = EllipticCurveIsogeny(E, [6,13,1]) + sage: phi(E((1,0))) (15 : 13 : 1) - sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi(E((1,5))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi(E((1,5))) (2 : 0 : 1) - sage: E = EllipticCurve(QQ, [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: P = E((1,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [0,1]) # optional - sage.rings.finite_rings - sage: phi(P) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(QQ, [0,0,0,3,0]) + sage: P = E((1,2)) + sage: phi = EllipticCurveIsogeny(E, [0,1]) + sage: phi(P) (4 : -4 : 1) - sage: phi(-P) # optional - sage.rings.finite_rings + sage: phi(-P) (4 : 4 : 1) - sage: E = EllipticCurve(GF(17), [0,-1,0,-3,-1]) # optional - sage.rings.finite_rings - sage: Q = E((16,0)) # optional - sage.rings.finite_rings - sage: tau = E.isogeny([Q], E) # optional - sage.rings.finite_rings - sage: tau(Q) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,-1,0,-3,-1]) + sage: Q = E((16,0)) + sage: tau = E.isogeny([Q], E) + sage: tau(Q) (0 : 1 : 0) TESTS: Tests for :trac:`10888`:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [7,0]) # optional - sage.rings.number_field - sage: phi = E.isogeny(E(0,0)) # optional - sage.rings.number_field - sage: P = E(-3,4*th) # optional - sage.rings.number_field - sage: phi(P) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 3) + sage: E = EllipticCurve(K, [7,0]) + sage: phi = E.isogeny(E(0,0)) + sage: P = E(-3,4*th) + sage: phi(P) (-16/3 : 8/9*th : 1) - sage: Q = phi(P) # optional - sage.rings.number_field - sage: phihat = phi.dual() # optional - sage.rings.number_field - sage: phihat(Q) # optional - sage.rings.number_field + sage: Q = phi(P) + sage: phihat = phi.dual() + sage: phihat(Q) (-1/48 : 127/576*th : 1) Call a composed isogeny (added for :trac:`16238`):: - sage: E = EllipticCurve(j=GF(7)(0)) # optional - sage.rings.finite_rings - sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]) # optional - sage.rings.finite_rings - sage: phi(E.points()[0]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(0)) + sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]) + sage: phi(E.points()[0]) (0 : 1 : 0) - sage: phi2 = phi * phi # optional - sage.rings.finite_rings - sage: phi2(E.points()[0]) # optional - sage.rings.finite_rings + sage: phi2 = phi * phi + sage: phi2(E.points()[0]) (0 : 1 : 0) Coercion works fine with :meth:`_call_` (added for :trac:`16238`):: - sage: K. = NumberField(x^2 + 3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [7,0]) # optional - sage.rings.number_field - sage: E2 = EllipticCurve(K, [5,0]) # optional - sage.rings.number_field - sage: phi = E.isogeny(E(0)) # optional - sage.rings.number_field - sage: phi(E2(0)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 3) + sage: E = EllipticCurve(K, [7,0]) + sage: E2 = EllipticCurve(K, [5,0]) + sage: phi = E.isogeny(E(0)) + sage: phi(E2(0)) (0 : 1 : 0) - sage: E2(20,90) # optional - sage.rings.number_field + sage: E2(20,90) (20 : 90 : 1) - sage: phi(E2(20,90)) # optional - sage.rings.number_field + sage: phi(E2(20,90)) Traceback (most recent call last): ... TypeError: (20 : 90 : 1) fails to convert into the map's domain @@ -1243,24 +1251,25 @@ def _call_(self, P): Check that copying the order over works:: - sage: E = EllipticCurve(GF(431), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: Q = 2^99*P; Q.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(431), [1,0]) + sage: P, = E.gens() + sage: Q = 2^99*P; Q.order() 27 - sage: phi = E.isogeny(3^99*P) # optional - sage.rings.finite_rings - sage: phi(Q)._order # optional - sage.rings.finite_rings + sage: phi = E.isogeny(3^99*P) + sage: phi(Q)._order 27 Test for :trac:`35983`:: - sage: E = EllipticCurve([1,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E([1,0]) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: E = EllipticCurve([1,0,0,-1,0]) + sage: P = E([1,0]) + sage: P.order() +Infinity - sage: phi = E.isogenies_prime_degree(2)[0] # optional - sage.rings.finite_rings - sage: Q = phi(P); Q # optional - sage.rings.finite_rings + sage: phi = E.isogenies_prime_degree(2)[0] + sage: Q = phi(P); Q (0 : 1 : 1) - sage: Q.order() # optional - sage.rings.finite_rings + sage: Q.order() +Infinity """ @@ -1326,11 +1335,11 @@ def __getitem__(self, i): sage: phi[1] y - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi[0] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi[0] (x^2 + 3)/x - sage: phi[1] # optional - sage.rings.finite_rings + sage: phi[1] (x^2*y - 3*y)/x^2 """ return self.rational_maps()[i] @@ -1347,9 +1356,9 @@ def __iter__(self): x y - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: for c in phi: print(c) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: for c in phi: print(c) (x^2 + 3)/x (x^2*y - 3*y)/x^2 """ @@ -1365,19 +1374,19 @@ def __neg__(self): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(17)(0)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((-1,0)) ) # optional - sage.rings.finite_rings - sage: negphi = -phi # optional - sage.rings.finite_rings - sage: phi(E((0,1))) + negphi(E((0,1))) == 0 # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(17)(0)) + sage: phi = EllipticCurveIsogeny(E, E((-1,0)) ) + sage: negphi = -phi + sage: phi(E((0,1))) + negphi(E((0,1))) == 0 True - sage: E = EllipticCurve(j=GF(19)(1728)) # optional - sage.rings.finite_rings - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x) # optional - sage.rings.finite_rings - sage: negphi = -phi # optional - sage.rings.finite_rings - sage: phi(E((3,7))) + negphi(E((3,12))) == phi(2*E((3,7))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(19)(1728)) + sage: R. = GF(19)[] + sage: phi = EllipticCurveIsogeny(E, x) + sage: negphi = -phi + sage: phi(E((3,7))) + negphi(E((3,12))) == phi(2*E((3,7))) True - sage: negphi(E((18,6))) # optional - sage.rings.finite_rings + sage: negphi(E((18,6))) (17 : 0 : 1) sage: R. = QQ[] @@ -1392,31 +1401,30 @@ def __neg__(self): sage: phi(P) + negphi(P) == 0 True - sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: f = E.torsion_polynomial(3)/3 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f, E) # optional - sage.rings.finite_rings - sage: phi.rational_maps() == E.multiplication_by_m(3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) + sage: f = E.torsion_polynomial(3)/3 + sage: phi = EllipticCurveIsogeny(E, f, E) + sage: phi.rational_maps() == E.multiplication_by_m(3) False - sage: negphi = -phi # optional - sage.rings.finite_rings - sage: negphi.rational_maps() == E.multiplication_by_m(3) # optional - sage.rings.finite_rings + sage: negphi = -phi + sage: negphi.rational_maps() == E.multiplication_by_m(3) True - sage: E = EllipticCurve(GF(17), [-2, 3, -5, 7, -11]) # optional - sage.rings.finite_rings - sage: R. = GF(17)[] # optional - sage.rings.finite_rings - sage: f = x+6 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [-2, 3, -5, 7, -11]) + sage: R. = GF(17)[] + sage: f = x+6 + sage: phi = EllipticCurveIsogeny(E, f); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 7*x + 6 over Finite Field of size 17 to Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 4*x + 8 over Finite Field of size 17 - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^2 + 6*x + 4)/(x + 6), (x^2*y - 5*x*y + 8*x - 2*y)/(x^2 - 5*x + 2)) - sage: negphi = -phi # optional - sage.rings.finite_rings - sage: negphi # optional - sage.rings.finite_rings + sage: negphi = -phi + sage: negphi Isogeny of degree 2 from Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 7*x + 6 over Finite Field of size 17 to Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 4*x + 8 over Finite Field of size 17 - sage: negphi.rational_maps() # optional - sage.rings.finite_rings + sage: negphi.rational_maps() ((x^2 + 6*x + 4)/(x + 6), (2*x^3 - x^2*y - 5*x^2 + 5*x*y - 4*x + 2*y + 7)/(x^2 - 5*x + 2)) @@ -1432,14 +1440,15 @@ def __neg__(self): sage: ymap1 == -ymap2 - E.a1()*xmap2 - E.a3() True - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: phi = EllipticCurveIsogeny(E, x - a) # optional - sage.rings.number_field - sage: phi.rational_maps() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: R. = K[] + sage: phi = EllipticCurveIsogeny(E, x - a) + sage: phi.rational_maps() ((x^2 + (-a)*x - 2)/(x + (-a)), (x^2*y + (-2*a)*x*y + y)/(x^2 + (-2*a)*x - 1)) - sage: negphi = -phi # optional - sage.rings.number_field - sage: negphi.rational_maps() # optional - sage.rings.number_field + sage: negphi = -phi + sage: negphi.rational_maps() ((x^2 + (-a)*x - 2)/(x + (-a)), (-x^2*y + (2*a)*x*y - y)/(x^2 + (-2*a)*x - 1)) """ output = copy(self) @@ -1456,9 +1465,9 @@ def _repr_(self): EXAMPLES:: - sage: E = EllipticCurve(GF(31), [1,0,1,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) # optional - sage.rings.finite_rings - sage: phi._repr_() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [1,0,1,1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) + sage: phi._repr_() 'Isogeny of degree 17 from Elliptic Curve defined by y^2 + x*y + y = x^3 + x over Finite Field of size 31 to Elliptic Curve defined by y^2 + x*y + y = x^3 + 14*x + 9 over Finite Field of size 31' sage: E = EllipticCurve(QQ, [1,0,0,1,9]) @@ -1482,10 +1491,10 @@ def _latex_(self): sage: phi._latex_() '\\left( x , y \\right)' - sage: E = EllipticCurve(GF(17), [0,0,0,1,-1]) # optional - sage.rings.finite_rings - sage: R. = GF(17)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, X + 11) # optional - sage.rings.finite_rings - sage: phi._latex_() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,1,-1]) + sage: R. = GF(17)[] + sage: phi = EllipticCurveIsogeny(E, X + 11) + sage: phi._latex_() '\\left( \\frac{x^{2} + 11 x + 7}{x + 11} , \\frac{x^{2} y + 5 x y + 12 y}{x^{2} + 5 x + 2} \\right)' """ fx,fy = self.rational_maps() @@ -1513,17 +1522,17 @@ def __clear_cached_values(self): sage: old_ratl_maps[1] == -phi.rational_maps()[1] True - sage: F = GF(127); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=F(1728)) # optional - sage.rings.finite_rings - sage: f = x^5 + 43*x^4 + 97*x^3 + 81*x^2 + 42*x + 82 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: old_ratl_maps = phi.rational_maps() # optional - sage.rings.finite_rings + sage: F = GF(127); R. = F[] + sage: E = EllipticCurve(j=F(1728)) + sage: f = x^5 + 43*x^4 + 97*x^3 + 81*x^2 + 42*x + 82 + sage: phi = EllipticCurveIsogeny(E, f) + sage: old_ratl_maps = phi.rational_maps() sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: phi._set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), # optional - sage.rings.finite_rings + sage: phi._set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), ....: (-13,13,-13,13))) - sage: old_ratl_maps == phi.rational_maps() # optional - sage.rings.finite_rings + sage: old_ratl_maps == phi.rational_maps() False - sage: phi._EllipticCurveIsogeny__clear_cached_values() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__clear_cached_values() """ self.__ratl_maps = None self.__dual = None @@ -1538,17 +1547,17 @@ def __perform_inheritance_housekeeping(self): The following examples will implicitly exercise this function:: - sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) # optional - sage.rings.finite_rings - sage: R. = GF(43)[]; f = x + 42 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) + sage: R. = GF(43)[]; f = x + 42 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: post_isom = WeierstrassIsomorphism(E2, (41, 37, 31, 29)) # optional - sage.rings.finite_rings - sage: phi._set_post_isomorphism(post_isom) # optional - sage.rings.finite_rings - sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain() # optional - sage.rings.finite_rings - sage: pre_isom = E1pr.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_pre_isomorphism(pre_isom) # optional - sage.rings.finite_rings + sage: E2 = phi.codomain() + sage: post_isom = WeierstrassIsomorphism(E2, (41, 37, 31, 29)) + sage: phi._set_post_isomorphism(post_isom) + sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain() + sage: pre_isom = E1pr.isomorphism_to(E) + sage: phi._set_pre_isomorphism(pre_isom) """ EllipticCurveHom.__init__(self, self._domain, self._codomain) @@ -1559,31 +1568,31 @@ def __init_algebraic_structs(self, E): EXAMPLES:: - sage: E = EllipticCurve(j=GF(17)(0)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((-1,0))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(17)(0)) + sage: phi = EllipticCurveIsogeny(E, E((-1,0))) The constructor calls this function itself, so the fields it sets are already defined:: - sage: phi._domain # optional - sage.rings.finite_rings + sage: phi._domain Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__base_field # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__base_field Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__poly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__poly_ring Univariate Polynomial Ring in x over Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__mpoly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__mpoly_ring Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Finite Field of size 17 Now, calling the initialization function does nothing more:: - sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) # optional - sage.rings.finite_rings - sage: phi._domain # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) + sage: phi._domain Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__base_field # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__base_field Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__poly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__poly_ring Univariate Polynomial Ring in x over Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__mpoly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__mpoly_ring Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Finite Field of size 17 sage: E = EllipticCurve(QQ, [0,0,0,1,0]) @@ -1598,17 +1607,17 @@ def __init_algebraic_structs(self, E): sage: phi._EllipticCurveIsogeny__mpoly_ring Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field - sage: F = GF(19); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=GF(19)(0)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) # optional - sage.rings.finite_rings - sage: phi._domain # optional - sage.rings.finite_rings + sage: F = GF(19); R. = F[] + sage: E = EllipticCurve(j=GF(19)(0)) + sage: phi = EllipticCurveIsogeny(E, x) + sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) + sage: phi._domain Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 19 - sage: phi._EllipticCurveIsogeny__base_field # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__base_field Finite Field of size 19 - sage: phi._EllipticCurveIsogeny__poly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__poly_ring Univariate Polynomial Ring in x over Finite Field of size 19 - sage: phi._EllipticCurveIsogeny__mpoly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__mpoly_ring Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Finite Field of size 19 """ self._domain = E @@ -1628,17 +1637,17 @@ def __compute_codomain(self): These examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__compute_codomain() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_codomain() - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi = EllipticCurveIsogeny(E, x) + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__compute_codomain() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_codomain() """ if self.__algorithm == 'velu': self._codomain = self.__compute_codomain_via_velu() @@ -1661,14 +1670,14 @@ def __initialize_rational_maps(self, precomputed_maps=None): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # implicit doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.rational_maps() # implicit doctest ((x^2 + 1)/x, (x^2*y - y)/x^2) - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # implicit doctest # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi = EllipticCurveIsogeny(E, x) + sage: phi.rational_maps() # implicit doctest ((x^2 + 1)/x, (x^2*y - y)/x^2) sage: E = EllipticCurve([1,2,3,4,5]) @@ -1717,9 +1726,9 @@ def __init_kernel_polynomial(self): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.kernel_polynomial() # implicit doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.kernel_polynomial() # implicit doctest x """ if self.__kernel_polynomial is None: @@ -1735,16 +1744,16 @@ def __set_pre_isomorphism(self, domain, isomorphism): EXAMPLES:: - sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) # optional - sage.rings.finite_rings - sage: R. = GF(43)[]; f = x + 42 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) + sage: R. = GF(43)[]; f = x + 42 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain() # optional - sage.rings.finite_rings - sage: pre_isom = E1pr.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_pre_isomorphism(pre_isom) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__set_pre_isomorphism(E, WeierstrassIsomorphism(E, (-1, 3, -3, 4))) # optional - sage.rings.finite_rings - sage: E == phi.domain() # optional - sage.rings.finite_rings + sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain() + sage: pre_isom = E1pr.isomorphism_to(E) + sage: phi._set_pre_isomorphism(pre_isom) + sage: phi._EllipticCurveIsogeny__set_pre_isomorphism(E, WeierstrassIsomorphism(E, (-1, 3, -3, 4))) + sage: E == phi.domain() True """ self._domain = domain @@ -1779,14 +1788,14 @@ def __set_post_isomorphism(self, codomain, isomorphism): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: isom = WeierstrassIsomorphism(E2, (-1,2,-3,4)) # optional - sage.rings.finite_rings - sage: phi._set_post_isomorphism(isom) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__set_post_isomorphism(E2, WeierstrassIsomorphism(phi.codomain(), (1,-2,3,-4))) # optional - sage.rings.finite_rings - sage: E2 == phi.codomain() # optional - sage.rings.finite_rings + sage: E2 = phi.codomain() + sage: isom = WeierstrassIsomorphism(E2, (-1,2,-3,4)) + sage: phi._set_post_isomorphism(isom) + sage: phi._EllipticCurveIsogeny__set_post_isomorphism(E2, WeierstrassIsomorphism(phi.codomain(), (1,-2,3,-4))) + sage: E2 == phi.codomain() True """ self._codomain = codomain @@ -1815,20 +1824,20 @@ def __setup_post_isomorphism(self, codomain, model): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: E2 = EllipticCurve(GF(7), [0,0,0,5,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0)), E2); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: E2 = EllipticCurve(GF(7), [0,0,0,5,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0)), E2); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 7 - sage: E3 = EllipticCurve(GF(7), [0,0,0,6,0]) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__setup_post_isomorphism(E3, None) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: E3 = EllipticCurve(GF(7), [0,0,0,6,0]) + sage: phi._EllipticCurveIsogeny__setup_post_isomorphism(E3, None) + sage: phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 - sage: EllipticCurveIsogeny(E, E(0,0), model='montgomery') # optional - sage.rings.finite_rings + sage: EllipticCurveIsogeny(E, E(0,0), model='montgomery') Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + x^2 + x over Finite Field of size 7 @@ -1887,22 +1896,23 @@ def __init_from_kernel_list(self, kernel_gens): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__init_from_kernel_list([E(0), E((0,0))]) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_from_kernel_list([E(0), E((0,0))]) The following example demonstrates the necessity of avoiding any calls to P.order(), since such calls involve factoring the group order which could take a long time. :: - sage: p = 12 * next_prime(2^180) * next_prime(2^194) - 1 # optional - sage.rings.finite_rings - sage: F = FiniteField(p, proof=False) # optional - sage.rings.finite_rings - sage: E = EllipticCurve([F(1), F(0)]) # optional - sage.rings.finite_rings - sage: P = E(0).division_points(3)[1] # optional - sage.rings.finite_rings - sage: EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = 12 * next_prime(2^180) * next_prime(2^194) - 1 + sage: F = FiniteField(p, proof=False) + sage: E = EllipticCurve([F(1), F(0)]) + sage: P = E(0).division_points(3)[1] + sage: EllipticCurveIsogeny(E, P) Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 461742260113997803268895001173557974278278194575766957660028841364655249961609425998827452443620996655395008156411 @@ -1949,13 +1959,13 @@ def __sort_kernel_list(self): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P); phi Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__sort_kernel_list() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__sort_kernel_list() """ a1, a2, a3, a4, _ = self._domain.a_invariants() @@ -2001,12 +2011,12 @@ def __compute_codomain_via_velu(self): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__compute_codomain_via_velu() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_codomain_via_velu() Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 """ return compute_codomain_formula(self._domain, self.__v, self.__w) @@ -2021,22 +2031,22 @@ def __velu_sum_helper(xQ, Qvalues, a1, a3, x, y): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: Q = E((0,0)); phi(Q) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: Q = E((0,0)); phi(Q) (0 : 0 : 1) - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) - sage: F = GF(7) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) # optional - sage.rings.finite_rings - sage: Qvals = phi._EllipticCurveIsogeny__kernel_mod_sign[0] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__velu_sum_helper(0, Qvals, 0, 0, F(5), F(5)) # optional - sage.rings.finite_rings + sage: F = GF(7) + sage: E = EllipticCurve(F, [0,0,0,1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) + sage: Qvals = phi._EllipticCurveIsogeny__kernel_mod_sign[0] + sage: phi._EllipticCurveIsogeny__velu_sum_helper(0, Qvals, 0, 0, F(5), F(5)) (3, 3) - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__velu_sum_helper(0, Qvals, 0, 0, x, y) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi._EllipticCurveIsogeny__velu_sum_helper(0, Qvals, 0, 0, x, y) (1/x, y/x^2) """ yQ, gxQ, gyQ, vQ, uQ = Qvalues @@ -2069,17 +2079,17 @@ def __compute_via_velu_numeric(self, xP, yP): The following example inherently exercises this function:: - sage: F = GF(7) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: Q = E((0,0)); phi(Q) # optional - sage.rings.finite_rings + sage: F = GF(7) + sage: E = EllipticCurve(F, [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: Q = E((0,0)); phi(Q) (0 : 0 : 1) - sage: Q = E((-1,0)); phi(Q) # optional - sage.rings.finite_rings + sage: Q = E((-1,0)); phi(Q) (0 : 0 : 1) - sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(0), F(0)) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(0), F(0)) (0, 0) - sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(-1), F(0)) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(-1), F(0)) (0, 0) """ # first check if the point is in the kernel @@ -2096,18 +2106,18 @@ def __compute_via_velu(self, xP, yP): The following example inherently exercises this function:: - sage: F = GF(7) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: Q = E((0,0)); phi(Q) # optional - sage.rings.finite_rings + sage: F = GF(7) + sage: E = EllipticCurve(F, [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: Q = E((0,0)); phi(Q) (0 : 0 : 1) - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) - sage: phi._EllipticCurveIsogeny__compute_via_velu(F(0), F(0)) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_velu(F(0), F(0)) (0, 0) - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__compute_via_velu(x, y) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi._EllipticCurveIsogeny__compute_via_velu(x, y) ((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) @@ -2115,24 +2125,26 @@ def __compute_via_velu(self, xP, yP): Check for :trac:`33214`:: - sage: z2 = GF(71^2).gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(71^2), [5,5]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(0)) # optional - sage.rings.finite_rings - sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism # optional - sage.rings.finite_rings - sage: pre = WeierstrassIsomorphism(None, (z2,7,8,9), E) # optional - sage.rings.finite_rings - sage: phi = phi * pre # optional - sage.rings.finite_rings - sage: P = phi.domain()(1, 46*z2+49) # optional - sage.rings.finite_rings - sage: phi(P) # indirect doctest # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: z2 = GF(71^2).gen() + sage: E = EllipticCurve(GF(71^2), [5,5]) + sage: phi = E.isogeny(E.lift_x(0)) + sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism + sage: pre = WeierstrassIsomorphism(None, (z2,7,8,9), E) + sage: phi = phi * pre + sage: P = phi.domain()(1, 46*z2+49) + sage: phi(P) # indirect doctest (33 : 61*z2 + 10 : 1) The rational maps are also computed via this code path; check that they are plausible (this failed prior to :trac:`33214`):: - sage: fx,fy = phi.rational_maps() # indirect doctest # optional - sage.rings.finite_rings - sage: R. = GF(71^2)[] # optional - sage.rings.finite_rings - sage: E0, E2 = phi.domain(), phi.codomain() # optional - sage.rings.finite_rings - sage: eqs = [EE.defining_polynomial()(x,y,1) for EE in (E0,E2)] # optional - sage.rings.finite_rings - sage: eqs[1](fx,fy).numerator() % eqs[0] # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: fx,fy = phi.rational_maps() # indirect doctest + sage: R. = GF(71^2)[] + sage: E0, E2 = phi.domain(), phi.codomain() + sage: eqs = [EE.defining_polynomial()(x,y,1) for EE in (E0,E2)] + sage: eqs[1](fx,fy).numerator() % eqs[0] 0 """ if self.__pre_isomorphism is None: @@ -2162,12 +2174,12 @@ def __initialize_rational_maps_via_velu(self): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: phi.rational_maps() ((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) - sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_velu() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_velu() ((x^4 + 5*x^3 + x^2 + 4*x)/(x^3 + 5*x^2 + 3*x + 5), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) """ x = self.__poly_ring.gen() @@ -2183,10 +2195,10 @@ def __init_kernel_polynomial_velu(self): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: phi.kernel_polynomial() # implicit doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: phi.kernel_polynomial() # implicit doctest x^2 + 2*x + 4 """ poly_ring, x = self.__poly_ring.objgen() @@ -2216,22 +2228,22 @@ def __init_from_kernel_polynomial(self, kernel_polynomial): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x);phi # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: phi = EllipticCurveIsogeny(E, x);phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x) - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x+6) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x+6) """ poly_ring = self.__poly_ring E = self._domain @@ -2317,39 +2329,39 @@ def __init_even_kernel_polynomial(self, E, psi_G): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [-1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x); phi # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [-1,0]) + sage: phi = EllipticCurveIsogeny(E, x); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import two_torsion_part - sage: psig = two_torsion_part(E,x) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) # optional - sage.rings.finite_rings + sage: psig = two_torsion_part(E,x) + sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) (x^3 + 6*x, (x^3 + x)*y, 6, 0, 1, 2) - sage: F = GF(2^4, 'alpha'); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1,0,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x); phi # optional - sage.rings.finite_rings + sage: F = GF(2^4, 'alpha'); R. = F[] # needs sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1,0,1,0]) # needs sage.rings.finite_rings + sage: phi = EllipticCurveIsogeny(E, x); phi # needs sage.rings.finite_rings Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + x over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 1 over Finite Field in alpha of size 2^4 - sage: psig = two_torsion_part(E,x) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) # optional - sage.rings.finite_rings + sage: psig = two_torsion_part(E,x) # needs sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) # needs sage.rings.finite_rings (x^3 + x, (x^3 + x)*y + x^2, 1, 0, 1, 2) - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: f = x^3 + 6*x^2 + 1 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: R. = GF(7)[] + sage: f = x^3 + 6*x^2 + 1 + sage: phi = EllipticCurveIsogeny(E, f); phi Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 2*x + 5 over Finite Field of size 7 - sage: psig = two_torsion_part(E,f) # optional - sage.rings.finite_rings - sage: psig = two_torsion_part(E,f) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) # optional - sage.rings.finite_rings + sage: psig = two_torsion_part(E,f) + sage: psig = two_torsion_part(E,f) + sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) (x^7 + 5*x^6 + 2*x^5 + 6*x^4 + 3*x^3 + 5*x^2 + 6*x + 3, (x^9 + 4*x^8 + 2*x^7 + 4*x^3 + 2*x^2 + x + 6)*y, 1, 6, 3, 4) """ # check if the polynomial really divides the two_torsion_polynomial @@ -2434,36 +2446,37 @@ def __init_odd_kernel_polynomial(self, E, psi): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, x+6) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, x+6) (x^3 + 5*x^2 + 3*x + 2, (x^3 + 4*x^2 + x)*y, 2, 6, 1, 3) - sage: F = GF(2^4, 'alpha'); R. = F[] # optional - sage.rings.finite_rings - sage: alpha = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1,F.gen(),F.gen()^2+1,1]) # optional - sage.rings.finite_rings - sage: f = x + alpha^2 + 1 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f); phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(2^4, 'alpha'); R. = F[] + sage: alpha = F.gen() + sage: E = EllipticCurve(F, [1,1,F.gen(),F.gen()^2+1,1]) + sage: f = x + alpha^2 + 1 + sage: phi = EllipticCurveIsogeny(E, f); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + (alpha^2+1)*x + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + alpha*x + alpha^3 over Finite Field in alpha of size 2^4 - sage: R. = F[] # optional - sage.rings.finite_rings - sage: f = x + alpha^2 + 1 # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, f) # optional - sage.rings.finite_rings + sage: R. = F[] # needs sage.rings.finite_rings + sage: f = x + alpha^2 + 1 # needs sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, f) # needs sage.rings.finite_rings (x^3 + (alpha^2 + 1)*x + alpha^3 + alpha^2 + alpha, (x^3 + (alpha^2 + 1)*x^2 + (alpha^2 + 1)*x + alpha)*y + (alpha^2 + alpha + 1)*x^2 + (alpha^2 + alpha)*x + alpha, alpha^2 + alpha + 1, alpha^3 + alpha^2 + alpha, 1, 3) - sage: E = EllipticCurve(j=-262537412640768000) # optional - sage.rings.finite_rings - sage: f = E.isogenies_prime_degree()[0].kernel_polynomial() # optional - sage.rings.finite_rings - sage: f.degree() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=-262537412640768000) + sage: f = E.isogenies_prime_degree()[0].kernel_polynomial() + sage: f.degree() 81 - sage: E.isogeny(kernel=f, check=False) # optional - sage.rings.finite_rings + sage: E.isogeny(kernel=f, check=False) Isogeny of degree 163 from Elliptic Curve defined by y^2 + y = x^3 - 2174420*x + 1234136692 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 57772164980*x - 5344733777551611 over Rational Field @@ -2536,19 +2549,19 @@ def __compute_omega_fast(self, E, psi, psi_pr, phi, phi_pr): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: psi = phi._EllipticCurveIsogeny__psi # optional - sage.rings.finite_rings - sage: psi_pr = psi.derivative() # optional - sage.rings.finite_rings - sage: fi = phi._EllipticCurveIsogeny__phi # optional - sage.rings.finite_rings - sage: fi_pr = fi.derivative() # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__compute_omega_fast(E, psi, psi_pr, fi, fi_pr) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: psi = phi._EllipticCurveIsogeny__psi + sage: psi_pr = psi.derivative() + sage: fi = phi._EllipticCurveIsogeny__phi + sage: fi_pr = fi.derivative() + sage: phi._EllipticCurveIsogeny__compute_omega_fast(E, psi, psi_pr, fi, fi_pr) (x^3 + 4*x^2 + x)*y """ a1 = E.a1() @@ -2586,32 +2599,35 @@ def __compute_omega_general(self, E, psi, psi_pr, phi, phi_pr): These examples inherently exercise this private function:: - sage: F = GF(2^4, 'alpha'); R. = F[] # optional - sage.rings.finite_rings - sage: alpha = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1, 1, F.gen(), F.gen()^2+1, 1]) # optional - sage.rings.finite_rings - sage: f = x + alpha^2 + 1 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f); phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(2^4, 'alpha'); R. = F[] + sage: alpha = F.gen() + sage: E = EllipticCurve(F, [1, 1, F.gen(), F.gen()^2+1, 1]) + sage: f = x + alpha^2 + 1 + sage: phi = EllipticCurveIsogeny(E, f); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + (alpha^2+1)*x + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + alpha*x + alpha^3 over Finite Field in alpha of size 2^4 - sage: R. = F[] # optional - sage.rings.finite_rings - sage: psi = phi._EllipticCurveIsogeny__psi # optional - sage.rings.finite_rings - sage: psi_pr = psi.derivative() # optional - sage.rings.finite_rings - sage: fi = phi._EllipticCurveIsogeny__phi # optional - sage.rings.finite_rings - sage: fi_pr = fi.derivative() # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__compute_omega_general(E, psi, psi_pr, fi, fi_pr) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = F[] + sage: psi = phi._EllipticCurveIsogeny__psi + sage: psi_pr = psi.derivative() + sage: fi = phi._EllipticCurveIsogeny__phi + sage: fi_pr = fi.derivative() + sage: phi._EllipticCurveIsogeny__compute_omega_general(E, psi, psi_pr, fi, fi_pr) (x^3 + (alpha^2 + 1)*x^2 + (alpha^2 + 1)*x + alpha)*y + (alpha^2 + alpha + 1)*x^2 + (alpha^2 + alpha)*x + alpha A bug fixed in :trac:`7907`:: - sage: F = GF(128,'a') # optional - sage.rings.finite_rings - sage: a = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve([1,0,0,0,(a**6+a**4+a**2+a)]) # optional - sage.rings.finite_rings - sage: x = polygen(F) # optional - sage.rings.finite_rings - sage: ker = (x^6 + (a^6 + a^5 + a^4 + a^3 + a^2 + a)*x^5 + (a^6 + a^5 + a^2 + 1)*x^4 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(128,'a') + sage: a = F.gen() + sage: E = EllipticCurve([1,0,0,0,(a**6+a**4+a**2+a)]) + sage: x = polygen(F) + sage: ker = (x^6 + (a^6 + a^5 + a^4 + a^3 + a^2 + a)*x^5 + (a^6 + a^5 + a^2 + 1)*x^4 ....: + (a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^3 + (a^6 + a^3 + a)*x^2 + (a^4 + a^3 + 1)*x + a^5 + a^4 + a) - sage: E.isogeny(ker) # optional - sage.rings.finite_rings + sage: E.isogeny(ker) Isogeny of degree 13 from Elliptic Curve defined by y^2 + x*y = x^3 + (a^6+a^4+a^2+a) over Finite Field in a of size 2^7 to Elliptic Curve defined by y^2 + x*y = x^3 + (a^6+a^5+a^4+a^3+a^2+a)*x + (a^5+a^3) over Finite Field in a of size 2^7 @@ -2668,16 +2684,16 @@ def __compute_via_kohel_numeric(self, xP, yP): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) # optional - sage.rings.finite_rings - sage: P = E((0,1)); phi(P) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) + sage: P = E((0,1)); phi(P) (2 : 0 : 1) - sage: P = E((1,1)); phi(P) # optional - sage.rings.finite_rings + sage: P = E((1,1)); phi(P) (0 : 1 : 0) - sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(0, 1) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(0, 1) (2, 0) - sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(1, 1) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(1, 1) () """ # first check if the point is in the kernel @@ -2694,17 +2710,17 @@ def __compute_via_kohel(self, xP, yP): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) # optional - sage.rings.finite_rings - sage: P = E((0,1)); phi(P) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) + sage: P = E((0,1)); phi(P) (2 : 0 : 1) - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) - sage: phi._EllipticCurveIsogeny__compute_via_kohel(0,1) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_kohel(0,1) (2, 0) - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__compute_via_kohel(x,y) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi._EllipticCurveIsogeny__compute_via_kohel(x,y) ((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) """ a = self.__phi(xP) @@ -2723,12 +2739,12 @@ def __initialize_rational_maps_via_kohel(self): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) + sage: phi.rational_maps() ((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) - sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_kohel() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_kohel() ((x^3 + 5*x^2 + 3*x + 2)/(x^2 + 5*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) """ x = self.__poly_ring.gen() @@ -2747,12 +2763,12 @@ def __compute_codomain_via_kohel(self): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__compute_codomain_via_kohel() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_codomain_via_kohel() Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 """ return compute_codomain_formula(self._domain, self.__v, self.__w) @@ -2780,9 +2796,9 @@ def rational_maps(self): sage: phi.rational_maps() (x, y) - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.rational_maps() ((x^2 + 3)/x, (x^2*y - 3*y)/x^2) """ self.__initialize_rational_maps() @@ -2807,9 +2823,9 @@ def x_rational_map(self): sage: phi.x_rational_map() x - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.x_rational_map() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.x_rational_map() (x^2 + 3)/x """ self.__initialize_rational_maps() @@ -2828,13 +2844,14 @@ def scaling_factor(self): EXAMPLES:: - sage: E = EllipticCurve(GF(257^2), [0,1]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(240)) # optional - sage.rings.finite_rings - sage: phi.degree() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(257^2), [0,1]) + sage: phi = E.isogeny(E.lift_x(240)) + sage: phi.degree() 43 - sage: phi.scaling_factor() # optional - sage.rings.finite_rings + sage: phi.scaling_factor() 1 - sage: phi.dual().scaling_factor() # optional - sage.rings.finite_rings + sage: phi.dual().scaling_factor() 43 ALGORITHM: The "inner" isogeny is normalized by construction, @@ -2864,14 +2881,14 @@ def kernel_polynomial(self): sage: phi.kernel_polynomial() x^2 - 21*x + 80 - sage: E = EllipticCurve(GF(17), [1,-1,1,-1,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [1]) # optional - sage.rings.finite_rings - sage: phi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [1,-1,1,-1,1]) + sage: phi = EllipticCurveIsogeny(E, [1]) + sage: phi.kernel_polynomial() 1 - sage: E = EllipticCurve(GF(31), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [0,3,0,1]) # optional - sage.rings.finite_rings - sage: phi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, [0,3,0,1]) + sage: phi.kernel_polynomial() x^3 + 3*x """ if self.__kernel_polynomial is None: @@ -2887,9 +2904,9 @@ def is_separable(self): EXAMPLES:: - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.is_separable() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.is_separable() True :: @@ -2910,45 +2927,45 @@ def _set_pre_isomorphism(self, preWI): TESTS:: - sage: E = EllipticCurve(GF(31), [1,1,0,1,-1]) # optional - sage.rings.finite_rings - sage: R. = GF(31)[] # optional - sage.rings.finite_rings - sage: f = x^3 + 9*x^2 + x + 30 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: Epr = E.short_weierstrass_model() # optional - sage.rings.finite_rings - sage: isom = Epr.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_pre_isomorphism(isom) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [1,1,0,1,-1]) + sage: R. = GF(31)[] + sage: f = x^3 + 9*x^2 + x + 30 + sage: phi = EllipticCurveIsogeny(E, f) + sage: Epr = E.short_weierstrass_model() + sage: isom = Epr.isomorphism_to(E) + sage: phi._set_pre_isomorphism(isom) + sage: phi.rational_maps() ((-6*x^4 - 3*x^3 + 12*x^2 + 10*x - 1)/(x^3 + x - 12), (3*x^7 + x^6*y - 14*x^6 - 3*x^5 + 5*x^4*y + 7*x^4 + 8*x^3*y - 8*x^3 - 5*x^2*y + 5*x^2 - 14*x*y + 14*x - 6*y - 6)/(x^6 + 2*x^4 + 7*x^3 + x^2 + 7*x - 11)) - sage: phi(Epr((0,22))) # optional - sage.rings.finite_rings + sage: phi(Epr((0,22))) (13 : 21 : 1) - sage: phi(Epr((3,7))) # optional - sage.rings.finite_rings + sage: phi(Epr((3,7))) (14 : 17 : 1) - sage: E = EllipticCurve(GF(29), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: R. = GF(29)[] # optional - sage.rings.finite_rings - sage: f = x^2 + 5 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(29), [0,0,0,1,0]) + sage: R. = GF(29)[] + sage: f = x^2 + 5 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 20*x over Finite Field of size 29 sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: inv_isom = WeierstrassIsomorphism(E, (1,-2,5,10)) # optional - sage.rings.finite_rings - sage: Epr = inv_isom.codomain() # optional - sage.rings.finite_rings - sage: isom = Epr.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_pre_isomorphism(isom) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: inv_isom = WeierstrassIsomorphism(E, (1,-2,5,10)) + sage: Epr = inv_isom.codomain() + sage: isom = Epr.isomorphism_to(E) + sage: phi._set_pre_isomorphism(isom) + sage: phi Isogeny of degree 5 from Elliptic Curve defined by y^2 + 10*x*y + 20*y = x^3 + 27*x^2 + 6 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 20*x over Finite Field of size 29 - sage: phi(Epr((12,1))) # optional - sage.rings.finite_rings + sage: phi(Epr((12,1))) (26 : 0 : 1) - sage: phi(Epr((2,9))) # optional - sage.rings.finite_rings + sage: phi(Epr((2,9))) (0 : 0 : 1) - sage: phi(Epr((21,12))) # optional - sage.rings.finite_rings + sage: phi(Epr((21,12))) (3 : 0 : 1) - sage: phi.rational_maps()[0] # optional - sage.rings.finite_rings + sage: phi.rational_maps()[0] (x^5 - 10*x^4 - 6*x^3 - 7*x^2 - x + 3)/(x^4 - 8*x^3 + 5*x^2 - 14*x - 6) sage: E = EllipticCurve('11a1') @@ -2998,26 +3015,26 @@ def _set_post_isomorphism(self, postWI): TESTS:: - sage: E = EllipticCurve(j=GF(31)(0)) # optional - sage.rings.finite_rings - sage: R. = GF(31)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+18) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(31)(0)) + sage: R. = GF(31)[] + sage: phi = EllipticCurveIsogeny(E, x+18) sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: phi._set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (6,8,10,12))) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: phi._set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (6,8,10,12))) + sage: phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 31 to Elliptic Curve defined by y^2 + 24*x*y + 7*y = x^3 + 22*x^2 + 16*x + 20 over Finite Field of size 31 - sage: E = EllipticCurve(j=GF(47)(0)) # optional - sage.rings.finite_rings - sage: f = E.torsion_polynomial(3)/3 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: post_isom = E2.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_post_isomorphism(post_isom) # optional - sage.rings.finite_rings - sage: phi.rational_maps() == E.multiplication_by_m(3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(47)(0)) + sage: f = E.torsion_polynomial(3)/3 + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: post_isom = E2.isomorphism_to(E) + sage: phi._set_post_isomorphism(post_isom) + sage: phi.rational_maps() == E.multiplication_by_m(3) False - sage: phi = -phi # optional - sage.rings.finite_rings - sage: phi.rational_maps() == E.multiplication_by_m(3) # optional - sage.rings.finite_rings + sage: phi = -phi + sage: phi.rational_maps() == E.multiplication_by_m(3) True sage: R. = QQ[] @@ -3083,49 +3100,50 @@ def dual(self): sage: (Xm, Ym) == E.multiplication_by_m(5) True - sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(37)[] # optional - sage.rings.finite_rings - sage: f = x^3 + x^2 + 28*x + 33 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi_hat = phi.dual() # optional - sage.rings.finite_rings - sage: phi_hat.codomain() == phi.domain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) + sage: R. = GF(37)[] + sage: f = x^3 + x^2 + 28*x + 33 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi_hat = phi.dual() + sage: phi_hat.codomain() == phi.domain() True - sage: phi_hat.domain() == phi.codomain() # optional - sage.rings.finite_rings + sage: phi_hat.domain() == phi.codomain() True - sage: (X, Y) = phi.rational_maps() # optional - sage.rings.finite_rings - sage: (Xhat, Yhat) = phi_hat.rational_maps() # optional - sage.rings.finite_rings - sage: Xm = Xhat.subs(x=X, y=Y) # optional - sage.rings.finite_rings - sage: Ym = Yhat.subs(x=X, y=Y) # optional - sage.rings.finite_rings - sage: (Xm, Ym) == E.multiplication_by_m(7) # optional - sage.rings.finite_rings + sage: (X, Y) = phi.rational_maps() + sage: (Xhat, Yhat) = phi_hat.rational_maps() + sage: Xm = Xhat.subs(x=X, y=Y) + sage: Ym = Yhat.subs(x=X, y=Y) + sage: (Xm, Ym) == E.multiplication_by_m(7) True - sage: E = EllipticCurve(GF(31), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(31)[] # optional - sage.rings.finite_rings - sage: f = x^2 + 17*x + 29 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi_hat = phi.dual() # optional - sage.rings.finite_rings - sage: phi_hat.codomain() == phi.domain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [0,0,0,1,8]) + sage: R. = GF(31)[] + sage: f = x^2 + 17*x + 29 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi_hat = phi.dual() + sage: phi_hat.codomain() == phi.domain() True - sage: phi_hat.domain() == phi.codomain() # optional - sage.rings.finite_rings + sage: phi_hat.domain() == phi.codomain() True - sage: (X, Y) = phi.rational_maps() # optional - sage.rings.finite_rings - sage: (Xhat, Yhat) = phi_hat.rational_maps() # optional - sage.rings.finite_rings - sage: Xm = Xhat.subs(x=X, y=Y) # optional - sage.rings.finite_rings - sage: Ym = Yhat.subs(x=X, y=Y) # optional - sage.rings.finite_rings - sage: (Xm, Ym) == E.multiplication_by_m(5) # optional - sage.rings.finite_rings + sage: (X, Y) = phi.rational_maps() + sage: (Xhat, Yhat) = phi_hat.rational_maps() + sage: Xm = Xhat.subs(x=X, y=Y) + sage: Ym = Yhat.subs(x=X, y=Y) + sage: (Xm, Ym) == E.multiplication_by_m(5) True Inseparable duals should be computed correctly:: - sage: z2 = GF(71^2).gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=57*z2+51) # optional - sage.rings.finite_rings - sage: E.isogeny(3*E.lift_x(0)).dual() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: z2 = GF(71^2).gen() + sage: E = EllipticCurve(j=57*z2+51) + sage: E.isogeny(3*E.lift_x(0)).dual() Composite morphism of degree 71 = 71*1^2: From: Elliptic Curve defined by y^2 = x^3 + (32*z2+67)*x + (24*z2+37) over Finite Field in z2 of size 71^2 To: Elliptic Curve defined by y^2 = x^3 + (41*z2+56)*x + (18*z2+42) over Finite Field in z2 of size 71^2 - sage: E.isogeny(E.lift_x(0)).dual() # optional - sage.rings.finite_rings + sage: E.isogeny(E.lift_x(0)).dual() Composite morphism of degree 213 = 71*3: From: Elliptic Curve defined by y^2 = x^3 + (58*z2+31)*x + (34*z2+58) over Finite Field in z2 of size 71^2 @@ -3134,12 +3152,13 @@ def dual(self): ...even if pre- or post-isomorphisms are present:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: phi = E.isogeny(E.lift_x(0)) # optional - sage.rings.finite_rings - sage: pre = ~WeierstrassIsomorphism(phi.domain(), (z2,2,3,4)) # optional - sage.rings.finite_rings - sage: post = WeierstrassIsomorphism(phi.codomain(), (5,6,7,8)) # optional - sage.rings.finite_rings - sage: phi = post * phi * pre # optional - sage.rings.finite_rings - sage: phi.dual() # optional - sage.rings.finite_rings + sage: phi = E.isogeny(E.lift_x(0)) + sage: pre = ~WeierstrassIsomorphism(phi.domain(), (z2,2,3,4)) + sage: post = WeierstrassIsomorphism(phi.codomain(), (5,6,7,8)) + sage: phi = post * phi * pre + sage: phi.dual() Composite morphism of degree 213 = 71*3: From: Elliptic Curve defined by y^2 + 17*x*y + 45*y = x^3 + 30*x^2 + (6*z2+64)*x + (48*z2+65) @@ -3153,9 +3172,9 @@ def dual(self): Test for :trac:`23928`:: - sage: E = EllipticCurve(j=GF(431**2)(4)) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(0)) # optional - sage.rings.finite_rings - sage: phi.dual() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(431**2)(4)) # needs sage.rings.finite_rings + sage: phi = E.isogeny(E.lift_x(0)) # needs sage.rings.finite_rings + sage: phi.dual() # needs sage.rings.finite_rings Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 427*x over Finite Field in z2 of size 431^2 to Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 431^2 @@ -3167,34 +3186,35 @@ def dual(self): sage: phi.dual().dual() == phi True - sage: k = GF(103) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k,[11,11]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E(4,4)) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: k = GF(103) + sage: E = EllipticCurve(k,[11,11]) + sage: phi = E.isogeny(E(4,4)) + sage: phi Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x + 11 over Finite Field of size 103 to Elliptic Curve defined by y^2 = x^3 + 25*x + 80 over Finite Field of size 103 sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: phi = WeierstrassIsomorphism(phi.codomain(),(5,0,1,2)) * phi # optional - sage.rings.finite_rings - sage: phi.dual().dual() == phi # optional - sage.rings.finite_rings + sage: phi = WeierstrassIsomorphism(phi.codomain(),(5,0,1,2)) * phi + sage: phi.dual().dual() == phi True - sage: E = EllipticCurve(GF(103),[1,0,0,1,-1]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E(60,85)) # optional - sage.rings.finite_rings - sage: phi.dual() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(103),[1,0,0,1,-1]) + sage: phi = E.isogeny(E(60,85)) + sage: phi.dual() Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 + 84*x + 34 over Finite Field of size 103 to Elliptic Curve defined by y^2 + x*y = x^3 + x + 102 over Finite Field of size 103 Check that :trac:`17293` is fixed:: - sage: k. = QuadraticField(2) # optional - sage.rings.number_field - sage: E = EllipticCurve(k, [-3*s*(4 + 5*s), 2*s*(2 + 14*s + 11*s^2)]) # optional - sage.rings.number_field - sage: phi = E.isogenies_prime_degree(3)[0] # optional - sage.rings.number_field - sage: (-phi).dual() == -phi.dual() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: k. = QuadraticField(2) + sage: E = EllipticCurve(k, [-3*s*(4 + 5*s), 2*s*(2 + 14*s + 11*s^2)]) + sage: phi = E.isogenies_prime_degree(3)[0] + sage: (-phi).dual() == -phi.dual() True - sage: phi._EllipticCurveIsogeny__clear_cached_values() # forget the dual # optional - sage.rings.number_field - sage: -phi.dual() == (-phi).dual() # optional - sage.rings.number_field + sage: phi._EllipticCurveIsogeny__clear_cached_values() # forget the dual + sage: -phi.dual() == (-phi).dual() True """ if self.__base_field.characteristic() in (2, 3): @@ -3286,19 +3306,19 @@ def _composition_impl(left, right): EXAMPLES:: - sage: E = EllipticCurve(GF(127), [5,2]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(47)); E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: iso1 = E.change_weierstrass_model(1,1,1,1).isomorphism_to(E) # optional - sage.rings.finite_rings - sage: iso2 = E2.isomorphism_to(E2.change_weierstrass_model(39,0,0,0)) # optional - sage.rings.finite_rings - sage: phi * iso1 # indirect doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(127), [5,2]) + sage: phi = E.isogeny(E.lift_x(47)); E2 = phi.codomain() + sage: iso1 = E.change_weierstrass_model(1,1,1,1).isomorphism_to(E) + sage: iso2 = E2.isomorphism_to(E2.change_weierstrass_model(39,0,0,0)) + sage: phi * iso1 # indirect doctest Isogeny of degree 11 from Elliptic Curve defined by y^2 + 2*x*y + 2*y = x^3 + 2*x^2 + 6*x + 7 over Finite Field of size 127 to Elliptic Curve defined by y^2 = x^3 + 37*x + 85 over Finite Field of size 127 - sage: iso2 * phi # indirect doctest # optional - sage.rings.finite_rings + sage: iso2 * phi # indirect doctest Isogeny of degree 11 from Elliptic Curve defined by y^2 = x^3 + 5*x + 2 over Finite Field of size 127 to Elliptic Curve defined by y^2 = x^3 + 117*x + 58 over Finite Field of size 127 - sage: iso2 * phi * iso1 # indirect doctest # optional - sage.rings.finite_rings + sage: iso2 * phi * iso1 # indirect doctest Isogeny of degree 11 from Elliptic Curve defined by y^2 + 2*x*y + 2*y = x^3 + 2*x^2 + 6*x + 7 over Finite Field of size 127 to Elliptic Curve defined by y^2 = x^3 + 117*x + 58 over Finite Field of size 127 @@ -3308,7 +3328,7 @@ def _composition_impl(left, right): We should return ``NotImplemented`` when passed a combination of elliptic-curve morphism types that we don't handle here:: - sage: phi._composition_impl(iso1, iso1**-1) # optional - sage.rings.finite_rings + sage: phi._composition_impl(iso1, iso1**-1) NotImplemented """ if isinstance(left, WeierstrassIsomorphism) and isinstance(right, EllipticCurveIsogeny): @@ -3363,22 +3383,22 @@ def compute_isogeny_stark(E1, E2, ell): sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_stark, compute_sequence_of_maps - sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) # optional - sage.rings.finite_rings - sage: R. = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: isom1, isom2, E1pr, E2pr, ker_poly = compute_sequence_of_maps(E, E2, 11) # optional - sage.rings.finite_rings - sage: compute_isogeny_stark(E1pr, E2pr, 11) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) + sage: R. = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: isom1, isom2, E1pr, E2pr, ker_poly = compute_sequence_of_maps(E, E2, 11) + sage: compute_isogeny_stark(E1pr, E2pr, 11) x^10 + 37*x^9 + 53*x^8 + 66*x^7 + 66*x^6 + 17*x^5 + 57*x^4 + 6*x^3 + 89*x^2 + 53*x + 8 - sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(37)[] # optional - sage.rings.finite_rings - sage: f = (x + 14) * (x + 30) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: compute_isogeny_stark(E, E2, 5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) + sage: R. = GF(37)[] + sage: f = (x + 14) * (x + 30) + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: compute_isogeny_stark(E, E2, 5) x^4 + 14*x^3 + x^2 + 34*x + 21 - sage: f**2 # optional - sage.rings.finite_rings + sage: f**2 x^4 + 14*x^3 + x^2 + 34*x + 21 sage: E = EllipticCurve(QQ, [0,0,0,1,0]) @@ -3432,6 +3452,7 @@ def compute_isogeny_stark(E1, E2, ell): qn /= qn.leading_coefficient() return qn + from sage.misc.superseded import deprecated_function_alias compute_isogeny_starks = deprecated_function_alias(34871, compute_isogeny_stark) @@ -3459,12 +3480,13 @@ def split_kernel_polynomial(poly): Check that this behaves identically to ``.radical()``:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import split_kernel_polynomial - sage: q = next_prime(randrange(3,10^3)) # optional - sage.rings.finite_rings - sage: e = randrange(1,5) # optional - sage.rings.finite_rings - sage: R = GF(q^e,'a')['x'] # optional - sage.rings.finite_rings - sage: f = R.random_element(randrange(10,100)).monic() # optional - sage.rings.finite_rings - sage: split_kernel_polynomial(f) == f.radical() # optional - sage.rings.finite_rings + sage: q = next_prime(randrange(3,10^3)) + sage: e = randrange(1,5) + sage: R = GF(q^e,'a')['x'] + sage: f = R.random_element(randrange(10,100)).monic() + sage: split_kernel_polynomial(f) == f.radical() doctest:warning ... DeprecationWarning: ... True @@ -3504,40 +3526,41 @@ def compute_isogeny_kernel_polynomial(E1, E2, ell, algorithm="stark"): sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_kernel_polynomial - sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(37)[] # optional - sage.rings.finite_rings - sage: f = (x + 14) * (x + 30) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: compute_isogeny_kernel_polynomial(E, E2, 5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) + sage: R. = GF(37)[] + sage: f = (x + 14) * (x + 30) + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: compute_isogeny_kernel_polynomial(E, E2, 5) x^2 + 7*x + 13 - sage: f # optional - sage.rings.finite_rings + sage: f x^2 + 7*x + 13 + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: E2 = EllipticCurve(K, [0,0,0,16,0]) # optional - sage.rings.number_field - sage: compute_isogeny_kernel_polynomial(E, E2, 4) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: E2 = EllipticCurve(K, [0,0,0,16,0]) + sage: compute_isogeny_kernel_polynomial(E, E2, 4) x^3 + x TESTS: Check that :meth:`Polynomial.radical` is doing the right thing for us:: - sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(37)[] # optional - sage.rings.finite_rings - sage: f = (x + 10) * (x + 12) * (x + 16) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) + sage: R. = GF(37)[] + sage: f = (x + 10) * (x + 12) * (x + 16) + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_stark - sage: ker_poly = compute_isogeny_stark(E, E2, 7); ker_poly # optional - sage.rings.finite_rings + sage: ker_poly = compute_isogeny_stark(E, E2, 7); ker_poly x^6 + 2*x^5 + 20*x^4 + 11*x^3 + 36*x^2 + 35*x + 16 - sage: ker_poly.factor() # optional - sage.rings.finite_rings + sage: ker_poly.factor() (x + 10)^2 * (x + 12)^2 * (x + 16)^2 - sage: poly = ker_poly.radical(); poly # optional - sage.rings.finite_rings + sage: poly = ker_poly.radical(); poly x^3 + x^2 + 28*x + 33 - sage: poly.factor() # optional - sage.rings.finite_rings + sage: poly.factor() (x + 10) * (x + 12) * (x + 16) """ if algorithm == 'starks': @@ -3585,11 +3608,11 @@ def compute_intermediate_curves(E1, E2): EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_intermediate_curves - sage: E = EllipticCurve(GF(83), [1,0,1,1,0]) # optional - sage.rings.finite_rings - sage: R. = GF(83)[]; f = x + 24 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: compute_intermediate_curves(E, E2) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(83), [1,0,1,1,0]) + sage: R. = GF(83)[]; f = x + 24 + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: compute_intermediate_curves(E, E2) (Elliptic Curve defined by y^2 = x^3 + 62*x + 74 over Finite Field of size 83, Elliptic Curve defined by y^2 = x^3 + 65*x + 69 over Finite Field of size 83, Elliptic-curve morphism: @@ -3605,11 +3628,12 @@ def compute_intermediate_curves(E1, E2): over Finite Field of size 83 Via: (u,r,s,t) = (1, 7, 42, 42)) + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: E2 = EllipticCurve(K, [0,0,0,16,0]) # optional - sage.rings.number_field - sage: compute_intermediate_curves(E, E2) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: E2 = EllipticCurve(K, [0,0,0,16,0]) + sage: compute_intermediate_curves(E, E2) (Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1, Elliptic Curve defined by y^2 = x^3 + 16*x @@ -3696,10 +3720,11 @@ def compute_sequence_of_maps(E1, E2, ell): Elliptic Curve defined by y^2 = x^3 - 23461/3*x - 28748141/108 over Rational Field, x^2 - 61/3*x + 658/9) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: E2 = EllipticCurve(K, [0,0,0,16,0]) # optional - sage.rings.number_field - sage: compute_sequence_of_maps(E, E2, 4) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: E2 = EllipticCurve(K, [0,0,0,16,0]) + sage: compute_sequence_of_maps(E, E2, 4) (Elliptic-curve endomorphism of Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 Via: (u,r,s,t) = (1, 0, 0, 0), @@ -3712,11 +3737,11 @@ def compute_sequence_of_maps(E1, E2, ell): over Number Field in i with defining polynomial x^2 + 1, x^3 + x) - sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) # optional - sage.rings.finite_rings - sage: R. = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: compute_sequence_of_maps(E, E2, 11) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) + sage: R. = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: compute_sequence_of_maps(E, E2, 11) (Elliptic-curve morphism: From: Elliptic Curve defined by y^2 + x*y + y = x^3 + x over Finite Field of size 97 diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py index 3c359e3de03..e793237b8bc 100644 --- a/src/sage/schemes/elliptic_curves/ell_field.py +++ b/src/sage/schemes/elliptic_curves/ell_field.py @@ -48,8 +48,8 @@ def genus(self): EXAMPLES:: - sage: E = EllipticCurve(GF(3), [0, -1, 0, -346, 2652]) # optional - sage.rings.finite_rings - sage: E.genus() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(3), [0, -1, 0, -346, 2652]) + sage: E.genus() 1 sage: R = FractionField(QQ['z']) @@ -98,52 +98,55 @@ def quadratic_twist(self, D=None): EXAMPLES:: - sage: E = EllipticCurve([GF(1103)(1), 0, 0, 107, 340]); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve([GF(1103)(1), 0, 0, 107, 340]); E Elliptic Curve defined by y^2 + x*y = x^3 + 107*x + 340 over Finite Field of size 1103 - sage: F = E.quadratic_twist(-1); F # optional - sage.rings.finite_rings + sage: F = E.quadratic_twist(-1); F Elliptic Curve defined by y^2 = x^3 + 1102*x^2 + 609*x + 300 over Finite Field of size 1103 - sage: E.is_isomorphic(F) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(F) False - sage: E.is_isomorphic(F, GF(1103^2,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(F, GF(1103^2,'a')) True A characteristic 2 example:: - sage: E = EllipticCurve(GF(2), [1,0,1,1,1]) # optional - sage.rings.finite_rings - sage: E1 = E.quadratic_twist(1) # optional - sage.rings.finite_rings - sage: E.is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(2), [1,0,1,1,1]) + sage: E1 = E.quadratic_twist(1) + sage: E.is_isomorphic(E1) False - sage: E.is_isomorphic(E1, GF(4,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(4,'a')) True Over finite fields, the twisting parameter may be omitted:: - sage: k. = GF(2^10) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [a^2,a,1,a+1,1]) # optional - sage.rings.finite_rings - sage: Et = E.quadratic_twist() # optional - sage.rings.finite_rings - sage: Et # random (only determined up to isomorphism) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF(2^10) + sage: E = EllipticCurve(k, [a^2,a,1,a+1,1]) + sage: Et = E.quadratic_twist() + sage: Et # random (only determined up to isomorphism) Elliptic Curve defined by y^2 + x*y = x^3 + (a^7+a^4+a^3+a^2+a+1)*x^2 + (a^8+a^6+a^4+1) over Finite Field in a of size 2^10 - sage: E.is_isomorphic(Et) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(Et) False - sage: E.j_invariant() == Et.j_invariant() # optional - sage.rings.finite_rings + sage: E.j_invariant() == Et.j_invariant() True - sage: p = next_prime(10^10) # optional - sage.rings.finite_rings - sage: k = GF(p) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: Et = E.quadratic_twist() # optional - sage.rings.finite_rings - sage: Et # random (only determined up to isomorphism) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = next_prime(10^10) + sage: k = GF(p) + sage: E = EllipticCurve(k, [1,2,3,4,5]) + sage: Et = E.quadratic_twist() + sage: Et # random (only determined up to isomorphism) Elliptic Curve defined by y^2 = x^3 + 7860088097*x^2 + 9495240877*x + 3048660957 over Finite Field of size 10000000019 - sage: E.is_isomorphic(Et) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(Et) False - sage: k2 = GF(p^2,'a') # optional - sage.rings.finite_rings - sage: E.change_ring(k2).is_isomorphic(Et.change_ring(k2)) # optional - sage.rings.finite_rings + sage: k2 = GF(p^2,'a') + sage: E.change_ring(k2).is_isomorphic(Et.change_ring(k2)) True """ K = self.base_ring() @@ -210,8 +213,8 @@ def two_torsion_rank(self): sage: E = EllipticCurve('11a1') sage: E.two_torsion_rank() 0 - sage: K. = QQ.extension(E.division_polynomial(2).monic()) # optional - sage.rings.number_field - sage: E.base_extend(K).two_torsion_rank() # optional - sage.rings.number_field + sage: K. = QQ.extension(E.division_polynomial(2).monic()) # needs sage.rings.number_field + sage: E.base_extend(K).two_torsion_rank() # needs sage.rings.number_field 1 sage: E.reduction(53).two_torsion_rank() 2 @@ -222,8 +225,8 @@ def two_torsion_rank(self): sage: E.two_torsion_rank() 1 sage: f = E.division_polynomial(2).monic().factor()[1][0] - sage: K. = QQ.extension(f) # optional - sage.rings.number_field - sage: E.base_extend(K).two_torsion_rank() # optional - sage.rings.number_field + sage: K. = QQ.extension(f) # needs sage.rings.number_field + sage: E.base_extend(K).two_torsion_rank() # needs sage.rings.number_field 2 :: @@ -249,15 +252,16 @@ def quartic_twist(self, D): EXAMPLES:: - sage: E = EllipticCurve_from_j(GF(13)(1728)); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(1728)); E Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 13 - sage: E1 = E.quartic_twist(2); E1 # optional - sage.rings.finite_rings + sage: E1 = E.quartic_twist(2); E1 Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 13 - sage: E.is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1) False - sage: E.is_isomorphic(E1, GF(13^2,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^2,'a')) False - sage: E.is_isomorphic(E1, GF(13^4,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^4,'a')) True """ K = self.base_ring() @@ -292,17 +296,18 @@ def sextic_twist(self, D): EXAMPLES:: - sage: E = EllipticCurve_from_j(GF(13)(0)); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(0)); E Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 13 - sage: E1 = E.sextic_twist(2); E1 # optional - sage.rings.finite_rings + sage: E1 = E.sextic_twist(2); E1 Elliptic Curve defined by y^2 = x^3 + 11 over Finite Field of size 13 - sage: E.is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1) False - sage: E.is_isomorphic(E1, GF(13^2,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^2,'a')) False - sage: E.is_isomorphic(E1, GF(13^4,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^4,'a')) False - sage: E.is_isomorphic(E1, GF(13^6,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^6,'a')) True """ K = self.base_ring() @@ -329,7 +334,7 @@ def is_quadratic_twist(self, other): INPUT: - - ``other`` -- an elliptic curves with the same base field as self. + - ``other`` -- an elliptic curve with the same base field as ``self``. OUTPUT: @@ -360,7 +365,7 @@ def is_quadratic_twist(self, other): 2 sage: E1.is_quadratic_twist(E1) 1 - sage: type(E1.is_quadratic_twist(E1)) == type(E1.is_quadratic_twist(E2)) #trac 6574 + sage: type(E1.is_quadratic_twist(E1)) == type(E1.is_quadratic_twist(E2)) # Issue #6574 True :: @@ -377,40 +382,43 @@ def is_quadratic_twist(self, other): :: - sage: F = GF(101) # optional - sage.rings.finite_rings - sage: E1 = EllipticCurve(F, [4,7]) # optional - sage.rings.finite_rings - sage: E2 = E1.quadratic_twist() # optional - sage.rings.finite_rings - sage: D = E1.is_quadratic_twist(E2); D != 0 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(101) + sage: E1 = EllipticCurve(F, [4,7]) + sage: E2 = E1.quadratic_twist() + sage: D = E1.is_quadratic_twist(E2); D != 0 True - sage: F = GF(101) # optional - sage.rings.finite_rings - sage: E1 = EllipticCurve(F, [4,7]) # optional - sage.rings.finite_rings - sage: E2 = E1.quadratic_twist() # optional - sage.rings.finite_rings - sage: D = E1.is_quadratic_twist(E2) # optional - sage.rings.finite_rings - sage: E1.quadratic_twist(D).is_isomorphic(E2) # optional - sage.rings.finite_rings + sage: F = GF(101) + sage: E1 = EllipticCurve(F, [4,7]) + sage: E2 = E1.quadratic_twist() + sage: D = E1.is_quadratic_twist(E2) + sage: E1.quadratic_twist(D).is_isomorphic(E2) True - sage: E1.is_isomorphic(E2) # optional - sage.rings.finite_rings + sage: E1.is_isomorphic(E2) False - sage: F2 = GF(101^2,'a') # optional - sage.rings.finite_rings - sage: E1.change_ring(F2).is_isomorphic(E2.change_ring(F2)) # optional - sage.rings.finite_rings + sage: F2 = GF(101^2,'a') + sage: E1.change_ring(F2).is_isomorphic(E2.change_ring(F2)) True A characteristic 3 example:: - sage: F = GF(3^5,'a') # optional - sage.rings.finite_rings - sage: E1 = EllipticCurve_from_j(F(1)) # optional - sage.rings.finite_rings - sage: E2 = E1.quadratic_twist(-1) # optional - sage.rings.finite_rings - sage: D = E1.is_quadratic_twist(E2); D != 0 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(3^5,'a') + sage: E1 = EllipticCurve_from_j(F(1)) + sage: E2 = E1.quadratic_twist(-1) + sage: D = E1.is_quadratic_twist(E2); D != 0 True - sage: E1.quadratic_twist(D).is_isomorphic(E2) # optional - sage.rings.finite_rings + sage: E1.quadratic_twist(D).is_isomorphic(E2) True :: - sage: E1 = EllipticCurve_from_j(F(0)) # optional - sage.rings.finite_rings - sage: E2 = E1.quadratic_twist() # optional - sage.rings.finite_rings - sage: D = E1.is_quadratic_twist(E2); D # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E1 = EllipticCurve_from_j(F(0)) + sage: E2 = E1.quadratic_twist() + sage: D = E1.is_quadratic_twist(E2); D 1 - sage: E1.is_isomorphic(E2) # optional - sage.rings.finite_rings + sage: E1.is_isomorphic(E2) True """ from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve @@ -496,11 +504,11 @@ def is_quartic_twist(self, other): EXAMPLES:: - sage: E = EllipticCurve_from_j(GF(13)(1728)) # optional - sage.rings.finite_rings - sage: E1 = E.quartic_twist(2) # optional - sage.rings.finite_rings - sage: D = E.is_quartic_twist(E1); D!=0 # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(1728)) + sage: E1 = E.quartic_twist(2) + sage: D = E.is_quartic_twist(E1); D!=0 True - sage: E.quartic_twist(D).is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E.quartic_twist(D).is_isomorphic(E1) True :: @@ -565,11 +573,11 @@ def is_sextic_twist(self, other): EXAMPLES:: - sage: E = EllipticCurve_from_j(GF(13)(0)) # optional - sage.rings.finite_rings - sage: E1 = E.sextic_twist(2) # optional - sage.rings.finite_rings - sage: D = E.is_sextic_twist(E1); D != 0 # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(0)) + sage: E1 = E.sextic_twist(2) + sage: D = E.is_sextic_twist(E1); D != 0 True - sage: E.sextic_twist(D).is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E.sextic_twist(D).is_isomorphic(E1) True :: @@ -650,51 +658,54 @@ def descend_to(self, K, f=None): :: - sage: F. = QuadraticField(23) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F. = QuadraticField(23) sage: x = polygen(ZZ, 'x') - sage: G. = F.extension(x^3 + 5) # optional - sage.rings.number_field - sage: E = EllipticCurve(j=1728*b).change_ring(G) # optional - sage.rings.number_field - sage: EF = E.descend_to(F); EF # optional - sage.rings.number_field + sage: G. = F.extension(x^3 + 5) + sage: E = EllipticCurve(j=1728*b).change_ring(G) + sage: EF = E.descend_to(F); EF [Elliptic Curve defined by y^2 = x^3 + (27*b-621)*x + (-1296*b+2484) over Number Field in b with defining polynomial x^2 - 23 with b = 4.795831523312720?] - sage: all(Ei.change_ring(G).is_isomorphic(E) for Ei in EF) # optional - sage.rings.number_field + sage: all(Ei.change_ring(G).is_isomorphic(E) for Ei in EF) True :: - sage: L. = NumberField(x^4 - 7) # optional - sage.rings.number_field - sage: K. = NumberField(x^2 - 7, embedding=a^2) # optional - sage.rings.number_field - sage: E = EllipticCurve([a^6, 0]) # optional - sage.rings.number_field - sage: EK = E.descend_to(K); EK # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: L. = NumberField(x^4 - 7) + sage: K. = NumberField(x^2 - 7, embedding=a^2) + sage: E = EllipticCurve([a^6, 0]) + sage: EK = E.descend_to(K); EK [Elliptic Curve defined by y^2 = x^3 + b*x over Number Field in b with defining polynomial x^2 - 7 with b = a^2, Elliptic Curve defined by y^2 = x^3 + 7*b*x over Number Field in b with defining polynomial x^2 - 7 with b = a^2] - sage: all(Ei.change_ring(L).is_isomorphic(E) for Ei in EK) # optional - sage.rings.number_field + sage: all(Ei.change_ring(L).is_isomorphic(E) for Ei in EK) True :: - sage: K. = QuadraticField(17) # optional - sage.rings.number_field - sage: E = EllipticCurve(j=2*a) # optional - sage.rings.number_field - sage: E.descend_to(QQ) # optional - sage.rings.number_field + sage: K. = QuadraticField(17) # needs sage.rings.number_field + sage: E = EllipticCurve(j=2*a) # needs sage.rings.number_field + sage: E.descend_to(QQ) # needs sage.rings.number_field [] TESTS: Check that :trac:`16456` is fixed:: - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve('11a1').quadratic_twist(2) # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: EK2 = EK.change_weierstrass_model((a,a,a,a+1)) # optional - sage.rings.number_field - sage: EK2.descend_to(QQ) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve('11a1').quadratic_twist(2) + sage: EK = E.change_ring(K) + sage: EK2 = EK.change_weierstrass_model((a,a,a,a+1)) + sage: EK2.descend_to(QQ) [Elliptic Curve defined by y^2 = x^3 + x^2 - 41*x - 199 over Rational Field] - sage: k. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(k,[0,0,0,1,0]) # optional - sage.rings.number_field - sage: E.descend_to(QQ) # optional - sage.rings.number_field + sage: k. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve(k,[0,0,0,1,0]) # needs sage.rings.number_field + sage: E.descend_to(QQ) # needs sage.rings.number_field [Elliptic Curve defined by y^2 = x^3 + x over Rational Field, Elliptic Curve defined by y^2 = x^3 - 4*x over Rational Field] """ @@ -819,17 +830,18 @@ def division_field(self, l, names='t', map=False, **kwds): The 2-division field is the same as the splitting field of the 2-division polynomial (therefore, it has degree 1, 2, 3 or 6):: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('15a1') - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x sage: E = EllipticCurve('14a1') - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^2 + 5*x + 92 sage: E = EllipticCurve('196b1') - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^3 + x^2 - 114*x - 127 sage: E = EllipticCurve('19a1') - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^6 + 10*x^5 + 24*x^4 - 212*x^3 + 1364*x^2 + 24072*x + 104292 @@ -837,11 +849,12 @@ def division_field(self, l, names='t', map=False, **kwds): field of the `\ell`-division polynomial, or a quadratic extension of it. :: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('50a1') - sage: F. = E.division_polynomial(3).splitting_field(simplify_all=True); F # optional - sage.rings.number_field + sage: F. = E.division_polynomial(3).splitting_field(simplify_all=True); F Number Field in a with defining polynomial x^6 - 3*x^5 + 4*x^4 - 3*x^3 - 2*x^2 + 3*x + 3 - sage: K. = E.division_field(3, simplify_all=True); K # optional - sage.rings.number_field + sage: K. = E.division_field(3, simplify_all=True); K Number Field in b with defining polynomial x^6 - 3*x^5 + 4*x^4 - 3*x^3 - 2*x^2 + 3*x + 3 @@ -849,75 +862,80 @@ def division_field(self, l, names='t', map=False, **kwds): 3-division polynomial remains the same, but the 3-division field becomes a quadratic extension:: - sage: E = E.quadratic_twist(5) # 50b3 # optional - sage.rings.number_field - sage: F. = E.division_polynomial(3).splitting_field(simplify_all=True); F # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = E.quadratic_twist(5) # 50b3 + sage: F. = E.division_polynomial(3).splitting_field(simplify_all=True); F Number Field in a with defining polynomial x^6 - 3*x^5 + 4*x^4 - 3*x^3 - 2*x^2 + 3*x + 3 - sage: K. = E.division_field(3, simplify_all=True); K # optional - sage.rings.number_field + sage: K. = E.division_field(3, simplify_all=True); K Number Field in b with defining polynomial x^12 - 3*x^11 + 8*x^10 - 15*x^9 + 30*x^8 - 63*x^7 + 109*x^6 - 144*x^5 + 150*x^4 - 120*x^3 + 68*x^2 - 24*x + 4 Try another quadratic twist, this time over a subfield of `F`:: - sage: G.,_,_ = F.subfields(3)[0] # optional - sage.rings.number_field - sage: E = E.base_extend(G).quadratic_twist(c); E # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: G.,_,_ = F.subfields(3)[0] + sage: E = E.base_extend(G).quadratic_twist(c); E Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9 - sage: K. = E.division_field(3, simplify_all=True); K # optional - sage.rings.number_field + sage: K. = E.division_field(3, simplify_all=True); K Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025 Some higher-degree examples:: - sage: E = EllipticCurve('11a1') # optional - sage.rings.number_field - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve('11a1') + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^6 + 2*x^5 - 48*x^4 - 436*x^3 + 1668*x^2 + 28792*x + 73844 - sage: K. = E.division_field(3); K # long time (3s on sage.math, 2014) # optional - sage.rings.number_field + sage: K. = E.division_field(3); K # long time Number Field in b with defining polynomial x^48 ... - sage: K. = E.division_field(5); K # optional - sage.rings.number_field + sage: K. = E.division_field(5); K Number Field in b with defining polynomial x^4 - x^3 + x^2 - x + 1 - sage: E.division_field(5, 'b', simplify=False) # optional - sage.rings.number_field + sage: E.division_field(5, 'b', simplify=False) Number Field in b with defining polynomial x^4 + x^3 + 11*x^2 + 41*x + 101 - sage: E.base_extend(K).torsion_subgroup() # long time (2s on sage.math, 2014) # optional - sage.rings.number_field + sage: E.base_extend(K).torsion_subgroup() # long time Torsion Subgroup isomorphic to Z/5 + Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in b with defining polynomial x^4 - x^3 + x^2 - x + 1 - sage: E = EllipticCurve('27a1') # optional - sage.rings.number_field - sage: K. = E.division_field(3); K # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve('27a1') + sage: K. = E.division_field(3); K Number Field in b with defining polynomial x^2 + 3*x + 9 - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^6 + 6*x^5 + 24*x^4 - 52*x^3 - 228*x^2 + 744*x + 3844 - sage: K. = E.division_field(2, simplify_all=True); K # optional - sage.rings.number_field + sage: K. = E.division_field(2, simplify_all=True); K Number Field in b with defining polynomial x^6 - 3*x^5 + 5*x^3 - 3*x + 1 - sage: K. = E.division_field(5); K # long time (4s on sage.math, 2014) # optional - sage.rings.number_field + sage: K. = E.division_field(5); K # long time Number Field in b with defining polynomial x^48 ... - sage: K. = E.division_field(7); K # long time (8s on sage.math, 2014) # optional - sage.rings.number_field + sage: K. = E.division_field(7); K # long time Number Field in b with defining polynomial x^72 ... Over a number field:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,i]) # optional - sage.rings.number_field - sage: L. = E.division_field(2); L # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve([0,0,0,0,i]) + sage: L. = E.division_field(2); L Number Field in b with defining polynomial x^4 - x^2 + 1 - sage: L., phi = E.division_field(2, map=True); phi # optional - sage.rings.number_field + sage: L., phi = E.division_field(2, map=True); phi Ring morphism: From: Number Field in i with defining polynomial x^2 + 1 To: Number Field in b with defining polynomial x^4 - x^2 + 1 Defn: i |--> -b^3 - sage: L., phi = E.division_field(3, map=True) # optional - sage.rings.number_field - sage: L # optional - sage.rings.number_field + sage: L., phi = E.division_field(3, map=True) + sage: L Number Field in b with defining polynomial x^24 - 6*x^22 - 12*x^21 - 21*x^20 + 216*x^19 + 48*x^18 + 804*x^17 + 1194*x^16 - 13488*x^15 + 21222*x^14 + 44196*x^13 - 47977*x^12 - 102888*x^11 + 173424*x^10 - 172308*x^9 + 302046*x^8 + 252864*x^7 - 931182*x^6 + 180300*x^5 + 879567*x^4 - 415896*x^3 + 1941012*x^2 + 650220*x + 443089 - sage: phi # optional - sage.rings.number_field + sage: phi Ring morphism: From: Number Field in i with defining polynomial x^2 + 1 To: Number Field in b with defining polynomial x^24 ... @@ -925,8 +943,8 @@ def division_field(self, l, names='t', map=False, **kwds): Over a finite field:: - sage: E = EllipticCurve(GF(431^2), [1,0]) # optional - sage.rings.finite_rings - sage: E.division_field(5, map=True) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(431^2), [1,0]) # needs sage.rings.finite_rings + sage: E.division_field(5, map=True) # needs sage.rings.finite_rings (Finite Field in t of size 431^4, Ring morphism: From: Finite Field in z2 of size 431^2 @@ -935,8 +953,8 @@ def division_field(self, l, names='t', map=False, **kwds): :: - sage: E = EllipticCurve(GF(433^2), [1,0]) # optional - sage.rings.finite_rings - sage: K. = E.division_field(7); K # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(433^2), [1,0]) # needs sage.rings.finite_rings + sage: K. = E.division_field(7); K # needs sage.rings.finite_rings Finite Field in v of size 433^16 .. SEEALSO:: @@ -951,6 +969,7 @@ def division_field(self, l, names='t', map=False, **kwds): Some random testing:: + sage: # needs sage.rings.finite_rings sage: def check(E, l, K): ....: EE = E.change_ring(K) ....: cof = EE.order().prime_to_m_part(l) @@ -974,20 +993,20 @@ def division_field(self, l, names='t', map=False, **kwds): ....: assert False ....: deg = lcm(el.minpoly().degree() for el in sum(map(list,Ps),[])) ....: assert max(deg, E.base_field().degree()) == K.degree() - sage: q = next_prime_power(randrange(1, 10^9)) # optional - sage.rings.finite_rings - sage: F. = GF(q) # optional - sage.rings.finite_rings - sage: while True: # optional - sage.rings.finite_rings + sage: q = next_prime_power(randrange(1, 10^9)) + sage: F. = GF(q) + sage: while True: ....: try: ....: E = EllipticCurve([F.random_element() for _ in range(5)]) ....: except ArithmeticError: ....: continue ....: break - sage: l = random_prime(8) # optional - sage.rings.finite_rings - sage: K = E.division_field(l) # optional - sage.rings.finite_rings - sage: n = E.cardinality(extension_degree=K.degree()//F.degree()) # optional - sage.rings.finite_rings - sage: (l^2 if q%l else 0 + E.is_ordinary()).divides(n) # optional - sage.rings.finite_rings + sage: l = random_prime(8) + sage: K = E.division_field(l) + sage: n = E.cardinality(extension_degree=K.degree()//F.degree()) + sage: (l^2 if q%l else 0 + E.is_ordinary()).divides(n) True - sage: check(E, l, K) # long time # optional - sage.rings.finite_rings + sage: check(E, l, K) # long time AUTHORS: @@ -1161,11 +1180,12 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al EXAMPLES:: - sage: F = GF(2^5, 'alpha'); alpha = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,0,1,1,1]) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: phi = E.isogeny(x + 1) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(2^5, 'alpha'); alpha = F.gen() + sage: E = EllipticCurve(F, [1,0,1,1,1]) + sage: R. = F[] + sage: phi = E.isogeny(x + 1) + sage: phi.rational_maps() ((x^2 + x + 1)/(x + 1), (x^2*y + x)/(x^2 + 1)) :: @@ -1181,22 +1201,22 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al :: - sage: E = EllipticCurve(GF(19),[1,1]) # optional - sage.rings.finite_rings - sage: P = E(15,3); Q = E(2,12) # optional - sage.rings.finite_rings - sage: (P.order(), Q.order()) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19),[1,1]) + sage: P = E(15,3); Q = E(2,12) + sage: (P.order(), Q.order()) (7, 3) - sage: phi = E.isogeny([P,Q]); phi # optional - sage.rings.finite_rings + sage: phi = E.isogeny([P,Q]); phi Isogeny of degree 21 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 19 to Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 19 - sage: phi(E.random_point()) # all points defined over GF(19) are in the kernel # optional - sage.rings.finite_rings + sage: phi(E.random_point()) # all points defined over GF(19) are in the kernel (0 : 1 : 0) :: - sage: E = EllipticCurve(GF(2^32 - 5), [170246996, 2036646110]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(2) # optional - sage.rings.finite_rings - sage: E.isogeny(P, algorithm="factored") # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^32 - 5), [170246996, 2036646110]) # needs sage.rings.finite_rings + sage: P = E.lift_x(2) # needs sage.rings.finite_rings + sage: E.isogeny(P, algorithm="factored") # needs sage.rings.finite_rings Composite morphism of degree 1073721825 = 3^4*5^2*11*19*43*59: From: Elliptic Curve defined by y^2 = x^3 + 170246996*x + 2036646110 over Finite Field of size 4294967291 @@ -1205,8 +1225,8 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al Not all polynomials define a finite subgroup (:trac:`6384`):: - sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny([14,27,4,1]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) + sage: phi = E.isogeny([14,27,4,1]) Traceback (most recent call last): ... ValueError: the polynomial x^3 + 4*x^2 + 27*x + 14 does not define a finite @@ -1225,11 +1245,12 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al :trac:`23222`, the following raised no error but returned an invalid morphism. See also :trac:`11578`:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [-13392, -1080432]) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: phi = E.isogeny( (x-564)*(x - 396/5*a + 348/5) ) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) + sage: E = EllipticCurve(K, [-13392, -1080432]) + sage: R. = K[] + sage: phi = E.isogeny( (x-564)*(x - 396/5*a + 348/5) ) Traceback (most recent call last): ... ValueError: the polynomial x^2 + (-396/5*a - 2472/5)*x + 223344/5*a - 196272/5 does not @@ -1238,10 +1259,11 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al We check that the cached order is correctly copied over:: - sage: E = EllipticCurve(GF(2^127-1), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: E.set_order(170141183460469231746191640949390434666) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(77347718128277853096420969229987528666)) # optional - sage.rings.finite_rings - sage: phi.codomain()._order # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^127 - 1), [1,2,3,4,5]) + sage: E.set_order(170141183460469231746191640949390434666) + sage: phi = E.isogeny(E.lift_x(77347718128277853096420969229987528666)) + sage: phi.codomain()._order 170141183460469231746191640949390434666 """ if algorithm is not None and degree is not None: @@ -1283,15 +1305,16 @@ def isogeny_codomain(self, kernel, degree=None): We check that the cached order is correctly copied over:: - sage: E = EllipticCurve(GF(2^127 - 1), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: E.set_order(170141183460469231746191640949390434666) # optional - sage.rings.finite_rings - sage: E2 = E.isogeny_codomain(E.lift_x(77347718128277853096420969229987528666)) # optional - sage.rings.finite_rings - sage: E2._order # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^127 - 1), [1,2,3,4,5]) + sage: E.set_order(170141183460469231746191640949390434666) + sage: E2 = E.isogeny_codomain(E.lift_x(77347718128277853096420969229987528666)) + sage: E2._order 170141183460469231746191640949390434666 Test deprecation warning for obsolete argument:: - sage: E.isogeny_codomain(E.lift_x(77347718128277853096420969229987528666), degree=11) # optional - sage.rings.finite_rings + sage: E.isogeny_codomain(E.lift_x(77347718128277853096420969229987528666), degree=11) # needs sage.rings.finite_rings doctest:warning ... DeprecationWarning: The "degree" argument to .isogeny_codomain() does nothing and will be removed. @@ -1336,8 +1359,9 @@ def isogenies_prime_degree(self, l=None, max_l=31): Examples over finite fields:: - sage: E = EllipticCurve(GF(next_prime(1000000)), [7,8]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(2) # optional - sage.rings.finite_rings + sage: # needs sage.libs.pari + sage: E = EllipticCurve(GF(next_prime(1000000)), [7,8]) + sage: E.isogenies_prime_degree(2) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, @@ -1347,22 +1371,22 @@ def isogenies_prime_degree(self, l=None, max_l=31): Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 999960*x + 78 over Finite Field of size 1000003] - sage: E.isogenies_prime_degree(3) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(3) [] - sage: E.isogenies_prime_degree(5) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(5) [] - sage: E.isogenies_prime_degree(7) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(7) [] - sage: E.isogenies_prime_degree(11) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(11) [] - sage: E.isogenies_prime_degree(13) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(13) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 878063*x + 845666 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003] - sage: E.isogenies_prime_degree(max_l=13) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(max_l=13) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, @@ -1378,7 +1402,7 @@ def isogenies_prime_degree(self, l=None, max_l=31): Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003] - sage: E.isogenies_prime_degree() # Default limit of 31 # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree() # Default limit of 31 [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, @@ -1404,10 +1428,10 @@ def isogenies_prime_degree(self, l=None, max_l=31): from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 390065*x + 605596 over Finite Field of size 1000003] - sage: E = EllipticCurve(GF(17), [2,0]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [2,0]) + sage: E.isogenies_prime_degree(3) [] - sage: E.isogenies_prime_degree(2) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(2) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 17 to Elliptic Curve defined by y^2 = x^3 + 9*x over Finite Field of size 17, @@ -1421,16 +1445,18 @@ def isogenies_prime_degree(self, l=None, max_l=31): The base field matters, over a field extension we find more isogenies:: - sage: E = EllipticCurve(GF(13), [2,8]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(max_l=3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13), [2,8]) + sage: E.isogenies_prime_degree(max_l=3) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 7*x + 4 over Finite Field of size 13, Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 9*x + 11 over Finite Field of size 13] - sage: E = EllipticCurve(GF(13^6), [2,8]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(max_l=3) # optional - sage.rings.finite_rings + + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(13^6), [2,8]) + sage: E.isogenies_prime_degree(max_l=3) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in z6 of size 13^6 to Elliptic Curve defined by y^2 = x^3 + 7*x + 4 over Finite Field in z6 of size 13^6, @@ -1456,19 +1482,21 @@ def isogenies_prime_degree(self, l=None, max_l=31): If the degree equals the characteristic, we find only separable isogenies:: - sage: E = EllipticCurve(GF(13), [2,8]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(13) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13), [2,8]) + sage: E.isogenies_prime_degree(13) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 6*x + 5 over Finite Field of size 13] - sage: E = EllipticCurve(GF(5), [1,1]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5), [1,1]) + sage: E.isogenies_prime_degree(5) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 to Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 5] - sage: k. = GF(3^4) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [0,1,0,0,a]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(3) # optional - sage.rings.finite_rings + + sage: # needs sage.rings.finite_rings + sage: k. = GF(3^4) + sage: E = EllipticCurve(k, [0,1,0,0,a]) + sage: E.isogenies_prime_degree(3) [Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + x^2 + a over Finite Field in a of size 3^4 @@ -1478,16 +1506,16 @@ def isogenies_prime_degree(self, l=None, max_l=31): In the supersingular case, there are no separable isogenies of degree equal to the characteristic:: - sage: E = EllipticCurve(GF(5), [0,1]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5), [0,1]) + sage: E.isogenies_prime_degree(5) [] An example over a rational function field:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: K = R.fraction_field() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [1, t^5]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(5) # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: K = R.fraction_field() + sage: E = EllipticCurve(K, [1, t^5]) + sage: E.isogenies_prime_degree(5) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x + t^5 over Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5 @@ -1496,10 +1524,11 @@ def isogenies_prime_degree(self, l=None, max_l=31): Examples over number fields (other than QQ):: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: QQroot2. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve(QQroot2, j=8000) # optional - sage.rings.number_field - sage: E.isogenies_prime_degree() # optional - sage.rings.number_field + sage: QQroot2. = NumberField(x^2 - 2) + sage: E = EllipticCurve(QQroot2, j=8000) + sage: E.isogenies_prime_degree() [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-150528000)*x + (-629407744000) over Number Field in e with defining polynomial x^2 - 2 @@ -1515,17 +1544,16 @@ def isogenies_prime_degree(self, l=None, max_l=31): over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 = x^3 + (-220500*e-257250)*x + (-54022500*e-88837000) over Number Field in e with defining polynomial x^2 - 2] - - sage: E = EllipticCurve(QQroot2, [1,0,1,4, -6]); E # optional - sage.rings.number_field + sage: E = EllipticCurve(QQroot2, [1,0,1,4, -6]); E Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 - sage: E.isogenies_prime_degree(2) # optional - sage.rings.number_field + sage: E.isogenies_prime_degree(2) [Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 + x*y + y = x^3 + (-36)*x + (-70) over Number Field in e with defining polynomial x^2 - 2] - sage: E.isogenies_prime_degree(3) # optional - sage.rings.number_field + sage: E.isogenies_prime_degree(3) [Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 @@ -1539,9 +1567,9 @@ def isogenies_prime_degree(self, l=None, max_l=31): These are not implemented yet:: - sage: E = EllipticCurve(QQbar, [1,18]); E # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [1,18]); E # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + x + 18 over Algebraic Field - sage: E.isogenies_prime_degree() # optional - sage.rings.number_field + sage: E.isogenies_prime_degree() # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: This code could be implemented for QQbar, but has not been yet. @@ -1721,18 +1749,19 @@ def hasse_invariant(self): Some examples over larger fields:: - sage: EllipticCurve(GF(101), [0,0,0,0,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: EllipticCurve(GF(101), [0,0,0,0,1]).hasse_invariant() 0 - sage: EllipticCurve(GF(101), [0,0,0,1,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(101), [0,0,0,1,1]).hasse_invariant() 98 - sage: EllipticCurve(GF(103), [0,0,0,0,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(103), [0,0,0,0,1]).hasse_invariant() 20 - sage: EllipticCurve(GF(103), [0,0,0,1,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(103), [0,0,0,1,1]).hasse_invariant() 17 - sage: F. = GF(107^2) # optional - sage.rings.finite_rings - sage: EllipticCurve(F, [0,0,0,a,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: F. = GF(107^2) + sage: EllipticCurve(F, [0,0,0,a,1]).hasse_invariant() 62*a + 75 - sage: EllipticCurve(F, [0,0,0,0,a]).hasse_invariant() # optional - sage.rings.finite_rings + sage: EllipticCurve(F, [0,0,0,0,a]).hasse_invariant() 0 Over fields of characteristic zero, the Hasse invariant is @@ -1792,17 +1821,17 @@ class of curves. If the j-invariant is not unique in the isogeny Ordinary curve over finite extension field of degree 2:: + sage: # needs sage.graphs sage.rings.finite_rings sage: x = polygen(ZZ, 'x') - sage: E = EllipticCurve(GF(59^2, "i", x^2 + 1), j=5) # optional - sage.rings.finite_rings - sage: G = E.isogeny_ell_graph(5, directed=False, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G # optional - sage.graphs sage.rings.finite_rings + sage: E = EllipticCurve(GF(59^2, "i", x^2 + 1), j=5) + sage: G = E.isogeny_ell_graph(5, directed=False, label_by_j=True); G Graph on 20 vertices - sage: G.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G.vertices(sort=True) ['1', '12', ... 'i + 55'] - sage: G.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G.edges(sort=True) [('1', '28*i + 11', None), ('1', '31*i + 11', None), ... @@ -1810,26 +1839,25 @@ class of curves. If the j-invariant is not unique in the isogeny Supersingular curve over prime field:: - sage: E = EllipticCurve(GF(419), j=1728) # optional - sage.rings.finite_rings - sage: G3 = E.isogeny_ell_graph(3, directed=False, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G3 # optional - sage.graphs sage.rings.finite_rings + sage: # needs sage.graphs sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), j=1728) + sage: G3 = E.isogeny_ell_graph(3, directed=False, label_by_j=True); G3 Graph on 27 vertices - sage: G3.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G3.vertices(sort=True) ['0', '0*', ... '98*'] - sage: G3.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G3.edges(sort=True) [('0', '0*', None), ('0', '13', None), ... ('48*', '98*', None)] - sage: G5 = E.isogeny_ell_graph(5, directed=False, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G5 # optional - sage.graphs sage.rings.finite_rings + sage: G5 = E.isogeny_ell_graph(5, directed=False, label_by_j=True); G5 Graph on 9 vertices - sage: G5.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G5.vertices(sort=True) ['13', '13*', '407', '407*', '52', '62', '62*', '98', '98*'] - sage: G5.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G5.edges(sort=True) [('13', '52', None), ('13', '98', None), ... @@ -1837,32 +1865,31 @@ class of curves. If the j-invariant is not unique in the isogeny Supersingular curve over finite extension field of degree 2:: - sage: K = GF(431^2, "i", x^2 + 1) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, j=0) # optional - sage.rings.finite_rings - sage: E.is_supersingular() # optional - sage.rings.finite_rings + sage: # needs sage.graphs sage.rings.finite_rings + sage: K = GF(431^2, "i", x^2 + 1) + sage: E = EllipticCurve(K, j=0) + sage: E.is_supersingular() True - sage: G = E.isogeny_ell_graph(2, directed=True, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G # optional - sage.graphs sage.rings.finite_rings + sage: G = E.isogeny_ell_graph(2, directed=True, label_by_j=True); G Looped multi-digraph on 37 vertices - sage: G.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G.vertices(sort=True) ['0', '102', ... '87*i + 190'] - sage: G.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G.edges(sort=True) [('0', '125', None), ('0', '125', None), ... '81*i + 65', None)] - sage: H = E.isogeny_ell_graph(2, directed=False, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: H # optional - sage.graphs sage.rings.finite_rings + sage: H = E.isogeny_ell_graph(2, directed=False, label_by_j=True); H Looped multi-graph on 37 vertices - sage: H.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: H.vertices(sort=True) ['0', '102', ... '87*i + 190'] - sage: H.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: H.edges(sort=True) [('0', '125', None), ('102', '125', None), ... @@ -1870,27 +1897,28 @@ class of curves. If the j-invariant is not unique in the isogeny Curve over a quadratic number field:: - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1, 0, 1, 4, -6]) # optional - sage.rings.number_field - sage: G2 = E.isogeny_ell_graph(2, directed=False) # optional - sage.graphs sage.rings.number_field - sage: G2.vertices(sort=True) # optional - sage.graphs sage.rings.number_field + sage: # needs sage.graphs sage.rings.finite_rings sage.rings.number_field + sage: K. = NumberField(x^2 - 2) + sage: E = EllipticCurve(K, [1, 0, 1, 4, -6]) + sage: G2 = E.isogeny_ell_graph(2, directed=False) + sage: G2.vertices(sort=True) ['y^2 + x*y + y = x^3 + (-130*e-356)*x + (-2000*e-2038)', 'y^2 + x*y + y = x^3 + (-36)*x + (-70)', 'y^2 + x*y + y = x^3 + (130*e-356)*x + (2000*e-2038)', 'y^2 + x*y + y = x^3 + 4*x + (-6)'] - sage: G2.edges(sort=True) # optional - sage.graphs sage.rings.number_field + sage: G2.edges(sort=True) [('y^2 + x*y + y = x^3 + (-130*e-356)*x + (-2000*e-2038)', 'y^2 + x*y + y = x^3 + (-36)*x + (-70)', None), ('y^2 + x*y + y = x^3 + (-36)*x + (-70)', 'y^2 + x*y + y = x^3 + (130*e-356)*x + (2000*e-2038)', None), ('y^2 + x*y + y = x^3 + (-36)*x + (-70)', 'y^2 + x*y + y = x^3 + 4*x + (-6)', None)] - sage: G3 = E.isogeny_ell_graph(3, directed=False) # optional - sage.graphs sage.rings.number_field - sage: G3.vertices(sort=True) # optional - sage.graphs sage.rings.number_field + sage: G3 = E.isogeny_ell_graph(3, directed=False) + sage: G3.vertices(sort=True) ['y^2 + x*y + y = x^3 + (-1)*x', 'y^2 + x*y + y = x^3 + (-171)*x + (-874)', 'y^2 + x*y + y = x^3 + 4*x + (-6)'] - sage: G3.edges(sort=True) # optional - sage.graphs sage.rings.number_field + sage: G3.edges(sort=True) [('y^2 + x*y + y = x^3 + (-1)*x', 'y^2 + x*y + y = x^3 + 4*x + (-6)', None), ('y^2 + x*y + y = x^3 + (-171)*x + (-874)', @@ -1898,21 +1926,21 @@ class of curves. If the j-invariant is not unique in the isogeny TESTS:: - sage: E = EllipticCurve(GF(11), j=0) # optional - sage.rings.finite_rings - sage: G0 = E.isogeny_ell_graph(2, directed=False) # optional - sage.graphs sage.rings.finite_rings - sage: G0.is_directed() # optional - sage.graphs sage.rings.finite_rings + sage: E = EllipticCurve(GF(11), j=0) + sage: G0 = E.isogeny_ell_graph(2, directed=False) + sage: G0.is_directed() False - sage: G1 = E.isogeny_ell_graph(2, directed=True) # optional - sage.graphs sage.rings.finite_rings - sage: G1.is_directed() # optional - sage.graphs sage.rings.finite_rings + sage: G1 = E.isogeny_ell_graph(2, directed=True) + sage: G1.is_directed() True - sage: G2 = E.isogeny_ell_graph(2, label_by_j=False) # optional - sage.graphs sage.rings.finite_rings - sage: G2.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G2 = E.isogeny_ell_graph(2, label_by_j=False) + sage: G2.vertices(sort=True) ['y^2 = x^3 + 1', 'y^2 = x^3 + 2', 'y^2 = x^3 + 5*x', 'y^2 = x^3 + 7*x'] - sage: G3 = E.isogeny_ell_graph(2, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G3.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G3 = E.isogeny_ell_graph(2, label_by_j=True) + sage: G3.vertices(sort=True) ['0', '0*', '1', '1*'] """ diff --git a/src/sage/schemes/elliptic_curves/ell_finite_field.py b/src/sage/schemes/elliptic_curves/ell_finite_field.py index a46d722fb51..52115c51c7d 100644 --- a/src/sage/schemes/elliptic_curves/ell_finite_field.py +++ b/src/sage/schemes/elliptic_curves/ell_finite_field.py @@ -55,6 +55,7 @@ class EllipticCurve_finite_field(EllipticCurve_field, HyperellipticCurve_finite_ sage: EllipticCurve(GF(101),[2,3]) Elliptic Curve defined by y^2 = x^3 + 2*x + 3 over Finite Field of size 101 + sage: # needs sage.rings.finite_rings sage: F = GF(101^2, 'a') sage: EllipticCurve([F(2),F(3)]) Elliptic Curve defined by y^2 = x^3 + 2*x + 3 over Finite Field in a of size 101^2 @@ -99,7 +100,7 @@ def plot(self, *args, **kwds): EXAMPLES:: sage: E = EllipticCurve(FiniteField(17), [0,1]) - sage: P = plot(E, rgbcolor=(0,0,1)) + sage: P = plot(E, rgbcolor=(0,0,1)) # needs sage.plot """ R = self.base_ring() if not R.is_prime_field(): @@ -135,6 +136,7 @@ def _points_via_group_structure(self): :: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(4,'a'),[0, 0, 1, 0, 1]) sage: E.points() [(0 : 1 : 0), (0 : a : 1), (0 : a + 1 : 1), (1 : 0 : 1), (1 : 1 : 1), (a : 0 : 1), (a : 1 : 1), (a + 1 : 0 : 1), (a + 1 : 1 : 1)] @@ -184,6 +186,7 @@ def points(self): :: + sage: # needs sage.rings.finite_rings sage: K = GF((p, 2),'a') sage: E = E.change_ring(K) sage: len(E.points()) @@ -195,7 +198,7 @@ def points(self): Note that the returned list is an immutable sorted Sequence:: - sage: w[0] = 9 + sage: w[0] = 9 # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: object is immutable; please change a copy instead. @@ -245,6 +248,7 @@ def count_points(self, n=1): :: + sage: # needs sage.rings.finite_rings sage: F. = GF(p^2) sage: E = EllipticCurve(F, [a,a]) sage: E.cardinality() @@ -309,6 +313,7 @@ def random_element(self): :: + sage: # needs sage.rings.finite_rings sage: k. = GF(7^5) sage: E = EllipticCurve(k,[2,4]) sage: P = E.random_element(); P # random @@ -320,9 +325,10 @@ def random_element(self): :: + sage: # needs sage.rings.finite_rings sage: k. = GF(2^5) sage: E = EllipticCurve(k,[a^2,a,1,a+1,1]) - sage: P = E.random_element();P # random + sage: P = E.random_element(); P # random (a^4 + a : a^4 + a^3 + a^2 : 1) sage: type(P) @@ -352,6 +358,7 @@ def random_element(self): sage: E.cardinality() 1 + sage: # needs sage.rings.finite_rings sage: F. = GF(4) sage: E = EllipticCurve(F, [0, 0, 1, 0, a]) sage: E.random_point() @@ -390,14 +397,14 @@ def trace_of_frobenius(self): sage: E = EllipticCurve(GF(101),[2,3]) sage: E.trace_of_frobenius() 6 - sage: E = EllipticCurve(GF(11^5,'a'),[2,5]) - sage: E.trace_of_frobenius() + sage: E = EllipticCurve(GF(11^5,'a'),[2,5]) # needs sage.rings.finite_rings + sage: E.trace_of_frobenius() # needs sage.rings.finite_rings 802 The following shows that the issue from :trac:`2849` is fixed:: - sage: E = EllipticCurve(GF(3^5,'a'),[-1,-1]) - sage: E.trace_of_frobenius() + sage: E = EllipticCurve(GF(3^5,'a'),[-1,-1]) # needs sage.rings.finite_rings + sage: E.trace_of_frobenius() # needs sage.rings.finite_rings -27 """ return 1 + self.base_field().order() - self.cardinality() @@ -437,6 +444,7 @@ def cardinality(self, algorithm=None, extension_degree=1): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: EllipticCurve(GF(4, 'a'), [1,2,3,4,5]).cardinality() 8 sage: k. = GF(3^3) @@ -446,12 +454,14 @@ def cardinality(self, algorithm=None, extension_degree=1): :: + sage: # needs sage.rings.finite_rings sage: l = [1, 1, 0, 2, 0] sage: EllipticCurve(k, l).cardinality() 38 An even bigger extension (which we check against Magma):: + sage: # needs sage.rings.finite_rings sage: EllipticCurve(GF(3^100, 'a'), [1,2,3,4,5]).cardinality() 515377520732011331036459693969645888996929981504 sage: magma.eval("Order(EllipticCurve([GF(3^100)|1,2,3,4,5]))") # optional - magma @@ -468,6 +478,7 @@ def cardinality(self, algorithm=None, extension_degree=1): The cardinality is cached:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(3^100, 'a'), [1,2,3,4,5]) sage: E.cardinality() is E.cardinality() True @@ -475,6 +486,7 @@ def cardinality(self, algorithm=None, extension_degree=1): The following is very fast since the curve is actually defined over the prime field:: + sage: # needs sage.rings.finite_rings sage: k. = GF(11^100) sage: E1 = EllipticCurve(k, [3,3]) sage: N1 = E1.cardinality(algorithm="subfield"); N1 @@ -491,17 +503,20 @@ def cardinality(self, algorithm=None, extension_degree=1): We can count points over curves defined as a reduction:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) sage: K. = NumberField(x^2 + x + 1) sage: EK = EllipticCurve(K, [0, 0, w, 2, 1]) sage: E = EK.base_extend(K.residue_field(2)) sage: E - Elliptic Curve defined by y^2 + wbar*y = x^3 + 1 over Residue field in wbar of Fractional ideal (2) + Elliptic Curve defined by y^2 + wbar*y = x^3 + 1 + over Residue field in wbar of Fractional ideal (2) sage: E.cardinality() 7 sage: E = EK.base_extend(K.residue_field(w - 1)) sage: E.abelian_group() - Trivial group embedded in Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 + 2*x + 1 over Residue field of Fractional ideal (w - 1) + Trivial group embedded in Abelian group of points on Elliptic Curve defined + by y^2 + y = x^3 + 2*x + 1 over Residue field of Fractional ideal (w - 1) :: @@ -510,7 +525,9 @@ def cardinality(self, algorithm=None, extension_degree=1): sage: k. = R.residue_field(pol) sage: E = EllipticCurve(R, [1, x]).base_extend(k) sage: E - Elliptic Curve defined by y^2 = x^3 + x + a over Residue field in a of Principal ideal (x^5 + x + 14) of Univariate Polynomial Ring in x over Finite Field of size 17 + Elliptic Curve defined by y^2 = x^3 + x + a + over Residue field in a of Principal ideal (x^5 + x + 14) + of Univariate Polynomial Ring in x over Finite Field of size 17 sage: E.cardinality() 1421004 @@ -532,6 +549,7 @@ def cardinality(self, algorithm=None, extension_degree=1): Check that a bug noted at :trac:`15667` is fixed:: + sage: # needs sage.rings.finite_rings sage: F. = GF(3^6) sage: EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]).cardinality() 784 @@ -614,6 +632,7 @@ def frobenius_polynomial(self): For some supersingular curves, Frobenius is in Z and the polynomial is a square:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(25,'a'),[0,0,0,0,1]) sage: E.frobenius_polynomial().factor() (x + 5)^2 @@ -640,6 +659,7 @@ def frobenius_order(self): For some supersingular curves, Frobenius is in Z and the Frobenius order is Z:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(25,'a'),[0,0,0,0,1]) sage: R = E.frobenius_order() sage: R @@ -671,6 +691,7 @@ def frobenius(self): For some supersingular curves, Frobenius is in Z:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(25,'a'),[0,0,0,0,1]) sage: E.frobenius() -5 @@ -688,6 +709,7 @@ def frobenius_endomorphism(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F. = GF(11^4) sage: E = EllipticCurve([t,t]) sage: E.frobenius_endomorphism() @@ -709,6 +731,7 @@ def frobenius_discriminant(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F. = GF(11^4) sage: E = EllipticCurve([t,t]) sage: E.frobenius_discriminant() @@ -736,6 +759,7 @@ def cardinality_pari(self): Since :trac:`16931`, this now works over finite fields which are not prime fields:: + sage: # needs sage.rings.finite_rings sage: k. = GF(7^3) sage: E = EllipticCurve_from_j(a) sage: E.cardinality_pari() @@ -747,7 +771,7 @@ def cardinality_pari(self): TESTS:: - sage: E.cardinality_pari().parent() + sage: E.cardinality_pari().parent() # needs sage.rings.finite_rings Integer Ring """ return Integer(self.__pari__().ellcard()) @@ -800,7 +824,9 @@ def gens(self): instead:: sage: E.abelian_group() - Additive abelian group isomorphic to Z/22 + Z/2 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 2*x + 5 over Finite Field of size 41 + Additive abelian group isomorphic to Z/22 + Z/2 + embedded in Abelian group of points on Elliptic Curve + defined by y^2 = x^3 + 2*x + 5 over Finite Field of size 41 sage: ab_gens = E.abelian_group().gens() sage: ab_gens == E.gens() True @@ -811,6 +837,7 @@ def gens(self): Examples with 1 and 0 generators:: + sage: # needs sage.rings.finite_rings sage: F. = GF(3^6) sage: E = EllipticCurve([a, a+1]) sage: pts = E.gens() @@ -818,6 +845,7 @@ def gens(self): 1 sage: pts[0].order() == E.cardinality() True + sage: E = EllipticCurve(GF(2), [0,0,1,1,1]) sage: E.gens() () @@ -825,6 +853,7 @@ def gens(self): This works over larger finite fields where :meth:`abelian_group` may be too expensive:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^60) sage: E = EllipticCurve([a, a]) sage: len(E.gens()) @@ -951,6 +980,7 @@ def abelian_group(self): :: + sage: # needs sage.rings.finite_rings sage: F. = GF(3^6,'a') sage: E = EllipticCurve([a^4 + a^3 + 2*a^2 + 2*a, 2*a^5 + 2*a^3 + 2*a^2 + 1]) sage: E.abelian_group() @@ -958,6 +988,7 @@ def abelian_group(self): :: + sage: # needs sage.rings.finite_rings sage: F. = GF(101^3,'a') sage: E = EllipticCurve([2*a^2 + 48*a + 27, 89*a^2 + 76*a + 24]) sage: E.abelian_group() @@ -987,6 +1018,7 @@ def abelian_group(self): This tests that the bug reported in :trac:`3926` has been fixed:: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(-1) sage: OK = K.ring_of_integers() sage: P = K.factor(10007)[0][0] @@ -1038,6 +1070,7 @@ def torsion_basis(self, n): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(62207^2), [1,0]) sage: E.abelian_group() Additive abelian group isomorphic to Z/62208 + Z/62208 embedded in @@ -1121,6 +1154,7 @@ def is_isogenous(self, other, field=None, proof=True): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: E1 = EllipticCurve(GF(11^2,'a'),[2,7]); E1 Elliptic Curve defined by y^2 = x^3 + 2*x + 7 over Finite Field in a of size 11^2 sage: E1.is_isogenous(5) @@ -1130,6 +1164,7 @@ def is_isogenous(self, other, field=None, proof=True): sage: E1.is_isogenous(E1) True + sage: # needs sage.rings.finite_rings sage: E2 = EllipticCurve(GF(7^3,'b'),[3,1]); E2 Elliptic Curve defined by y^2 = x^3 + 3*x + 1 over Finite Field in b of size 7^3 sage: E1.is_isogenous(E2) @@ -1137,16 +1172,19 @@ def is_isogenous(self, other, field=None, proof=True): ... ValueError: The base fields must have the same characteristic. + sage: # needs sage.rings.finite_rings sage: E3 = EllipticCurve(GF(11^2,'c'),[4,3]); E3 Elliptic Curve defined by y^2 = x^3 + 4*x + 3 over Finite Field in c of size 11^2 sage: E1.is_isogenous(E3) False + sage: # needs sage.rings.finite_rings sage: E4 = EllipticCurve(GF(11^6,'d'),[6,5]); E4 Elliptic Curve defined by y^2 = x^3 + 6*x + 5 over Finite Field in d of size 11^6 sage: E1.is_isogenous(E4) True + sage: # needs sage.rings.finite_rings sage: E5 = EllipticCurve(GF(11^7,'e'),[4,2]); E5 Elliptic Curve defined by y^2 = x^3 + 4*x + 2 over Finite Field in e of size 11^7 sage: E1.is_isogenous(E5) @@ -1156,6 +1194,7 @@ def is_isogenous(self, other, field=None, proof=True): When the field is given:: + sage: # needs sage.rings.finite_rings sage: E1 = EllipticCurve(GF(13^2,'a'),[2,7]); E1 Elliptic Curve defined by y^2 = x^3 + 2*x + 7 over Finite Field in a of size 13^2 sage: E1.is_isogenous(5,GF(13^6,'f')) @@ -1664,10 +1703,12 @@ def twists(self): `j=0=1728`, when there are either 4 or 6 depending on whether the field has odd or even degree over `\GF{3}`:: + sage: # needs sage.rings.finite_rings sage: K = GF(3**5) sage: [E.ainvs() for E in EllipticCurve(j=K(1)).twists()] [(0, 1, 0, 0, 2), (0, z5, 0, 0, 2*z5^3)] + sage: # needs sage.rings.finite_rings sage: K = GF(3**5) sage: [E.ainvs() for E in EllipticCurve(j=K(0)).twists()] # random [(0, 0, 0, 1, 0), @@ -1675,10 +1716,12 @@ def twists(self): (0, 0, 0, 2, z5^4 + z5^3 + z5^2), (0, 0, 0, 2, 2*z5^4 + 2*z5^3 + 2*z5^2)] + sage: # needs sage.rings.finite_rings sage: K = GF(3**4) sage: [E.ainvs() for E in EllipticCurve(j=K(1)).twists()] [(0, 1, 0, 0, 2), (0, z4, 0, 0, 2*z4^3)] + sage: # needs sage.rings.finite_rings sage: K = GF(3**4) sage: [E.ainvs() for E in EllipticCurve(j=K(0)).twists()] # random [(0, 0, 0, 1, 0), @@ -1692,18 +1735,22 @@ def twists(self): `j=0=1728`, when there are either 3 or 7 depending on whether the field has odd or even degree over `\GF{2}`:: + sage: # needs sage.rings.finite_rings sage: K = GF(2**7) sage: [E.ainvs() for E in EllipticCurve(j=K(1)).twists()] [(1, 0, 0, 0, 1), (1, 1, 0, 0, 1)] + sage: # needs sage.rings.finite_rings sage: K = GF(2**7) sage: [E.ainvs() for E in EllipticCurve(j=K(0)).twists()] [(0, 0, 1, 0, 0), (0, 0, 1, 1, 0), (0, 0, 1, 1, 1)] + sage: # needs sage.rings.finite_rings sage: K = GF(2**8) sage: [E.ainvs() for E in EllipticCurve(j=K(1)).twists()] # random [(1, 0, 0, 0, 1), (1, z8^7 + z8^6 + z8^5 + z8^4 + z8^2 + z8, 0, 0, 1)] + sage: # needs sage.rings.finite_rings sage: K = GF(2**8) sage: [E.ainvs() for E in EllipticCurve(j=K(0)).twists()] # random [(0, 0, 1, 0, 0), @@ -1718,6 +1765,7 @@ def twists(self): Randomized check that we find all twists and there are no duplicates:: + sage: # needs sage.rings.finite_rings sage: p = next_prime(randrange(2,100)) sage: e = randrange(1,10) sage: F. = GF((p,e)) @@ -1799,7 +1847,7 @@ def curves_with_j_0(K): Elliptic Curve defined by y^2 = x^3 + 4 over Finite Field of size 7, Elliptic Curve defined by y^2 = x^3 + 5 over Finite Field of size 7, Elliptic Curve defined by y^2 = x^3 + 6 over Finite Field of size 7] - sage: curves_with_j_0(GF(25)) + sage: curves_with_j_0(GF(25)) # needs sage.rings.finite_rings [Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in z2 of size 5^2, Elliptic Curve defined by y^2 = x^3 + z2 over Finite Field in z2 of size 5^2, Elliptic Curve defined by y^2 = x^3 + (z2+3) over Finite Field in z2 of size 5^2, @@ -1858,7 +1906,7 @@ def curves_with_j_1728(K): Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 5, Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 5, Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 5] - sage: curves_with_j_1728(GF(49)) + sage: curves_with_j_1728(GF(49)) # needs sage.rings.finite_rings [Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 7^2, Elliptic Curve defined by y^2 = x^3 + z2*x over Finite Field in z2 of size 7^2, Elliptic Curve defined by y^2 = x^3 + (z2+4)*x over Finite Field in z2 of size 7^2, @@ -1908,6 +1956,7 @@ def curves_with_j_0_char2(K): In odd degree, there are three isomorphism classes all with representatives defined over `\GF{2}`:: sage: from sage.schemes.elliptic_curves.ell_finite_field import curves_with_j_0_char2 + sage: # needs sage.rings.finite_rings sage: K = GF(2**7) sage: curves = curves_with_j_0_char2(K) sage: len(curves) @@ -1917,17 +1966,19 @@ def curves_with_j_0_char2(K): Check that the curves are mutually non-isomorphic:: - sage: all((e1 == e2 or not e1.is_isomorphic(e2)) for e1 in curves for e2 in curves) + sage: all((e1 == e2 or not e1.is_isomorphic(e2)) # needs sage.rings.finite_rings + ....: for e1 in curves for e2 in curves) True Check that the weight formula holds:: - sage: sum(1/len(E.automorphisms()) for E in curves) == 1 + sage: sum(1/len(E.automorphisms()) for E in curves) == 1 # needs sage.rings.finite_rings True In even degree there are seven isomorphism classes:: sage: from sage.schemes.elliptic_curves.ell_finite_field import curves_with_j_0_char2 + sage: # needs sage.rings.finite_rings sage: K = GF(2**8) sage: curves = EllipticCurve(j=K(0)).twists() sage: len(curves) @@ -1943,12 +1994,13 @@ def curves_with_j_0_char2(K): Check that the twists are mutually non-isomorphic:: - sage: all((e1 == e2 or not e1.is_isomorphic(e2)) for e1 in curves for e2 in curves) + sage: all((e1 == e2 or not e1.is_isomorphic(e2)) # needs sage.rings.finite_rings + ....: for e1 in curves for e2 in curves) True Check that the weight formula holds:: - sage: sum(1/len(E.automorphisms()) for E in curves) == 1 + sage: sum(1/len(E.automorphisms()) for E in curves) == 1 # needs sage.rings.finite_rings True """ if not K.is_finite() or K.characteristic() != 2: @@ -1997,6 +2049,7 @@ def curves_with_j_0_char3(K): In odd degree, there are four isomorphism classes:: sage: from sage.schemes.elliptic_curves.ell_finite_field import curves_with_j_0_char3 + sage: # needs sage.rings.finite_rings sage: K = GF(3**5) sage: curves = curves_with_j_0_char3(K) sage: len(curves) @@ -2009,17 +2062,19 @@ def curves_with_j_0_char3(K): Check that the twists are mutually non-isomorphic:: - sage: all((e1 == e2 or not e1.is_isomorphic(e2)) for e1 in curves for e2 in curves) + sage: all((e1 == e2 or not e1.is_isomorphic(e2)) # needs sage.rings.finite_rings + ....: for e1 in curves for e2 in curves) True Check that the weight formula holds:: - sage: sum(1/len(E.automorphisms()) for E in curves) == 1 + sage: sum(1/len(E.automorphisms()) for E in curves) == 1 # needs sage.rings.finite_rings True In even degree, there are six isomorphism classes:: sage: from sage.schemes.elliptic_curves.ell_finite_field import curves_with_j_0_char3 + sage: # needs sage.rings.finite_rings sage: K = GF(3**4) sage: curves = EllipticCurve(j=K(0)).twists() sage: len(curves) @@ -2034,12 +2089,13 @@ def curves_with_j_0_char3(K): Check that the twists are mutually non-isomorphic:: - sage: all((e1 == e2 or not e1.is_isomorphic(e2)) for e1 in curves for e2 in curves) + sage: all((e1 == e2 or not e1.is_isomorphic(e2)) # needs sage.rings.finite_rings + ....: for e1 in curves for e2 in curves) True Check that the weight formula holds:: - sage: sum(1/len(E.automorphisms()) for E in curves) == 1 + sage: sum(1/len(E.automorphisms()) for E in curves) == 1 # needs sage.rings.finite_rings True """ if not K.is_finite() or K.characteristic() != 3: @@ -2071,6 +2127,7 @@ def curves_with_j_0_char3(K): # dict to hold precomputed coefficient vectors of supersingular j values (excluding 0, 1728): + supersingular_j_polynomials = {} def fill_ss_j_dict(): @@ -2258,7 +2315,8 @@ def is_j_supersingular(j, proof=True): sage: from sage.schemes.elliptic_curves.ell_finite_field import is_j_supersingular, supersingular_j_polynomials sage: [(p,[j for j in GF(p) if is_j_supersingular(j)]) for p in prime_range(30)] - [(2, [0]), (3, [0]), (5, [0]), (7, [6]), (11, [0, 1]), (13, [5]), (17, [0, 8]), (19, [7, 18]), (23, [0, 3, 19]), (29, [0, 2, 25])] + [(2, [0]), (3, [0]), (5, [0]), (7, [6]), (11, [0, 1]), (13, [5]), + (17, [0, 8]), (19, [7, 18]), (23, [0, 3, 19]), (29, [0, 2, 25])] sage: [j for j in GF(109) if is_j_supersingular(j)] [17, 41, 43] diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py index c7a4bb94e73..8e7fb204892 100644 --- a/src/sage/schemes/elliptic_curves/ell_generic.py +++ b/src/sage/schemes/elliptic_curves/ell_generic.py @@ -19,13 +19,13 @@ We construct an elliptic curve over an elaborate base ring:: sage: p, a, b = 97, 1, 3 - sage: R. = GF(p)[] # optional - sage.rings.finite_rings - sage: S. = R[] # optional - sage.rings.finite_rings - sage: T = S.fraction_field() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(T, [a, b]); E # optional - sage.rings.finite_rings + sage: R. = GF(p)[] + sage: S. = R[] + sage: T = S.fraction_field() + sage: E = EllipticCurve(T, [a, b]); E Elliptic Curve defined by y^2 = x^3 + x + 3 over Fraction Field of Univariate Polynomial Ring in v over Univariate Polynomial Ring in u over Finite Field of size 97 - sage: latex(E) # optional - sage.rings.finite_rings + sage: latex(E) y^2 = x^{3} + x + 3 AUTHORS: @@ -143,7 +143,7 @@ def __init__(self, K, ainvs): sage: E = EllipticCurve([1,2,3,4,5]); E Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field - sage: E = EllipticCurve(GF(7), [1,2,3,4,5]); E # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [1,2,3,4,5]); E Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 7 @@ -253,8 +253,8 @@ def _repr_(self): :: sage: R. = QQ['x'] - sage: K. = NumberField(x^3 - 17) # optional - sage.rings.number_field - sage: EllipticCurve([a^2 - 3, -2/3*a + 3]) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 17) # needs sage.rings.number_field + sage: EllipticCurve([a^2 - 3, -2/3*a + 3]) # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (a^2-3)*x + (-2/3*a+3) over Number Field in a with defining polynomial x^3 - 17 @@ -283,9 +283,9 @@ def _latex_(self): Check that :trac:`12524` is solved:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, phi, 27*phi - 43, -80*phi + 128]) # optional - sage.rings.number_field - sage: E._latex_() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) # needs sage.rings.number_field + sage: E = EllipticCurve([0, 0, phi, 27*phi - 43, -80*phi + 128]) # needs sage.rings.number_field + sage: E._latex_() # needs sage.rings.number_field 'y^2 + \\phi y = x^{3} + \\left(27 \\phi - 43\\right) x - 80 \\phi + 128 ' """ from sage.rings.polynomial.polynomial_ring import polygen @@ -321,19 +321,20 @@ def _magma_init_(self, magma): EXAMPLES:: + sage: # optional - magma sage: E = EllipticCurve(QQ, [1,1]) - sage: E._magma_init_(magma) # optional - magma + sage: E._magma_init_(magma) 'EllipticCurve([_sage_ref...|0/1,0/1,0/1,1/1,1/1])' - sage: E = EllipticCurve(GF(41), [2,5]) # optional - sage.rings.finite_rings - sage: E._magma_init_(magma) # optional - magma # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(41), [2,5]) + sage: E._magma_init_(magma) 'EllipticCurve([_sage_ref...|GF(41)!0,GF(41)!0,GF(41)!0,GF(41)!2,GF(41)!5])' - sage: E = EllipticCurve(GF(25,'a'), [0,0,1,4,0]) # optional - sage.rings.finite_rings - sage: magma(E) # optional - magma # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(25,'a'), [0,0,1,4,0]) # needs sage.rings.finite_rings + sage: magma(E) # needs sage.rings.finite_rings Elliptic Curve defined by y^2 + y = x^3 + 4*x over GF(5^2) - sage: magma(EllipticCurve([1/2,2/3,-4/5,6/7,8/9])) # optional - magma + sage: magma(EllipticCurve([1/2,2/3,-4/5,6/7,8/9])) Elliptic Curve defined by y^2 + 1/2*x*y - 4/5*y = x^3 + 2/3*x^2 + 6/7*x + 8/9 over Rational Field sage: R. = Frac(QQ['x']) - sage: magma(EllipticCurve([x, 1 + x])) # optional - magma + sage: magma(EllipticCurve([x, 1 + x])) Elliptic Curve defined by y^2 = x^3 + x*x + (x + 1) over Univariate rational function field over Rational Field """ @@ -351,29 +352,29 @@ def _symbolic_(self, SR): :: sage: E = EllipticCurve('11a') - sage: E._symbolic_(SR) # optional - sage.symbolic + sage: E._symbolic_(SR) # needs sage.symbolic y^2 + y == x^3 - x^2 - 10*x - 20 - sage: E.torsion_subgroup().gens() # optional - sage.symbolic + sage: E.torsion_subgroup().gens() # needs sage.symbolic ((5 : 5 : 1),) We find the corresponding symbolic equality:: - sage: eqn = symbolic_expression(E); eqn # optional - sage.symbolic + sage: eqn = symbolic_expression(E); eqn # needs sage.symbolic y^2 + y == x^3 - x^2 - 10*x - 20 We verify that the given point is on the curve:: - sage: eqn(x=5, y=5) # optional - sage.symbolic + sage: eqn(x=5, y=5) # needs sage.symbolic 30 == 30 - sage: bool(eqn(x=5, y=5)) # optional - sage.symbolic + sage: bool(eqn(x=5, y=5)) # needs sage.symbolic True We create a single expression:: - sage: F = eqn.lhs() - eqn.rhs(); F # optional - sage.symbolic + sage: F = eqn.lhs() - eqn.rhs(); F # needs sage.symbolic -x^3 + x^2 + y^2 + 10*x + y + 20 - sage: y = var('y') # optional - sage.symbolic - sage: F.solve(y) # optional - sage.symbolic + sage: y = var('y') # needs sage.symbolic + sage: F.solve(y) # needs sage.symbolic [y == -1/2*sqrt(4*x^3 - 4*x^2 - 40*x - 79) - 1/2, y == 1/2*sqrt(4*x^3 - 4*x^2 - 40*x - 79) - 1/2] @@ -381,44 +382,46 @@ def _symbolic_(self, SR): horrendous. Continuing with the above example, we can explicitly find points over random fields by substituting in values for x:: - sage: v = F.solve(y)[0].rhs(); v # optional - sage.symbolic + sage: # needs sage.symbolic + sage: v = F.solve(y)[0].rhs(); v -1/2*sqrt(4*x^3 - 4*x^2 - 40*x - 79) - 1/2 - sage: v = v.function(x) # optional - sage.symbolic - sage: v(3) # optional - sage.symbolic + sage: v = v.function(x) + sage: v(3) -1/2*sqrt(-127) - 1/2 - sage: v(7) # optional - sage.symbolic + sage: v(7) -1/2*sqrt(817) - 1/2 - sage: v(-7) # optional - sage.symbolic + sage: v(-7) -1/2*sqrt(-1367) - 1/2 - sage: v(sqrt(2)) # optional - sage.symbolic + sage: v(sqrt(2)) -1/2*sqrt(-32*sqrt(2) - 87) - 1/2 We can even do arithmetic with them, as follows:: - sage: E2 = E.change_ring(SR); E2 # optional - sage.symbolic + sage: # needs sage.symbolic + sage: E2 = E.change_ring(SR); E2 Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Symbolic Ring - sage: P = E2.point((3, v(3), 1), check=False) # the check=False option doesn't verify that y^2 = f(x) # optional - sage.symbolic - sage: P # optional - sage.symbolic + sage: P = E2.point((3, v(3), 1), check=False) # the check=False option doesn't verify that y^2 = f(x) + sage: P (3 : -1/2*sqrt(-127) - 1/2 : 1) - sage: P + P # optional - sage.symbolic + sage: P + P (-756/127 : 41143/32258*sqrt(-127) - 1/2 : 1) We can even throw in a transcendental:: - sage: w = E2.point((pi,v(pi),1), check=False); w # optional - sage.symbolic + sage: w = E2.point((pi,v(pi),1), check=False); w # needs sage.symbolic (pi : -1/2*sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1/2 : 1) - sage: x, y, z = w; ((y^2 + y) - (x^3 - x^2 - 10*x - 20)).expand() # optional - sage.symbolic + sage: x, y, z = w; ((y^2 + y) - (x^3 - x^2 - 10*x - 20)).expand() # needs sage.symbolic 0 - sage: 2*w # optional - sage.symbolic + sage: 2*w # needs sage.symbolic (-2*pi - (2*pi - 3*pi^2 + 10)^2/(40*pi - 4*pi^3 + 4*pi^2 + 79) + 1 : (3*pi + (2*pi - 3*pi^2 + 10)^2/(40*pi - 4*pi^3 + 4*pi^2 + 79) - 1)*(2*pi - 3*pi^2 + 10)/sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1/2*sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1/2 : 1) - sage: x, y, z = 2*w; temp = ((y^2 + y) - (x^3 - x^2 - 10*x - 20)) # optional - sage.symbolic + sage: x, y, z = 2*w; temp = ((y^2 + y) - (x^3 - x^2 - 10*x - 20)) # needs sage.symbolic This is a point on the curve:: - sage: bool(temp == 0) # optional - sage.symbolic + sage: bool(temp == 0) # needs sage.symbolic True """ a = [SR(x) for x in self.a_invariants()] @@ -438,15 +441,15 @@ def __contains__(self, P): True sage: (1,3) in E False - sage: E = EllipticCurve([GF(7)(0), 1]) # optional - sage.rings.finite_rings - sage: [0,0] in E # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(0), 1]) + sage: [0,0] in E False - sage: [0,8] in E # optional - sage.rings.finite_rings + sage: [0,8] in E True - sage: P = E(0,8) # optional - sage.rings.finite_rings - sage: P # optional - sage.rings.finite_rings + sage: P = E(0,8) + sage: P (0 : 1 : 1) - sage: P in E # optional - sage.rings.finite_rings + sage: P in E True """ if not isinstance(P, ell_point.EllipticCurvePoint): @@ -496,10 +499,10 @@ def __call__(self, *args, **kwds): We create points on an elliptic curve over a prime finite field:: - sage: E = EllipticCurve([GF(7)(0), 1]) # optional - sage.rings.finite_rings - sage: E([2,3]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(0), 1]) + sage: E([2,3]) (2 : 3 : 1) - sage: E([0,0]) # optional - sage.rings.finite_rings + sage: E([0,0]) Traceback (most recent call last): ... TypeError: Coordinates [0, 0, 1] do not define a point @@ -507,20 +510,21 @@ def __call__(self, *args, **kwds): We create a point on an elliptic curve over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(RationalField()) - sage: K = NumberField(x**3 + x + 1, 'a'); a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve([a, a]) # optional - sage.rings.number_field - sage: E # optional - sage.rings.number_field + sage: K = NumberField(x**3 + x + 1, 'a'); a = K.gen() + sage: E = EllipticCurve([a, a]) + sage: E Elliptic Curve defined by y^2 = x^3 + a*x + a over Number Field in a with defining polynomial x^3 + x + 1 - sage: E = EllipticCurve([K(1), 1]) # optional - sage.rings.number_field - sage: E # optional - sage.rings.number_field + sage: E = EllipticCurve([K(1), 1]) + sage: E Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^3 + x + 1 - sage: P = E([a,0,1]) # optional - sage.rings.number_field - sage: P # optional - sage.rings.number_field + sage: P = E([a,0,1]) + sage: P (a : 0 : 1) - sage: P + P # optional - sage.rings.number_field + sage: P + P (0 : 1 : 0) Another example involving p-adics:: @@ -528,12 +532,12 @@ def __call__(self, *args, **kwds): sage: E = EllipticCurve('37a1') sage: P = E([0,0]); P (0 : 0 : 1) - sage: R = pAdicField(3, 20) # optional - sage.rings.padics - sage: Ep = E.base_extend(R); Ep # optional - sage.rings.padics + sage: R = pAdicField(3, 20) # needs sage.rings.padics + sage: Ep = E.base_extend(R); Ep # needs sage.rings.padics Elliptic Curve defined by y^2 + (1+O(3^20))*y = x^3 + (2+2*3+2*3^2+2*3^3+2*3^4+2*3^5+2*3^6+2*3^7+2*3^8+2*3^9+2*3^10+2*3^11+2*3^12+2*3^13+2*3^14+2*3^15+2*3^16+2*3^17+2*3^18+2*3^19+O(3^20))*x over 3-adic Field with capped relative precision 20 - sage: Ep(P) + sage: Ep(P) # needs sage.rings.padics (0 : 0 : 1 + O(3^20)) Constructing points from the torsion subgroup (which is an abstract @@ -622,14 +626,14 @@ def _reduce_point(self, R, p): point at infinity on the same curve but reduced modulo 11. The reduce function tells us this:: - sage: E11 = E.change_ring(GF(11)) # optional - sage.rings.finite_rings - sage: S = E11._reduce_point(R, 11) # optional - sage.rings.finite_rings - sage: E11(S) # optional - sage.rings.finite_rings + sage: E11 = E.change_ring(GF(11)) + sage: S = E11._reduce_point(R, 11) + sage: E11(S) (0 : 1 : 0) The 0 point reduces as expected:: - sage: E11._reduce_point(E(0), 11) # optional - sage.rings.finite_rings + sage: E11._reduce_point(E(0), 11) (0 : 1 : 0) Note that one need not explicitly call @@ -690,9 +694,9 @@ def is_x_coord(self, x): :: - sage: F = GF(32,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F,[1,0,0,0,1]) # optional - sage.rings.finite_rings - sage: set(P[0] for P in E.points() if P!=E(0)) == set(x for x in F if E.is_x_coord(x)) # optional - sage.rings.finite_rings + sage: F = GF(32,'a') # needs sage.rings.finite_rings + sage: E = EllipticCurve(F,[1,0,0,0,1]) # needs sage.rings.finite_rings + sage: set(P[0] for P in E.points() if P!=E(0)) == set(x for x in F if E.is_x_coord(x)) # needs sage.rings.finite_rings True """ K = self.base_ring() @@ -772,9 +776,9 @@ def lift_x(self, x, all=False, extend=False): point is a point on a new curve object, the result of changing the base ring to the parent of `x`:: - sage: P = E.lift_x(3, extend=True); P # optional - sage.rings.number_field + sage: P = E.lift_x(3, extend=True); P # needs sage.rings.number_field (3 : -y - 1 : 1) - sage: P.curve() # optional - sage.rings.number_field + sage: P.curve() # needs sage.rings.number_field Elliptic Curve defined by y^2 + y = x^3 + (-1)*x over Number Field in y with defining polynomial y^2 + y - 24 @@ -798,19 +802,19 @@ def lift_x(self, x, all=False, extend=False): sage: E = EllipticCurve([0,0,0,0,2]); E Elliptic Curve defined by y^2 = x^3 + 2 over Rational Field - sage: P = E.lift_x(0, extend=True); P # optional - sage.rings.number_field + sage: P = E.lift_x(0, extend=True); P # needs sage.rings.number_field (0 : -y : 1) - sage: P.curve() # optional - sage.rings.number_field + sage: P.curve() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + 2 over Number Field in y with defining polynomial y^2 - 2 We can perform these operations over finite fields too:: - sage: E = EllipticCurve('37a').change_ring(GF(17)); E # optional - sage.rings.finite_rings + sage: E = EllipticCurve('37a').change_ring(GF(17)); E Elliptic Curve defined by y^2 + y = x^3 + 16*x over Finite Field of size 17 - sage: E.lift_x(7) # optional - sage.rings.finite_rings + sage: E.lift_x(7) (7 : 5 : 1) - sage: E.lift_x(3) # optional - sage.rings.finite_rings + sage: E.lift_x(3) Traceback (most recent call last): ... ValueError: No point with x-coordinate 3 on @@ -819,7 +823,7 @@ def lift_x(self, x, all=False, extend=False): Note that there is only one lift with `x`-coordinate 10 in `E(\GF{17})`:: - sage: E.lift_x(10, all=True) # optional - sage.rings.finite_rings + sage: E.lift_x(10, all=True) [(10 : 8 : 1)] We can lift over more exotic rings too. If the supplied x @@ -827,19 +831,19 @@ def lift_x(self, x, all=False, extend=False): returned is on the base-extended curve:: sage: E = EllipticCurve('37a') - sage: P = E.lift_x(pAdicField(17, 5)(6)); P # optional - sage.rings.padics + sage: P = E.lift_x(pAdicField(17, 5)(6)); P # needs sage.rings.padics (6 + O(17^5) : 14 + O(17^5) : 1 + O(17^5)) - sage: P.curve() # optional - sage.rings.padics + sage: P.curve() # needs sage.rings.padics Elliptic Curve defined by y^2 + (1+O(17^5))*y = x^3 + (16+16*17+16*17^2+16*17^3+16*17^4+O(17^5))*x over 17-adic Field with capped relative precision 5 sage: K. = PowerSeriesRing(QQ, 't', 5) sage: P = E.lift_x(1 + t); P (1 + t : -1 - 2*t + t^2 - 5*t^3 + 21*t^4 + O(t^5) : 1) - sage: K. = GF(16) # optional - sage.rings.finite_rings - sage: P = E.change_ring(K).lift_x(a^3); P # optional - sage.rings.finite_rings + sage: K. = GF(16) # needs sage.rings.finite_rings + sage: P = E.change_ring(K).lift_x(a^3); P # needs sage.rings.finite_rings (a^3 : a^3 + a : 1) - sage: P.curve() # optional - sage.rings.finite_rings + sage: P.curve() # needs sage.rings.finite_rings Elliptic Curve defined by y^2 + y = x^3 + x over Finite Field in a of size 2^4 We can extend the base field to include the associated `y` value(s):: @@ -864,9 +868,9 @@ def lift_x(self, x, all=False, extend=False): Check that :trac:`30297` is fixed:: - sage: K = Qp(5) # optional - sage.rings.padics - sage: E = EllipticCurve([K(0), K(1)]) # optional - sage.rings.padics - sage: E.lift_x(1, extend=True) # optional - sage.rings.padics + sage: K = Qp(5) # needs sage.rings.padics + sage: E = EllipticCurve([K(0), K(1)]) # needs sage.rings.padics + sage: E.lift_x(1, extend=True) # needs sage.rings.padics (1 + O(5^20) : y + O(5^20) : 1 + O(5^20)) AUTHORS: @@ -876,10 +880,10 @@ def lift_x(self, x, all=False, extend=False): TESTS:: - sage: E = EllipticCurve('37a').short_weierstrass_model().change_ring(GF(17)) # optional - sage.rings.finite_rings - sage: E.lift_x(3, all=True) # optional - sage.rings.finite_rings + sage: E = EllipticCurve('37a').short_weierstrass_model().change_ring(GF(17)) + sage: E.lift_x(3, all=True) [] - sage: E.lift_x(7, all=True) # optional - sage.rings.finite_rings + sage: E.lift_x(7, all=True) [(7 : 3 : 1), (7 : 14 : 1)] Check determinism:: @@ -972,8 +976,8 @@ def _point_homset(self, *args, **kwds): EXAMPLES:: - sage: E = EllipticCurve(GF(5),[1,1]) # optional - sage.rings.finite_rings - sage: E._point_homset(Spec(GF(5^10,'a'), GF(5)), E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5),[1,1]) + sage: E._point_homset(Spec(GF(5^10,'a'), GF(5)), E) # needs sage.rings.finite_rings Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in a of size 5^10 @@ -1018,8 +1022,8 @@ def __is_over_RationalField(self): sage: E = EllipticCurve(QQ,[1,1]) sage: E._EllipticCurve_generic__is_over_RationalField() True - sage: E = EllipticCurve(GF(5),[1,1]) # optional - sage.rings.finite_rings - sage: E._EllipticCurve_generic__is_over_RationalField() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5),[1,1]) + sage: E._EllipticCurve_generic__is_over_RationalField() False """ return isinstance(self.base_ring(), RationalField) @@ -1062,8 +1066,8 @@ def a_invariants(self): sage: E.a_invariants() (0, 0, 0, 0, 1) - sage: E = EllipticCurve([GF(7)(3),5]) # optional - sage.rings.finite_rings - sage: E.a_invariants() # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(3),5]) + sage: E.a_invariants() (0, 0, 0, 3, 5) TESTS:: @@ -1308,8 +1312,8 @@ def discriminant(self): sage: E.discriminant() -161051 - sage: E = EllipticCurve([GF(7)(2),1]) # optional - sage.rings.finite_rings - sage: E.discriminant() # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(2),1]) + sage: E.discriminant() 1 """ b2, b4, b6, b8 = self.b_invariants() @@ -1336,8 +1340,8 @@ def j_invariant(self): sage: E.j_invariant() 1728 - sage: E = EllipticCurve([GF(7)(2),1]) # optional - sage.rings.finite_rings - sage: E.j_invariant() # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(2),1]) + sage: E.j_invariant() 1 """ c4, _ = self.c_invariants() @@ -1360,9 +1364,9 @@ def base_extend(self, R): EXAMPLES:: - sage: E = EllipticCurve(GF(5), [1,1]); E # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5), [1,1]); E Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 - sage: E1 = E.base_extend(GF(125,'a')); E1 # optional - sage.rings.finite_rings + sage: E1 = E.base_extend(GF(125,'a')); E1 # needs sage.rings.finite_rings Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in a of size 5^3 TESTS: @@ -1370,24 +1374,25 @@ def base_extend(self, R): Check that we are correctly keeping track of known cardinalities when extending the base field:: - sage: E = EllipticCurve(j=GF(7)(5)) # optional - sage.rings.finite_rings - sage: E.cardinality() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(5)) + sage: E.cardinality() 10 - sage: EE = E.base_extend(GF(7^2)) # optional - sage.rings.finite_rings - sage: EE._order # optional - sage.rings.finite_rings + sage: EE = E.base_extend(GF(7^2)) + sage: EE._order 60 Changing to a smaller field should not cache orders:: - sage: EE = EllipticCurve(j=GF(7^3)(6)) # optional - sage.rings.finite_rings - sage: hasattr(EE.change_ring(GF(7)), '_order') # optional - sage.rings.finite_rings + sage: EE = EllipticCurve(j=GF(7^3)(6)) # needs sage.rings.finite_rings + sage: hasattr(EE.change_ring(GF(7)), '_order') # needs sage.rings.finite_rings False Changing to a field of different characteristic should not cache orders:: - sage: Elift = E.change_ring(QQ) # optional - sage.rings.finite_rings - sage: hasattr(Elift, '_order') # optional - sage.rings.finite_rings + sage: Elift = E.change_ring(QQ) # needs sage.rings.finite_rings + sage: hasattr(Elift, '_order') # needs sage.rings.finite_rings False """ E = constructor.EllipticCurve([R(a) for a in self.a_invariants()]) @@ -1408,14 +1413,15 @@ def change_ring(self, R): EXAMPLES:: - sage: F2 = GF(5^2,'a'); a = F2.gen() # optional - sage.rings.finite_rings - sage: F4 = GF(5^4,'b'); b = F4.gen() # optional - sage.rings.finite_rings - sage: roots = a.charpoly().roots(ring=F4, multiplicities=False) # optional - sage.rings.finite_rings - sage: h = F2.hom([roots[0]], F4) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F2, [1,a]); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F2 = GF(5^2,'a'); a = F2.gen() + sage: F4 = GF(5^4,'b'); b = F4.gen() + sage: roots = a.charpoly().roots(ring=F4, multiplicities=False) + sage: h = F2.hom([roots[0]], F4) + sage: E = EllipticCurve(F2, [1,a]); E Elliptic Curve defined by y^2 = x^3 + x + a over Finite Field in a of size 5^2 - sage: E.change_ring(h) # optional - sage.rings.finite_rings + sage: E.change_ring(h) Elliptic Curve defined by y^2 = x^3 + x + (4*b^3+4*b^2+4*b+3) over Finite Field in b of size 5^4 """ @@ -1427,8 +1433,8 @@ def base_ring(self): EXAMPLES:: - sage: E = EllipticCurve(GF(49, 'a'), [3,5]) # optional - sage.rings.finite_rings - sage: E.base_ring() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(49, 'a'), [3,5]) # needs sage.rings.finite_rings + sage: E.base_ring() # needs sage.rings.finite_rings Finite Field in a of size 7^2 :: @@ -1660,12 +1666,12 @@ def division_polynomial_0(self, n, x=None): An example to illustrate the relationship with torsion points:: - sage: F = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0, 2]); E # optional - sage.rings.finite_rings + sage: F = GF(11) + sage: E = EllipticCurve(F, [0, 2]); E Elliptic Curve defined by y^2 = x^3 + 2 over Finite Field of size 11 - sage: f = E.division_polynomial_0(5); f # optional - sage.rings.finite_rings + sage: f = E.division_polynomial_0(5); f 5*x^12 + x^9 + 8*x^6 + 4*x^3 + 7 - sage: f.factor() # optional - sage.rings.finite_rings + sage: f.factor() (5) * (x^2 + 5) * (x^2 + 2*x + 5) * (x^2 + 5*x + 7) * (x^2 + 7*x + 7) * (x^2 + 9*x + 5) * (x^2 + 10*x + 7) @@ -1673,10 +1679,11 @@ def division_polynomial_0(self, n, x=None): `E` are in `\GF{11^2}`, and therefore the `y`-coordinates are in `\GF{11^4}`:: - sage: K = GF(11^4, 'a') # optional - sage.rings.finite_rings - sage: X = E.change_ring(K) # optional - sage.rings.finite_rings - sage: f = X.division_polynomial_0(5) # optional - sage.rings.finite_rings - sage: x_coords = f.roots(multiplicities=False); x_coords # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(11^4, 'a') + sage: X = E.change_ring(K) + sage: f = X.division_polynomial_0(5) + sage: x_coords = f.roots(multiplicities=False); x_coords [10*a^3 + 4*a^2 + 5*a + 6, 9*a^3 + 8*a^2 + 10*a + 8, 8*a^3 + a^2 + 4*a + 10, @@ -1693,7 +1700,7 @@ def division_polynomial_0(self, n, x=None): Now we check that these are exactly the `x`-coordinates of the 5-torsion points of `E`:: - sage: for x in x_coords: # optional - sage.rings.finite_rings + sage: for x in x_coords: # needs sage.rings.finite_rings ....: assert X.lift_x(x).order() == 5 The roots of the polynomial are the `x`-coordinates of the points `P` @@ -1783,10 +1790,10 @@ def two_division_polynomial(self, x=None): sage: E = EllipticCurve('5077a1') sage: E.two_division_polynomial() 4*x^3 - 28*x + 25 - sage: E = EllipticCurve(GF(3^2,'a'), [1,1,1,1,1]) # optional - sage.rings.finite_rings - sage: E.two_division_polynomial() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(3^2,'a'), [1,1,1,1,1]) # needs sage.rings.finite_rings + sage: E.two_division_polynomial() # needs sage.rings.finite_rings x^3 + 2*x^2 + 2 - sage: E.two_division_polynomial().roots() # optional - sage.rings.finite_rings + sage: E.two_division_polynomial().roots() # needs sage.rings.finite_rings [(2, 1), (2*a, 1), (a + 2, 1)] """ return self.division_polynomial_0(-1,x) @@ -2096,11 +2103,12 @@ def _multiple_x_numerator(self, n, x=None): Check for :trac:`33156`:: - sage: E = EllipticCurve(GF(65537), [5,5]) # optional - sage.rings.finite_rings - sage: R. = E.base_field()[] # optional - sage.rings.finite_rings - sage: E._multiple_x_numerator(5, x=R.quotient(x^2).gen()) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [5,5]) + sage: R. = E.base_field()[] + sage: E._multiple_x_numerator(5, x=R.quotient(x^2).gen()) 10220*xbar + 42539 - sage: E._multiple_x_numerator(5) # optional - sage.rings.finite_rings + sage: E._multiple_x_numerator(5) x^25 + 65037*x^23 + 55137*x^22 + ... + 813*x^2 + 10220*x + 42539 """ n = Integer(n).abs() @@ -2192,11 +2200,12 @@ def _multiple_x_denominator(self, n, x=None): Check for :trac:`33156`:: - sage: E = EllipticCurve(GF(65537), [5,5]) # optional - sage.rings.finite_rings - sage: R. = E.base_field()[] # optional - sage.rings.finite_rings - sage: E._multiple_x_denominator(5, x=R.quotient(x^2).gen()) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [5,5]) + sage: R. = E.base_field()[] + sage: E._multiple_x_denominator(5, x=R.quotient(x^2).gen()) 52039*xbar + 56726 - sage: E._multiple_x_denominator(5) # optional - sage.rings.finite_rings + sage: E._multiple_x_denominator(5) 25*x^24 + 3100*x^22 + 19000*x^21 + ... + 24111*x^2 + 52039*x + 56726 """ n = Integer(n).abs() @@ -2315,14 +2324,15 @@ def multiplication_by_m(self, m, x_only=False): The following test shows that :trac:`4364` is indeed fixed:: - sage: p = next_prime(2^30-41) # optional - sage.rings.finite_rings - sage: a = GF(p)(1) # optional - sage.rings.finite_rings - sage: b = GF(p)(1) # optional - sage.rings.finite_rings - sage: E = EllipticCurve([a, b]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: my_eval = lambda f,P: [fi(P[0],P[1]) for fi in f] # optional - sage.rings.finite_rings - sage: f = E.multiplication_by_m(2) # optional - sage.rings.finite_rings - sage: assert(E(eval(f,P)) == 2*P) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = next_prime(2^30 - 41) + sage: a = GF(p)(1) + sage: b = GF(p)(1) + sage: E = EllipticCurve([a, b]) + sage: P = E.random_point() + sage: my_eval = lambda f,P: [fi(P[0],P[1]) for fi in f] + sage: f = E.multiplication_by_m(2) + sage: assert(E(eval(f,P)) == 2*P) """ # Coerce the input m to be an integer m = Integer(m) @@ -2407,15 +2417,15 @@ def multiplication_by_m_isogeny(self, m): Tests for :trac:`32490`:: - sage: E = EllipticCurve(QQbar, [1,0]) # optional - sage.rings.number_field - sage: E.multiplication_by_m_isogeny(1).rational_maps() # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [1,0]) # needs sage.rings.number_field + sage: E.multiplication_by_m_isogeny(1).rational_maps() # needs sage.rings.number_field (x, y) :: - sage: E = EllipticCurve_from_j(GF(31337).random_element()) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: [E.multiplication_by_m_isogeny(m)(P) == m*P for m in (1,2,3,5,7,9)] # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(31337).random_element()) # needs sage.rings.finite_rings + sage: P = E.random_point() # needs sage.rings.finite_rings + sage: [E.multiplication_by_m_isogeny(m)(P) == m*P for m in (1,2,3,5,7,9)] # needs sage.rings.finite_rings [True, True, True, True, True, True] :: @@ -2501,15 +2511,16 @@ def frobenius_isogeny(self, n=1): EXAMPLES:: - sage: z3, = GF(13^3).gens() # optional - sage.rings.finite_rings - sage: E = EllipticCurve([z3, z3^2]) # optional - sage.rings.finite_rings - sage: E.frobenius_isogeny() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: z3, = GF(13^3).gens() + sage: E = EllipticCurve([z3, z3^2]) + sage: E.frobenius_isogeny() Frobenius isogeny of degree 13: From: Elliptic Curve defined by y^2 = x^3 + z3*x + z3^2 over Finite Field in z3 of size 13^3 To: Elliptic Curve defined by y^2 = x^3 + (5*z3^2+7*z3+11)*x + (5*z3^2+12*z3+1) over Finite Field in z3 of size 13^3 - sage: E.frobenius_isogeny(3) # optional - sage.rings.finite_rings + sage: E.frobenius_isogeny(3) Frobenius endomorphism of degree 2197 = 13^3: From: Elliptic Curve defined by y^2 = x^3 + z3*x + z3^2 over Finite Field in z3 of size 13^3 @@ -2562,8 +2573,8 @@ def isomorphism_to(self, other): We can also handle injections to different base rings:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 7) # optional - sage.rings.number_field - sage: E.isomorphism_to(E.change_ring(K)) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 7) # needs sage.rings.number_field + sage: E.isomorphism_to(E.change_ring(K)) # needs sage.rings.number_field Elliptic-curve morphism: From: Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field To: Elliptic Curve defined by y^2 + y = x^3 + (-1)*x @@ -2605,8 +2616,8 @@ def automorphisms(self, field=None): We can also find automorphisms defined over extension fields:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 3) # adjoin roots of unity # optional - sage.rings.number_field - sage: E.automorphisms(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 3) # adjoin roots of unity # needs sage.rings.number_field + sage: E.automorphisms(K) # needs sage.rings.number_field [Elliptic-curve endomorphism of Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^2 + 3 Via: (u,r,s,t) = (1, 0, 0, 0), @@ -2628,7 +2639,7 @@ def automorphisms(self, field=None): :: - sage: [len(EllipticCurve_from_j(GF(q,'a')(0)).automorphisms()) # optional - sage.rings.finite_rings + sage: [len(EllipticCurve_from_j(GF(q,'a')(0)).automorphisms()) # needs sage.rings.finite_rings ....: for q in [2,4,3,9,5,25,7,49]] [2, 24, 2, 12, 2, 6, 6, 6] @@ -2636,21 +2647,22 @@ def automorphisms(self, field=None): Random testing:: + sage: # needs sage.rings.finite_rings sage: p = random_prime(100) sage: k = randrange(1,30) - sage: F. = GF((p,k)) # optional - sage.rings.finite_rings - sage: while True: # optional - sage.rings.finite_rings + sage: F. = GF((p,k)) + sage: while True: ....: try: ....: E = EllipticCurve(list((F^5).random_element())) ....: except ArithmeticError: ....: continue ....: break - sage: Aut = E.automorphisms() # optional - sage.rings.finite_rings - sage: Aut[0] == E.scalar_multiplication(1) # optional - sage.rings.finite_rings + sage: Aut = E.automorphisms() + sage: Aut[0] == E.scalar_multiplication(1) True - sage: Aut[1] == E.scalar_multiplication(-1) # optional - sage.rings.finite_rings + sage: Aut[1] == E.scalar_multiplication(-1) True - sage: sorted(Aut) == Aut # optional - sage.rings.finite_rings + sage: sorted(Aut) == Aut True """ if field is not None: @@ -2689,11 +2701,12 @@ def isomorphisms(self, other, field=None): We can also find isomorphisms defined over extension fields:: - sage: E = EllipticCurve(GF(7), [0,0,0,1,1]) # optional - sage.rings.finite_rings - sage: F = EllipticCurve(GF(7), [0,0,0,1,-1]) # optional - sage.rings.finite_rings - sage: E.isomorphisms(F) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,1,1]) + sage: F = EllipticCurve(GF(7), [0,0,0,1,-1]) + sage: E.isomorphisms(F) [] - sage: E.isomorphisms(F, GF(49,'a')) # optional - sage.rings.finite_rings + sage: E.isomorphisms(F, GF(49,'a')) [Elliptic-curve morphism: From: Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in a of size 7^2 @@ -2821,28 +2834,28 @@ def short_weierstrass_model(self, complete_cube=True): :: - sage: E = EllipticCurve(GF(3), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: E.short_weierstrass_model(complete_cube=False) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(3), [1,2,3,4,5]) + sage: E.short_weierstrass_model(complete_cube=False) Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 3 This used to be different see :trac:`3973`:: - sage: E.short_weierstrass_model() # optional - sage.rings.finite_rings + sage: E.short_weierstrass_model() Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 3 More tests in characteristic 3:: - sage: E = EllipticCurve(GF(3), [0,2,1,2,1]) # optional - sage.rings.finite_rings - sage: E.short_weierstrass_model() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(3), [0,2,1,2,1]) + sage: E.short_weierstrass_model() Traceback (most recent call last): ... ValueError: short_weierstrass_model(): no short model for Elliptic Curve defined by y^2 + y = x^3 + 2*x^2 + 2*x + 1 over Finite Field of size 3 (characteristic is 3) - sage: E.short_weierstrass_model(complete_cube=False) # optional - sage.rings.finite_rings + sage: E.short_weierstrass_model(complete_cube=False) Elliptic Curve defined by y^2 = x^3 + 2*x^2 + 2*x + 2 over Finite Field of size 3 - sage: E.short_weierstrass_model(complete_cube=False).is_isomorphic(E) # optional - sage.rings.finite_rings + sage: E.short_weierstrass_model(complete_cube=False).is_isomorphic(E) True """ from . import constructor @@ -2915,22 +2928,22 @@ def montgomery_model(self, twisted=False, morphism=False): EXAMPLES:: - sage: E = EllipticCurve(QQbar, '11a1') # optional - sage.rings.number_field - sage: E.montgomery_model() # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, '11a1') # needs sage.rings.number_field + sage: E.montgomery_model() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (-1.953522420987248?)*x^2 + x over Algebraic Field :: - sage: E = EllipticCurve(GF(431^2), [7,7]) # optional - sage.rings.finite_rings - sage: E.montgomery_model() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(431^2), [7,7]) # needs sage.rings.finite_rings + sage: E.montgomery_model() # needs sage.rings.finite_rings Elliptic Curve defined by y^2 = x^3 + (51*z2+190)*x^2 + x over Finite Field in z2 of size 431^2 An isomorphism between the Montgomery and Weierstrass form can be obtained using the ``morphism`` parameter:: - sage: E.montgomery_model(morphism=True) # optional - sage.rings.finite_rings + sage: E.montgomery_model(morphism=True) # needs sage.rings.finite_rings (Elliptic Curve defined by y^2 = x^3 + (51*z2+190)*x^2 + x over Finite Field in z2 of size 431^2, Elliptic-curve morphism: @@ -2943,8 +2956,8 @@ def montgomery_model(self, twisted=False, morphism=False): Not all elliptic curves have a Montgomery model over their field of definition:: - sage: E = EllipticCurve(GF(257), [1,1]) # optional - sage.rings.finite_rings - sage: E.montgomery_model() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(257), [1,1]) + sage: E.montgomery_model() Traceback (most recent call last): ... ValueError: Elliptic Curve defined by y^2 = x^3 + x + 1 @@ -2952,8 +2965,8 @@ def montgomery_model(self, twisted=False, morphism=False): :: - sage: E = EllipticCurve(GF(257), [10,10]) # optional - sage.rings.finite_rings - sage: E.montgomery_model() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(257), [10,10]) + sage: E.montgomery_model() Traceback (most recent call last): ... ValueError: Elliptic Curve defined by y^2 = x^3 + 10*x + 10 @@ -2963,7 +2976,7 @@ def montgomery_model(self, twisted=False, morphism=False): admit a *twisted* Montgomery model, which can be computed by passing ``twisted=True``:: - sage: E.montgomery_model(twisted=True) # optional - sage.rings.finite_rings + sage: E.montgomery_model(twisted=True) Projective Plane Curve over Finite Field of size 257 defined by -x^3 + 8*x^2*z - 127*y^2*z - x*z^2 @@ -2977,8 +2990,8 @@ def montgomery_model(self, twisted=False, morphism=False): but can easily be emulated by mapping back and forth to the corresponding Weierstrass curve:: - sage: C, f = E.montgomery_model(twisted=True, morphism=True) # optional - sage.rings.finite_rings - sage: f # optional - sage.rings.finite_rings + sage: C, f = E.montgomery_model(twisted=True, morphism=True) + sage: f Scheme morphism: From: Elliptic Curve defined by y^2 = x^3 + 10*x + 10 over Finite Field of size 257 @@ -2986,7 +2999,7 @@ def montgomery_model(self, twisted=False, morphism=False): defined by -x^3 + 8*x^2*z - 127*y^2*z - x*z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + 116*z : -y : -85*z) - sage: g = f.inverse(); g # optional - sage.rings.finite_rings + sage: g = f.inverse(); g Scheme morphism: From: Projective Plane Curve over Finite Field of size 257 defined by -x^3 + 8*x^2*z - 127*y^2*z - x*z^2 @@ -2994,39 +3007,40 @@ def montgomery_model(self, twisted=False, morphism=False): over Finite Field of size 257 Defn: Defined on coordinates by sending (x : y : z) to (-85*x - 116*z : 85*y : z) - sage: P = C(70, 8) # optional - sage.rings.finite_rings - sage: Q = C(17, 17) # optional - sage.rings.finite_rings - sage: P + Q # this doesn't work... # optional - sage.rings.finite_rings + sage: P = C(70, 8) + sage: Q = C(17, 17) + sage: P + Q # this doesn't work... Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for +: ... - sage: f(g(P) + g(Q)) # ...but this does # optional - sage.rings.finite_rings + sage: f(g(P) + g(Q)) # ...but this does (107 : 168 : 1) Using the fact that the Weil pairing satisfies `e(\psi(P),\psi(Q)) = e(P,Q)^{\deg\psi}`, even pairings can be emulated in this way (note that isomorphisms have degree `1`):: - sage: F. = GF(257^2) # optional - sage.rings.finite_rings - sage: C_ = C.change_ring(F) # optional - sage.rings.finite_rings - sage: g_ = g.change_ring(F) # optional - sage.rings.finite_rings - sage: g_(P).order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(257^2) + sage: C_ = C.change_ring(F) + sage: g_ = g.change_ring(F) + sage: g_(P).order() 12 - sage: T = C_(-7 * z2 - 57, 31 * z2 - 52, 1) # optional - sage.rings.finite_rings - sage: g_(T).order() # optional - sage.rings.finite_rings + sage: T = C_(-7 * z2 - 57, 31 * z2 - 52, 1) + sage: g_(T).order() 12 - sage: g_(P).weil_pairing(g_(T), 12) # optional - sage.rings.finite_rings + sage: g_(P).weil_pairing(g_(T), 12) 15*z2 + 204 Another alternative is to simply extend the base field enough for the curve to have an untwisted Montgomery model:: - sage: C_ = E.change_ring(F).montgomery_model(); C_ # optional - sage.rings.finite_rings + sage: C_ = E.change_ring(F).montgomery_model(); C_ # needs sage.rings.finite_rings Elliptic Curve defined by y^2 = x^3 + 249*x^2 + x over Finite Field in z2 of size 257^2 - sage: h = C.defining_polynomial().change_ring(F); h # optional - sage.rings.finite_rings + sage: h = C.defining_polynomial().change_ring(F); h # needs sage.rings.finite_rings -x^3 + 8*x^2*z - 127*y^2*z - x*z^2 - sage: C_.is_isomorphic(EllipticCurve_from_cubic(h).codomain()) # optional - sage.rings.finite_rings + sage: C_.is_isomorphic(EllipticCurve_from_cubic(h).codomain()) # needs sage.rings.finite_rings True .. SEEALSO:: @@ -3137,28 +3151,28 @@ def plot(self, xmin=None, xmax=None, components='both', **args): EXAMPLES:: sage: E = EllipticCurve([0, -1]) - sage: plot(E, rgbcolor=hue(0.7)) # optional - sage.plot + sage: plot(E, rgbcolor=hue(0.7)) # needs sage.plot Graphics object consisting of 1 graphics primitive sage: E = EllipticCurve('37a') - sage: plot(E) # optional - sage.plot + sage: plot(E) # needs sage.plot Graphics object consisting of 2 graphics primitives - sage: plot(E, xmin=25, xmax=26) # optional - sage.plot + sage: plot(E, xmin=25, xmax=26) # needs sage.plot Graphics object consisting of 2 graphics primitives With :trac:`12766` we added the components keyword:: sage: E.real_components() 2 - sage: E.plot(components='bounded') # optional - sage.plot + sage: E.plot(components='bounded') # needs sage.plot Graphics object consisting of 1 graphics primitive - sage: E.plot(components='unbounded') # optional - sage.plot + sage: E.plot(components='unbounded') # needs sage.plot Graphics object consisting of 1 graphics primitive If there is only one component then specifying components='bounded' raises a ValueError:: sage: E = EllipticCurve('9990be2') - sage: E.plot(components='bounded') # optional - sage.plot + sage: E.plot(components='bounded') # needs sage.plot Traceback (most recent call last): ... ValueError: no bounded component for this curve @@ -3166,7 +3180,7 @@ def plot(self, xmin=None, xmax=None, components='both', **args): An elliptic curve defined over the Complex Field can not be plotted:: sage: E = EllipticCurve(CC, [0,0,1,-1,0]) - sage: E.plot() # optional - sage.plot + sage: E.plot() # needs sage.plot Traceback (most recent call last): ... NotImplementedError: plotting of curves over Complex Field @@ -3350,18 +3364,20 @@ def _p_primary_torsion_basis(self, p, m=None): sage: E = EllipticCurve('11a1') sage: E._p_primary_torsion_basis(5) [[(5 : -6 : 1), 1]] + + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^4 + x^3 + 11*x^2 + 41*x + 101) # optional - sage.rings.number_field - sage: EK = E.base_extend(K) # optional - sage.rings.number_field - sage: EK._p_primary_torsion_basis(5) # long time (2s on sage.math, 2011) # optional - sage.rings.number_field + sage: K. = NumberField(x^4 + x^3 + 11*x^2 + 41*x + 101) + sage: EK = E.base_extend(K) + sage: EK._p_primary_torsion_basis(5) # long time [[(16 : 60 : 1), 1], [(t : 1/11*t^3 + 6/11*t^2 + 19/11*t + 48/11 : 1), 1]] - sage: EF = E.change_ring(GF(101)) # optional - sage.rings.finite_rings - sage: EF._p_primary_torsion_basis(5) # optional - sage.rings.finite_rings + sage: EF = E.change_ring(GF(101)) # needs sage.rings.finite_rings + sage: EF._p_primary_torsion_basis(5) # needs sage.rings.finite_rings [[(0 : 13 : 1), 1], [(5 : 5 : 1), 1]] - sage: F. = CyclotomicField(21) # optional - sage.rings.number_field - sage: E = EllipticCurve([2, -z^7, -z^7, 0, 0]) # optional - sage.rings.number_field - sage: E._p_primary_torsion_basis(7,2) # long time (8s on sage.math, 2011) # optional - sage.rings.number_field + sage: F. = CyclotomicField(21) # needs sage.rings.number_field + sage: E = EllipticCurve([2, -z^7, -z^7, 0, 0]) # needs sage.rings.number_field + sage: E._p_primary_torsion_basis(7,2) # long time # needs sage.rings.number_field [[(0 : z^7 : 1), 1], [(z^7 - z^6 + z^4 - z^3 + z^2 - 1 : z^8 - 2*z^7 + z^6 + 2*z^5 - 3*z^4 + 2*z^3 - 2*z + 2 : 1), 1]] @@ -3372,8 +3388,8 @@ def _p_primary_torsion_basis(self, p, m=None): sage: a = 804515977734860566494239770982282063895480484302363715494873 sage: b = 584772221603632866665682322899297141793188252000674256662071 - sage: E = EllipticCurve(GF(10^60+3201), [0,a,0,b,0]) # optional - sage.rings.finite_rings - sage: [t[1] for t in E._p_primary_torsion_basis(2)] # long time (3s on sage.math, 2011) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(10^60 + 3201), [0,a,0,b,0]) # needs sage.rings.finite_rings + sage: [t[1] for t in E._p_primary_torsion_basis(2)] # long time, needs sage.rings.finite_rings [16, 1] """ p = Integer(p) @@ -3526,18 +3542,19 @@ def pari_curve(self): EXAMPLES:: + sage: # needs sage.libs.pari sage: E = EllipticCurve([RR(0), RR(0), RR(1), RR(-1), RR(0)]) - sage: e = E.pari_curve() # optional - sage.libs.pari - sage: type(e) # optional - sage.libs.pari + sage: e = E.pari_curve() + sage: type(e) <... 'cypari2.gen.Gen'> - sage: e.type() # optional - sage.libs.pari + sage: e.type() 't_VEC' - sage: e.disc() # optional - sage.libs.pari + sage: e.disc() 37.0000000000000 Over a finite field:: - sage: EllipticCurve(GF(41), [2,5]).pari_curve() # optional - sage.libs.pari sage.rings.finite_rings + sage: EllipticCurve(GF(41), [2,5]).pari_curve() # needs sage.libs.pari [Mod(0, 41), Mod(0, 41), Mod(0, 41), Mod(2, 41), Mod(5, 41), Mod(0, 41), Mod(4, 41), Mod(20, 41), Mod(37, 41), Mod(27, 41), Mod(26, 41), Mod(4, 41), Mod(11, 41), @@ -3546,19 +3563,20 @@ def pari_curve(self): Over a `p`-adic field:: - sage: Qp = pAdicField(5, prec=3) # optional - sage.libs.pari sage.rings.padics - sage: E = EllipticCurve(Qp, [3, 4]) # optional - sage.libs.pari sage.rings.padics - sage: E.pari_curve() # optional - sage.libs.pari sage.rings.padics + sage: # needs sage.libs.pari sage.rings.padics + sage: Qp = pAdicField(5, prec=3) + sage: E = EllipticCurve(Qp, [3, 4]) + sage: E.pari_curve() [0, 0, 0, 3, 4, 0, 6, 16, -9, -144, -3456, -8640, 1728/5, Vecsmall([2]), [O(5^3)], [0, 0]] - sage: E.j_invariant() # optional - sage.libs.pari sage.rings.padics + sage: E.j_invariant() 3*5^-1 + O(5) Over a number field:: - sage: K. = QuadraticField(2) # optional - sage.libs.pari sage.rings.number_field - sage: E = EllipticCurve([1,a]) # optional - sage.libs.pari sage.rings.number_field - sage: E.pari_curve() # optional - sage.libs.pari sage.rings.number_field + sage: K. = QuadraticField(2) # needs sage.libs.pari sage.rings.number_field + sage: E = EllipticCurve([1,a]) # needs sage.libs.pari sage.rings.number_field + sage: E.pari_curve() # needs sage.libs.pari sage.rings.number_field [0, 0, 0, Mod(1, y^2 - 2), Mod(y, y^2 - 2), 0, Mod(2, y^2 - 2), Mod(4*y, y^2 - 2), Mod(-1, y^2 - 2), Mod(-48, y^2 - 2), Mod(-864*y, y^2 - 2), @@ -3572,10 +3590,10 @@ def pari_curve(self): PARI no longer requires that the `j`-invariant has negative `p`-adic valuation:: - sage: E = EllipticCurve(Qp,[1, 1]) # optional - sage.libs.pari sage.rings.padics - sage: E.j_invariant() # the j-invariant is a p-adic integer # optional - sage.libs.pari sage.rings.padics + sage: E = EllipticCurve(Qp,[1, 1]) # needs sage.libs.pari sage.rings.padics + sage: E.j_invariant() # the j-invariant is a p-adic integer # needs sage.libs.pari sage.rings.padics 2 + 4*5^2 + O(5^3) - sage: E.pari_curve() # optional - sage.libs.pari sage.rings.padics + sage: E.pari_curve() # needs sage.libs.pari sage.rings.padics [0, 0, 0, 1, 1, 0, 2, 4, -1, -48, -864, -496, 6912/31, Vecsmall([2]), [O(5^3)], [0, 0]] """ @@ -3596,12 +3614,12 @@ def __pari__(self): EXAMPLES:: sage: E = EllipticCurve('11a1') - sage: pari(E) # optional - sage.libs.pari + sage: pari(E) # needs sage.libs.pari [0, -1, 1, -10, -20, -4, -20, -79, -21, 496, 20008, -161051, -122023936/161051, Vecsmall([1]), [Vecsmall([64, -1])], [0, 0, 0, 0, 0, 0, 0, 0]] Over a finite field:: - sage: EllipticCurve(GF(2), [0,0,1,1,1]).__pari__() # optional - sage.libs.pari sage.rings.finite_rings + sage: EllipticCurve(GF(2), [0,0,1,1,1]).__pari__() # needs sage.libs.pari [0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, Vecsmall([4]), [1, [[Vecsmall([0, 1]), Vecsmall([0, 1]), Vecsmall([0, 1])], Vecsmall([0, 1]), [Vecsmall([0, 1]), Vecsmall([0]), Vecsmall([0]), Vecsmall([0])]]], [0, 0, 0, 0]] """ return self.pari_curve() diff --git a/src/sage/schemes/elliptic_curves/ell_local_data.py b/src/sage/schemes/elliptic_curves/ell_local_data.py index 2b9bd9d2ab4..11a0e9db661 100644 --- a/src/sage/schemes/elliptic_curves/ell_local_data.py +++ b/src/sage/schemes/elliptic_curves/ell_local_data.py @@ -16,6 +16,7 @@ EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) sage: E = EllipticCurve([(2+i)^2, (2+i)^7]) @@ -45,6 +46,7 @@ Kodaira Symbol: II Tamagawa Number: 1 + sage: # needs sage.rings.number_field sage: EK = E.base_extend(K) sage: EK.local_data(1+i) Local data at Fractional ideal (i + 1): @@ -61,6 +63,8 @@ sage: E = EllipticCurve([0,8]) sage: E.is_minimal() True + + sage: # needs sage.rings.number_field sage: EK = E.base_extend(K) sage: da = EK.local_data(1+i) sage: da.minimal_model() @@ -120,7 +124,7 @@ class EllipticCurveLocalData(SageObject): - ``P`` -- a prime ideal of the field, or a prime integer if the field is `\QQ`. - - ``proof`` (bool)-- if True, only use provably correct + - ``proof`` (bool) -- if ``True``, only use provably correct methods (default controlled by global proof module). Note that the proof module is number_field, not elliptic_curves, since the functions that actually need the flag are in @@ -332,6 +336,7 @@ def minimal_model(self, reduce=True): To demonstrate the behaviour of the parameter ``reduce``:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 + x + 1) sage: E = EllipticCurve(K, [0, 0, a, 0, 1]) @@ -356,6 +361,7 @@ def minimal_model(self, reduce=True): :trac:`14476`:: + sage: # needs sage.rings.number_field sage: t = QQ['t'].0 sage: K. = NumberField(t^4 - t^3-3*t^2 - t +1) sage: E = EllipticCurve([-2*g^3 + 10/3*g^2 + 3*g - 2/3, @@ -517,6 +523,7 @@ def bad_reduction_type(self): sage: [(p,E.local_data(p).bad_reduction_type()) for p in prime_range(15)] [(2, -1), (3, None), (5, None), (7, 1), (11, None), (13, None)] + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -536,6 +543,7 @@ def has_good_reduction(self): sage: [(p,E.local_data(p).has_good_reduction()) for p in prime_range(15)] [(2, False), (3, True), (5, True), (7, False), (11, True), (13, True)] + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -558,6 +566,7 @@ def has_bad_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -585,6 +594,7 @@ def has_multiplicative_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -607,6 +617,7 @@ def has_split_multiplicative_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -631,6 +642,7 @@ def has_nonsplit_multiplicative_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -653,6 +665,7 @@ def has_additive_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -695,16 +708,14 @@ def _tate(self, proof=None, globally=False): EXAMPLES (this raised a type error in sage prior to 4.4.4, see :trac:`7930`) :: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('99d1') - sage: R. = QQ[] sage: K. = NumberField(X^3 + X^2 - 2*X - 1) sage: L. = NumberField(X^3 + X^2 - 36*X - 4) - sage: EK = E.base_extend(K) sage: toK = EK.torsion_order() sage: da = EK.local_data() # indirect doctest - sage: EL = E.base_extend(L) sage: da = EL.local_data() # indirect doctest @@ -712,6 +723,7 @@ def _tate(self, proof=None, globally=False): The following example shows that the bug at :trac:`9324` is fixed:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - x + 6) sage: E = EllipticCurve([0,0,0,-53160*a-43995,-5067640*a+19402006]) @@ -720,14 +732,16 @@ def _tate(self, proof=None, globally=False): The following example shows that the bug at :trac:`9417` is fixed:: - sage: K. = NumberField(x^2+18*x+1) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 18*x + 1) sage: E = EllipticCurve(K, [0, -36, 0, 320, 0]) sage: E.tamagawa_number(K.ideal(2)) 4 This is to show that the bug :trac:`11630` is fixed. (The computation of the class group would produce a warning):: - sage: K. = NumberField(x^7-2*x+177) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^7 - 2*x + 177) sage: E = EllipticCurve([0,1,0,t,t]) sage: P = K.ideal(2,t^3 + t + 1) sage: E.local_data(P).kodaira_symbol() @@ -1141,6 +1155,8 @@ def check_prime(K, P): 3 sage: check_prime(QQ,ZZ.ideal(31)) 31 + + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 5) sage: check_prime(K, a) diff --git a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py index 11c0bc4b978..243df1d23f0 100644 --- a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py +++ b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py @@ -129,8 +129,8 @@ def modular_symbol_space(E, sign, base_ring, bound=None): sage: from sage.schemes.elliptic_curves.ell_modular_symbols import modular_symbol_space sage: E = EllipticCurve('11a1') - sage: M = modular_symbol_space(E, -1, GF(37)) # optional - sage.rings.finite_rings - sage: M # optional - sage.rings.finite_rings + sage: M = modular_symbol_space(E, -1, GF(37)) + sage: M Modular Symbols space of dimension 1 for Gamma_0(11) of weight 2 with sign -1 over Finite Field of size 37 """ diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py index e01d7436d94..54777488572 100644 --- a/src/sage/schemes/elliptic_curves/ell_number_field.py +++ b/src/sage/schemes/elliptic_curves/ell_number_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Elliptic curves over number fields diff --git a/src/sage/schemes/elliptic_curves/ell_padic_field.py b/src/sage/schemes/elliptic_curves/ell_padic_field.py index 2ac42b1b7e7..ba796d1b75b 100644 --- a/src/sage/schemes/elliptic_curves/ell_padic_field.py +++ b/src/sage/schemes/elliptic_curves/ell_padic_field.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics """ Elliptic curves over padic fields """ @@ -33,9 +34,10 @@ class EllipticCurve_padic_field(EllipticCurve_field, HyperellipticCurve_padic_fi EXAMPLES:: - sage: Qp=pAdicField(17) - sage: E=EllipticCurve(Qp,[2,3]); E - Elliptic Curve defined by y^2 = x^3 + (2+O(17^20))*x + (3+O(17^20)) over 17-adic Field with capped relative precision 20 + sage: Qp = pAdicField(17) + sage: E = EllipticCurve(Qp,[2,3]); E + Elliptic Curve defined by y^2 = x^3 + (2+O(17^20))*x + (3+O(17^20)) + over 17-adic Field with capped relative precision 20 sage: E == loads(dumps(E)) True """ diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 0b6d93a117a..c6f5c509d5d 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -32,36 +32,39 @@ An example over a number field:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1,0,0,0,-1]) # optional - sage.rings.number_field - sage: P = E(0,i); P # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve(K, [1,0,0,0,-1]) + sage: P = E(0,i); P (0 : i : 1) - sage: P.order() # optional - sage.rings.number_field + sage: P.order() +Infinity - sage: 101*P - 100*P == P # optional - sage.rings.number_field + sage: 101*P - 100*P == P True An example over a finite field:: - sage: K. = GF((101,3)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [1,0,0,0,-1]) # optional - sage.rings.finite_rings - sage: P = E(40*a^2 + 69*a + 84 , 58*a^2 + 73*a + 45) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF((101,3)) + sage: E = EllipticCurve(K, [1,0,0,0,-1]) + sage: P = E(40*a^2 + 69*a + 84 , 58*a^2 + 73*a + 45) + sage: P.order() 1032210 - sage: E.cardinality() # optional - sage.rings.finite_rings + sage: E.cardinality() 1032210 Arithmetic with a point over an extension of a finite field:: - sage: k. = GF((5,2)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k,[1,0]); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF((5,2)) + sage: E = EllipticCurve(k,[1,0]); E Elliptic Curve defined by y^2 = x^3 + x over Finite Field in a of size 5^2 - sage: P = E([a,2*a+4]) # optional - sage.rings.finite_rings - sage: 5*P # optional - sage.rings.finite_rings + sage: P = E([a,2*a+4]) + sage: 5*P (2*a + 3 : 2*a : 1) - sage: P*5 # optional - sage.rings.finite_rings + sage: P*5 (2*a + 3 : 2*a : 1) - sage: P + P + P + P + P # optional - sage.rings.finite_rings + sage: P + P + P + P + P (2*a + 3 : 2*a : 1) :: @@ -169,7 +172,7 @@ class EllipticCurvePoint_field(SchemeMorphism_point_abelian_variety_field): (0 : 0 : 1) sage: E(0,0) # brackets are optional (0 : 0 : 1) - sage: E([GF(5)(0), 0]) # entries are coerced # optional - sage.rings.finite_rings + sage: E([GF(5)(0), 0]) # entries are coerced (0 : 0 : 1) sage: E(0.000, 0) @@ -188,14 +191,15 @@ class EllipticCurvePoint_field(SchemeMorphism_point_abelian_variety_field): Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1,0,-160,308]) # optional - sage.rings.number_field - sage: P = E(26, -120) # optional - sage.rings.number_field - sage: Q = E(2+12*i, -36+48*i) # optional - sage.rings.number_field - sage: P.order() == Q.order() == 4 # long time (3s) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,1,0,-160,308]) + sage: P = E(26, -120) + sage: Q = E(2+12*i, -36+48*i) + sage: P.order() == Q.order() == 4 # long time True - sage: 2*P == 2*Q # optional - sage.rings.number_field + sage: 2*P == 2*Q False :: @@ -231,14 +235,14 @@ class EllipticCurvePoint_field(SchemeMorphism_point_abelian_variety_field): sage: P = E(0,1) sage: P.domain() Spectrum of Rational Field - sage: K. = NumberField(x^2 - 3, 'a') # optional - sage.rings.number_field - sage: P = E.base_extend(K)(1,a) # optional - sage.rings.number_field - sage: P.domain() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3, 'a') # needs sage.rings.number_field + sage: P = E.base_extend(K)(1,a) # needs sage.rings.number_field + sage: P.domain() # needs sage.rings.number_field Spectrum of Number Field in a with defining polynomial x^2 - 3 - sage: P.codomain() # optional - sage.rings.number_field + sage: P.codomain() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^2 - 3 - sage: P.codomain() == P.curve() # optional - sage.rings.number_field + sage: P.codomain() == P.curve() # needs sage.rings.number_field True """ def __init__(self, curve, v, check=True): @@ -414,18 +418,18 @@ def __pari__(self): Try the same over a finite field:: - sage: E = EllipticCurve(GF(11), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: O = E(0) # optional - sage.rings.finite_rings - sage: P = E.point([1,2]) # optional - sage.rings.finite_rings - sage: O.__pari__() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(11), [0,0,0,3,0]) + sage: O = E(0) + sage: P = E.point([1,2]) + sage: O.__pari__() [0] - sage: P.__pari__() # optional - sage.rings.finite_rings + sage: P.__pari__() [Mod(1, 11), Mod(2, 11)] We no longer need to explicitly call ``pari(O)`` and ``pari(P)`` after :trac:`11868`:: - sage: pari(E).elladd(O, P) # optional - sage.rings.finite_rings + sage: pari(E).elladd(O, P) [Mod(1, 11), Mod(2, 11)] """ if self[2]: @@ -448,9 +452,9 @@ def scheme(self): sage: P.scheme() == P.curve() True sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 3,'a') # optional - sage.rings.number_field - sage: P = E.base_extend(K)(1, a) # optional - sage.rings.number_field - sage: P.scheme() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3,'a') # needs sage.rings.number_field + sage: P = E.base_extend(K)(1, a) # needs sage.rings.number_field + sage: P.scheme() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^2 - 3 """ @@ -606,7 +610,7 @@ def plot(self, **args): sage: E = EllipticCurve('389a') sage: P = E([-1,1]) - sage: P.plot(pointsize=30, rgbcolor=(1,0,0)) # optional - sage.plot + sage: P.plot(pointsize=30, rgbcolor=(1,0,0)) # needs sage.plot Graphics object consisting of 1 graphics primitive """ from sage.plot.point import point @@ -807,43 +811,45 @@ def is_divisible_by(self, m): A finite field example:: - sage: E = EllipticCurve(GF(101), [23,34]) # optional - sage.rings.finite_rings - sage: E.cardinality().factor() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(101), [23,34]) + sage: E.cardinality().factor() 2 * 53 - sage: Set([T.order() for T in E.points()]) # optional - sage.rings.finite_rings + sage: Set([T.order() for T in E.points()]) {1, 106, 2, 53} - sage: len([T for T in E.points() if T.is_divisible_by(2)]) # optional - sage.rings.finite_rings + sage: len([T for T in E.points() if T.is_divisible_by(2)]) 53 - sage: len([T for T in E.points() if T.is_divisible_by(3)]) # optional - sage.rings.finite_rings + sage: len([T for T in E.points() if T.is_divisible_by(3)]) 106 TESTS: This shows that the bug reported at :trac:`10076` is fixed:: - sage: K = QuadraticField(8,'a') # optional - sage.rings.number_field - sage: E = EllipticCurve([K(0),0,0,-1,0]) # optional - sage.rings.number_field - sage: P = E([-1,0]) # optional - sage.rings.number_field - sage: P.is_divisible_by(2) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(8,'a') + sage: E = EllipticCurve([K(0),0,0,-1,0]) + sage: P = E([-1,0]) + sage: P.is_divisible_by(2) False - sage: P.division_points(2) # optional - sage.rings.number_field + sage: P.division_points(2) [] Note that it is not sufficient to test that ``self.division_points(m,poly_only=True)`` has roots:: - sage: P.division_points(2, poly_only=True).roots() # optional - sage.rings.number_field + sage: P.division_points(2, poly_only=True).roots() # needs sage.rings.number_field [(1/2*a - 1, 1), (-1/2*a - 1, 1)] - sage: tor = E.torsion_points(); len(tor) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: tor = E.torsion_points(); len(tor) 8 - sage: [T.order() for T in tor] # optional - sage.rings.number_field + sage: [T.order() for T in tor] [2, 4, 4, 2, 1, 2, 4, 4] - sage: all(T.is_divisible_by(3) for T in tor) # optional - sage.rings.number_field + sage: all(T.is_divisible_by(3) for T in tor) True - sage: sorted(T for T in tor if T.is_divisible_by(2)) # optional - sage.rings.number_field + sage: sorted(T for T in tor if T.is_divisible_by(2)) [(0 : 1 : 0), (1 : 0 : 1)] - sage: sorted(Set([2*T for T in tor])) # optional - sage.rings.number_field + sage: sorted(Set([2*T for T in tor])) [(0 : 1 : 0), (1 : 0 : 1)] """ # Coerce the input m to an integer @@ -938,64 +944,68 @@ def division_points(self, m, poly_only=False): We create a curve over a non-prime finite field with group of order `18`:: - sage: k. = GF((5,2)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,2+a,3,4*a,2]) # optional - sage.rings.finite_rings - sage: P = E([3, 3*a+4]) # optional - sage.rings.finite_rings - sage: factor(E.order()) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF((5,2)) + sage: E = EllipticCurve(k, [1,2+a,3,4*a,2]) + sage: P = E([3, 3*a+4]) + sage: factor(E.order()) 2 * 3^2 - sage: P.order() # optional - sage.rings.finite_rings + sage: P.order() 9 We find the `1`-division points as a consistency check -- there is just one, of course:: - sage: P.division_points(1) # optional - sage.rings.finite_rings + sage: P.division_points(1) # needs sage.rings.finite_rings [(3 : 3*a + 4 : 1)] The point `P` has order coprime to 2 but divisible by 3, so:: - sage: P.division_points(2) # optional - sage.rings.finite_rings + sage: P.division_points(2) # needs sage.rings.finite_rings [(2*a + 1 : 3*a + 4 : 1), (3*a + 1 : a : 1)] We check that each of the 2-division points works as claimed:: - sage: [2*Q for Q in P.division_points(2)] # optional - sage.rings.finite_rings + sage: [2*Q for Q in P.division_points(2)] # needs sage.rings.finite_rings [(3 : 3*a + 4 : 1), (3 : 3*a + 4 : 1)] Some other checks:: - sage: P.division_points(3) # optional - sage.rings.finite_rings + sage: P.division_points(3) # needs sage.rings.finite_rings [] - sage: P.division_points(4) # optional - sage.rings.finite_rings + sage: P.division_points(4) # needs sage.rings.finite_rings [(0 : 3*a + 2 : 1), (1 : 0 : 1)] - sage: P.division_points(5) # optional - sage.rings.finite_rings + sage: P.division_points(5) # needs sage.rings.finite_rings [(1 : 1 : 1)] An example over a number field (see :trac:`3383`):: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('19a1') - sage: K. = NumberField(x^9 - 3*x^8 - 4*x^7 + 16*x^6 - 3*x^5 # optional - sage.rings.number_field + sage: x = polygen(ZZ, 'x') + sage: K. = NumberField(x^9 - 3*x^8 - 4*x^7 + 16*x^6 - 3*x^5 ....: - 21*x^4 + 5*x^3 + 7*x^2 - 7*x + 1) - sage: EK = E.base_extend(K) # optional - sage.rings.number_field - sage: E(0).division_points(3) # optional - sage.rings.number_field + sage: EK = E.base_extend(K) + sage: E(0).division_points(3) [(0 : 1 : 0), (5 : -10 : 1), (5 : 9 : 1)] - sage: EK(0).division_points(3) # optional - sage.rings.number_field + sage: EK(0).division_points(3) [(0 : 1 : 0), (5 : 9 : 1), (5 : -10 : 1)] - sage: E(0).division_points(9) # optional - sage.rings.number_field + sage: E(0).division_points(9) [(0 : 1 : 0), (5 : -10 : 1), (5 : 9 : 1)] - sage: EK(0).division_points(9) # optional - sage.rings.number_field + sage: EK(0).division_points(9) [(0 : 1 : 0), (5 : 9 : 1), (5 : -10 : 1), (-150/121*t^8 + 414/121*t^7 + 1481/242*t^6 - 2382/121*t^5 - 103/242*t^4 + 629/22*t^3 - 367/242*t^2 - 1307/121*t + 625/121 : 35/484*t^8 - 133/242*t^7 + 445/242*t^6 - 799/242*t^5 + 373/484*t^4 + 113/22*t^3 - 2355/484*t^2 - 753/242*t + 1165/484 : 1), (-150/121*t^8 + 414/121*t^7 + 1481/242*t^6 - 2382/121*t^5 - 103/242*t^4 + 629/22*t^3 - 367/242*t^2 - 1307/121*t + 625/121 : -35/484*t^8 + 133/242*t^7 - 445/242*t^6 + 799/242*t^5 - 373/484*t^4 - 113/22*t^3 + 2355/484*t^2 + 753/242*t - 1649/484 : 1), (-1383/484*t^8 + 970/121*t^7 + 3159/242*t^6 - 5211/121*t^5 + 37/484*t^4 + 654/11*t^3 - 909/484*t^2 - 4831/242*t + 6791/484 : 927/121*t^8 - 5209/242*t^7 - 8187/242*t^6 + 27975/242*t^5 - 1147/242*t^4 - 1729/11*t^3 + 1566/121*t^2 + 12873/242*t - 10871/242 : 1), (-1383/484*t^8 + 970/121*t^7 + 3159/242*t^6 - 5211/121*t^5 + 37/484*t^4 + 654/11*t^3 - 909/484*t^2 - 4831/242*t + 6791/484 : -927/121*t^8 + 5209/242*t^7 + 8187/242*t^6 - 27975/242*t^5 + 1147/242*t^4 + 1729/11*t^3 - 1566/121*t^2 - 12873/242*t + 10629/242 : 1), (-4793/484*t^8 + 6791/242*t^7 + 10727/242*t^6 - 18301/121*t^5 + 2347/484*t^4 + 2293/11*t^3 - 7311/484*t^2 - 17239/242*t + 26767/484 : 30847/484*t^8 - 21789/121*t^7 - 34605/121*t^6 + 117164/121*t^5 - 10633/484*t^4 - 29437/22*t^3 + 39725/484*t^2 + 55428/121*t - 176909/484 : 1), (-4793/484*t^8 + 6791/242*t^7 + 10727/242*t^6 - 18301/121*t^5 + 2347/484*t^4 + 2293/11*t^3 - 7311/484*t^2 - 17239/242*t + 26767/484 : -30847/484*t^8 + 21789/121*t^7 + 34605/121*t^6 - 117164/121*t^5 + 10633/484*t^4 + 29437/22*t^3 - 39725/484*t^2 - 55428/121*t + 176425/484 : 1)] TESTS: Check that :trac:`24844` is fixed:: - sage: p = next_prime(1000000) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(p), 123, 456) # optional - sage.rings.finite_rings - sage: pts = E(0).division_points(3) # optional - sage.rings.finite_rings - sage: P = pts[1]; P # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = next_prime(1000000) + sage: E = EllipticCurve(GF(p), 123, 456) + sage: pts = E(0).division_points(3) + sage: P = pts[1]; P (389063 : 124244 : 1) - sage: P._order # optional - sage.rings.finite_rings + sage: P._order 3 When we successfully divide a point known to have infinite @@ -1215,14 +1225,14 @@ def set_order(self, value=None, *, multiple=None, check=True): :: - sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 # optional - sage.rings.finite_rings - sage: G = E(5, 0) # optional - sage.rings.finite_rings - sage: G.set_order(2) # optional - sage.rings.finite_rings - sage: 2*G # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 + sage: G = E(5, 0) + sage: G.set_order(2) + sage: 2*G (0 : 1 : 0) - sage: G = E(0, 6) # optional - sage.rings.finite_rings - sage: G.set_order(multiple=12) # optional - sage.rings.finite_rings - sage: G._order # optional - sage.rings.finite_rings + sage: G = E(0, 6) + sage: G.set_order(multiple=12) + sage: G._order 3 We now give a more interesting case, the NIST-P521 curve. Its @@ -1231,17 +1241,18 @@ def set_order(self, value=None, *, multiple=None, check=True): :: + sage: # needs sage.rings.finite_rings sage: p = 2^521 - 1 sage: prev_proof_state = proof.arithmetic() sage: proof.arithmetic(False) # turn off primality checking - sage: F = GF(p) # optional - sage.rings.finite_rings + sage: F = GF(p) sage: A = p - 3 sage: B = 1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984 sage: q = 6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449 - sage: E = EllipticCurve([F(A), F(B)]) # optional - sage.rings.finite_rings - sage: G = E.random_point() # optional - sage.rings.finite_rings - sage: G.set_order(q) # optional - sage.rings.finite_rings - sage: G.order() * G # This takes practically no time. # optional - sage.rings.finite_rings + sage: E = EllipticCurve([F(A), F(B)]) + sage: G = E.random_point() + sage: G.set_order(q) + sage: G.order() * G # This takes practically no time. (0 : 1 : 0) sage: proof.arithmetic(prev_proof_state) # restore state @@ -1271,13 +1282,14 @@ def set_order(self, value=None, *, multiple=None, check=True): It is an error to pass a ``value`` equal to `0`:: - sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 # optional - sage.rings.finite_rings - sage: G = E.random_point() # optional - sage.rings.finite_rings - sage: G.set_order(0) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 + sage: G = E.random_point() + sage: G.set_order(0) Traceback (most recent call last): ... ValueError: Value 0 illegal for point order - sage: G.set_order(1000) # optional - sage.rings.finite_rings + sage: G.set_order(1000) Traceback (most recent call last): ... ValueError: Value 1000 illegal: outside max Hasse bound @@ -1286,9 +1298,9 @@ def set_order(self, value=None, *, multiple=None, check=True): order of this point. How unlikely is determined by the factorization of the actual order, and the actual group structure:: - sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 # optional - sage.rings.finite_rings - sage: G = E(5, 0) # G has order 2 # optional - sage.rings.finite_rings - sage: G.set_order(11) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 + sage: G = E(5, 0) # G has order 2 + sage: G.set_order(11) Traceback (most recent call last): ... ValueError: Value 11 illegal: 11 * (5 : 0 : 1) is not the identity @@ -1296,10 +1308,10 @@ def set_order(self, value=None, *, multiple=None, check=True): However, ``set_order`` can be fooled. For instance, the order can be set to a multiple the actual order:: - sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 # optional - sage.rings.finite_rings - sage: G = E(5, 0) # G has order 2 # optional - sage.rings.finite_rings - sage: G.set_order(8) # optional - sage.rings.finite_rings - sage: G.order() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 + sage: G = E(5, 0) # G has order 2 + sage: G.set_order(8) + sage: G.order() 8 TESTS: @@ -1375,27 +1387,28 @@ def _line_(self, R, Q): EXAMPLES:: - sage: F. = GF((2,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F,[0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Q = E(a^4, a^4 + a^3) # optional - sage.rings.finite_rings - sage: O = E(0) # optional - sage.rings.finite_rings - sage: P._line_(P,-2*P) == 0 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((2,5)) + sage: E = EllipticCurve(F,[0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Q = E(a^4, a^4 + a^3) + sage: O = E(0) + sage: P._line_(P,-2*P) == 0 True - sage: P._line_(Q,-(P+Q)) == 0 # optional - sage.rings.finite_rings + sage: P._line_(Q,-(P+Q)) == 0 True - sage: O._line_(O,Q) == F(1) # optional - sage.rings.finite_rings + sage: O._line_(O,Q) == F(1) True - sage: P._line_(O,Q) == a^4 - a^4 + 1 # optional - sage.rings.finite_rings + sage: P._line_(O,Q) == a^4 - a^4 + 1 True - sage: P._line_(13*P,Q) == a^4 # optional - sage.rings.finite_rings + sage: P._line_(13*P,Q) == a^4 True - sage: P._line_(P,Q) == a^4 + a^3 + a^2 + 1 # optional - sage.rings.finite_rings + sage: P._line_(P,Q) == a^4 + a^3 + a^2 + 1 True See :trac:`7116`:: - sage: P._line_ (Q,O) # optional - sage.rings.finite_rings + sage: P._line_ (Q,O) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: Q must be nonzero. @@ -1453,120 +1466,124 @@ def _miller_(self, Q, n): EXAMPLES:: - sage: F. = GF((2,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Fx. = GF((2,(4*5))) # optional - sage.rings.finite_rings - sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: phi = Hom(F,Fx)(F.gen().minpoly().roots(Fx)[0][0]) # optional - sage.rings.finite_rings - sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) # optional - sage.rings.finite_rings - sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((2,5)) + sage: E = EllipticCurve(F, [0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Fx. = GF((2,(4*5))) + sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) + sage: phi = Hom(F,Fx)(F.gen().minpoly().roots(Fx)[0][0]) + sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) + sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, ....: b^18 + b^13 + b^10 + b^8 + b^5 + b^4 + b^3 + b) - sage: Px._miller_(Qx,41) == b^17 + b^13 + b^12 + b^9 + b^8 + b^6 + b^4 + 1 # optional - sage.rings.finite_rings + sage: Px._miller_(Qx,41) == b^17 + b^13 + b^12 + b^9 + b^8 + b^6 + b^4 + 1 True - sage: Qx._miller_(Px,41) == b^13 + b^10 + b^8 + b^7 + b^6 + b^5 # optional - sage.rings.finite_rings + sage: Qx._miller_(Px,41) == b^13 + b^10 + b^8 + b^7 + b^6 + b^5 True - sage: P._miller_(E(0),41) # optional - sage.rings.finite_rings + sage: P._miller_(E(0),41) Traceback (most recent call last): ... ValueError: Q must be nonzero. An example of even order:: - sage: F. = GF((19,4)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [-1,0]) # optional - sage.rings.finite_rings - sage: P = E(15*a^3 + 17*a^2 + 14*a + 13,16*a^3 + 7*a^2 + a + 18) # optional - sage.rings.finite_rings - sage: Q = E(10*a^3 + 16*a^2 + 4*a + 2, 6*a^3 + 4*a^2 + 3*a + 2) # optional - sage.rings.finite_rings - sage: x = P.weil_pairing(Q, 360) # optional - sage.rings.finite_rings - sage: x^360 == F(1) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((19,4)) + sage: E = EllipticCurve(F, [-1,0]) + sage: P = E(15*a^3 + 17*a^2 + 14*a + 13,16*a^3 + 7*a^2 + a + 18) + sage: Q = E(10*a^3 + 16*a^2 + 4*a + 2, 6*a^3 + 4*a^2 + 3*a + 2) + sage: x = P.weil_pairing(Q, 360) + sage: x^360 == F(1) True You can use the _miller_ function on linearly dependent points, but with the risk of a dividing with zero:: - sage: Px._miller_(2*Px, 41) # optional - sage.rings.finite_rings + sage: Px._miller_(2*Px, 41) # needs sage.rings.finite_rings Traceback (most recent call last): ... ZeroDivisionError: division by zero in finite field A small example of embedding degree 6:: - sage: q = 401; F = GF(q); a = 146; b = 400; k = 6 # optional - sage.rings.finite_rings - sage: E = EllipticCurve([F(a), F(b)]) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: K. = GF(q^k, modulus=x^6 + 4*x^4 + 115*x^3 + 81*x^2 + 51*x + 3) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = E([F(338), F(227)]) # optional - sage.rings.finite_rings - sage: Q_x = 333*a^5 + 391*a^4 + 160*a^3 + 335*a^2 + 71*a + 93 # optional - sage.rings.finite_rings - sage: Q_y = 343*a^5 + 273*a^4 + 26*a^3 + 342*a^2 + 340*a + 210 # optional - sage.rings.finite_rings - sage: Q = EK([Q_x, Q_y]) # optional - sage.rings.finite_rings - sage: P._miller_(Q, 127) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: q = 401; F = GF(q); a = 146; b = 400; k = 6 + sage: E = EllipticCurve([F(a), F(b)]) + sage: R. = F[] + sage: K. = GF(q^k, modulus=x^6 + 4*x^4 + 115*x^3 + 81*x^2 + 51*x + 3) + sage: EK = E.base_extend(K) + sage: P = E([F(338), F(227)]) + sage: Q_x = 333*a^5 + 391*a^4 + 160*a^3 + 335*a^2 + 71*a + 93 + sage: Q_y = 343*a^5 + 273*a^4 + 26*a^3 + 342*a^2 + 340*a + 210 + sage: Q = EK([Q_x, Q_y]) + sage: P._miller_(Q, 127) 371*a^5 + 39*a^4 + 355*a^3 + 233*a^2 + 20*a + 275 A series of small examples and small torsions. We start with `n=1`, which is trivial: the function is the constant 1:: - sage: E = EllipticCurve([GF(7)(0), 2]) # optional - sage.rings.finite_rings - sage: P = E(5, 1); Q = E(0, 3); I = E(0) # optional - sage.rings.finite_rings - sage: I._miller_(P, 1) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(0), 2]) + sage: P = E(5, 1); Q = E(0, 3); I = E(0) + sage: I._miller_(P, 1) 1 - sage: I._miller_(Q, 1) # optional - sage.rings.finite_rings + sage: I._miller_(Q, 1) 1 A two-torsion example. In this case `f_{n,P}(Q) = x_Q - x_P`:: - sage: E = EllipticCurve([GF(7)(-1), 0]) # optional - sage.rings.finite_rings - sage: P = E(0,0); Q = E(1, 0); # optional - sage.rings.finite_rings - sage: P._miller_(P, 2) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(-1), 0]) + sage: P = E(0,0); Q = E(1, 0); + sage: P._miller_(P, 2) 0 - sage: Q._miller_(Q, 2) # optional - sage.rings.finite_rings + sage: Q._miller_(Q, 2) 0 - sage: P._miller_(Q, 2) # optional - sage.rings.finite_rings + sage: P._miller_(Q, 2) 1 - sage: Q._miller_(P, 2) # optional - sage.rings.finite_rings + sage: Q._miller_(P, 2) 6 A three-torsion example:: - sage: E = EllipticCurve([GF(7)(0), 2]) # optional - sage.rings.finite_rings - sage: P = E(5, 1); Q = E(0, 3); # optional - sage.rings.finite_rings - sage: P._miller_(Q, 3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(0), 2]) + sage: P = E(5, 1); Q = E(0, 3); + sage: P._miller_(Q, 3) 4 A 4-torsion example:: - sage: E = EllipticCurve([GF(7)(-1), 0]) # optional - sage.rings.finite_rings - sage: P = E(5, 1); Q = E(4, 2) # optional - sage.rings.finite_rings - sage: P._miller_(Q, 4) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(-1), 0]) + sage: P = E(5, 1); Q = E(4, 2) + sage: P._miller_(Q, 4) 3 A 5-torsion example:: - sage: E = EllipticCurve([GF(7)(-1), 4]) # optional - sage.rings.finite_rings - sage: P = E(4, 1); Q = E(6, 5) # optional - sage.rings.finite_rings - sage: P._miller_(Q, 5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(-1), 4]) + sage: P = E(4, 1); Q = E(6, 5) + sage: P._miller_(Q, 5) 1 A 6-torsion example:: - sage: E = EllipticCurve([GF(7)(3), 1]) # optional - sage.rings.finite_rings - sage: P = E(5, 1); Q = E(3, 3) # optional - sage.rings.finite_rings - sage: P._miller_(Q, 6) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(3), 1]) + sage: P = E(5, 1); Q = E(3, 3) + sage: P._miller_(Q, 6) 5 An example which is part of an ate pairing calculation. The trace of the curve is negative, so it should exercise the `n<0` case in the code:: + sage: # needs sage.rings.finite_rings sage: p = 2017; A = 1; B = 30; r = 29; t = -70; k = 7 - sage: F = GF(p); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve([F(A), F(B)]); P = E(369, 716) # optional - sage.rings.finite_rings - sage: K. = GF(p^k, modulus=x^k+2); EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: Qx = 1226*a^6 + 1778*a^5 + 660*a^4 + 1791*a^3 + 1750*a^2 + 867*a + 770 # optional - sage.rings.finite_rings - sage: Qy = 1764*a^6 + 198*a^5 + 1206*a^4 + 406*a^3 + 1200*a^2 + 273*a + 1712 # optional - sage.rings.finite_rings - sage: Q = EK(Qx, Qy) # optional - sage.rings.finite_rings - sage: Q._miller_(P, t - 1) # optional - sage.rings.finite_rings + sage: F = GF(p); R. = F[] + sage: E = EllipticCurve([F(A), F(B)]); P = E(369, 716) + sage: K. = GF(p^k, modulus=x^k+2); EK = E.base_extend(K) + sage: Qx = 1226*a^6 + 1778*a^5 + 660*a^4 + 1791*a^3 + 1750*a^2 + 867*a + 770 + sage: Qy = 1764*a^6 + 198*a^5 + 1206*a^4 + 406*a^3 + 1200*a^2 + 273*a + 1712 + sage: Q = EK(Qx, Qy) + sage: Q._miller_(P, t - 1) 1311*a^6 + 1362*a^5 + 1177*a^4 + 807*a^3 + 1331*a^2 + 1530*a + 1931 ALGORITHM: @@ -1634,66 +1651,70 @@ def weil_pairing(self, Q, n, algorithm=None): EXAMPLES:: - sage: F. = GF((2,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Fx. = GF((2, 4*5)) # optional - sage.rings.finite_rings - sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) # optional - sage.rings.finite_rings - sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) # optional - sage.rings.finite_rings - sage: O = Ex(0) # optional - sage.rings.finite_rings - sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((2,5)) + sage: E = EllipticCurve(F, [0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Fx. = GF((2, 4*5)) + sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) + sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) + sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) + sage: O = Ex(0) + sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, ....: b^18 + b^13 + b^10 + b^8 + b^5 + b^4 + b^3 + b) - sage: Px.weil_pairing(Qx, 41) == b^19 + b^15 + b^9 + b^8 + b^6 + b^4 + b^3 + b^2 + 1 # optional - sage.rings.finite_rings + sage: Px.weil_pairing(Qx, 41) == b^19 + b^15 + b^9 + b^8 + b^6 + b^4 + b^3 + b^2 + 1 True - sage: Px.weil_pairing(17*Px, 41) == Fx(1) # optional - sage.rings.finite_rings + sage: Px.weil_pairing(17*Px, 41) == Fx(1) True - sage: Px.weil_pairing(O, 41) == Fx(1) # optional - sage.rings.finite_rings + sage: Px.weil_pairing(O, 41) == Fx(1) True An error is raised if either point is not `n`-torsion:: - sage: Px.weil_pairing(O, 40) # optional - sage.rings.finite_rings + sage: Px.weil_pairing(O, 40) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: points must both be n-torsion A larger example (see :trac:`4964`):: - sage: P, Q = EllipticCurve(GF((19,4),'a'), [-1,0]).gens() # optional - sage.rings.finite_rings - sage: P.order(), Q.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P, Q = EllipticCurve(GF((19,4),'a'), [-1,0]).gens() + sage: P.order(), Q.order() (360, 360) - sage: z = P.weil_pairing(Q, 360) # optional - sage.rings.finite_rings - sage: z.multiplicative_order() # optional - sage.rings.finite_rings + sage: z = P.weil_pairing(Q, 360) + sage: z.multiplicative_order() 360 An example over a number field:: - sage: E = EllipticCurve('11a1').change_ring(CyclotomicField(5)) # optional - sage.rings.number_field - sage: P, Q = E.torsion_subgroup().gens() # optional - sage.rings.number_field - sage: P, Q = (P.element(), Q.element()) # optional - sage.rings.number_field - sage: (P.order(), Q.order()) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve('11a1').change_ring(CyclotomicField(5)) + sage: P, Q = E.torsion_subgroup().gens() + sage: P, Q = (P.element(), Q.element()) + sage: (P.order(), Q.order()) (5, 5) - sage: P.weil_pairing(Q, 5) # optional - sage.rings.number_field + sage: P.weil_pairing(Q, 5) zeta5^2 - sage: Q.weil_pairing(P, 5) # optional - sage.rings.number_field + sage: Q.weil_pairing(P, 5) zeta5^3 TESTS: Check that the original Sage implementation still works:: - sage: GF(65537^2).inject_variables() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: GF(65537^2).inject_variables() Defining z2 - sage: E = EllipticCurve(GF(65537^2), [0,1]) # optional - sage.rings.finite_rings - sage: P = E(22, 28891) # optional - sage.rings.finite_rings - sage: Q = E(-93, 40438*z2 + 31573) # optional - sage.rings.finite_rings - sage: P.weil_pairing(Q, 7282, algorithm='sage') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537^2), [0,1]) + sage: P = E(22, 28891) + sage: Q = E(-93, 40438*z2 + 31573) + sage: P.weil_pairing(Q, 7282, algorithm='sage') 19937*z2 + 65384 Passing an unknown ``algorithm=`` argument should fail:: - sage: P.weil_pairing(Q, 7282, algorithm='_invalid_') # optional - sage.rings.finite_rings + sage: P.weil_pairing(Q, 7282, algorithm='_invalid_') # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: unknown algorithm @@ -1812,82 +1833,86 @@ def tate_pairing(self, Q, n, k, q=None): A simple example, pairing a point with itself, and pairing a point with another rational point:: - sage: p = 103; A = 1; B = 18; E = EllipticCurve(GF(p), [A, B]) # optional - sage.rings.finite_rings - sage: P = E(33, 91); n = P.order(); n # optional - sage.rings.finite_rings + sage: p = 103; A = 1; B = 18; E = EllipticCurve(GF(p), [A, B]) + sage: P = E(33, 91); n = P.order(); n 19 - sage: k = GF(n)(p).multiplicative_order(); k # optional - sage.rings.finite_rings + sage: k = GF(n)(p).multiplicative_order(); k 6 - sage: P.tate_pairing(P, n, k) # optional - sage.rings.finite_rings + sage: P.tate_pairing(P, n, k) 1 - sage: Q = E(87, 51) # optional - sage.rings.finite_rings - sage: P.tate_pairing(Q, n, k) # optional - sage.rings.finite_rings + sage: Q = E(87, 51) + sage: P.tate_pairing(Q, n, k) 1 sage: set_random_seed(35) - sage: P.tate_pairing(P, n, k) # optional - sage.rings.finite_rings + sage: P.tate_pairing(P, n, k) 1 We now let `Q` be a point on the same curve as above, but defined over the pairing extension field, and we also demonstrate the bilinearity of the pairing:: - sage: K. = GF((p,k)) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K); P = EK(P) # optional - sage.rings.finite_rings - sage: Qx = 69*a^5 + 96*a^4 + 22*a^3 + 86*a^2 + 6*a + 35 # optional - sage.rings.finite_rings - sage: Qy = 34*a^5 + 24*a^4 + 16*a^3 + 41*a^2 + 4*a + 40 # optional - sage.rings.finite_rings - sage: Q = EK(Qx, Qy); # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF((p,k)) + sage: EK = E.base_extend(K); P = EK(P) + sage: Qx = 69*a^5 + 96*a^4 + 22*a^3 + 86*a^2 + 6*a + 35 + sage: Qy = 34*a^5 + 24*a^4 + 16*a^3 + 41*a^2 + 4*a + 40 + sage: Q = EK(Qx, Qy); Multiply by cofactor so Q has order n:: - sage: h = 551269674; Q = h*Q # optional - sage.rings.finite_rings - sage: P = EK(P); P.tate_pairing(Q, n, k) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: h = 551269674; Q = h*Q + sage: P = EK(P); P.tate_pairing(Q, n, k) 24*a^5 + 34*a^4 + 3*a^3 + 69*a^2 + 86*a + 45 - sage: s = Integer(randrange(1,n)) # optional - sage.rings.finite_rings - sage: ans1 = (s*P).tate_pairing(Q, n, k) # optional - sage.rings.finite_rings - sage: ans2 = P.tate_pairing(s*Q, n, k) # optional - sage.rings.finite_rings - sage: ans3 = P.tate_pairing(Q, n, k)^s # optional - sage.rings.finite_rings - sage: ans1 == ans2 == ans3 # optional - sage.rings.finite_rings + sage: s = Integer(randrange(1,n)) + sage: ans1 = (s*P).tate_pairing(Q, n, k) + sage: ans2 = P.tate_pairing(s*Q, n, k) + sage: ans3 = P.tate_pairing(Q, n, k)^s + sage: ans1 == ans2 == ans3 True - sage: (ans1 != 1) and (ans1^n == 1) # optional - sage.rings.finite_rings + sage: (ans1 != 1) and (ans1^n == 1) True Here is an example of using the Tate pairing to compute the Weil pairing (using the same data as above):: - sage: e = Integer((p^k-1)/n); e # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: e = Integer((p^k-1)/n); e 62844857712 - sage: P.weil_pairing(Q, n)^e # optional - sage.rings.finite_rings + sage: P.weil_pairing(Q, n)^e 94*a^5 + 99*a^4 + 29*a^3 + 45*a^2 + 57*a + 34 - sage: P.tate_pairing(Q, n, k) == P._miller_(Q, n)^e # optional - sage.rings.finite_rings + sage: P.tate_pairing(Q, n, k) == P._miller_(Q, n)^e True - sage: Q.tate_pairing(P, n, k) == Q._miller_(P, n)^e # optional - sage.rings.finite_rings + sage: Q.tate_pairing(P, n, k) == Q._miller_(P, n)^e True - sage: P.tate_pairing(Q, n, k)/Q.tate_pairing(P, n, k) # optional - sage.rings.finite_rings + sage: P.tate_pairing(Q, n, k)/Q.tate_pairing(P, n, k) 94*a^5 + 99*a^4 + 29*a^3 + 45*a^2 + 57*a + 34 An example where we have to pass the base field size (and we again have agreement with the Weil pairing):: - sage: F. = GF((2,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Fx. = GF((2,4*5)) # optional - sage.rings.finite_rings - sage: Ex = EllipticCurve(Fx,[0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) # optional - sage.rings.finite_rings - sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) # optional - sage.rings.finite_rings - sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((2,5)) + sage: E = EllipticCurve(F, [0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Fx. = GF((2,4*5)) + sage: Ex = EllipticCurve(Fx,[0,0,1,1,1]) + sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) + sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) + sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, ....: b^18 + b^13 + b^10 + b^8 + b^5 + b^4 + b^3 + b) - sage: Px.tate_pairing(Qx, n=41, k=4) # optional - sage.rings.finite_rings + sage: Px.tate_pairing(Qx, n=41, k=4) Traceback (most recent call last): ... ValueError: Unexpected field degree: set keyword argument q equal to the size of the base field (big field is GF(q^4)). - sage: num = Px.tate_pairing(Qx, n=41, k=4, q=32); num # optional - sage.rings.finite_rings + sage: num = Px.tate_pairing(Qx, n=41, k=4, q=32); num b^19 + b^14 + b^13 + b^12 + b^6 + b^4 + b^3 - sage: den = Qx.tate_pairing(Px, n=41, k=4, q=32); den # optional - sage.rings.finite_rings + sage: den = Qx.tate_pairing(Px, n=41, k=4, q=32); den b^19 + b^17 + b^16 + b^15 + b^14 + b^10 + b^6 + b^2 + 1 - sage: e = Integer((32^4-1)/41); e # optional - sage.rings.finite_rings + sage: e = Integer((32^4-1)/41); e 25575 - sage: Px.weil_pairing(Qx, 41)^e == num/den # optional - sage.rings.finite_rings + sage: Px.weil_pairing(Qx, 41)^e == num/den True .. NOTE:: @@ -1968,64 +1993,68 @@ def ate_pairing(self, Q, n, k, t, q=None): An example with embedding degree 6:: + sage: # needs sage.rings.finite_rings sage: p = 7549; A = 0; B = 1; n = 157; k = 6; t = 14 - sage: F = GF(p); E = EllipticCurve(F, [A, B]) # optional - sage.rings.finite_rings - sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(3050, 5371); Q = EK(6908*a^4, 3231*a^3) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: F = GF(p); E = EllipticCurve(F, [A, B]) + sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) + sage: EK = E.base_extend(K) + sage: P = EK(3050, 5371); Q = EK(6908*a^4, 3231*a^3) + sage: P.ate_pairing(Q, n, k, t) 6708*a^5 + 4230*a^4 + 4350*a^3 + 2064*a^2 + 4022*a + 6733 - sage: s = Integer(randrange(1, n)) # optional - sage.rings.finite_rings - sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) # optional - sage.rings.finite_rings + sage: s = Integer(randrange(1, n)) + sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) True - sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s # optional - sage.rings.finite_rings + sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s True Another example with embedding degree 7 and positive trace:: + sage: # needs sage.rings.finite_rings sage: p = 2213; A = 1; B = 49; n = 1093; k = 7; t = 28 - sage: F = GF(p); E = EllipticCurve(F, [A, B]) # optional - sage.rings.finite_rings - sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(1583, 1734) # optional - sage.rings.finite_rings - sage: Qx = 1729*a^6+1767*a^5+245*a^4+980*a^3+1592*a^2+1883*a+722 # optional - sage.rings.finite_rings - sage: Qy = 1299*a^6+1877*a^5+1030*a^4+1513*a^3+1457*a^2+309*a+1636 # optional - sage.rings.finite_rings - sage: Q = EK(Qx, Qy) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: F = GF(p); E = EllipticCurve(F, [A, B]) + sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) + sage: EK = E.base_extend(K) + sage: P = EK(1583, 1734) + sage: Qx = 1729*a^6+1767*a^5+245*a^4+980*a^3+1592*a^2+1883*a+722 + sage: Qy = 1299*a^6+1877*a^5+1030*a^4+1513*a^3+1457*a^2+309*a+1636 + sage: Q = EK(Qx, Qy) + sage: P.ate_pairing(Q, n, k, t) 1665*a^6 + 1538*a^5 + 1979*a^4 + 239*a^3 + 2134*a^2 + 2151*a + 654 - sage: s = Integer(randrange(1, n)) # optional - sage.rings.finite_rings - sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) # optional - sage.rings.finite_rings + sage: s = Integer(randrange(1, n)) + sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) True - sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s # optional - sage.rings.finite_rings + sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s True Another example with embedding degree 7 and negative trace:: + sage: # needs sage.rings.finite_rings sage: p = 2017; A = 1; B = 30; n = 29; k = 7; t = -70 - sage: F = GF(p); E = EllipticCurve(F, [A, B]) # optional - sage.rings.finite_rings - sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(369, 716) # optional - sage.rings.finite_rings - sage: Qx = 1226*a^6+1778*a^5+660*a^4+1791*a^3+1750*a^2+867*a+770 # optional - sage.rings.finite_rings - sage: Qy = 1764*a^6+198*a^5+1206*a^4+406*a^3+1200*a^2+273*a+1712 # optional - sage.rings.finite_rings - sage: Q = EK(Qx, Qy) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: F = GF(p); E = EllipticCurve(F, [A, B]) + sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) + sage: EK = E.base_extend(K) + sage: P = EK(369, 716) + sage: Qx = 1226*a^6+1778*a^5+660*a^4+1791*a^3+1750*a^2+867*a+770 + sage: Qy = 1764*a^6+198*a^5+1206*a^4+406*a^3+1200*a^2+273*a+1712 + sage: Q = EK(Qx, Qy) + sage: P.ate_pairing(Q, n, k, t) 1794*a^6 + 1161*a^5 + 576*a^4 + 488*a^3 + 1950*a^2 + 1905*a + 1315 - sage: s = Integer(randrange(1, n)) # optional - sage.rings.finite_rings - sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) # optional - sage.rings.finite_rings + sage: s = Integer(randrange(1, n)) + sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) True - sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s # optional - sage.rings.finite_rings + sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s True Using the same data, we show that the ate pairing is a power of the Tate pairing (see [HSV2006]_ end of section 3.1):: - sage: c = (k*p^(k-1)).mod(n); T = t - 1 # optional - sage.rings.finite_rings - sage: N = gcd(T^k - 1, p^k - 1) # optional - sage.rings.finite_rings - sage: s = Integer(N/n) # optional - sage.rings.finite_rings - sage: L = Integer((T^k - 1)/N) # optional - sage.rings.finite_rings - sage: M = (L*s*c.inverse_mod(n)).mod(n) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) == Q.tate_pairing(P, n, k)^M # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: c = (k*p^(k-1)).mod(n); T = t - 1 + sage: N = gcd(T^k - 1, p^k - 1) + sage: s = Integer(N/n) + sage: L = Integer((T^k - 1)/N) + sage: M = (L*s*c.inverse_mod(n)).mod(n) + sage: P.ate_pairing(Q, n, k, t) == Q.tate_pairing(P, n, k)^M True An example where we have to pass the base field size (and we again have @@ -2033,59 +2062,62 @@ def ate_pairing(self, Q, n, k, t, q=None): `F`-rational, (it is the homomorphic image of an `F`-rational point) it is nonetheless in `ker(\pi-1)`, and so is a legitimate input:: - sage: q = 2^5; F. = GF(q) # optional - sage.rings.finite_rings - sage: n = 41; k = 4; t = -8 # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F,[0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Fx. = GF(q^k) # optional - sage.rings.finite_rings - sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) # optional - sage.rings.finite_rings - sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) # optional - sage.rings.finite_rings - sage: Qx = Ex(b^19+b^18+b^16+b^12+b^10+b^9+b^8+b^5+b^3+1, # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: q = 2^5; F. = GF(q) + sage: n = 41; k = 4; t = -8 + sage: E = EllipticCurve(F,[0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Fx. = GF(q^k) + sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) + sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) + sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) + sage: Qx = Ex(b^19+b^18+b^16+b^12+b^10+b^9+b^8+b^5+b^3+1, ....: b^18+b^13+b^10+b^8+b^5+b^4+b^3+b) - sage: Qx = Ex(Qx[0]^q, Qx[1]^q) - Qx # ensure Qx is in ker(pi - q) # optional - sage.rings.finite_rings - sage: Px.ate_pairing(Qx, n, k, t) # optional - sage.rings.finite_rings + sage: Qx = Ex(Qx[0]^q, Qx[1]^q) - Qx # ensure Qx is in ker(pi - q) + sage: Px.ate_pairing(Qx, n, k, t) Traceback (most recent call last): ... ValueError: Unexpected field degree: set keyword argument q equal to the size of the base field (big field is GF(q^4)). - sage: Px.ate_pairing(Qx, n, k, t, q) # optional - sage.rings.finite_rings + sage: Px.ate_pairing(Qx, n, k, t, q) b^19 + b^18 + b^17 + b^16 + b^15 + b^14 + b^13 + b^12 + b^11 + b^9 + b^8 + b^5 + b^4 + b^2 + b + 1 sage: s = Integer(randrange(1, n)) - sage: (s*Px).ate_pairing(Qx, n, k, t, q) == Px.ate_pairing(s*Qx, n, k, t, q) # optional - sage.rings.finite_rings + sage: (s*Px).ate_pairing(Qx, n, k, t, q) == Px.ate_pairing(s*Qx, n, k, t, q) True - sage: Px.ate_pairing(s*Qx, n, k, t, q) == Px.ate_pairing(Qx, n, k, t, q)^s # optional - sage.rings.finite_rings + sage: Px.ate_pairing(s*Qx, n, k, t, q) == Px.ate_pairing(Qx, n, k, t, q)^s True - sage: c = (k*q^(k-1)).mod(n); T = t - 1 # optional - sage.rings.finite_rings - sage: N = gcd(T^k - 1, q^k - 1) # optional - sage.rings.finite_rings - sage: s = Integer(N/n) # optional - sage.rings.finite_rings - sage: L = Integer((T^k - 1)/N) # optional - sage.rings.finite_rings - sage: M = (L*s*c.inverse_mod(n)).mod(n) # optional - sage.rings.finite_rings - sage: Px.ate_pairing(Qx, n, k, t, q) == Qx.tate_pairing(Px, n, k, q)^M # optional - sage.rings.finite_rings + sage: c = (k*q^(k-1)).mod(n); T = t - 1 + sage: N = gcd(T^k - 1, q^k - 1) + sage: s = Integer(N/n) + sage: L = Integer((T^k - 1)/N) + sage: M = (L*s*c.inverse_mod(n)).mod(n) + sage: Px.ate_pairing(Qx, n, k, t, q) == Qx.tate_pairing(Px, n, k, q)^M True It is an error if `Q` is not in the kernel of `\pi - p`, where `\pi` is the Frobenius automorphism:: - sage: p = 29; A = 1; B = 0; n = 5; k = 2; t = 10 # optional - sage.rings.finite_rings - sage: F = GF(p); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [A, B]); # optional - sage.rings.finite_rings - sage: K. = GF((p,k), modulus=x^k+2); EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(13, 8); Q = EK(13, 21) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = 29; A = 1; B = 0; n = 5; k = 2; t = 10 + sage: F = GF(p); R. = F[] + sage: E = EllipticCurve(F, [A, B]); + sage: K. = GF((p,k), modulus=x^k+2); EK = E.base_extend(K) + sage: P = EK(13, 8); Q = EK(13, 21) + sage: P.ate_pairing(Q, n, k, t) Traceback (most recent call last): ... ValueError: Point (13 : 21 : 1) not in Ker(pi - q) It is also an error if `P` is not in the kernel os `\pi - 1`:: + sage: # needs sage.rings.finite_rings sage: p = 29; A = 1; B = 0; n = 5; k = 2; t = 10 - sage: F = GF(p); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [A, B]); # optional - sage.rings.finite_rings - sage: K. = GF((p,k), modulus=x^k+2); EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(14, 10*a); Q = EK(13, 21) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: F = GF(p); R. = F[] + sage: E = EllipticCurve(F, [A, B]); + sage: K. = GF((p,k), modulus=x^k+2); EK = E.base_extend(K) + sage: P = EK(14, 10*a); Q = EK(13, 21) + sage: P.ate_pairing(Q, n, k, t) Traceback (most recent call last): ... ValueError: This point (14 : 10*a : 1) is not in Ker(pi - 1) @@ -2155,7 +2187,7 @@ class EllipticCurvePoint_number_field(EllipticCurvePoint_field): (0 : 0 : 1) sage: E(0,0) # brackets are optional (0 : 0 : 1) - sage: E([GF(5)(0), 0]) # entries are coerced # optional - sage.rings.finite_rings + sage: E([GF(5)(0), 0]) # entries are coerced (0 : 0 : 1) sage: E(0.000, 0) @@ -2340,21 +2372,23 @@ def is_on_identity_component(self, embedding=None): An example over a field with two real embeddings:: - sage: L. = QuadraticField(2) # optional - sage.rings.number_field - sage: E = EllipticCurve(L, [0,1,0,a,a]) # optional - sage.rings.number_field - sage: P = E(-1,0) # optional - sage.rings.number_field - sage: [P.is_on_identity_component(e) for e in L.embeddings(RR)] # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: L. = QuadraticField(2) + sage: E = EllipticCurve(L, [0,1,0,a,a]) + sage: P = E(-1,0) + sage: [P.is_on_identity_component(e) for e in L.embeddings(RR)] [False, True] We can check this as follows:: - sage: [e(E.discriminant()) > 0 for e in L.embeddings(RR)] # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: [e(E.discriminant()) > 0 for e in L.embeddings(RR)] [True, False] - sage: e = L.embeddings(RR)[0] # optional - sage.rings.number_field - sage: E1 = EllipticCurve(RR, [e(ai) for ai in E.ainvs()]) # optional - sage.rings.number_field - sage: e1, e2, e3 = E1.two_division_polynomial().roots(RR, # optional - sage.rings.number_field + sage: e = L.embeddings(RR)[0] + sage: E1 = EllipticCurve(RR, [e(ai) for ai in E.ainvs()]) + sage: e1, e2, e3 = E1.two_division_polynomial().roots(RR, ....: multiplicities=False) - sage: e1 < e2 < e3 and e(P[0]) < e3 # optional - sage.rings.number_field + sage: e1 < e2 < e3 and e(P[0]) < e3 True """ if self.is_zero(): # trivial case @@ -2425,22 +2459,23 @@ def has_good_reduction(self, P=None): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1,0,-160,308]) # optional - sage.rings.number_field - sage: P = E(26, -120) # optional - sage.rings.number_field - sage: E.discriminant().support() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,1,0,-160,308]) + sage: P = E(26, -120) + sage: E.discriminant().support() [Fractional ideal (i + 1), Fractional ideal (-i - 2), Fractional ideal (2*i + 1), Fractional ideal (3)] - sage: [E.tamagawa_exponent(p) for p in E.discriminant().support()] # optional - sage.rings.number_field + sage: [E.tamagawa_exponent(p) for p in E.discriminant().support()] [1, 4, 4, 4] - sage: P.has_good_reduction() # optional - sage.rings.number_field + sage: P.has_good_reduction() False - sage: (2*P).has_good_reduction() # optional - sage.rings.number_field + sage: (2*P).has_good_reduction() False - sage: (4*P).has_good_reduction() # optional - sage.rings.number_field + sage: (4*P).has_good_reduction() True TESTS: @@ -2448,14 +2483,14 @@ def has_good_reduction(self, P=None): An example showing that :trac:`8498` is fixed:: sage: E = EllipticCurve('11a1') - sage: K. = NumberField(x^2 + 47) # optional - sage.rings.number_field - sage: EK = E.base_extend(K) # optional - sage.rings.number_field - sage: T = EK(5, 5) # optional - sage.rings.number_field - sage: P = EK(-2, -1/2*t - 1/2) # optional - sage.rings.number_field - sage: p = K.ideal(11) # optional - sage.rings.number_field - sage: T.has_good_reduction(p) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 47) # needs sage.rings.number_field + sage: EK = E.base_extend(K) # needs sage.rings.number_field + sage: T = EK(5, 5) # needs sage.rings.number_field + sage: P = EK(-2, -1/2*t - 1/2) # needs sage.rings.number_field + sage: p = K.ideal(11) # needs sage.rings.number_field + sage: T.has_good_reduction(p) # needs sage.rings.number_field False - sage: P.has_good_reduction(p) # optional - sage.rings.number_field + sage: P.has_good_reduction(p) # needs sage.rings.number_field True """ if self.is_zero(): # trivial case @@ -2536,23 +2571,25 @@ def reduction(self, p): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: F. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: E = EllipticCurve(F, [1,2,3,4,0]) # optional - sage.rings.number_field - sage: Q = E(98, 931) # optional - sage.rings.number_field - sage: Q.reduction(a) # optional - sage.rings.number_field + sage: F. = NumberField(x^2 + 5) + sage: E = EllipticCurve(F, [1,2,3,4,0]) + sage: Q = E(98, 931) + sage: Q.reduction(a) (3 : 1 : 1) - sage: Q.reduction(11) # optional - sage.rings.number_field + sage: Q.reduction(11) (10 : 7 : 1) :: - sage: F. = NumberField(x^3 + x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(F, [a,2]) # optional - sage.rings.number_field - sage: P = E(a, 1) # optional - sage.rings.number_field - sage: P.reduction(F.ideal(5)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F. = NumberField(x^3 + x^2 + 1) + sage: E = EllipticCurve(F, [a,2]) + sage: P = E(a, 1) + sage: P.reduction(F.ideal(5)) (abar : 1 : 1) - sage: P.reduction(F.ideal(a^2 - 4*a - 2)) # optional - sage.rings.number_field + sage: P.reduction(F.ideal(a^2 - 4*a - 2)) (abar : 1 : 1) """ P = self @@ -2666,20 +2703,20 @@ def height(self, precision=None, normalised=True, algorithm='pari'): Canonical heights over number fields are implemented as well:: sage: R. = QQ[] - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([a, 4]); E # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: E = EllipticCurve([a, 4]); E # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + a*x + 4 over Number Field in a with defining polynomial x^3 - 2 - sage: P = E((0,2)) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: P = E((0,2)) # needs sage.rings.number_field + sage: P.height() # needs sage.rings.number_field 0.810463096585925 - sage: P.height(precision=100) # optional - sage.rings.number_field + sage: P.height(precision=100) # needs sage.rings.number_field 0.81046309658592536863991810577 - sage: P.height(precision=200) # optional - sage.rings.number_field + sage: P.height(precision=200) # needs sage.rings.number_field 0.81046309658592536863991810576865158896130286417155832378086 - sage: (2*P).height() / P.height() # optional - sage.rings.number_field + sage: (2*P).height() / P.height() # needs sage.rings.number_field 4.00000000000000 - sage: (100*P).height() / P.height() # optional - sage.rings.number_field + sage: (100*P).height() / P.height() # needs sage.rings.number_field 10000.0000000000 Setting ``normalised=False`` multiplies the height by the degree of `K`:: @@ -2690,12 +2727,12 @@ def height(self, precision=None, normalised=True, algorithm='pari'): 0.0511114082399688 sage: P.height(normalised=False) 0.0511114082399688 - sage: K. = CyclotomicField(5) # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: PK = EK([0,0]) # optional - sage.rings.number_field - sage: PK.height() # optional - sage.rings.number_field + sage: K. = CyclotomicField(5) # needs sage.rings.number_field + sage: EK = E.change_ring(K) # needs sage.rings.number_field + sage: PK = EK([0,0]) # needs sage.rings.number_field + sage: PK.height() # needs sage.rings.number_field 0.0511114082399688 - sage: PK.height(normalised=False) # optional - sage.rings.number_field + sage: PK.height(normalised=False) # needs sage.rings.number_field 0.204445632959875 Some consistency checks:: @@ -2705,31 +2742,32 @@ def height(self, precision=None, normalised=True, algorithm='pari'): sage: P.height() 1.36857250535393 - sage: EK = E.change_ring(QuadraticField(-3,'a')) # optional - sage.rings.number_field - sage: PK = EK([-2,3,1]) # optional - sage.rings.number_field - sage: PK.height() # optional - sage.rings.number_field + sage: EK = E.change_ring(QuadraticField(-3,'a')) # needs sage.rings.number_field + sage: PK = EK([-2,3,1]) # needs sage.rings.number_field + sage: PK.height() # needs sage.rings.number_field 1.36857250535393 - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,4,6*i,0]) # optional - sage.rings.number_field - sage: Q = E.lift_x(-9/4); Q # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,4,6*i,0]) + sage: Q = E.lift_x(-9/4); Q (-9/4 : 27/8*i - 4 : 1) - sage: Q.height() # optional - sage.rings.number_field + sage: Q.height() 2.69518560017909 - sage: (15*Q).height() / Q.height() # optional - sage.rings.number_field + sage: (15*Q).height() / Q.height() 225.000000000000 sage: E = EllipticCurve('37a') sage: P = E([0,-1]) sage: P.height() 0.0511114082399688 - sage: K. = QuadraticField(-7) # optional - sage.rings.number_field - sage: ED = E.quadratic_twist(-7) # optional - sage.rings.number_field - sage: Q = E.isomorphism_to(ED.change_ring(K))(P); Q # optional - sage.rings.number_field + sage: K. = QuadraticField(-7) # needs sage.rings.number_field + sage: ED = E.quadratic_twist(-7) # needs sage.rings.number_field + sage: Q = E.isomorphism_to(ED.change_ring(K))(P); Q # needs sage.rings.number_field (0 : -7/2*a - 1/2 : 1) - sage: Q.height() # optional - sage.rings.number_field + sage: Q.height() # needs sage.rings.number_field 0.0511114082399688 - sage: Q.height(precision=100) # optional - sage.rings.number_field + sage: Q.height(precision=100) # needs sage.rings.number_field 0.051111408239968840235886099757 An example to show that the bug at :trac:`5252` is fixed:: @@ -2763,18 +2801,19 @@ def height(self, precision=None, normalised=True, algorithm='pari'): An example to show that the bug at :trac:`12509` is fixed (precision issues):: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688] # optional - sage.rings.number_field - sage: E = EllipticCurve(v) # optional - sage.rings.number_field - sage: P = E([72*a - 509/5, -682/25*a - 434/25]) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) + sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688] + sage: E = EllipticCurve(v) + sage: P = E([72*a - 509/5, -682/25*a - 434/25]) + sage: P.height() 1.38877711688727 - sage: (2*P).height()/P.height() # optional - sage.rings.number_field + sage: (2*P).height()/P.height() 4.00000000000000 - sage: (2*P).height(precision=100)/P.height(precision=100) # optional - sage.rings.number_field + sage: (2*P).height(precision=100)/P.height(precision=100) 4.0000000000000000000000000000 - sage: (2*P).height(precision=1000)/P.height(precision=1000) # optional - sage.rings.number_field + sage: (2*P).height(precision=1000)/P.height(precision=1000) 4.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 This shows that the bug reported at :trac:`13951` has been fixed:: @@ -2783,9 +2822,9 @@ def height(self, precision=None, normalised=True, algorithm='pari'): sage: P1 = E(2,5) sage: P1.height() 1.06248137652528 - sage: F = E.change_ring(QuadraticField(-3, 'a')) # optional - sage.rings.number_field - sage: P2 = F([2,5]) # optional - sage.rings.number_field - sage: P2.height() # optional - sage.rings.number_field + sage: F = E.change_ring(QuadraticField(-3, 'a')) # needs sage.rings.number_field + sage: P2 = F([2,5]) # needs sage.rings.number_field + sage: P2.height() # needs sage.rings.number_field 1.06248137652528 """ if self.has_finite_order(): @@ -2860,27 +2899,29 @@ def archimedean_local_height(self, v=None, prec=None, weighted=False): Examples 1, 2, and 3 from [Sil1988]_:: - sage: K. = QuadraticField(-2) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,-1,1,0,0]); E # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-2) + sage: E = EllipticCurve(K, [0,-1,1,0,0]); E Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 over Number Field in a with defining polynomial x^2 + 2 with a = 1.414213562373095?*I - sage: P = E.lift_x(2 + a); P # optional - sage.rings.number_field + sage: P = E.lift_x(2 + a); P (a + 2 : -2*a - 2 : 1) - sage: P.archimedean_local_height(K.places(prec=170)[0]) / 2 # optional - sage.rings.number_field + sage: P.archimedean_local_height(K.places(prec=170)[0]) / 2 0.45754773287523276736211210741423654346576029814695 + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E Elliptic Curve defined by y^2 + 4*y = x^3 + 6*i*x over Number Field in i with defining polynomial x^2 + 1 - sage: P = E((0,0)) # optional - sage.rings.number_field - sage: P.archimedean_local_height(K.places()[0]) / 2 # optional - sage.rings.number_field + sage: P = E((0,0)) + sage: P.archimedean_local_height(K.places()[0]) / 2 0.510184995162373 - sage: Q = E.lift_x(-9/4); Q # optional - sage.rings.number_field + sage: Q = E.lift_x(-9/4); Q # needs sage.rings.number_field (-9/4 : 27/8*i - 4 : 1) - sage: Q.archimedean_local_height(K.places()[0]) / 2 # optional - sage.rings.number_field + sage: Q.archimedean_local_height(K.places()[0]) / 2 # needs sage.rings.number_field 0.654445619529600 An example over the rational numbers:: @@ -2893,45 +2934,49 @@ def archimedean_local_height(self, v=None, prec=None, weighted=False): Local heights of torsion points can be non-zero (unlike the global height):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, K(1), 0]) # optional - sage.rings.number_field - sage: P = E(i, 0) # optional - sage.rings.number_field - sage: P.archimedean_local_height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, K(1), 0]) + sage: P = E(i, 0) + sage: P.archimedean_local_height() 0.346573590279973 TESTS: See :trac:`12509`:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688] # optional - sage.rings.number_field - sage: E = EllipticCurve(v) # optional - sage.rings.number_field - sage: P = E([72*a - 509/5, -682/25*a - 434/25]) # optional - sage.rings.number_field - sage: P.archimedean_local_height() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) + sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688] + sage: E = EllipticCurve(v) + sage: P = E([72*a - 509/5, -682/25*a - 434/25]) + sage: P.archimedean_local_height() -0.220660795546828 See :trac:`19276`:: - sage: K. = NumberField(x^2 - x - 104) # optional - sage.rings.number_field - sage: E = EllipticCurve([1, a - 1, 1, -816765673272*a - 7931030674178, 1478955604013312315*a + 14361086227143654561]) # optional - sage.rings.number_field - sage: P = E(5393511/49*a + 52372721/49 , -33896210324/343*a - 329141996591/343 ) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - x - 104) + sage: E = EllipticCurve([1, a - 1, 1, -816765673272*a - 7931030674178, 1478955604013312315*a + 14361086227143654561]) + sage: P = E(5393511/49*a + 52372721/49 , -33896210324/343*a - 329141996591/343 ) + sage: P.height() 0.974232017827741 See :trac:`29966`:: - sage: K. = NumberField(x^3 - x^2 - 6*x + 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([1, -a^2 + 2*a + 4, 0, -6056450500590472699700624*a^2 - 11239394326797569935861742*a + 4241549693833829432516231, # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - x^2 - 6*x + 2) + sage: E = EllipticCurve([1, -a^2 + 2*a + 4, 0, -6056450500590472699700624*a^2 - 11239394326797569935861742*a + 4241549693833829432516231, ....: 1904879037869682826729875958079326124520*a^2 + 3535022146945771697732350459284777382011*a - 1334055169621036218710397707677347972626]) - sage: P = E([1033399668533*a^2 + 1917754693229*a - 723726883800 , 12536493059202326563*a^2 + 23264879148900575548*a - 8779756111574815918 , 1]) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: P = E([1033399668533*a^2 + 1917754693229*a - 723726883800 , 12536493059202326563*a^2 + 23264879148900575548*a - 8779756111574815918 , 1]) + sage: P.height() 0.297318833424763 - sage: (2*P).height() / P.height() # optional - sage.rings.number_field + sage: (2*P).height() / P.height() 4.00000000000000 - sage: P.height(200) # optional - sage.rings.number_field + sage: P.height(200) 0.29731883342476341806143743594519935578696537745294661858984 - sage: (2*P).height(200) / P.height(200) # optional - sage.rings.number_field + sage: (2*P).height(200) / P.height(200) 4.0000000000000000000000000000000000000000000000000000000000 """ from sage.rings.number_field.number_field import refine_embedding @@ -3089,28 +3134,30 @@ def non_archimedean_local_height(self, v=None, prec=None, Examples 2 and 3 from [Sil1988]_:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E Elliptic Curve defined by y^2 + 4*y = x^3 + 6*i*x over Number Field in i with defining polynomial x^2 + 1 - sage: P = E((0,0)) # optional - sage.rings.number_field - sage: P.non_archimedean_local_height(K.ideal(i+1)) # optional - sage.rings.number_field + sage: P = E((0,0)) + sage: P.non_archimedean_local_height(K.ideal(i+1)) -1/2*log(2) - sage: P.non_archimedean_local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: P.non_archimedean_local_height(K.ideal(3)) 0 - sage: P.non_archimedean_local_height(K.ideal(1-2*i)) # optional - sage.rings.number_field + sage: P.non_archimedean_local_height(K.ideal(1-2*i)) 0 - sage: Q = E.lift_x(-9/4); Q # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: Q = E.lift_x(-9/4); Q (-9/4 : 27/8*i - 4 : 1) - sage: Q.non_archimedean_local_height(K.ideal(1+i)) # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height(K.ideal(1+i)) 2*log(2) - sage: Q.non_archimedean_local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height(K.ideal(3)) 0 - sage: Q.non_archimedean_local_height(K.ideal(1-2*i)) # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height(K.ideal(1-2*i)) 0 - sage: Q.non_archimedean_local_height() # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height() 2*log(2) An example over the rational numbers:: @@ -3123,30 +3170,32 @@ def non_archimedean_local_height(self, v=None, prec=None, Local heights of torsion points can be non-zero (unlike the global height):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, K(1), 0]) # optional - sage.rings.number_field - sage: P = E(i, 0) # optional - sage.rings.number_field - sage: P.non_archimedean_local_height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, K(1), 0]) + sage: P = E(i, 0) + sage: P.non_archimedean_local_height() -1/2*log(2) TESTS:: - sage: Q.non_archimedean_local_height(prec=100) # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height(prec=100) # needs sage.rings.number_field 1.3862943611198906188344642429 - sage: (3*Q).non_archimedean_local_height() # optional - sage.rings.number_field + sage: (3*Q).non_archimedean_local_height() # needs sage.rings.number_field 1/2*log(75923153929839865104) - sage: F. = NumberField(x^4 + 2*x^3 + 19*x^2 + 18*x + 288) # optional - sage.rings.number_field - sage: F.ring_of_integers().basis() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F. = NumberField(x^4 + 2*x^3 + 19*x^2 + 18*x + 288) + sage: F.ring_of_integers().basis() [1, 5/6*a^3 + 1/6*a, 1/6*a^3 + 1/6*a^2, a^3] - sage: F.class_number() # optional - sage.rings.number_field + sage: F.class_number() 12 - sage: E = EllipticCurve('37a').change_ring(F) # optional - sage.rings.number_field - sage: P = E((-a^2/6 - a/6 - 1, a)); P # optional - sage.rings.number_field + sage: E = EllipticCurve('37a').change_ring(F) + sage: P = E((-a^2/6 - a/6 - 1, a)); P (-1/6*a^2 - 1/6*a - 1 : a : 1) - sage: P[0].is_integral() # optional - sage.rings.number_field + sage: P[0].is_integral() True - sage: P.non_archimedean_local_height() # optional - sage.rings.number_field + sage: P.non_archimedean_local_height() 0 This shows that the bug reported at :trac:`13951` has been fixed:: @@ -3333,25 +3382,27 @@ def elliptic_logarithm(self, embedding=None, precision=100, Examples over number fields:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: Ls = [E.period_lattice(e) for e in embs] # optional - sage.rings.number_field - sage: [L.real_flag for L in Ls] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: embs = K.embeddings(CC) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: Ls = [E.period_lattice(e) for e in embs] + sage: [L.real_flag for L in Ls] [0, 0, -1] - sage: P = E(-1,0) # order 2 # optional - sage.rings.number_field - sage: [L.elliptic_logarithm(P) for L in Ls] # optional - sage.rings.number_field + sage: P = E(-1,0) # order 2 + sage: [L.elliptic_logarithm(P) for L in Ls] [-1.73964256006716 - 1.07861534489191*I, -0.363756518406398 - 1.50699412135253*I, 1.90726488608927] - sage: E = EllipticCurve([-a^2 - a - 1, a^2 + a]) # optional - sage.rings.number_field - sage: Ls = [E.period_lattice(e) for e in embs] # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve([-a^2 - a - 1, a^2 + a]) + sage: Ls = [E.period_lattice(e) for e in embs] sage: pts = [E(2*a^2 - a - 1 , -2*a^2 - 2*a + 6 ), ....: E(-2/3*a^2 - 1/3 , -4/3*a - 2/3 ), ....: E(5/4*a^2 - 1/2*a , -a^2 - 1/4*a + 9/4 ), ....: E(2*a^2 + 3*a + 4 , -7*a^2 - 10*a - 12 )] - sage: [[L.elliptic_logarithm(P) for P in pts] for L in Ls] # optional - sage.rings.number_field + sage: [[L.elliptic_logarithm(P) for P in pts] for L in Ls] [[0.250819591818930 - 0.411963479992219*I, -0.290994550611374 - 1.37239400324105*I, -0.693473752205595 - 2.45028458830342*I, -0.151659609775291 - 1.48985406505459*I], [1.33444787667954 - 1.50889756650544*I, 0.792633734249234 - 0.548467043256610*I, @@ -3361,12 +3412,13 @@ def elliptic_logarithm(self, embedding=None, precision=100, :: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,9*i-10,21-i]) # optional - sage.rings.number_field - sage: emb = K.embeddings(CC)[1] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: P = E(2-i, 4+2*i) # optional - sage.rings.number_field - sage: L.elliptic_logarithm(P, prec=100) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0,0,0,9*i-10,21-i]) + sage: emb = K.embeddings(CC)[1] + sage: L = E.period_lattice(emb) + sage: P = E(2-i, 4+2*i) + sage: L.elliptic_logarithm(P, prec=100) 0.70448375537782208460499649302 - 0.79246725643650979858266018068*I """ from sage.rings.number_field.number_field import refine_embedding @@ -3484,30 +3536,30 @@ def padic_elliptic_logarithm(self, p, absprec=20): EXAMPLES:: sage: E = EllipticCurve([0,1,1,-2,0]) - sage: E(0).padic_elliptic_logarithm(3) # optional - sage.rings.padics + sage: E(0).padic_elliptic_logarithm(3) # needs sage.rings.padics 0 - sage: P = E(0, 0) # optional - sage.rings.padics - sage: P.padic_elliptic_logarithm(3) # optional - sage.rings.padics + sage: P = E(0, 0) # needs sage.rings.padics + sage: P.padic_elliptic_logarithm(3) # needs sage.rings.padics 2 + 2*3 + 3^3 + 2*3^7 + 3^8 + 3^9 + 3^11 + 3^15 + 2*3^17 + 3^18 + O(3^19) - sage: P.padic_elliptic_logarithm(3).lift() # optional - sage.rings.padics + sage: P.padic_elliptic_logarithm(3).lift() # needs sage.rings.padics 660257522 - sage: P = E(-11/9, 28/27) # optional - sage.rings.padics - sage: [(2*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(20)] # long time (3s) # optional - sage.rings.padics + sage: P = E(-11/9, 28/27) # needs sage.rings.padics + sage: [(2*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(20)] # long time, needs sage.rings.padics [2 + O(2^19), 2 + O(3^20), 2 + O(5^19), 2 + O(7^19), 2 + O(11^19), 2 + O(13^19), 2 + O(17^19), 2 + O(19^19)] - sage: [(3*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(12)] # long time (2s) # optional - sage.rings.padics + sage: [(3*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(12)] # long time, needs sage.rings.padics [1 + 2 + O(2^19), 3 + 3^20 + O(3^21), 3 + O(5^19), 3 + O(7^19), 3 + O(11^19)] - sage: [(5*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(12)] # long time (2s) # optional - sage.rings.padics + sage: [(5*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(12)] # long time, needs sage.rings.padics [1 + 2^2 + O(2^19), 2 + 3 + O(3^20), 5 + O(5^19), 5 + O(7^19), 5 + O(11^19)] An example which arose during reviewing :trac:`4741`:: sage: E = EllipticCurve('794a1') sage: P = E(-1,2) - sage: P.padic_elliptic_logarithm(2) # default precision=20 # optional - sage.rings.padics + sage: P.padic_elliptic_logarithm(2) # default precision=20 # needs sage.rings.padics 2^4 + 2^5 + 2^6 + 2^8 + 2^9 + 2^13 + 2^14 + 2^15 + O(2^16) - sage: P.padic_elliptic_logarithm(2, absprec=30) # optional - sage.rings.padics + sage: P.padic_elliptic_logarithm(2, absprec=30) # needs sage.rings.padics 2^4 + 2^5 + 2^6 + 2^8 + 2^9 + 2^13 + 2^14 + 2^15 + 2^22 + 2^23 + 2^24 + O(2^26) - sage: P.padic_elliptic_logarithm(2, absprec=40) # optional - sage.rings.padics + sage: P.padic_elliptic_logarithm(2, absprec=40) # needs sage.rings.padics 2^4 + 2^5 + 2^6 + 2^8 + 2^9 + 2^13 + 2^14 + 2^15 + 2^22 + 2^23 + 2^24 + 2^28 + 2^29 + 2^31 + 2^34 + O(2^35) """ @@ -3596,9 +3648,9 @@ def _magma_init_(self, magma): EXAMPLES:: - sage: E = EllipticCurve(GF(17), [1,-1]) # optional - sage.rings.finite_rings - sage: P = E([13, 4]) # optional - sage.rings.finite_rings - sage: P._magma_init_(magma) # optional - magma # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [1,-1]) + sage: P = E([13, 4]) + sage: P._magma_init_(magma) # optional - magma 'EllipticCurve([_sage_ref...|GF(17)!0,GF(17)!0,GF(17)!0,GF(17)!1,GF(17)!16])![13,4]' """ E = self.curve()._magma_init_(magma) @@ -3612,14 +3664,15 @@ def _acted_upon_(self, other, side): EXAMPLES:: - sage: P = EllipticCurve(GF(65537), [2,2]).lift_x(6) # optional - sage.rings.finite_rings - sage: P.order().factor() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P = EllipticCurve(GF(65537), [2,2]).lift_x(6) + sage: P.order().factor() 2^2 * 3 * 37^2 - sage: getattr(74*P, '_order', None) # optional - sage.rings.finite_rings + sage: getattr(74*P, '_order', None) 222 - sage: getattr(P*4070, '_order', None) # optional - sage.rings.finite_rings + sage: getattr(P*4070, '_order', None) 222 - sage: getattr(506*P*37, '_order', None) # optional - sage.rings.finite_rings + sage: getattr(506*P*37, '_order', None) 222 """ k = ZZ(other) @@ -3702,33 +3755,35 @@ def discrete_log(self, Q, ord=None): EXAMPLES:: - sage: F = GF((3,6),'a') # optional - sage.rings.finite_rings - sage: a = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve([0,1,1,a,a]) # optional - sage.rings.finite_rings - sage: E.cardinality() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF((3,6),'a') + sage: a = F.gen() + sage: E = EllipticCurve([0,1,1,a,a]) + sage: E.cardinality() 762 - sage: P = E.gens()[0] # optional - sage.rings.finite_rings - sage: Q = 400*P # optional - sage.rings.finite_rings - sage: P.discrete_log(Q) # optional - sage.rings.finite_rings + sage: P = E.gens()[0] + sage: Q = 400*P + sage: P.discrete_log(Q) 400 TESTS: Some random testing:: + sage: # needs sage.rings.finite_rings sage: sz = randint(8,32) sage: e = randint(1,3) sage: p = random_prime(ceil(2**(sz/e))) - sage: E = EllipticCurve(j=GF((p,e),'a').random_element()) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: Q = randrange(2**999) * P # optional - sage.rings.finite_rings - sage: x = P.discrete_log(Q) # optional - sage.rings.finite_rings - sage: x*P == Q # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF((p,e),'a').random_element()) + sage: P = E.random_point() + sage: Q = randrange(2**999) * P + sage: x = P.discrete_log(Q) + sage: x*P == Q True Doctest deprecation:: - sage: P.discrete_log(Q, ord=P.order()) # optional - sage.rings.finite_rings + sage: P.discrete_log(Q, ord=P.order()) # needs sage.rings.finite_rings doctest:warning ... DeprecationWarning: The "ord" argument to .discrete_log() is obsolete. ... @@ -3784,27 +3839,29 @@ def padic_elliptic_logarithm(self,Q, p): EXAMPLES:: - sage: p=235322474717419 - sage: b=8856682 - sage: E = EllipticCurve(GF(p), [0, b]) # optional - sage.rings.finite_rings - sage: P = E(200673830421813, 57025307876612) # optional - sage.rings.finite_rings - sage: Q = E(40345734829479, 211738132651297) # optional - sage.rings.finite_rings - sage: x = P.padic_elliptic_logarithm(Q, p) # optional - sage.rings.finite_rings sage.rings.padics - sage: x * P == Q # optional - sage.rings.finite_rings sage.rings.padics + sage: # needs sage.rings.finite_rings + sage: p = 235322474717419 + sage: b = 8856682 + sage: E = EllipticCurve(GF(p), [0, b]) + sage: P = E(200673830421813, 57025307876612) + sage: Q = E(40345734829479, 211738132651297) + sage: x = P.padic_elliptic_logarithm(Q, p) # needs sage.rings.padics + sage: x * P == Q # needs sage.rings.padics True TESTS: Some testing:: + sage: # needs sage.rings.finite_rings sage: a = 49850651047495986645822557378918223 sage: b = 21049438014429831351540675253466229 sage: p = 54283205379427155782089046839411711 - sage: E = EllipticCurve(GF(p), [a, b]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: Q = randrange(0, p-1) * P # optional - sage.rings.finite_rings - sage: x = P.padic_elliptic_logarithm(Q, p) # optional - sage.rings.finite_rings sage.rings.padics - sage: x*P == Q # optional - sage.rings.finite_rings sage.rings.padics + sage: E = EllipticCurve(GF(p), [a, b]) + sage: P = E.random_point() + sage: Q = randrange(0, p-1) * P + sage: x = P.padic_elliptic_logarithm(Q, p) # needs sage.rings.padics + sage: x*P == Q # needs sage.rings.padics True """ E = self.curve() @@ -3852,9 +3909,9 @@ def has_finite_order(self): EXAMPLES:: - sage: E = EllipticCurve(GF(7), [1,3]) # optional - sage.rings.finite_rings - sage: P = E.points()[3] # optional - sage.rings.finite_rings - sage: P.has_finite_order() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [1,3]) + sage: P = E.points()[3] + sage: P.has_finite_order() True """ return True @@ -3871,68 +3928,73 @@ def order(self): EXAMPLES:: - sage: k. = GF((5,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k,[2,4]); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF((5,5)) + sage: E = EllipticCurve(k,[2,4]); E Elliptic Curve defined by y^2 = x^3 + 2*x + 4 over Finite Field in a of size 5^5 - sage: P = E(3*a^4 + 3*a, 2*a + 1) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: P = E(3*a^4 + 3*a, 2*a + 1) + sage: P.order() 3227 - sage: Q = E(0,2) # optional - sage.rings.finite_rings - sage: Q.order() # optional - sage.rings.finite_rings + sage: Q = E(0,2) + sage: Q.order() 7 - sage: Q.additive_order() # optional - sage.rings.finite_rings + sage: Q.additive_order() 7 :: + sage: # needs sage.rings.finite_rings sage: p = next_prime(2^150) - sage: E = EllipticCurve(GF(p), [1,1]) # optional - sage.rings.finite_rings - sage: P = E(831623307675610677632782670796608848711856078, # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(p), [1,1]) + sage: P = E(831623307675610677632782670796608848711856078, ....: 42295786042873366706573292533588638217232964) - sage: P.order() # optional - sage.rings.finite_rings + sage: P.order() 1427247692705959881058262545272474300628281448 - sage: P.order() == E.cardinality() # optional - sage.rings.finite_rings + sage: P.order() == E.cardinality() True The next example has `j(E)=0`:: + sage: # needs sage.rings.finite_rings sage: p = 33554501 - sage: F. = GF((p,2)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,1]) # optional - sage.rings.finite_rings - sage: E.j_invariant() # optional - sage.rings.finite_rings + sage: F. = GF((p,2)) + sage: E = EllipticCurve(F, [0,1]) + sage: E.j_invariant() 0 - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: P.order() # random # optional - sage.rings.finite_rings + sage: P = E.random_point() + sage: P.order() # random 16777251 Similarly when `j(E)=1728`:: + sage: # needs sage.rings.finite_rings sage: p = 33554473 - sage: F. = GF((p,2)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,0]) # optional - sage.rings.finite_rings - sage: E.j_invariant() # optional - sage.rings.finite_rings + sage: F. = GF((p,2)) + sage: E = EllipticCurve(F, [1,0]) + sage: E.j_invariant() 1728 - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: P.order() # random # optional - sage.rings.finite_rings + sage: P = E.random_point() + sage: P.order() # random 46912611635760 TESTS: Check that the order actually gets cached (:trac:`32786`):: - sage: E = EllipticCurve(GF(31337), [42,1]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(1) # optional - sage.rings.finite_rings - sage: hasattr(P, '_order') # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(31337), [42,1]) + sage: P = E.lift_x(1) + sage: hasattr(P, '_order') False - sage: P.order() # optional - sage.rings.finite_rings + sage: P.order() 15649 - sage: P._order # optional - sage.rings.finite_rings + sage: P._order 15649 The curve order should also get cached as a side effect of computing a point order:: - sage: E._order # optional - sage.rings.finite_rings + sage: E._order # needs sage.rings.finite_rings 31298 """ try: diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py index 765485f0374..0ab4d47d1e1 100644 --- a/src/sage/schemes/elliptic_curves/ell_rational_field.py +++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py @@ -2306,7 +2306,7 @@ def gens(self, proof=None, **kwds): sage: E.gens(algorithm="pari") # random output [(5/4 : 5/8 : 1), (0 : 0 : 1)] sage: E = EllipticCurve([0,2429469980725060,0,275130703388172136833647756388,0]) - sage: len(E.gens(algorithm="pari")) + sage: len(E.gens(algorithm="pari")) # not tested (takes too long) 14 A non-integral example:: @@ -3055,12 +3055,12 @@ def selmer_rank(self, algorithm="pari"): try: return self.__selmer_rank except AttributeError: - if algorithm=="pari": + if algorithm == "pari": ep = self.pari_curve() lower, upper, s, pts = ep.ellrank() tor = self.two_torsion_rank() return upper + tor + s - elif algorithm=="mwrank": + elif algorithm == "mwrank": C = self.mwrank_curve() self.__selmer_rank = C.selmer_rank() return self.__selmer_rank @@ -3110,11 +3110,11 @@ def rank_bound(self, algorithm="pari"): try: return self.__rank_bound except AttributeError: - if algorithm=="pari": + if algorithm == "pari": ep = self.pari_curve() lower, upper, s, pts = ep.ellrank() return upper - elif algorithm=="mwrank": + elif algorithm == "mwrank": C = self.mwrank_curve() self.__rank_bound = C.rank_bound() return self.__rank_bound @@ -4160,22 +4160,22 @@ def reduction(self,p): EXAMPLES:: sage: E = EllipticCurve('389a1') - sage: E.reduction(2) # optional - sage.rings.finite_rings + sage: E.reduction(2) Elliptic Curve defined by y^2 + y = x^3 + x^2 over Finite Field of size 2 - sage: E.reduction(3) # optional - sage.rings.finite_rings + sage: E.reduction(3) Elliptic Curve defined by y^2 + y = x^3 + x^2 + x over Finite Field of size 3 - sage: E.reduction(5) # optional - sage.rings.finite_rings + sage: E.reduction(5) Elliptic Curve defined by y^2 + y = x^3 + x^2 + 3*x over Finite Field of size 5 - sage: E.reduction(38) # optional - sage.rings.finite_rings + sage: E.reduction(38) Traceback (most recent call last): ... AttributeError: p must be prime. - sage: E.reduction(389) # optional - sage.rings.finite_rings + sage: E.reduction(389) Traceback (most recent call last): ... AttributeError: The curve must have good reduction at p. sage: E = EllipticCurve([5^4, 5^6]) - sage: E.reduction(5) # optional - sage.rings.finite_rings + sage: E.reduction(5) Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 """ p = Integer(p) @@ -4513,7 +4513,7 @@ def has_rational_cm(self, field=None): If we extend scalars to a field in which the discriminant is a square, the CM becomes rational:: - sage: E.has_rational_cm(QuadraticField(-3)) # optional - sage.rings.number_field + sage: E.has_rational_cm(QuadraticField(-3)) # needs sage.rings.number_field True sage: E = EllipticCurve(j=8000) @@ -4527,7 +4527,7 @@ def has_rational_cm(self, field=None): Again, we may extend scalars to a field in which the discriminant is a square, where the CM becomes rational:: - sage: E.has_rational_cm(QuadraticField(-2)) # optional - sage.rings.number_field + sage: E.has_rational_cm(QuadraticField(-2)) # needs sage.rings.number_field True The field need not be a number field provided that it is an @@ -4541,7 +4541,7 @@ def has_rational_cm(self, field=None): An error is raised if a field is given which is not an extension of `\QQ`, i.e., not of characteristic `0`:: - sage: E.has_rational_cm(GF(2)) # optional - sage.rings.finite_rings + sage: E.has_rational_cm(GF(2)) Traceback (most recent call last): ... ValueError: Error in has_rational_cm: Finite Field of size 2 @@ -5229,7 +5229,7 @@ def isogeny_graph(self, order=None): 6 Elliptic Curve defined by y^2 + x*y = x^3 - 8125*x - 282568 over Rational Field 7 Elliptic Curve defined by y^2 + x*y = x^3 - 7930*x - 296725 over Rational Field 8 Elliptic Curve defined by y^2 + x*y = x^3 - 130000*x - 18051943 over Rational Field - sage: G.plot(edge_labels=True) + sage: G.plot(edge_labels=True) # needs sage.plot Graphics object consisting of 23 graphics primitives """ return self.isogeny_class(order=order).graph() diff --git a/src/sage/schemes/elliptic_curves/ell_torsion.py b/src/sage/schemes/elliptic_curves/ell_torsion.py index f56c3ee0e6f..9a39ead60e5 100644 --- a/src/sage/schemes/elliptic_curves/ell_torsion.py +++ b/src/sage/schemes/elliptic_curves/ell_torsion.py @@ -100,6 +100,7 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): Examples over other Number Fields:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('11a1') sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) @@ -111,9 +112,9 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): over Number Field in i with defining polynomial x^2 + 1 sage: E = EllipticCurve('11a1') - sage: K. = NumberField(x^2 + 1) - sage: EK = E.change_ring(K) - sage: T = EK.torsion_subgroup() + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: EK = E.change_ring(K) # needs sage.rings.number_field + sage: T = EK.torsion_subgroup() # needs sage.rings.number_field sage: T.ngens() 1 sage: T.gen(0) @@ -121,6 +122,7 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): Note: this class is normally constructed indirectly as follows:: + sage: # needs sage.rings.number_field sage: T = EK.torsion_subgroup(); T Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) @@ -147,20 +149,20 @@ def __init__(self, E): sage: from sage.schemes.elliptic_curves.ell_torsion import EllipticCurveTorsionSubgroup sage: E = EllipticCurve('11a1') sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) - sage: EK = E.change_ring(K) - sage: EllipticCurveTorsionSubgroup(EK) + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: EK = E.change_ring(K) # needs sage.rings.number_field + sage: EllipticCurveTorsionSubgroup(EK) # needs sage.rings.number_field Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in i with defining polynomial x^2 + 1 Note: this class is normally constructed indirectly as follows:: - sage: T = EK.torsion_subgroup(); T + sage: T = EK.torsion_subgroup(); T # needs sage.rings.number_field Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in i with defining polynomial x^2 + 1 - sage: type(T) + sage: type(T) # needs sage.rings.number_field sage: T == loads(dumps(T)) # known bug, see https://github.com/sagemath/sage/issues/11599#comment:7 @@ -219,9 +221,9 @@ def _repr_(self): sage: E = EllipticCurve('11a1') sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) - sage: EK = E.change_ring(K) - sage: T = EK.torsion_subgroup(); T._repr_() + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: EK = E.change_ring(K) # needs sage.rings.number_field + sage: T = EK.torsion_subgroup(); T._repr_() # needs sage.rings.number_field 'Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in i with defining polynomial x^2 + 1' """ return "Torsion Subgroup isomorphic to %s associated to the %s" % (self.short_name(), self.__E) @@ -247,6 +249,7 @@ def curve(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('11a1') sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) @@ -266,6 +269,7 @@ def points(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) sage: E = EllipticCurve(K, [0,0,0,1,0]) @@ -315,6 +319,7 @@ def torsion_bound(E, number_of_places=20): An example over a relative number field (see :trac:`16011`):: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: F. = QuadraticField(5) sage: K. = F.extension(x^2 - 3) @@ -324,6 +329,7 @@ def torsion_bound(E, number_of_places=20): An example of a base-change curve from `\QQ` to a degree 16 field:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.ell_torsion import torsion_bound sage: f = PolynomialRing(QQ,'x')([5643417737593488384,0, ....: -11114515801179776,0,-455989850911004,0,379781901872, diff --git a/src/sage/schemes/elliptic_curves/ell_wp.py b/src/sage/schemes/elliptic_curves/ell_wp.py index 462899d33f2..8785976dec3 100644 --- a/src/sage/schemes/elliptic_curves/ell_wp.py +++ b/src/sage/schemes/elliptic_curves/ell_wp.py @@ -91,34 +91,34 @@ def weierstrass_p(E, prec=20, algorithm=None): sage: E.weierstrass_p(prec=8, algorithm='quadratic') z^-2 + 31/15*z^2 + 2501/756*z^4 + 961/675*z^6 + O(z^8) - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,1]) # optional - sage.rings.finite_rings - sage: E.weierstrass_p(prec=6, algorithm='fast') # optional - sage.rings.finite_rings + sage: k = GF(11) + sage: E = EllipticCurve(k, [1,1]) + sage: E.weierstrass_p(prec=6, algorithm='fast') z^-2 + 2*z^2 + 3*z^4 + O(z^6) - sage: E.weierstrass_p(prec=7, algorithm='fast') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=7, algorithm='fast') Traceback (most recent call last): ... ValueError: for computing the Weierstrass p-function via the fast algorithm, the characteristic (11) of the underlying field must be greater than prec + 4 = 11 - sage: E.weierstrass_p(prec=8) # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=8) z^-2 + 2*z^2 + 3*z^4 + 5*z^6 + O(z^8) - sage: E.weierstrass_p(prec=8, algorithm='quadratic') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=8, algorithm='quadratic') z^-2 + 2*z^2 + 3*z^4 + 5*z^6 + O(z^8) - sage: E.weierstrass_p(prec=8, algorithm='pari') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=8, algorithm='pari') z^-2 + 2*z^2 + 3*z^4 + 5*z^6 + O(z^8) - sage: E.weierstrass_p(prec=9) # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=9) Traceback (most recent call last): ... NotImplementedError: currently no algorithms for computing the Weierstrass p-function for that characteristic / precision pair is implemented. Lower the precision below char(k) - 2 - sage: E.weierstrass_p(prec=9, algorithm="quadratic") # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=9, algorithm="quadratic") Traceback (most recent call last): ... ValueError: for computing the Weierstrass p-function via the quadratic algorithm, the characteristic (11) of the underlying field must be greater than prec + 2 = 11 - sage: E.weierstrass_p(prec=9, algorithm='pari') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=9, algorithm='pari') Traceback (most recent call last): ... ValueError: for computing the Weierstrass p-function via pari, the @@ -126,7 +126,7 @@ def weierstrass_p(E, prec=20, algorithm=None): TESTS:: - sage: E.weierstrass_p(prec=4, algorithm='foo') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=4, algorithm='foo') Traceback (most recent call last): ... ValueError: unknown algorithm for computing the Weierstrass p-function @@ -224,13 +224,13 @@ def compute_wp_quadratic(k, A, B, prec): sage: E.weierstrass_p(prec=10, algorithm='quadratic') z^-2 - 7/5*z^2 + 49/75*z^6 + O(z^10) - sage: E = EllipticCurve(GF(103), [1,2]) # optional - sage.rings.finite_rings - sage: E.weierstrass_p(algorithm='quadratic') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(103), [1,2]) + sage: E.weierstrass_p(algorithm='quadratic') z^-2 + 41*z^2 + 88*z^4 + 11*z^6 + 57*z^8 + 55*z^10 + 73*z^12 + 11*z^14 + 17*z^16 + 50*z^18 + O(z^20) sage: from sage.schemes.elliptic_curves.ell_wp import compute_wp_quadratic - sage: compute_wp_quadratic(E.base_ring(), E.a4(), E.a6(), prec=10) # optional - sage.rings.finite_rings + sage: compute_wp_quadratic(E.base_ring(), E.a4(), E.a6(), prec=10) z^-2 + 41*z^2 + 88*z^4 + 11*z^6 + 57*z^8 + O(z^10) """ m = (prec + 1)//2 @@ -283,8 +283,8 @@ def compute_wp_fast(k, A, B, m): sage: compute_wp_fast(QQ, 1, 8, 7) z^-2 - 1/5*z^2 - 8/7*z^4 + 1/75*z^6 + O(z^7) - sage: k = GF(37) # optional - sage.rings.finite_rings - sage: compute_wp_fast(k, k(1), k(8), 5) # optional - sage.rings.finite_rings + sage: k = GF(37) + sage: compute_wp_fast(k, k(1), k(8), 5) z^-2 + 22*z^2 + 20*z^4 + O(z^5) """ R = PowerSeriesRing(k,'z',default_prec=m+5) @@ -330,15 +330,15 @@ def solve_linear_differential_system(a, b, c, alpha): EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_wp import solve_linear_differential_system - sage: k = GF(17) # optional - sage.rings.finite_rings - sage: R. = PowerSeriesRing(k) # optional - sage.rings.finite_rings - sage: a = 1 + x + O(x^7); b = x + O(x^7); c = 1 + x^3 + O(x^7); alpha = k(3) # optional - sage.rings.finite_rings - sage: f = solve_linear_differential_system(a, b, c, alpha) # optional - sage.rings.finite_rings - sage: f # optional - sage.rings.finite_rings + sage: k = GF(17) + sage: R. = PowerSeriesRing(k) + sage: a = 1 + x + O(x^7); b = x + O(x^7); c = 1 + x^3 + O(x^7); alpha = k(3) + sage: f = solve_linear_differential_system(a, b, c, alpha) + sage: f 3 + x + 15*x^2 + x^3 + 10*x^5 + 3*x^6 + 13*x^7 + O(x^8) - sage: a*f.derivative() + b*f - c # optional - sage.rings.finite_rings + sage: a*f.derivative() + b*f - c O(x^7) - sage: f(0) == alpha # optional - sage.rings.finite_rings + sage: f(0) == alpha True """ a_recip = 1 / a diff --git a/src/sage/schemes/elliptic_curves/formal_group.py b/src/sage/schemes/elliptic_curves/formal_group.py index 63ce58c74c6..dbd2db5f778 100644 --- a/src/sage/schemes/elliptic_curves/formal_group.py +++ b/src/sage/schemes/elliptic_curves/formal_group.py @@ -488,26 +488,26 @@ def group_law(self, prec=10): sage: ehat.group_law(5) t1 + t2 - t1*t2 - 2*t1^3*t2 - 3*t1^2*t2^2 - 2*t1*t2^3 + O(t1, t2)^5 - sage: e = EllipticCurve(GF(7), [3, 4]) # optional - sage.rings.finite_rings - sage: ehat = e.formal() # optional - sage.rings.finite_rings - sage: ehat.group_law(3) # optional - sage.rings.finite_rings + sage: e = EllipticCurve(GF(7), [3, 4]) + sage: ehat = e.formal() + sage: ehat.group_law(3) t1 + t2 + O(t1, t2)^3 - sage: F = ehat.group_law(7); F # optional - sage.rings.finite_rings + sage: F = ehat.group_law(7); F t1 + t2 + t1^4*t2 + 2*t1^3*t2^2 + 2*t1^2*t2^3 + t1*t2^4 + O(t1, t2)^7 TESTS:: - sage: R. = GF(7)[[]] # optional - sage.rings.finite_rings - sage: F(x, ehat.inverse()(x)) # optional - sage.rings.finite_rings + sage: R. = GF(7)[[]] + sage: F(x, ehat.inverse()(x)) 0 + O(x, y, z)^7 - sage: F(x, y) == F(y, x) # optional - sage.rings.finite_rings + sage: F(x, y) == F(y, x) True - sage: F(x, F(y, z)) == F(F(x, y), z) # optional - sage.rings.finite_rings + sage: F(x, F(y, z)) == F(F(x, y), z) True Let's ensure caching with changed precision is working:: - sage: e.formal_group().group_law(4) # optional - sage.rings.finite_rings + sage: e.formal_group().group_law(4) t1 + t2 + O(t1, t2)^4 Test for :trac:`9646`:: @@ -625,12 +625,12 @@ def mult_by_n(self, n, prec=10): TESTS:: - sage: F = EllipticCurve(GF(17), [1, 1]).formal_group() # optional - sage.rings.finite_rings - sage: F.mult_by_n(10, 50) # long time (13s on sage.math, 2011) # optional - sage.rings.finite_rings + sage: F = EllipticCurve(GF(17), [1, 1]).formal_group() + sage: F.mult_by_n(10, 50) # long time 10*t + 5*t^5 + 7*t^7 + 13*t^9 + t^11 + 16*t^13 + 13*t^15 + 9*t^17 + 16*t^19 + 15*t^23 + 15*t^25 + 2*t^27 + 10*t^29 + 8*t^31 + 15*t^33 + 6*t^35 + 7*t^37 + 9*t^39 + 10*t^41 + 5*t^43 + 4*t^45 + 6*t^47 + 13*t^49 + O(t^50) - sage: F = EllipticCurve(GF(101), [1, 1]).formal_group() # optional - sage.rings.finite_rings - sage: F.mult_by_n(100, 20) # optional - sage.rings.finite_rings + sage: F = EllipticCurve(GF(101), [1, 1]).formal_group() + sage: F.mult_by_n(100, 20) 100*t + O(t^20) sage: P. = PolynomialRing(ZZ, 5) diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py index 06fa51c9050..e257b511371 100644 --- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py +++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.number_field r""" Galois representations for elliptic curves over number fields diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py index 34418ad1025..198ceed7218 100644 --- a/src/sage/schemes/elliptic_curves/gp_simon.py +++ b/src/sage/schemes/elliptic_curves/gp_simon.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari """ Denis Simon's PARI scripts """ @@ -54,37 +55,41 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None, EXAMPLES:: sage: import sage.schemes.elliptic_curves.gp_simon - sage: E=EllipticCurve('389a1') + sage: E = EllipticCurve('389a1') sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E) (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)]) TESTS:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('37a1').change_ring(QuadraticField(-11,'x')) sage: E.simon_two_descent() (1, 1, [(0 : 0 : 1)]) An example with an elliptic curve defined over a relative number field:: + sage: # needs sage.rings.number_field sage: F. = QuadraticField(29) sage: x = QQ['x'].gen() sage: K. = F.extension(x^2-1/2*a+1/2) - sage: E = EllipticCurve(K,[1, 0, 5/2*a + 27/2, 0, 0]) # long time (about 3 s) + sage: E = EllipticCurve(K,[1, 0, 5/2*a + 27/2, 0, 0]) # long time (about 3 s) sage: E.simon_two_descent(lim1=2, limtriv=3) (1, 1, ...) Check that :trac:`16022` is fixed:: + sage: # needs sage.rings.number_field sage: K. = NumberField(x^4 + x^2 - 7) sage: E = EllipticCurve(K, [1, 0, 5*y^2 + 16, 0, 0]) - sage: E.simon_two_descent(lim1=2, limtriv=3) # long time (about 3 s) + sage: E.simon_two_descent(lim1=2, limtriv=3) # long time (about 3 s) (1, 1, ...) An example that checks that :trac:`9322` is fixed (it should take less than a second to run):: - sage: K. = NumberField(x^2-x-232) - sage: E = EllipticCurve([2-w,18+3*w,209+9*w,2581+175*w,852-55*w]) - sage: E.simon_two_descent() # long time + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - x - 232) + sage: E = EllipticCurve([2 - w, 18 + 3*w, 209 + 9*w, 2581 + 175*w, 852 - 55*w]) + sage: E.simon_two_descent() # long time (0, 2, []) """ init() diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py index 75a356289f2..793c1652e53 100644 --- a/src/sage/schemes/elliptic_curves/heegner.py +++ b/src/sage/schemes/elliptic_curves/heegner.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Heegner points on elliptic curves over the rational numbers @@ -2654,9 +2654,9 @@ def plot(self, *args, **kwds): EXAMPLES:: - sage: heegner_points(389,-7,5).plot(pointsize=50, rgbcolor='red') # optional - sage.plot + sage: heegner_points(389,-7,5).plot(pointsize=50, rgbcolor='red') # needs sage.plot Graphics object consisting of 12 graphics primitives - sage: heegner_points(53,-7,15).plot(pointsize=50, rgbcolor='purple') # optional - sage.plot + sage: heegner_points(53,-7,15).plot(pointsize=50, rgbcolor='purple') # needs sage.plot Graphics object consisting of 48 graphics primitives """ return sum(z.plot(*args, **kwds) for z in self) @@ -4285,7 +4285,7 @@ def plot(self, prec=53, *args, **kwds): EXAMPLES:: sage: E = EllipticCurve('37a'); P = E.heegner_point(-11).kolyvagin_point() - sage: P.plot(prec=30, pointsize=50, rgbcolor='red') + E.plot() # optional - sage.plot + sage: P.plot(prec=30, pointsize=50, rgbcolor='red') + E.plot() # needs sage.plot Graphics object consisting of 3 graphics primitives """ if self.conductor() != 1: diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py index 506dc229f1d..97020957574 100644 --- a/src/sage/schemes/elliptic_curves/height.py +++ b/src/sage/schemes/elliptic_curves/height.py @@ -85,7 +85,7 @@ def __init__(self, endpoints): sage: from sage.schemes.elliptic_curves.height import UnionOfIntervals sage: UnionOfIntervals([0, 1]) ([0, 1]) - sage: UnionOfIntervals([-infinity, pi, 17, infinity]) # optional - sage.symbolic + sage: UnionOfIntervals([-infinity, pi, 17, infinity]) # needs sage.symbolic ([-Infinity, pi] U [17, +Infinity]) sage: UnionOfIntervals([]) () @@ -128,7 +128,7 @@ def intervals(self): sage: from sage.schemes.elliptic_curves.height import UnionOfIntervals sage: UnionOfIntervals(list(range(10))).intervals() [(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)] - sage: UnionOfIntervals([-infinity, pi, 17, infinity]).intervals() + sage: UnionOfIntervals([-infinity, pi, 17, infinity]).intervals() # needs sage.symbolic [(-Infinity, pi), (17, +Infinity)] """ return list(zip(self._endpoints[::2], self._endpoints[1::2])) @@ -165,7 +165,7 @@ def __add__(left, right): ([0, 1/2] U [2, +Infinity]) sage: A + 1 ([1, 3/2] U [3, +Infinity]) - sage: pi + A + sage: pi + A # needs sage.symbolic ([pi, pi + 1/2] U [pi + 2, +Infinity]) sage: A + UnionOfIntervals([-infinity, -1]) ([-Infinity, -1] U [0, 1/2] U [2, +Infinity]) @@ -209,7 +209,7 @@ def __rmul__(self, other): sage: from sage.schemes.elliptic_curves.height import UnionOfIntervals sage: A = UnionOfIntervals([0, 1/2, 2, infinity]); A ([0, 1/2] U [2, +Infinity]) - sage: pi * A + sage: pi * A # needs sage.symbolic ([0, 1/2*pi] U [2*pi, +Infinity]) """ return self * other @@ -786,9 +786,9 @@ def __init__(self, E): An example over a number field:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,i,0,i,i]) # optional - sage.rings.number_field - sage: EllipticCurveCanonicalHeight(E) # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve([0,i,0,i,i]) # needs sage.rings.number_field + sage: EllipticCurveCanonicalHeight(E) # needs sage.rings.number_field EllipticCurveCanonicalHeight object associated to Elliptic Curve defined by y^2 = x^3 + i*x^2 + i*x + i over Number Field in i with defining polynomial x^2 + 1 with i = 1*I @@ -798,8 +798,8 @@ def __init__(self, E): The base field must be a number field (or `\QQ`):: sage: from sage.schemes.elliptic_curves.height import EllipticCurveCanonicalHeight - sage: E = EllipticCurve(GF(7), [0,0,0,0,1]) # optional - sage.rings.finite_rings - sage: EllipticCurveCanonicalHeight(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,0,1]) + sage: EllipticCurveCanonicalHeight(E) Traceback (most recent call last): ... ValueError: EllipticCurveCanonicalHeight class can only be created @@ -884,12 +884,13 @@ def __call__(self, P): Over a number field other than `\QQ`:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,-27]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve(K, [0,0,0,1,-27]) + sage: H = E.height_function() + sage: H.base_field() Number Field in i with defining polynomial x^2 + 1 with i = 1*I - sage: H((1, 5*i)) # optional - sage.rings.number_field + sage: H((1, 5*i)) 1.22257115164148 """ return self.E(P).height() @@ -913,16 +914,17 @@ def alpha(self, v, tol=0.01): Example 1 from [CPS2006]_:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: alpha = H.alpha(K.places()[0]) # optional - sage.rings.number_field - sage: alpha # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) + sage: H = E.height_function() + sage: alpha = H.alpha(K.places()[0]) + sage: alpha 1.12272013439355 Compare with `\log(\epsilon_v)=0.344562...` in [CPS2006]_:: - sage: 3*alpha.log() # optional - sage.rings.number_field + sage: 3*alpha.log() # needs sage.rings.number_field 0.347263296676126 """ from sage.rings.polynomial.polynomial_ring import polygen @@ -984,29 +986,30 @@ def e_p(self, p): EXAMPLES:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.e_p(K.prime_above(2)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) + sage: H = E.height_function() + sage: H.e_p(K.prime_above(2)) 2 - sage: H.e_p(K.prime_above(3)) # optional - sage.rings.number_field + sage: H.e_p(K.prime_above(3)) 10 - sage: H.e_p(K.prime_above(5)) # optional - sage.rings.number_field + sage: H.e_p(K.prime_above(5)) 9 - sage: E.conductor().norm().factor() # optional - sage.rings.number_field + sage: E.conductor().norm().factor() 2^10 * 20921 - sage: p1, p2 = K.primes_above(20921) # optional - sage.rings.number_field - sage: E.local_data(p1) # optional - sage.rings.number_field + sage: p1, p2 = K.primes_above(20921) + sage: E.local_data(p1) Local data at Fractional ideal (-40*i + 139): Reduction type: bad split multiplicative ... - sage: H.e_p(p1) # optional - sage.rings.number_field + sage: H.e_p(p1) 20920 - sage: E.local_data(p2) # optional - sage.rings.number_field + sage: E.local_data(p2) Local data at Fractional ideal (40*i + 139): Reduction type: good ... - sage: H.e_p(p2) # optional - sage.rings.number_field + sage: H.e_p(p2) 20815 """ kp = self.K.residue_field(p) @@ -1036,10 +1039,11 @@ def DE(self, n): EXAMPLES:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1+5*i, 3+i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: [H.DE(n) for n in srange(1,6)] # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 1+5*i, 3+i]) + sage: H = E.height_function() + sage: [H.DE(n) for n in srange(1,6)] [0, 2*log(5) + 2*log(2), 0, 2*log(13) + 2*log(5) + 4*log(2), 0] """ s = 0 @@ -1064,10 +1068,10 @@ def ME(self): EXAMPLES:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1+5*i, 3+i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.ME() # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve([0, 0, 0, 1+5*i, 3+i]) # needs sage.rings.number_field + sage: H = E.height_function() # needs sage.rings.number_field + sage: H.ME() # needs sage.rings.number_field 1 sage: E = EllipticCurve([0,0,0,0,1]) sage: E.height_function().ME() @@ -1103,13 +1107,13 @@ def B(self, n, mu): Example 10.2 from [Tho2010]_:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 1-i, i, -i, 0]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve([0, 1-i, i, -i, 0]) # needs sage.rings.number_field + sage: H = E.height_function() # needs sage.rings.number_field In [Tho2010]_ the value is given as 0.772:: - sage: RealField(12)( H.B(5, 0.01) ) # optional - sage.rings.number_field + sage: RealField(12)( H.B(5, 0.01) ) # needs sage.rings.number_field 0.777 """ K = self.K @@ -1162,21 +1166,22 @@ def psi(self, xi, v): An example over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: P = E.lift_x(1/3*a^2 + a + 5/3) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(v) # optional - sage.rings.number_field - sage: L(P) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: P = E.lift_x(1/3*a^2 + a + 5/3) + sage: v = K.real_places()[0] + sage: L = E.period_lattice(v) + sage: L(P) 3.51086196882538 - sage: L(P) / L.real_period() # optional - sage.rings.number_field + sage: L(P) / L.real_period() 0.867385122699931 - sage: xP = v(P.xy()[0]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.psi(xP, v) # optional - sage.rings.number_field + sage: xP = v(P.xy()[0]) + sage: H = E.height_function() + sage: H.psi(xP, v) 0.867385122699931 - sage: H.psi(1.23, v) # optional - sage.rings.number_field + sage: H.psi(1.23, v) 0.785854718241495 """ if xi > 1e9: @@ -1218,12 +1223,13 @@ def S(self, xi1, xi2, v): An example over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.S(9, 10, v) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.real_places()[0] + sage: H = E.height_function() + sage: H.S(9, 10, v) ([0.078119444725347..., 0.082342373201640...] U [0.91765762679836..., 0.92188055527465...]) """ L = self.E.period_lattice(v) @@ -1270,15 +1276,16 @@ def Sn(self, xi1, xi2, n, v): An example over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.S(2, 3, v), H.Sn(2, 3, 1, v) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.real_places()[0] + sage: H = E.height_function() + sage: H.S(2, 3, v), H.Sn(2, 3, 1, v) (([0.142172065860075, 0.172845716928584] U [0.827154283071416, 0.857827934139925]), ([0.142172065860075, 0.172845716928584] U [0.827154283071416, 0.857827934139925])) - sage: H.Sn(2, 3, 6, v) # optional - sage.rings.number_field + sage: H.Sn(2, 3, 6, v) ([0.0236953443100124, 0.0288076194880974] U [0.137859047178569, 0.142971322356654] U [0.190362010976679, 0.195474286154764] U [0.304525713845236, 0.309637989023321] U [0.357028677643346, 0.362140952821431] U [0.471192380511903, 0.476304655689988] U [0.523695344310012, 0.528807619488097] U [0.637859047178569, 0.642971322356654] U [0.690362010976679, 0.695474286154764] U [0.804525713845236, 0.809637989023321] U [0.857028677643346, 0.862140952821431] U [0.971192380511903, 0.976304655689988]) """ SS = 1/ZZ(n) * self.S(xi1, xi2, v) @@ -1324,20 +1331,21 @@ def real_intersection_is_empty(self, Bk, v): An example over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.real_places()[0] + sage: H = E.height_function() The following two lines prove that the heights of non-torsion points on `E` with everywhere good reduction have canonical height strictly greater than 0.07, but fail to prove the same for 0.08:: - sage: H.real_intersection_is_empty([H.B(n,0.07) for n in srange(1,5)], v) # long time (3.3s) # optional - sage.rings.number_field + sage: H.real_intersection_is_empty([H.B(n,0.07) for n in srange(1,5)], v) # long time, needs sage.rings.number_field True - sage: H.real_intersection_is_empty([H.B(n,0.08) for n in srange(1,5)], v) # optional - sage.rings.number_field + sage: H.real_intersection_is_empty([H.B(n,0.08) for n in srange(1,5)], v) # needs sage.rings.number_field False """ return UnionOfIntervals.intersection([self.Sn(-B, B, k+1, v) for k,B in enumerate(Bk)]).is_empty() @@ -1396,10 +1404,11 @@ def wp_c(self, v): sage: H.wp_c(QQ.places()[0]) 2.68744508779950 - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.wp_c(K.places()[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) + sage: H = E.height_function() + sage: H.wp_c(K.places()[0]) 2.66213425640096 """ # Note that we normalise w1, w2 differently from [Tho2010]_! @@ -1675,11 +1684,12 @@ def complex_intersection_is_empty(self, Bk, v, verbose=False, use_half=True): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.complex_embeddings()[0] # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.complex_embeddings()[0] + sage: H = E.height_function() The following two lines prove that the heights of non-torsion points on `E` with everywhere good reduction have canonical @@ -1687,18 +1697,18 @@ def complex_intersection_is_empty(self, Bk, v, verbose=False, use_half=True): for 0.03. For the first proof, using only `n=1,2,3` is not sufficient:: - sage: H.complex_intersection_is_empty([H.B(n,0.02) for n in [1,2,3]], v) # long time (~6s) # optional - sage.rings.number_field + sage: H.complex_intersection_is_empty([H.B(n,0.02) for n in [1,2,3]], v) # long time, needs sage.rings.number_field False - sage: H.complex_intersection_is_empty([H.B(n,0.02) for n in [1,2,3,4]], v) # optional - sage.rings.number_field + sage: H.complex_intersection_is_empty([H.B(n,0.02) for n in [1,2,3,4]], v) # needs sage.rings.number_field True - sage: H.complex_intersection_is_empty([H.B(n,0.03) for n in [1,2,3,4]], v) # long time (4s) # optional - sage.rings.number_field + sage: H.complex_intersection_is_empty([H.B(n,0.03) for n in [1,2,3,4]], v) # long time, needs sage.rings.number_field False Using `n\le6` enables us to prove the lower bound 0.03. Note that it takes longer when the result is ``False`` than when it is ``True``:: - sage: H.complex_intersection_is_empty([H.B(n,0.03) for n in [1..6]], v) # optional - sage.rings.number_field + sage: H.complex_intersection_is_empty([H.B(n,0.03) for n in [1..6]], v) # needs sage.rings.number_field True """ from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion @@ -1795,28 +1805,28 @@ def test_mu(self, mu, N, verbose=True): EXAMPLES:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: E = EllipticCurve([0,0,0,0,a]) # needs sage.rings.number_field + sage: H = E.height_function() # needs sage.rings.number_field This curve does have a point of good reduction whose canonical point is approximately 1.68:: - sage: P = E.gens(lim3=5)[0]; P # optional - sage.rings.number_field + sage: P = E.gens(lim3=5)[0]; P # needs sage.rings.number_field (1/3*a^2 + a + 5/3 : -2*a^2 - 4/3*a - 5/3 : 1) - sage: P.height() # optional - sage.rings.number_field + sage: P.height() # needs sage.rings.number_field 1.68038085233673 - sage: P.has_good_reduction() # optional - sage.rings.number_field + sage: P.has_good_reduction() # needs sage.rings.number_field True Using `N=5` we can prove that 0.1 is a lower bound (in fact we only need `N=2`), but not that 0.2 is:: - sage: H.test_mu(0.1, 5) # optional - sage.rings.number_field + sage: H.test_mu(0.1, 5) # needs sage.rings.number_field B_1(0.100000000000000) = 1.51580969677387 B_2(0.100000000000000) = 0.932072561526720 True - sage: H.test_mu(0.2, 5) # optional - sage.rings.number_field + sage: H.test_mu(0.2, 5) # needs sage.rings.number_field B_1(0.200000000000000) = 2.04612906979932 B_2(0.200000000000000) = 3.09458988474327 B_3(0.200000000000000) = 27.6251108409484 @@ -1828,11 +1838,11 @@ def test_mu(self, mu, N, verbose=True): either primitive or divisible by either 2 or 3. In fact it is primitive:: - sage: (P.height()/0.1).sqrt() # optional - sage.rings.number_field + sage: (P.height()/0.1).sqrt() # needs sage.rings.number_field 4.09924487233530 - sage: P.division_points(2) # optional - sage.rings.number_field + sage: P.division_points(2) # needs sage.rings.number_field [] - sage: P.division_points(3) # optional - sage.rings.number_field + sage: P.division_points(3) # needs sage.rings.number_field [] """ # Compute the list of values `B_n(\mu)` for n in 1..N. If any @@ -1903,46 +1913,50 @@ def min_gr(self, tol, n_max, verbose=False): Example 10.1 from [Tho2010]_ (where a lower bound of 0.18 was given):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 91 - 26*i, -144 - 323*i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min_gr(0.1, 4) # long time (8.1s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 91 - 26*i, -144 - 323*i]) + sage: H = E.height_function() + sage: H.min_gr(0.1, 4) # long time 0.1621049443313762 Example 10.2 from [Tho2010]_:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 1 - i, i, -i, 0]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min_gr(0.01, 5) # long time # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 1 - i, i, -i, 0]) + sage: H = E.height_function() + sage: H.min_gr(0.01, 5) # long time 0.020153685521979152 In this example the point `P=(0,0)` has height 0.023 so our lower bound is quite good:: - sage: P = E((0,0)) # optional - sage.rings.number_field - sage: P.has_good_reduction() # optional - sage.rings.number_field + sage: P = E((0,0)) # needs sage.rings.number_field + sage: P.has_good_reduction() # needs sage.rings.number_field True - sage: P.height() # optional - sage.rings.number_field + sage: P.height() # needs sage.rings.number_field 0.0230242154471211 Example 10.3 from [Tho2010]_ (where the same bound of 0.25 is given):: - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, -3*a - a^2, a^2]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min_gr(0.1, 5) # long time (7.2s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0, 0, 0, -3*a - a^2, a^2]) + sage: H = E.height_function() + sage: H.min_gr(0.1, 5) # long time 0.25 TESTS: This example from the LMFDB gave problems before the fix in :trac:`8829`:: - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: E = EllipticCurve([phi + 1, -phi + 1, 1, 20*phi - 39, 196*phi + 237]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min_gr(.1, 5, verbose=True) # long time (~22s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) + sage: E = EllipticCurve([phi + 1, -phi + 1, 1, 20*phi - 39, 196*phi + 237]) + sage: H = E.height_function() + sage: H.min_gr(.1, 5, verbose=True) # long time B_1(1) = 1540.199246369678 ... halving mu to 0.25 and increasing n_max to 6 @@ -2024,34 +2038,37 @@ def min(self, tol, n_max, verbose=False): Example 10.1 from [Tho2010]_ (where a lower bound of 0.18 was given):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 91 - 26*i, -144 - 323*i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min(0.1, 4) # long time (8.1s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 91 - 26*i, -144 - 323*i]) + sage: H = E.height_function() + sage: H.min(0.1, 4) # long time 0.1621049443313762 Example 10.2 from [Tho2010]_:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 1 - i, i, -i, 0]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min(0.01, 5) # long time (4s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 1 - i, i, -i, 0]) + sage: H = E.height_function() + sage: H.min(0.01, 5) # long time 0.020153685521979152 In this example the point `P=(0,0)` has height 0.023 so our lower bound is quite good:: - sage: P = E((0,0)) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: P = E((0,0)) # needs sage.rings.number_field + sage: P.height() # needs sage.rings.number_field 0.0230242154471211 Example 10.3 from [Tho2010]_ (where the same bound of 0.0625 is given):: - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, -3*a - a^2, a^2]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min(0.1, 5) # long time (7s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0, 0, 0, -3*a - a^2, a^2]) + sage: H = E.height_function() + sage: H.min(0.1, 5) # long time 0.0625 More examples over `\QQ`:: @@ -2065,8 +2082,8 @@ def min(self, tol, n_max, verbose=False): After base change the lower bound can decrease:: - sage: K. = QuadraticField(-5) # optional - sage.rings.number_field - sage: E.change_ring(K).height_function().min(0.5, 10) # long time (8s) # optional - sage.rings.number_field + sage: K. = QuadraticField(-5) # needs sage.rings.number_field + sage: E.change_ring(K).height_function().min(0.5, 10) # long time, needs sage.rings.number_field 0.04419417382415922 sage: E = EllipticCurve('389a') diff --git a/src/sage/schemes/elliptic_curves/hom_composite.py b/src/sage/schemes/elliptic_curves/hom_composite.py index 832fdd036dc..e82cc6d226d 100644 --- a/src/sage/schemes/elliptic_curves/hom_composite.py +++ b/src/sage/schemes/elliptic_curves/hom_composite.py @@ -13,15 +13,16 @@ straightforward :class:`EllipticCurveIsogeny` implementation, but decomposing into prime steps is exponentially faster:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite sage: p = 3 * 2^143 - 1 - sage: GF(p^2).inject_variables() # optional - sage.rings.finite_rings + sage: GF(p^2).inject_variables() Defining z2 - sage: E = EllipticCurve(GF(p^2), [1,0]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(31415926535897932384626433832795028841971 - z2) # optional - sage.rings.finite_rings - sage: P.order().factor() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(p^2), [1,0]) + sage: P = E.lift_x(31415926535897932384626433832795028841971 - z2) + sage: P.order().factor() 2^143 - sage: EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings + sage: EllipticCurveHom_composite(E, P) Composite morphism of degree 11150372599265311570767859136324180752990208 = 2^143: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 33451117797795934712303577408972542258970623^2 @@ -33,40 +34,41 @@ is identical to :class:`EllipticCurveIsogeny` and other instantiations of :class:`EllipticCurveHom`:: - sage: E = EllipticCurve(GF(419), [0,1]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(33); P.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [0,1]) + sage: P = E.lift_x(33); P.order() 35 - sage: psi = EllipticCurveHom_composite(E, P); psi # optional - sage.rings.finite_rings + sage: psi = EllipticCurveHom_composite(E, P); psi Composite morphism of degree 35 = 5*7: From: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 419 To: Elliptic Curve defined by y^2 = x^3 + 101*x + 285 over Finite Field of size 419 - sage: psi(E.lift_x(11)) # optional - sage.rings.finite_rings + sage: psi(E.lift_x(11)) (352 : 346 : 1) - sage: psi.rational_maps() # optional - sage.rings.finite_rings + sage: psi.rational_maps() ((x^35 + 162*x^34 + 186*x^33 + 92*x^32 - ... + 44*x^3 + 190*x^2 + 80*x - 72)/(x^34 + 162*x^33 - 129*x^32 + 41*x^31 + ... + 66*x^3 - 191*x^2 + 119*x + 21), (x^51*y - 176*x^50*y + 115*x^49*y - 120*x^48*y + ... + 72*x^3*y + 129*x^2*y + 163*x*y + 178*y)/(x^51 - 176*x^50 + 11*x^49 + 26*x^48 - ... - 77*x^3 + 185*x^2 + 169*x - 128)) - sage: psi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: psi.kernel_polynomial() x^17 + 81*x^16 + 7*x^15 + 82*x^14 + 49*x^13 + 68*x^12 + 109*x^11 + 326*x^10 + 117*x^9 + 136*x^8 + 111*x^7 + 292*x^6 + 55*x^5 + 389*x^4 + 175*x^3 + 43*x^2 + 149*x + 373 - sage: psi.dual() # optional - sage.rings.finite_rings + sage: psi.dual() Composite morphism of degree 35 = 7*5: From: Elliptic Curve defined by y^2 = x^3 + 101*x + 285 over Finite Field of size 419 To: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 419 - sage: psi.formal() # optional - sage.rings.finite_rings + sage: psi.formal() t + 211*t^5 + 417*t^7 + 159*t^9 + 360*t^11 + 259*t^13 + 224*t^15 + 296*t^17 + 139*t^19 + 222*t^21 + O(t^23) Equality is decided correctly (and, in some cases, much faster than comparing :meth:`EllipticCurveHom.rational_maps`) even when distinct factorizations of the same isogeny are compared:: - sage: psi == EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings + sage: psi == EllipticCurveIsogeny(E, P) # needs sage.rings.finite_rings True We can easily obtain the individual factors of the composite map:: - sage: psi.factors() # optional - sage.rings.finite_rings + sage: psi.factors() # needs sage.rings.finite_rings (Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 419 to Elliptic Curve defined by y^2 = x^3 + 140*x + 214 over Finite Field of size 419, @@ -100,17 +102,18 @@ def _eval_factored_isogeny(phis, P): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves import hom_composite - sage: E = EllipticCurve(GF(419), [1,0]) # optional - sage.rings.finite_rings - sage: Q = E(21, 8) # optional - sage.rings.finite_rings - sage: phis = [] # optional - sage.rings.finite_rings - sage: while len(phis) < 10: # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [1,0]) + sage: Q = E(21, 8) + sage: phis = [] + sage: while len(phis) < 10: ....: P = list(sorted(E(0).division_points(7)))[1] ....: phis.append(E.isogeny(P)) ....: E = phis[-1].codomain() - sage: R = hom_composite._eval_factored_isogeny(phis, Q); R # optional - sage.rings.finite_rings + sage: R = hom_composite._eval_factored_isogeny(phis, Q); R (290 : 183 : 1) - sage: R in E # optional - sage.rings.finite_rings + sage: R in E True """ for phi in phis: @@ -164,32 +167,34 @@ def _compute_factored_isogeny_prime_power(P, l, n, split=.8): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves import hom_composite - sage: E = EllipticCurve(GF(8191), [1,0]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: (l,n), = P.order().factor() # optional - sage.rings.finite_rings - sage: phis = hom_composite._compute_factored_isogeny_prime_power(P, l, n) # optional - sage.rings.finite_rings - sage: hom_composite._eval_factored_isogeny(phis, P) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(8191), [1,0]) + sage: P = E.random_point() + sage: (l,n), = P.order().factor() + sage: phis = hom_composite._compute_factored_isogeny_prime_power(P, l, n) + sage: hom_composite._eval_factored_isogeny(phis, P) (0 : 1 : 0) - sage: [phi.degree() for phi in phis] == [l]*n # optional - sage.rings.finite_rings + sage: [phi.degree() for phi in phis] == [l]*n True All choices of ``split`` produce the same result, albeit not equally fast:: - sage: E = EllipticCurve(GF(2^127 - 1), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: (l,n), = P.order().factor() # optional - sage.rings.finite_rings - sage: phis = hom_composite._compute_factored_isogeny_prime_power(P,l,n) # optional - sage.rings.finite_rings - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^127 - 1), [1,0]) + sage: P, = E.gens() + sage: (l,n), = P.order().factor() + sage: phis = hom_composite._compute_factored_isogeny_prime_power(P,l,n) + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0) True - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.1) # optional - sage.rings.finite_rings + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.1) True - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.5) # optional - sage.rings.finite_rings + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.5) True - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.9) # optional - sage.rings.finite_rings + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.9) True - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=1) # optional - sage.rings.finite_rings + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=1) True """ def rec(Q, k): @@ -222,13 +227,14 @@ def _compute_factored_isogeny_single_generator(P): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves import hom_composite - sage: E = EllipticCurve(GF(419), [1,0]) # optional - sage.rings.finite_rings - sage: P = E(42, 321) # optional - sage.rings.finite_rings - sage: phis = hom_composite._compute_factored_isogeny_single_generator(P) # optional - sage.rings.finite_rings - sage: list(sorted(phi.degree() for phi in phis)) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [1,0]) + sage: P = E(42, 321) + sage: phis = hom_composite._compute_factored_isogeny_single_generator(P) + sage: list(sorted(phi.degree() for phi in phis)) [2, 2, 3, 5, 7] - sage: hom_composite._eval_factored_isogeny(phis, P) # optional - sage.rings.finite_rings + sage: hom_composite._eval_factored_isogeny(phis, P) (0 : 1 : 0) """ phis = [] @@ -249,13 +255,14 @@ def _compute_factored_isogeny(kernel): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves import hom_composite - sage: E = EllipticCurve(GF(419), [-1,0]) # optional - sage.rings.finite_rings - sage: Ps = [E(41,99), E(41,-99), E(51,14), E(21,21), E(33,17)] # optional - sage.rings.finite_rings - sage: phis = hom_composite._compute_factored_isogeny(Ps) # optional - sage.rings.finite_rings - sage: [phi.degree() for phi in phis] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [-1,0]) + sage: Ps = [E(41,99), E(41,-99), E(51,14), E(21,21), E(33,17)] + sage: phis = hom_composite._compute_factored_isogeny(Ps) + sage: [phi.degree() for phi in phis] [2, 3, 5, 7, 2] - sage: {hom_composite._eval_factored_isogeny(phis, P) for P in Ps} # optional - sage.rings.finite_rings + sage: {hom_composite._eval_factored_isogeny(phis, P) for P in Ps} {(0 : 1 : 0)} """ phis = [] @@ -285,8 +292,8 @@ def __init__(self, E, kernel, codomain=None, model=None): EXAMPLES:: sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(419), [1,0]) # optional - sage.rings.finite_rings - sage: EllipticCurveHom_composite(E, E.lift_x(23)) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [1,0]) # needs sage.rings.finite_rings + sage: EllipticCurveHom_composite(E, E.lift_x(23)) # needs sage.rings.finite_rings Composite morphism of degree 105 = 3*5*7: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 419 @@ -295,14 +302,15 @@ def __init__(self, E, kernel, codomain=None, model=None): The given kernel generators need not be independent:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - x - 5) # optional - sage.rings.number_field - sage: E = EllipticCurve('210.b6').change_ring(K) # optional - sage.rings.number_field - sage: E.torsion_subgroup() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 5) + sage: E = EllipticCurve('210.b6').change_ring(K) + sage: E.torsion_subgroup() Torsion Subgroup isomorphic to Z/12 + Z/2 associated to the Elliptic Curve defined by y^2 + x*y + y = x^3 + (-578)*x + 2756 over Number Field in a with defining polynomial x^2 - x - 5 - sage: EllipticCurveHom_composite(E, E.torsion_points()) # optional - sage.rings.number_field + sage: EllipticCurveHom_composite(E, E.torsion_points()) Composite morphism of degree 24 = 2^3*3: From: Elliptic Curve defined by y^2 + x*y + y = x^3 + (-578)*x + 2756 over Number Field in a with defining polynomial x^2 - x - 5 @@ -312,27 +320,28 @@ def __init__(self, E, kernel, codomain=None, model=None): TESTS:: - sage: E = EllipticCurve(GF(19), [1,0]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: psi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: psi # random # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,0]) + sage: P = E.random_point() + sage: psi = EllipticCurveHom_composite(E, P) + sage: psi # random Composite morphism of degree 10 = 2*5: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 19 To: Elliptic Curve defined by y^2 = x^3 + 14*x over Finite Field of size 19 :: - sage: EllipticCurveHom_composite(E, E.lift_x(3), codomain=E) # optional - sage.rings.finite_rings + sage: EllipticCurveHom_composite(E, E.lift_x(3), codomain=E) Composite morphism of degree 20 = 2^2*5: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 19 To: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 19 :: - sage: E = EllipticCurve(GF((2^127-1)^2), [1,0]) # optional - sage.rings.finite_rings - sage: K = 2^30 * E.random_point() # optional - sage.rings.finite_rings - sage: psi = EllipticCurveHom_composite(E, K, model='montgomery') # optional - sage.rings.finite_rings - sage: psi.codomain().a_invariants() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF((2^127-1)^2), [1,0]) + sage: K = 2^30 * E.random_point() + sage: psi = EllipticCurveHom_composite(E, K, model='montgomery') + sage: psi.codomain().a_invariants() (0, ..., 0, 1, 0) """ if not isinstance(E, EllipticCurve_generic): @@ -416,11 +425,11 @@ def from_factors(cls, maps, E=None, strict=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(43), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: psi = EllipticCurveHom_composite.from_factors(phi.factors()) # optional - sage.rings.finite_rings - sage: psi == phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [1,0]) + sage: P, = E.gens() + sage: phi = EllipticCurveHom_composite(E, P) + sage: psi = EllipticCurveHom_composite.from_factors(phi.factors()) + sage: psi == phi True TESTS:: @@ -431,10 +440,11 @@ def from_factors(cls, maps, E=None, strict=True): :: - sage: E = EllipticCurve(GF(419), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: EllipticCurveHom_composite.from_factors(phi.factors()) == phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [1,0]) + sage: P, = E.gens() + sage: phi = EllipticCurveHom_composite(E, P) + sage: EllipticCurveHom_composite.from_factors(phi.factors()) == phi True """ maps = tuple(maps) @@ -467,23 +477,25 @@ def _call_(self, P): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - x - 5) # optional - sage.rings.number_field - sage: E = EllipticCurve('210.b6').change_ring(K) # optional - sage.rings.number_field - sage: psi = EllipticCurveHom_composite(E, E.torsion_points()) # optional - sage.rings.number_field - sage: R = E.lift_x(15/4 * (a+3)) # optional - sage.rings.number_field - sage: psi(R) # indirect doctest # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 5) + sage: E = EllipticCurve('210.b6').change_ring(K) + sage: psi = EllipticCurveHom_composite(E, E.torsion_points()) + sage: R = E.lift_x(15/4 * (a+3)) + sage: psi(R) # indirect doctest (1033648757/303450 : -58397496786187/1083316500*a + 54706287407197/2166633000 : 1) Check that copying the order over works:: - sage: E = EllipticCurve(GF(431), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: Q = 2^99*P; Q.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(431), [1,0]) + sage: P, = E.gens() + sage: Q = 2^99*P; Q.order() 27 - sage: phi = E.isogeny(3^99*P, algorithm='factored') # optional - sage.rings.finite_rings - sage: phi(Q)._order # optional - sage.rings.finite_rings + sage: phi = E.isogeny(3^99*P, algorithm='factored') + sage: phi(Q)._order 27 """ return _eval_factored_isogeny(self._phis, P) @@ -505,8 +517,8 @@ def _eval(self, P): sage: E = EllipticCurve(j=Mod(1728,419)) sage: K, = E.gens() sage: psi = EllipticCurveHom_composite(E, 4*K) - sage: Ps = E.change_ring(GF(419**2))(0).division_points(5) # optional - sage.rings.finite_rings - sage: {psi._eval(P).curve() for P in Ps} # optional - sage.rings.finite_rings + sage: Ps = E.change_ring(GF(419**2))(0).division_points(5) # needs sage.rings.finite_rings + sage: {psi._eval(P).curve() for P in Ps} # needs sage.rings.finite_rings {Elliptic Curve defined by y^2 = x^3 + 373*x + 126 over Finite Field in z2 of size 419^2} """ if self._domain.defining_polynomial()(*P): @@ -526,14 +538,14 @@ def _repr_(self): TESTS:: sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(43), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi # indirect doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [1,0]) + sage: P, = E.gens() + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi # indirect doctest Composite morphism of degree 44 = 2^2*11: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 To: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 - sage: phi * phi * phi * phi * phi * phi * phi # indirect doctest # optional - sage.rings.finite_rings + sage: phi * phi * phi * phi * phi * phi * phi # indirect doctest Composite morphism of degree 319277809664 = 2^2*11*2^2*11*2^2*11*2^2*11*2^2*11*2^2*11*2^2*11: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 To: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 @@ -557,10 +569,10 @@ def factors(self): EXAMPLES:: sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(43), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi.factors() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [1,0]) + sage: P, = E.gens() + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi.factors() (Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 to Elliptic Curve defined by y^2 = x^3 + 39*x over Finite Field of size 43, @@ -584,33 +596,34 @@ def _composition_impl(left, right): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve([i + 1, i, 0, -4, -6*i]) # optional - sage.rings.number_field - sage: P,Q = E.lift_x(i - 5), E.lift_x(-4*i) # optional - sage.rings.number_field - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.number_field - sage: psi = phi.codomain().isogeny(phi(Q)) # optional - sage.rings.number_field + sage: E = EllipticCurve([i + 1, i, 0, -4, -6*i]) + sage: P,Q = E.lift_x(i - 5), E.lift_x(-4*i) + sage: phi = EllipticCurveHom_composite(E, P) + sage: psi = phi.codomain().isogeny(phi(Q)) sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: iso1 = WeierstrassIsomorphism(E, (-1, 0, -i - 1, 0)) # optional - sage.rings.number_field - sage: iso2 = psi.codomain().isomorphism_to(E) # optional - sage.rings.number_field - sage: psi * phi # indirect doctest # optional - sage.rings.number_field + sage: iso1 = WeierstrassIsomorphism(E, (-1, 0, -i - 1, 0)) + sage: iso2 = psi.codomain().isomorphism_to(E) + sage: psi * phi # indirect doctest Composite morphism of degree 16 = 2^2*4: From: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-3331/4)*x + (-142593/8*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - sage: iso2 * EllipticCurveHom_composite.from_factors([phi, psi]) # indirect doctest # optional - sage.rings.number_field + sage: iso2 * EllipticCurveHom_composite.from_factors([phi, psi]) # indirect doctest Composite morphism of degree 16 = 4^2: From: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - sage: phi * iso1 # indirect doctest # optional - sage.rings.number_field + sage: phi * iso1 # indirect doctest Composite morphism of degree 4 = 2^2: From: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (480*I-694)*x + (-7778*I+5556) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - sage: iso2 * psi * phi * iso1 # indirect doctest # optional - sage.rings.number_field + sage: iso2 * psi * phi * iso1 # indirect doctest Composite morphism of degree 16 = 2^2*4: From: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I @@ -647,26 +660,28 @@ def _comparison_impl(left, right, op): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(QuadraticField(-3), [0,16]) # optional - sage.rings.number_field - sage: P,Q = E.lift_x(0), E.lift_x(-4) # optional - sage.rings.number_field - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.number_field - sage: psi = phi.codomain().isogeny(phi(Q)) # optional - sage.rings.number_field - sage: psi = psi.codomain().isomorphism_to(E) * psi # optional - sage.rings.number_field - sage: comp = psi * phi # optional - sage.rings.number_field - sage: mu = E.scalar_multiplication(phi.degree()) # optional - sage.rings.number_field - sage: sum(a*comp == mu for a in E.automorphisms()) # optional - sage.rings.number_field + sage: E = EllipticCurve(QuadraticField(-3), [0,16]) + sage: P,Q = E.lift_x(0), E.lift_x(-4) + sage: phi = EllipticCurveHom_composite(E, P) + sage: psi = phi.codomain().isogeny(phi(Q)) + sage: psi = psi.codomain().isomorphism_to(E) * psi + sage: comp = psi * phi + sage: mu = E.scalar_multiplication(phi.degree()) + sage: sum(a*comp == mu for a in E.automorphisms()) 1 :: - sage: E = EllipticCurve(GF(431**2), [1,0]) # optional - sage.rings.finite_rings - sage: P,Q = E.gens() # optional - sage.rings.finite_rings - sage: phi1 = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi2 = EllipticCurveHom_composite(phi1.codomain(), phi1(Q)) # optional - sage.rings.finite_rings - sage: psi1 = EllipticCurveHom_composite(E, Q) # optional - sage.rings.finite_rings - sage: psi2 = EllipticCurveHom_composite(psi1.codomain(), psi1(P)) # optional - sage.rings.finite_rings - sage: phi2 * phi1 == psi2 * psi1 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(431**2), [1,0]) + sage: P,Q = E.gens() + sage: phi1 = EllipticCurveHom_composite(E, P) # needs sage.rings.number_field + sage: phi2 = EllipticCurveHom_composite(phi1.codomain(), phi1(Q)) # needs sage.rings.number_field + sage: psi1 = EllipticCurveHom_composite(E, Q) # needs sage.rings.number_field + sage: psi2 = EllipticCurveHom_composite(psi1.codomain(), psi1(P)) # needs sage.rings.number_field + sage: phi2 * phi1 == psi2 * psi1 # needs sage.rings.number_field True """ if op != op_EQ: @@ -683,11 +698,12 @@ def rational_maps(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi.rational_maps() ((x^9 + 27463*x^8 + 21204*x^7 - 5750*x^6 + 1610*x^5 + 14440*x^4 + 26605*x^3 - 15569*x^2 - 3341*x + 1267)/(x^8 + 27463*x^7 + 26871*x^6 + 5999*x^5 - 20194*x^4 - 6310*x^3 + 24366*x^2 - 20905*x - 13867), @@ -700,17 +716,17 @@ def rational_maps(self): TESTS:: - sage: f = phi.codomain().defining_polynomial() # optional - sage.rings.finite_rings - sage: g = E.defining_polynomial().subs({2:1}) # optional - sage.rings.finite_rings - sage: f(*phi.rational_maps(), 1) % g # optional - sage.rings.finite_rings + sage: f = phi.codomain().defining_polynomial() # needs sage.rings.finite_rings + sage: g = E.defining_polynomial().subs({2:1}) # needs sage.rings.finite_rings + sage: f(*phi.rational_maps(), 1) % g # needs sage.rings.finite_rings 0 :: - sage: phi.rational_maps()[0].parent() # optional - sage.rings.finite_rings + sage: phi.rational_maps()[0].parent() # needs sage.rings.finite_rings Fraction Field of Multivariate Polynomial Ring in x, y over Finite Field of size 65537 - sage: phi.rational_maps()[1].parent() # optional - sage.rings.finite_rings + sage: phi.rational_maps()[1].parent() # needs sage.rings.finite_rings Fraction Field of Multivariate Polynomial Ring in x, y over Finite Field of size 65537 """ @@ -726,16 +742,17 @@ def x_rational_map(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi.x_rational_map() == phi.rational_maps()[0] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi.x_rational_map() == phi.rational_maps()[0] True TESTS:: - sage: phi.x_rational_map().parent() # optional - sage.rings.finite_rings + sage: phi.x_rational_map().parent() # needs sage.rings.finite_rings Fraction Field of Univariate Polynomial Ring in x over Finite Field of size 65537 """ @@ -750,16 +767,17 @@ def kernel_polynomial(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P); phi Composite morphism of degree 9 = 3^2: From: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 65537 To: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 28339*x + 59518 over Finite Field of size 65537 - sage: phi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: phi.kernel_polynomial() x^4 + 46500*x^3 + 19556*x^2 + 7643*x + 15952 """ # shouldn't there be a better algorithm for this? @@ -772,24 +790,25 @@ def dual(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P); phi Composite morphism of degree 9 = 3^2: From: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 65537 To: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 28339*x + 59518 over Finite Field of size 65537 - sage: psi = phi.dual(); psi # optional - sage.rings.finite_rings + sage: psi = phi.dual(); psi Composite morphism of degree 9 = 3^2: From: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 28339*x + 59518 over Finite Field of size 65537 To: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 65537 - sage: psi * phi == phi.domain().scalar_multiplication(phi.degree()) # optional - sage.rings.finite_rings + sage: psi * phi == phi.domain().scalar_multiplication(phi.degree()) True - sage: phi * psi == psi.domain().scalar_multiplication(psi.degree()) # optional - sage.rings.finite_rings + sage: phi * psi == psi.domain().scalar_multiplication(psi.degree()) True """ phis = (phi.dual() for phi in self._phis[::-1]) @@ -804,16 +823,17 @@ def is_separable(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(7^2), [3,2]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(1) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7^2), [3,2]) + sage: P = E.lift_x(1) + sage: phi = EllipticCurveHom_composite(E, P); phi Composite morphism of degree 7 = 7: From: Elliptic Curve defined by y^2 = x^3 + 3*x + 2 over Finite Field in z2 of size 7^2 To: Elliptic Curve defined by y^2 = x^3 + 3*x + 2 over Finite Field in z2 of size 7^2 - sage: phi.is_separable() # optional - sage.rings.finite_rings + sage: phi.is_separable() True """ return all(phi.is_separable() for phi in self._phis) @@ -826,16 +846,17 @@ def formal(self, prec=20): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi.formal() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi.formal() t + 54203*t^5 + 48536*t^6 + 40698*t^7 + 37808*t^8 + 21111*t^9 + 42381*t^10 + 46688*t^11 + 657*t^12 + 38916*t^13 + 62261*t^14 + 59707*t^15 + 30767*t^16 + 7248*t^17 + 60287*t^18 + 50451*t^19 + 38305*t^20 + 12312*t^21 + 31329*t^22 + O(t^23) - sage: (phi.dual() * phi).formal(prec=5) # optional - sage.rings.finite_rings + sage: (phi.dual() * phi).formal(prec=5) 9*t + 65501*t^2 + 65141*t^3 + 59183*t^4 + 21491*t^5 + 8957*t^6 + 999*t^7 + O(t^8) """ @@ -857,18 +878,19 @@ def scaling_factor(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi = WeierstrassIsomorphism(phi.codomain(), [7,8,9,10]) * phi # optional - sage.rings.finite_rings - sage: phi.formal() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi = WeierstrassIsomorphism(phi.codomain(), [7,8,9,10]) * phi + sage: phi.formal() 7*t + 65474*t^2 + 511*t^3 + 61316*t^4 + 20548*t^5 + 45511*t^6 + 37285*t^7 + 48414*t^8 + 9022*t^9 + 24025*t^10 + 35986*t^11 + 55397*t^12 + 25199*t^13 + 18744*t^14 + 46142*t^15 + 9078*t^16 + 18030*t^17 + 47599*t^18 + 12158*t^19 + 50630*t^20 + 56449*t^21 + 43320*t^22 + O(t^23) - sage: phi.scaling_factor() # optional - sage.rings.finite_rings + sage: phi.scaling_factor() 7 ALGORITHM: The scaling factor is multiplicative under @@ -891,15 +913,15 @@ def is_injective(self): sage: phi = EllipticCurveHom_composite(E, E(0,0)) sage: phi.is_injective() False - sage: E = EllipticCurve_from_j(GF(3).algebraic_closure()(0)) # optional - sage.rings.finite_rings - sage: nu = EllipticCurveHom_composite.from_factors(E.automorphisms()) # optional - sage.rings.finite_rings - sage: nu # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(3).algebraic_closure()(0)) + sage: nu = EllipticCurveHom_composite.from_factors(E.automorphisms()) + sage: nu Composite morphism of degree 1 = 1^12: From: Elliptic Curve defined by y^2 = x^3 + x over Algebraic closure of Finite Field of size 3 To: Elliptic Curve defined by y^2 = x^3 + x over Algebraic closure of Finite Field of size 3 - sage: nu.is_injective() # optional - sage.rings.finite_rings + sage: nu.is_injective() True """ return all(phi.is_injective() for phi in self._phis) diff --git a/src/sage/schemes/elliptic_curves/hom_frobenius.py b/src/sage/schemes/elliptic_curves/hom_frobenius.py index b5f2b51d470..fb4496aedbb 100644 --- a/src/sage/schemes/elliptic_curves/hom_frobenius.py +++ b/src/sage/schemes/elliptic_curves/hom_frobenius.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Frobenius isogenies of elliptic curves diff --git a/src/sage/schemes/elliptic_curves/isogeny_class.py b/src/sage/schemes/elliptic_curves/isogeny_class.py index 1588ecbe814..84404c28b76 100644 --- a/src/sage/schemes/elliptic_curves/isogeny_class.py +++ b/src/sage/schemes/elliptic_curves/isogeny_class.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Isogeny class of elliptic curves over number fields diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py index ceda9840aa2..ac68ba3d601 100644 --- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py +++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py @@ -751,9 +751,9 @@ def isogenies_2(E, minimal_models=True): Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field sage: [phi.codomain().ainvs() for phi in isogenies_2(E)] [] - sage: E = EllipticCurve(QQbar, [9,8]); E # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [9,8]); E # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + 9*x + 8 over Algebraic Field - sage: isogenies_2(E) # not implemented # optional - sage.rings.number_field + sage: isogenies_2(E) # not implemented # needs sage.rings.number_field """ f2 = E.division_polynomial(2) x2 = sorted(f2.roots(multiplicities=False)) @@ -787,12 +787,12 @@ def isogenies_3(E, minimal_models=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_3 - sage: E = EllipticCurve(GF(17), [1,1]) # optional - sage.rings.finite_rings - sage: [phi.codomain().ainvs() for phi in isogenies_3(E)] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [1,1]) + sage: [phi.codomain().ainvs() for phi in isogenies_3(E)] [(0, 0, 0, 9, 7), (0, 0, 0, 0, 1)] - sage: E = EllipticCurve(GF(17^2,'a'), [1,1]) # optional - sage.rings.finite_rings - sage: [phi.codomain().ainvs() for phi in isogenies_3(E)] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17^2,'a'), [1,1]) # needs sage.rings.finite_rings + sage: [phi.codomain().ainvs() for phi in isogenies_3(E)] # needs sage.rings.finite_rings [(0, 0, 0, 9, 7), (0, 0, 0, 0, 1), (0, 0, 0, 5*a + 1, a + 13), (0, 0, 0, 12*a + 6, 16*a + 14)] sage: E = EllipticCurve('19a1') @@ -850,8 +850,8 @@ def isogenies_5_0(E, minimal_models=True): sage: isogenies_5_0(E) [] - sage: E = EllipticCurve(GF(13^2,'a'), [0,-3]) # optional - sage.rings.finite_rings - sage: isogenies_5_0(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13^2,'a'), [0,-3]) # needs sage.rings.finite_rings + sage: isogenies_5_0(E) # needs sage.rings.finite_rings [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (4*a+6)*x + (2*a+10) @@ -878,9 +878,9 @@ def isogenies_5_0(E, minimal_models=True): over Finite Field in a of size 13^2] sage: x = polygen(QQ, 'x') - sage: K. = NumberField(x**6 - 320*x**3 - 320) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,1,0,0]) # optional - sage.rings.number_field - sage: isogenies_5_0(E) # optional - sage.rings.number_field + sage: K. = NumberField(x**6 - 320*x**3 - 320) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [0,0,1,0,0]) # needs sage.rings.number_field + sage: isogenies_5_0(E) # needs sage.rings.number_field [Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 @@ -955,8 +955,8 @@ def isogenies_5_1728(E, minimal_models=True): sage: isogenies_5_1728(E) [] - sage: E = EllipticCurve(GF(13), [11,0]) # optional - sage.rings.finite_rings - sage: isogenies_5_1728(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13), [11,0]) + sage: isogenies_5_1728(E) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13, @@ -966,9 +966,10 @@ def isogenies_5_1728(E, minimal_models=True): An example of endomorphisms of degree 5:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: isogenies_5_1728(E) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: isogenies_5_1728(E) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I @@ -979,7 +980,7 @@ def isogenies_5_1728(E, minimal_models=True): with defining polynomial x^2 + 1 with i = 1*I to Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I] - sage: _[0].rational_maps() # optional - sage.rings.number_field + sage: _[0].rational_maps() (((4/25*i + 3/25)*x^5 + (4/5*i - 2/5)*x^3 - x)/(x^4 + (-4/5*i + 2/5)*x^2 + (-4/25*i - 3/25)), ((11/125*i + 2/125)*x^6*y + (-23/125*i + 64/125)*x^4*y @@ -989,12 +990,13 @@ def isogenies_5_1728(E, minimal_models=True): An example of 5-isogenies over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ, 'x') - sage: K. = NumberField(x**4 + 20*x**2 - 80) # optional - sage.rings.number_field - sage: K(5).is_square() # necessary but not sufficient! # optional - sage.rings.number_field + sage: K. = NumberField(x**4 + 20*x**2 - 80) + sage: K(5).is_square() # necessary but not sufficient! True - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: isogenies_5_1728(E) # optional - sage.rings.number_field + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: isogenies_5_1728(E) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in a with defining polynomial x^4 + 20*x^2 - 80 @@ -1008,14 +1010,15 @@ def isogenies_5_1728(E, minimal_models=True): See :trac:`19840`:: - sage: K. = NumberField(x^4 - 5*x^2 + 5) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^4 - 5*x^2 + 5) sage: E = EllipticCurve([a^2 + a + 1, a^3 + a^2 + a + 1, a^2 + a, ....: 17*a^3 + 34*a^2 - 16*a - 37, ....: 54*a^3 + 105*a^2 - 66*a - 135]) - sage: len(E.isogenies_prime_degree(5)) # optional - sage.rings.number_field + sage: len(E.isogenies_prime_degree(5)) 2 sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_5_1728 - sage: [phi.codomain().j_invariant() for phi in isogenies_5_1728(E)] # optional - sage.rings.number_field + sage: [phi.codomain().j_invariant() for phi in isogenies_5_1728(E)] [19691491018752*a^2 - 27212977933632, 19691491018752*a^2 - 27212977933632] """ F = E.base_field() @@ -1084,9 +1087,9 @@ def isogenies_7_0(E, minimal_models=True): First some examples of endomorphisms:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_7_0 - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1]) # optional - sage.rings.number_field - sage: isogenies_7_0(E) # optional - sage.rings.number_field + sage: K. = QuadraticField(-3) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [0,1]) # needs sage.rings.number_field + sage: isogenies_7_0(E) # needs sage.rings.number_field [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I @@ -1098,8 +1101,8 @@ def isogenies_7_0(E, minimal_models=True): to Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I] - sage: E = EllipticCurve(GF(13^2,'a'), [0,-3]) # optional - sage.rings.finite_rings - sage: isogenies_7_0(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13^2,'a'), [0,-3]) # needs sage.rings.finite_rings + sage: isogenies_7_0(E) # needs sage.rings.finite_rings [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2, @@ -1109,9 +1112,9 @@ def isogenies_7_0(E, minimal_models=True): Now some examples of 7-isogenies which are not endomorphisms:: - sage: K = GF(101) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [0,1]) # optional - sage.rings.finite_rings - sage: isogenies_7_0(E) # optional - sage.rings.finite_rings + sage: K = GF(101) + sage: E = EllipticCurve(K, [0,1]) + sage: isogenies_7_0(E) [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 101 to Elliptic Curve defined by y^2 = x^3 + 55*x + 100 over Finite Field of size 101, @@ -1122,8 +1125,8 @@ def isogenies_7_0(E, minimal_models=True): Examples over a number field:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_7_0 - sage: E = EllipticCurve('27a1').change_ring(QuadraticField(-3,'r')) # optional - sage.rings.number_field - sage: isogenies_7_0(E) # optional - sage.rings.number_field + sage: E = EllipticCurve('27a1').change_ring(QuadraticField(-3,'r')) # needs sage.rings.number_field + sage: isogenies_7_0(E) # needs sage.rings.number_field [Isogeny of degree 7 from Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I @@ -1135,11 +1138,12 @@ def isogenies_7_0(E, minimal_models=True): to Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I] + sage: # needs sage.rings.number_field sage: x = polygen(QQ, 'x') - sage: K. = NumberField(x^6 + 1512*x^3 - 21168) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1]) # optional - sage.rings.number_field - sage: isogs = isogenies_7_0(E) # optional - sage.rings.number_field - sage: [phi.codomain().a_invariants() for phi in isogs] # optional - sage.rings.number_field + sage: K. = NumberField(x^6 + 1512*x^3 - 21168) + sage: E = EllipticCurve(K, [0,1]) + sage: isogs = isogenies_7_0(E) + sage: [phi.codomain().a_invariants() for phi in isogs] [(0, 0, 0, @@ -1152,7 +1156,7 @@ def isogenies_7_0(E, minimal_models=True): -24485/392*a^5 - 1080/7*a^4 - 2255/7*a^3 - 1340865/14*a^2 - 230040*a - 553500, 1753037/56*a^5 + 8345733/112*a^4 + 374275/2*a^3 + 95377029/2*a^2 + 458385345/4*a + 275241835)] - sage: [phi.codomain().j_invariant() for phi in isogs] # optional - sage.rings.number_field + sage: [phi.codomain().j_invariant() for phi in isogs] [158428486656000/7*a^3 - 313976217600000, -158428486656000/7*a^3 - 34534529335296000] """ @@ -1219,8 +1223,8 @@ def isogenies_7_1728(E, minimal_models=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_7_1728 - sage: E = EllipticCurve(GF(47), [1, 0]) # optional - sage.rings.finite_rings - sage: isogenies_7_1728(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(47), [1, 0]) + sage: isogenies_7_1728(E) [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 47 to Elliptic Curve defined by y^2 = x^3 + 26 over Finite Field of size 47, @@ -1230,32 +1234,34 @@ def isogenies_7_1728(E, minimal_models=True): An example in characteristic 53 (for which an earlier implementation did not work):: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_7_1728 - sage: E = EllipticCurve(GF(53), [1, 0]) # optional - sage.rings.finite_rings - sage: isogenies_7_1728(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(53), [1, 0]) + sage: isogenies_7_1728(E) [] - sage: E = EllipticCurve(GF(53^2,'a'), [1, 0]) # optional - sage.rings.finite_rings - sage: [iso.codomain().ainvs() for iso in isogenies_7_1728(E)] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(53^2,'a'), [1, 0]) + sage: [iso.codomain().ainvs() for iso in isogenies_7_1728(E)] [(0, 0, 0, 36, 19*a + 15), (0, 0, 0, 36, 34*a + 38), (0, 0, 0, 33, 39*a + 28), (0, 0, 0, 33, 14*a + 25), (0, 0, 0, 19, 45*a + 16), (0, 0, 0, 19, 8*a + 37), (0, 0, 0, 3, 45*a + 16), (0, 0, 0, 3, 8*a + 37)] :: + sage: # needs sage.rings.number_field sage: x = polygen(QQ, 'x') - sage: K. = NumberField(x^8 + 84*x^6 - 1890*x^4 + 644*x^2 - 567) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1, 0]) # optional - sage.rings.number_field - sage: isogs = isogenies_7_1728(E) # optional - sage.rings.number_field - sage: [phi.codomain().j_invariant() for phi in isogs] # optional - sage.rings.number_field + sage: K. = NumberField(x^8 + 84*x^6 - 1890*x^4 + 644*x^2 - 567) + sage: E = EllipticCurve(K, [1, 0]) + sage: isogs = isogenies_7_1728(E) + sage: [phi.codomain().j_invariant() for phi in isogs] [-526110256146528/53*a^6 + 183649373229024*a^4 - 3333881559996576/53*a^2 + 2910267397643616/53, -526110256146528/53*a^6 + 183649373229024*a^4 - 3333881559996576/53*a^2 + 2910267397643616/53] - sage: E1 = isogs[0].codomain() # optional - sage.rings.number_field - sage: E2 = isogs[1].codomain() # optional - sage.rings.number_field - sage: E1.is_isomorphic(E2) # optional - sage.rings.number_field + sage: E1 = isogs[0].codomain() + sage: E2 = isogs[1].codomain() + sage: E1.is_isomorphic(E2) False - sage: E1.is_quadratic_twist(E2) # optional - sage.rings.number_field + sage: E1.is_quadratic_twist(E2) -1 """ if E.j_invariant() != 1728: @@ -1320,11 +1326,12 @@ def isogenies_13_0(E, minimal_models=True): Endomorphisms of degree 13 will exist when -3 is a square:: - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0, r]); E # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: E = EllipticCurve(K, [0, r]); E Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I - sage: isogenies_13_0(E) # optional - sage.rings.number_field + sage: isogenies_13_0(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I @@ -1335,7 +1342,7 @@ def isogenies_13_0(E, minimal_models=True): with defining polynomial x^2 + 3 with r = 1.732050807568878?*I to Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I] - sage: isogenies_13_0(E)[0].rational_maps() # optional - sage.rings.number_field + sage: isogenies_13_0(E)[0].rational_maps() (((7/338*r + 23/338)*x^13 + (-164/13*r - 420/13)*x^10 + (720/13*r + 3168/13)*x^7 + (3840/13*r - 576/13)*x^4 + (4608/13*r + 2304/13)*x)/(x^12 + (4*r + 36)*x^9 + (1080/13*r + 3816/13)*x^6 @@ -1350,27 +1357,28 @@ def isogenies_13_0(E, minimal_models=True): An example of endomorphisms over a finite field:: - sage: K = GF(19^2,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=K(0)); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(19^2,'a') + sage: E = EllipticCurve(j=K(0)); E Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 - sage: isogenies_13_0(E) # optional - sage.rings.finite_rings + sage: isogenies_13_0(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2] - sage: isogenies_13_0(E)[0].rational_maps() # optional - sage.rings.finite_rings + sage: isogenies_13_0(E)[0].rational_maps() ((6*x^13 - 6*x^10 - 3*x^7 + 6*x^4 + x)/(x^12 - 5*x^9 - 9*x^6 - 7*x^3 + 5), (-8*x^18*y - 9*x^15*y + 9*x^12*y - 5*x^9*y + 5*x^6*y - 7*x^3*y + 7*y)/(x^18 + 2*x^15 + 3*x^12 - x^9 + 8*x^6 - 9*x^3 + 7)) A previous implementation did not work in some characteristics:: - sage: K = GF(29) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=K(0)) # optional - sage.rings.finite_rings - sage: isogenies_13_0(E) # optional - sage.rings.finite_rings + sage: K = GF(29) + sage: E = EllipticCurve(j=K(0)) + sage: isogenies_13_0(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 26*x + 12 over Finite Field of size 29, @@ -1380,20 +1388,20 @@ def isogenies_13_0(E, minimal_models=True): :: - sage: K = GF(101) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=K(0)); E.ainvs() # optional - sage.rings.finite_rings + sage: K = GF(101) + sage: E = EllipticCurve(j=K(0)); E.ainvs() (0, 0, 0, 0, 1) - sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)] # optional - sage.rings.finite_rings + sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)] [(0, 0, 0, 64, 36), (0, 0, 0, 42, 66)] :: sage: x = polygen(QQ) sage: f = x^12 + 78624*x^9 - 130308048*x^6 + 2270840832*x^3 - 54500179968 - sage: K. = NumberField(f) # optional - sage.rings.number_field - sage: E = EllipticCurve(j=K(0)); E.ainvs() # optional - sage.rings.number_field + sage: K. = NumberField(f) # needs sage.rings.number_field + sage: E = EllipticCurve(j=K(0)); E.ainvs() # needs sage.rings.number_field (0, 0, 0, 0, 1) - sage: len([phi.codomain().ainvs() # long time (4s) # optional - sage.rings.number_field + sage: len([phi.codomain().ainvs() # long time # needs sage.rings.number_field ....: for phi in isogenies_13_0(E)]) 2 """ @@ -1469,10 +1477,10 @@ def isogenies_13_1728(E, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_13_1728 - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,i,0]); E.ainvs() # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve([0,0,0,i,0]); E.ainvs() # needs sage.rings.number_field (0, 0, 0, i, 0) - sage: isogenies_13_1728(E) # optional - sage.rings.number_field + sage: isogenies_13_1728(E) # needs sage.rings.number_field [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I @@ -1486,15 +1494,15 @@ def isogenies_13_1728(E, minimal_models=True): :: - sage: K = GF(83) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs() # optional - sage.rings.finite_rings + sage: K = GF(83) + sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs() (0, 0, 0, 5, 0) - sage: isogenies_13_1728(E) # optional - sage.rings.finite_rings + sage: isogenies_13_1728(E) [] - sage: K = GF(89) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs() # optional - sage.rings.finite_rings + sage: K = GF(89) + sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs() (0, 0, 0, 5, 0) - sage: isogenies_13_1728(E) # optional - sage.rings.finite_rings + sage: isogenies_13_1728(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89, @@ -1504,9 +1512,9 @@ def isogenies_13_1728(E, minimal_models=True): :: - sage: K = GF(23) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [1,0]) # optional - sage.rings.finite_rings - sage: isogenies_13_1728(E) # optional - sage.rings.finite_rings + sage: K = GF(23) + sage: E = EllipticCurve(K, [1,0]) + sage: isogenies_13_1728(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 23 to Elliptic Curve defined by y^2 = x^3 + 16 over Finite Field of size 23, @@ -1519,9 +1527,9 @@ def isogenies_13_1728(E, minimal_models=True): sage: x = polygen(QQ) sage: f = (x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 ....: - 282896640*x^4 - 149879808*x^2 - 349360128) - sage: K. = NumberField(f) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1,0]) # optional - sage.rings.number_field - sage: [phi.codomain().ainvs() # long time (3s) # optional - sage.rings.number_field + sage: K. = NumberField(f) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [1,0]) # needs sage.rings.number_field + sage: [phi.codomain().ainvs() # long time # needs sage.rings.number_field ....: for phi in isogenies_13_1728(E)] [(0, 0, @@ -1865,10 +1873,11 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field] - sage: K = QuadraticField(-295,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(-484650135/16777216*a + 4549855725/16777216) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0(E, 23) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(-295,'a') + sage: a = K.gen() + sage: E = EllipticCurve_from_j(-484650135/16777216*a + 4549855725/16777216) + sage: isogenies_prime_degree_genus_plus_0(E, 23) [Isogeny of degree 23 from Elliptic Curve defined by y^2 = x^3 + (-14460494784192904095/140737488355328*a+270742665778826768325/140737488355328)*x @@ -1881,10 +1890,11 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 + 295 with a = 17.17556403731767?*I] - sage: K = QuadraticField(-199,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(94743000*a + 269989875) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0(E, 29) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(-199,'a') + sage: a = K.gen() + sage: E = EllipticCurve_from_j(94743000*a + 269989875) + sage: isogenies_prime_degree_genus_plus_0(E, 29) [Isogeny of degree 29 from Elliptic Curve defined by y^2 = x^3 + (-153477413215038000*a+5140130723072965125)*x @@ -1897,10 +1907,11 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 + 199 with a = 14.106735979665884?*I] - sage: K = QuadraticField(253,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(208438034112000*a - 3315409892960000) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0(E, 31) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(253,'a') + sage: a = K.gen() + sage: E = EllipticCurve_from_j(208438034112000*a - 3315409892960000) + sage: isogenies_prime_degree_genus_plus_0(E, 31) [Isogeny of degree 31 from Elliptic Curve defined by y^2 = x^3 + (4146345122185433034677956608000*a-65951656549965037259634800640000)*x @@ -1913,8 +1924,8 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 - 253 with a = 15.905973720586867?] - sage: E = EllipticCurve_from_j(GF(5)(1)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_genus_plus_0(E, 41) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(5)(1)) + sage: isogenies_prime_degree_genus_plus_0(E, 41) [Isogeny of degree 41 from Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 5 to Elliptic Curve defined by y^2 = x^3 + x + 3 over Finite Field of size 5, @@ -1922,11 +1933,12 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): from Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 5 to Elliptic Curve defined by y^2 = x^3 + x + 3 over Finite Field of size 5] - sage: K = QuadraticField(5,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(184068066743177379840*a # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(5,'a') + sage: a = K.gen() + sage: E = EllipticCurve_from_j(184068066743177379840*a ....: - 411588709724712960000) - sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (2s) # optional - sage.rings.number_field + sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x @@ -1939,9 +1951,9 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?] - sage: K = QuadraticField(-66827,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000) # optional - sage.rings.number_field + sage: K = QuadraticField(-66827,'a') # needs sage.rings.number_field + sage: a = K.gen() # needs sage.rings.number_field + sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000) # needs sage.rings.number_field sage: isogenies_prime_degree_genus_plus_0(E, 59) # long time (5s) [Isogeny of degree 59 from Elliptic Curve defined by @@ -1955,8 +1967,8 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I] - sage: E = EllipticCurve_from_j(GF(13)(5)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_genus_plus_0(E, 71) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(5)) + sage: isogenies_prime_degree_genus_plus_0(E, 71) [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, @@ -1964,8 +1976,8 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13] - sage: E = EllipticCurve(GF(13), [0,1,1,1,0]) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_genus_plus_0(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13), [0,1,1,1,0]) + sage: isogenies_prime_degree_genus_plus_0(E) [Isogeny of degree 17 from Elliptic Curve defined by y^2 + y = x^3 + x^2 + x over Finite Field of size 13 to Elliptic Curve defined by y^2 + y = x^3 + x^2 + 10*x + 1 over Finite Field of size 13, @@ -2070,9 +2082,9 @@ def isogenies_prime_degree_genus_plus_0_j0(E, l, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree_genus_plus_0_j0 sage: u = polygen(QQ) - sage: K. = NumberField(u^4 + 228*u^3 + 486*u^2 - 540*u + 225) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0, -121/5*a^3 - 20691/5*a^2 - 29403/5*a + 3267]) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0_j0(E, 11) # optional - sage.rings.number_field + sage: K. = NumberField(u^4 + 228*u^3 + 486*u^2 - 540*u + 225) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [0, -121/5*a^3 - 20691/5*a^2 - 29403/5*a + 3267]) # needs sage.rings.number_field + sage: isogenies_prime_degree_genus_plus_0_j0(E, 11) # needs sage.rings.number_field [Isogeny of degree 11 from Elliptic Curve defined by y^2 = x^3 + (-121/5*a^3-20691/5*a^2-29403/5*a+3267) over @@ -2171,13 +2183,14 @@ def isogenies_prime_degree_genus_plus_0_j1728(E, l, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree_genus_plus_0_j1728 + sage: # needs sage.rings.number_field sage: u = polygen(QQ) - sage: K. = NumberField(u^6 - 522*u^5 - 10017*u^4 # optional - sage.rings.number_field + sage: K. = NumberField(u^6 - 522*u^5 - 10017*u^4 ....: + 2484*u^3 - 5265*u^2 + 12150*u - 5103) - sage: E = EllipticCurve(K, [-75295/1335852*a^5 + 13066735/445284*a^4 # optional - sage.rings.number_field + sage: E = EllipticCurve(K, [-75295/1335852*a^5 + 13066735/445284*a^4 ....: + 44903485/74214*a^3 + 17086861/24738*a^2 ....: + 11373021/16492*a - 1246245/2356, 0]) - sage: isogenies_prime_degree_genus_plus_0_j1728(E, 11) # optional - sage.rings.number_field + sage: isogenies_prime_degree_genus_plus_0_j1728(E, 11) [Isogeny of degree 11 from Elliptic Curve defined by y^2 = x^3 + (-75295/1335852*a^5+13066735/445284*a^4+44903485/74214*a^3+17086861/24738*a^2+11373021/16492*a-1246245/2356)*x @@ -2198,9 +2211,9 @@ def isogenies_prime_degree_genus_plus_0_j1728(E, l, minimal_models=True): + (3540460*a^3-30522492*a^2+7043652*a+5031180) over Number Field in a with defining polynomial x^6 - 522*x^5 - 10017*x^4 + 2484*x^3 - 5265*x^2 + 12150*x - 5103] - sage: i = QuadraticField(-1,'i').gen() # optional - sage.rings.number_field - sage: E = EllipticCurve([-1 - 2*i, 0]) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0_j1728(E, 17) # optional - sage.rings.number_field + sage: i = QuadraticField(-1,'i').gen() + sage: E = EllipticCurve([-1 - 2*i, 0]) + sage: isogenies_prime_degree_genus_plus_0_j1728(E, 17) [Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + (-2*i-1)*x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I @@ -2211,8 +2224,8 @@ def isogenies_prime_degree_genus_plus_0_j1728(E, l, minimal_models=True): over Number Field in i with defining polynomial x^2 + 1 with i = 1*I to Elliptic Curve defined by y^2 = x^3 + (-562*i+319)*x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I] - sage: Emin = E.global_minimal_model() # optional - sage.rings.number_field - sage: [(p, len(isogenies_prime_degree_genus_plus_0_j1728(Emin, p))) # optional - sage.rings.number_field + sage: Emin = E.global_minimal_model() + sage: [(p, len(isogenies_prime_degree_genus_plus_0_j1728(Emin, p))) ....: for p in [17, 29, 41]] [(17, 2), (29, 2), (41, 2)] """ @@ -2346,13 +2359,13 @@ def is_kernel_polynomial(E, m, f): into 14 factors each of degree 6, but only two of these is a kernel polynomial for a 13-isogeny:: - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: f13 = E.division_polynomial(13) # optional - sage.rings.finite_rings - sage: factors = [f for f, e in f13.factor()] # optional - sage.rings.finite_rings - sage: all(f.degree() == 6 for f in factors) # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: E = EllipticCurve(F, [0,0,0,-1,0]) + sage: f13 = E.division_polynomial(13) + sage: factors = [f for f, e in f13.factor()] + sage: all(f.degree() == 6 for f in factors) True - sage: [is_kernel_polynomial(E, 13, f) for f in factors] # optional - sage.rings.finite_rings + sage: [is_kernel_polynomial(E, 13, f) for f in factors] [True, True, False, @@ -2370,15 +2383,16 @@ def is_kernel_polynomial(E, m, f): See :trac:`22232`:: - sage: K = GF(47^2) # optional - sage.rings.finite_rings - sage: E = EllipticCurve([0, K.gen()]) # optional - sage.rings.finite_rings - sage: psi7 = E.division_polynomial(7) # optional - sage.rings.finite_rings - sage: f = psi7.factor()[4][0] # optional - sage.rings.finite_rings - sage: f # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(47^2) + sage: E = EllipticCurve([0, K.gen()]) + sage: psi7 = E.division_polynomial(7) + sage: f = psi7.factor()[4][0] + sage: f x^3 + (7*z2 + 11)*x^2 + (25*z2 + 33)*x + 25*z2 - sage: f.divides(psi7) # optional - sage.rings.finite_rings + sage: f.divides(psi7) True - sage: is_kernel_polynomial(E, 7, f) # optional - sage.rings.finite_rings + sage: is_kernel_polynomial(E, 7, f) False """ m2 = m // 2 @@ -2397,14 +2411,18 @@ def is_kernel_polynomial(E, m, f): if m == 2 or m == 3: return True - # For each a in a set of generators of (Z/mZ)^* we check that the - # multiplication-by-a map permutes the roots of f. It would be - # enough to take a generating (Z/mZ)^*/{1,-1} but that is not - # implemented. If m is prime (or more generally, has a primitive - # root) then only one a will be needed. + # For each a in a set of generators of (Z/mZ)^*/{1,-1} we check + # that the multiplication-by-a map permutes the roots of f. + # If m is prime (or more generally, has a primitive root) then + # only one a will be needed. - from sage.rings.finite_rings.integer_mod_ring import Integers - for a in Integers(m).unit_gens(): + if m & 1 and m.is_prime_power(): + gens = _least_semi_primitive(m), + else: + from sage.rings.finite_rings.integer_mod_ring import Integers + gens = Integers(m).unit_gens() + + for a in gens: mu = E.multiplication_by_m(a, x_only=True) if f( S(mu.numerator()) / S(mu.denominator()) ) != 0: return False @@ -2444,15 +2462,15 @@ def isogenies_prime_degree_general(E, l, minimal_models=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree_general - sage: E = EllipticCurve_from_j(GF(2^6,'a')(1)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_general(E, 7) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(2^6,'a')(1)) # needs sage.rings.finite_rings + sage: isogenies_prime_degree_general(E, 7) # needs sage.rings.finite_rings [Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 + 1 over Finite Field in a of size 2^6 to Elliptic Curve defined by y^2 + x*y = x^3 + x over Finite Field in a of size 2^6] - sage: E = EllipticCurve_from_j(GF(3^12,'a')(2)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_general(E, 17) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(3^12,'a')(2)) # needs sage.rings.finite_rings + sage: isogenies_prime_degree_general(E, 17) # needs sage.rings.finite_rings [Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + 2*x^2 + 2 over Finite Field in a of size 3^12 @@ -2503,7 +2521,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree_general sage: ainvs = (0,1,1,-1,-1) - sage: for l in prime_range(50): # optional - sage.rings.finite_rings + sage: for l in prime_range(50): ....: E = EllipticCurve(GF(l),ainvs) ....: isogenies_prime_degree_general(E,l) [] @@ -2546,26 +2564,26 @@ def isogenies_prime_degree_general(E, l, minimal_models=True): factors of degree 6 each, but only two those are kernel polynomials:: - sage: F3 = GF(3) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F3, [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: Psi13 = E.division_polynomial(13) # optional - sage.rings.finite_rings - sage: len([f for f, e in Psi13.factor() if f.degree() == 6]) # optional - sage.rings.finite_rings + sage: F3 = GF(3) + sage: E = EllipticCurve(F3, [0,0,0,-1,0]) + sage: Psi13 = E.division_polynomial(13) + sage: len([f for f, e in Psi13.factor() if f.degree() == 6]) 14 - sage: len(E.isogenies_prime_degree(13)) # optional - sage.rings.finite_rings + sage: len(E.isogenies_prime_degree(13)) 2 Over GF(9) the other factors of degree 6 split into pairs of cubics which can be rearranged to give the remaining 12 kernel polynomials:: - sage: len(E.change_ring(GF(3^2,'a')).isogenies_prime_degree(13)) # optional - sage.rings.finite_rings + sage: len(E.change_ring(GF(3^2,'a')).isogenies_prime_degree(13)) # needs sage.rings.finite_rings 14 See :trac:`18589`: the following example took 20s before, now only 4s:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K,[0,0,0,1,0]) # optional - sage.rings.number_field - sage: [phi.codomain().ainvs() # long time (6s) # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve(K,[0,0,0,1,0]) # needs sage.rings.number_field + sage: [phi.codomain().ainvs() # long time # needs sage.rings.number_field ....: for phi in E.isogenies_prime_degree(37)] [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)] @@ -2668,15 +2686,15 @@ def isogenies_prime_degree(E, l, minimal_models=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree - sage: E = EllipticCurve_from_j(GF(2^6,'a')(1)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree(E, 7) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(2^6,'a')(1)) # needs sage.rings.finite_rings + sage: isogenies_prime_degree(E, 7) # needs sage.rings.finite_rings [Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 + 1 over Finite Field in a of size 2^6 to Elliptic Curve defined by y^2 + x*y = x^3 + x over Finite Field in a of size 2^6] - sage: E = EllipticCurve_from_j(GF(3^12,'a')(2)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree(E, 17) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(3^12,'a')(2)) # needs sage.rings.finite_rings + sage: isogenies_prime_degree(E, 17) # needs sage.rings.finite_rings [Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + 2*x^2 + 2 over Finite Field in a of size 3^12 @@ -2718,7 +2736,7 @@ def isogenies_prime_degree(E, l, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree sage: ainvs = (0,1,1,-1,-1) - sage: for l in prime_range(50): # optional - sage.rings.finite_rings + sage: for l in prime_range(50): ....: E = EllipticCurve(GF(l), ainvs) ....: isogenies_prime_degree(E, l) [] @@ -2770,17 +2788,17 @@ def isogenies_prime_degree(E, l, minimal_models=True): primes (11, 17, 19, 23, 29, 31, 41, 47, 59, 71) than when the generic code must be used:: - sage: E = EllipticCurve(GF(101), [-3440, 77658]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(71) # fast # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(101), [-3440, 77658]) + sage: E.isogenies_prime_degree(71) # fast [] - sage: E.isogenies_prime_degree(73) # long time (2s) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(73) # long time [] Test that :trac:`32269` is fixed:: - sage: K = QuadraticField(-11) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1,0,-117,-541]) # optional - sage.rings.number_field - sage: E.isogenies_prime_degree(37) # long time (9s) # optional - sage.rings.number_field + sage: K = QuadraticField(-11) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [0,1,0,-117,-541]) # needs sage.rings.number_field + sage: E.isogenies_prime_degree(37) # long time # needs sage.rings.number_field [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 diff --git a/src/sage/schemes/elliptic_curves/kraus.py b/src/sage/schemes/elliptic_curves/kraus.py index 9573dccabac..8565cc5e3be 100644 --- a/src/sage/schemes/elliptic_curves/kraus.py +++ b/src/sage/schemes/elliptic_curves/kraus.py @@ -86,6 +86,7 @@ def c4c6_nonsingular(c4, c6): Over number fields:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: c4c6_nonsingular(-217728*a - 679104, 141460992*a + 409826304) @@ -122,9 +123,10 @@ def c4c6_model(c4, c6, assume_nonsingular=False): sage: from sage.schemes.elliptic_curves.kraus import c4c6_model sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 10) - sage: c4c6_model(-217728*a - 679104, 141460992*a + 409826304) - Elliptic Curve defined by y^2 = x^3 + (4536*a+14148)*x + (-163728*a-474336) over Number Field in a with defining polynomial x^3 - 10 + sage: K. = NumberField(x^3 - 10) # needs sage.rings.number_field + sage: c4c6_model(-217728*a - 679104, 141460992*a + 409826304) # needs sage.rings.number_field + Elliptic Curve defined by y^2 = x^3 + (4536*a+14148)*x + (-163728*a-474336) + over Number Field in a with defining polynomial x^3 - 10 sage: c4, c6 = EllipticCurve('389a1').c_invariants() sage: c4c6_model(c4,c6) @@ -166,6 +168,7 @@ def make_integral(a, P, e): sage: from sage.schemes.elliptic_curves.kraus import make_integral + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: P = K.primes_above(2)[0] @@ -206,6 +209,7 @@ def sqrt_mod_4(x, P): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import sqrt_mod_4 sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -249,6 +253,7 @@ def test_b2_local(c4, c6, P, b2, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: c4 = -60544*a + 385796 @@ -259,28 +264,36 @@ def test_b2_local(c4, c6, P, b2, debug=False): b2=0 works at the first prime but not the second:: sage: b2 = 0 - sage: test_b2_local(c4,c6,P3a,b2) - Elliptic Curve defined by y^2 = x^3 + (3784/3*a-96449/12)*x + (1743740/27*a-32765791/108) over Number Field in a with defining polynomial x^2 - 10 - sage: test_b2_local(c4,c6,P3b,b2) + sage: test_b2_local(c4,c6,P3a,b2) # needs sage.rings.number_field + Elliptic Curve defined by + y^2 = x^3 + (3784/3*a-96449/12)*x + (1743740/27*a-32765791/108) + over Number Field in a with defining polynomial x^2 - 10 + sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field False b2=-a works at the second prime but not the first:: - sage: b2 = -a - sage: test_b2_local(c4,c6,P3a,b2,debug=True) + sage: b2 = -a # needs sage.rings.number_field + sage: test_b2_local(c4,c6,P3a,b2,debug=True) # needs sage.rings.number_field test_b2_local: not integral at Fractional ideal (3, a + 1) False - sage: test_b2_local(c4,c6,P3b,b2) - Elliptic Curve defined by y^2 = x^3 + (-1/4*a)*x^2 + (3784/3*a-192893/24)*x + (56378369/864*a-32879311/108) over Number Field in a with defining polynomial x^2 - 10 + sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field + Elliptic Curve defined by + y^2 = x^3 + (-1/4*a)*x^2 + (3784/3*a-192893/24)*x + (56378369/864*a-32879311/108) + over Number Field in a with defining polynomial x^2 - 10 Using CRT we can do both with the same b2:: - sage: b2 = K.solve_CRT([0,-a],[P3a,P3b]); b2 + sage: b2 = K.solve_CRT([0,-a],[P3a,P3b]); b2 # needs sage.rings.number_field a + 1 - sage: test_b2_local(c4,c6,P3a,b2) - Elliptic Curve defined by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) over Number Field in a with defining polynomial x^2 - 10 - sage: test_b2_local(c4,c6,P3b,b2) - Elliptic Curve defined by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) over Number Field in a with defining polynomial x^2 - 10 + sage: test_b2_local(c4,c6,P3a,b2) # needs sage.rings.number_field + Elliptic Curve defined by + y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) + over Number Field in a with defining polynomial x^2 - 10 + sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field + Elliptic Curve defined + by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) + over Number Field in a with defining polynomial x^2 - 10 """ E = c4c6_model(c4,c6).rst_transform(b2/12,0,0) if not (c4,c6) == E.c_invariants(): @@ -312,6 +325,7 @@ def test_b2_global(c4, c6, b2, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: c4 = -60544*a + 385796 @@ -361,6 +375,7 @@ def check_Kraus_local_3(c4, c6, P, assume_nonsingular=False, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import check_Kraus_local_3 sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -374,7 +389,8 @@ def check_Kraus_local_3(c4, c6, P, assume_nonsingular=False, debug=False): An example in a field where 3 is ramified:: - sage: K. = NumberField(x^2-15) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - 15) sage: c4 = -60504*a + 386001 sage: c6 = -55346820*a + 261045153 sage: P3 = K.primes_above(3)[0] @@ -430,6 +446,7 @@ def test_a1a3_local(c4, c6, P, a1, a3, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import test_a1a3_local sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -472,6 +489,7 @@ def test_a1a3_global(c4, c6, a1, a3, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import test_a1a3_global sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -513,6 +531,7 @@ def test_rst_global(c4, c6, r, s, t, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import test_rst_global sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2-10) @@ -579,6 +598,7 @@ def check_Kraus_local_2(c4, c6, P, a1=None, assume_nonsingular=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import check_Kraus_local_2 sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -666,6 +686,7 @@ def check_Kraus_local(c4, c6, P, assume_nonsingular=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import check_Kraus_local sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 15) @@ -687,6 +708,7 @@ def check_Kraus_local(c4, c6, P, assume_nonsingular=False): sage: E.is_local_integral_model(P5) and (c4,c6)==E.c_invariants() True + sage: # needs sage.rings.number_field sage: c4 = 123+456*a sage: c6 = 789+101112*a sage: check_Kraus_local(c4,c6,P2) @@ -735,6 +757,7 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import check_Kraus_global sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -752,7 +775,8 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): ...and it does! Elliptic Curve defined by y^2 + 3*a*x*y + (-89*a+10)*y = x^3 + (a-89)*x^2 + (1202*a-5225)*x + (34881*a-151813) over Number Field in a with defining polynomial x^2 - 10 - sage: K. = NumberField(x^2-15) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - 15) sage: E = EllipticCurve([0, 0, 0, 4536*a + 14148, -163728*a - 474336]) sage: c4, c6 = E.c_invariants() sage: check_Kraus_global(c4,c6) @@ -760,16 +784,19 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): TESTS (see :trac:`17295`):: - sage: K. =NumberField(x^3 - 7*x - 5) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 7*x - 5) sage: E = EllipticCurve([a, 0, 1, 2*a^2 + 5*a + 3, -a^2 - 3*a - 2]) sage: assert E.conductor().norm() ==8 sage: G = K.galois_group(names='b') sage: def conj_curve(E,sigma): return EllipticCurve([sigma(a) for a in E.ainvs()]) sage: EL = conj_curve(E,G[0]) sage: L = EL.base_field() - sage: assert L.class_number()== 2 - sage: EL.isogeny_class() # long time (~10s) - Isogeny class of Elliptic Curve defined by y^2 + (-1/90*b^4+7/18*b^2-1/2*b-98/45)*x*y + y = x^3 + (1/45*b^5-1/18*b^4-7/9*b^3+41/18*b^2+167/90*b-29/9)*x + (-1/90*b^5+1/30*b^4+7/18*b^3-4/3*b^2-61/90*b+11/5) over Number Field in b with defining polynomial x^6 - 42*x^4 + 441*x^2 - 697 + sage: assert L.class_number() == 2 + sage: EL.isogeny_class() # long time (~10s) + Isogeny class of Elliptic Curve defined by + y^2 + (-1/90*b^4+7/18*b^2-1/2*b-98/45)*x*y + y = x^3 + (1/45*b^5-1/18*b^4-7/9*b^3+41/18*b^2+167/90*b-29/9)*x + (-1/90*b^5+1/30*b^4+7/18*b^3-4/3*b^2-61/90*b+11/5) + over Number Field in b with defining polynomial x^6 - 42*x^4 + 441*x^2 - 697 """ if not assume_nonsingular: if not c4c6_nonsingular(c4,c6): @@ -913,6 +940,7 @@ def semi_global_minimal_model(E, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: K.class_number() @@ -932,16 +960,18 @@ def semi_global_minimal_model(E, debug=False): has order 3315. The smallest prime in that ideal class has norm 23567:: - sage: K. = NumberField(x^2-x+31821453) - sage: ainvs = (0, 0, 0, -382586771000351226384*a - 2498023791133552294513515, 358777608829102441023422458989744*a + 1110881475104109582383304709231832166) + sage: # long time, needs sage.rings.number_field + sage: K. = NumberField(x^2 - x + 31821453) + sage: ainvs = (0, 0, 0, -382586771000351226384*a - 2498023791133552294513515, + ....: 358777608829102441023422458989744*a + 1110881475104109582383304709231832166) sage: E = EllipticCurve(ainvs) sage: from sage.schemes.elliptic_curves.kraus import semi_global_minimal_model - sage: Emin, p = semi_global_minimal_model(E) # long time (25s) - sage: p # long time + sage: Emin, p = semi_global_minimal_model(E) # 25s + sage: p Fractional ideal (23567, a + 2270) - sage: p.norm() # long time + sage: p.norm() 23567 - sage: Emin.discriminant().norm().factor() # long time + sage: Emin.discriminant().norm().factor() 23567^12 """ c = E.global_minimality_class() diff --git a/src/sage/schemes/elliptic_curves/lseries_ell.py b/src/sage/schemes/elliptic_curves/lseries_ell.py index 45db560c861..6e1dfa18c52 100644 --- a/src/sage/schemes/elliptic_curves/lseries_ell.py +++ b/src/sage/schemes/elliptic_curves/lseries_ell.py @@ -661,17 +661,18 @@ def deriv_at1(self, k=None, prec=None): EXAMPLES:: sage: E = EllipticCurve('37a') - sage: E.lseries().deriv_at1() + sage: E.lseries().deriv_at1() # needs sage.symbolic (0.3059866, 0.000801045) - sage: E.lseries().deriv_at1(100) + sage: E.lseries().deriv_at1(100) # needs sage.symbolic (0.3059997738340523018204836833216764744526377745903, 1.52493e-45) - sage: E.lseries().deriv_at1(1000) + sage: E.lseries().deriv_at1(1000) # needs sage.symbolic (0.305999773834052301820483683321676474452637774590771998..., 2.75031e-449) With less numerical precision, the error is bounded by numerical accuracy:: - sage: L,err = E.lseries().deriv_at1(100, prec=64) - sage: L,err + sage: # needs sage.symbolic + sage: L, err = E.lseries().deriv_at1(100, prec=64) + sage: L, err (0.305999773834052302, 5.55318e-18) sage: parent(L) Real Field with 64 bits of precision @@ -681,12 +682,12 @@ def deriv_at1(self, k=None, prec=None): Rank 2 and rank 3 elliptic curves:: sage: E = EllipticCurve('389a1') - sage: E.lseries().deriv_at1() + sage: E.lseries().deriv_at1() # needs sage.symbolic (0.0000000, 0.000000) sage: E = EllipticCurve((1, 0, 1, -131, 558)) # curve 59450i1 - sage: E.lseries().deriv_at1() + sage: E.lseries().deriv_at1() # needs sage.symbolic (-0.00010911444, 0.142428) - sage: E.lseries().deriv_at1(4000) + sage: E.lseries().deriv_at1(4000) # needs sage.symbolic (6.990...e-50, 1.31318e-43) """ sqrtN = sqrt(self.__E.conductor()) diff --git a/src/sage/schemes/elliptic_curves/modular_parametrization.py b/src/sage/schemes/elliptic_curves/modular_parametrization.py index 891a9e0142f..501c17cd571 100644 --- a/src/sage/schemes/elliptic_curves/modular_parametrization.py +++ b/src/sage/schemes/elliptic_curves/modular_parametrization.py @@ -153,7 +153,7 @@ def __call__(self, z, prec=None): sage: E = EllipticCurve('37a') sage: phi = E.modular_parametrization() - sage: phi((sqrt(7)*I - 17)/74, 53) + sage: phi((sqrt(7)*I - 17)/74, 53) # needs sage.symbolic (...e-16 - ...e-16*I : ...e-16 + ...e-16*I : 1.00000000000000) Verify that the mapping is invariant under the action of `\Gamma_0(N)` @@ -212,10 +212,11 @@ def map_to_complex_numbers(self, z, prec=None): EXAMPLES:: + sage: # needs sage.symbolic sage: E = EllipticCurve('37a'); phi = E.modular_parametrization() sage: x = polygen(ZZ, 'x') - sage: tau = (sqrt(7)*I - 17)/74 # optional - sage.symbolic - sage: z = phi.map_to_complex_numbers(tau); z # optional - sage.symbolic + sage: tau = (sqrt(7)*I - 17)/74 + sage: z = phi.map_to_complex_numbers(tau); z 0.929592715285395 - 1.22569469099340*I sage: E.elliptic_exponential(z) (...e-16 - ...e-16*I : ...e-16 + ...e-16*I : 1.00000000000000) diff --git a/src/sage/schemes/elliptic_curves/padic_lseries.py b/src/sage/schemes/elliptic_curves/padic_lseries.py index a6ac5c30af5..96177ed417c 100644 --- a/src/sage/schemes/elliptic_curves/padic_lseries.py +++ b/src/sage/schemes/elliptic_curves/padic_lseries.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics r""" `p`-adic `L`-functions of elliptic curves diff --git a/src/sage/schemes/elliptic_curves/padics.py b/src/sage/schemes/elliptic_curves/padics.py index 51f7cc3db90..6f05c10e6b5 100644 --- a/src/sage/schemes/elliptic_curves/padics.py +++ b/src/sage/schemes/elliptic_curves/padics.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics # # All these methods are imported in EllipticCurve_rational_field, # so there is no reason to add this module to the documentation. @@ -643,7 +643,7 @@ def _multiple_to_make_good_reduction(E): li = [] for p in ps: np = u.valuation(p) - if Emin.discriminant() %p != 0: + if Emin.discriminant() % p != 0: li.append(Emin.Np(p) * p**(np-1)) elif Emin.has_additive_reduction(p): li.append(E.tamagawa_number(p) * p**np) @@ -652,7 +652,7 @@ def _multiple_to_make_good_reduction(E): else: # non split li.append(E.tamagawa_number(p) * (p+1) * p**(np-1)) otherbad = Integer(Emin.discriminant()).prime_divisors() - otherbad = [p for p in otherbad if u%p != 0 ] + otherbad = [p for p in otherbad if u % p != 0 ] li += [E.tamagawa_number(p) for p in otherbad] n2 = LCM(li) return n2 @@ -1107,12 +1107,13 @@ def padic_sigma(self, p, N=20, E2=None, check=False, check_hypotheses=True): Test that it returns consistent results over a range of precision:: - sage: max_N = 30 # get up to at least p^2 # long time - sage: E = EllipticCurve([1, 1, 1, 1, 1]) # long time - sage: p = 5 # long time - sage: E2 = E.padic_E2(5, max_N) # long time - sage: max_sigma = E.padic_sigma(p, max_N, E2=E2) # long time - sage: for N in range(3, max_N): # long time + sage: # long time + sage: max_N = 30 # get up to at least p^2 + sage: E = EllipticCurve([1, 1, 1, 1, 1]) + sage: p = 5 + sage: E2 = E.padic_E2(5, max_N) + sage: max_sigma = E.padic_sigma(p, max_N, E2=E2) + sage: for N in range(3, max_N): ....: sigma = E.padic_sigma(p, N, E2=E2) ....: assert sigma == max_sigma """ diff --git a/src/sage/schemes/elliptic_curves/period_lattice.py b/src/sage/schemes/elliptic_curves/period_lattice.py index 66a53cc571a..fe07917abaa 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice.py +++ b/src/sage/schemes/elliptic_curves/period_lattice.py @@ -17,13 +17,13 @@ EXAMPLES:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: E = EllipticCurve([0,1,0,a,a]) # needs sage.rings.number_field First we try a real embedding:: - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb); L # optional - sage.rings.number_field + sage: emb = K.embeddings(RealField())[0] # needs sage.rings.number_field + sage: L = E.period_lattice(emb); L # needs sage.rings.number_field Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: @@ -33,22 +33,22 @@ The first basis period is real:: - sage: L.basis() # optional - sage.rings.number_field + sage: L.basis() # needs sage.rings.number_field (3.81452977217855, 1.90726488608927 + 1.34047785962440*I) - sage: L.is_real() # optional - sage.rings.number_field + sage: L.is_real() # needs sage.rings.number_field True For a basis `\omega_1,\omega_2` normalised so that `\omega_1/\omega_2` is in the fundamental region of the upper half-plane, use the function ``normalised_basis()`` instead:: - sage: L.normalised_basis() # optional - sage.rings.number_field + sage: L.normalised_basis() # needs sage.rings.number_field (1.90726488608927 - 1.34047785962440*I, -1.90726488608927 - 1.34047785962440*I) Next a complex embedding:: - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb); L # optional - sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] # needs sage.rings.number_field + sage: L = E.period_lattice(emb); L # needs sage.rings.number_field Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: @@ -60,21 +60,23 @@ that `\tau = \omega_1/\omega_2` is in the fundamental region in the upper half plane:: - sage: w1, w2 = L.basis(); w1, w2 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: w1, w2 = L.basis(); w1, w2 (-1.37588604166076 - 2.58560946624443*I, -2.10339907847356 + 0.428378776460622*I) - sage: L.is_real() # optional - sage.rings.number_field + sage: L.is_real() False - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.387694505032876 + 1.30821088214407*I - sage: L.normalised_basis() # optional - sage.rings.number_field + sage: L.normalised_basis() (-1.37588604166076 - 2.58560946624443*I, -2.10339907847356 + 0.428378776460622*I) We test that bug :trac:`8415` (caused by a PARI bug fixed in v2.3.5) is OK:: - sage: E = EllipticCurve('37a') # optional - sage.rings.number_field - sage: K. = QuadraticField(-7) # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: EK.period_lattice(K.complex_embeddings()[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve('37a') + sage: K. = QuadraticField(-7) + sage: EK = E.change_ring(K) + sage: EK.period_lattice(K.complex_embeddings()[0]) Period lattice associated to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x over Number Field in a with defining polynomial x^2 + 7 with a = 2.645751311064591?*I @@ -180,11 +182,12 @@ def __init__(self, E, embedding=None): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = PeriodLattice_ell(E, emb); L # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = PeriodLattice_ell(E, emb); L Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: @@ -192,8 +195,8 @@ def __init__(self, E, embedding=None): To: Algebraic Real Field Defn: a |--> 1.259921049894873? - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = PeriodLattice_ell(E, emb); L # optional - sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] # needs sage.rings.number_field + sage: L = PeriodLattice_ell(E, emb); L # needs sage.rings.number_field Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: @@ -203,12 +206,13 @@ def __init__(self, E, embedding=None): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.period_lattice import PeriodLattice_ell - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = PeriodLattice_ell(E,emb) # optional - sage.rings.number_field - sage: L == loads(dumps(L)) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = PeriodLattice_ell(E,emb) + sage: L == loads(dumps(L)) True """ # First we cache the elliptic curve with this period lattice: @@ -280,13 +284,14 @@ def __richcmp__(self, other, op): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.period_lattice import PeriodLattice_ell sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: embs = K.embeddings(ComplexField()) # optional - sage.rings.number_field - sage: L1, L2, L3 = [PeriodLattice_ell(E, e) for e in embs] # optional - sage.rings.number_field - sage: L1 < L2 < L3 # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: embs = K.embeddings(ComplexField()) + sage: L1, L2, L3 = [PeriodLattice_ell(E, e) for e in embs] + sage: L1 < L2 < L3 True """ if not isinstance(other, PeriodLattice_ell): @@ -312,11 +317,12 @@ def __repr__(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb); L # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb); L Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 @@ -438,21 +444,23 @@ def basis(self, prec=None, algorithm='sage'): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.basis(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.basis(64) (3.81452977217854509, 1.90726488608927255 + 1.34047785962440202*I) - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: w1, w2 = L.basis(); w1, w2 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] + sage: L = E.period_lattice(emb) + sage: w1, w2 = L.basis(); w1, w2 (-1.37588604166076 - 2.58560946624443*I, -2.10339907847356 + 0.428378776460622*I) - sage: L.is_real() # optional - sage.rings.number_field + sage: L.is_real() False - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.387694505032876 + 1.30821088214407*I """ # We divide into two cases: (1) Q, or a number field with a @@ -540,23 +548,25 @@ def normalised_basis(self, prec=None, algorithm='sage'): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.normalised_basis(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.normalised_basis(64) (1.90726488608927255 - 1.34047785962440202*I, -1.90726488608927255 - 1.34047785962440202*I) - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: w1, w2 = L.normalised_basis(); w1, w2 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] + sage: L = E.period_lattice(emb) + sage: w1, w2 = L.normalised_basis(); w1, w2 (-1.37588604166076 - 2.58560946624443*I, -2.10339907847356 + 0.428378776460622*I) - sage: L.is_real() # optional - sage.rings.number_field + sage: L.is_real() False - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.387694505032876 + 1.30821088214407*I """ w1, w2 = self.basis(prec=prec, algorithm=algorithm) @@ -594,25 +604,27 @@ def tau(self, prec=None, algorithm='sage'): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: tau = L.tau(); tau # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: tau = L.tau(); tau -0.338718341018919 + 0.940887817679340*I - sage: tau.abs() # optional - sage.rings.number_field + sage: tau.abs() 1.00000000000000 - sage: -0.5 <= tau.real() <= 0.5 # optional - sage.rings.number_field + sage: -0.5 <= tau.real() <= 0.5 True - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: tau = L.tau(); tau # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] + sage: L = E.period_lattice(emb) + sage: tau = L.tau(); tau 0.387694505032876 + 1.30821088214407*I - sage: tau.abs() # optional - sage.rings.number_field + sage: tau.abs() 1.36444961115933 - sage: -0.5 <= tau.real() <= 0.5 # optional - sage.rings.number_field + sage: -0.5 <= tau.real() <= 0.5 True """ w1, w2 = self.normalised_basis(prec=prec, algorithm=algorithm) @@ -641,17 +653,18 @@ def _compute_periods_real(self, prec=None, algorithm='sage'): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: Ls = [E.period_lattice(e) for e in embs] # optional - sage.rings.number_field - sage: [L.is_real() for L in Ls] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: embs = K.embeddings(CC) + sage: Ls = [E.period_lattice(e) for e in embs] + sage: [L.is_real() for L in Ls] [False, False, True] - sage: Ls[2]._compute_periods_real(100) # optional - sage.rings.number_field + sage: Ls[2]._compute_periods_real(100) (3.8145297721785450936365098936, 1.9072648860892725468182549468 + 1.3404778596244020196600112394*I) - sage: Ls[2]._compute_periods_real(100, algorithm='pari') # optional - sage.rings.number_field + sage: Ls[2]._compute_periods_real(100, algorithm='pari') (3.8145297721785450936365098936, 1.9072648860892725468182549468 - 1.3404778596244020196600112394*I) """ @@ -712,33 +725,35 @@ def _compute_periods_complex(self, prec=None, normalise=True): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: Ls = [E.period_lattice(e) for e in embs] # optional - sage.rings.number_field - sage: [L.is_real() for L in Ls] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: embs = K.embeddings(CC) + sage: Ls = [E.period_lattice(e) for e in embs] + sage: [L.is_real() for L in Ls] [False, False, True] - sage: L = Ls[0] # optional - sage.rings.number_field - sage: w1,w2 = L._compute_periods_complex(100); w1,w2 # optional - sage.rings.number_field + sage: L = Ls[0] + sage: w1,w2 = L._compute_periods_complex(100); w1,w2 (-1.3758860416607626645495991458 - 2.5856094662444337042877901304*I, -2.1033990784735587243397865076 + 0.42837877646062187766760569686*I) - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.38769450503287609349437509561 + 1.3082108821440725664008561928*I - sage: tau.real() # optional - sage.rings.number_field + sage: tau.real() 0.38769450503287609349437509561 - sage: tau.abs() # optional - sage.rings.number_field + sage: tau.abs() 1.3644496111593345713923386773 Without normalisation:: - sage: w1,w2 = L._compute_periods_complex(normalise=False); w1,w2 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: w1,w2 = L._compute_periods_complex(normalise=False); w1,w2 (2.10339907847356 - 0.428378776460622*I, 0.727513036812796 - 3.01398824270506*I) - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.293483964608883 + 0.627038168678760*I - sage: tau.real() # optional - sage.rings.number_field + sage: tau.real() 0.293483964608883 - sage: tau.abs() # > 1 # optional - sage.rings.number_field + sage: tau.abs() # > 1 0.692321964451917 """ if prec is None: @@ -775,19 +790,20 @@ def is_real(self): :: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,i,2*i]) # optional - sage.rings.number_field - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.is_real() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve(K, [0,0,0,i,2*i]) + sage: emb = K.embeddings(ComplexField())[0] + sage: L = E.period_lattice(emb) + sage: L.is_real() False :: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: [E.period_lattice(emb).is_real() for emb in K.embeddings(CC)] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: E = EllipticCurve([0,1,0,a,a]) # needs sage.rings.number_field + sage: [E.period_lattice(emb).is_real() for emb in K.embeddings(CC)] # needs sage.rings.number_field [False, False, True] ALGORITHM: @@ -859,12 +875,13 @@ def real_period(self, prec=None, algorithm='sage'): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.real_period(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.real_period(64) 3.81452977217854509 """ if self.is_real(): @@ -921,12 +938,13 @@ def omega(self, prec=None, bsd_normalise=False): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.omega(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.omega(64) 3.81452977217854509 A complex example (taken from J.E.Cremona and E.Whitley, @@ -934,14 +952,15 @@ def omega(self, prec=None, bsd_normalise=False): quadratic fields*, Mathematics of Computation 62 No. 205 (1994), 407-429). See :trac:`29645` and :trac:`29782`:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1-i,i,-i,0]) # optional - sage.rings.number_field - sage: L = E.period_lattice(K.embeddings(CC)[0]) # optional - sage.rings.number_field - sage: L.omega() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0,1-i,i,-i,0]) + sage: L = E.period_lattice(K.embeddings(CC)[0]) + sage: L.omega() 8.80694160502647 - sage: L.omega(prec=200) # optional - sage.rings.number_field + sage: L.omega(prec=200) 8.8069416050264741493250743632295462227858630765392114070032 - sage: L.omega(bsd_normalise=True) # optional - sage.rings.number_field + sage: L.omega(bsd_normalise=True) 17.6138832100529 """ if self.is_real(): @@ -979,12 +998,13 @@ def basis_matrix(self, prec=None, normalised=False): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.basis_matrix(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.basis_matrix(64) [ 3.81452977217854509 0.000000000000000000] [ 1.90726488608927255 1.34047785962440202] @@ -1037,6 +1057,7 @@ def complex_area(self, prec=None): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: embs = K.embeddings(ComplexField()) @@ -1104,15 +1125,16 @@ def curve(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(K.embeddings(RealField())[0]) # optional - sage.rings.number_field - sage: L.curve() is E # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(K.embeddings(RealField())[0]) + sage: L.curve() is E True - sage: L = E.period_lattice(K.embeddings(ComplexField())[0]) # optional - sage.rings.number_field - sage: L.curve() is E # optional - sage.rings.number_field + sage: L = E.period_lattice(K.embeddings(ComplexField())[0]) # needs sage.rings.number_field + sage: L.curve() is E # needs sage.rings.number_field True """ return self.E @@ -1134,20 +1156,21 @@ def ei(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(K.embeddings(RealField())[0]) # optional - sage.rings.number_field - sage: x1,x2,x3 = L.ei() # optional - sage.rings.number_field - sage: abs(x1.real()) + abs(x2.real()) < 1e-14 # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(K.embeddings(RealField())[0]) + sage: x1,x2,x3 = L.ei() + sage: abs(x1.real()) + abs(x2.real()) < 1e-14 True - sage: x1.imag(), x2.imag(), x3 # optional - sage.rings.number_field + sage: x1.imag(), x2.imag(), x3 (-1.122462048309373?, 1.122462048309373?, -1.000000000000000?) :: - sage: L = E.period_lattice(K.embeddings(ComplexField())[0]) # optional - sage.rings.number_field - sage: L.ei() # optional - sage.rings.number_field + sage: L = E.period_lattice(K.embeddings(ComplexField())[0]) # needs sage.rings.number_field + sage: L.ei() # needs sage.rings.number_field [-1.000000000000000? + 0.?e-1...*I, -0.9720806486198328? - 0.561231024154687?*I, 0.9720806486198328? + 0.561231024154687?*I] @@ -1350,45 +1373,48 @@ def e_log_RC(self, xP, yP, prec=None, reduce=True): A number field example:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(v) # optional - sage.rings.number_field - sage: P = E.lift_x(1/3*a^2 + a + 5/3) # optional - sage.rings.number_field - sage: L(P) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.real_places()[0] + sage: L = E.period_lattice(v) + sage: P = E.lift_x(1/3*a^2 + a + 5/3) + sage: L(P) 3.51086196882538 - sage: xP, yP = [v(c) for c in P.xy()] # optional - sage.rings.number_field - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: xP, yP = [v(c) for c in P.xy()] + sage: L.e_log_RC(xP, yP) 3.51086196882538 Elliptic logs of real points which do not come from algebraic points:: - sage: ER = EllipticCurve([v(ai) for ai in E.a_invariants()]) # optional - sage.rings.number_field - sage: P = ER.lift_x(12.34) # optional - sage.rings.number_field - sage: xP, yP = P.xy() # optional - sage.rings.number_field - sage: xP, yP # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: ER = EllipticCurve([v(ai) for ai in E.a_invariants()]) + sage: P = ER.lift_x(12.34) + sage: xP, yP = P.xy() + sage: xP, yP (12.3400000000000, -43.3628968710567) - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: L.e_log_RC(xP, yP) 0.284656841192041 - sage: xP, yP = ER.lift_x(0).xy() # optional - sage.rings.number_field - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: xP, yP = ER.lift_x(0).xy() + sage: L.e_log_RC(xP, yP) 1.34921304541057 Elliptic logs of complex points:: - sage: v = K.complex_embeddings()[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(v) # optional - sage.rings.number_field - sage: P = E.lift_x(1/3*a^2 + a + 5/3) # optional - sage.rings.number_field - sage: L(P) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: v = K.complex_embeddings()[0] + sage: L = E.period_lattice(v) + sage: P = E.lift_x(1/3*a^2 + a + 5/3) + sage: L(P) 1.68207104397706 - 1.87873661686704*I - sage: xP, yP = [v(c) for c in P.xy()] # optional - sage.rings.number_field - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: xP, yP = [v(c) for c in P.xy()] + sage: L.e_log_RC(xP, yP) 1.68207104397706 - 1.87873661686704*I - sage: EC = EllipticCurve([v(ai) for ai in E.a_invariants()]) # optional - sage.rings.number_field - sage: xP, yP = EC.lift_x(0).xy() # optional - sage.rings.number_field - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: EC = EllipticCurve([v(ai) for ai in E.a_invariants()]) + sage: xP, yP = EC.lift_x(0).xy() + sage: L.e_log_RC(xP, yP) 2.06711431204080 - 1.73451485683471*I """ if prec is None: @@ -1583,22 +1609,23 @@ def elliptic_logarithm(self, P, prec=None, reduce=True): Some complex examples, taken from the paper by Cremona and Thongjunthug:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: a4 = 9*i - 10 # optional - sage.rings.number_field - sage: a6 = 21 - i # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,a4,a6]) # optional - sage.rings.number_field - sage: e1 = 3 - 2*i; e2 = 1 + i; e3 = -4 + i # optional - sage.rings.number_field - sage: emb = K.embeddings(CC)[1] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: P = E(2 - i, 4 + 2*i) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: a4 = 9*i - 10 + sage: a6 = 21 - i + sage: E = EllipticCurve([0,0,0,a4,a6]) + sage: e1 = 3 - 2*i; e2 = 1 + i; e3 = -4 + i + sage: emb = K.embeddings(CC)[1] + sage: L = E.period_lattice(emb) + sage: P = E(2 - i, 4 + 2*i) By default, the output is reduced with respect to the normalised lattice basis, so that its coordinates with respect to that basis lie in the interval [0,1):: - sage: z = L.elliptic_logarithm(P, prec=100); z # optional - sage.rings.number_field + sage: z = L.elliptic_logarithm(P, prec=100); z # needs sage.rings.number_field 0.70448375537782208460499649302 - 0.79246725643650979858266018068*I - sage: L.coordinates(z) # optional - sage.rings.number_field + sage: L.coordinates(z) # needs sage.rings.number_field (0.46247636364807931766105406092, 0.79497588726808704200760395829) Using ``reduce=False`` this step can be omitted. In this case @@ -1606,76 +1633,78 @@ def elliptic_logarithm(self, P, prec=None, reduce=True): this is not guaranteed. This option is mainly for testing purposes:: - sage: z = L.elliptic_logarithm(P, prec=100, reduce=False); z # optional - sage.rings.number_field + sage: z = L.elliptic_logarithm(P, prec=100, reduce=False); z # needs sage.rings.number_field 0.57002153834710752778063503023 + 0.46476340520469798857457031393*I - sage: L.coordinates(z) # optional - sage.rings.number_field + sage: L.coordinates(z) # needs sage.rings.number_field (0.46247636364807931766105406092, -0.20502411273191295799239604171) The elliptic logs of the 2-torsion points are half-periods:: - sage: L.elliptic_logarithm(E(e1, 0), prec=100) # optional - sage.rings.number_field + sage: L.elliptic_logarithm(E(e1, 0), prec=100) # needs sage.rings.number_field 0.64607575874356525952487867052 + 0.22379609053909448304176885364*I - sage: L.elliptic_logarithm(E(e2, 0), prec=100) # optional - sage.rings.number_field + sage: L.elliptic_logarithm(E(e2, 0), prec=100) # needs sage.rings.number_field 0.71330686725892253793705940192 - 0.40481924028150941053684639367*I - sage: L.elliptic_logarithm(E(e3, 0), prec=100) # optional - sage.rings.number_field + sage: L.elliptic_logarithm(E(e3, 0), prec=100) # needs sage.rings.number_field 0.067231108515357278412180731396 - 0.62861533082060389357861524731*I We check this by doubling and seeing that the resulting coordinates are integers:: - sage: L.coordinates(2*L.elliptic_logarithm(E(e1, 0), prec=100)) # optional - sage.rings.number_field + sage: L.coordinates(2*L.elliptic_logarithm(E(e1, 0), prec=100)) # needs sage.rings.number_field (1.0000000000000000000000000000, 0.00000000000000000000000000000) - sage: L.coordinates(2*L.elliptic_logarithm(E(e2, 0), prec=100)) # optional - sage.rings.number_field + sage: L.coordinates(2*L.elliptic_logarithm(E(e2, 0), prec=100)) # needs sage.rings.number_field (1.0000000000000000000000000000, 1.0000000000000000000000000000) - sage: L.coordinates(2*L.elliptic_logarithm(E(e3, 0), prec=100)) # optional - sage.rings.number_field + sage: L.coordinates(2*L.elliptic_logarithm(E(e3, 0), prec=100)) # needs sage.rings.number_field (0.00000000000000000000000000000, 1.0000000000000000000000000000) :: - sage: a4 = -78*i + 104 # optional - sage.rings.number_field - sage: a6 = -216*i - 312 # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,a4,a6]) # optional - sage.rings.number_field - sage: emb = K.embeddings(CC)[1] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: P = E(3 + 2*i, 14 - 7*i) # optional - sage.rings.number_field - sage: L.elliptic_logarithm(P) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: a4 = -78*i + 104 + sage: a6 = -216*i - 312 + sage: E = EllipticCurve([0,0,0,a4,a6]) + sage: emb = K.embeddings(CC)[1] + sage: L = E.period_lattice(emb) + sage: P = E(3 + 2*i, 14 - 7*i) + sage: L.elliptic_logarithm(P) 0.297147783912228 - 0.546125549639461*I - sage: L.coordinates(L.elliptic_logarithm(P)) # optional - sage.rings.number_field + sage: L.coordinates(L.elliptic_logarithm(P)) (0.628653378040238, 0.371417754610223) - sage: e1 = 1 + 3*i; e2 = -4 - 12*i; e3 = -e1 - e2 # optional - sage.rings.number_field - sage: L.coordinates(L.elliptic_logarithm(E(e1, 0))) # optional - sage.rings.number_field + sage: e1 = 1 + 3*i; e2 = -4 - 12*i; e3 = -e1 - e2 + sage: L.coordinates(L.elliptic_logarithm(E(e1, 0))) (0.500000000000000, 0.500000000000000) - sage: L.coordinates(L.elliptic_logarithm(E(e2, 0))) # optional - sage.rings.number_field + sage: L.coordinates(L.elliptic_logarithm(E(e2, 0))) (1.00000000000000, 0.500000000000000) - sage: L.coordinates(L.elliptic_logarithm(E(e3, 0))) # optional - sage.rings.number_field + sage: L.coordinates(L.elliptic_logarithm(E(e3, 0))) (0.500000000000000, 0.000000000000000) TESTS: See :trac:`10026` and :trac:`11767`:: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, -1, 1, -3*w - 4, 3*w + 4]) # optional - sage.rings.number_field - sage: T = E.simon_two_descent(lim1=20, lim3=5, limtriv=20) # optional - sage.rings.number_field - sage: P, Q = T[2] # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: Lambda = E.period_lattice(embs[0]) # optional - sage.rings.number_field - sage: Lambda.elliptic_logarithm(P, 100) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: E = EllipticCurve([0, -1, 1, -3*w - 4, 3*w + 4]) + sage: T = E.simon_two_descent(lim1=20, lim3=5, limtriv=20) + sage: P, Q = T[2] + sage: embs = K.embeddings(CC) + sage: Lambda = E.period_lattice(embs[0]) + sage: Lambda.elliptic_logarithm(P, 100) 4.7100131126199672766973600998 sage: R. = QQ[] - sage: K. = NumberField(x^2 + x + 5) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,1,-3,-5]) # optional - sage.rings.number_field - sage: P = E([0,a]) # optional - sage.rings.number_field - sage: Lambda = P.curve().period_lattice(K.embeddings(ComplexField(600))[0]) # optional - sage.rings.number_field - sage: Lambda.elliptic_logarithm(P, prec=600) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + x + 5) + sage: E = EllipticCurve(K, [0,0,1,-3,-5]) + sage: P = E([0,a]) + sage: Lambda = P.curve().period_lattice(K.embeddings(ComplexField(600))[0]) + sage: Lambda.elliptic_logarithm(P, prec=600) -0.842248166487739393375018008381693990800588864069506187033873183845246233548058477561706400464057832396643843146464236956684557207157300006542470428493573195030603817094900751609464 - 0.571366031453267388121279381354098224265947866751130917440598461117775339240176310729173301979590106474259885638797913383502735083088736326391919063211421189027226502851390118943491*I - sage: K. = QuadraticField(-5) # optional - sage.rings.number_field - sage: E = EllipticCurve([1,1,a,a,0]) # optional - sage.rings.number_field - sage: P = E(0, 0) # optional - sage.rings.number_field - sage: L = P.curve().period_lattice(K.embeddings(ComplexField())[0]) # optional - sage.rings.number_field - sage: L.elliptic_logarithm(P, prec=500) # optional - sage.rings.number_field + sage: K. = QuadraticField(-5) + sage: E = EllipticCurve([1,1,a,a,0]) + sage: P = E(0, 0) + sage: L = P.curve().period_lattice(K.embeddings(ComplexField())[0]) + sage: L.elliptic_logarithm(P, prec=500) 1.17058357737548897849026170185581196033579563441850967539191867385734983296504066660506637438866628981886518901958717288150400849746892393771983141354 - 1.13513899565966043682474529757126359416758251309237866586896869548539516543734207347695898664875799307727928332953834601460994992792519799260968053875*I - sage: L.elliptic_logarithm(P, prec=1000) # optional - sage.rings.number_field + sage: L.elliptic_logarithm(P, prec=1000) 1.17058357737548897849026170185581196033579563441850967539191867385734983296504066660506637438866628981886518901958717288150400849746892393771983141354014895386251320571643977497740116710952913769943240797618468987304985625823413440999754037939123032233879499904283600304184828809773650066658885672885 - 1.13513899565966043682474529757126359416758251309237866586896869548539516543734207347695898664875799307727928332953834601460994992792519799260968053875387282656993476491590607092182964878750169490985439873220720963653658829712494879003124071110818175013453207439440032582917366703476398880865439217473*I """ if not P.curve() is self.E: @@ -1748,53 +1777,56 @@ def elliptic_exponential(self, z, to_curve=True): Examples over number fields:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: E = EllipticCurve('37a') # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: Li = [EK.period_lattice(e) for e in embs] # optional - sage.rings.number_field - sage: P = EK(-1, -1) # optional - sage.rings.number_field - sage: Q = EK(a - 1, 1 - a^2) # optional - sage.rings.number_field - sage: zi = [L.elliptic_logarithm(P) for L in Li] # optional - sage.rings.number_field - sage: [c.real() for c in Li[0].elliptic_exponential(zi[0])] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: embs = K.embeddings(CC) + sage: E = EllipticCurve('37a') + sage: EK = E.change_ring(K) + sage: Li = [EK.period_lattice(e) for e in embs] + sage: P = EK(-1, -1) + sage: Q = EK(a - 1, 1 - a^2) + sage: zi = [L.elliptic_logarithm(P) for L in Li] + sage: [c.real() for c in Li[0].elliptic_exponential(zi[0])] [-1.00000000000000, -1.00000000000000, 1.00000000000000] - sage: [c.real() for c in Li[0].elliptic_exponential(zi[1])] # optional - sage.rings.number_field + sage: [c.real() for c in Li[0].elliptic_exponential(zi[1])] [-1.00000000000000, -1.00000000000000, 1.00000000000000] - sage: [c.real() for c in Li[0].elliptic_exponential(zi[2])] # optional - sage.rings.number_field + sage: [c.real() for c in Li[0].elliptic_exponential(zi[2])] [-1.00000000000000, -1.00000000000000, 1.00000000000000] - sage: zi = [L.elliptic_logarithm(Q) for L in Li] # optional - sage.rings.number_field - sage: Li[0].elliptic_exponential(zi[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: zi = [L.elliptic_logarithm(Q) for L in Li] + sage: Li[0].elliptic_exponential(zi[0]) (-1.62996052494744 - 1.09112363597172*I : 1.79370052598410 - 1.37472963699860*I : 1.00000000000000) - sage: [embs[0](c) for c in Q] # optional - sage.rings.number_field + sage: [embs[0](c) for c in Q] [-1.62996052494744 - 1.09112363597172*I, 1.79370052598410 - 1.37472963699860*I, 1.00000000000000] - sage: Li[1].elliptic_exponential(zi[1]) # optional - sage.rings.number_field + sage: Li[1].elliptic_exponential(zi[1]) (-1.62996052494744 + 1.09112363597172*I : 1.79370052598410 + 1.37472963699860*I : 1.00000000000000) - sage: [embs[1](c) for c in Q] # optional - sage.rings.number_field + sage: [embs[1](c) for c in Q] [-1.62996052494744 + 1.09112363597172*I, 1.79370052598410 + 1.37472963699860*I, 1.00000000000000] - sage: [c.real() for c in Li[2].elliptic_exponential(zi[2])] # optional - sage.rings.number_field + sage: [c.real() for c in Li[2].elliptic_exponential(zi[2])] [0.259921049894873, -0.587401051968199, 1.00000000000000] - sage: [embs[2](c) for c in Q] # optional - sage.rings.number_field + sage: [embs[2](c) for c in Q] [0.259921049894873, -0.587401051968200, 1.00000000000000] Test to show that :trac:`8820` is fixed:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('37a') - sage: K. = QuadraticField(-5) # optional - sage.rings.number_field - sage: L = E.change_ring(K).period_lattice(K.places()[0]) # optional - sage.rings.number_field - sage: L.elliptic_exponential(CDF(.1,.1)) # optional - sage.rings.number_field + sage: K. = QuadraticField(-5) + sage: L = E.change_ring(K).period_lattice(K.places()[0]) + sage: L.elliptic_exponential(CDF(.1,.1)) (0.0000142854026029... - 49.9960001066650*I : 249.520141250950 + 250.019855549131*I : 1.00000000000000) - sage: L.elliptic_exponential(CDF(.1,.1), to_curve=False) # optional - sage.rings.number_field + sage: L.elliptic_exponential(CDF(.1,.1), to_curve=False) (0.0000142854026029447 - 49.9960001066650*I, 500.040282501900 + 500.039711098263*I) @@ -1809,22 +1841,24 @@ def elliptic_exponential(self, z, to_curve=True): :: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('37a') - sage: K. = QuadraticField(-5) # optional - sage.rings.number_field - sage: L = E.change_ring(K).period_lattice(K.places()[0]) # optional - sage.rings.number_field - sage: P = L.elliptic_exponential(0); P # optional - sage.rings.number_field + sage: K. = QuadraticField(-5) + sage: L = E.change_ring(K).period_lattice(K.places()[0]) + sage: P = L.elliptic_exponential(0); P (0.000000000000000 : 1.00000000000000 : 0.000000000000000) - sage: P.parent() # optional - sage.rings.number_field + sage: P.parent() Abelian group of points on Elliptic Curve defined by y^2 + 1.00000000000000*y = x^3 + (-1.00000000000000)*x over Complex Field with 53 bits of precision Very small `z` are handled properly (see :trac:`8820`):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,a,0]) # optional - sage.rings.number_field - sage: L = E.period_lattice(K.complex_embeddings()[0]) # optional - sage.rings.number_field - sage: L.elliptic_exponential(1e-100) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0,0,0,a,0]) + sage: L = E.period_lattice(K.complex_embeddings()[0]) + sage: L.elliptic_exponential(1e-100) (0.000000000000000 : 1.00000000000000 : 0.000000000000000) The elliptic exponential of `z` is returned as (0 : 1 : 0) if @@ -1833,9 +1867,9 @@ def elliptic_exponential(self, z, to_curve=True): sage: (100/log(2.0,10))/0.8 415.241011860920 - sage: L.elliptic_exponential((RealField(415)(1e-100))).is_zero() # optional - sage.rings.number_field + sage: L.elliptic_exponential((RealField(415)(1e-100))).is_zero() # needs sage.rings.number_field True - sage: L.elliptic_exponential((RealField(420)(1e-100))).is_zero() # optional - sage.rings.number_field + sage: L.elliptic_exponential((RealField(420)(1e-100))).is_zero() # needs sage.rings.number_field False """ C = z.parent() @@ -1919,6 +1953,7 @@ def reduce_tau(tau): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage.symbolic sage: from sage.schemes.elliptic_curves.period_lattice import reduce_tau sage: reduce_tau(CC(1.23,3.45)) (0.230000000000000 + 3.45000000000000*I, [1, -1, 0, 1]) @@ -1966,6 +2001,7 @@ def normalise_periods(w1, w2): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage.symbolic sage: from sage.schemes.elliptic_curves.period_lattice import reduce_tau, normalise_periods sage: w1 = CC(1.234, 3.456) sage: w2 = CC(1.234, 3.456000001) @@ -2007,6 +2043,7 @@ def extended_agm_iteration(a, b, c): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: from sage.schemes.elliptic_curves.period_lattice import extended_agm_iteration sage: extended_agm_iteration(RR(1), RR(2), RR(3)) (1.45679103104691, 1.45679103104691, 3.21245294970054) @@ -2017,7 +2054,7 @@ def extended_agm_iteration(a, b, c): TESTS:: - sage: extended_agm_iteration(1,2,3) + sage: extended_agm_iteration(1,2,3) # needs sage.rings.real_mpfr Traceback (most recent call last): ... ValueError: values must be real or complex numbers diff --git a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx index 0d24651f4c1..b0914d6347a 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx +++ b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.complex_double sage.symbolic r""" Regions in fundamental domains of period lattices @@ -54,12 +55,12 @@ cdef class PeriodicRegion: sage: import numpy as np sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion sage: S = PeriodicRegion(CDF(2), CDF(2*I), np.zeros((4, 4))) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 1 graphics primitive sage: data = np.zeros((4, 4)) sage: data[1,1] = True sage: S = PeriodicRegion(CDF(2), CDF(2*I+1), data) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 5 graphics primitives """ if data.dtype is not np.int8: @@ -250,16 +251,16 @@ cdef class PeriodicRegion: sage: data = np.zeros((4, 4)) sage: data[1,1] = True sage: S = PeriodicRegion(CDF(1), CDF(I + 1/2), data) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 5 graphics primitives - sage: S.expand().plot() + sage: S.expand().plot() # needs sage.plot Graphics object consisting of 13 graphics primitives sage: S.expand().data array([[1, 1, 1, 0], [1, 1, 1, 0], [1, 1, 1, 0], [0, 0, 0, 0]], dtype=int8) - sage: S.expand(corners=False).plot() + sage: S.expand(corners=False).plot() # needs sage.plot Graphics object consisting of 13 graphics primitives sage: S.expand(corners=False).data array([[0, 1, 0, 0], @@ -298,9 +299,9 @@ cdef class PeriodicRegion: sage: data = np.zeros((10, 10)) sage: data[1:4,1:4] = True sage: S = PeriodicRegion(CDF(1), CDF(I + 1/2), data) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 13 graphics primitives - sage: S.contract().plot() + sage: S.contract().plot() # needs sage.plot Graphics object consisting of 5 graphics primitives sage: S.contract().data.sum() 1 @@ -376,11 +377,11 @@ cdef class PeriodicRegion: sage: data[2:6, 2] = True sage: data[3, 3] = True sage: S = PeriodicRegion(CDF(1), CDF(I + 1/2), data) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 29 graphics primitives - sage: (S / 2).plot() + sage: (S / 2).plot() # needs sage.plot Graphics object consisting of 57 graphics primitives - sage: (S / 3).plot() + sage: (S / 3).plot() # needs sage.plot Graphics object consisting of 109 graphics primitives sage: (S / 2 / 3) == (S / 6) == (S / 3 / 2) True @@ -619,7 +620,7 @@ cdef class PeriodicRegion: sage: S = PeriodicRegion(CDF(1), CDF(I+1/2), data) sage: S.innermost_point() 0.375 + 0.25*I - sage: S.plot() + point(S.innermost_point()) + sage: S.plot() + point(S.innermost_point()) # needs sage.plot Graphics object consisting of 24 graphics primitives """ if self.is_empty(): @@ -646,7 +647,7 @@ cdef class PeriodicRegion: sage: data[2:5, 2] = True sage: data[3, 3] = True sage: S = PeriodicRegion(CDF(1), CDF(I + 1/2), data) - sage: plot(S) + plot(S.expand(), rgbcolor=(1, 0, 1), thickness=2) + sage: plot(S) + plot(S.expand(), rgbcolor=(1, 0, 1), thickness=2) # needs sage.plot Graphics object consisting of 46 graphics primitives """ from sage.plot.line import line diff --git a/src/sage/schemes/elliptic_curves/saturation.py b/src/sage/schemes/elliptic_curves/saturation.py index c75972e7f02..095b5b1be12 100644 --- a/src/sage/schemes/elliptic_curves/saturation.py +++ b/src/sage/schemes/elliptic_curves/saturation.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings sage.rings.number_field +# sage.doctest: needs sage.rings.finite_rings sage.rings.number_field r""" Saturation of Mordell-Weil groups of elliptic curves over number fields diff --git a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py index 16fd424bde6..57ff015a2b2 100644 --- a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py +++ b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py @@ -446,9 +446,9 @@ def __init__(self, E=None, urst=None, F=None): Check for :trac:`33215`:: sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E = EllipticCurve(GF(71^2), [5,5]) # optional - sage.rings.finite_rings - sage: iso = WeierstrassIsomorphism(E, (1,2,3,4)) # optional - sage.rings.finite_rings - sage: ~iso # indirect doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(71^2), [5,5]) # needs sage.rings.finite_rings + sage: iso = WeierstrassIsomorphism(E, (1,2,3,4)) # needs sage.rings.finite_rings + sage: ~iso # indirect doctest # needs sage.rings.finite_rings Elliptic-curve morphism: From: Elliptic Curve defined by y^2 + 6*x*y + 8*y = x^3 + 68*x^2 + 64*x + 7 over Finite Field in z2 of size 71^2 To: Elliptic Curve defined by y^2 = x^3 + 5*x + 5 over Finite Field in z2 of size 71^2 @@ -456,7 +456,7 @@ def __init__(self, E=None, urst=None, F=None): Test for :trac:`33312`:: - sage: type(iso.degree()) # optional - sage.rings.finite_rings + sage: type(iso.degree()) # needs sage.rings.finite_rings """ from .ell_generic import is_EllipticCurve @@ -535,16 +535,16 @@ def _comparison_impl(left, right, op): sage: w1 == w2 False - sage: E = EllipticCurve_from_j(GF(7)(0)) # optional - sage.rings.finite_rings - sage: F = E.change_weierstrass_model(2,3,4,5) # optional - sage.rings.finite_rings - sage: a = E.isomorphisms(F) # optional - sage.rings.finite_rings - sage: b = [w*a[0] for w in F.automorphisms()] # optional - sage.rings.finite_rings - sage: b.sort() # optional - sage.rings.finite_rings - sage: a == b # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(7)(0)) + sage: F = E.change_weierstrass_model(2,3,4,5) + sage: a = E.isomorphisms(F) + sage: b = [w*a[0] for w in F.automorphisms()] + sage: b.sort() + sage: a == b True - sage: c = [a[0]*w for w in E.automorphisms()] # optional - sage.rings.finite_rings - sage: c.sort() # optional - sage.rings.finite_rings - sage: a == c # optional - sage.rings.finite_rings + sage: c = [a[0]*w for w in E.automorphisms()] + sage: c.sort() + sage: a == c True """ if not isinstance(left, WeierstrassIsomorphism) or not isinstance(right, WeierstrassIsomorphism): @@ -589,18 +589,19 @@ def _eval(self, P): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E = EllipticCurve([i, 0]); E # optional - sage.rings.number_field + sage: E = EllipticCurve([i, 0]); E Elliptic Curve defined by y^2 = x^3 + I*x over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - sage: iso = WeierstrassIsomorphism(E, (i,1,2,3)) # optional - sage.rings.number_field - sage: P = E.change_ring(QQbar).lift_x(QQbar.random_element()) # optional - sage.rings.number_field - sage: Q = iso._eval(P) # optional - sage.rings.number_field - sage: Q.curve() # optional - sage.rings.number_field + sage: iso = WeierstrassIsomorphism(E, (i,1,2,3)) + sage: P = E.change_ring(QQbar).lift_x(QQbar.random_element()) + sage: Q = iso._eval(P) + sage: Q.curve() Elliptic Curve defined by y^2 + (-4*I)*x*y + 6*I*y = x^3 + x^2 + (I-9)*x + (-I+8) over Algebraic Field - sage: y = next(filter(bool, iter(QQbar.random_element, None))) # sample until nonzero # optional - sage.rings.number_field - sage: iso._eval((0, y, 0)) == 0 # optional - sage.rings.number_field + sage: y = next(filter(bool, iter(QQbar.random_element, None))) # sample until nonzero + sage: iso._eval((0, y, 0)) == 0 True """ if self._domain.defining_polynomial()(*P): @@ -637,14 +638,15 @@ def __call__(self, P): Check that copying the order over works:: - sage: E = EllipticCurve(GF(431^2), [1,0]) # optional - sage.rings.finite_rings - sage: i = next(a for a in E.automorphisms() if a^2 == -a^24) # optional - sage.rings.finite_rings - sage: P,_ = E.gens() # optional - sage.rings.finite_rings - sage: P._order # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(431^2), [1,0]) + sage: i = next(a for a in E.automorphisms() if a^2 == -a^24) + sage: P,_ = E.gens() + sage: P._order 432 - sage: i(P)._order # optional - sage.rings.finite_rings + sage: i(P)._order 432 - sage: E(i(P))._order # optional - sage.rings.finite_rings + sage: E(i(P))._order 432 """ if P[2] == 0: @@ -768,11 +770,12 @@ def rational_maps(self): :: - sage: E = EllipticCurve(GF(65537), [1,1,1,1,1]) # optional - sage.rings.finite_rings - sage: w = E.isomorphism_to(E.short_weierstrass_model()) # optional - sage.rings.finite_rings - sage: f,g = w.rational_maps() # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: w(P).xy() == (f(P.xy()), g(P.xy())) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,1,1,1,1]) + sage: w = E.isomorphism_to(E.short_weierstrass_model()) + sage: f,g = w.rational_maps() + sage: P = E.random_point() + sage: w(P).xy() == (f(P.xy()), g(P.xy())) True TESTS: @@ -855,8 +858,8 @@ def is_separable(self): EXAMPLES:: - sage: E = EllipticCurve(GF(31337), [0,1]) # optional - sage.rings.finite_rings - sage: {f.is_separable() for f in E.automorphisms()} # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31337), [0,1]) # needs sage.rings.finite_rings + sage: {f.is_separable() for f in E.automorphisms()} # needs sage.rings.finite_rings {True} """ return True @@ -870,9 +873,9 @@ def dual(self): EXAMPLES:: sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E = EllipticCurve(QuadraticField(-3), [0,1]) # optional - sage.rings.number_field - sage: w = WeierstrassIsomorphism(E, (CyclotomicField(3).gen(),0,0,0)) # optional - sage.rings.number_field - sage: (w.dual() * w).rational_maps() # optional - sage.rings.number_field + sage: E = EllipticCurve(QuadraticField(-3), [0,1]) # needs sage.rings.number_field + sage: w = WeierstrassIsomorphism(E, (CyclotomicField(3).gen(),0,0,0)) # needs sage.rings.number_field + sage: (w.dual() * w).rational_maps() # needs sage.rings.number_field (x, y) :: @@ -906,23 +909,24 @@ def __neg__(self): :: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1]) # optional - sage.rings.number_field - sage: w = WeierstrassIsomorphism(E, (CyclotomicField(3).gen(),0,0,0)) # optional - sage.rings.number_field - sage: w.tuple() # optional - sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: E = EllipticCurve(K, [0,1]) + sage: w = WeierstrassIsomorphism(E, (CyclotomicField(3).gen(),0,0,0)) + sage: w.tuple() (1/2*a - 1/2, 0, 0, 0) - sage: (-w).tuple() # optional - sage.rings.number_field + sage: (-w).tuple() (-1/2*a + 1/2, 0, 0, 0) - sage: (-w)^3 == -(w^3) # optional - sage.rings.number_field + sage: (-w)^3 == -(w^3) True :: sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism, identity_morphism - sage: E = EllipticCurve(QuadraticField(-1), [1,0]) # optional - sage.rings.number_field - sage: t = WeierstrassIsomorphism(E, (i,0,0,0)) # optional - sage.rings.number_field - sage: -t^2 == identity_morphism(E) # optional - sage.rings.number_field + sage: E = EllipticCurve(QuadraticField(-1), [1,0]) # needs sage.rings.number_field + sage: t = WeierstrassIsomorphism(E, (i,0,0,0)) # needs sage.rings.number_field + sage: -t^2 == identity_morphism(E) # needs sage.rings.number_field True """ a1,_,a3,_,_ = self._domain.a_invariants() @@ -943,8 +947,8 @@ def scaling_factor(self): EXAMPLES:: - sage: E = EllipticCurve(QQbar, [0,1]) # optional - sage.rings.number_field - sage: all(f.scaling_factor() == f.formal()[1] for f in E.automorphisms()) # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [0,1]) # needs sage.rings.number_field + sage: all(f.scaling_factor() == f.formal()[1] for f in E.automorphisms()) # needs sage.rings.number_field True ALGORITHM: The scaling factor equals the `u` component of diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index c1434b7c5b4..5d071f2bd49 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -47,7 +47,7 @@ sage: V = A2.subscheme([x^2 + y^2 - 1]); V Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^2 + y^2 - 1 - sage: V.dimension() + sage: V.dimension() # needs sage.libs.singular 1 Here is a more complicated example in a projective space:: @@ -55,14 +55,14 @@ sage: P3 = ProjectiveSpace(3, QQ, 'x') sage: P3.inject_variables() Defining x0, x1, x2, x3 - sage: Q = matrix([[x0, x1, x2], [x1, x2, x3]]).minors(2); Q + sage: Q = matrix([[x0, x1, x2], [x1, x2, x3]]).minors(2); Q # needs sage.modules [-x1^2 + x0*x2, -x1*x2 + x0*x3, -x2^2 + x1*x3] - sage: twisted_cubic = P3.subscheme(Q); twisted_cubic + sage: twisted_cubic = P3.subscheme(Q); twisted_cubic # needs sage.libs.singular sage.modules Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: -x1^2 + x0*x2, -x1*x2 + x0*x3, -x2^2 + x1*x3 - sage: twisted_cubic.dimension() + sage: twisted_cubic.dimension() # needs sage.libs.singular sage.modules 1 Note that there are 3 equations in the 3-dimensional ambient space, @@ -72,13 +72,12 @@ Let us look at one affine patch, for example the one where `x_0=1` :: - sage: patch = twisted_cubic.affine_patch(0) - sage: patch + sage: patch = twisted_cubic.affine_patch(0); patch # needs sage.libs.singular sage.modules Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x1^2 + x2, -x1*x2 + x3, -x2^2 + x1*x3 - sage: patch.embedding_morphism() + sage: patch.embedding_morphism() # needs sage.libs.singular sage.modules Scheme morphism: From: Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x1^2 + x2, -x1*x2 + x3, -x2^2 + x1*x3 @@ -279,9 +278,9 @@ def is_projective(self): projective spaces. This is why this method returns ``False`` for toric varieties:: - sage: PP. = toric_varieties.P(3) + sage: PP. = toric_varieties.P(3) # needs sage.geometry.polyhedron sage: V = PP.subscheme(x^3 + y^3 + z^3 + w^3) - sage: V.is_projective() + sage: V.is_projective() # needs sage.geometry.polyhedron False """ return self.ambient_space().is_projective() @@ -319,9 +318,9 @@ def ambient_space(self): EXAMPLES:: - sage: A. = AffineSpace(2, GF(5)) # optional - sage.rings.finite_rings - sage: S = A.subscheme([]) # optional - sage.rings.finite_rings - sage: S.ambient_space() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(5)) + sage: S = A.subscheme([]) + sage: S.ambient_space() Affine Space of dimension 2 over Finite Field of size 5 sage: P. = ProjectiveSpace(2, ZZ) @@ -381,15 +380,15 @@ def embedding_morphism(self): sage: A2. = AffineSpace(QQ, 2) sage: C = A2.subscheme(x^2 + y^2 - 1) - sage: C.embedding_morphism() + sage: C.embedding_morphism() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^2 + y^2 - 1 To: Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to (x, y) - sage: P1xP1. = toric_varieties.P1xP1() - sage: P1 = P1xP1.subscheme(x - y) - sage: P1.embedding_morphism() + sage: P1xP1. = toric_varieties.P1xP1() # needs sage.geometry.polyhedron + sage: P1 = P1xP1.subscheme(x - y) # needs sage.geometry.polyhedron sage.libs.singular + sage: P1.embedding_morphism() # needs sage.geometry.polyhedron sage.libs.singular Scheme morphism: From: Closed subscheme of 2-d CPR-Fano toric variety covered by 4 affine patches defined by: x - y @@ -402,8 +401,7 @@ def embedding_morphism(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P2.subscheme((x^2-y^2)*z) sage: p = (1,1,0) - sage: nbhd = X.neighborhood(p) - sage: nbhd + sage: nbhd = X.neighborhood(p); nbhd Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -y^2*z - 2*y*z @@ -429,19 +427,18 @@ def embedding_morphism(self): A couple more examples:: - sage: patch1 = P1xP1.affine_patch(1) - sage: patch1 + sage: # needs sage.geometry.polyhedron + sage: patch1 = P1xP1.affine_patch(1); patch1 2-d affine toric variety - sage: patch1.embedding_morphism() + sage: patch1.embedding_morphism() # needs sage.libs.singular Scheme morphism: From: 2-d affine toric variety To: 2-d CPR-Fano toric variety covered by 4 affine patches Defn: Defined on coordinates by sending [y : u] to [1 : y : u : 1] - sage: subpatch = P1.affine_patch(1) - sage: subpatch + sage: subpatch = P1.affine_patch(1); subpatch # needs sage.libs.singular Closed subscheme of 2-d affine toric variety defined by: -y + 1 - sage: subpatch.embedding_morphism() + sage: subpatch.embedding_morphism() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of 2-d affine toric variety defined by: -y + 1 To: Closed subscheme of 2-d CPR-Fano toric variety covered @@ -506,9 +503,9 @@ def ngens(self): EXAMPLES:: - sage: A. = AffineSpace(2, GF(5)) # optional - sage.rings.finite_rings - sage: S = A.subscheme([]) # optional - sage.rings.finite_rings - sage: S.ngens() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(5)) + sage: S = A.subscheme([]) + sage: S.ngens() 2 sage: P. = ProjectiveSpace(2, ZZ) sage: S = P.subscheme([x - y, x - z]) @@ -530,7 +527,7 @@ def _repr_(self): sage: S._repr_() 'Subscheme of Projective Space of dimension 3 over Integer Ring' """ - return "Subscheme of %s"%self.__A + return "Subscheme of %s" % self.__A def _homset(self, *args, **kwds): """ @@ -546,6 +543,7 @@ def _homset(self, *args, **kwds): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage: P1. = toric_varieties.P1() sage: type(P1.Hom(P1)) @@ -555,9 +553,9 @@ def _homset(self, *args, **kwds): :: - sage: P1xP1 = toric_varieties.P1xP1() - sage: P1 = toric_varieties.P1() - sage: P1xP1._homset(P1xP1, P1) + sage: P1xP1 = toric_varieties.P1xP1() # needs sage.geometry.polyhedron + sage: P1 = toric_varieties.P1() # needs sage.geometry.polyhedron + sage: P1xP1._homset(P1xP1, P1) # needs sage.geometry.polyhedron Set of morphisms From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 1-d CPR-Fano toric variety covered by 2 affine patches @@ -778,17 +776,17 @@ def _check_satisfies_equations(self, v): ... TypeError: number of arguments does not match number of variables in parent - sage: A. = AffineSpace(2, GF(7)) # optional - sage.rings.finite_rings - sage: S = A.subscheme([x^2 - y]) # optional - sage.rings.finite_rings - sage: T = A.subscheme([x - y]) # optional - sage.rings.finite_rings - sage: U = T.complement(S) # optional - sage.rings.finite_rings - sage: U._check_satisfies_equations([2, 4]) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(7)) + sage: S = A.subscheme([x^2 - y]) + sage: T = A.subscheme([x - y]) + sage: U = T.complement(S) + sage: U._check_satisfies_equations([2, 4]) True - sage: U.point([2,4]) # optional - sage.rings.finite_rings + sage: U.point([2,4]) (2, 4) - sage: U._check_satisfies_equations(_) # optional - sage.rings.finite_rings + sage: U._check_satisfies_equations(_) True - sage: U._check_satisfies_equations([1, 1]) # optional - sage.rings.finite_rings + sage: U._check_satisfies_equations([1, 1]) Traceback (most recent call last): ... TypeError: Coordinates [1, 1] do not define a point on Quasi-affine @@ -797,7 +795,7 @@ def _check_satisfies_equations(self, v): x^2 - y and Y is defined by: x - y - sage: U._check_satisfies_equations([1, 0]) # optional - sage.rings.finite_rings + sage: U._check_satisfies_equations([1, 0]) Traceback (most recent call last): ... TypeError: Coordinates [1, 0] do not define a point on Quasi-affine @@ -821,11 +819,11 @@ def _check_satisfies_equations(self, v): coords = list(v) for f in self.__X.defining_polynomials(): if f(coords) != 0: - raise TypeError("Coordinates %s do not define a point on %s"%(v,self)) + raise TypeError("Coordinates %s do not define a point on %s" % (v,self)) for f in self.__Y.defining_polynomials(): if f(coords) != 0: return True - raise TypeError("Coordinates %s do not define a point on %s"%(v,self)) + raise TypeError("Coordinates %s do not define a point on %s" % (v,self)) def rational_points(self, **kwds): """ @@ -845,13 +843,13 @@ def rational_points(self, **kwds): EXAMPLES:: - sage: A. = AffineSpace(2, GF(7)) # optional - sage.rings.finite_rings - sage: S = A.subscheme([x^2 - y]) # optional - sage.rings.finite_rings - sage: T = A.subscheme([x - y]) # optional - sage.rings.finite_rings - sage: U = T.complement(S) # optional - sage.rings.finite_rings - sage: U.rational_points() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(7)) + sage: S = A.subscheme([x^2 - y]) + sage: T = A.subscheme([x - y]) + sage: U = T.complement(S) + sage: U.rational_points() [(2, 4), (3, 2), (4, 2), (5, 4), (6, 1)] - sage: U.rational_points(F=GF(7^2, 'b')) # optional - sage.rings.finite_rings + sage: U.rational_points(F=GF(7^2, 'b')) # needs sage.rings.finite_rings [(2, 4), (3, 2), (4, 2), (5, 4), (6, 1), (b, b + 4), (b + 1, 3*b + 5), (b + 2, 5*b + 1), (b + 3, 6), (b + 4, 2*b + 6), (b + 5, 4*b + 1), (b + 6, 6*b + 5), (2*b, 4*b + 2), (2*b + 1, b + 3), (2*b + 2, 5*b + 6), @@ -872,9 +870,9 @@ def rational_points(self, **kwds): if bound == 0: if is_RationalField(F): - raise TypeError("A positive bound (= %s) must be specified."%bound) + raise TypeError("A positive bound (= %s) must be specified." % bound) if not isinstance(F, FiniteField): - raise TypeError("Argument F (= %s) must be a finite field."%F) + raise TypeError("Argument F (= %s) must be a finite field." % F) pts = [] for P in self.ambient_space().rational_points(F): try: @@ -986,11 +984,11 @@ def _check_satisfies_equations(self, v): for f in self.defining_polynomials(): if f(coords) != 0: # it must be "!=0" instead of "if f(v)", e.g., # because of p-adic base rings. - raise TypeError("Coordinates %s do not define a point on %s"%(coords,self)) + raise TypeError("Coordinates %s do not define a point on %s" % (coords,self)) try: return self.ambient_space()._check_satisfies_equations(coords) except TypeError: - raise TypeError("Coordinates %s do not define a point on %s"%(coords,self)) + raise TypeError("Coordinates %s do not define a point on %s" % (coords,self)) def base_extend(self, R): """ @@ -998,13 +996,13 @@ def base_extend(self, R): EXAMPLES:: - sage: P. = ProjectiveSpace(2, GF(11)) # optional - sage.rings.finite_rings - sage: S = P.subscheme([x^2 - y*z]) # optional - sage.rings.finite_rings - sage: S.base_extend(GF(11^2, 'b')) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(2, GF(11)) + sage: S = P.subscheme([x^2 - y*z]) + sage: S.base_extend(GF(11^2, 'b')) # needs sage.rings.finite_rings Closed subscheme of Projective Space of dimension 2 over Finite Field in b of size 11^2 defined by: x^2 - y*z - sage: S.base_extend(ZZ) # optional - sage.rings.finite_rings + sage: S.base_extend(ZZ) Traceback (most recent call last): ... ValueError: no natural map from the base ring (=Finite Field of size 11) @@ -1021,7 +1019,7 @@ def __richcmp__(self, other, op): sage: X = A.subscheme([x*y, z]) sage: X == A.subscheme([z, x*y]) True - sage: X == A.subscheme([x*y, z^2]) + sage: X == A.subscheme([x*y, z^2]) # needs sage.libs.singular False sage: B. = AffineSpace(3, QQ) sage: X == B.subscheme([u*v, t]) @@ -1040,19 +1038,17 @@ def _latex_(self): EXAMPLES:: - sage: P. = ProjectiveSpace(2, GF(11)) # optional - sage.rings.finite_rings - sage: S = P.subscheme([x^2 - y*z]) # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(2, GF(11)) + sage: S = P.subscheme([x^2 - y*z]); S Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: x^2 - y*z - sage: S._latex_() # optional - sage.rings.finite_rings + sage: S._latex_() '\\text{Closed subscheme of } {\\mathbf P}_{\\Bold{F}_{11}}^2 \\text{ defined by } x^{2} - y z' - sage: S = P.subscheme([x^2 - y*z, x^5]) # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: S = P.subscheme([x^2 - y*z, x^5]); S Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: x^2 - y*z, x^5 - sage: S._latex_() # optional - sage.rings.finite_rings + sage: S._latex_() '\\text{Closed subscheme of } {\\mathbf P}_{\\Bold{F}_{11}}^2 \\text{ defined by } x^{2} - y z, x^{5}' """ polynomials = ', '.join(latex(f) for f in self.defining_polynomials()) @@ -1067,19 +1063,17 @@ def _repr_(self): EXAMPLES:: - sage: P. = ProjectiveSpace(2, GF(11)) # optional - sage.rings.finite_rings - sage: S = P.subscheme([x^2 - y*z]) # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(2, GF(11)) + sage: S = P.subscheme([x^2 - y*z]); S Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: x^2 - y*z - sage: S._repr_() # optional - sage.rings.finite_rings + sage: S._repr_() 'Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by:\n x^2 - y*z' - sage: S = P.subscheme([x^2 - y*z, x^5]) # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: S = P.subscheme([x^2 - y*z, x^5]); S Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: x^2 - y*z, x^5 - sage: S._repr_() # optional - sage.rings.finite_rings + sage: S._repr_() 'Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by:\n x^2 - y*z,\n x^5' """ polynomials = ',\n '.join(str(f) for f in self.defining_polynomials()) @@ -1184,9 +1178,9 @@ def codimension(self): sage: PP. = ProjectiveSpace(4, QQ) sage: V = PP.subscheme(x*y) - sage: V.codimension() + sage: V.codimension() # needs sage.libs.singular 1 - sage: V.dimension() + sage: V.dimension() # needs sage.libs.singular 3 """ return self.ambient_space().dimension() - self.dimension() @@ -1209,8 +1203,8 @@ def irreducible_components(self): `\P^4_{\QQ}` then find the irreducible components:: sage: PP. = ProjectiveSpace(4, QQ) - sage: V = PP.subscheme((x^2 - y^2 - z^2) * (w^5 - 2*v^2*z^3) * w * (v^3 - x^2*z)) - sage: V.irreducible_components() + sage: V = PP.subscheme((x^2 - y^2 - z^2) * (w^5 - 2*v^2*z^3) * w * (v^3 - x^2*z)) + sage: V.irreducible_components() # needs sage.libs.singular [ Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: w, @@ -1230,7 +1224,7 @@ def irreducible_components(self): sage: R = f.parent() sage: I = [f] + [f.derivative(zz) for zz in PP.gens()] sage: V = PP.subscheme(I) - sage: V.irreducible_components() + sage: V.irreducible_components() # needs sage.libs.singular [ ] @@ -1241,7 +1235,7 @@ def irreducible_components(self): sage: AA. = AffineSpace(4, QQ) sage: V = AA.subscheme(I) - sage: V.irreducible_components() + sage: V.irreducible_components() # needs sage.libs.singular [ Closed subscheme of Affine Space of dimension 4 over Rational Field defined by: w, @@ -1281,27 +1275,28 @@ def is_irreducible(self): EXAMPLES:: - sage: K = QuadraticField(-3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 5) # optional - sage.rings.number_field - sage: X = P.subscheme([x*y - z^2 - K.0*t^2, t*w*x + y*z^2 - u^3]) # optional - sage.rings.number_field - sage: X.is_irreducible() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(-3) + sage: P. = ProjectiveSpace(K, 5) + sage: X = P.subscheme([x*y - z^2 - K.0*t^2, t*w*x + y*z^2 - u^3]) + sage: X.is_irreducible() True :: sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme([(y + x - z)^2]) - sage: X.is_irreducible() + sage: X.is_irreducible() # needs sage.libs.singular False :: - sage: A. = AffineSpace(GF(17), 4) # optional - sage.rings.finite_rings - sage: X = A.subscheme([ # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(17), 4) + sage: X = A.subscheme([ ....: x*y*z^2 - x*y*z*w - z*w^2 + w^3, ....: x^3*y*z*w - x*y^3*z - x^2*y*z*w - x^2*w^3 + y^2*w^2 + x*w^3 ....: ]) - sage: X.is_irreducible() # optional - sage.rings.finite_rings + sage: X.is_irreducible() # needs sage.rings.finite_rings False """ return self.defining_ideal().is_prime() @@ -1318,8 +1313,9 @@ def Jacobian_matrix(self): EXAMPLES:: sage: P3. = ProjectiveSpace(3, QQ) - sage: twisted_cubic = P3.subscheme(matrix([[w, x, y], [x, y, z]]).minors(2)) - sage: twisted_cubic.Jacobian_matrix() + sage: twisted_cubic = P3.subscheme(matrix([[w, x, y], # needs sage.libs.singular + ....: [x, y, z]]).minors(2)) + sage: twisted_cubic.Jacobian_matrix() # needs sage.libs.singular [ y -2*x w 0] [ z -y -x w] [ 0 z -2*y x] @@ -1327,7 +1323,7 @@ def Jacobian_matrix(self): This example addresses issue :trac:`20512`:: sage: X = P3.subscheme([]) - sage: X.Jacobian_matrix().base_ring() == P3.coordinate_ring() + sage: X.Jacobian_matrix().base_ring() == P3.coordinate_ring() # needs sage.libs.singular True """ R = self.ambient_space().coordinate_ring() @@ -1357,20 +1353,21 @@ def Jacobian(self): EXAMPLES:: sage: P3. = ProjectiveSpace(3, QQ) - sage: twisted_cubic = P3.subscheme(matrix([[w, x, y], [x, y, z]]).minors(2)) - sage: twisted_cubic.Jacobian() + sage: twisted_cubic = P3.subscheme(matrix([[w, x, y], # needs sage.libs.singular + ....: [x, y, z]]).minors(2)) + sage: twisted_cubic.Jacobian() # needs sage.libs.singular Ideal (-x^2 + w*y, -x*y + w*z, -y^2 + x*z, x*z, -2*w*z, w*y, 3*w*y, -2*w*x, w^2, y*z, -2*x*z, w*z, 3*w*z, -2*w*y, w*x, z^2, -2*y*z, x*z, 3*x*z, -2*w*z, w*y) of Multivariate Polynomial Ring in w, x, y, z over Rational Field - sage: twisted_cubic.defining_ideal() + sage: twisted_cubic.defining_ideal() # needs sage.libs.singular Ideal (-x^2 + w*y, -x*y + w*z, -y^2 + x*z) of Multivariate Polynomial Ring in w, x, y, z over Rational Field This example addresses issue :trac:`20512`:: sage: X = P3.subscheme([]) - sage: X.Jacobian() == P3.coordinate_ring().unit_ideal() + sage: X.Jacobian() == P3.coordinate_ring().unit_ideal() # needs sage.libs.singular True """ d = self.codimension() @@ -1392,18 +1389,19 @@ def reduce(self): Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^5 - 3*x^4*y + 3*x^3*y^2 - x^2*y^3 - 2*x^4 + 6*x^3*y - 6*x^2*y^2 + 2*x*y^3 + x^3 - 3*x^2*y + 3*x*y^2 - y^3 - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular 1 Then we compute the corresponding reduced scheme:: - sage: Y = X.reduce(); Y + sage: Y = X.reduce(); Y # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^2 - x*y - x + y Finally, we verify that the reduced scheme `Y` is the union of those two lines:: + sage: # needs sage.libs.singular sage: L1 = A.subscheme([x - 1]); L1 Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x - 1 @@ -1440,35 +1438,35 @@ def union(self, other): sage: I = ideal([x, y])^3 sage: P = A.subscheme(I) sage: L = A.subscheme([y - 1]) - sage: S = L.union(P); S + sage: S = L.union(P); S # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: y^4 - y^3, x*y^3 - x*y^2, x^2*y^2 - x^2*y, x^3*y - x^3 - sage: S.dimension() + sage: S.dimension() # needs sage.libs.singular 1 - sage: S.reduce() + sage: S.reduce() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: y^2 - y, x*y - x We can also use the notation "+" for the union:: - sage: A.subscheme([x]) + A.subscheme([y^2 - (x^3+1)]) + sage: A.subscheme([x]) + A.subscheme([y^2 - (x^3+1)]) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^4 - x*y^2 + x Saving and loading:: - sage: loads(S.dumps()) == S + sage: loads(S.dumps()) == S # needs sage.libs.singular True """ if not isinstance(other, AlgebraicScheme_subscheme): - raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space"%other) + raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space" % other) A = self.ambient_space() if other.ambient_space() != A: - raise ValueError("other (=%s) must be in the same ambient space as self"%other) + raise ValueError("other (=%s) must be in the same ambient space as self" % other) return A.subscheme(self.defining_ideal().intersection(other.defining_ideal())) def __pow__(self, m): @@ -1515,8 +1513,8 @@ def __pow__(self, m): -x1*x3 + x0*x4, -x7*x9 + x6*x10 - sage: E = EllipticCurve([0,0,0,0,1]) - sage: E^2 + sage: E = EllipticCurve([0,0,0,0,1]) # needs sage.schemes + sage: E^2 # needs sage.schemes Closed subscheme of Product of projective spaces P^2 x P^2 over Rational Field defined by: -x0^3 + x1^2*x2 - x2^3, @@ -1649,10 +1647,10 @@ def intersection(self, other): y """ if not isinstance(other, AlgebraicScheme_subscheme): - raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space"%other) + raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space" % other) A = self.ambient_space() if other.ambient_space() != A: - raise ValueError("other (=%s) must be in the same ambient space as self"%other) + raise ValueError("other (=%s) must be in the same ambient space as self" % other) return A.subscheme(self.defining_ideal() + other.defining_ideal()) def complement(self, other=None): @@ -1708,9 +1706,9 @@ def complement(self, other=None): if other == A: other = A.subscheme([]) else: - raise TypeError("Argument other (=%s) must be a closed algebraic subscheme of an ambient space"%other) + raise TypeError("Argument other (=%s) must be a closed algebraic subscheme of an ambient space" % other) if other.ambient_space() != A: - raise ValueError("other (=%s) must be in the same ambient space as self"%other) + raise ValueError("other (=%s) must be in the same ambient space as self" % other) return AlgebraicScheme_quasi(other, self) def rational_points(self, **kwds): @@ -1766,18 +1764,19 @@ def rational_points(self, **kwds): Enumerate over a projective scheme over a number field:: + sage: # needs sage.rings.number_field sage: u = QQ['u'].0 - sage: K. = NumberField(u^2 + 3) # optional - sage.rings.number_field - sage: A. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = A.subscheme(x^2 - y^2) # optional - sage.rings.number_field - sage: X.rational_points(bound=3) # optional - sage.rings.number_field + sage: K. = NumberField(u^2 + 3) + sage: A. = ProjectiveSpace(K, 1) + sage: X = A.subscheme(x^2 - y^2) + sage: X.rational_points(bound=3) [(-1 : 1), (1 : 1)] One can enumerate points up to a given bound on a projective scheme over the rationals:: - sage: E = EllipticCurve('37a') - sage: E.rational_points(bound=8) + sage: E = EllipticCurve('37a') # needs sage.schemes + sage: E.rational_points(bound=8) # needs sage.schemes [(-1 : -1 : 1), (-1 : 0 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 0), (1/4 : -5/8 : 1), (1/4 : -3/8 : 1), (1 : -1 : 1), (1 : 0 : 1), (2 : -3 : 1), (2 : 2 : 1)] @@ -1785,36 +1784,38 @@ def rational_points(self, **kwds): For a small finite field, the complete set of points can be enumerated. :: - sage: Etilde = E.base_extend(GF(3)) # optional - sage.rings.finite_rings - sage: Etilde.rational_points() # optional - sage.rings.finite_rings + sage: Etilde = E.base_extend(GF(3)) # needs sage.schemes + sage: Etilde.rational_points() # needs sage.schemes [(0 : 0 : 1), (0 : 1 : 0), (0 : 2 : 1), (1 : 0 : 1), (1 : 2 : 1), (2 : 0 : 1), (2 : 2 : 1)] The class of hyperelliptic curves does not (yet) support desingularization of the places at infinity into two points:: - sage: FF = FiniteField(7) # optional - sage.rings.finite_rings - sage: P. = PolynomialRing(FiniteField(7)) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(x^8 + x + 1) # optional - sage.rings.finite_rings - sage: C.rational_points() # optional - sage.rings.finite_rings + sage: FF = FiniteField(7) + sage: P. = PolynomialRing(FiniteField(7)) + sage: C = HyperellipticCurve(x^8 + x + 1) # needs sage.schemes + sage: C.rational_points() # needs sage.schemes [(0 : 1 : 0), (0 : 1 : 1), (0 : 6 : 1), (2 : 0 : 1), (4 : 0 : 1), (6 : 1 : 1), (6 : 6 : 1)] :: - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 - v^2*x*z, y*x - v*z^2]) # optional - sage.rings.number_field - sage: X.rational_points(F=CC) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: P. = ProjectiveSpace(K, 2) + sage: X = P.subscheme([x^2 - v^2*x*z, y*x - v*z^2]) + sage: X.rational_points(F=CC) [(-3.00000000000000 : -0.577350269189626*I : 1.00000000000000), (0.000000000000000 : 1.00000000000000 : 0.000000000000000)] :: - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: X = A.subscheme([x^2 - v^2*y, y*x - v]) # optional - sage.rings.number_field - sage: X.rational_points(F=RR) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: A. = AffineSpace(K, 2) + sage: X = A.subscheme([x^2 - v^2*y, y*x - v]) + sage: X.rational_points(F=RR) [(1.73205080756888, 1.00000000000000)] .. TODO:: @@ -1831,7 +1832,7 @@ def rational_points(self, **kwds): try: return X.points(**kwds) # checks for proper bound done in points functions except TypeError: - raise TypeError("Unable to enumerate points over %s."%F) + raise TypeError("Unable to enumerate points over %s." % F) elif (self.base_ring() in NumberFields() or self.base_ring() == ZZ)\ and hasattr(F, 'precision'): #we are numerically approximating number field points @@ -1840,7 +1841,7 @@ def rational_points(self, **kwds): X = self.base_extend(F)(F) return X.points() except TypeError: - raise TypeError("Unable to enumerate points over %s."%F) + raise TypeError("Unable to enumerate points over %s." % F) def change_ring(self, R): r""" @@ -1859,31 +1860,33 @@ def change_ring(self, R): sage: P. = ProjectiveSpace(QQ, 1) sage: X = P.subscheme([3*x^2 - y^2]) sage: H = Hom(X, X) - sage: X.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: X.change_ring(GF(3)) Closed subscheme of Projective Space of dimension 1 over Finite Field of size 3 defined by: -y^2 :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(z^3 - 5) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = P.subscheme(x - w*y) # optional - sage.rings.number_field - sage: X.change_ring(L) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: R. = K[] + sage: L. = K.extension(z^3 - 5) + sage: P. = ProjectiveSpace(K, 1) + sage: X = P.subscheme(x - w*y) # needs sage.libs.singular + sage: X.change_ring(L) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Number Field in v with defining polynomial z^3 - 5 over its base field defined by: x + (-w)*y :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(z^3 - 5) # optional - sage.rings.number_field - sage: P. = AffineSpace(L, 3) # optional - sage.rings.number_field - sage: X = P.subscheme([x - w*y, z^2 - v*x]) # optional - sage.rings.number_field - sage: emb = L.embeddings(QQbar) # optional - sage.rings.number_field - sage: X.change_ring(emb[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: R. = K[] + sage: L. = K.extension(z^3 - 5) + sage: P. = AffineSpace(L, 3) + sage: X = P.subscheme([x - w*y, z^2 - v*x]) # needs sage.libs.singular + sage: emb = L.embeddings(QQbar) # needs sage.libs.singular + sage: X.change_ring(emb[0]) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Algebraic Field defined by: x + (-1.414213562373095? + 0.?e-16*I)*y, @@ -1891,13 +1894,14 @@ def change_ring(self, R): :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(z^3 - 5) # optional - sage.rings.number_field - sage: P. = AffineSpace(L, 3) # optional - sage.rings.number_field - sage: X = P.subscheme([x - w*y, z^2 - v*x]) # optional - sage.rings.number_field - sage: emb = L.embeddings(QQbar) # optional - sage.rings.number_field - sage: X.change_ring(emb[1]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: R. = K[] + sage: L. = K.extension(z^3 - 5) + sage: P. = AffineSpace(L, 3) + sage: X = P.subscheme([x - w*y, z^2 - v*x]) # needs sage.libs.singular + sage: emb = L.embeddings(QQbar) # needs sage.libs.singular + sage: X.change_ring(emb[1]) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Algebraic Field defined by: x + (-1.414213562373095? + 0.?e-16*I)*y, @@ -1905,48 +1909,52 @@ def change_ring(self, R): :: - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = P.subscheme(x - w*y) # optional - sage.rings.number_field - sage: X.change_ring(CC) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: P. = ProjectiveSpace(K, 1) + sage: X = P.subscheme(x - w*y) # needs sage.libs.singular + sage: X.change_ring(CC) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Complex Field with 53 bits of precision defined by: x + (-1.73205080756888*I)*y :: - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = P.subscheme(x - w*y) # optional - sage.rings.number_field - sage: X.change_ring(RR) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: P. = ProjectiveSpace(K, 1) + sage: X = P.subscheme(x - w*y) # needs sage.libs.singular + sage: X.change_ring(RR) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Real Field with 53 bits of precision defined by: x - 1.73205080756888*y :: - sage: K. = CyclotomicField(7) # optional - sage.rings.number_field - sage: O = K.maximal_order() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 + O(v)*y^2]) # optional - sage.rings.number_field - sage: X.change_ring(CC) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(7) + sage: O = K.maximal_order() + sage: P. = ProjectiveSpace(O, 1) + sage: X = P.subscheme([x^2 + O(v)*y^2]) # needs sage.libs.singular + sage: X.change_ring(CC) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Complex Field with 53 bits of precision defined by: x^2 + (0.623489801858734 + 0.781831482468030*I)*y^2 - sage: X.change_ring(K).change_ring(K.embeddings(QQbar)[3]) # optional - sage.rings.number_field + sage: X.change_ring(K).change_ring(K.embeddings(QQbar)[3]) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Algebraic Field defined by: x^2 + (-0.9009688679024191? - 0.4338837391175581?*I)*y^2 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: f = x^6 - 2 - sage: L. = NumberField(f, embedding=f.roots(CC)[2][0]) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: H = Hom(A, A) # optional - sage.rings.number_field - sage: X = A.subscheme([b*x^2, y^2]) # optional - sage.rings.number_field - sage: X.change_ring(CC) # optional - sage.rings.number_field + sage: L. = NumberField(f, embedding=f.roots(CC)[2][0]) + sage: A. = AffineSpace(L, 2) + sage: H = Hom(A, A) + sage: X = A.subscheme([b*x^2, y^2]) # needs sage.libs.singular + sage: X.change_ring(CC) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Complex Field with 53 bits of precision defined by: (-0.561231024154687 - 0.972080648619833*I)*x^2, @@ -1992,25 +2000,26 @@ def weil_restriction(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 - 2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(x^2 + 1) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: X = A.subscheme([y^2 - L(w)*x^3 - v]) # optional - sage.rings.number_field - sage: X.weil_restriction() # optional - sage.rings.number_field + sage: K. = NumberField(x^5 - 2) + sage: R. = K[] + sage: L. = K.extension(x^2 + 1) + sage: A. = AffineSpace(L, 2) + sage: X = A.subscheme([y^2 - L(w)*x^3 - v]) # needs sage.libs.singular + sage: X.weil_restriction() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 4 over Number Field in w with defining polynomial x^5 - 2 defined by: (-w)*z0^3 + (3*w)*z0*z1^2 + z2^2 - z3^2, (-3*w)*z0^2*z1 + w*z1^3 + 2*z2*z3 - 1 - sage: X.weil_restriction().ambient_space() is A.weil_restriction() # optional - sage.rings.number_field + sage: X.weil_restriction().ambient_space() is A.weil_restriction() # needs sage.libs.singular True :: - sage: A. = AffineSpace(GF(5^2, 't'), 3) # optional - sage.rings.finite_rings - sage: X = A.subscheme([y^2 - x*z, z^2 + 2*y]) # optional - sage.rings.finite_rings - sage: X.weil_restriction() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(5^2, 't'), 3) # needs sage.rings.finite_rings + sage: X = A.subscheme([y^2 - x*z, z^2 + 2*y]) # needs sage.libs.singular sage.rings.finite_rings + sage: X.weil_restriction() # needs sage.libs.singular sage.rings.finite_rings Closed subscheme of Affine Space of dimension 6 over Finite Field of size 5 defined by: z2^2 - 2*z3^2 - z0*z4 + 2*z1*z5, @@ -2068,8 +2077,9 @@ def specialization(self, D=None, phi=None): sage: P. = AffineSpace(S, 3) sage: X = P.subscheme([x^2 + a*c*y^2 - b*z^2]) sage: from sage.rings.polynomial.flatten import SpecializationMorphism - sage: phi = SpecializationMorphism(P.coordinate_ring(), dict({c: 2, a: 1})) - sage: X.specialization(phi=phi) + sage: phi = SpecializationMorphism(P.coordinate_ring(), + ....: dict({c: 2, a: 1})) + sage: X.specialization(phi=phi) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Univariate Polynomial Ring in b over Rational Field defined by: x^2 + 2*y^2 + (-b)*z^2 diff --git a/src/sage/schemes/generic/ambient_space.py b/src/sage/schemes/generic/ambient_space.py index 9b7b11feb74..d22ea07d149 100644 --- a/src/sage/schemes/generic/ambient_space.py +++ b/src/sage/schemes/generic/ambient_space.py @@ -148,7 +148,7 @@ def _validate(self, polynomials): sage: from sage.schemes.generic.ambient_space import AmbientSpace sage: A = AmbientSpace(3, ZZ) - sage: A._validate((x + 1, 1)) + sage: A._validate((x + 1, 1)) # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError: ambient spaces must override "_validate" method! @@ -227,7 +227,7 @@ def base_extend(self, R): sage: P. = ProjectiveSpace(2, ZZ) sage: PQ = P.base_extend(QQ); PQ Projective Space of dimension 2 over Rational Field - sage: PQ.base_extend(GF(5)) # optional - sage.rings.finite_rings + sage: PQ.base_extend(GF(5)) Traceback (most recent call last): ... ValueError: no natural map from the base ring (=Rational Field) @@ -257,8 +257,8 @@ def ambient_space(self): sage: P.ambient_space() is P True - sage: A = AffineSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: A.ambient_space() # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(3)) + sage: A.ambient_space() Affine Space of dimension 2 over Finite Field of size 3 """ return self @@ -285,8 +285,8 @@ def identity_morphism(self): EXAMPLES:: - sage: A = AffineSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: A.identity_morphism() # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(3)) + sage: A.identity_morphism() Scheme endomorphism of Affine Space of dimension 2 over Finite Field of size 3 Defn: Identity map @@ -325,8 +325,8 @@ def gens(self): sage: AffineSpace(0, QQ).gens() () - sage: P. = ProjectiveSpace(2, GF(5)) # optional - sage.rings.finite_rings - sage: P.gens() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(2, GF(5)) + sage: P.gens() (x, y, z) """ return self.coordinate_ring().gens() diff --git a/src/sage/schemes/generic/divisor.py b/src/sage/schemes/generic/divisor.py index 9124b3cfb90..6a55c3e8ce7 100644 --- a/src/sage/schemes/generic/divisor.py +++ b/src/sage/schemes/generic/divisor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.schemes """ Divisors on schemes @@ -13,22 +14,22 @@ EXAMPLES:: - sage: x,y,z = ProjectiveSpace(2, GF(5), names='x,y,z').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2*z^7 - x^9 - x*z^8) # optional - sage.rings.finite_rings - sage: pts = C.rational_points(); pts # optional - sage.rings.finite_rings + sage: x,y,z = ProjectiveSpace(2, GF(5), names='x,y,z').gens() + sage: C = Curve(y^2*z^7 - x^9 - x*z^8) + sage: pts = C.rational_points(); pts [(0 : 0 : 1), (0 : 1 : 0), (2 : 2 : 1), (2 : 3 : 1), (3 : 1 : 1), (3 : 4 : 1)] - sage: D1 = C.divisor(pts[0])*3 # optional - sage.rings.finite_rings - sage: D2 = C.divisor(pts[1]) # optional - sage.rings.finite_rings - sage: D3 = 10*C.divisor(pts[5]) # optional - sage.rings.finite_rings - sage: D1.parent() is D2.parent() # optional - sage.rings.finite_rings + sage: D1 = C.divisor(pts[0])*3 + sage: D2 = C.divisor(pts[1]) + sage: D3 = 10*C.divisor(pts[5]) + sage: D1.parent() is D2.parent() True - sage: D = D1 - D2 + D3; D # optional - sage.rings.finite_rings + sage: D = D1 - D2 + D3; D 3*(x, y) - (x, z) + 10*(x + 2*z, y + z) - sage: D[1][0] # optional - sage.rings.finite_rings + sage: D[1][0] -1 - sage: D[1][1] # optional - sage.rings.finite_rings + sage: D[1][1] Ideal (x, z) of Multivariate Polynomial Ring in x, y, z over Finite Field of size 5 - sage: C.divisor([(3, pts[0]), (-1, pts[1]), (10, pts[5])]) # optional - sage.rings.finite_rings + sage: C.divisor([(3, pts[0]), (-1, pts[1]), (10, pts[5])]) 3*(x, y) - (x, z) + 10*(x + 2*z, y + z) """ #******************************************************************************* @@ -107,9 +108,9 @@ def is_Divisor(x): EXAMPLES:: sage: from sage.schemes.generic.divisor import is_Divisor - sage: x,y = AffineSpace(2, GF(5), names='xy').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^9 - x) # optional - sage.rings.finite_rings - sage: is_Divisor(C.divisor([])) # optional - sage.rings.finite_rings + sage: x,y = AffineSpace(2, GF(5), names='xy').gens() + sage: C = Curve(y^2 - x^9 - x) + sage: is_Divisor(C.divisor([])) True sage: is_Divisor("Ceci n'est pas un diviseur") False @@ -223,13 +224,13 @@ def scheme(self): EXAMPLES:: - sage: A. = AffineSpace(2, GF(5)) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^9 - x) # optional - sage.rings.finite_rings - sage: pts = C.rational_points(); pts # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(5)) + sage: C = Curve(y^2 - x^9 - x) + sage: pts = C.rational_points(); pts [(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)] - sage: D = C.divisor(pts[0])*3 - C.divisor(pts[1]); D # optional - sage.rings.finite_rings + sage: D = C.divisor(pts[0])*3 - C.divisor(pts[1]); D 3*(x, y) - (x - 2, y - 2) - sage: D.scheme() # optional - sage.rings.finite_rings + sage: D.scheme() Affine Plane Curve over Finite Field of size 5 defined by -x^9 + y^2 - x """ return self.parent().scheme() @@ -369,31 +370,31 @@ def support(self): EXAMPLES:: - sage: x,y = AffineSpace(2, GF(5), names='xy').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^9 - x) # optional - sage.rings.finite_rings - sage: pts = C.rational_points(); pts # optional - sage.rings.finite_rings + sage: x,y = AffineSpace(2, GF(5), names='xy').gens() + sage: C = Curve(y^2 - x^9 - x) + sage: pts = C.rational_points(); pts [(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)] - sage: D = C.divisor_group()([(3, pts[0]), (-1, pts[1])]); D # optional - sage.rings.finite_rings + sage: D = C.divisor_group()([(3, pts[0]), (-1, pts[1])]); D 3*(x, y) - (x - 2, y - 2) - sage: D.support() # optional - sage.rings.finite_rings + sage: D.support() [(0, 0), (2, 2)] TESTS: This checks that :trac:`10732` is fixed:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: C = Curve(x^7 + y^7 + z^7) # optional - sage.rings.finite_rings - sage: pts = C.rational_points() # optional - sage.rings.finite_rings - sage: D = C.divisor([(2, pts[0])]) # optional - sage.rings.finite_rings - sage: D.support() # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: C = Curve(x^7 + y^7 + z^7) + sage: pts = C.rational_points() + sage: D = C.divisor([(2, pts[0])]) + sage: D.support() [(0 : 4 : 1)] - sage: (D + D).support() # optional - sage.rings.finite_rings + sage: (D + D).support() [(0 : 4 : 1)] - sage: E = C.divisor([(-3, pts[1]), (1, pts[2])]) # optional - sage.rings.finite_rings - sage: (D - 2*E).support() # optional - sage.rings.finite_rings + sage: E = C.divisor([(-3, pts[1]), (1, pts[2])]) + sage: (D - 2*E).support() [(0 : 4 : 1), (1 : 2 : 1), (2 : 1 : 1)] - sage: (D - D).support() # optional - sage.rings.finite_rings + sage: (D - D).support() [] """ try: @@ -417,18 +418,18 @@ def coefficient(self, P): EXAMPLES:: - sage: x,y = AffineSpace(2, GF(5), names='xy').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^9 - x) # optional - sage.rings.finite_rings - sage: pts = C.rational_points(); pts # optional - sage.rings.finite_rings + sage: x,y = AffineSpace(2, GF(5), names='xy').gens() + sage: C = Curve(y^2 - x^9 - x) + sage: pts = C.rational_points(); pts [(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)] - sage: D = C.divisor(pts[0]) # optional - sage.rings.finite_rings - sage: D.coefficient(pts[0]) # optional - sage.rings.finite_rings + sage: D = C.divisor(pts[0]) + sage: D.coefficient(pts[0]) 1 - sage: D = C.divisor([(3, pts[0]), (-1, pts[1])]); D # optional - sage.rings.finite_rings + sage: D = C.divisor([(3, pts[0]), (-1, pts[1])]); D 3*(x, y) - (x - 2, y - 2) - sage: D.coefficient(pts[0]) # optional - sage.rings.finite_rings + sage: D.coefficient(pts[0]) 3 - sage: D.coefficient(pts[1]) # optional - sage.rings.finite_rings + sage: D.coefficient(pts[1]) -1 """ P = self.parent().scheme()(P) diff --git a/src/sage/schemes/generic/divisor_group.py b/src/sage/schemes/generic/divisor_group.py index dfcb699d457..5dfd66a1bb9 100644 --- a/src/sage/schemes/generic/divisor_group.py +++ b/src/sage/schemes/generic/divisor_group.py @@ -209,10 +209,10 @@ def _an_element_(self): EXAMPLES:: - sage: A. = AffineSpace(2, CC) - sage: C = Curve(y^2 - x^9 - x) + sage: A. = AffineSpace(2, CC) # needs sage.rings.real_mpfr + sage: C = Curve(y^2 - x^9 - x) # needs sage.rings.real_mpfr sage.schemes sage: from sage.schemes.generic.divisor_group import DivisorGroup - sage: DivisorGroup(C).an_element() # indirect test + sage: DivisorGroup(C).an_element() # indirect test # needs sage.rings.real_mpfr sage.schemes 0 """ return self._scheme.divisor([], base_ring=self.base_ring(), check=False, reduce=False) @@ -224,14 +224,14 @@ def base_extend(self, R): sage: from sage.schemes.generic.divisor_group import DivisorGroup sage: DivisorGroup(Spec(ZZ), ZZ).base_extend(QQ) Group of QQ-Divisors on Spectrum of Integer Ring - sage: DivisorGroup(Spec(ZZ), ZZ).base_extend(GF(7)) # optional - sage.rings.finite_rings + sage: DivisorGroup(Spec(ZZ), ZZ).base_extend(GF(7)) Group of (Finite Field of size 7)-Divisors on Spectrum of Integer Ring Divisor groups are unique:: - sage: A. = AffineSpace(2, CC) - sage: C = Curve(y^2 - x^9 - x) - sage: DivisorGroup(C, ZZ).base_extend(QQ) is DivisorGroup(C, QQ) + sage: A. = AffineSpace(2, CC) # needs sage.rings.real_mpfr + sage: C = Curve(y^2 - x^9 - x) # needs sage.rings.real_mpfr sage.schemes + sage: DivisorGroup(C, ZZ).base_extend(QQ) is DivisorGroup(C, QQ) # needs sage.rings.real_mpfr sage.schemes True """ if self.base_ring().has_coerce_map_from(R): @@ -251,15 +251,16 @@ def _element_constructor_(self, x, check=True, reduce=True): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage.schemes sage: A. = AffineSpace(2, CC) sage: C = Curve(y^2 - x^9 - x) - sage: DivZZ=C.divisor_group(ZZ) - sage: DivQQ=C.divisor_group(QQ) - sage: DivQQ( DivQQ.an_element() ) # indirect test + sage: DivZZ = C.divisor_group(ZZ) + sage: DivQQ = C.divisor_group(QQ) + sage: DivQQ(DivQQ.an_element()) # indirect test 0 - sage: DivZZ( DivZZ.an_element() ) # indirect test + sage: DivZZ(DivZZ.an_element()) # indirect test 0 - sage: DivQQ( DivZZ.an_element() ) # indirect test + sage: DivQQ(DivZZ.an_element()) # indirect test 0 """ if isinstance(x, Divisor_curve): diff --git a/src/sage/schemes/generic/glue.py b/src/sage/schemes/generic/glue.py index d3169ba0116..76bd9a1ab9e 100644 --- a/src/sage/schemes/generic/glue.py +++ b/src/sage/schemes/generic/glue.py @@ -33,11 +33,11 @@ class GluedScheme(scheme.Scheme): def __init__(self, f, g, check=True): if check: if not morphism.is_SchemeMorphism(f): - raise TypeError("f (=%s) must be a scheme morphism"%f) + raise TypeError("f (=%s) must be a scheme morphism" % f) if not morphism.is_SchemeMorphism(g): - raise TypeError("g (=%s) must be a scheme morphism"%g) + raise TypeError("g (=%s) must be a scheme morphism" % g) if f.domain() != g.domain(): - raise ValueError("f (=%s) and g (=%s) must have the same domain"%(f,g)) + raise ValueError("f (=%s) and g (=%s) must have the same domain" % (f,g)) self.__f = f self.__g = g @@ -45,5 +45,5 @@ def gluing_maps(self): return self.__f, self.__g def _repr_(self): - return "Scheme obtained by gluing X and Y along U, where\n X: %s\n Y: %s\n U: %s"%( + return "Scheme obtained by gluing X and Y along U, where\n X: %s\n Y: %s\n U: %s" % ( self.__f.codomain(), self.__g.codomain(), self.__f.domain()) diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py index 5e88b3ceef5..5db57860f7d 100644 --- a/src/sage/schemes/generic/homset.py +++ b/src/sage/schemes/generic/homset.py @@ -473,8 +473,8 @@ def _coerce_map_from_(self, other): :: sage: P = ProjectiveSpace(QQ, 1, 'x') - sage: P2 = ProjectiveSpace(CC, 1, 'y') - sage: P2(CC)._coerce_map_from_(P(QQ)) + sage: P2 = ProjectiveSpace(CC, 1, 'y') # needs sage.rings.real_mpfr + sage: P2(CC)._coerce_map_from_(P(QQ)) # needs sage.rings.real_mpfr False :: @@ -484,13 +484,13 @@ def _coerce_map_from_(self, other): sage: L = A.subscheme([z, y + z]) sage: A(QQ)._coerce_map_from_(H(QQ)) True - sage: H(QQ)._coerce_map_from_(L(QQ)) + sage: H(QQ)._coerce_map_from_(L(QQ)) # needs sage.libs.singular True - sage: L(QQ).has_coerce_map_from(H(QQ)) + sage: L(QQ).has_coerce_map_from(H(QQ)) # needs sage.libs.singular False - sage: A(CC)._coerce_map_from_(H(QQ)) + sage: A(CC)._coerce_map_from_(H(QQ)) # needs sage.rings.real_mpfr True - sage: H(CC)._coerce_map_from_(L(RR)) + sage: H(CC)._coerce_map_from_(L(RR)) # needs sage.libs.singular sage.rings.real_mpfr True :: @@ -516,10 +516,10 @@ def _coerce_map_from_(self, other): :: sage: PS = ProjectiveSpace(ZZ, 1, 'x') - sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # optional - sage.rings.padics - sage: PS(ZZ).has_coerce_map_from(PS2(Zp(7))) # optional - sage.rings.padics + sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # needs sage.rings.padics + sage: PS(ZZ).has_coerce_map_from(PS2(Zp(7))) # needs sage.rings.padics False - sage: PS2(Zp(7)).has_coerce_map_from(PS(ZZ)) # optional - sage.rings.padics + sage: PS2(Zp(7)).has_coerce_map_from(PS(ZZ)) # needs sage.rings.padics True :: @@ -536,10 +536,11 @@ def _coerce_map_from_(self, other): :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: A. = AffineSpace(QQ, 3) # optional - sage.rings.number_field - sage: H = A.subscheme(z) # optional - sage.rings.number_field - sage: A(K).has_coerce_map_from(H(QQ)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: A. = AffineSpace(QQ, 3) + sage: H = A.subscheme(z) + sage: A(K).has_coerce_map_from(H(QQ)) True TESTS:: @@ -552,8 +553,8 @@ def _coerce_map_from_(self, other): :: sage: A = AffineSpace(QQ, 1, 'x') - sage: AC = AffineSpace(CC, 1, 'x') - sage: A(3/2) == AC(3/2) + sage: AC = AffineSpace(CC, 1, 'x') # needs sage.rings.real_mpfr + sage: A(3/2) == AC(3/2) # needs sage.rings.real_mpfr True :: @@ -632,23 +633,24 @@ def _element_constructor_(self, *v, **kwds): EXAMPLES:: sage: A2 = AffineSpace(ZZ, 2) - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: F_points = A2(F); type(F_points) # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: F_points = A2(F); type(F_points) - sage: F_points([2,5]) # optional - sage.rings.finite_rings + sage: F_points([2,5]) (2, 2) - sage: P2 = ProjectiveSpace(GF(3), 2) # optional - sage.rings.finite_rings - sage: F. = GF(9, 'a') # optional - sage.rings.finite_rings - sage: F_points = P2(F) # optional - sage.rings.finite_rings - sage: type(F_points) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P2 = ProjectiveSpace(GF(3), 2) + sage: F. = GF(9, 'a') + sage: F_points = P2(F) + sage: type(F_points) - sage: F_points([4,2*a]) # optional - sage.rings.finite_rings + sage: F_points([4,2*a]) (1 : 2*a : 1) TESTS:: - sage: F_points._element_constructor_([4,2*a]) # optional - sage.rings.finite_rings + sage: F_points._element_constructor_([4,2*a]) # needs sage.rings.finite_rings (1 : 2*a : 1) """ if len(v) == 1: @@ -667,17 +669,16 @@ def extended_codomain(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: P2 = ProjectiveSpace(QQ, 2) sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + x - (3^3-3)) # optional - sage.rings.number_field - sage: K_points = P2(K); K_points # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + x - (3^3-3)) + sage: K_points = P2(K); K_points Set of rational points of Projective Space of dimension 2 over Number Field in a with defining polynomial x^2 + x - 24 - - sage: K_points.codomain() # optional - sage.rings.number_field + sage: K_points.codomain() Projective Space of dimension 2 over Rational Field - - sage: K_points.extended_codomain() # optional - sage.rings.number_field + sage: K_points.extended_codomain() Projective Space of dimension 2 over Number Field in a with defining polynomial x^2 + x - 24 """ @@ -736,11 +737,11 @@ def cardinality(self): EXAMPLES:: - sage: toric_varieties.P2().point_set().cardinality() + sage: toric_varieties.P2().point_set().cardinality() # needs sage.geometry.polyhedron +Infinity - sage: P2 = toric_varieties.P2(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: P2.point_set().cardinality() # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(3)) # needs sage.geometry.polyhedron + sage: P2.point_set().cardinality() # needs sage.geometry.polyhedron 13 """ if hasattr(self, 'is_finite') and not self.is_finite(): @@ -760,8 +761,8 @@ def list(self): EXAMPLES:: - sage: P1 = toric_varieties.P1(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: P1.point_set().list() # optional - sage.rings.finite_rings + sage: P1 = toric_varieties.P1(base_ring=GF(3)) # needs sage.geometry.polyhedron + sage: P1.point_set().list() # needs sage.geometry.polyhedron ([0 : 1], [1 : 0], [1 : 1], [1 : 2]) """ return tuple(self) diff --git a/src/sage/schemes/generic/hypersurface.py b/src/sage/schemes/generic/hypersurface.py index fa2326d43e5..f4991527c78 100644 --- a/src/sage/schemes/generic/hypersurface.py +++ b/src/sage/schemes/generic/hypersurface.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.schemes r""" Hypersurfaces in affine and projective space @@ -94,9 +95,9 @@ def __init__(self, poly, ambient=None): True """ if not isinstance(poly, MPolynomial): - raise TypeError("Defining polynomial (=%s) must be a multivariate polynomial."%poly) + raise TypeError("Defining polynomial (=%s) must be a multivariate polynomial." % poly) if not poly.is_homogeneous(): - raise TypeError("Defining polynomial (=%s) must be homogeneous."%poly) + raise TypeError("Defining polynomial (=%s) must be homogeneous." % poly) if ambient is None: R = poly.parent() from sage.schemes.projective.projective_space import ProjectiveSpace @@ -119,7 +120,7 @@ def _repr_(self): sage: H._repr_() 'Projective hypersurface defined by y^2 + x*z in Projective Space of dimension 2 over Integer Ring' """ - return "Projective hypersurface defined by %s in %s"%( + return "Projective hypersurface defined by %s in %s" % ( self.defining_polynomial(), self.ambient_space()) def defining_polynomial(self): @@ -184,7 +185,7 @@ def __init__(self, poly, ambient=None): True """ if not isinstance(poly, MPolynomial): - raise TypeError("Defining polynomial (= %s) must be a multivariate polynomial"%poly) + raise TypeError("Defining polynomial (= %s) must be a multivariate polynomial" % poly) if ambient is None: R = poly.parent() from sage.schemes.affine.affine_space import AffineSpace @@ -207,7 +208,7 @@ def _repr_(self): sage: H._repr_() 'Affine hypersurface defined by y^2 + x*z in Affine Space of dimension 3 over Integer Ring' """ - return "Affine hypersurface defined by %s in %s"%( + return "Affine hypersurface defined by %s in %s" % ( self.defining_polynomial(), self.ambient_space()) def defining_polynomial(self): diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index 086c2960755..f42e8f4a680 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -165,7 +165,7 @@ def __init__(self, parent, codomain=None): if codomain is not None: parent = Hom(parent, codomain) if not isinstance(parent, Homset): - raise TypeError("parent (=%s) must be a Homspace"%parent) + raise TypeError("parent (=%s) must be a Homspace" % parent) Element.__init__(self, parent) self._codomain = parent.codomain() @@ -261,9 +261,9 @@ def __call__(self, x, *args, **kwds): try: x = D(x) except (TypeError, NotImplementedError): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain())) - elif self.domain()!=x.codomain(): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain())) + raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (x, self.domain())) + elif self.domain() != x.codomain(): + raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (x, self.domain())) else: x = converter(x) if not args and not kwds: @@ -330,14 +330,14 @@ def _repr_(self): NotImplementedError """ if self.is_endomorphism(): - s = "%s endomorphism of %s"%(self._repr_type(), self.domain()) + s = "%s endomorphism of %s" % (self._repr_type(), self.domain()) else: - s = "%s morphism:"%self._repr_type() - s += "\n From: %s"%self.domain() - s += "\n To: %s"%self._codomain + s = "%s morphism:" % self._repr_type() + s += "\n From: %s" % self.domain() + s += "\n To: %s" % self._codomain d = self._repr_defn() if d != '': - s += "\n Defn: %s"%('\n '.join(self._repr_defn().split('\n'))) + s += "\n Defn: %s" % ('\n '.join(self._repr_defn().split('\n'))) return s def __mul__(self, right): @@ -396,7 +396,7 @@ def __mul__(self, right): if not isinstance(right, SchemeMorphism): return coercion_model.bin_op(self, right, operator.mul) if right.codomain() != self.domain(): - raise TypeError("self (=%s) domain must equal right (=%s) codomain"%(self, right)) + raise TypeError("self (=%s) domain must equal right (=%s) codomain" % (self, right)) if isinstance(self, SchemeMorphism_id): return right if isinstance(right, SchemeMorphism_id): @@ -428,7 +428,7 @@ def __pow__(self, n, dummy=None): """ if not self.is_endomorphism(): raise TypeError("self must be an endomorphism.") - if n==0: + if n == 0: return self.domain().identity_morphism() return generic_power(self, n) @@ -513,9 +513,10 @@ def base_ring(self): :: - sage: E = EllipticCurve(GF((17,2)), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: P.base_ring() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF((17,2)), [1,2,3,4,5]) + sage: P = E.random_point() + sage: P.base_ring() Finite Field in z2 of size 17^2 """ return self.domain().base_ring() @@ -612,7 +613,7 @@ def glue_along_domains(self, other): OUTPUT: - Assuming that self and other are open immersions with the same + Assuming that ``self`` and ``other`` are open immersions with the same domain, return scheme obtained by gluing along the images. EXAMPLES: @@ -621,6 +622,7 @@ def glue_along_domains(self, other): `\mathrm{Spec}(\QQ)` by gluing two copies of `\mathbb{A}^1` minus a point:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) sage: S. = R.quotient(x*y - 1) sage: Rx = PolynomialRing(QQ, 'x') @@ -634,14 +636,13 @@ def glue_along_domains(self, other): Now f1 and f2 have the same domain, which is a `\mathbb{A}^1` minus a point. We glue along the domain:: - sage: P1 = f1.glue_along_domains(f2) - sage: P1 + sage: # needs sage.libs.singular + sage: P1 = f1.glue_along_domains(f2); P1 Scheme obtained by gluing X and Y along U, where X: Spectrum of Univariate Polynomial Ring in x over Rational Field Y: Spectrum of Univariate Polynomial Ring in y over Rational Field U: Spectrum of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x*y - 1) - sage: a, b = P1.gluing_maps() sage: a Affine Scheme morphism: @@ -972,7 +973,7 @@ class SchemeMorphism_polynomial(SchemeMorphism): Some checks are performed to make sure the given polynomials define a morphism:: - sage: f = H([exp(x),exp(y)]) + sage: f = H([exp(x),exp(y)]) # needs sage.symbolic Traceback (most recent call last): ... TypeError: polys (=[e^x, e^y]) must be elements of Multivariate @@ -995,11 +996,11 @@ def __init__(self, parent, polys, check=True): """ if check: if not isinstance(polys, (list, tuple)): - raise TypeError("polys (=%s) must be a list or tuple"%polys) + raise TypeError("polys (=%s) must be a list or tuple" % polys) source_ring = parent.domain().ambient_space().coordinate_ring() target = parent._codomain.ambient_space() if len(polys) != target.ngens(): - raise ValueError("there must be %s polynomials"%target.ngens()) + raise ValueError("there must be %s polynomials" % target.ngens()) F = [] for poly in polys: try: @@ -1011,7 +1012,7 @@ def __init__(self, parent, polys, check=True): try: p = source_ring(poly.numerator()) / source_ring(poly.denominator()) except (TypeError, AttributeError): - raise TypeError("polys (=%s) must be elements of %s"%(polys, source_ring)) + raise TypeError("polys (=%s) must be elements of %s" % (polys, source_ring)) F.append(p) polys = Sequence(F) @@ -1244,7 +1245,7 @@ def _repr_defn(self): """ i = self.domain().ambient_space()._repr_generic_point() o = self._codomain.ambient_space()._repr_generic_point(self.defining_polynomials()) - return "Defined on coordinates by sending %s to\n%s"%(i,o) + return "Defined on coordinates by sending %s to\n%s" % (i,o) def __getitem__(self, i): """ @@ -1342,27 +1343,29 @@ def change_ring(self, R, check=True): TESTS:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = QuadraticField(2) - sage: K2. = NumberField(t**4 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 1) # optional - sage.rings.number_field - sage: phi = K.embeddings(K2)[0] # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x**2 + 3*y**2, y**2]) # optional - sage.rings.number_field - sage: f.change_ring(phi) # optional - sage.rings.number_field + sage: K2. = NumberField(t**4 - 2) + sage: P. = ProjectiveSpace(QQ, 1) + sage: phi = K.embeddings(K2)[0] + sage: f = DynamicalSystem_projective([x**2 + 3*y**2, y**2]) + sage: f.change_ring(phi) Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial t^4 - 2 Defn: Defined on coordinates by sending (x : y) to (x^2 + 3*y^2 : y^2) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: K1. = NumberField(t^4 - 2) # optional - sage.rings.number_field - sage: K2. = NumberField(t^8 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: phi = K1.embeddings(K2)[0] # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + 3*y^2, y^2]) # optional - sage.rings.number_field - sage: f.change_ring(phi) # optional - sage.rings.number_field + sage: K. = QuadraticField(2) + sage: K1. = NumberField(t^4 - 2) + sage: K2. = NumberField(t^8 - 2) + sage: P. = ProjectiveSpace(K, 1) + sage: phi = K1.embeddings(K2)[0] + sage: f = DynamicalSystem_projective([x^2 + 3*y^2, y^2]) + sage: f.change_ring(phi) Traceback (most recent call last): ... ValueError: no canonical coercion of base ring of morphism to domain of embedding @@ -1373,7 +1376,7 @@ def change_ring(self, R, check=True): sage: P. = ProjectiveSpace(ZZ, 1) sage: H = Hom(P, P) sage: f = H([3*x^2, y^2]) - sage: f.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: f.change_ring(GF(3)) Scheme endomorphism of Projective Space of dimension 1 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (0 : y^2) @@ -1382,7 +1385,7 @@ def change_ring(self, R, check=True): sage: P. = ProjectiveSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([5/2*x^3 + 3*x*y^2 - y^3, 3*z^3 + y*x^2, x^3 - z^3]) - sage: f.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: f.change_ring(GF(3)) Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (x^3 - y^3 : x^2*y : x^3 - z^3) @@ -1393,7 +1396,7 @@ def change_ring(self, R, check=True): sage: X = P.subscheme([5*x^2 - y^2]) sage: H = Hom(X, X) sage: f = H([x, y]) - sage: f.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: f.change_ring(GF(3)) Scheme endomorphism of Closed subscheme of Projective Space of dimension 1 over Finite Field of size 3 defined by: -x^2 - y^2 Defn: Defined on coordinates by sending (x : y) to (x : y) @@ -1401,11 +1404,13 @@ def change_ring(self, R, check=True): Check that :trac:`16834` is fixed:: + sage: # needs sage.rings.real_mpfr sage: A. = AffineSpace(RR, 3) sage: h = Hom(A, A) sage: f = h([x^2 + 1.5, y^3, z^5 - 2.0]) sage: f.change_ring(CC) - Scheme endomorphism of Affine Space of dimension 3 over Complex Field with 53 bits of precision + Scheme endomorphism of Affine Space of dimension 3 over + Complex Field with 53 bits of precision Defn: Defined on coordinates by sending (x, y, z) to (x^2 + 1.50000000000000, y^3, z^5 - 2.00000000000000) @@ -1426,7 +1431,7 @@ def change_ring(self, R, check=True): sage: A. = AffineSpace(QQ, 2) sage: H = Hom(A, A) sage: f = H([3*x^2/y, y^2/x]) - sage: f.change_ring(RR) + sage: f.change_ring(RR) # needs sage.rings.real_mpfr Scheme endomorphism of Affine Space of dimension 2 over Real Field with 53 bits of precision Defn: Defined on coordinates by sending (x, y) to @@ -1434,18 +1439,19 @@ def change_ring(self, R, check=True): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^3 - x + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 + a*x*y + a^2*y^2, y^2]) # optional - sage.rings.number_field - sage: emb = K.embeddings(QQbar) # optional - sage.rings.number_field - sage: f.change_ring(emb[0]) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - x + 1) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 + a*x*y + a^2*y^2, y^2]) + sage: emb = K.embeddings(QQbar) + sage: f.change_ring(emb[0]) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to (x^2 + (-1.324717957244746?)*x*y + 1.754877666246693?*y^2 : y^2) - sage: f.change_ring(emb[1]) # optional - sage.rings.number_field + sage: f.change_ring(emb[1]) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to @@ -1454,11 +1460,12 @@ def change_ring(self, R, check=True): :: - sage: K. = QuadraticField(2, embedding=QQbar(sqrt(2))) # optional - sage.rings.number_field sage.symbolic - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field sage.symbolic - sage: H = End(P) # optional - sage.rings.number_field sage.symbolic - sage: f = H([x^2 + v*y^2, y^2]) # optional - sage.rings.number_field sage.symbolic - sage: f.change_ring(QQbar) # optional - sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field sage.symbolic + sage: K. = QuadraticField(2, embedding=QQbar(sqrt(2))) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 + v*y^2, y^2]) + sage: f.change_ring(QQbar) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to @@ -1466,14 +1473,15 @@ def change_ring(self, R, check=True): :: + sage: # needs sage.rings.number_field sage.symbolic sage: from sage.misc.verbose import set_verbose sage: set_verbose(-1) - sage: K. = QuadraticField(2, embedding=QQbar(-sqrt(2))) # optional - sage.rings.number_field sage.symbolic - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field sage.symbolic - sage: X = P.subscheme(x - y) # optional - sage.rings.number_field sage.symbolic - sage: H = End(X) # optional - sage.rings.number_field sage.symbolic - sage: f = H([6*x^2 + 2*x*y + 16*y^2, -w*x^2 - 4*x*y - 4*y^2]) # optional - sage.rings.number_field sage.symbolic - sage: f.change_ring(QQbar) # optional - sage.rings.number_field sage.symbolic + sage: K. = QuadraticField(2, embedding=QQbar(-sqrt(2))) + sage: P. = ProjectiveSpace(K, 1) + sage: X = P.subscheme(x - y) + sage: H = End(X) + sage: f = H([6*x^2 + 2*x*y + 16*y^2, -w*x^2 - 4*x*y - 4*y^2]) + sage: f.change_ring(QQbar) Scheme endomorphism of Closed subscheme of Projective Space of dimension 1 over Algebraic Field defined by: x - y Defn: Defined on coordinates by sending (x : y) to @@ -1481,25 +1489,27 @@ def change_ring(self, R, check=True): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: f = x^6 - 2 - sage: L. = NumberField(f, embedding=f.roots(QQbar)[1][0]) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: H = Hom(A, A) # optional - sage.rings.number_field - sage: F = H([b*x/y, 1 + y]) # optional - sage.rings.number_field - sage: F.change_ring(QQbar) # optional - sage.rings.number_field + sage: L. = NumberField(f, embedding=f.roots(QQbar)[1][0]) + sage: A. = AffineSpace(L, 2) + sage: H = Hom(A, A) + sage: F = H([b*x/y, 1 + y]) + sage: F.change_ring(QQbar) Scheme endomorphism of Affine Space of dimension 2 over Algebraic Field Defn: Defined on coordinates by sending (x, y) to (1.122462048309373?*x/y, y + 1) :: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: phi = H([x/y, y]) # optional - sage.rings.number_field - sage: emb = K.embeddings(QQbar)[0] # optional - sage.rings.number_field - sage: phi.change_ring(emb) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: A. = AffineSpace(K, 2) + sage: H = End(A) + sage: phi = H([x/y, y]) + sage: emb = K.embeddings(QQbar)[0] + sage: phi.change_ring(emb) Scheme endomorphism of Affine Space of dimension 2 over Algebraic Field Defn: Defined on coordinates by sending (x, y) to (x/y, y) """ @@ -1610,10 +1620,10 @@ def specialization(self, D=None, phi=None, homset=None): sage: R. = QQ[] sage: P. = ProjectiveSpace(R, 1) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2], domain=P) - sage: F = f.dynatomic_polynomial(3) + sage: F = f.dynatomic_polynomial(3) # needs sage.libs.pari sage: g = F.specialization({c: 1}); g x^6 + x^5*y + 4*x^4*y^2 + 3*x^3*y^3 + 7*x^2*y^4 + 4*x*y^5 + 5*y^6 - sage: g == f.specialization({c:1}).dynatomic_polynomial(3) + sage: g == f.specialization({c:1}).dynatomic_polynomial(3) # needs sage.libs.pari True :: @@ -1716,15 +1726,16 @@ def _composition_(self, other, homset): Not both defined by polynomials:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: p1, p2 = K.Hom(K) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: q1 = R.Hom(R)(p1) # optional - sage.rings.number_field - sage: A = AffineSpace(R) # optional - sage.rings.number_field - sage: f1 = A.Hom(A)(q1) # optional - sage.rings.number_field - sage: g = A.Hom(A)([x^2 - y, y + 1]) # optional - sage.rings.number_field - sage: g*f1 # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 2) + sage: p1, p2 = K.Hom(K) + sage: R. = K[] + sage: q1 = R.Hom(R)(p1) + sage: A = AffineSpace(R) + sage: f1 = A.Hom(A)(q1) + sage: g = A.Hom(A)([x^2 - y, y + 1]) + sage: g*f1 Composite map: From: Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2 @@ -1764,8 +1775,8 @@ def __init__(self, X): TESTS:: - sage: A = AffineSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: A.identity_morphism().defining_polynomials() # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(3)) + sage: A.identity_morphism().defining_polynomials() (x0, x1) """ super().__init__(X) @@ -1969,29 +1980,30 @@ def change_ring(self, R, check=True): sage: P. = ProjectiveSpace(ZZ, 2) sage: X = P.subscheme(x^2 - y^2) - sage: X(23,23,1).change_ring(GF(13)) # optional - sage.rings.finite_rings + sage: X(23,23,1).change_ring(GF(13)) (10 : 10 : 1) :: sage: P. = ProjectiveSpace(QQ, 1) - sage: P(-2/3,1).change_ring(CC) + sage: P(-2/3,1).change_ring(CC) # needs sage.rings.real_mpfr (-0.666666666666667 : 1.00000000000000) :: sage: P. = ProjectiveSpace(ZZ, 1) - sage: P(152,113).change_ring(Zp(5)) # optional - sage.rings.padics + sage: P(152,113).change_ring(Zp(5)) # needs sage.rings.padics (2 + 5^2 + 5^3 + O(5^20) : 3 + 2*5 + 4*5^2 + O(5^20)) :: - sage: K. = QuadraticField(-7) # optional - sage.rings.number_field - sage: O = K.maximal_order() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: F = H([x^2 + O(v)*y^2, y^2]) # optional - sage.rings.number_field - sage: F.change_ring(K).change_ring(K.embeddings(QQbar)[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-7) + sage: O = K.maximal_order() + sage: P. = ProjectiveSpace(O, 1) + sage: H = End(P) + sage: F = H([x^2 + O(v)*y^2, y^2]) + sage: F.change_ring(K).change_ring(K.embeddings(QQbar)[0]) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to @@ -1999,32 +2011,35 @@ def change_ring(self, R, check=True): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 - x + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: Q = P([a + 1, 1]) # optional - sage.rings.number_field - sage: emb = K.embeddings(QQbar) # optional - sage.rings.number_field - sage: Q.change_ring(emb[0]) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x + 1) + sage: P. = ProjectiveSpace(K, 1) + sage: Q = P([a + 1, 1]) + sage: emb = K.embeddings(QQbar) + sage: Q.change_ring(emb[0]) (1.5000000000000000? - 0.866025403784439?*I : 1) - sage: Q.change_ring(emb[1]) # optional - sage.rings.number_field + sage: Q.change_ring(emb[1]) (1.5000000000000000? + 0.866025403784439?*I : 1) :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: Q = P([v,1]) # optional - sage.rings.number_field - sage: Q.change_ring(K.embeddings(QQbar)[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: P. = ProjectiveSpace(K, 1) + sage: Q = P([v,1]) + sage: Q.change_ring(K.embeddings(QQbar)[0]) (-1.414213562373095? : 1) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: f = x^6 - 2 - sage: L. = NumberField(f, embedding=f.roots(QQbar)[1][0]) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: P = A([b,1]) # optional - sage.rings.number_field - sage: P.change_ring(QQbar) # optional - sage.rings.number_field + sage: L. = NumberField(f, embedding=f.roots(QQbar)[1][0]) + sage: A. = AffineSpace(L, 2) + sage: P = A([b,1]) + sage: P.change_ring(QQbar) (1.122462048309373?, 1) """ S = self.codomain().change_ring(R) diff --git a/src/sage/schemes/generic/point.py b/src/sage/schemes/generic/point.py index c3f628159aa..c65963e3eaa 100644 --- a/src/sage/schemes/generic/point.py +++ b/src/sage/schemes/generic/point.py @@ -66,7 +66,7 @@ def _repr_(self): sage: P._repr_() 'Point on Spectrum of Integer Ring' """ - return "Point on %s"%self.__S + return "Point on %s" % self.__S ######################################################## # Topological points on a scheme @@ -179,7 +179,7 @@ def __init__(self, S, P, check=False): # unfortunately is_prime() is only implemented in a small # number of cases if check and not P.is_prime(): - raise ValueError("The argument %s must be a prime ideal of %s"%(P, R)) + raise ValueError("The argument %s must be a prime ideal of %s" % (P, R)) SchemeTopologicalPoint.__init__(self, S) self.__P = P @@ -197,7 +197,7 @@ def _repr_(self): sage: pt._repr_() 'Point on Projective Space of dimension 2 over Rational Field defined by the Ideal (-x^2 + y*z) of Multivariate Polynomial Ring in x, y, z over Rational Field' """ - return "Point on %s defined by the %s"%(self.scheme(), + return "Point on %s defined by the %s" % (self.scheme(), self.prime_ideal()) def prime_ideal(self): @@ -247,7 +247,7 @@ def __init__(self, f): self.__f = f def _repr_(self): - return "Point on %s defined by the morphism %s"%(self.scheme(), + return "Point on %s defined by the morphism %s" % (self.scheme(), self.morphism()) def morphism(self): diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py index 3b039697814..fe55bca9117 100644 --- a/src/sage/schemes/generic/scheme.py +++ b/src/sage/schemes/generic/scheme.py @@ -96,7 +96,7 @@ def __init__(self, X=None, category=None): sage: I = (x^2 - y^2)*R sage: RmodI = R.quotient(I) sage: X = Spec(RmodI) - sage: TestSuite(X).run() + sage: TestSuite(X).run() # needs sage.libs.singular """ from sage.schemes.generic.morphism import is_SchemeMorphism @@ -216,17 +216,17 @@ def __call__(self, *args): sage: A(QQ) Set of rational points of Affine Space of dimension 2 over Rational Field - sage: A(RR) + sage: A(RR) # needs sage.rings.real_mpfr Set of rational points of Affine Space of dimension 2 over Real Field with 53 bits of precision Space of dimension 2 over Rational Field:: sage: R. = PolynomialRing(QQ) - sage: A(NumberField(x^2 + 1, 'a')) # optional - sage.rings.number_field + sage: A(NumberField(x^2 + 1, 'a')) # needs sage.rings.number_field Set of rational points of Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 + 1 - sage: A(GF(7)) # optional - sage.rings.finite_rings + sage: A(GF(7)) Traceback (most recent call last): ... ValueError: There must be a natural map S --> R, but @@ -285,14 +285,14 @@ def point_homset(self, S=None): Set of rational points of Projective Space of dimension 3 over Integer Ring sage: P.point_homset(QQ) Set of rational points of Projective Space of dimension 3 over Rational Field - sage: P.point_homset(GF(11)) # optional - sage.rings.finite_rings + sage: P.point_homset(GF(11)) Set of rational points of Projective Space of dimension 3 over Finite Field of size 11 TESTS:: sage: P = ProjectiveSpace(QQ, 3) - sage: P.point_homset(GF(11)) # optional - sage.rings.finite_rings + sage: P.point_homset(GF(11)) Traceback (most recent call last): ... ValueError: There must be a natural map S --> R, but @@ -326,8 +326,8 @@ def point(self, v, check=True): (4, 5) sage: R. = PolynomialRing(QQ) - sage: E = EllipticCurve([t + 1, t, t, 0, 0]) - sage: E.point([0, 0]) + sage: E = EllipticCurve([t + 1, t, t, 0, 0]) # needs sage.schemes + sage: E.point([0, 0]) # needs sage.schemes (0 : 0 : 1) """ # todo: update elliptic curve stuff to take point_homset as argument @@ -386,7 +386,7 @@ def __truediv__(self, Y): Affine Space of dimension 3 over Integer Ring sage: A/QQ Affine Space of dimension 3 over Rational Field - sage: A/GF(7) # optional - sage.rings.finite_rings + sage: A/GF(7) Affine Space of dimension 3 over Finite Field of size 7 """ return self.base_extend(Y) @@ -645,8 +645,8 @@ def _Hom_(self, Y, category=None, check=True): sage: S._Hom_(P).__class__ - sage: E = EllipticCurve('37a1') - sage: Hom(E, E).__class__ + sage: E = EllipticCurve('37a1') # needs sage.schemes + sage: Hom(E, E).__class__ # needs sage.schemes sage: Hom(Spec(ZZ), Spec(ZZ)).__class__ @@ -672,18 +672,19 @@ def count_points(self, n): EXAMPLES:: - sage: P. = PolynomialRing(GF(3)) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(x^3 + x^2 + 1) # optional - sage.rings.finite_rings - sage: C.count_points(4) # optional - sage.rings.finite_rings + sage: # needs sage.schemes + sage: P. = PolynomialRing(GF(3)) + sage: C = HyperellipticCurve(x^3 + x^2 + 1) + sage: C.count_points(4) [6, 12, 18, 96] - sage: C.base_extend(GF(9,'a')).count_points(2) # optional - sage.rings.finite_rings + sage: C.base_extend(GF(9,'a')).count_points(2) # needs sage.rings.finite_rings [12, 96] :: - sage: P. = ProjectiveSpace(GF(4, 't'), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme([y^2*z - x^3 - z^3]) # optional - sage.rings.finite_rings - sage: X.count_points(2) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(4, 't'), 2) # needs sage.rings.finite_rings + sage: X = P.subscheme([y^2*z - x^3 - z^3]) # needs sage.rings.finite_rings + sage: X.count_points(2) # needs sage.rings.finite_rings [5, 17] """ F = self.base_ring() @@ -706,9 +707,9 @@ def zeta_function(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(4, 't'), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme([y^2*z - x^3 - z^3]) # optional - sage.rings.finite_rings - sage: X.zeta_function() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(4, 't'), 2) # needs sage.rings.finite_rings + sage: X = P.subscheme([y^2*z - x^3 - z^3]) # needs sage.rings.finite_rings + sage: X.zeta_function() # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError @@ -734,12 +735,12 @@ def zeta_series(self, n, t): EXAMPLES:: - sage: P. = PolynomialRing(GF(3)) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(x^3 + x^2 + 1) # optional - sage.rings.finite_rings + sage: P. = PolynomialRing(GF(3)) + sage: C = HyperellipticCurve(x^3 + x^2 + 1) # needs sage.schemes sage: R. = PowerSeriesRing(Integers()) - sage: C.zeta_series(4, t) # optional - sage.rings.finite_rings + sage: C.zeta_series(4, t) # needs sage.schemes 1 + 6*t + 24*t^2 + 78*t^3 + 240*t^4 + O(t^5) - sage: (1+2*t+3*t^2)/(1-t)/(1-3*t) + O(t^5) # optional - sage.rings.finite_rings + sage: (1+2*t+3*t^2)/(1-t)/(1-3*t) + O(t^5) 1 + 6*t + 24*t^2 + 78*t^3 + 240*t^4 + O(t^5) If the scheme has a method ``zeta_function``, this is used to @@ -749,23 +750,24 @@ def zeta_series(self, n, t): Nonetheless, since :trac:`15108` and :trac:`15148`, it supports hyperelliptic curves over non-prime fields:: - sage: C.base_extend(GF(9, 'a')).zeta_series(4, t) # optional - sage.rings.finite_rings + sage: C.base_extend(GF(9, 'a')).zeta_series(4, t) # needs sage.rings.finite_rings sage.schemes 1 + 12*t + 120*t^2 + 1092*t^3 + 9840*t^4 + O(t^5) :: - sage: P. = ProjectiveSpace(GF(4, 't'), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme([y^2*z - x^3 - z^3]) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(4, 't'), 2) # needs sage.rings.finite_rings + sage: X = P.subscheme([y^2*z - x^3 - z^3]) # needs sage.rings.finite_rings + sage: R. = PowerSeriesRing(Integers()) - sage: X.zeta_series(2, t) # optional - sage.rings.finite_rings + sage: X.zeta_series(2, t) # needs sage.libs.singular sage.rings.finite_rings 1 + 5*t + 21*t^2 + O(t^3) TESTS:: sage: P. = PolynomialRing(ZZ) - sage: C = HyperellipticCurve(x^3 + x + 1) + sage: C = HyperellipticCurve(x^3 + x + 1) # needs sage.schemes sage: R. = PowerSeriesRing(Integers()) - sage: C.zeta_series(4, t) + sage: C.zeta_series(4, t) # needs sage.schemes Traceback (most recent call last): ... TypeError: zeta functions only defined for schemes @@ -952,8 +954,9 @@ def __call__(self, *args): Point on Spectrum of Integer Ring defined by the Principal ideal (3) of Integer Ring sage: type(P) - sage: S(ZZ.ideal(next_prime(1000000))) - Point on Spectrum of Integer Ring defined by the Principal ideal (1000003) of Integer Ring + sage: S(ZZ.ideal(next_prime(1000000))) # needs sage.libs.pari + Point on Spectrum of Integer Ring + defined by the Principal ideal (1000003) of Integer Ring sage: R. = QQ[] sage: S = Spec(R) @@ -1203,8 +1206,8 @@ def hom(self, x, Y=None): sage: S. = QQ[] sage: A1. = AffineSpace(QQ, 1) - sage: A1_emb = Curve(p - 2) - sage: A1.hom([2, r], A1_emb) + sage: A1_emb = Curve(p - 2) # needs sage.schemes + sage: A1.hom([2, r], A1_emb) # needs sage.schemes Scheme morphism: From: Affine Space of dimension 1 over Rational Field To: Affine Plane Curve over Rational Field defined by p - 2 diff --git a/src/sage/schemes/generic/spec.py b/src/sage/schemes/generic/spec.py index 60f46664e31..c9a07313bb3 100644 --- a/src/sage/schemes/generic/spec.py +++ b/src/sage/schemes/generic/spec.py @@ -42,10 +42,10 @@ def Spec(R, S=None): Spectrum of Univariate Polynomial Ring in x over Rational Field sage: Spec(PolynomialRing(QQ, 'x', 3)) Spectrum of Multivariate Polynomial Ring in x0, x1, x2 over Rational Field - sage: X = Spec(PolynomialRing(GF(49,'a'), 3, 'x')); X # optional - sage.rings.finite_rings + sage: X = Spec(PolynomialRing(GF(49,'a'), 3, 'x')); X # needs sage.rings.finite_rings Spectrum of Multivariate Polynomial Ring in x0, x1, x2 over Finite Field in a of size 7^2 - sage: TestSuite(X).run() # optional - sage.rings.finite_rings + sage: TestSuite(X).run() # needs sage.rings.finite_rings Applying ``Spec`` twice to the same ring gives identical output (see :trac:`17008`):: @@ -60,7 +60,7 @@ def Spec(R, S=None): Traceback (most recent call last): ... TypeError: x (=5) is not in Category of commutative rings - sage: Spec(FreeAlgebra(QQ, 2, 'x')) + sage: Spec(FreeAlgebra(QQ, 2, 'x')) # needs sage.combinat sage.modules Traceback (most recent call last): ... TypeError: x (=Free Algebra on 2 generators (x0, x1) over Rational Field) @@ -152,7 +152,7 @@ def _apply_functor(self, A): sage: from sage.schemes.generic.spec import SpecFunctor sage: F = SpecFunctor() - sage: F(RR) # indirect doctest + sage: F(RR) # indirect doctest # needs sage.rings.real_mpfr Spectrum of Real Field with 53 bits of precision """ # The second argument of AffineScheme defaults to None. @@ -170,11 +170,11 @@ def _apply_functor_to_morphism(self, f): EXAMPLES:: sage: from sage.schemes.generic.spec import SpecFunctor - sage: F = SpecFunctor(GF(7)) # optional - sage.rings.finite_rings - sage: A. = GF(7)[] # optional - sage.rings.finite_rings - sage: B. = GF(7)[] # optional - sage.rings.finite_rings - sage: f = A.hom((t^2, t^3)) # optional - sage.rings.finite_rings - sage: Spec(f) # indirect doctest # optional - sage.rings.finite_rings + sage: F = SpecFunctor(GF(7)) + sage: A. = GF(7)[] + sage: B. = GF(7)[] + sage: f = A.hom((t^2, t^3)) + sage: Spec(f) # indirect doctest Affine Scheme morphism: From: Spectrum of Univariate Polynomial Ring in t over Finite Field of size 7 To: Spectrum of Multivariate Polynomial Ring in x, y over Finite Field of size 7 diff --git a/src/sage/schemes/hyperelliptic_curves/constructor.py b/src/sage/schemes/hyperelliptic_curves/constructor.py index 121da1bf072..de93cc7e371 100644 --- a/src/sage/schemes/hyperelliptic_curves/constructor.py +++ b/src/sage/schemes/hyperelliptic_curves/constructor.py @@ -74,41 +74,40 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True): sage: HyperellipticCurve(x^19 + x + 1, x - 2) Hyperelliptic Curve over Rational Field defined by y^2 + (x - 2)*y = x^19 + x + 1 - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^3 + x - 1, x+a) # optional - sage.rings.finite_rings + sage: k. = GF(9); R. = k[] # needs sage.rings.finite_rings + sage: HyperellipticCurve(x^3 + x - 1, x+a) # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 3^2 defined by y^2 + (x + a)*y = x^3 + x + 2 Characteristic two:: - sage: P. = GF(8, 'a')[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^7 + 1, x) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P. = GF(8, 'a')[] + sage: HyperellipticCurve(x^7 + 1, x) Hyperelliptic Curve over Finite Field in a of size 2^3 defined by y^2 + x*y = x^7 + 1 - sage: HyperellipticCurve(x^8 + x^7 + 1, x^4 + 1) # optional - sage.rings.finite_rings + sage: HyperellipticCurve(x^8 + x^7 + 1, x^4 + 1) Hyperelliptic Curve over Finite Field in a of size 2^3 defined by y^2 + (x^4 + 1)*y = x^8 + x^7 + 1 - - sage: HyperellipticCurve(x^8 + 1, x) # optional - sage.rings.finite_rings + sage: HyperellipticCurve(x^8 + 1, x) Traceback (most recent call last): ... ValueError: Not a hyperelliptic curve: highly singular at infinity. - - sage: HyperellipticCurve(x^8 + x^7 + 1, x^4) # optional - sage.rings.finite_rings + sage: HyperellipticCurve(x^8 + x^7 + 1, x^4) Traceback (most recent call last): ... ValueError: Not a hyperelliptic curve: singularity in the provided affine patch. - sage: F. = PowerSeriesRing(FiniteField(2)) # optional - sage.rings.finite_rings - sage: P. = PolynomialRing(FractionField(F)) # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^5 + t, x) # optional - sage.rings.finite_rings + sage: F. = PowerSeriesRing(FiniteField(2)) + sage: P. = PolynomialRing(FractionField(F)) + sage: HyperellipticCurve(x^5 + t, x) Hyperelliptic Curve over Laurent Series Ring in t over Finite Field of size 2 defined by y^2 + x*y = x^5 + t We can change the names of the variables in the output:: - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^3 + x - 1, x + a, names=['X','Y']) # optional - sage.rings.finite_rings + sage: k. = GF(9); R. = k[] # needs sage.rings.finite_rings + sage: HyperellipticCurve(x^3 + x - 1, x + a, names=['X','Y']) # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 3^2 defined by Y^2 + (X + a)*Y = X^3 + X + 2 @@ -125,13 +124,13 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True): Double roots:: - sage: P. = GF(7)[] # optional - sage.rings.finite_rings + sage: P. = GF(7)[] sage: HyperellipticCurve((x^3-x+2)^2*(x^6-1)) Traceback (most recent call last): ... ValueError: Not a hyperelliptic curve: singularity in the provided affine patch. - sage: HyperellipticCurve((x^3-x+2)^2*(x^6-1), check_squarefree=False) # optional - sage.rings.finite_rings + sage: HyperellipticCurve((x^3-x+2)^2*(x^6-1), check_squarefree=False) Hyperelliptic Curve over Finite Field of size 7 defined by y^2 = x^12 + 5*x^10 + 4*x^9 + x^8 + 3*x^7 + 3*x^6 + 2*x^4 + 3*x^3 + 6*x^2 + 4*x + 3 @@ -156,9 +155,9 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True): An example with a singularity over an inseparable extension of the base field:: - sage: F. = GF(5)[] # optional - sage.rings.finite_rings - sage: P. = F[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^5 + t) # optional - sage.rings.finite_rings + sage: F. = GF(5)[] + sage: P. = F[] + sage: HyperellipticCurve(x^5 + t) Traceback (most recent call last): ... ValueError: Not a hyperelliptic curve: singularity in the provided affine patch. @@ -182,17 +181,19 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True): Check that two curves with the same class name have the same class type:: - sage: R. = PolynomialRing(GF(next_prime(10^9))) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(t^5 + t + 1) # optional - sage.rings.finite_rings - sage: C2 = HyperellipticCurve(t^5 + 3*t + 1) # optional - sage.rings.finite_rings - sage: type(C2) == type(C) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = PolynomialRing(GF(next_prime(10^9))) + sage: C = HyperellipticCurve(t^5 + t + 1) + sage: C2 = HyperellipticCurve(t^5 + 3*t + 1) + sage: type(C2) == type(C) True Check that the inheritance is correct:: - sage: R. = PolynomialRing(GF(next_prime(10^9))) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(t^5 + t + 1) # optional - sage.rings.finite_rings - sage: type(C).mro() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = PolynomialRing(GF(next_prime(10^9))) + sage: C = HyperellipticCurve(t^5 + t + 1) + sage: type(C).mro() [, , , diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py index ddb2cd61479..a4cabb5bb93 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Hyperelliptic curves over a finite field @@ -644,7 +644,7 @@ def _points_fast_sqrt(self): # (0:1:0) is a point on the curve points = [self.point([K(0), K(1), K(0)], check=True)] else: - points=[] + points = [] if P.degree() > 2: # P(1, y, 0) = r*y + s s = P(K(1), K(0), K(0)) @@ -1109,7 +1109,7 @@ def count_points_hypellfrob(self, n=1, N=None, algorithm=None): raise ValueError("Unknown algorithm") if p <= (2*g+1)*(2*N-1): - raise ValueError("p=%d should be greater than (2*g+1)(2*N-1)=%d"%(p,(2*g+1)*(2*N-1))) + raise ValueError("p=%d should be greater than (2*g+1)(2*N-1)=%d" % (p,(2*g+1)*(2*N-1))) if algorithm == 'traces': M = self.frobenius_matrix(N=N, algorithm='hypellfrob') @@ -1535,16 +1535,16 @@ def _Cartier_matrix_cached(self): #retrieve the function f(x) ,where y^2=f(x) f,h = self.hyperelliptic_polynomials() #This implementation only deals with h=0 - if h!=0: + if h != 0: raise ValueError("E must be of the form y^2 = f(x)") d = f.degree() #this implementation is for odd degree only, even degree will be handled later. - if d%2 == 0: + if d % 2 == 0: raise ValueError("In this implementation the degree of f must be odd") #Compute resultant to make sure no repeated roots - df=f.derivative() - R=df.resultant(f) + df = f.derivative() + R = df.resultant(f) if R == 0: raise ValueError("curve is not smooth") @@ -1566,9 +1566,9 @@ def _Cartier_matrix_cached(self): # compute each row of matrix as list and then M=list of lists(rows) - M=[] + M = [] for j in range(1,g+1): - H=[Coeff[i] for i in range((p*j-1), (p*j-g-1),-1)] + H = [Coeff[i] for i in range((p*j-1), (p*j-g-1),-1)] M.append(H) return matrix(Fq,M), Coeff, g, Fq,p, self @@ -1657,10 +1657,10 @@ def Cartier_matrix(self): # Github Issue #11115: Why shall we waste time by studying # the cache manually? We only need to check whether the cached # data belong to self. - M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() - if E!=self: + M, Coeffs,g, Fq, p, E = self._Cartier_matrix_cached() + if E != self: self._Cartier_matrix_cached.clear_cache() - M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() + M, Coeffs,g, Fq, p, E = self._Cartier_matrix_cached() return M @cached_method @@ -1824,10 +1824,10 @@ def Hasse_Witt(self): # from the cache - but apparently it could be # that the cached value does not belong to self. # So, the easiest is: - N, E= self._Hasse_Witt_cached() - if E!=self: + N, E = self._Hasse_Witt_cached() + if E != self: self._Hasse_Witt_cached.clear_cache() - N, E= self._Hasse_Witt_cached() + N, E = self._Hasse_Witt_cached() return N def a_number(self): @@ -1866,10 +1866,10 @@ def a_number(self): # Since Github Issue #11115, there is a special cache for methods # that don't accept arguments. The easiest is: Call the cached # method, and test whether the last entry is self. - M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() + M,Coeffs,g, Fq, p,E = self._Cartier_matrix_cached() if E != self: self._Cartier_matrix_cached.clear_cache() - M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() + M,Coeffs,g, Fq, p,E = self._Cartier_matrix_cached() return g - rank(M) def p_rank(self): diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py index 19d767ea2f3..7a8fe986448 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py @@ -27,7 +27,7 @@ def is_odd_degree(self): f, h = self.hyperelliptic_polynomials() df = f.degree() if h.degree() < 3: - return df%2 == 1 + return df % 2 == 1 elif df < 6: return False else: @@ -95,13 +95,14 @@ def clebsch_invariants(self): TESTS:: - sage: magma(HyperellipticCurve(f)).ClebschInvariants() # optional - magma + sage: # optional - magma + sage: magma(HyperellipticCurve(f)).ClebschInvariants() [ 0, -2048/375, -4096/25, -4881645568/84375 ] - sage: magma(HyperellipticCurve(f(2*x))).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x))).ClebschInvariants() [ 0, -8388608/375, -1073741824/25, -5241627016305836032/84375 ] - sage: magma(HyperellipticCurve(f, x)).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f, x)).ClebschInvariants() [ -8/15, 17504/5625, -23162896/140625, -420832861216768/7119140625 ] - sage: magma(HyperellipticCurve(f(2*x), 2*x)).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x), 2*x)).ClebschInvariants() [ -512/15, 71696384/5625, -6072014209024/140625, -451865844002031331704832/7119140625 ] """ f, h = self.hyperelliptic_polynomials() @@ -131,13 +132,14 @@ def igusa_clebsch_invariants(self): TESTS:: - sage: magma(HyperellipticCurve(f)).IgusaClebschInvariants() # optional - magma + sage: # optional - magma + sage: magma(HyperellipticCurve(f)).IgusaClebschInvariants() [ -640, -20480, 1310720, 52160364544 ] - sage: magma(HyperellipticCurve(f(2*x))).IgusaClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x))).IgusaClebschInvariants() [ -40960, -83886080, 343597383680, 56006764965979488256 ] - sage: magma(HyperellipticCurve(f, x)).IgusaClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f, x)).IgusaClebschInvariants() [ -640, 17920, -1966656, 52409511936 ] - sage: magma(HyperellipticCurve(f(2*x), 2*x)).IgusaClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x), 2*x)).IgusaClebschInvariants() [ -40960, 73400320, -515547070464, 56274284941110411264 ] """ f, h = self.hyperelliptic_polynomials() @@ -203,13 +205,14 @@ def clebsch_invariants(self): TESTS:: - sage: magma(HyperellipticCurve(f)).ClebschInvariants() # optional - magma + sage: # optional - magma + sage: magma(HyperellipticCurve(f)).ClebschInvariants() [ 0, -2048/375, -4096/25, -4881645568/84375 ] - sage: magma(HyperellipticCurve(f(2*x))).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x))).ClebschInvariants() [ 0, -8388608/375, -1073741824/25, -5241627016305836032/84375 ] - sage: magma(HyperellipticCurve(f, x)).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f, x)).ClebschInvariants() [ -8/15, 17504/5625, -23162896/140625, -420832861216768/7119140625 ] - sage: magma(HyperellipticCurve(f(2*x), 2*x)).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x), 2*x)).ClebschInvariants() [ -512/15, 71696384/5625, -6072014209024/140625, -451865844002031331704832/7119140625 ] """ f, h = self.hyperelliptic_polynomials() diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py index a56fee001cf..8c94e32705a 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py @@ -3,9 +3,9 @@ EXAMPLES:: - sage: P. = GF(5)[] # optional - sage.rings.finite_rings - sage: f = x^5 - 3*x^4 - 2*x^3 + 6*x^2 + 3*x - 1 # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(f); C # optional - sage.rings.finite_rings + sage: P. = GF(5)[] + sage: f = x^5 - 3*x^4 - 2*x^3 + 6*x^2 + 3*x - 1 + sage: C = HyperellipticCurve(f); C Hyperelliptic Curve over Finite Field of size 5 defined by y^2 = x^5 + 2*x^4 + 3*x^3 + x^2 + 3*x + 4 @@ -85,14 +85,14 @@ class HyperellipticCurve_generic(plane_curve.ProjectivePlaneCurve): sage: C0 = HyperellipticCurve(f0) sage: f1 = x^5 - x^3 + x - 22 sage: C1 = HyperellipticCurve(f1) - sage: Q. = GF(5)[] # optional - sage.rings.finite_rings - sage: f2 = y^5 - y^3 + y - 22 # optional - sage.rings.finite_rings - sage: C2 = HyperellipticCurve(f2) # optional - sage.rings.finite_rings + sage: Q. = GF(5)[] + sage: f2 = y^5 - y^3 + y - 22 + sage: C2 = HyperellipticCurve(f2) sage: hash(C0) == hash(C0) True sage: hash(C0) == hash(C1) False - sage: hash(C1) == hash(C2) # optional - sage.rings.finite_rings + sage: hash(C1) == hash(C2) False """ def __init__(self, PP, f, h=None, names=None, genus=None): @@ -126,20 +126,21 @@ def change_ring(self, R): EXAMPLES:: + sage: # needs sage.rings.padics sage: R. = QQ[] sage: H = HyperellipticCurve(x^5 - 10*x + 9) - sage: K = Qp(3, 5) # optional - sage.rings.padics - sage: L. = K.extension(x^30 - 3) # optional - sage.rings.padics - sage: HK = H.change_ring(K) # optional - sage.rings.padics - sage: HL = HK.change_ring(L); HL # optional - sage.rings.padics + sage: K = Qp(3, 5) + sage: L. = K.extension(x^30 - 3) + sage: HK = H.change_ring(K) + sage: HL = HK.change_ring(L); HL Hyperelliptic Curve over 3-adic Eisenstein Extension Field in a defined by x^30 - 3 defined by (1 + O(a^150))*y^2 = (1 + O(a^150))*x^5 + (2 + 2*a^30 + a^60 + 2*a^90 + 2*a^120 + O(a^150))*x + a^60 + O(a^210) - sage: R. = FiniteField(7)[] # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^8 + x + 5) # optional - sage.rings.finite_rings - sage: H.base_extend(FiniteField(7^2, 'a')) # optional - sage.rings.finite_rings + sage: R. = FiniteField(7)[] + sage: H = HyperellipticCurve(x^8 + x + 5) + sage: H.base_extend(FiniteField(7^2, 'a')) # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 7^2 defined by y^2 = x^8 + x + 5 """ @@ -147,7 +148,7 @@ def change_ring(self, R): f, h = self._hyperelliptic_polynomials y = self._printing_ring.variable_name() x = self._printing_ring.base_ring().variable_name() - return HyperellipticCurve(f.change_ring(R), h.change_ring(R), "%s,%s"%(x,y)) + return HyperellipticCurve(f.change_ring(R), h.change_ring(R), "%s,%s" % (x,y)) base_extend = change_ring @@ -225,23 +226,24 @@ def is_smooth(self): EXAMPLES:: - sage: R. = GF(13)[] # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^8 + 1) # optional - sage.rings.finite_rings - sage: H.is_smooth() # optional - sage.rings.finite_rings + sage: R. = GF(13)[] + sage: H = HyperellipticCurve(x^8 + 1) + sage: H.is_smooth() True A hyperelliptic curve with genus at least 2 always has a singularity at infinity when viewed as a *plane* projective curve. This can be seen in the following example.:: - sage: R. = GF(27, 'a')[] # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^10 + 2) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(27, 'a')[] + sage: H = HyperellipticCurve(x^10 + 2) sage: from sage.misc.verbose import set_verbose sage: set_verbose(-1) - sage: H.is_smooth() # optional - sage.rings.finite_rings + sage: H.is_smooth() True sage: from sage.schemes.curves.projective_curve import ProjectivePlaneCurve - sage: ProjectivePlaneCurve.is_smooth(H) # optional - sage.rings.finite_rings + sage: ProjectivePlaneCurve.is_smooth(H) False """ return True @@ -268,7 +270,7 @@ def lift_x(self, x, all=False): if all: return [] else: - raise ValueError("No point with x-coordinate %s on %s"%(x, self)) + raise ValueError("No point with x-coordinate %s on %s" % (x, self)) def genus(self): return self._genus @@ -291,14 +293,14 @@ def odd_degree_model(self): ... ValueError: No odd degree model exists over field of definition - sage: K2 = QuadraticField(-2, 'a') # optional - sage.rings.number_field - sage: Hp2 = H.change_ring(K2).odd_degree_model(); Hp2 # optional - sage.rings.number_field + sage: K2 = QuadraticField(-2, 'a') # needs sage.rings.number_field + sage: Hp2 = H.change_ring(K2).odd_degree_model(); Hp2 # needs sage.rings.number_field Hyperelliptic Curve over Number Field in a with defining polynomial x^2 + 2 with a = 1.414213562373095?*I defined by y^2 = 6*a*x^5 - 29*x^4 - 20*x^2 + 6*a*x + 1 - sage: K3 = QuadraticField(-3, 'b') # optional - sage.rings.number_field - sage: Hp3 = H.change_ring(QuadraticField(-3, 'b')).odd_degree_model(); Hp3 # optional - sage.rings.number_field + sage: K3 = QuadraticField(-3, 'b') # needs sage.rings.number_field + sage: Hp3 = H.change_ring(QuadraticField(-3, 'b')).odd_degree_model(); Hp3 # needs sage.rings.number_field Hyperelliptic Curve over Number Field in b with defining polynomial x^2 + 3 with b = 1.732050807568878?*I defined by y^2 = -4*b*x^5 - 14*x^4 - 20*b*x^3 - 35*x^2 + 6*b*x + 1 @@ -309,22 +311,26 @@ def odd_degree_model(self): points on their reductions. 43 and 67 split completely in the compositum, so when we reduce we find: - sage: P2 = K2.factor(43)[0][0] # optional - sage.rings.number_field - sage: P3 = K3.factor(43)[0][0] # optional - sage.rings.number_field - sage: Hp2.change_ring(K2.residue_field(P2)).frobenius_polynomial() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P2 = K2.factor(43)[0][0] + sage: P3 = K3.factor(43)[0][0] + sage: Hp2.change_ring(K2.residue_field(P2)).frobenius_polynomial() x^4 - 16*x^3 + 134*x^2 - 688*x + 1849 - sage: Hp3.change_ring(K3.residue_field(P3)).frobenius_polynomial() # optional - sage.rings.number_field + sage: Hp3.change_ring(K3.residue_field(P3)).frobenius_polynomial() x^4 - 16*x^3 + 134*x^2 - 688*x + 1849 - sage: H.change_ring(GF(43)).odd_degree_model().frobenius_polynomial() # optional - sage.rings.finite_rings + + sage: H.change_ring(GF(43)).odd_degree_model().frobenius_polynomial() # needs sage.rings.finite_rings x^4 - 16*x^3 + 134*x^2 - 688*x + 1849 - sage: P2 = K2.factor(67)[0][0] # optional - sage.rings.number_field - sage: P3 = K3.factor(67)[0][0] # optional - sage.rings.number_field - sage: Hp2.change_ring(K2.residue_field(P2)).frobenius_polynomial() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P2 = K2.factor(67)[0][0] + sage: P3 = K3.factor(67)[0][0] + sage: Hp2.change_ring(K2.residue_field(P2)).frobenius_polynomial() x^4 - 8*x^3 + 150*x^2 - 536*x + 4489 - sage: Hp3.change_ring(K3.residue_field(P3)).frobenius_polynomial() # optional - sage.rings.number_field + sage: Hp3.change_ring(K3.residue_field(P3)).frobenius_polynomial() x^4 - 8*x^3 + 150*x^2 - 536*x + 4489 - sage: H.change_ring(GF(67)).odd_degree_model().frobenius_polynomial() # optional - sage.rings.finite_rings + + sage: H.change_ring(GF(67)).odd_degree_model().frobenius_polynomial() # needs sage.rings.finite_rings x^4 - 8*x^3 + 150*x^2 - 536*x + 4489 TESTS:: @@ -382,22 +388,23 @@ def _magma_init_(self, magma): EXAMPLES:: + sage: # optional - magma sage: R. = QQ[]; C = HyperellipticCurve(x^3 + x - 1, x); C Hyperelliptic Curve over Rational Field defined by y^2 + x*y = x^3 + x - 1 - sage: magma(C) # optional - magma + sage: magma(C) Hyperelliptic Curve defined by y^2 + x*y = x^3 + x - 1 over Rational Field - sage: R. = GF(9,'a')[]; C = HyperellipticCurve(x^3 + x - 1, x^10); C # optional - sage.rings.finite_rings + sage: R. = GF(9,'a')[]; C = HyperellipticCurve(x^3 + x - 1, x^10); C # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 3^2 defined by y^2 + x^10*y = x^3 + x + 2 - sage: D = magma(C); D # optional - magma # optional - sage.rings.finite_rings + sage: D = magma(C); D # needs sage.rings.finite_rings Hyperelliptic Curve defined by y^2 + (x^10)*y = x^3 + x + 2 over GF(3^2) - sage: D.sage() # optional - magma # optional - sage.rings.finite_rings + sage: D.sage() # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 3^2 defined by y^2 + x^10*y = x^3 + x + 2 """ f, h = self._hyperelliptic_polynomials - return 'HyperellipticCurve(%s, %s)'%(f._magma_init_(magma), h._magma_init_(magma)) + return 'HyperellipticCurve(%s, %s)' % (f._magma_init_(magma), h._magma_init_(magma)) def monsky_washnitzer_gens(self): import sage.schemes.hyperelliptic_curves.monsky_washnitzer as monsky_washnitzer @@ -462,7 +469,7 @@ def local_coordinates_at_nonweierstrass(self, P, prec=20, name='t'): """ d = P[1] if d == 0: - raise TypeError("P = %s is a Weierstrass point. Use local_coordinates_at_weierstrass instead!"%P) + raise TypeError("P = %s is a Weierstrass point. Use local_coordinates_at_weierstrass instead!" % P) pol = self.hyperelliptic_polynomials()[0] L = PowerSeriesRing(self.base_ring(), name, default_prec=prec) t = L.gen() @@ -514,7 +521,7 @@ def local_coordinates_at_weierstrass(self, P, prec=20, name='t'): - Francis Clarke (2012-08-26) """ if P[1] != 0: - raise TypeError("P = %s is not a finite Weierstrass point. Use local_coordinates_at_nonweierstrass instead!"%P) + raise TypeError("P = %s is not a finite Weierstrass point. Use local_coordinates_at_nonweierstrass instead!" % P) L = PowerSeriesRing(self.base_ring(), name) t = L.gen() pol = self.hyperelliptic_polynomials()[0] @@ -655,9 +662,9 @@ def rational_points(self, **kwds): An example over a number field:: - sage: R. = PolynomialRing(QuadraticField(2)) # optional - sage.rings.number_field - sage: C = HyperellipticCurve(R([1, 0, 0, 0, 0, 1])) # optional - sage.rings.number_field - sage: C.rational_points(bound=2) # optional - sage.rings.number_field + sage: R. = PolynomialRing(QuadraticField(2)) # needs sage.rings.number_field + sage: C = HyperellipticCurve(R([1, 0, 0, 0, 0, 1])) # needs sage.rings.number_field + sage: C.rational_points(bound=2) # needs sage.rings.number_field [(-1 : 0 : 1), (0 : -1 : 1), (0 : 1 : 0), diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py index 5111e08faf1..619619dce30 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics """ Hyperelliptic curves over a `p`-adic field """ @@ -123,7 +124,7 @@ def local_analytic_interpolation(self, P, Q): """ prec = self.base_ring().precision_cap() if not self.is_same_disc(P,Q): - raise ValueError("%s and %s are not in the same residue disc"%(P,Q)) + raise ValueError("%s and %s are not in the same residue disc" % (P,Q)) disc = self.residue_disc(P) t = PowerSeriesRing(self.base_ring(), 't', prec).gen(0) if disc == self.change_ring(self.base_ring().residue_field())(0,1,0): # Infinite disc @@ -254,7 +255,7 @@ def find_char_zero_weier_point(self, Q): - Jennifer Balakrishnan """ if not self.is_in_weierstrass_disc(Q): - raise ValueError("%s is not in a Weierstrass disc"%Q) + raise ValueError("%s is not in a Weierstrass disc" % Q) points = self.weierstrass_points() for P in points: if self.is_same_disc(P,Q): @@ -298,7 +299,7 @@ def residue_disc(self, P): return HF(0,0,1) if xPv == 0: return HF(P[0].expansion(0), 0,1) - elif yPv ==0: + elif yPv == 0: if xPv > 0: return HF(0, P[1].expansion(0),1) if xPv == 0: @@ -604,7 +605,7 @@ def coleman_integrals_on_basis(self, P, Q, algorithm=None): offset = (2*g-1)*max(TPv, TQv) if offset == +Infinity: offset = (2*g-1)*min(TPv,TQv) - if (offset > prec and (xTPv <0 or xTQv <0) and (self.residue_disc(P) == self.change_ring(GF(p))(0,1,0) or self.residue_disc(Q) == self.change_ring(GF(p))(0,1,0))): + if (offset > prec and (xTPv < 0 or xTQv < 0) and (self.residue_disc(P) == self.change_ring(GF(p))(0,1,0) or self.residue_disc(Q) == self.change_ring(GF(p))(0,1,0))): newprec = offset + prec K = pAdicField(p,newprec) A = PolynomialRing(RationalField(),'x') @@ -932,10 +933,10 @@ def _frob(P): y0 = P[1] try: uN = (1 + h(x0)/y0**(2*p)).sqrt() - yres=y0**p * uN - xres=x0**p + yres = y0**p * uN + xres = x0**p if (yres-y0).valuation() == 0: - yres=-yres + yres = -yres return self.point([xres,yres, K(1)]) except (TypeError, NotImplementedError): uN2 = 1 + h(x0)/y0**(2*p) @@ -944,7 +945,7 @@ def _frob(P): v = uN2.valuation() a = uN2.parent().gen() uN = self.newton_sqrt(uN2,c.sqrt()*a**(v//2),K.precision_cap()) - yres = y0**p *uN + yres = y0**p * uN xres = x0**p if (yres - y0).valuation() == 0: yres = -yres @@ -1112,7 +1113,7 @@ def P_to_S(self, P, S): """ prec = self.base_ring().precision_cap() deg = (S[0]).parent().defining_polynomial().degree() - prec2= prec*deg + prec2 = prec*deg x,y = self.local_coord(P,prec2) g = self.genus() integrals = [((x**k*x.derivative()/(2*y)).integral()) for k in range(2*g)] diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py index a55a93dd996..f9337b0fbc0 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py @@ -27,7 +27,7 @@ def my_chage_ring(self, R): f, h = self._hyperelliptic_polynomials y = self._printing_ring.gen() x = self._printing_ring.base_ring().gen() - return HyperellipticCurve(f.change_ring(R), h, "%s,%s"%(x,y)) + return HyperellipticCurve(f.change_ring(R), h, "%s,%s" % (x,y)) import sage.schemes.hyperelliptic_curves.monsky_washnitzer as monsky_washnitzer if isinstance(p, (sage.rings.abc.pAdicField, sage.rings.abc.pAdicRing)): diff --git a/src/sage/schemes/hyperelliptic_curves/invariants.py b/src/sage/schemes/hyperelliptic_curves/invariants.py index 7db44ac03aa..05bffb5c113 100644 --- a/src/sage/schemes/hyperelliptic_curves/invariants.py +++ b/src/sage/schemes/hyperelliptic_curves/invariants.py @@ -175,8 +175,8 @@ def ubs(f): 'y2': 0, 'y3': 0} - sage: R. = GF(31)[] # optional - sage.rings.finite_rings - sage: ubs(t^6 + 2*t^5 + t^2 + 3*t + 1) # optional - sage.rings.finite_rings + sage: R. = GF(31)[] + sage: ubs(t^6 + 2*t^5 + t^2 + 3*t + 1) {'A': 0, 'B': -12, 'C': -15, @@ -219,11 +219,11 @@ def clebsch_to_igusa(A, B, C, D): sage: igusa_to_clebsch(*clebsch_to_igusa(2, 3, 4, 5)) (2, 3, 4, 5) - sage: Cs = tuple(map(GF(31), (2, 3, 4, 5))); Cs # optional - sage.rings.finite_rings + sage: Cs = tuple(map(GF(31), (2, 3, 4, 5))); Cs (2, 3, 4, 5) - sage: clebsch_to_igusa(*Cs) # optional - sage.rings.finite_rings + sage: clebsch_to_igusa(*Cs) (8, 10, 15, 26) - sage: igusa_to_clebsch(*clebsch_to_igusa(*Cs)) # optional - sage.rings.finite_rings + sage: igusa_to_clebsch(*clebsch_to_igusa(*Cs)) (2, 3, 4, 5) """ I2 = -120*A @@ -245,11 +245,11 @@ def igusa_to_clebsch(I2, I4, I6, I10): sage: clebsch_to_igusa(*igusa_to_clebsch(-2400, 173700, 23112000, -10309890600)) (-2400, 173700, 23112000, -10309890600) - sage: Is = tuple(map(GF(31), (-2400, 173700, 23112000, -10309890600))); Is # optional - sage.rings.finite_rings + sage: Is = tuple(map(GF(31), (-2400, 173700, 23112000, -10309890600))); Is (18, 7, 12, 27) - sage: igusa_to_clebsch(*Is) # optional - sage.rings.finite_rings + sage: igusa_to_clebsch(*Is) (20, 25, 25, 12) - sage: clebsch_to_igusa(*igusa_to_clebsch(*Is)) # optional - sage.rings.finite_rings + sage: clebsch_to_igusa(*igusa_to_clebsch(*Is)) (18, 7, 12, 27) """ A = -(+ I2) / 120 @@ -323,7 +323,7 @@ def igusa_clebsch_invariants(f): sage: igusa_clebsch_invariants(x^5 + a*x^4 + b*x^3 + c*x^2 + d*x + e)[0] 6*b^2 - 16*a*c + 40*d - sage: absolute_igusa_invariants_wamelen(GF(5)['x'](x^6 - 2*x)) # optional - sage.rings.finite_rings + sage: absolute_igusa_invariants_wamelen(GF(5)['x'](x^6 - 2*x)) Traceback (most recent call last): ... NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves @@ -358,7 +358,7 @@ def absolute_igusa_invariants_wamelen(f): TESTS:: - sage: absolute_igusa_invariants_wamelen(GF(3)['x'](x^5 - 2*x)) # optional - sage.rings.finite_rings + sage: absolute_igusa_invariants_wamelen(GF(3)['x'](x^5 - 2*x)) Traceback (most recent call last): ... NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves @@ -397,7 +397,7 @@ def absolute_igusa_invariants_kohel(f): TESTS:: - sage: absolute_igusa_invariants_kohel(GF(2)['x'](x^5 - x)) # optional - sage.rings.finite_rings + sage: absolute_igusa_invariants_kohel(GF(2)['x'](x^5 - x)) Traceback (most recent call last): ... NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py b/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py index 5c7c4b22c5c..8d8d89896db 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py @@ -122,7 +122,7 @@ def satisfies_coefficient_condition(g, p): return False if g[3]*p != g[1]: return False - if g[2]%p == 0: + if g[2] % p == 0: return False return True diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py b/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py index ec04cfd8801..8e2df486769 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py @@ -23,21 +23,22 @@ class HyperellipticJacobian_generic(Jacobian_generic): """ EXAMPLES:: - sage: FF = FiniteField(2003) # optional - sage.rings.finite_rings - sage: R. = PolynomialRing(FF) # optional - sage.rings.finite_rings - sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(f) # optional - sage.rings.finite_rings - sage: J = C.jacobian() # optional - sage.rings.finite_rings - sage: a = x**2 + 376*x + 245; b = 1015*x + 1368 # optional - sage.rings.finite_rings - sage: X = J(FF) # optional - sage.rings.finite_rings - sage: D = X([a,b]) # optional - sage.rings.finite_rings - sage: D # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: FF = FiniteField(2003) + sage: R. = PolynomialRing(FF) + sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 + sage: C = HyperellipticCurve(f) + sage: J = C.jacobian() + sage: a = x**2 + 376*x + 245; b = 1015*x + 1368 + sage: X = J(FF) + sage: D = X([a,b]) + sage: D (x^2 + 376*x + 245, y + 988*x + 635) - sage: J(0) # optional - sage.rings.finite_rings + sage: J(0) (1) - sage: D == J([a,b]) # optional - sage.rings.finite_rings + sage: D == J([a,b]) True - sage: D == D + J(0) # optional - sage.rings.finite_rings + sage: D == D + J(0) True An more extended example, demonstrating arithmetic in J(QQ) and @@ -47,19 +48,17 @@ class HyperellipticJacobian_generic(Jacobian_generic): sage: P. = PolynomialRing(QQ) sage: f = x^5 - x + 1; h = x - sage: C = HyperellipticCurve(f,h,'u,v') - sage: C + sage: C = HyperellipticCurve(f,h,'u,v'); C Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 - sage: PP = C.ambient_space() - sage: PP + sage: PP = C.ambient_space(); PP Projective Space of dimension 2 over Rational Field sage: C.defining_polynomial() -x0^5 + x0*x1*x2^3 + x1^2*x2^3 + x0*x2^4 - x2^5 sage: C(QQ) Set of rational points of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: C(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 2) # needs sage.rings.number_field + sage: C(K) # needs sage.rings.number_field Set of rational points of Hyperelliptic Curve over Number Field in t with defining polynomial x^2 - 2 defined by v^2 + u*v = u^5 - u + 1 @@ -70,13 +69,15 @@ class HyperellipticJacobian_generic(Jacobian_generic): sage: C(0,1,1).parent() Set of rational points of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 - sage: P1 = C(K)(P) # optional - sage.rings.number_field - sage: P2 = C(K)([2, 4*t - 1, 1]) # optional - sage.rings.number_field - sage: P3 = C(K)([-1/2, 1/8*(7*t+2), 1]) # optional - sage.rings.number_field - sage: P1, P2, P3 # optional - sage.rings.number_field + + sage: # needs sage.rings.number_field + sage: P1 = C(K)(P) + sage: P2 = C(K)([2, 4*t - 1, 1]) + sage: P3 = C(K)([-1/2, 1/8*(7*t+2), 1]) + sage: P1, P2, P3 ((0 : 1 : 1), (2 : 4*t - 1 : 1), (-1/2 : 7/8*t + 1/4 : 1)) - sage: J = C.jacobian() - sage: J + + sage: J = C.jacobian(); J Jacobian of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 sage: Q = J(QQ)(P); Q @@ -88,54 +89,57 @@ class HyperellipticJacobian_generic(Jacobian_generic): (u^2, v + 1) (u, v + 1) (1) - sage: Q1 = J(K)(P1); print("%s -> %s"%( P1, Q1 )) # optional - sage.rings.number_field + + sage: # needs sage.rings.number_field + sage: Q1 = J(K)(P1); print("%s -> %s"%( P1, Q1 )) (0 : 1 : 1) -> (u, v - 1) - sage: Q2 = J(K)(P2); print("%s -> %s"%( P2, Q2 )) # optional - sage.rings.number_field + sage: Q2 = J(K)(P2); print("%s -> %s"%( P2, Q2 )) (2 : 4*t - 1 : 1) -> (u - 2, v - 4*t + 1) - sage: Q3 = J(K)(P3); print("%s -> %s"%( P3, Q3 )) # optional - sage.rings.number_field + sage: Q3 = J(K)(P3); print("%s -> %s"%( P3, Q3 )) (-1/2 : 7/8*t + 1/4 : 1) -> (u + 1/2, v - 7/8*t - 1/4) - sage: R. = PolynomialRing(K) # optional - sage.rings.number_field - sage: Q4 = J(K)([x^2 - t, R(1)]) # optional - sage.rings.number_field - sage: for i in range(4): Q4*i # optional - sage.rings.number_field + sage: R. = PolynomialRing(K) + sage: Q4 = J(K)([x^2 - t, R(1)]) + sage: for i in range(4): Q4*i (1) (u^2 - t, v - 1) (u^2 + (-3/4*t - 9/16)*u + 1/2*t + 1/4, v + (-1/32*t - 57/64)*u + 1/2*t + 9/16) (u^2 + (1352416/247009*t - 1636930/247009)*u - 1156544/247009*t + 1900544/247009, v + (-2326345442/122763473*t + 3233153137/122763473)*u + 2439343104/122763473*t - 3350862929/122763473) - sage: R2 = Q2*5; R2 # optional - sage.rings.number_field + sage: R2 = Q2*5; R2 (u^2 - 3789465233/116983808*u - 267915823/58491904, v + (-233827256513849/1789384327168*t + 1/2)*u - 15782925357447/894692163584*t) - sage: R3 = Q3*5; R3 # optional - sage.rings.number_field + sage: R3 = Q3*5; R3 (u^2 + 5663300808399913890623/14426454798950909645952*u - 26531814176395676231273/28852909597901819291904, v + (253155440321645614070860868199103/2450498420175733688903836378159104*t + 1/2)*u + 2427708505064902611513563431764311/4900996840351467377807672756318208*t) - sage: R4 = Q4*5; R4 # optional - sage.rings.number_field + sage: R4 = Q4*5; R4 (u^2 - 3789465233/116983808*u - 267915823/58491904, v + (233827256513849/1789384327168*t + 1/2)*u + 15782925357447/894692163584*t) Thus we find the following identity:: - sage: 5*Q2 + 5*Q4 # optional - sage.rings.number_field + sage: 5*Q2 + 5*Q4 # needs sage.rings.number_field (1) Moreover the following relation holds in the 5-torsion subgroup:: - sage: Q2 + Q4 == 2*Q1 # optional - sage.rings.number_field + sage: Q2 + Q4 == 2*Q1 # needs sage.rings.number_field True TESTS:: - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: J1 = HyperellipticCurve(x^3 + x - 1, x + a).jacobian() # optional - sage.rings.finite_rings - sage: FF = FiniteField(2003) # optional - sage.rings.finite_rings - sage: R. = PolynomialRing(FF) # optional - sage.rings.finite_rings - sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 # optional - sage.rings.finite_rings - sage: J2 = HyperellipticCurve(f).jacobian() # optional - sage.rings.finite_rings - sage: J1 == J1 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF(9); R. = k[] + sage: J1 = HyperellipticCurve(x^3 + x - 1, x + a).jacobian() + sage: FF = FiniteField(2003) + sage: R. = PolynomialRing(FF) + sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 + sage: J2 = HyperellipticCurve(f).jacobian() + sage: J1 == J1 True - sage: J1 == J2 # optional - sage.rings.finite_rings + sage: J1 == J2 False """ def dimension(self): @@ -148,12 +152,13 @@ def dimension(self): EXAMPLES:: - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^3 + x - 1, x + a).jacobian().dimension() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF(9); R. = k[] + sage: HyperellipticCurve(x^3 + x - 1, x + a).jacobian().dimension() 1 - sage: g = HyperellipticCurve(x^6 + x - 1, x + a).jacobian().dimension(); g # optional - sage.rings.finite_rings + sage: g = HyperellipticCurve(x^6 + x - 1, x + a).jacobian().dimension(); g 2 - sage: type(g) # optional - sage.rings.finite_rings + sage: type(g) <... 'sage.rings.integer.Integer'> """ return Integer(self.curve().genus()) diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py index f205b79b433..a5f4f63876c 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py @@ -22,18 +22,18 @@ :: - sage: F. = GF(3) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: f = x^5 - 1 # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(f) # optional - sage.rings.finite_rings - sage: J = C.jacobian() # optional - sage.rings.finite_rings - sage: X = J(F) # optional - sage.rings.finite_rings - sage: a = x^2 - x + 1; b = -x + 1; c = x - 1; d = 0 # optional - sage.rings.finite_rings - sage: D1 = X([a,b]); D1 # optional - sage.rings.finite_rings + sage: F. = GF(3) + sage: R. = F[] + sage: f = x^5 - 1 + sage: C = HyperellipticCurve(f) + sage: J = C.jacobian() + sage: X = J(F) + sage: a = x^2 - x + 1; b = -x + 1; c = x - 1; d = 0 + sage: D1 = X([a,b]); D1 (x^2 + 2*x + 1, y + x + 2) - sage: D2 = X([c,d]); D2 # optional - sage.rings.finite_rings + sage: D2 = X([c,d]); D2 (x + 2, y) - sage: D1 + D2 # optional - sage.rings.finite_rings + sage: D1 + D2 (x^2 + 2*x + 2, y + 2*x + 1) """ # **************************************************************************** @@ -98,18 +98,18 @@ def __call__(self, P): :: - sage: F. = GF(3) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: f = x^5 - 1 # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(f) # optional - sage.rings.finite_rings - sage: J = C.jacobian() # optional - sage.rings.finite_rings - sage: X = J(F) # optional - sage.rings.finite_rings - sage: a = x^2 - x + 1; b = -x + 1; c = x - 1; d = 0 # optional - sage.rings.finite_rings - sage: D1 = X([a,b]); D1 # optional - sage.rings.finite_rings + sage: F. = GF(3) + sage: R. = F[] + sage: f = x^5 - 1 + sage: C = HyperellipticCurve(f) + sage: J = C.jacobian() + sage: X = J(F) + sage: a = x^2 - x + 1; b = -x + 1; c = x - 1; d = 0 + sage: D1 = X([a,b]); D1 (x^2 + 2*x + 1, y + x + 2) - sage: D2 = X([c,d]); D2 # optional - sage.rings.finite_rings + sage: D2 = X([c,d]); D2 (x + 2, y) - sage: D1 + D2 # optional - sage.rings.finite_rings + sage: D1 + D2 (x^2 + 2*x + 2, y + 2*x + 1) """ if isinstance(P, (Integer, int)) and P == 0: diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py b/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py index da1f8908a7a..53545229451 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py @@ -36,42 +36,42 @@ :: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x); H # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x); H Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x At this time, Jacobians of hyperelliptic curves are handled differently than elliptic curves:: - sage: J = H.jacobian(); J # optional - sage.rings.finite_rings + sage: J = H.jacobian(); J Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x - sage: J = J(J.base_ring()); J # optional - sage.rings.finite_rings + sage: J = J(J.base_ring()); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x Points on the Jacobian are represented by Mumford's polynomials. First we find a couple of points on the curve:: - sage: P1 = H.lift_x(2); P1 # optional - sage.rings.finite_rings + sage: P1 = H.lift_x(2); P1 (2 : 11 : 1) - sage: Q1 = H.lift_x(10); Q1 # optional - sage.rings.finite_rings + sage: Q1 = H.lift_x(10); Q1 (10 : 18 : 1) Observe that 2 and 10 are the roots of the polynomials in x, respectively:: - sage: P = J(P1); P # optional - sage.rings.finite_rings + sage: P = J(P1); P (x + 35, y + 26) - sage: Q = J(Q1); Q # optional - sage.rings.finite_rings + sage: Q = J(Q1); Q (x + 27, y + 19) :: - sage: P + Q # optional - sage.rings.finite_rings + sage: P + Q (x^2 + 25*x + 20, y + 13*x) - sage: (x^2 + 25*x + 20).roots(multiplicities=False) # optional - sage.rings.finite_rings + sage: (x^2 + 25*x + 20).roots(multiplicities=False) [10, 2] Frobenius satisfies @@ -85,24 +85,24 @@ :: - sage: 1904*P # optional - sage.rings.finite_rings + sage: 1904*P (1) - sage: 34*P == 0 # optional - sage.rings.finite_rings + sage: 34*P == 0 True - sage: 35*P == P # optional - sage.rings.finite_rings + sage: 35*P == P True - sage: 33*P == -P # optional - sage.rings.finite_rings + sage: 33*P == -P True :: - sage: Q*1904 # optional - sage.rings.finite_rings + sage: Q*1904 (1) - sage: Q*238 == 0 # optional - sage.rings.finite_rings + sage: Q*238 == 0 True - sage: Q*239 == Q # optional - sage.rings.finite_rings + sage: Q*239 == Q True - sage: Q*237 == -Q # optional - sage.rings.finite_rings + sage: Q*237 == -Q True """ @@ -230,22 +230,23 @@ def cantor_composition_simple(D1,D2,f,genus): :: - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))); P # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P = J(H.lift_x(F(1))); P (x - 1, y - a) - sage: Q = J(H.lift_x(F(0))); Q # optional - sage.rings.number_field + sage: Q = J(H.lift_x(F(0))); Q (x, y) - sage: 2*P + 2*Q # indirect doctest # optional - sage.rings.number_field + sage: 2*P + 2*Q # indirect doctest (x^2 - 2*x + 1, y - 3/2*a*x + 1/2*a) - sage: 2*(P + Q) # indirect doctest # optional - sage.rings.number_field + sage: 2*(P + Q) # indirect doctest (x^2 - 2*x + 1, y - 3/2*a*x + 1/2*a) - sage: 3*P # indirect doctest # optional - sage.rings.number_field + sage: 3*P # indirect doctest (x^2 - 25/32*x + 49/32, y - 45/256*a*x - 315/256*a) """ a1, b1 = D1 @@ -264,60 +265,62 @@ def cantor_composition_simple(D1,D2,f,genus): d, l, h3 = d0.xgcd(b1 + b2) a = (a1*a2) // (d**2) b = ((b2 + l*h2*(b1-b2)*(a2 // d)) + h3*((f - b2**2) // d)) % (a) - a =a.monic() + a = a.monic() return (a, b) def cantor_composition(D1,D2,f,h,genus): r""" EXAMPLES:: - sage: F. = GF(7^2, 'a') # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + a # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x); H # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(7^2, 'a') + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + a + sage: H = HyperellipticCurve(f, 2*x); H Hyperelliptic Curve over Finite Field in a of size 7^2 defined by y^2 + 2*x*y = x^7 + x^2 + a - sage: J = H.jacobian()(F); J # optional - sage.rings.finite_rings + sage: J = H.jacobian()(F); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field in a of size 7^2 defined by y^2 + 2*x*y = x^7 + x^2 + a :: - sage: Q = J(H.lift_x(F(1))); Q # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); Q # needs sage.rings.finite_rings (x + 6, y + 2*a + 2) - sage: 10*Q # indirect doctest # optional - sage.rings.finite_rings + sage: 10*Q # indirect doctest # needs sage.rings.finite_rings (x^3 + (3*a + 1)*x^2 + (2*a + 5)*x + a + 5, y + (4*a + 5)*x^2 + (a + 1)*x + 6*a + 3) - sage: 7*8297*Q # optional - sage.rings.finite_rings + sage: 7*8297*Q # needs sage.rings.finite_rings (1) :: - sage: Q = J(H.lift_x(F(a+1))); Q # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(a+1))); Q # needs sage.rings.finite_rings (x + 6*a + 6, y + 2*a) - sage: 7*8297*Q # indirect doctest # optional - sage.rings.finite_rings + sage: 7*8297*Q # indirect doctest # needs sage.rings.finite_rings (1) A test over a prime field: - sage: F = GF(next_prime(10^30)) # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + 1 # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x); H # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(next_prime(10^30)) + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + 1 + sage: H = HyperellipticCurve(f, 2*x); H Hyperelliptic Curve over Finite Field of size 1000000000000000000000000000057 defined by y^2 + 2*x*y = x^7 + x^2 + 1 - sage: J = H.jacobian()(F); J # optional - sage.rings.finite_rings + sage: J = H.jacobian()(F); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 1000000000000000000000000000057 defined by y^2 + 2*x*y = x^7 + x^2 + 1 - sage: Q = J(H.lift_x(F(1))); Q # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); Q (x + 1000000000000000000000000000056, y + 1000000000000000000000000000056) - sage: 10*Q # indirect doctest # optional - sage.rings.finite_rings + sage: 10*Q # indirect doctest (x^3 + 150296037169838934997145567227*x^2 + 377701248971234560956743242408*x + 509456150352486043408603286615, y + 514451014495791237681619598519*x^2 + 875375621665039398768235387900*x + 861429240012590886251910326876) - sage: 7*8297*Q # optional - sage.rings.finite_rings + sage: 7*8297*Q (x^3 + 35410976139548567549919839063*x^2 + 26230404235226464545886889960*x + 681571430588959705539385624700, y + 999722365017286747841221441793*x^2 @@ -371,22 +374,22 @@ def __init__(self, parent, polys, check=True): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)); J # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x :: - sage: P1 = J(H.lift_x(2)); P1 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 = J(H.lift_x(2)); P1 # indirect doctest (x + 35, y + 26) - sage: P1.parent() # optional - sage.rings.finite_rings + sage: P1.parent() Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x - sage: type(P1) # optional - sage.rings.finite_rings + sage: type(P1) """ SchemeMorphism.__init__(self, parent) @@ -394,8 +397,8 @@ def __init__(self, parent, polys, check=True): C = parent.curve() f, h = C.hyperelliptic_polynomials() a, b = polys - if not (b**2 + h*b - f)%a == 0: - raise ValueError("Argument polys (= %s) must be divisor on curve %s."%( + if not (b**2 + h*b - f) % a == 0: + raise ValueError("Argument polys (= %s) must be divisor on curve %s." % ( polys, C)) genus = C.genus() if a.degree() > genus: @@ -408,15 +411,16 @@ def _printing_polys(self): TESTS:: - sage: F. = GF(7^2, 'a') # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + a # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(F) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(7^2, 'a') + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + a + sage: H = HyperellipticCurve(f, 2*x) + sage: J = H.jacobian()(F) :: - sage: Q = J(H.lift_x(F(1))); Q # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); Q # indirect doctest # needs sage.rings.finite_rings (x + 6, y + 2*a + 2) """ a, b = self.__polys @@ -431,19 +435,20 @@ def _repr_(self): EXAMPLES:: - sage: F. = GF(7^2, 'a') # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + a # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(F) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(7^2, 'a') + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + a + sage: H = HyperellipticCurve(f, 2*x) + sage: J = H.jacobian()(F) :: - sage: Q = J(0); Q # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(0); Q # indirect doctest # needs sage.rings.finite_rings (1) - sage: Q = J(H.lift_x(F(1))); Q # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); Q # indirect doctest # needs sage.rings.finite_rings (x + 6, y + 2*a + 2) - sage: Q + Q # indirect doctest # optional - sage.rings.finite_rings + sage: Q + Q # indirect doctest # needs sage.rings.finite_rings (x^2 + 5*x + 1, y + 3*a*x + 6*a + 2) """ if self.is_zero(): @@ -457,22 +462,23 @@ def _latex_(self): EXAMPLES:: - sage: F. = GF(7^2) # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + alpha # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(F) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(7^2) + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + alpha + sage: H = HyperellipticCurve(f, 2*x) + sage: J = H.jacobian()(F) :: - sage: Q = J(0); print(latex(Q)) # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(0); print(latex(Q)) # indirect doctest # needs sage.rings.finite_rings \left(1\right) - sage: Q = J(H.lift_x(F(1))); print(latex(Q)) # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); print(latex(Q)) # indirect doctest # needs sage.rings.finite_rings \left(x + 6, y + 2 \alpha + 2\right) :: - sage: print(latex(Q + Q)) # optional - sage.rings.finite_rings + sage: print(latex(Q + Q)) # needs sage.rings.finite_rings \left(x^{2} + 5 x + 1, y + 3 \alpha x + 6 \alpha + 2\right) """ if self.is_zero(): @@ -497,16 +503,16 @@ def scheme(self): sage: x = QQ['x'].gen() sage: f = x^5 + x sage: H = HyperellipticCurve(f) - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))) # optional - sage.rings.number_field - sage: P.scheme() # optional - sage.rings.number_field + sage: P = J(H.lift_x(F(1))) # needs sage.rings.number_field + sage: P.scheme() # needs sage.rings.number_field Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 + x """ return self.codomain() @@ -521,16 +527,16 @@ def __list__(self): sage: x = QQ['x'].gen() sage: f = x^5 + x sage: H = HyperellipticCurve(f) - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))) # optional - sage.rings.number_field - sage: list(P) # indirect doctest # optional - sage.rings.number_field + sage: P = J(H.lift_x(F(1))) # needs sage.rings.number_field + sage: list(P) # indirect doctest # needs sage.rings.number_field [x - 1, a] """ return list(self.__polys) @@ -545,16 +551,16 @@ def __tuple__(self): sage: x = QQ['x'].gen() sage: f = x^5 + x sage: H = HyperellipticCurve(f) - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))) # optional - sage.rings.number_field - sage: tuple(P) # indirect doctest # optional - sage.rings.number_field + sage: P = J(H.lift_x(F(1))) # needs sage.rings.number_field + sage: tuple(P) # indirect doctest # needs sage.rings.number_field (x - 1, a) """ return tuple(self.__polys) @@ -569,22 +575,23 @@ def __getitem__(self, n): sage: x = QQ['x'].gen() sage: f = x^5 + x sage: H = HyperellipticCurve(f) - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))) # optional - sage.rings.number_field - sage: P[0] # indirect doctest # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P = J(H.lift_x(F(1))) + sage: P[0] # indirect doctest x - 1 - sage: P[1] # indirect doctest # optional - sage.rings.number_field + sage: P[1] # indirect doctest a - sage: P[-1] # indirect doctest # optional - sage.rings.number_field + sage: P[-1] # indirect doctest a - sage: P[:1] # indirect doctest # optional - sage.rings.number_field + sage: P[:1] # indirect doctest [x - 1] """ return list(self.__polys)[n] @@ -653,17 +660,17 @@ def __bool__(self): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)) # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)) :: - sage: P1 = J(H.lift_x(2)); P1 # optional - sage.rings.finite_rings + sage: P1 = J(H.lift_x(2)); P1 (x + 35, y + 26) - sage: P1 == 0 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 == 0 # indirect doctest False - sage: P1 - P1 == 0 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 - P1 == 0 # indirect doctest True """ return self.__polys[0] != 1 @@ -674,43 +681,44 @@ def __neg__(self): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)) # optional - sage.rings.finite_rings - sage: P1 = J(H.lift_x(2)); P1 # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)) + sage: P1 = J(H.lift_x(2)); P1 (x + 35, y + 26) - sage: - P1 # indirect doctest # optional - sage.rings.finite_rings + sage: - P1 # indirect doctest (x + 35, y + 11) - sage: P1 + (-P1) # indirect doctest # optional - sage.rings.finite_rings + sage: P1 + (-P1) # indirect doctest (1) :: - sage: H2 = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x, x) # optional - sage.rings.finite_rings - sage: J2 = H2.jacobian()(GF(37)) # optional - sage.rings.finite_rings - sage: P2 = J2(H2.lift_x(2)); P2 # optional - sage.rings.finite_rings + sage: H2 = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x, x) + sage: J2 = H2.jacobian()(GF(37)) + sage: P2 = J2(H2.lift_x(2)); P2 (x + 35, y + 15) - sage: - P2 # indirect doctest # optional - sage.rings.finite_rings + sage: - P2 # indirect doctest (x + 35, y + 24) - sage: P2 + (-P2) # indirect doctest # optional - sage.rings.finite_rings + sage: P2 + (-P2) # indirect doctest (1) TESTS: The following was fixed in :trac:`14264`:: + sage: # needs sage.rings.number_field sage: P. = QQ[] sage: f = x^5 - x + 1; h = x sage: C = HyperellipticCurve(f, h, 'u,v') sage: J = C.jacobian() - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: Q = J(K)([x^2 - t, R(1)]) # optional - sage.rings.number_field - sage: Q # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 2) + sage: R. = K[] + sage: Q = J(K)([x^2 - t, R(1)]) + sage: Q (u^2 - t, v - 1) - sage: -Q # optional - sage.rings.number_field + sage: -Q (u^2 - t, v + u + 1) - sage: Q + (-Q) # indirect doctest # optional - sage.rings.number_field + sage: Q + (-Q) # indirect doctest (1) """ @@ -737,15 +745,15 @@ def _add_(self,other): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)) # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)) :: - sage: P1 = J(H.lift_x(2)); P1 # optional - sage.rings.finite_rings + sage: P1 = J(H.lift_x(2)); P1 (x + 35, y + 26) - sage: P1 + P1 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 + P1 # indirect doctest (x^2 + 33*x + 4, y + 13*x) """ X = self.parent() @@ -768,30 +776,30 @@ def _sub_(self, other): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)) # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)) :: - sage: P1 = J(H.lift_x(2)); P1 # optional - sage.rings.finite_rings + sage: P1 = J(H.lift_x(2)); P1 (x + 35, y + 26) - sage: P1 - P1 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 - P1 # indirect doctest (1) :: - sage: P2 = J(H.lift_x(4)); P2 # optional - sage.rings.finite_rings + sage: P2 = J(H.lift_x(4)); P2 (x + 33, y + 34) Observe that the `x`-coordinates are the same but the `y`-coordinates differ:: - sage: P1 - P2 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 - P2 # indirect doctest (x^2 + 31*x + 8, y + 7*x + 12) - sage: P1 + P2 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 + P2 # indirect doctest (x^2 + 31*x + 8, y + 4*x + 18) - sage: (P1 - P2) - (P1 + P2) + 2*P2 # indirect doctest # optional - sage.rings.finite_rings + sage: (P1 - P2) - (P1 + P2) + 2*P2 # indirect doctest (1) """ return self + (-other) diff --git a/src/sage/schemes/hyperelliptic_curves/mestre.py b/src/sage/schemes/hyperelliptic_curves/mestre.py index 166681b32a1..7687cff0916 100644 --- a/src/sage/schemes/hyperelliptic_curves/mestre.py +++ b/src/sage/schemes/hyperelliptic_curves/mestre.py @@ -82,17 +82,17 @@ def HyperellipticCurve_from_invariants(i, reduced=True, precision=None, An example over a finite field:: - sage: H = HyperellipticCurve_from_invariants([GF(13)(1), 3, 7, 5]); H # optional - sage.rings.finite_rings + sage: H = HyperellipticCurve_from_invariants([GF(13)(1), 3, 7, 5]); H Hyperelliptic Curve over Finite Field of size 13 defined by ... - sage: H.igusa_clebsch_invariants() # optional - sage.rings.finite_rings + sage: H.igusa_clebsch_invariants() (4, 9, 6, 11) An example over a number field:: - sage: K = QuadraticField(353, 'a') # optional - sage.rings.number_field - sage: H = HyperellipticCurve_from_invariants([21, 225/64, 22941/512, 1], # optional - sage.rings.number_field + sage: K = QuadraticField(353, 'a') # needs sage.rings.number_field + sage: H = HyperellipticCurve_from_invariants([21, 225/64, 22941/512, 1], # needs sage.rings.number_field ....: reduced=false) - sage: f = K['x'](H.hyperelliptic_polynomials()[0]) # optional - sage.rings.number_field + sage: f = K['x'](H.hyperelliptic_polynomials()[0]) # needs sage.rings.number_field If the Mestre Conic defined by the Igusa-Clebsch invariants has no rational points, then there exists no hyperelliptic curve over the base field with @@ -123,13 +123,13 @@ def HyperellipticCurve_from_invariants(i, reduced=True, precision=None, different from 2, 3, and 5, so another algorithm will be needed for fields of those characteristics. See also :trac:`12200`:: - sage: P. = GF(3)[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^6 + x + 1).igusa_clebsch_invariants() # optional - sage.rings.finite_rings + sage: P. = GF(3)[] + sage: HyperellipticCurve(x^6 + x + 1).igusa_clebsch_invariants() Traceback (most recent call last): ... NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves not implemented in characteristics 2, 3, and 5 - sage: HyperellipticCurve_from_invariants([GF(5)(1), 1, 0, 1]) # optional - sage.rings.finite_rings + sage: HyperellipticCurve_from_invariants([GF(5)(1), 1, 0, 1]) Traceback (most recent call last): ... ZeroDivisionError: inverse of Mod(0, 5) does not exist @@ -188,7 +188,7 @@ def HyperellipticCurve_from_invariants(i, reduced=True, precision=None, # setting the cijk from Mestre's algorithm c111 = 12*x*y - 2*y/3 - 4*z c112 = -18*x**3 - 12*x*y - 36*y**2 - 2*z - c113 = -9*x**3 - 36*x**2*y -4*x*y - 6*x*z - 18*y**2 + c113 = -9*x**3 - 36*x**2*y - 4*x*y - 6*x*z - 18*y**2 c122 = c113 c123 = -54*x**4 - 36*x**2*y - 36*x*y**2 - 6*x*z - 4*y**2 - 24*y*z c133 = -27*x**4/2 - 72*x**3*y - 6*x**2*y - 9*x**2*z - 39*x*y**2 - \ @@ -249,9 +249,9 @@ def Mestre_conic(i, xyz=False, names='u,v,w'): Note that the algorithm works over number fields as well:: sage: x = polygen(ZZ, 'x') - sage: k = NumberField(x^2 - 41, 'a') # optional - sage.rings.number_field - sage: a = k.an_element() # optional - sage.rings.number_field - sage: Mestre_conic([1, 2 + a, a, 4 + a]) # optional - sage.rings.number_field + sage: k = NumberField(x^2 - 41, 'a') # needs sage.rings.number_field + sage: a = k.an_element() # needs sage.rings.number_field + sage: Mestre_conic([1, 2 + a, a, 4 + a]) # needs sage.rings.number_field Projective Conic Curve over Number Field in a with defining polynomial x^2 - 41 defined by (-801900000*a + 343845000)*u^2 + (855360000*a + 15795864000)*u*v + (312292800000*a + 1284808579200)*v^2 + (624585600000*a + 2569617158400)*u*w @@ -259,7 +259,7 @@ def Mestre_conic(i, xyz=False, names='u,v,w'): And over finite fields:: - sage: Mestre_conic([GF(7)(10), GF(7)(1), GF(7)(2), GF(7)(3)]) # optional - sage.rings.finite_rings + sage: Mestre_conic([GF(7)(10), GF(7)(1), GF(7)(2), GF(7)(3)]) Projective Conic Curve over Finite Field of size 7 defined by -2*u*v - v^2 - 2*u*w + 2*v*w - 3*w^2 diff --git a/src/sage/schemes/jacobians/abstract_jacobian.py b/src/sage/schemes/jacobians/abstract_jacobian.py index 08bee459739..8fece57a242 100644 --- a/src/sage/schemes/jacobians/abstract_jacobian.py +++ b/src/sage/schemes/jacobians/abstract_jacobian.py @@ -122,11 +122,11 @@ def __init__(self, C): defined by x + y + z) must be defined over a field. """ if not is_Scheme(C): - raise TypeError("Argument (=%s) must be a scheme."%C) + raise TypeError("Argument (=%s) must be a scheme." % C) if C.base_ring() not in _Fields: - raise TypeError("C (=%s) must be defined over a field."%C) + raise TypeError("C (=%s) must be defined over a field." % C) if C.dimension() != 1: - raise ValueError("C (=%s) must have dimension 1."%C) + raise ValueError("C (=%s) must have dimension 1." % C) self.__curve = C Scheme.__init__(self, C.base_scheme()) @@ -246,8 +246,8 @@ def base_extend(self, R): sage: Jac = H.jacobian(); Jac Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^3 - 10*x + 9 - sage: F. = QQ.extension(x^2 + 1) # optional - sage.rings.number_field - sage: Jac.base_extend(F) # optional - sage.rings.number_field + sage: F. = QQ.extension(x^2 + 1) # needs sage.rings.number_field + sage: Jac.base_extend(F) # needs sage.rings.number_field Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 + 1 defined by y^2 = x^3 - 10*x + 9 """ diff --git a/src/sage/schemes/plane_conics/con_field.py b/src/sage/schemes/plane_conics/con_field.py index fa813565f7a..9794790e1ae 100644 --- a/src/sage/schemes/plane_conics/con_field.py +++ b/src/sage/schemes/plane_conics/con_field.py @@ -105,10 +105,10 @@ def base_extend(self, S): Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2 sage: c.has_rational_point() False - sage: d = c.base_extend(QuadraticField(-1, 'i')); d # optional - sage.rings.number_field + sage: d = c.base_extend(QuadraticField(-1, 'i')); d # needs sage.rings.number_field Projective Conic Curve over Number Field in i with defining polynomial x^2 + 1 with i = 1*I defined by x^2 + y^2 + z^2 - sage: d.rational_point(algorithm='rnfisnorm') # optional - sage.rings.number_field + sage: d.rational_point(algorithm='rnfisnorm') # needs sage.rings.number_field (i : 1 : 0) """ if S in _Fields: @@ -160,10 +160,10 @@ def coefficients(self): sage: Conic(QQ, [1,2,3,4,5,6]).coefficients() [1, 2, 3, 4, 5, 6] - sage: P. = GF(13)[] # optional - sage.rings.finite_rings - sage: a = Conic(x^2 + 5*x*y + y^2 + z^2).coefficients(); a # optional - sage.rings.finite_rings + sage: P. = GF(13)[] + sage: a = Conic(x^2 + 5*x*y + y^2 + z^2).coefficients(); a [1, 5, 0, 1, 0, 1] - sage: Conic(a) # optional - sage.rings.finite_rings + sage: Conic(a) Projective Conic Curve over Finite Field of size 13 defined by x^2 + 5*x*y + y^2 + z^2 """ @@ -194,14 +194,14 @@ def derivative_matrix(self): An example in characteristic `2`:: - sage: P. = GF(2)[] # optional - sage.rings.finite_rings - sage: c = Conic([t, 1, t^2, 1, 1, 0]); c # optional - sage.rings.finite_rings + sage: P. = GF(2)[] + sage: c = Conic([t, 1, t^2, 1, 1, 0]); c # needs sage.libs.ntl Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 2 (using GF2X) defined by t*x^2 + x*y + y^2 + (t^2)*x*z + y*z - sage: c.is_smooth() # optional - sage.rings.finite_rings + sage: c.is_smooth() True - sage: c.derivative_matrix() # optional - sage.rings.finite_rings + sage: c.derivative_matrix() [ 0 1 t^2] [ 1 0 1] [t^2 1 0] @@ -231,10 +231,10 @@ def determinant(self): Determinants are only defined in characteristic different from `2`:: - sage: C = Conic(GF(2), [1, 1, 1, 1, 1, 0]) # optional - sage.rings.finite_rings - sage: C.is_smooth() # optional - sage.rings.finite_rings + sage: C = Conic(GF(2), [1, 1, 1, 1, 1, 0]) + sage: C.is_smooth() True - sage: C.determinant() # optional - sage.rings.finite_rings + sage: C.determinant() Traceback (most recent call last): ... ValueError: The conic self (= Projective Conic Curve over Finite Field @@ -270,10 +270,10 @@ def diagonal_matrix(self): :: - sage: c = Conic(GF(4, 'a'), [0, 1, 1, 1, 1, 1]) # optional - sage.rings.finite_rings - sage: c.is_smooth() # optional - sage.rings.finite_rings + sage: c = Conic(GF(4, 'a'), [0, 1, 1, 1, 1, 1]) # needs sage.rings.finite_rings + sage: c.is_smooth() # needs sage.rings.finite_rings True - sage: c.diagonal_matrix() # optional - sage.rings.finite_rings + sage: c.diagonal_matrix() # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: The conic self (= Projective Conic Curve over Finite Field @@ -284,7 +284,7 @@ def diagonal_matrix(self): B = self.base_ring() basis = [vector(B,{2:0,i:1}) for i in range(3)] for i in range(3): - zerovalue = (basis[i]*A*basis[i].column()== 0) + zerovalue = (basis[i]*A*basis[i].column() == 0) if zerovalue: for j in range(i+1,3): if basis[j]*A*basis[j].column() != 0: @@ -312,7 +312,7 @@ def diagonalization(self, names=None): EXAMPLES:: - sage: Conic(GF(5), [1,0,1,1,0,1]).diagonalization() # optional - sage.rings.finite_rings + sage: Conic(GF(5), [1,0,1,1,0,1]).diagonalization() (Projective Conic Curve over Finite Field of size 5 defined by x^2 + y^2 + 2*z^2, Scheme morphism: @@ -333,7 +333,7 @@ def diagonalization(self, names=None): :: - sage: Conic(GF(2), [1,1,1,1,1,0]).diagonalization() # optional - sage.rings.finite_rings + sage: Conic(GF(2), [1,1,1,1,1,0]).diagonalization() Traceback (most recent call last): ... ValueError: The conic self (= Projective Conic Curve over Finite Field @@ -344,10 +344,10 @@ def diagonalization(self, names=None): :: - sage: K = FractionField(PolynomialRing(GF(7), 't')) # optional - sage.rings.finite_rings - sage: (t,) = K.gens() # optional - sage.rings.finite_rings - sage: C = Conic(K, [t/2,0, 1, 2, 0, 3]) # optional - sage.rings.finite_rings - sage: C.diagonalization() # optional - sage.rings.finite_rings + sage: K = FractionField(PolynomialRing(GF(7), 't')) + sage: (t,) = K.gens() + sage: C = Conic(K, [t/2,0, 1, 2, 0, 3]) + sage: C.diagonalization() (Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 7 defined by (-3*t)*x^2 + 2*y^2 + (3*t + 3)/t*z^2, @@ -394,8 +394,8 @@ def gens(self): :: - sage: C. = Conic(GF(3), [1, 1, 1]) # optional - sage.rings.finite_rings - sage: C # optional - sage.rings.finite_rings + sage: C. = Conic(GF(3), [1, 1, 1]) + sage: C Projective Conic Curve over Finite Field of size 3 defined by a^2 + b^2 + c^2 @@ -460,6 +460,7 @@ def has_rational_point(self, point=False, numbers, one does not. Check that they are both handled correctly by the Magma interface. :: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(-1) sage: K.coerce_embedding() Generic morphism: @@ -469,8 +470,9 @@ def has_rational_point(self, point=False, sage: Conic(K, [1,1,1]).rational_point(algorithm='magma') # optional - magma (-i : 1 : 0) + sage: # needs sage.rings.number_field sage: x = QQ['x'].gen() - sage: L. = NumberField(x^2+1, embedding=None) + sage: L. = NumberField(x^2 + 1, embedding=None) sage: Conic(L, [1,1,1]).rational_point(algorithm='magma') # optional - magma (-i : 1 : 0) sage: L == K @@ -579,11 +581,11 @@ def has_singular_point(self, point=False): sage: c.has_singular_point(point = True) (True, (0 : 1 : 0)) - sage: P. = GF(7)[] # optional - sage.rings.finite_rings - sage: e = Conic((x+y+z)*(x-y+2*z)); e # optional - sage.rings.finite_rings + sage: P. = GF(7)[] + sage: e = Conic((x+y+z)*(x-y+2*z)); e Projective Conic Curve over Finite Field of size 7 defined by x^2 - y^2 + 3*x*z + y*z + 2*z^2 - sage: e.has_singular_point(point = True) # optional - sage.rings.finite_rings + sage: e.has_singular_point(point = True) (True, (2 : 4 : 1)) sage: Conic([1, 1, -1]).has_singular_point() @@ -596,15 +598,15 @@ def has_singular_point(self, point=False): :: - sage: F. = FiniteField(8) # optional - sage.rings.finite_rings - sage: Conic([a, a + 1, 1]).has_singular_point(point=True) # optional - sage.rings.finite_rings + sage: F. = FiniteField(8) # needs sage.rings.finite_rings + sage: Conic([a, a + 1, 1]).has_singular_point(point=True) # needs sage.rings.finite_rings (True, (a + 1 : 0 : 1)) - sage: P. = GF(2)[] # optional - sage.rings.finite_rings - sage: C = Conic(P, [t,t,1]); C # optional - sage.rings.finite_rings + sage: P. = GF(2)[] + sage: C = Conic(P, [t,t,1]); C # needs sage.libs.ntl Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 2 (using GF2X) defined by t*x^2 + t*y^2 + z^2 - sage: C.has_singular_point(point = False) # optional - sage.rings.finite_rings + sage: C.has_singular_point(point=False) # needs sage.libs.ntl Traceback (most recent call last): ... NotImplementedError: Sorry, find singular point on conics not implemented @@ -755,7 +757,7 @@ def is_smooth(self): sage: Conic([1,-1,0]).is_smooth() False - sage: Conic(GF(2),[1,1,1,1,1,0]).is_smooth() # optional - sage.rings.finite_rings + sage: Conic(GF(2),[1,1,1,1,1,0]).is_smooth() True """ if self.base_ring().characteristic() == 2: @@ -772,30 +774,30 @@ def _magma_init_(self, magma): EXAMPLES:: + sage: # optional - magma sage: C = Conic(QQ, [1,2,3]) - sage: C._magma_init_(magma) # optional - magma + sage: C._magma_init_(magma) 'Conic([_sage_ref...|1/1,2/1,3/1,0/1,0/1,0/1])' - sage: C = Conic(GF(41), [-1,2,5]) # optional - magma # optional - sage.rings.finite_rings - sage: C._magma_init_(magma) # optional - magma # optional - sage.rings.finite_rings + sage: C = Conic(GF(41), [-1,2,5]) + sage: C._magma_init_(magma) 'Conic([_sage_ref...|GF(41)!40,GF(41)!2,GF(41)!5,GF(41)!0,GF(41)!0,GF(41)!0])' - sage: F. = GF(25) # optional - sage.rings.finite_rings - sage: C = Conic([3,0,1,4,a,2]) # optional - sage.rings.finite_rings - sage: C # optional - sage.rings.finite_rings + sage: F. = GF(25) # needs sage.rings.finite_rings + sage: C = Conic([3,0,1,4,a,2]); C # needs sage.rings.finite_rings Projective Conic Curve over Finite Field in a of size 5^2 defined by -2*x^2 - y^2 + x*z + a*y*z + 2*z^2 - sage: magma(C) # optional - magma # optional - sage.rings.finite_rings + sage: magma(C) # needs sage.rings.finite_rings Conic over GF(5^2) defined by 3*X^2 + 4*Y^2 + X*Z + a*Y*Z + 2*Z^2 - sage: magma(Conic([1/2,2/3,-4/5,6/7,8/9,-10/11])) # optional - magma + sage: magma(Conic([1/2,2/3,-4/5,6/7,8/9,-10/11])) Conic over Rational Field defined by 1/2*X^2 + 2/3*X*Y + 6/7*Y^2 - 4/5*X*Z + 8/9*Y*Z - 10/11*Z^2 sage: R. = Frac(QQ['x']) - sage: magma(Conic([x, 1 + x, 1 - x])) # optional - magma + sage: magma(Conic([x, 1 + x, 1 - x])) Conic over Univariate rational function field over Rational Field defined by x*X^2 + (x + 1)*Y^2 + (-x + 1)*Z^2 sage: P. = QQ[] - sage: K. = NumberField(x^3 + x + 1) # optional - sage.rings.number_field - sage: magma(Conic([b,1,2])) # optional - magma # optional - sage.rings.number_field + sage: K. = NumberField(x^3 + x + 1) # needs sage.rings.number_field + sage: magma(Conic([b,1,2])) # needs sage.rings.number_field Conic over Number Field with defining polynomial x^3 + x + 1 over the Rational Field defined by b*X^2 + Y^2 + 2*Z^2 """ @@ -821,9 +823,9 @@ def matrix(self): [1/2 1 0] [ 0 0 1] - sage: R. = GF(2)[] # optional - sage.rings.finite_rings - sage: C = Conic(x^2 + x*y + y^2 + x*z + z^2) # optional - sage.rings.finite_rings - sage: C.matrix() # optional - sage.rings.finite_rings + sage: R. = GF(2)[] + sage: C = Conic(x^2 + x*y + y^2 + x*z + z^2) + sage: C.matrix() [1 1 1] [0 1 0] [0 0 1] @@ -851,8 +853,8 @@ def parametrization(self, point=None, morphism=True): An example over a finite field :: - sage: c = Conic(GF(2), [1,1,1,1,1,0]) # optional - sage.rings.finite_rings - sage: f, g = c.parametrization(); f, g # optional - sage.rings.finite_rings + sage: c = Conic(GF(2), [1,1,1,1,1,0]) + sage: f, g = c.parametrization(); f, g (Scheme morphism: From: Projective Space of dimension 1 over Finite Field of size 2 To: Projective Conic Curve over Finite Field of size 2 @@ -863,40 +865,42 @@ def parametrization(self, point=None, morphism=True): defined by x^2 + x*y + y^2 + x*z + y*z To: Projective Space of dimension 1 over Finite Field of size 2 Defn: Defined on coordinates by sending (x : y : z) to ...) - sage: set(f(p) for p in f.domain()) # optional - sage.rings.finite_rings + sage: set(f(p) for p in f.domain()) {(0 : 0 : 1), (0 : 1 : 1), (1 : 0 : 1)} Verfication of the example :: - sage: h = g*f; h # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: h = g*f; h Scheme endomorphism of Projective Space of dimension 1 over Finite Field of size 2 Defn: Defined on coordinates by sending (x : y) to ... - sage: h[0]/h[1] # optional - sage.rings.finite_rings + sage: h[0]/h[1] x/y - sage: h.is_one() # known bug (see :trac:`31892`) # optional - sage.rings.finite_rings + sage: h.is_one() # known bug (see :trac:`31892`) True - sage: (x,y,z) = c.gens() # optional - sage.rings.finite_rings - sage: x.parent() # optional - sage.rings.finite_rings + sage: (x,y,z) = c.gens() + sage: x.parent() Quotient of Multivariate Polynomial Ring in x, y, z over Finite Field of size 2 by the ideal (x^2 + x*y + y^2 + x*z + y*z) - sage: k = f*g # optional - sage.rings.finite_rings - sage: k[0]*z-k[2]*x # optional - sage.rings.finite_rings + sage: k = f*g + sage: k[0]*z-k[2]*x 0 - sage: k[1]*z-k[2]*y # optional - sage.rings.finite_rings + sage: k[1]*z-k[2]*y 0 The morphisms are mathematically defined in all points, but don't work completely in SageMath (see :trac:`31892`) :: - sage: f, g = c.parametrization([0,0,1]) # optional - sage.rings.finite_rings - sage: g([0,1,1]) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: f, g = c.parametrization([0,0,1]) + sage: g([0,1,1]) (1 : 0) - sage: f([1,0]) # optional - sage.rings.finite_rings + sage: f([1,0]) (0 : 1 : 1) - sage: f([1,1]) # optional - sage.rings.finite_rings + sage: f([1,1]) (0 : 0 : 1) - sage: g([0,0,1]) # optional - sage.rings.finite_rings + sage: g([0,0,1]) (1 : 1) An example with ``morphism = False`` :: @@ -1009,8 +1013,8 @@ def random_rational_point(self, *args1, **args2): EXAMPLES:: - sage: c = Conic(GF(2), [1,1,1,1,1,0]) # optional - sage.rings.finite_rings - sage: [c.random_rational_point() for i in range(10)] # random # optional - sage.rings.finite_rings + sage: c = Conic(GF(2), [1,1,1,1,1,0]) + sage: [c.random_rational_point() for i in range(10)] # random [(1 : 0 : 1), (1 : 0 : 1), (1 : 0 : 1), (0 : 1 : 1), (1 : 0 : 1), (0 : 0 : 1), (1 : 0 : 1), (1 : 0 : 1), (0 : 0 : 1), (1 : 0 : 1)] @@ -1063,7 +1067,7 @@ def rational_point(self, algorithm='default', read_cache=True): x^2 + 2*y^2 + z^2 has no rational points over Rational Field! sage: C = Conic(x^2 + y^2 + 7*z^2) - sage: C.rational_point(algorithm = 'rnfisnorm') + sage: C.rational_point(algorithm='rnfisnorm') Traceback (most recent call last): ... ValueError: Conic Projective Conic Curve over Rational Field defined by @@ -1071,71 +1075,76 @@ def rational_point(self, algorithm='default', read_cache=True): Examples over number fields :: + sage: # needs sage.rings.number_field sage: P. = QQ[] - sage: L. = NumberField(x^3 - 5) # optional - sage.rings.number_field - sage: C = Conic(L, [3, 2, -b]) # optional - sage.rings.number_field - sage: p = C.rational_point(algorithm = 'rnfisnorm') # optional - sage.rings.number_field - sage: p # output is random # optional - sage.rings.number_field + sage: L. = NumberField(x^3 - 5) + sage: C = Conic(L, [3, 2, -b]) + sage: p = C.rational_point(algorithm='rnfisnorm') + sage: p # output is random (1/3*b^2 - 4/3*b + 4/3 : b^2 - 2 : 1) - sage: C.defining_polynomial()(list(p)) # optional - sage.rings.number_field + sage: C.defining_polynomial()(list(p)) 0 - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: D = Conic(K, [3, 2, 5]) # optional - sage.rings.number_field - sage: D.rational_point(algorithm = 'rnfisnorm') # output is random # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: D = Conic(K, [3, 2, 5]) # needs sage.rings.number_field + sage: D.rational_point(algorithm='rnfisnorm') # output is random # needs sage.rings.number_field (-3 : 4*i : 1) - sage: L. = QuadraticField(2) # optional - sage.rings.number_field - sage: Conic(QQ, [1, 1, -3]).has_rational_point() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: L. = QuadraticField(2) + sage: Conic(QQ, [1, 1, -3]).has_rational_point() False - sage: E = Conic(L, [1, 1, -3]) # optional - sage.rings.number_field - sage: E.rational_point() # output is random # optional - sage.rings.number_field + sage: E = Conic(L, [1, 1, -3]) + sage: E.rational_point() # output is random (-1 : -s : 1) Currently Magma is better at solving conics over number fields than Sage, so it helps to use the algorithm 'magma' if Magma is installed:: - sage: q = C.rational_point(algorithm='magma', # optional - magma # optional - sage.rings.number_field + sage: # optional - magma, needs sage.rings.number_field + sage: q = C.rational_point(algorithm='magma', ....: read_cache=False) - sage: q # output is random, # optional - magma # optional - sage.rings.number_field + sage: q # output is random (1/5*b^2 : 1/5*b^2 : 1) - sage: C.defining_polynomial()(list(q)) # optional - magma # optional - sage.rings.number_field + sage: C.defining_polynomial()(list(q)) 0 - sage: len(str(p)) > 1.5*len(str(q)) # optional - magma # optional - sage.rings.number_field + sage: len(str(p)) > 1.5*len(str(q)) True - - sage: D.rational_point(algorithm='magma', # random, optional - magma # optional - sage.rings.number_field + sage: D.rational_point(algorithm='magma', # random + ....: read_cache=False) (1 : 2*i : 1) - - sage: E.rational_point(algorithm='magma', # random, optional - magma # optional - sage.rings.number_field + sage: E.rational_point(algorithm='magma', # random ....: read_cache=False) (-s : 1 : 1) - sage: F = Conic([L.gen(), 30, -20]) # optional - sage.rings.number_field - sage: q = F.rational_point(algorithm='magma') # optional - magma # optional - sage.rings.number_field - sage: q # random, optional - magma # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F = Conic([L.gen(), 30, -20]) + sage: q = F.rational_point(algorithm='magma') # optional - magma + sage: q # random # optional - magma (-10/7*s + 40/7 : 5/7*s - 6/7 : 1) - sage: p = F.rational_point(read_cache=False) # optional - sage.rings.number_field - sage: p # random # optional - sage.rings.number_field + sage: p = F.rational_point(read_cache=False) + sage: p # random (788210*s - 1114700 : -171135*s + 242022 : 1) - sage: len(str(p)) > len(str(q)) # optional - magma # optional - sage.rings.number_field + sage: len(str(p)) > len(str(q)) # optional - magma True - sage: G = Conic([L.gen(), 30, -21]) # optional - sage.rings.number_field - sage: G.has_rational_point(algorithm='magma') # optional - magma # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: G = Conic([L.gen(), 30, -21]) + sage: G.has_rational_point(algorithm='magma') # optional - magma False - sage: G.has_rational_point(read_cache=False) # optional - sage.rings.number_field + sage: G.has_rational_point(read_cache=False) False - sage: G.has_rational_point(algorithm='local', read_cache=False) # optional - sage.rings.number_field + sage: G.has_rational_point(algorithm='local', + ....: read_cache=False) False - sage: G.rational_point(algorithm='magma') # optional - magma # optional - sage.rings.number_field + sage: G.rational_point(algorithm='magma') # optional - magma Traceback (most recent call last): ... ValueError: Conic Projective Conic Curve over Number Field in s with defining polynomial x^2 - 2 with s = 1.414213562373095? defined by s*x^2 + 30*y^2 - 21*z^2 has no rational points over Number Field in s with defining polynomial x^2 - 2 with s = 1.414213562373095?! - sage: G.rational_point(algorithm='magma', # optional - magma # optional - sage.rings.number_field + sage: G.rational_point(algorithm='magma', # optional - magma ....: read_cache=False) Traceback (most recent call last): ... @@ -1146,11 +1155,11 @@ def rational_point(self, algorithm='default', read_cache=True): Examples over finite fields :: - sage: F. = FiniteField(7^20) # optional - sage.rings.finite_rings - sage: C = Conic([1, a, -5]); C # optional - sage.rings.finite_rings + sage: F. = FiniteField(7^20) # needs sage.rings.finite_rings + sage: C = Conic([1, a, -5]); C # needs sage.rings.finite_rings Projective Conic Curve over Finite Field in a of size 7^20 defined by x^2 + a*y^2 + 2*z^2 - sage: C.rational_point() # output is random # optional - sage.rings.finite_rings + sage: C.rational_point() # output is random # needs sage.rings.finite_rings (4*a^19 + 5*a^18 + 4*a^17 + a^16 + 6*a^15 + 3*a^13 + 6*a^11 + a^9 + 3*a^8 + 2*a^7 + 4*a^6 + 3*a^5 + 3*a^4 + a^3 + a + 6 : 5*a^18 + a^17 + a^16 + 6*a^15 + 4*a^14 + a^13 + 5*a^12 + 5*a^10 @@ -1159,10 +1168,10 @@ def rational_point(self, algorithm='default', read_cache=True): Examples over `\RR` and `\CC` :: - sage: Conic(CC, [1, 2, 3]).rational_point() # optional - sage.rings.finite_rings + sage: Conic(CC, [1, 2, 3]).rational_point() (0 : 1.22474487139159*I : 1) - sage: Conic(RR, [1, 1, 1]).rational_point() # optional - sage.rings.finite_rings + sage: Conic(RR, [1, 1, 1]).rational_point() Traceback (most recent call last): ... ValueError: Conic Projective Conic Curve over Real Field @@ -1184,7 +1193,7 @@ def singular_point(self): :: - sage: Conic(GF(2), [1,1,1,1,1,1]).singular_point() # optional - sage.rings.finite_rings + sage: Conic(GF(2), [1,1,1,1,1,1]).singular_point() (1 : 1 : 1) ``ValueError`` is raised if the conic has no rational singular point diff --git a/src/sage/schemes/plane_conics/con_finite_field.py b/src/sage/schemes/plane_conics/con_finite_field.py index 5a6ef94bd7e..e62d8db828f 100644 --- a/src/sage/schemes/plane_conics/con_finite_field.py +++ b/src/sage/schemes/plane_conics/con_finite_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Projective plane conics over finite fields diff --git a/src/sage/schemes/plane_conics/con_number_field.py b/src/sage/schemes/plane_conics/con_number_field.py index 2844329e195..19be6d237a8 100644 --- a/src/sage/schemes/plane_conics/con_number_field.py +++ b/src/sage/schemes/plane_conics/con_number_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Projective plane conics over a number field diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py index 8e5bf4669c2..1b3f0ac412a 100644 --- a/src/sage/schemes/plane_conics/con_rational_function_field.py +++ b/src/sage/schemes/plane_conics/con_rational_function_field.py @@ -130,16 +130,19 @@ def has_rational_point(self, point=False, algorithm='default', sage: C = Conic(K, [t^2 - 2, 2*t^3, -2*t^3 - 13*t^2 - 2*t + 18]) sage: C.has_rational_point(point=True) (True, (-3 : (t + 1)/t : 1)) - sage: R. = FiniteField(23)[] # optional - sage.rings.finite_rings - sage: C = Conic([2, t^2 + 1, t^2 + 5]) # optional - sage.rings.finite_rings - sage: C.has_rational_point() # optional - sage.rings.finite_rings + + sage: R. = FiniteField(23)[] + sage: C = Conic([2, t^2 + 1, t^2 + 5]) + sage: C.has_rational_point() True - sage: C.has_rational_point(point=True) # optional - sage.rings.finite_rings + sage: C.has_rational_point(point=True) (True, (5*t : 8 : 1)) - sage: F. = QuadraticField(-1) # optional - sage.rings.number_field - sage: R. = F[] # optional - sage.rings.number_field - sage: C = Conic([1, i*t, -t^2 + 4]) # optional - sage.rings.number_field - sage: C.has_rational_point(point=True) # optional - sage.rings.number_field + + sage: # needs sage.rings.number_field + sage: F. = QuadraticField(-1) + sage: R. = F[] + sage: C = Conic([1, i*t, -t^2 + 4]) + sage: C.has_rational_point(point=True) (True, (-t - 2*i : -2*i : 1)) It works on non-diagonal conics as well:: @@ -183,11 +186,11 @@ def has_rational_point(self, point=False, algorithm='default', sage: P. = QQ[] sage: E = P.fraction_field() sage: Q. = E[] - sage: F. = E.extension(Y^2 - u^3 - 1) # optional - sage.rings.function_field - sage: R. = F[] # optional - sage.rings.function_field - sage: K = R.fraction_field() # optional - sage.rings.function_field - sage: C = Conic(K, [u, v, 1]) # optional - sage.rings.function_field - sage: C.has_rational_point() # optional - sage.rings.function_field + sage: F. = E.extension(Y^2 - u^3 - 1) + sage: R. = F[] + sage: K = R.fraction_field() # needs sage.rings.function_field + sage: C = Conic(K, [u, v, 1]) # needs sage.rings.function_field + sage: C.has_rational_point() # needs sage.rings.function_field Traceback (most recent call last): ... NotImplementedError: has_rational_point not implemented for conics @@ -198,10 +201,10 @@ def has_rational_point(self, point=False, algorithm='default', ``has_rational_point`` fails for some conics over function fields over finite fields, due to :trac:`20003`:: - sage: K. = PolynomialRing(GF(7)) # optional - sage.rings.finite_rings - sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2, # optional - sage.rings.finite_rings + sage: K. = PolynomialRing(GF(7)) + sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2, ....: 5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5]) - sage: C.has_rational_point() # optional - sage.rings.finite_rings + sage: C.has_rational_point() Traceback (most recent call last): ... TypeError: self (=Scheme morphism: @@ -477,6 +480,7 @@ def find_point(self, supports, roots, case, solution=0): Different solubility certificates give different points:: + sage: # needs sage.rings.number_field sage: K. = PolynomialRing(QQ, 't') sage: C = Conic(K, [t^2 - 2, 2*t, -2*t^3 - 13*t^2 - 2*t + 18]) sage: supp = [[t^2 - 2], [t], [t^3 + 13/2*t^2 + t - 9]] diff --git a/src/sage/schemes/plane_conics/constructor.py b/src/sage/schemes/plane_conics/constructor.py index 0a73422519c..20bc5630ac1 100644 --- a/src/sage/schemes/plane_conics/constructor.py +++ b/src/sage/schemes/plane_conics/constructor.py @@ -105,8 +105,8 @@ def Conic(base_field, F=None, names=None, unique=True): sage: X,Y,Z = QQ['X,Y,Z'].gens() sage: Conic(X^2 - X*Y + Y^2 - Z^2) Projective Conic Curve over Rational Field defined by X^2 - X*Y + Y^2 - Z^2 - sage: x,y = GF(7)['x,y'].gens() # optional - sage.rings.finite_rings - sage: Conic(x^2 - x + 2*y^2 - 3, 'U,V,W') # optional - sage.rings.finite_rings + sage: x,y = GF(7)['x,y'].gens() + sage: Conic(x^2 - x + 2*y^2 - 3, 'U,V,W') Projective Conic Curve over Finite Field of size 7 defined by U^2 + 2*V^2 - U*W - 3*W^2 @@ -115,17 +115,17 @@ def Conic(base_field, F=None, names=None, unique=True): sage: Conic(matrix(QQ, [[1, 2, 0], [4, 0, 0], [7, 0, 9]]), 'x,y,z') Projective Conic Curve over Rational Field defined by x^2 + 6*x*y + 7*x*z + 9*z^2 - sage: x,y,z = GF(11)['x,y,z'].gens() # optional - sage.rings.finite_rings - sage: C = Conic(x^2 + y^2 - 2*z^2); C # optional - sage.rings.finite_rings + sage: x,y,z = GF(11)['x,y,z'].gens() + sage: C = Conic(x^2 + y^2 - 2*z^2); C Projective Conic Curve over Finite Field of size 11 defined by x^2 + y^2 - 2*z^2 - sage: Conic(C.symmetric_matrix(), 'x,y,z') # optional - sage.rings.finite_rings + sage: Conic(C.symmetric_matrix(), 'x,y,z') Projective Conic Curve over Finite Field of size 11 defined by x^2 + y^2 - 2*z^2 Conics given by coefficients :: sage: Conic(QQ, [1,2,3]) Projective Conic Curve over Rational Field defined by x^2 + 2*y^2 + 3*z^2 - sage: Conic(GF(7), [1,2,3,4,5,6], 'X') # optional - sage.rings.finite_rings + sage: Conic(GF(7), [1,2,3,4,5,6], 'X') Projective Conic Curve over Finite Field of size 7 defined by X0^2 + 2*X0*X1 - 3*X1^2 + 3*X0*X2 - 2*X1*X2 - X2^2 @@ -139,8 +139,8 @@ def Conic(base_field, F=None, names=None, unique=True): sage: C.point([3,4]) (3 : 4 : 1) - sage: a = AffineSpace(GF(13), 2) # optional - sage.rings.finite_rings - sage: Conic([a([x,x^2]) for x in range(5)]) # optional - sage.rings.finite_rings + sage: a = AffineSpace(GF(13), 2) + sage: Conic([a([x,x^2]) for x in range(5)]) Projective Conic Curve over Finite Field of size 13 defined by x^2 - y*z """ if not (base_field is None or isinstance(base_field, IntegralDomain)): diff --git a/src/sage/schemes/product_projective/homset.py b/src/sage/schemes/product_projective/homset.py index 91af8105def..42d463077ee 100644 --- a/src/sage/schemes/product_projective/homset.py +++ b/src/sage/schemes/product_projective/homset.py @@ -104,24 +104,24 @@ def points(self, **kwds): sage: P. = ProductProjectiveSpaces([1, 1], QQ) sage: X = P.subscheme([x - y, z^2 - 2*w^2]) - sage: X(P.base_ring()).points() + sage: X(P.base_ring()).points() # needs sage.libs.singular [] :: sage: u = QQ['u'].0 - sage: K = NumberField(u^2 - 2, 'v') # optional - sage.rings.number_field - sage: P. = ProductProjectiveSpaces([1, 1], K) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 - y^2, z^2 - 2*w^2]) # optional - sage.rings.number_field - sage: sorted(X(P.base_ring()).points()) # optional - sage.rings.number_field + sage: K = NumberField(u^2 - 2, 'v') # needs sage.rings.number_field + sage: P. = ProductProjectiveSpaces([1, 1], K) # needs sage.rings.number_field + sage: X = P.subscheme([x^2 - y^2, z^2 - 2*w^2]) + sage: sorted(X(P.base_ring()).points()) # needs sage.libs.singular sage.rings.number_field [(-1 : 1 , -v : 1), (-1 : 1 , v : 1), (1 : 1 , -v : 1), (1 : 1 , v : 1)] :: sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 1, 'v') # optional - sage.rings.number_field - sage: P. = ProductProjectiveSpaces([1, 1], K) # optional - sage.rings.number_field - sage: P(K).points(bound=1) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 1, 'v') # needs sage.rings.number_field + sage: P. = ProductProjectiveSpaces([1, 1], K) # needs sage.rings.number_field + sage: P(K).points(bound=1) # needs sage.libs.singular sage.rings.number_field [(-1 : 1 , -1 : 1), (-1 : 1 , -v : 1), (-1 : 1 , 0 : 1), (-1 : 1 , v : 1), (-1 : 1 , 1 : 0), (-1 : 1 , 1 : 1), (-v : 1 , -1 : 1), (-v : 1 , -v : 1), (-v : 1 , 0 : 1), (-v : 1 , v : 1), (-v : 1 , 1 : 0), (-v : 1 , 1 : 1), @@ -134,8 +134,8 @@ def points(self, **kwds): :: - sage: P. = ProductProjectiveSpaces([2, 1], GF(3)) # optional - sage.rings.finite_rings - sage: P(P.base_ring()).points() # optional - sage.rings.finite_rings + sage: P. = ProductProjectiveSpaces([2, 1], GF(3)) + sage: P(P.base_ring()).points() [(0 : 0 : 1 , 0 : 1), (0 : 0 : 1 , 1 : 0), (0 : 0 : 1 , 1 : 1), (0 : 0 : 1 , 2 : 1), (0 : 1 : 0 , 0 : 1), (0 : 1 : 0 , 1 : 0), (0 : 1 : 0 , 1 : 1), (0 : 1 : 0 , 2 : 1), (0 : 1 : 1 , 0 : 1), (0 : 1 : 1 , 1 : 0), (0 : 1 : 1 , 1 : 1), (0 : 1 : 1 , 2 : 1), @@ -154,7 +154,7 @@ def points(self, **kwds): sage: PP. = ProductProjectiveSpaces([2, 1], QQ) sage: X = PP.subscheme([x + y, u*u - v*u]) - sage: X.rational_points(bound=2) + sage: X.rational_points(bound=2) # needs sage.libs.singular [(-2 : 2 : 1 , 0 : 1), (-2 : 2 : 1 , 1 : 1), (-1 : 1 : 0 , 0 : 1), @@ -176,7 +176,7 @@ def points(self, **kwds): sage: PP. = ProductProjectiveSpaces([2, 1, 2], QQ) sage: X = PP.subscheme([x*u^2*a, b*z*u*v, z*v^2*c]) - sage: len(X.rational_points(bound=1, algorithm='enumerate')) + sage: len(X.rational_points(bound=1, algorithm='enumerate')) # needs sage.libs.singular 232 """ B = kwds.pop('bound', 0) @@ -201,7 +201,7 @@ def points(self, **kwds): points = [] if is_RationalField(R): if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) alg = kwds.pop('algorithm', None) if alg is None: # sieve should only be called for subschemes and if the bound is not very small @@ -222,7 +222,7 @@ def points(self, **kwds): raise ValueError("algorithm must be 'sieve' or 'enumerate'") elif R in NumberFields(): if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) from sage.schemes.product_projective.rational_point import enum_product_projective_number_field return enum_product_projective_number_field(self, bound=B) elif isinstance(R, FiniteField): diff --git a/src/sage/schemes/product_projective/morphism.py b/src/sage/schemes/product_projective/morphism.py index f28aa84e7ba..74b424022a2 100644 --- a/src/sage/schemes/product_projective/morphism.py +++ b/src/sage/schemes/product_projective/morphism.py @@ -115,7 +115,7 @@ def __init__(self, parent, polys, check=True): for m in range(len(splitpolys)): d = dom._degree(splitpolys[m][0]) if not all(d == dom._degree(f) for f in splitpolys[m]): - raise TypeError("polys (=%s) must be multi-homogeneous of the same degrees (by component)"%polys) + raise TypeError("polys (=%s) must be multi-homogeneous of the same degrees (by component)" % polys) else: #we are mapping into some other kind of space target._validate(polys) @@ -225,9 +225,9 @@ def __call__(self, P, check=True): try: P = self.domain()(P) except (TypeError, NotImplementedError): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(P, self.domain())) - elif self.domain()!= P.codomain(): - raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(P, self.domain())) + raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (P, self.domain())) + elif self.domain() != P.codomain(): + raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented" % (P, self.domain())) A = self.codomain() Q = list(P) @@ -250,11 +250,12 @@ def __eq__(self, right): EXAMPLES:: sage: P1. = ProductProjectiveSpaces([1, 1], QQ) - sage: P2. = ProductProjectiveSpaces([1, 1], CC) - sage: H1 = End(P1); H2 = End(P2) + sage: P2. = ProductProjectiveSpaces([1, 1], CC) # needs sage.rings.real_mpfr + sage: H1 = End(P1) + sage: H2 = End(P2) # needs sage.rings.real_mpfr sage: f = H1([x1*x2, x2^2, x3*x4, x4^2]) - sage: g = H2([y1*y2, y2^2, y3*y4, y4^2]) - sage: f == g + sage: g = H2([y1*y2, y2^2, y3*y4, y4^2]) # needs sage.rings.real_mpfr + sage: f == g # needs sage.rings.real_mpfr False :: @@ -359,7 +360,7 @@ def is_morphism(self): sage: Z. = ProductProjectiveSpaces([1, 2], ZZ) sage: H = End(Z) sage: f = H([a^2, b^2, x*z - y*z, x^2 - y^2, z^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular False :: @@ -367,7 +368,7 @@ def is_morphism(self): sage: P. = ProductProjectiveSpaces([2, 2], QQ) sage: H = End(P) sage: f = H([u, v, w, u^2, v^2, w^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True :: @@ -376,7 +377,7 @@ def is_morphism(self): sage: Q. = ProductProjectiveSpaces([1, 2], QQ) sage: H = Hom(P, Q) sage: f = H([x^2, y^2, u^3, w^3, u^3]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular False """ m = 0 @@ -411,7 +412,7 @@ def as_dynamical_system(self): sage: Z. = ProductProjectiveSpaces([1, 2], ZZ) sage: H = End(Z) sage: f = H([a^3, b^3, x^2, y^2, z^2]) - sage: type(f.as_dynamical_system()) + sage: type(f.as_dynamical_system()) # needs sage.schemes """ if not self.is_endomorphism(): @@ -443,18 +444,19 @@ def global_height(self, prec=None): sage: P1xP1. = ProductProjectiveSpaces([1, 1], ZZ) sage: H = End(P1xP1) sage: f = H([x^2*u, 3*y^2*v, 5*x*v^2, y*u^2]) - sage: f.global_height() + sage: f.global_height() # needs sage.rings.real_mpfr 1.60943791243410 :: + sage: # needs sage.rings.number_field sage: u = QQ['u'].0 - sage: R = NumberField(u^2 - 2, 'v') # optional - sage.rings.number_field - sage: PP. = ProductProjectiveSpaces([1, 1], R) # optional - sage.rings.number_field - sage: H = End(PP) # optional - sage.rings.number_field - sage: O = R.maximal_order() # optional - sage.rings.number_field - sage: g = H([3*O(u)*x^2, 13*x*y, 7*a*y, 5*b*x + O(u)*a*y]) # optional - sage.rings.number_field - sage: g.global_height() # optional - sage.rings.number_field + sage: R = NumberField(u^2 - 2, 'v') + sage: PP. = ProductProjectiveSpaces([1, 1], R) + sage: H = End(PP) + sage: O = R.maximal_order() + sage: g = H([3*O(u)*x^2, 13*x*y, 7*a*y, 5*b*x + O(u)*a*y]) + sage: g.global_height() # needs sage.rings.real_mpfr 2.56494935746154 """ K = self.domain().base_ring() @@ -489,17 +491,18 @@ def local_height(self, v, prec=None): sage: T. = ProductProjectiveSpaces([2, 1], QQ) sage: H = T.Hom(T) sage: f = H([4*x^2 + 3/100*y^2, 8/210*x*y, 1/10000*z^2, 20*w^2, 1/384*u*w]) - sage: f.local_height(2) + sage: f.local_height(2) # needs sage.rings.real_mpfr 4.85203026391962 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 5) # optional - sage.rings.number_field - sage: P. = ProductProjectiveSpaces([1, 1], K) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2, a^2, 6*b^2 + 1/9*a*b]) # optional - sage.rings.number_field - sage: f.local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 5) + sage: P. = ProductProjectiveSpaces([1, 1], K) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2, a^2, 6*b^2 + 1/9*a*b]) + sage: f.local_height(K.ideal(3)) # needs sage.rings.real_mpfr 2.19722457733622 """ K = FractionField(self.domain().base_ring()) diff --git a/src/sage/schemes/product_projective/point.py b/src/sage/schemes/product_projective/point.py index 09cd0225209..d51d5d369bf 100644 --- a/src/sage/schemes/product_projective/point.py +++ b/src/sage/schemes/product_projective/point.py @@ -69,15 +69,15 @@ def __init__(self, parent, polys, check=True): :: - sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') # optional - sage.rings.finite_rings - sage: T.point([1, 2, 3, 4, 5, 6, 7, 8, 9]) # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') + sage: T.point([1, 2, 3, 4, 5, 6, 7, 8, 9]) (2 : 4 : 1 , 4 : 0 : 1 , 3 : 2 : 1) :: - sage: T. = ProductProjectiveSpaces([1, 1], GF(5)) # optional - sage.rings.finite_rings - sage: X = T.subscheme([x - y, z - 2*w]) # optional - sage.rings.finite_rings - sage: X([1, 1, 2, 1]) # optional - sage.rings.finite_rings + sage: T. = ProductProjectiveSpaces([1, 1], GF(5)) + sage: X = T.subscheme([x - y, z - 2*w]) + sage: X([1, 1, 2, 1]) (1 : 1 , 2 : 1) """ polys = copy(polys) @@ -99,7 +99,7 @@ def __init__(self, parent, polys, check=True): N = parent.codomain().ambient_space().dimension_relative_components() if check: parent.codomain()._check_satisfies_equations(polys) - splitpolys=self.codomain().ambient_space()._factors(polys) + splitpolys = self.codomain().ambient_space()._factors(polys) self._points = [parent.codomain().ambient_space()[i].point(splitpolys[i], check) for i in range(len(N))] def __getitem__(self, i): @@ -116,13 +116,13 @@ def __getitem__(self, i): EXAMPLES:: - sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') # optional - sage.rings.finite_rings - sage: P = T([1, 0, 1, 1, 0, 0, 0, 0, 1]) # optional - sage.rings.finite_rings - sage: P[1] # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') + sage: P = T([1, 0, 1, 1, 0, 0, 0, 0, 1]) + sage: P[1] (1 : 0 : 0) - sage: P[1].codomain() # optional - sage.rings.finite_rings + sage: P[1].codomain() Projective Space of dimension 2 over Finite Field of size 5 - sage: P[1][0] # optional - sage.rings.finite_rings + sage: P[1][0] 1 """ return self._points[i] @@ -173,26 +173,26 @@ def _richcmp_(self, right, op): EXAMPLES:: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: P = T([3, 2, 3, 4, 1, 0]) # optional - sage.rings.finite_rings - sage: Q = T([1, 2, 3, 4, 3, 1]) # optional - sage.rings.finite_rings - sage: P > Q # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: P = T([3, 2, 3, 4, 1, 0]) + sage: Q = T([1, 2, 3, 4, 3, 1]) + sage: P > Q True :: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: P = T([1, 2, 3, 4, 1, 0]) # optional - sage.rings.finite_rings - sage: Q = T([1, 2, 3, 4, 3, 0]) # optional - sage.rings.finite_rings - sage: P == Q # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: P = T([1, 2, 3, 4, 1, 0]) + sage: Q = T([1, 2, 3, 4, 3, 0]) + sage: P == Q True :: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: P = T([1, 2, 3, 4, 1, 0]) # optional - sage.rings.finite_rings - sage: Q = T([1, 2, 3, 4, 3, 1]) # optional - sage.rings.finite_rings - sage: P < Q # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: P = T([1, 2, 3, 4, 1, 0]) + sage: Q = T([1, 2, 3, 4, 3, 1]) + sage: P < Q True """ #needed for Digraph @@ -281,10 +281,10 @@ def __hash__(self): :: - sage: PP = ProductProjectiveSpaces(GF(7), [1, 1, 1]) # optional - sage.rings.finite_rings - sage: hash(PP([4, 1, 5, 4, 6, 1])) == hash((4, 1, 5, 4, 6, 1)) # optional - sage.rings.finite_rings + sage: PP = ProductProjectiveSpaces(GF(7), [1, 1, 1]) + sage: hash(PP([4, 1, 5, 4, 6, 1])) == hash((4, 1, 5, 4, 6, 1)) False - sage: hash(PP([4, 1, 5, 4, 6, 1])) == hash((4, 1, 3, 1, 6, 1)) # optional - sage.rings.finite_rings + sage: hash(PP([4, 1, 5, 4, 6, 1])) == hash((4, 1, 3, 1, 6, 1)) True """ R = self.codomain().base_ring() @@ -339,6 +339,7 @@ def dehomogenize(self, L): :: + sage: # needs sage.rings.real_mpfr sage: PP. = ProductProjectiveSpaces([1, 2], CC) sage: X = PP.subscheme([a^2 + b^2]) sage: P = X([2, 2*i, -3, 6*i, 3 - 6*i]) @@ -410,7 +411,7 @@ def change_ring(self, R, **kwds): sage: T. = ProductProjectiveSpaces([1, 1, 1], ZZ) sage: P = T.point([5, 3, 15, 4, 2, 6]) - sage: P.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: P.change_ring(GF(3)) (1 : 0 , 0 : 1 , 1 : 0) """ check = kwds.get('check', True) @@ -437,30 +438,31 @@ def global_height(self, prec=None): sage: PP = ProductProjectiveSpaces(QQ, [2, 2], 'x') sage: Q = PP([1, 7, 5, 18, 2, 3]) - sage: Q.global_height() + sage: Q.global_height() # needs sage.symbolic 2.89037175789616 :: sage: PP = ProductProjectiveSpaces(ZZ, [1, 1], 'x') sage: A = PP([-30, 2, 1, 6]) - sage: A.global_height() + sage: A.global_height() # needs sage.symbolic 2.70805020110221 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: k. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: PP = ProductProjectiveSpaces(k, [1, 2], 'y') # optional - sage.rings.number_field - sage: Q = PP([3, 5*w + 1, 1, 7*w, 10]) # optional - sage.rings.number_field - sage: Q.global_height() # optional - sage.rings.number_field + sage: k. = NumberField(x^2 + 5) + sage: PP = ProductProjectiveSpaces(k, [1, 2], 'y') + sage: Q = PP([3, 5*w + 1, 1, 7*w, 10]) + sage: Q.global_height() 2.75062910527236 :: - sage: PP = ProductProjectiveSpaces(QQbar, [1, 1], 'x') # optional - sage.rings.number_field - sage: Q = PP([1, QQbar(sqrt(2)), QQbar(5^(1/3)), QQbar(3^(1/3))]) # optional - sage.rings.number_field sage.symbolic - sage: Q.global_height() # optional - sage.rings.number_field sage.symbolic + sage: PP = ProductProjectiveSpaces(QQbar, [1, 1], 'x') # needs sage.rings.number_field + sage: Q = PP([1, QQbar(sqrt(2)), QQbar(5^(1/3)), QQbar(3^(1/3))]) # needs sage.rings.number_field sage.symbolic + sage: Q.global_height() # needs sage.rings.number_field sage.symbolic 0.536479304144700 """ K = self.codomain().base_ring() @@ -491,14 +493,14 @@ def local_height(self, v, prec=None): sage: PP = ProductProjectiveSpaces(QQ, [1, 1], 'x') sage: A = PP([11, 5, 10, 2]) - sage: A.local_height(5) + sage: A.local_height(5) # needs sage.rings.real_mpfr 1.60943791243410 :: sage: P = ProductProjectiveSpaces(QQ, [1, 2], 'x') sage: Q = P([1, 4, 1/2, 2, 32]) - sage: Q.local_height(2) + sage: Q.local_height(2) # needs sage.rings.real_mpfr 4.15888308335967 """ K = FractionField(self.domain().base_ring()) @@ -530,7 +532,7 @@ def intersection_multiplicity(self, X): sage: X = PP.subscheme([y^2*z^3*u - x^5*v]) sage: Y = PP.subscheme([u^3 - v^3, x - y]) sage: Q = X([0,0,1,1,1]) - sage: Q.intersection_multiplicity(Y) + sage: Q.intersection_multiplicity(Y) # needs sage.libs.singular 2 """ from sage.schemes.product_projective.space import is_ProductProjectiveSpaces @@ -552,13 +554,13 @@ def multiplicity(self): sage: PP. = ProductProjectiveSpaces(QQ, [3, 2]) sage: X = PP.subscheme([x^8*t - y^8*t + z^5*w^3*v]) sage: Q1 = X([1,1,0,0,-1,-1,1]) - sage: Q1.multiplicity() + sage: Q1.multiplicity() # needs sage.libs.singular 1 sage: Q2 = X([0,0,0,1,0,1,1]) - sage: Q2.multiplicity() + sage: Q2.multiplicity() # needs sage.libs.singular 5 sage: Q3 = X([0,0,0,1,1,0,0]) - sage: Q3.multiplicity() + sage: Q3.multiplicity() # needs sage.libs.singular 6 """ from sage.schemes.product_projective.space import is_ProductProjectiveSpaces diff --git a/src/sage/schemes/product_projective/rational_point.py b/src/sage/schemes/product_projective/rational_point.py index d9cda05b8e2..5375ffb4535 100644 --- a/src/sage/schemes/product_projective/rational_point.py +++ b/src/sage/schemes/product_projective/rational_point.py @@ -27,11 +27,11 @@ Product projective over finite field:: - sage: P1. = ProductProjectiveSpaces([1, 1], GF(7)) # optional - sage.rings.finite_rings - sage: X = P1.subscheme([2*x + 3*y]) # optional - sage.rings.finite_rings + sage: P1. = ProductProjectiveSpaces([1, 1], GF(7)) + sage: X = P1.subscheme([2*x + 3*y]) sage: from sage.schemes.product_projective.rational_point import \ enum_product_projective_finite_field - sage: enum_product_projective_finite_field(X) # optional - sage.rings.finite_rings + sage: enum_product_projective_finite_field(X) [(2 : 1 , 0 : 1), (2 : 1 , 1 : 0), (2 : 1 , 1 : 1), (2 : 1 , 2 : 1), (2 : 1 , 3 : 1), (2 : 1 , 4 : 1), (2 : 1 , 5 : 1), (2 : 1 , 6 : 1)] @@ -207,13 +207,14 @@ def enum_product_projective_number_field(X, **kwds): EXAMPLES:: + sage: # needs sage.rings.number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 2, 'v') # optional - sage.rings.number_field - sage: PP. = ProductProjectiveSpaces([1, 1], K) # optional - sage.rings.number_field - sage: X = PP.subscheme([x^2 + 2*y^2]) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 2, 'v') + sage: PP. = ProductProjectiveSpaces([1, 1], K) + sage: X = PP.subscheme([x^2 + 2*y^2]) sage: from sage.schemes.product_projective.rational_point import \ enum_product_projective_number_field - sage: enum_product_projective_number_field(X, bound=1.5) # optional - sage.rings.number_field + sage: enum_product_projective_number_field(X, bound=1.5) [(-v : 1 , -1 : 1), (-v : 1 , -v : 1), (-v : 1 , -1/2*v : 1), (-v : 1 , 0 : 1), (-v : 1 , 1/2*v : 1), (-v : 1 , v : 1), (-v : 1 , 1 : 0), (-v : 1 , 1 : 1), (v : 1 , -1 : 1), @@ -261,10 +262,10 @@ def enum_product_projective_finite_field(X): EXAMPLES:: - sage: PP. = ProductProjectiveSpaces([1, 1], GF(3)) # optional - sage.rings.finite_rings + sage: PP. = ProductProjectiveSpaces([1, 1], GF(3)) sage: from sage.schemes.product_projective.rational_point import \ enum_product_projective_finite_field - sage: enum_product_projective_finite_field(PP) # optional - sage.rings.finite_rings + sage: enum_product_projective_finite_field(PP) [(0 : 1 , 0 : 1), (0 : 1 , 1 : 0), (0 : 1 , 1 : 1), (0 : 1 , 2 : 1), (1 : 0 , 0 : 1), (1 : 0 , 1 : 0), (1 : 0 , 1 : 1), (1 : 0 , 2 : 1), (1 : 1 , 0 : 1), @@ -274,11 +275,11 @@ def enum_product_projective_finite_field(X): :: - sage: PP. = ProductProjectiveSpaces([1, 1], GF(17)) # optional - sage.rings.finite_rings - sage: X = PP.subscheme([x0^2 + 2*x1^2]) # optional - sage.rings.finite_rings + sage: PP. = ProductProjectiveSpaces([1, 1], GF(17)) + sage: X = PP.subscheme([x0^2 + 2*x1^2]) sage: from sage.schemes.product_projective.rational_point import \ enum_product_projective_finite_field - sage: len(enum_product_projective_finite_field(X)) # optional - sage.rings.finite_rings + sage: len(enum_product_projective_finite_field(X)) 36 """ if is_Scheme(X): @@ -336,7 +337,7 @@ def sieve(X, bound): sage: from sage.schemes.product_projective.rational_point import sieve sage: PP. = ProductProjectiveSpaces([2, 1], QQ) sage: X = PP.subscheme([x^2 + y^2 - x*z, u*u - v*u]) - sage: sieve(X, 2) + sage: sieve(X, 2) # needs sage.libs.singular [(0 : 0 : 1 , 0 : 1), (0 : 0 : 1 , 1 : 1), (1/2 : -1/2 : 1 , 0 : 1), (1/2 : -1/2 : 1 , 1 : 1), (1/2 : 1/2 : 1 , 0 : 1), (1/2 : 1/2 : 1 , 1 : 1), (1 : 0 : 1 , 0 : 1), (1 : 0 : 1 , 1 : 1)] diff --git a/src/sage/schemes/product_projective/space.py b/src/sage/schemes/product_projective/space.py index c17524ed163..16d6cfb38c0 100644 --- a/src/sage/schemes/product_projective/space.py +++ b/src/sage/schemes/product_projective/space.py @@ -105,7 +105,7 @@ def ProductProjectiveSpaces(n, R=None, names='x'): :: - sage: ProductProjectiveSpaces([2, 2], GF(7), 'y') # optional - sage.rings.finite_rings + sage: ProductProjectiveSpaces([2, 2], GF(7), 'y') Product of projective spaces P^2 x P^2 over Finite Field of size 7 :: @@ -243,7 +243,7 @@ def __init__(self, N, R=QQ, names=None): # Note that the coordinate ring should really be the tensor product of # the component coordinate rings. But we just deal with them as # multihomogeneous polynomial rings. - self._coordinate_ring = PolynomialRing(R,sum(N)+ len(N),names) + self._coordinate_ring = PolynomialRing(R,sum(N) + len(N),names) self._assign_names(names) def _repr_(self): @@ -508,10 +508,10 @@ def dimension_absolute(self): EXAMPLES:: - sage: T. = ProductProjectiveSpaces([2, 2], GF(17)) # optional - sage.rings.finite_rings - sage: T.dimension_absolute() # optional - sage.rings.finite_rings + sage: T. = ProductProjectiveSpaces([2, 2], GF(17)) + sage: T.dimension_absolute() 4 - sage: T.dimension() # optional - sage.rings.finite_rings + sage: T.dimension() 4 """ base = self.base_scheme() @@ -543,10 +543,10 @@ def dimension_absolute_components(self): EXAMPLES:: - sage: T. = ProductProjectiveSpaces([2, 2], GF(17)) # optional - sage.rings.finite_rings - sage: T.dimension_absolute_components() # optional - sage.rings.finite_rings + sage: T. = ProductProjectiveSpaces([2, 2], GF(17)) + sage: T.dimension_absolute_components() [2, 2] - sage: T.dimension_components() # optional - sage.rings.finite_rings + sage: T.dimension_components() [2, 2] """ base = self.base_scheme() @@ -564,8 +564,8 @@ def num_components(self): EXAMPLES:: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: T.num_components() # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: T.num_components() 3 """ return len(self._components) @@ -581,8 +581,8 @@ def ngens(self): EXAMPLES:: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: T.ngens() # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: T.ngens() 6 """ return sum([P.ngens() for P in self._components]) @@ -604,12 +604,12 @@ def _factors(self, v): [[1, 2], [3, 4], [5, 6]] """ if not isinstance(v, (list, tuple, ETuple)): - raise TypeError("%s, must be a list or tuple"%v) + raise TypeError("%s, must be a list or tuple" % v) if len(v) != self.ngens(): - raise ValueError("%s must have %s elements"%(v, self.ngens())) + raise ValueError("%s must have %s elements" % (v, self.ngens())) index = 0 splitv = [] - dims=self._dims + dims = self._dims for i in range(len(dims)): splitv.append(v[index:index+dims[i]+1]) index += dims[i]+1 @@ -722,22 +722,22 @@ def _validate(self, polynomials): :: - sage: R. = PolynomialRing(GF(5)) # optional - sage.rings.finite_rings - sage: T. = ProductProjectiveSpaces([2, 1], QQ) # optional - sage.rings.finite_rings - sage: T._validate([t, t, t, w^2, u^2]) # optional - sage.rings.finite_rings + sage: R. = PolynomialRing(GF(5)) + sage: T. = ProductProjectiveSpaces([2, 1], QQ) + sage: T._validate([t, t, t, w^2, u^2]) Traceback (most recent call last): ... TypeError: polynomials (=[t, t, t, w^2, u^2]) must be elements of Multivariate Polynomial Ring in x, y, z, w, u over Rational Field """ if not isinstance(polynomials, (list, tuple)): - raise TypeError('the argument polynomials=%s must be a list or tuple'%polynomials) + raise TypeError('the argument polynomials=%s must be a list or tuple' % polynomials) #check in the coordinate ring source_ring = self.coordinate_ring() try: polynomials = [source_ring(poly) for poly in polynomials] except TypeError: - raise TypeError("polynomials (=%s) must be elements of %s"%(polynomials,source_ring)) + raise TypeError("polynomials (=%s) must be elements of %s" % (polynomials,source_ring)) for f in polynomials: self._degree(f) #raises a ValueError if not multi-homogeneous return polynomials @@ -755,9 +755,9 @@ def _check_satisfies_equations(self, v): :: - sage: R. = PolynomialRing(GF(7)) # optional - sage.rings.finite_rings - sage: T. = ProductProjectiveSpaces([2, 1], R) # optional - sage.rings.finite_rings - sage: T._check_satisfies_equations([1 + t, 1, 0, 0, 1]) # optional - sage.rings.finite_rings + sage: R. = PolynomialRing(GF(7)) + sage: T. = ProductProjectiveSpaces([2, 1], R) + sage: T._check_satisfies_equations([1 + t, 1, 0, 0, 1]) True :: @@ -785,15 +785,15 @@ def _check_satisfies_equations(self, v): TypeError: the components of v=[1, 1/2, 1, 0] must be elements of Integer Ring """ if not isinstance(v, (list, tuple)): - raise TypeError('the argument v=%s must be a list or tuple'%v) + raise TypeError('the argument v=%s must be a list or tuple' % v) n = self.ngens() if not len(v) == n: - raise TypeError('the list v=%s must have %s components'%(v, n)) + raise TypeError('the list v=%s must have %s components' % (v, n)) R = self.base_ring() try: n = [R(w) for w in v] except TypeError: - raise TypeError('the components of v=%s must be elements of %s'%(v, R)) + raise TypeError('the components of v=%s must be elements of %s' % (v, R)) #check if any of the component points are 0 N = self._dims start = 0 @@ -837,24 +837,24 @@ def subscheme(self, X): EXAMPLES:: - sage: P. = ProductProjectiveSpaces([1, 1], GF(5)) # optional - sage.rings.finite_rings - sage: X = P.subscheme([x - y, z - w]); X # optional - sage.rings.finite_rings + sage: P. = ProductProjectiveSpaces([1, 1], GF(5)) + sage: X = P.subscheme([x - y, z - w]); X Closed subscheme of Product of projective spaces P^1 x P^1 over Finite Field of size 5 defined by: x - y, z - w - sage: X.defining_polynomials() # optional - sage.rings.finite_rings + sage: X.defining_polynomials() [x - y, z - w] - sage: I = X.defining_ideal(); I # optional - sage.rings.finite_rings + sage: I = X.defining_ideal(); I Ideal (x - y, z - w) of Multivariate Polynomial Ring in x, y, z, w over Finite Field of size 5 - sage: X.dimension() # optional - sage.rings.finite_rings + sage: X.dimension() # needs sage.libs.singular 0 - sage: X.base_ring() # optional - sage.rings.finite_rings + sage: X.base_ring() Finite Field of size 5 - sage: X.base_scheme() # optional - sage.rings.finite_rings + sage: X.base_scheme() Spectrum of Finite Field of size 5 - sage: X.structure_morphism() # optional - sage.rings.finite_rings + sage: X.structure_morphism() Scheme morphism: From: Closed subscheme of Product of projective spaces P^1 x P^1 over Finite Field of size 5 defined by: x - y, z - w @@ -884,7 +884,7 @@ def change_ring(self, R): EXAMPLES:: sage: T. = ProductProjectiveSpaces([2, 2], QQ) - sage: T.change_ring(GF(17)) # optional - sage.rings.finite_rings + sage: T.change_ring(GF(17)) Product of projective spaces P^2 x P^2 over Finite Field of size 17 """ new_components = [P.change_ring(R) for P in self._components] @@ -921,15 +921,15 @@ def affine_patch(self, I, return_embedding=False): (1 : x0 : x1 , x2 : 1 : x3 , x4 : x5 : 1) """ if not isinstance(I, (list, tuple)): - raise TypeError('the argument I=%s must be a list or tuple of positive integers'%I) + raise TypeError('the argument I=%s must be a list or tuple of positive integers' % I) PP = self.ambient_space() N = PP._dims if len(I) != len(N): - raise ValueError('the argument I=%s must have %s entries'%(I,len(N))) + raise ValueError('the argument I=%s must have %s entries' % (I,len(N))) I = tuple([int(i) for i in I]) # implicit type checking for i in range(len(I)): if I[i] < 0 or I[i] > N[i]: - raise ValueError("argument i (= %s) must be between 0 and %s."%(I[i], N[i])) + raise ValueError("argument i (= %s) must be between 0 and %s." % (I[i], N[i])) try: if return_embedding: return self.__affine_patches[I][1] @@ -977,7 +977,7 @@ def segre_embedding(self, PP=None, var='u'): EXAMPLES:: sage: X. = ProductProjectiveSpaces(ZZ, [2, 2]) - sage: phi = X.segre_embedding(); phi + sage: phi = X.segre_embedding(); phi # needs sage.libs.singular Scheme morphism: From: Product of projective spaces P^2 x P^2 over Integer Ring To: Closed subscheme of Projective Space of dimension 8 over Integer Ring @@ -990,8 +990,8 @@ def segre_embedding(self, PP=None, var='u'): :: - sage: T = ProductProjectiveSpaces([1, 2], CC, 'z') - sage: T.segre_embedding() + sage: T = ProductProjectiveSpaces([1, 2], CC, 'z') # needs sage.rings.real_mpfr + sage: T.segre_embedding() # needs sage.libs.singular sage.rings.real_mpfr Scheme morphism: From: Product of projective spaces P^1 x P^2 over Complex Field with 53 bits of precision @@ -1004,7 +1004,7 @@ def segre_embedding(self, PP=None, var='u'): :: sage: T = ProductProjectiveSpaces([1, 2, 1], QQ, 'z') - sage: T.segre_embedding() + sage: T.segre_embedding() # needs sage.libs.singular Scheme morphism: From: Product of projective spaces P^1 x P^2 x P^1 over Rational Field To: Closed subscheme of Projective Space of dimension 11 @@ -1057,7 +1057,7 @@ def segre_embedding(self, PP=None, var='u'): Y = PS.subscheme(L) else: if PP.dimension_relative() != M: - raise ValueError("projective Space %s must be dimension %s")%(PP, M) + raise ValueError("projective Space %s must be dimension %s") % (PP, M) S = PP.coordinate_ring() psi = R.hom([0]*k + list(S.gens()), S) L = [psi(l) for l in L] @@ -1088,9 +1088,9 @@ def _point(self, *args, **kwds): EXAMPLES:: sage: u = QQ['u'].0 - sage: K = NumberField(u^2 - 2, 'v') # optional - sage.rings.number_field - sage: P = ProductProjectiveSpaces([1, 2], K, 'x') # optional - sage.rings.number_field - sage: P([1, 3, u, 1, 1]) # optional - sage.rings.number_field + sage: K = NumberField(u^2 - 2, 'v') # needs sage.rings.number_field + sage: P = ProductProjectiveSpaces([1, 2], K, 'x') # needs sage.rings.number_field + sage: P([1, 3, u, 1, 1]) # needs sage.rings.number_field (1/3 : 1 , v : 1 : 1) """ return ProductProjectiveSpaces_point_field(*args, **kwds) @@ -1103,8 +1103,8 @@ def _point_homset(self, *args, **kwds): EXAMPLES:: - sage: P. = ProductProjectiveSpaces([1, 1], GF(5)) # optional - sage.rings.finite_rings - sage: P._point_homset(Spec(GF(5)), P) # optional - sage.rings.finite_rings + sage: P. = ProductProjectiveSpaces([1, 1], GF(5)) + sage: P._point_homset(Spec(GF(5)), P) Set of rational points of Product of projective spaces P^1 x P^1 over Finite Field of size 5 """ @@ -1163,8 +1163,8 @@ def points_of_bounded_height(self, **kwds): :: sage: u = QQ['u'].0 - sage: P = ProductProjectiveSpaces([1, 1], NumberField(u^2 - 2, 'v')) # optional - sage.rings.number_field - sage: sorted(list(P.points_of_bounded_height(bound=1.5))) # optional - sage.rings.number_field + sage: P = ProductProjectiveSpaces([1, 1], NumberField(u^2 - 2, 'v')) # needs sage.rings.number_field + sage: sorted(list(P.points_of_bounded_height(bound=1.5))) # needs sage.rings.number_field [(-v : 1 , -v : 1), (-v : 1 , -1 : 1), (-v : 1 , -1/2*v : 1), (-v : 1 , 0 : 1), (-v : 1 , 1/2*v : 1), (-v : 1 , 1 : 0), (-v : 1 , 1 : 1), (-v : 1 , v : 1), (-1 : 1 , -v : 1), (-1 : 1 , -1 : 1), (-1 : 1 , -1/2*v : 1), (-1 : 1 , 0 : 1), @@ -1225,8 +1225,8 @@ def _point(self, *args, **kwds): EXAMPLES:: - sage: P = ProductProjectiveSpaces([1, 2], GF(11)) # optional - sage.rings.finite_rings - sage: P([3, 7, 4, 5, 9]) # optional - sage.rings.finite_rings + sage: P = ProductProjectiveSpaces([1, 2], GF(11)) + sage: P([3, 7, 4, 5, 9]) (2 : 1 , 9 : 3 : 1) """ return ProductProjectiveSpaces_point_finite_field(*args, **kwds) @@ -1237,8 +1237,8 @@ def __iter__(self): EXAMPLES:: - sage: P = ProductProjectiveSpaces([2, 1], GF(3)) # optional - sage.rings.finite_rings - sage: [x for x in P] # optional - sage.rings.finite_rings + sage: P = ProductProjectiveSpaces([2, 1], GF(3)) + sage: [x for x in P] [(0 : 0 : 1 , 0 : 1), (0 : 1 : 1 , 0 : 1), (0 : 2 : 1 , 0 : 1), @@ -1270,8 +1270,8 @@ def rational_points(self, F=None): EXAMPLES:: - sage: P = ProductProjectiveSpaces([1, 1], GF(5)) # optional - sage.rings.finite_rings - sage: P.rational_points() # optional - sage.rings.finite_rings + sage: P = ProductProjectiveSpaces([1, 1], GF(5)) + sage: P.rational_points() [(0 : 1 , 0 : 1), (1 : 1 , 0 : 1), (2 : 1 , 0 : 1), (3 : 1 , 0 : 1), (4 : 1 , 0 : 1), (1 : 0 , 0 : 1), (0 : 1 , 1 : 1), (1 : 1 , 1 : 1), (2 : 1 , 1 : 1), (3 : 1 , 1 : 1), (4 : 1 , 1 : 1), (1 : 0 , 1 : 1), (0 : 1 , 2 : 1), (1 : 1 , 2 : 1), (2 : 1 , 2 : 1), (3 : 1 , 2 : 1), (4 : 1 , 2 : 1), (1 : 0 , 2 : 1), @@ -1281,18 +1281,16 @@ def rational_points(self, F=None): :: - sage: P = ProductProjectiveSpaces([1, 1], GF(2)) # optional - sage.rings.finite_rings - sage: P.rational_points(GF(2^2, 'a')) # optional - sage.rings.finite_rings - [(0 : 1 , 0 : 1), (a : 1 , 0 : 1), (a + 1 : 1 , 0 : 1), (1 : 1 , 0 : 1), - (1 : 0 , 0 : 1), (0 : 1 , a : 1), (a : 1 , a : 1), (a + 1 : 1 , a : 1), - (1 : 1 , a : 1), (1 : 0 , a : 1), (0 : 1 , a + 1 : 1), (a : 1 , a + 1 : 1), - (a + 1 : 1 , a + 1 : 1), (1 : 1 , a + 1 : 1), (1 : 0 , a + 1 : 1), - (0 : 1 , 1 : 1), (a : 1 , 1 : 1), (a + 1 : 1 , 1 : 1), (1 : 1 , 1 : 1), - (1 : 0 , 1 : 1), (0 : 1 , 1 : 0), (a : 1 , 1 : 0), (a + 1 : 1 , 1 : 0), - (1 : 1 , 1 : 0), (1 : 0 , 1 : 0)] + sage: P = ProductProjectiveSpaces([1, 1], GF(2)) + sage: sorted(P.rational_points(GF(2^2, 'a')), key=str) # needs sage.rings.finite_rings + [(0 : 1 , 0 : 1), (0 : 1 , 1 : 0), (0 : 1 , 1 : 1), (0 : 1 , a + 1 : 1), (0 : 1 , a : 1), + (1 : 0 , 0 : 1), (1 : 0 , 1 : 0), (1 : 0 , 1 : 1), (1 : 0 , a + 1 : 1), (1 : 0 , a : 1), + (1 : 1 , 0 : 1), (1 : 1 , 1 : 0), (1 : 1 , 1 : 1), (1 : 1 , a + 1 : 1), (1 : 1 , a : 1), + (a + 1 : 1 , 0 : 1), (a + 1 : 1 , 1 : 0), (a + 1 : 1 , 1 : 1), (a + 1 : 1 , a + 1 : 1), (a + 1 : 1 , a : 1), + (a : 1 , 0 : 1), (a : 1 , 1 : 0), (a : 1 , 1 : 1), (a : 1 , a + 1 : 1), (a : 1 , a : 1)] """ if F is None: return list(self) elif not isinstance(F, FiniteField): - raise TypeError("second argument (= %s) must be a finite field"%F) + raise TypeError("second argument (= %s) must be a finite field" % F) return list(self.base_extend(F)) diff --git a/src/sage/schemes/product_projective/subscheme.py b/src/sage/schemes/product_projective/subscheme.py index 1678ab2f472..35433ba565b 100644 --- a/src/sage/schemes/product_projective/subscheme.py +++ b/src/sage/schemes/product_projective/subscheme.py @@ -84,14 +84,14 @@ def segre_embedding(self, PP=None): sage: Q = ((-u*w - v^2)*x^2 + ((-w^2 - u*w + (-u*v - u^2))*y + (-w^2 - u*v)*z)*x ....: + ((-w^2 - u*w - u^2)*y^2 + (-u*w - v^2)*z*y + (-w^2 + (-v - u)*w)*z^2)) sage: W = X.subscheme([L,Q]) - sage: phi = W.segre_embedding(P) - sage: phi.codomain().ambient_space() == P + sage: phi = W.segre_embedding(P) # needs sage.libs.singular + sage: phi.codomain().ambient_space() == P # needs sage.libs.singular True :: - sage: PP. = ProductProjectiveSpaces([1, 1, 1], CC) - sage: PP.subscheme([]).segre_embedding() + sage: PP. = ProductProjectiveSpaces([1, 1, 1], CC) # needs sage.rings.real_mpfr + sage: PP.subscheme([]).segre_embedding() # needs sage.libs.singular sage.rings.real_mpfr Scheme morphism: From: Closed subscheme of Product of projective spaces P^1 x P^1 x P^1 over Complex Field with 53 bits of precision defined by: @@ -107,7 +107,7 @@ def segre_embedding(self, PP=None): :: sage: PP. = ProductProjectiveSpaces([2, 1, 1], ZZ) - sage: PP.subscheme([x^3, u - v, s^2 - t^2]).segre_embedding() + sage: PP.subscheme([x^3, u - v, s^2 - t^2]).segre_embedding() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Product of projective spaces P^2 x P^1 x P^1 over Integer Ring defined by: @@ -161,7 +161,7 @@ def segre_embedding(self, PP=None): Y = PS.subscheme(L) else: if PP.dimension_relative() != M: - raise ValueError("projective space %s must be dimension %s")%(PP, M) + raise ValueError("projective space %s must be dimension %s") % (PP, M) S = PP.coordinate_ring() psi = R.hom([0]*k + list(S.gens()), S) L = [psi(l) for l in L] @@ -195,33 +195,33 @@ def dimension(self): sage: Q = ((-u*w - v^2)*x^2 + ((-w^2 - u*w + (-u*v - u^2))*y + (-w^2 - u*v)*z)*x ....: + ((-w^2 - u*w - u^2)*y^2 + (-u*w - v^2)*z*y + (-w^2 + (-v - u)*w)*z^2)) sage: W = X.subscheme([L, Q]) - sage: W.dimension() + sage: W.dimension() # needs sage.libs.singular 2 :: sage: PP. = ProductProjectiveSpaces([2, 1, 1], QQ) sage: X = PP.subscheme([x^3, x^5 + y^5, z^6, x*u - v*y, s^2 - t^2]) - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular -1 :: - sage: PP = ProductProjectiveSpaces([2, 1, 3], CC, 't') - sage: PP.subscheme([]).dimension() + sage: PP = ProductProjectiveSpaces([2, 1, 3], CC, 't') # needs sage.rings.real_mpfr + sage: PP.subscheme([]).dimension() # needs sage.libs.singular sage.rings.real_mpfr 6 :: sage: PP = ProductProjectiveSpaces([1, 3, 1], ZZ, 't') - sage: PP.subscheme([]).dimension() + sage: PP.subscheme([]).dimension() # needs sage.libs.singular 5 :: - sage: PP. = ProductProjectiveSpaces([1,1,1], CC) - sage: X = PP.subscheme([x^2 - y^2, u - v, s^2 - t^2]) - sage: X.dimension() + sage: PP. = ProductProjectiveSpaces([1,1,1], CC) # needs sage.rings.real_mpfr + sage: X = PP.subscheme([x^2 - y^2, u - v, s^2 - t^2]) # needs sage.libs.singular sage.rings.real_mpfr + sage: X.dimension() # needs sage.libs.singular sage.rings.real_mpfr 0 """ try: @@ -300,11 +300,11 @@ def affine_patch(self, I, return_embedding=False): PP = self.ambient_space() N = PP.dimension_relative_components() if len(I) != len(N): - raise ValueError('The argument I=%s must have %s entries'%(I,len(N))) + raise ValueError('The argument I=%s must have %s entries' % (I,len(N))) I = tuple([int(i) for i in I]) # implicit type checking for i in range(len(I)): if I[i] < 0 or I[i] > N[i]: - raise ValueError("Argument i (= %s) must be between 0 and %s."%(I[i], N[i])) + raise ValueError("Argument i (= %s) must be between 0 and %s." % (I[i], N[i])) #see if we've already created this affine patch try: if return_embedding: @@ -356,20 +356,21 @@ def intersection_multiplicity(self, X, P): sage: PP. = ProductProjectiveSpaces(QQ, [1, 1]) sage: G = PP.subscheme([(x^2 + 1/4*y^2)*v - y^2*u]) sage: D = PP.subscheme([x*v - y*u]) - sage: sorted(G.intersection(D).rational_points()) + sage: sorted(G.intersection(D).rational_points()) # needs sage.libs.singular [(1/2 : 1 , 1/2 : 1), (1 : 0 , 1 : 0)] sage: Q = PP([1/2,1,1/2,1]) - sage: G.intersection_multiplicity(D, Q) + sage: G.intersection_multiplicity(D, Q) # needs sage.libs.singular 2 :: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: PP. = ProductProjectiveSpaces(F, [2, 2]) # optional - sage.rings.finite_rings - sage: X = PP.subscheme([z^5 + 3*x*y^4 + 8*y^5, u^2 - v^2]) # optional - sage.rings.finite_rings - sage: Y = PP.subscheme([x^6 + z^6, w*z - v*y]) # optional - sage.rings.finite_rings - sage: Q = PP([a,a+1,1,a,a,1]) # optional - sage.rings.finite_rings - sage: X.intersection_multiplicity(Y, Q) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: PP. = ProductProjectiveSpaces(F, [2, 2]) + sage: X = PP.subscheme([z^5 + 3*x*y^4 + 8*y^5, u^2 - v^2]) + sage: Y = PP.subscheme([x^6 + z^6, w*z - v*y]) + sage: Q = PP([a,a+1,1,a,a,1]) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular 16 :: @@ -378,7 +379,7 @@ def intersection_multiplicity(self, X, P): sage: X = PP.subscheme([x^2*u^3 + y*z*u*v^2, x - y]) sage: Y = PP.subscheme([u^3 - w^3, x*v - y*w, z^3*w^2 - y^3*u*v]) sage: Q = PP([0,0,1,0,1,0]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: the intersection of this subscheme and (=Closed subscheme of Affine Space of dimension 4 @@ -388,7 +389,7 @@ def intersection_multiplicity(self, X, P): try: PP(P) except TypeError: - raise TypeError("(=%s) must be a point in the ambient space of this subscheme and (=%s)"%(P,X)) + raise TypeError("(=%s) must be a point in the ambient space of this subscheme and (=%s)" % (P,X)) # find an affine chart of the ambient space of this subscheme that contains P indices = [] aff_pt = [] @@ -424,21 +425,21 @@ def multiplicity(self, P): sage: PP. = ProductProjectiveSpaces(QQ, [1, 1]) sage: X = PP.subscheme([x^4*z^3 - y^4*w^3]) sage: Q1 = PP([1,1,1,1]) - sage: X.multiplicity(Q1) + sage: X.multiplicity(Q1) # needs sage.libs.singular 1 sage: Q2 = PP([0,1,1,0]) - sage: X.multiplicity(Q2) + sage: X.multiplicity(Q2) # needs sage.libs.singular 3 :: - sage: PP. = ProductProjectiveSpaces(GF(11), [1,2]) # optional - sage.rings.finite_rings - sage: X = PP.subscheme([x^7*u - y^7*z, u^6*x^2 - w^3*z^3*x*y - w^6*y^2]) # optional - sage.rings.finite_rings - sage: Q1 = PP([1,0,10,1,0]) # optional - sage.rings.finite_rings - sage: X.multiplicity(Q1) # optional - sage.rings.finite_rings + sage: PP. = ProductProjectiveSpaces(GF(11), [1,2]) + sage: X = PP.subscheme([x^7*u - y^7*z, u^6*x^2 - w^3*z^3*x*y - w^6*y^2]) + sage: Q1 = PP([1,0,10,1,0]) + sage: X.multiplicity(Q1) # needs sage.libs.singular sage.rings.finite_rings 1 - sage: Q2 = PP([1,0,1,0,0]) # optional - sage.rings.finite_rings - sage: X.multiplicity(Q2) # optional - sage.rings.finite_rings + sage: Q2 = PP([1,0,1,0,0]) + sage: X.multiplicity(Q2) # needs sage.libs.singular sage.rings.finite_rings 4 """ PP = self.ambient_space() diff --git a/src/sage/schemes/projective/proj_bdd_height.py b/src/sage/schemes/projective/proj_bdd_height.py index c00bf2f22c3..744313fc77f 100644 --- a/src/sage/schemes/projective/proj_bdd_height.py +++ b/src/sage/schemes/projective/proj_bdd_height.py @@ -172,12 +172,13 @@ def IQ_points_of_bounded_height(PS, K, dim, bound): EXAMPLES: + sage: # needs sage.rings.number_field sage: from sage.schemes.projective.proj_bdd_height import IQ_points_of_bounded_height - sage: CF. = CyclotomicField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(CF, 2) # optional - sage.rings.number_field - sage: len(list(IQ_points_of_bounded_height(P, CF, 2, -1))) # optional - sage.rings.number_field + sage: CF. = CyclotomicField(3) + sage: P. = ProjectiveSpace(CF, 2) + sage: len(list(IQ_points_of_bounded_height(P, CF, 2, -1))) 0 - sage: len(list(IQ_points_of_bounded_height(P, CF, 2, 1))) # optional - sage.rings.number_field + sage: len(list(IQ_points_of_bounded_height(P, CF, 2, 1))) 57 """ if bound < 1: @@ -255,15 +256,18 @@ def points_of_bounded_height(PS, K, dim, bound, prec=53): sage: from sage.schemes.projective.proj_bdd_height import points_of_bounded_height sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 7) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: sorted(list(points_of_bounded_height(P, K, 2, 1))) # optional - sage.rings.number_field + + sage: # needs sage.geometry.polyhedron sage.libs.pari sage.rings.number_field + sage: K. = NumberField(x^3 - 7) + sage: P. = ProjectiveSpace(K, 2) + sage: sorted(list(points_of_bounded_height(P, K, 2, 1))) [(0 : 0 : 1), (0 : 1 : 0), (1 : 0 : 0), (0 : -1 : 1), (0 : 1 : 1), (-1 : 0 : 1), (1 : 0 : 1), (1 : 1 : 0), (-1 : 1 : 0), (-1 : -1 : 1), (-1 : 1 : 1), (1 : -1 : 1), (1 : 1 : 1)] :: + sage: # needs sage.geometry.polyhedron sage.libs.pari sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: O = K.maximal_order() @@ -273,6 +277,7 @@ def points_of_bounded_height(PS, K, dim, bound, prec=53): :: + sage: # needs sage.geometry.polyhedron sage.libs.pari sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: O = K.maximal_order() @@ -283,6 +288,7 @@ def points_of_bounded_height(PS, K, dim, bound, prec=53): :: + sage: # needs sage.geometry.polyhedron sage.libs.pari sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^2 - 2) sage: R2. = K[] diff --git a/src/sage/schemes/projective/projective_homset.py b/src/sage/schemes/projective/projective_homset.py index c4aa79b9f7a..e1031e71fcf 100644 --- a/src/sage/schemes/projective/projective_homset.py +++ b/src/sage/schemes/projective/projective_homset.py @@ -122,31 +122,32 @@ def points(self, **kwds): :: sage: u = QQ['u'].0 - sage: K. = NumberField(u^2 + 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: len(P(K).points(bound=1.8)) # optional - sage.rings.number_field + sage: K. = NumberField(u^2 + 3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: len(P(K).points(bound=1.8)) # needs sage.rings.number_field 309 :: - sage: P1 = ProjectiveSpace(GF(2), 1) # optional - sage.rings.finite_rings - sage: F. = GF(4, 'a') # optional - sage.rings.finite_rings - sage: P1(F).points() # optional - sage.rings.finite_rings + sage: P1 = ProjectiveSpace(GF(2), 1) + sage: F. = GF(4, 'a') # needs sage.rings.finite_rings + sage: P1(F).points() # needs sage.libs.singular sage.rings.finite_rings [(0 : 1), (1 : 0), (1 : 1), (a : 1), (a + 1 : 1)] :: sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([(y^3-y*z^2) - (x^3-x*z^2), (y^3-y*z^2) + (x^3-x*z^2)]) - sage: E(P.base_ring()).points() + sage: E(P.base_ring()).points() # needs sage.libs.singular [(-1 : -1 : 1), (-1 : 0 : 1), (-1 : 1 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 1), (1 : -1 : 1), (1 : 0 : 1), (1 : 1 : 1)] :: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(CC, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: L = E(P.base_ring()).points(); sorted(L, key=str) + sage: L = E(P.base_ring()).points(); sorted(L, key=str) # needs sage.libs.singular verbose 0 (...: projective_homset.py, points) Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly. [(-0.500000000000000 + 0.866025403784439*I : 1.00000000000000 : 0.000000000000000), @@ -155,14 +156,15 @@ def points(self, **kwds): (0.000000000000000 : 0.000000000000000 : 1.00000000000000), (1.00000000000000 : 1.00000000000000 : 0.000000000000000), (1.00000000000000*I : 0.000000000000000 : 1.00000000000000)] - sage: L[0].codomain() + sage: L[0].codomain() # needs sage.libs.singular Projective Space of dimension 2 over Complex Field with 53 bits of precision :: + sage: # needs sage.rings.complex_double sage: P. = ProjectiveSpace(CDF, 2) sage: E = P.subscheme([y^2 + x^2 + z^2, x*y*z]) - sage: len(E(P.base_ring()).points()) + sage: len(E(P.base_ring()).points()) # needs sage.libs.singular verbose 0 (...: projective_homset.py, points) Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly. 6 @@ -274,7 +276,7 @@ def points(self, **kwds): prec = kwds.pop('precision', 53) if is_RationalField(R): if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) if isinstance(X, AlgebraicScheme_subscheme): # sieve should only be called for subschemes from sage.schemes.projective.projective_rational_point import sieve return sieve(X, B) @@ -283,14 +285,14 @@ def points(self, **kwds): return enum_projective_rational_field(self, B) elif R in NumberFields(): if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) from sage.schemes.projective.projective_rational_point import enum_projective_number_field return enum_projective_number_field(self, bound=B, tolerance=tol, precision=prec) elif isinstance(R, FiniteField): from sage.schemes.projective.projective_rational_point import enum_projective_finite_field return enum_projective_finite_field(self.extended_codomain()) else: - raise TypeError("unable to enumerate points over %s"%R) + raise TypeError("unable to enumerate points over %s" % R) def numerical_points(self, F=None, **kwds): """ @@ -326,33 +328,33 @@ def numerical_points(self, F=None, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: L = E(QQ).numerical_points(F=RR); L + sage: L = E(QQ).numerical_points(F=RR); L # needs sage.libs.singular [(0.000000000000000 : 0.000000000000000 : 1.00000000000000), (1.00000000000000 : 1.00000000000000 : 0.000000000000000)] - sage: L[0].codomain() + sage: L[0].codomain() # needs sage.libs.singular Projective Space of dimension 2 over Real Field with 53 bits of precision :: sage: S. = QQ[] - sage: K. = NumberField(a^5 - 7, embedding=CC((7)**(1/5))) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 - v^2*z^2, y - v*z]) # optional - sage.rings.number_field - sage: len(X(K).numerical_points(F=CDF)) # optional - sage.rings.number_field + sage: K. = NumberField(a^5 - 7, embedding=CC(7)**(1/5)) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: X = P.subscheme([x^2 - v^2*z^2, y - v*z]) # needs sage.rings.number_field + sage: len(X(K).numerical_points(F=CDF)) # needs sage.libs.singular sage.rings.number_field 2 :: sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([3000*x1^50 + 9875643*x2^2*x3^48 + 12334545*x2^50, x1 + x2]) - sage: len(E(P.base_ring()).numerical_points(F=CDF, zero_tolerance=1e-6)) + sage: len(E(P.base_ring()).numerical_points(F=CDF, zero_tolerance=1e-6)) # needs sage.libs.singular 49 TESTS:: sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: E(QQ).numerical_points(F=CDF, point_tolerance=-1) + sage: E(QQ).numerical_points(F=CDF, point_tolerance=-1) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: tolerance must be positive @@ -361,7 +363,7 @@ def numerical_points(self, F=None, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: E(QQ).numerical_points(F=CC, zero_tolerance=-1) + sage: E(QQ).numerical_points(F=CC, zero_tolerance=-1) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: tolerance must be positive @@ -370,7 +372,7 @@ def numerical_points(self, F=None, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: E(QQ).numerical_points(F=QQbar) + sage: E(QQ).numerical_points(F=QQbar) # needs sage.rings.number_field Traceback (most recent call last): ... TypeError: F must be a numerical field @@ -424,7 +426,7 @@ def numerical_points(self, F=None, **kwds): #of coordinates known so far. This results in a single #variable polynomial (by elimination) L = G[i].substitute(P) - if len(RF(L).variables())==1: + if len(RF(L).variables()) == 1: for pol in L.univariate_polynomial().roots(ring=F, multiplicities=False): r = L.variables()[0] varindex = RF.gens().index(r) @@ -523,11 +525,11 @@ def points(self, B=0): R = self.value_ring() if R == ZZ: if not B > 0: - raise TypeError("a positive bound B (= %s) must be specified"%B) + raise TypeError("a positive bound B (= %s) must be specified" % B) from sage.schemes.projective.projective_rational_point import enum_projective_rational_field return enum_projective_rational_field(self,B) else: - raise TypeError("unable to enumerate points over %s"%R) + raise TypeError("unable to enumerate points over %s" % R) class SchemeHomset_polynomial_projective_space(SchemeHomset_generic): @@ -579,34 +581,35 @@ class SchemeHomset_points_abelian_variety_field(SchemeHomset_points_projective_f The bug reported at :trac:`1785` is fixed:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + x - (3^3-3)) # optional - sage.rings.number_field - sage: E = EllipticCurve('37a') # optional - sage.rings.number_field - sage: X = E(K) # optional - sage.rings.number_field - sage: X # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + x - (3^3-3)) + sage: E = EllipticCurve('37a') + sage: X = E(K) + sage: X Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 + (-1)*x over Number Field in a with defining polynomial x^2 + x - 24 - sage: P = X([3,a]) # optional - sage.rings.number_field - sage: P # optional - sage.rings.number_field + sage: P = X([3,a]) + sage: P (3 : a : 1) - sage: P in E # optional - sage.rings.number_field + sage: P in E False - sage: P in E.base_extend(K) # optional - sage.rings.number_field + sage: P in E.base_extend(K) True - sage: P in X.codomain() # optional - sage.rings.number_field + sage: P in X.codomain() False - sage: P in X.extended_codomain() # optional - sage.rings.number_field + sage: P in X.extended_codomain() True Check for :trac:`11982`:: sage: P2. = ProjectiveSpace(QQ,2) sage: d = 7 - sage: C = Curve(x^3 + y^3 - d*z^3) - sage: E = EllipticCurve([0,-432*d^2]) - sage: transformation = [(36*d*z-y)/(72*d),(36*d*z+y)/(72*d),x/(12*d)] - sage: phi = E.hom(transformation, C); phi + sage: C = Curve(x^3 + y^3 - d*z^3) # needs sage.schemes + sage: E = EllipticCurve([0,-432*d^2]) # needs sage.schemes + sage: transformation = [(36*d*z-y)/(72*d), (36*d*z+y)/(72*d), x/(12*d)] + sage: phi = E.hom(transformation, C); phi # needs sage.schemes Scheme morphism: From: Elliptic Curve defined by y^2 = x^3 - 21168 over Rational Field To: Projective Plane Curve over Rational Field defined by x^3 + y^3 - 7*z^3 @@ -629,6 +632,7 @@ def _element_constructor_(self, *v, **kwds): EXAMPLES:: + sage: # needs sage.schemes sage: E = EllipticCurve('37a') sage: X = E(QQ) sage: P = X([0,1,0]); P @@ -638,7 +642,7 @@ def _element_constructor_(self, *v, **kwds): TESTS:: - sage: X._element_constructor_([0,1,0]) + sage: X._element_constructor_([0,1,0]) # needs sage.schemes (0 : 1 : 0) """ if len(v) == 1: @@ -655,9 +659,9 @@ def _repr_(self): EXAMPLES:: - sage: E = EllipticCurve('37a') - sage: X = E(QQ) - sage: X._repr_() + sage: E = EllipticCurve('37a') # needs sage.schemes + sage: X = E(QQ) # needs sage.schemes + sage: X._repr_() # needs sage.schemes 'Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field' """ s = 'Abelian group of points on ' + str(self.extended_codomain()) @@ -676,6 +680,7 @@ def base_extend(self, R): EXAMPLES:: + sage: # needs sage.schemes sage: E = EllipticCurve('37a') sage: Hom = E.point_homset(); Hom Abelian group of points on Elliptic Curve defined diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index ddbaa072962..5ba47f00afa 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -110,6 +110,7 @@ class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): An example of a morphism between projective plane curves (see :trac:`10297`):: + sage: # needs sage.schemes sage: P2. = ProjectiveSpace(QQ, 2) sage: f = x^3 + y^3 + 60*z^3 sage: g = y^2*z - (x^3 - 6400*z^3/3) @@ -151,7 +152,7 @@ class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): ... ValueError: polys (=[x - 1, x*y + x]) must be homogeneous - sage: H([exp(x), exp(y)]) + sage: H([exp(x), exp(y)]) # needs sage.symbolic Traceback (most recent call last): ... TypeError: polys (=[e^x, e^y]) must be elements of @@ -167,7 +168,7 @@ class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): sage: H = End(P) sage: f = H([(x-2*y)^2, (x-2*z)^2, x^2]) sage: X = P.subscheme(y-z) - sage: f(f(f(X))) + sage: f(f(f(X))) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: y - z @@ -177,7 +178,7 @@ class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): sage: P. = ProjectiveSpace(QQ, 3) sage: H = End(P) sage: f = H([(x-2*y)^2, (x-2*z)^2, (x-2*w)^2, x^2]) - sage: f(P.subscheme([x,y,z])) + sage: f(P.subscheme([x,y,z])) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: w, @@ -211,11 +212,12 @@ def __init__(self, parent, polys, check=True): When elements of the quotient ring is used, they are reduced:: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(CC, 2) sage: X = P.subscheme([x - y]) - sage: u,v,w = X.coordinate_ring().gens() + sage: u,v,w = X.coordinate_ring().gens() # needs sage.libs.singular sage: H = End(X) - sage: H([u^2, v^2, w*u]) + sage: H([u^2, v^2, w*u]) # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Complex Field with 53 bits of precision defined by: x - y Defn: Defined on coordinates by sending (x : y : z) to @@ -329,7 +331,7 @@ def __call__(self, x, check=True): sage: H = End(PS) sage: f = H([y^2, x^2, w^2, z^2]) sage: X = PS.subscheme([z^2 + y*w]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: x*z - w^2 @@ -341,7 +343,7 @@ def __call__(self, x, check=True): sage: H = End(PS) sage: f = H([x^2, y^2, z^2]) sage: X = P1.subscheme([u - v]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: subscheme must be in ambient space of domain of map @@ -352,11 +354,11 @@ def __call__(self, x, check=True): sage: P1. = ProjectiveSpace(ZZ, 1) sage: H = End(P1) sage: f = H([u^2, v^2]) - sage: f([u-v]) + sage: f([u - v]) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Integer Ring defined by: u - v sage: X = PS.subscheme([x - z]) - sage: f([x-z]) + sage: f([x - z]) Traceback (most recent call last): ... TypeError: [x - z] fails to convert into the map's domain Projective Space of @@ -375,13 +377,14 @@ def __call__(self, x, check=True): Defn: Defined on coordinates by sending (u : v) to (u^2 + v^2 : u*v) - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P = T(F)(1, a) # optional - sage.rings.finite_rings - sage: h(P) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P = T(F)(1, a) + sage: h(P) # needs sage.libs.singular (a : a) - sage: h(P).domain() # optional - sage.rings.finite_rings + sage: h(P).domain() Spectrum of Finite Field in a of size 2^2 - sage: h.change_ring(F)(P) # optional - sage.rings.finite_rings + sage: h.change_ring(F)(P) (1 : 1) """ from sage.schemes.projective.projective_point import SchemeMorphism_point_projective_ring @@ -474,6 +477,7 @@ def _fast_eval(self, x): :: + sage: # needs sage.libs.pari sage.rings.real_mpfr sage: T. = PolynomialRing(CC) sage: I = T.ideal(z^3) sage: P. = ProjectiveSpace(T.quotient_ring(I), 1) @@ -485,6 +489,7 @@ def _fast_eval(self, x): :: + sage: # needs sage.rings.real_mpfr sage: T. = LaurentSeriesRing(CC) sage: R. = PolynomialRing(T) sage: P. = ProjectiveSpace(R,1) @@ -521,6 +526,7 @@ def __eq__(self, right): :: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(QQ, 1) sage: P2. = ProjectiveSpace(CC, 1) sage: H = End(P) @@ -565,8 +571,8 @@ def __ne__(self, right): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([x^3 - 2*x^2*y, 5*x*y^2]) - sage: g = f.change_ring(GF(7)) # optional - sage.rings.finite_rings - sage: f != g # optional - sage.rings.finite_rings + sage: g = f.change_ring(GF(7)) + sage: f != g True :: @@ -600,19 +606,20 @@ def _matrix_times_polymap_(self, mat, h): sage: P. = ProjectiveSpace(ZZ, 1) sage: H = Hom(P,P) sage: f = H([x^2 + y^2, y^2]) - sage: matrix([[1,2], [0,1]]) * f + sage: matrix([[1,2], [0,1]]) * f # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x : y) to (x^2 + 3*y^2 : y^2) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([1/3*x^2 + 1/2*y^2, y^2]) # optional - sage.rings.number_field - sage: matrix([[i,0], [0,i]]) * f # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: P. = ProjectiveSpace(QQ, 1) + sage: H = Hom(P, P) + sage: f = H([1/3*x^2 + 1/2*y^2, y^2]) + sage: matrix([[i,0], [0,i]]) * f # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Number Field in i with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to @@ -644,19 +651,20 @@ def _polymap_times_matrix_(self, mat, h): sage: P. = ProjectiveSpace(ZZ, 1) sage: H = Hom(P, P) sage: f = H([x^2 + y^2, y^2]) - sage: f * matrix([[1,2], [0,1]]) + sage: f * matrix([[1,2], [0,1]]) # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x : y) to (x^2 + 4*x*y + 5*y^2 : y^2) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([1/3*x^2 + 1/2*y^2, y^2]) # optional - sage.rings.number_field - sage: f * matrix([[i,0], [0,i]]) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: P. = ProjectiveSpace(QQ, 1) + sage: H = Hom(P, P) + sage: f = H([1/3*x^2 + 1/2*y^2, y^2]) + sage: f * matrix([[i,0], [0,i]]) # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Number Field in i with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to @@ -688,31 +696,31 @@ def as_dynamical_system(self): sage: P. = ProjectiveSpace(ZZ, 2) sage: H = End(P) sage: f = H([x^2, y^2, z^2]) - sage: type(f.as_dynamical_system()) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) - sage: f = H([x^2-y^2, y^2]) - sage: type(f.as_dynamical_system()) + sage: f = H([x^2 - y^2, y^2]) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: - sage: P. = ProjectiveSpace(GF(5), 1) # optional - sage.rings.finite_rings - sage: H = End(P) # optional - sage.rings.finite_rings - sage: f = H([x^2, y^2]) # optional - sage.rings.finite_rings - sage: type(f.as_dynamical_system()) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 1) + sage: H = End(P) + sage: f = H([x^2, y^2]) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: sage: P. = ProjectiveSpace(RR, 1) - sage: f = DynamicalSystem([x^2 + y^2, y^2], P) - sage: g = f.as_dynamical_system() - sage: g is f + sage: f = DynamicalSystem([x^2 + y^2, y^2], P) # needs sage.schemes + sage: g = f.as_dynamical_system() # needs sage.schemes + sage: g is f # needs sage.schemes True """ from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem @@ -768,11 +776,11 @@ def scale_by(self, t): :: - sage: P. = ProjectiveSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.finite_rings - sage: H = Hom(X, X) # optional - sage.rings.finite_rings - sage: f = H([x^2, y^2, z^2]) # optional - sage.rings.finite_rings - sage: f.scale_by(x - y); f # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(7), 2) + sage: X = P.subscheme(x^2 - y^2) + sage: H = Hom(X, X) + sage: f = H([x^2, y^2, z^2]) + sage: f.scale_by(x - y); f # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Finite Field of size 7 defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x : y : z) to @@ -832,11 +840,11 @@ def normalize_coordinates(self, **kwds): :: - sage: P. = ProjectiveSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.finite_rings - sage: H = Hom(X, X) # optional - sage.rings.finite_rings - sage: f = H([x^3 + x*y^2, x*y^2, x*z^2]) # optional - sage.rings.finite_rings - sage: f.normalize_coordinates(); f # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(7), 2) + sage: X = P.subscheme(x^2 - y^2) + sage: H = Hom(X, X) + sage: f = H([x^3 + x*y^2, x*y^2, x*z^2]) + sage: f.normalize_coordinates(); f # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Finite Field of size 7 defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x : y : z) to (2*y^2 : y^2 : z^2) @@ -854,22 +862,24 @@ def normalize_coordinates(self, **kwds): :: - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: f = DynamicalSystem([w*x^2 + (1/5*w)*y^2, w*y^2]) # optional - sage.rings.number_field - sage: f.normalize_coordinates(); f # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem([w*x^2 + (1/5*w)*y^2, w*y^2]) + sage: f.normalize_coordinates(); f Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^2 - 5 with w = 2.236067977499790? Defn: Defined on coordinates by sending (x : y) to (5*x^2 + y^2 : 5*y^2) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(ZZ) - sage: K. = NumberField(t^3 - 11) # optional - sage.rings.number_field - sage: a = 7/(b - 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([a*y^2 - (a*y - x)^2, y^2]) # optional - sage.rings.number_field - sage: f.normalize_coordinates(); f # optional - sage.rings.number_field + sage: K. = NumberField(t^3 - 11) + sage: a = 7/(b - 1) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([a*y^2 - (a*y - x)^2, y^2]) + sage: f.normalize_coordinates(); f Dynamical System of Projective Space of dimension 1 over Number Field in b with defining polynomial t^3 - 11 Defn: Defined on coordinates by sending (x : y) to @@ -886,13 +896,14 @@ def normalize_coordinates(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(w^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(A, 2) # optional - sage.rings.number_field - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.number_field - sage: H = Hom(X, X) # optional - sage.rings.number_field - sage: f = H([(a+1)*x^3 + 2*x*y^2, 4*x*y^2, 8*x*z^2]) # optional - sage.rings.number_field - sage: f.normalize_coordinates(ideal=A.prime_above(2)); f # optional - sage.rings.number_field + sage: A. = NumberField(w^2 + 1) + sage: P. = ProjectiveSpace(A, 2) + sage: X = P.subscheme(x^2 - y^2) + sage: H = Hom(X, X) + sage: f = H([(a+1)*x^3 + 2*x*y^2, 4*x*y^2, 8*x*z^2]) + sage: f.normalize_coordinates(ideal=A.prime_above(2)); f Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Number Field in a with defining polynomial w^2 + 1 defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x : y : z) to @@ -900,16 +911,16 @@ def normalize_coordinates(self, **kwds): We can pass in a valuation to ``valuation``:: - sage: g = H([(a+1)*x^3 + 2*x*y^2, 4*x*y^2, 8*x*z^2]) # optional - sage.rings.number_field - sage: g.normalize_coordinates(valuation=A.valuation(A.prime_above(2))) # optional - sage.rings.number_field - sage: g == f # optional - sage.rings.number_field + sage: g = H([(a+1)*x^3 + 2*x*y^2, 4*x*y^2, 8*x*z^2]) # needs sage.rings.number_field + sage: g.normalize_coordinates(valuation=A.valuation(A.prime_above(2))) # needs sage.rings.number_field + sage: g == f # needs sage.rings.number_field True :: - sage: P. = ProjectiveSpace(Qp(3), 1) # optional - sage.rings.padics - sage: f = DynamicalSystem_projective([3*x^2 + 6*y^2, 9*x*y]) # optional - sage.rings.padics - sage: f.normalize_coordinates(); f # optional - sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([3*x^2 + 6*y^2, 9*x*y]) # needs sage.rings.padics + sage: f.normalize_coordinates(); f # needs sage.rings.padics Dynamical System of Projective Space of dimension 1 over 3-adic Field with capped relative precision 20 Defn: Defined on coordinates by sending (x : y) to @@ -917,6 +928,7 @@ def normalize_coordinates(self, **kwds): Check that #35797 is fixed:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: P. = ProjectiveSpace(K, 1) @@ -1069,6 +1081,7 @@ def degree(self): :: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(CC, 2) sage: H = Hom(P, P) sage: f = H([x^3 + y^3, y^2*z, z*x*y]) @@ -1160,7 +1173,7 @@ def dehomogenize(self, n): sage: X = P.subscheme(x^2 - y^2) sage: H = Hom(X, X) sage: f = H([x^2, y^2, x*z]) - sage: f.dehomogenize(2) + sage: f.dehomogenize(2) # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Affine Space of dimension 2 over Integer Ring defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x, y) to (x, y^2/x) @@ -1175,12 +1188,13 @@ def dehomogenize(self, n): :: - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: O = K.ring_of_integers() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 - O(w)*y^2, y^2]) # optional - sage.rings.number_field - sage: f.dehomogenize(1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: O = K.ring_of_integers() + sage: P. = ProjectiveSpace(O, 1) + sage: H = End(P) + sage: f = H([x^2 - O(w)*y^2, y^2]) + sage: f.dehomogenize(1) Scheme endomorphism of Affine Space of dimension 1 over Maximal Order in Number Field in w with defining polynomial x^2 - 3 with w = 1.732050807568878? @@ -1256,7 +1270,7 @@ def is_morphism(self): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([x^2 + y^2, y^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True :: @@ -1264,16 +1278,16 @@ def is_morphism(self): sage: P. = ProjectiveSpace(RR, 2) sage: H = Hom(P, P) sage: f = H([x*z - y*z, x^2 - y^2, z^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular False :: - sage: R. = PolynomialRing(GF(5)) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(R, 2) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x*z - t*y^2, x^2 - y^2, t*z^2]) # optional - sage.rings.finite_rings - sage: f.is_morphism() # optional - sage.rings.finite_rings + sage: R. = PolynomialRing(GF(5)) + sage: P. = ProjectiveSpace(R, 2) + sage: H = Hom(P, P) + sage: f = H([x*z - t*y^2, x^2 - y^2, t*z^2]) + sage: f.is_morphism() # needs sage.libs.singular True Map that is not morphism on projective space, but is over a subscheme:: @@ -1282,7 +1296,7 @@ def is_morphism(self): sage: X = P.subscheme([x*y + y*z]) sage: H = Hom(X, X) sage: f = H([x*z - y*z, x^2 - y^2, z^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True """ @@ -1319,7 +1333,7 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]); - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 20.8348429892146 :: @@ -1327,7 +1341,7 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]); - sage: f.global_height(prec=11) + sage: f.global_height(prec=11) # needs sage.symbolic 20.8 :: @@ -1335,27 +1349,29 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(ZZ, 2) sage: H = Hom(P, P) sage: f = H([4*x^2 + 100*y^2, 210*x*y, 10000*z^2]); - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 8.51719319141624 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: O = K.maximal_order() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + 3*O(w)*y^2, O(w)*y^2]) # optional - sage.rings.number_field - sage: f.global_height() # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: O = K.maximal_order() + sage: P. = ProjectiveSpace(O, 1) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + 3*O(w)*y^2, O(w)*y^2]) + sage: f.global_height() 1.09861228866811 :: - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: P2. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: H = Hom(P, P2) # optional - sage.rings.number_field - sage: f = H([x^2 + QQbar(I)*x*y + 3*y^2, y^2, QQbar(sqrt(5))*x*y]) # optional - sage.rings.number_field - sage: f.global_height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: P2. = ProjectiveSpace(QQbar, 2) + sage: H = Hom(P, P2) + sage: f = H([x^2 + QQbar(I)*x*y + 3*y^2, y^2, QQbar(sqrt(5))*x*y]) + sage: f.global_height() 1.09861228866811 :: @@ -1364,25 +1380,25 @@ def global_height(self, prec=None): sage: A. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, A) sage: f = H([1/1331*x^2 + 4000*y*z, y^2]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 15.4877354584971 :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([1/25*x^2 + 25/3*x*y + y^2, 1*y^2]) - sage: exp(f.global_height()) + sage: exp(f.global_height()) # needs sage.symbolic 625.000000000000 Scaling should not change the result:: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([1/25*x^2 + 25/3*x*y + y^2, 1*y^2]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 6.43775164973640 sage: c = 10000 sage: f.scale_by(c) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 6.43775164973640 """ K = self.domain().base_ring() @@ -1422,7 +1438,7 @@ def local_height(self, v, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height(1331) + sage: f.local_height(1331) # needs sage.rings.real_mpfr 7.19368581839511 :: @@ -1430,7 +1446,7 @@ def local_height(self, v, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height(1331, prec=2) + sage: f.local_height(1331, prec=2) # needs sage.rings.real_mpfr 8.0 This function does not automatically normalize:: @@ -1438,20 +1454,21 @@ def local_height(self, v, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([4*x^2 + 3/100*y^2, 8/210*x*y, 1/10000*z^2]) - sage: f.local_height(2) + sage: f.local_height(2) # needs sage.rings.real_mpfr 2.77258872223978 - sage: f.normalize_coordinates() - sage: f.local_height(2) + sage: f.normalize_coordinates() # needs sage.libs.singular + sage: f.local_height(2) # needs sage.libs.singular 0.000000000000000 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K, 1) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) + sage: f.local_height(K.ideal(3)) 1.09861228866811 """ K = FractionField(self.domain().base_ring()) @@ -1480,7 +1497,7 @@ def local_height_arch(self, i, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height_arch(0) + sage: f.local_height_arch(0) # needs sage.rings.real_mpfr 5.34710753071747 :: @@ -1488,17 +1505,18 @@ def local_height_arch(self, i, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height_arch(0, prec=5) + sage: f.local_height_arch(0, prec=5) # needs sage.rings.real_mpfr 5.2 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.local_height_arch(1) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K, 1) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) + sage: f.local_height_arch(1) 0.6931471805599453094172321214582 """ K = FractionField(self.domain().base_ring()) @@ -1520,20 +1538,22 @@ def wronskian_ideal(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 11) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 - w*y^2, w*y^2]) # optional - sage.rings.number_field - sage: f.wronskian_ideal() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 11) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 - w*y^2, w*y^2]) + sage: f.wronskian_ideal() Ideal ((4*w)*x*y) of Multivariate Polynomial Ring in x, y over Number Field in w with defining polynomial x^2 + 11 :: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: P2. = ProjectiveSpace(K, 2) - sage: H = Hom(P,P2) + sage: H = Hom(P, P2) sage: f = H([x^2 - 2*y^2, y^2, x*y]) sage: f.wronskian_ideal() Ideal (4*x*y, 2*x^2 + 4*y^2, -2*y^2) of @@ -1577,7 +1597,7 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([16*x^2 - 29*y^2, 16*y^2]) - sage: f.rational_preimages(P(-1, 4)) + sage: f.rational_preimages(P(-1, 4)) # needs sage.libs.singular [(-5/4 : 1), (5/4 : 1)] :: @@ -1587,7 +1607,7 @@ def rational_preimages(self, Q, k=1): sage: f = H([76*x^2 - 180*x*y + 45*y^2 + 14*x*z + 45*y*z - 90*z^2, ....: 67*x^2 - 180*x*y - 157*x*z + 90*y*z, ....: -90*z^2]) - sage: f.rational_preimages(P(-9, -4, 1)) + sage: f.rational_preimages(P(-9, -4, 1)) # needs sage.libs.singular [(0 : 4 : 1)] A non-periodic example :: @@ -1595,7 +1615,7 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([x^2 + y^2, 2*x*y]) - sage: f.rational_preimages(P(17, 15)) + sage: f.rational_preimages(P(17, 15)) # needs sage.libs.singular [(3/5 : 1), (5/3 : 1)] :: @@ -1605,7 +1625,7 @@ def rational_preimages(self, Q, k=1): sage: f = H([x^2 - 2*y*w - 3*w^2, -2*x^2 + y^2 - 2*x*z + 4*y*w + 3*w^2, ....: x^2 - y^2 + 2*x*z + z^2 - 2*y*w - w^2, ....: w^2]) - sage: f.rational_preimages(P(0, -1, 0, 1)) + sage: f.rational_preimages(P(0, -1, 0, 1)) # needs sage.libs.singular [] :: @@ -1613,30 +1633,32 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([x^2 + y^2, 2*x*y]) - sage: f.rational_preimages([CC.0, 1]) + sage: f.rational_preimages([CC.0, 1]) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: point must be in codomain of self A number field example :: + sage: # needs sage.rings.number_field sage: z = QQ['z'].0 - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 + y^2, y^2]) # optional - sage.rings.number_field - sage: f.rational_preimages(P(3, 1)) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 + y^2, y^2]) + sage: f.rational_preimages(P(3, 1)) # needs sage.libs.singular [(-a : 1), (a : 1)] :: + sage: # needs sage.rings.number_field sage: z = QQ['z'].0 - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 - z^2]) # optional - sage.rings.number_field - sage: H = End(X) # optional - sage.rings.number_field - sage: f= H([x^2 - z^2, a*y^2, z^2 - x^2]) # optional - sage.rings.number_field - sage: f.rational_preimages(X([1, 2, -1])) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K, 2) + sage: X = P.subscheme([x^2 - z^2]) + sage: H = End(X) + sage: f= H([x^2 - z^2, a*y^2, z^2 - x^2]) + sage: f.rational_preimages(X([1, 2, -1])) # needs sage.libs.singular [] :: @@ -1645,7 +1667,7 @@ def rational_preimages(self, Q, k=1): sage: X = P.subscheme([x^2 - z^2]) sage: H = End(X) sage: f = H([x^2-z^2, y^2, z^2-x^2]) - sage: f.rational_preimages(X([0, 1, 0])) + sage: f.rational_preimages(X([0, 1, 0])) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - z^2, -x^2 + z^2, @@ -1657,7 +1679,7 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([x^2 - y^2, y^2]) - sage: f.rational_preimages(P.subscheme([x])) + sage: f.rational_preimages(P.subscheme([x])) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: x^2 - y^2 @@ -1666,7 +1688,7 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([x^2 - 29/16*y^2, y^2]) - sage: f.rational_preimages(P(5/4, 1), k=4) + sage: f.rational_preimages(P(5/4, 1), k=4) # needs sage.libs.singular [(-3/4 : 1), (3/4 : 1), (-7/4 : 1), (7/4 : 1)] :: @@ -1675,7 +1697,7 @@ def rational_preimages(self, Q, k=1): sage: P2. = ProjectiveSpace(QQ, 2) sage: H = Hom(P, P2) sage: f = H([x^2, y^2, x^2-y^2]) - sage: f.rational_preimages(P2(1, 1, 0)) + sage: f.rational_preimages(P2(1, 1, 0)) # needs sage.libs.singular [(-1 : 1), (1 : 1)] """ k = ZZ(k) @@ -1727,11 +1749,12 @@ def _number_field_from_algebraics(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([QQbar(3^(1/3))*x^2 + QQbar(sqrt(-2))*y^2, y^2]) # optional - sage.rings.number_field - sage: f._number_field_from_algebraics() # optional - sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: H = End(P) + sage: f = H([QQbar(3^(1/3))*x^2 + QQbar(sqrt(-2))*y^2, y^2]) # needs sage.symbolic + sage: f._number_field_from_algebraics() # needs sage.symbolic Scheme endomorphism of Projective Space of dimension 1 over Number Field in a with defining polynomial y^6 + 6*y^4 - 6*y^3 + 12*y^2 + 36*y + 17 with a = 1.442249570307409? + 1.414213562373095?*I @@ -1742,11 +1765,12 @@ def _number_field_from_algebraics(self): :: - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: P2. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: H = Hom(P, P2) # optional - sage.rings.number_field - sage: f = H([x^2 + QQbar(I)*x*y + 3*y^2, y^2, QQbar(sqrt(5))*x*y]) # optional - sage.rings.number_field - sage: f._number_field_from_algebraics() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: P2. = ProjectiveSpace(QQbar, 2) + sage: H = Hom(P, P2) + sage: f = H([x^2 + QQbar(I)*x*y + 3*y^2, y^2, QQbar(sqrt(5))*x*y]) # needs sage.symbolic + sage: f._number_field_from_algebraics() # needs sage.symbolic Scheme morphism: From: Projective Space of dimension 1 over Number Field in a with defining polynomial y^4 + 3*y^2 + 1 @@ -1759,17 +1783,18 @@ def _number_field_from_algebraics(self): The following was fixed in :trac:`23808`:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: s = (t^3 + t + 1).roots(QQbar)[0][0] # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([s*x^3 - 13*y^3, y^3 - 15*y^3]) # optional - sage.rings.number_field - sage: f # optional - sage.rings.number_field + sage: s = (t^3 + t + 1).roots(QQbar)[0][0] + sage: P. = ProjectiveSpace(QQbar, 1) + sage: H = Hom(P, P) + sage: f = H([s*x^3 - 13*y^3, y^3 - 15*y^3]) + sage: f Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to ((-0.6823278038280193?)*x^3 + (-13)*y^3 : (-14)*y^3) - sage: f_alg = f._number_field_from_algebraics() # optional - sage.rings.number_field - sage: f_alg.change_ring(QQbar) # Used to fail # optional - sage.rings.number_field + sage: f_alg = f._number_field_from_algebraics() + sage: f_alg.change_ring(QQbar) # Used to fail Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to ((-0.6823278038280193?)*x^3 + (-13)*y^3 : (-14)*y^3) @@ -1856,7 +1881,7 @@ def base_indeterminacy_locus(self): sage: P2. = ProjectiveSpace(RR, 3) sage: H = Hom(P1, P2) sage: h = H([y^3*z^3, x^3*z^3, y^3*z^3, x^2*y^2*z^2]) - sage: h.base_indeterminacy_locus() + sage: h.base_indeterminacy_locus() # needs sage.rings.real_mpfr Closed subscheme of Projective Space of dimension 2 over Real Field with 53 bits of precision defined by: y^3*z^3, @@ -1894,7 +1919,7 @@ def indeterminacy_locus(self): sage: P. = ProjectiveSpace(QQ, 2) sage: H = End(P) sage: f = H([x^2, y^2, z^2]) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular ... DeprecationWarning: The meaning of indeterminacy_locus() has changed. Read the docstring. See https://github.com/sagemath/sage/issues/29145 for details. Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: @@ -1907,7 +1932,7 @@ def indeterminacy_locus(self): sage: P. = ProjectiveSpace(QQ, 2) sage: H = End(P) sage: f = H([x*z - y*z, x^2 - y^2, z^2]) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: z, x^2 - y^2 @@ -1951,7 +1976,7 @@ def indeterminacy_points(self, F=None, base=False): sage: P. = ProjectiveSpace(QQ, 2) sage: H = End(P) sage: f = H([x*z - y*z, x^2 - y^2, z^2]) - sage: f.indeterminacy_points() + sage: f.indeterminacy_points() # needs sage.libs.singular ... DeprecationWarning: The meaning of indeterminacy_locus() has changed. Read the docstring. See https://github.com/sagemath/sage/issues/29145 for details. [(-1 : 1 : 0), (1 : 1 : 0)] @@ -1963,10 +1988,10 @@ def indeterminacy_points(self, F=None, base=False): sage: H = Hom(P1, P2) sage: h = H([x + y, y, z + y, y]) sage: set_verbose(None) - sage: h.indeterminacy_points(base=True) + sage: h.indeterminacy_points(base=True) # needs sage.libs.singular [] sage: g = H([y^3*z^3, x^3*z^3, y^3*z^3, x^2*y^2*z^2]) - sage: g.indeterminacy_points(base=True) + sage: g.indeterminacy_points(base=True) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: indeterminacy scheme is not dimension 0 @@ -1976,14 +2001,15 @@ def indeterminacy_points(self, F=None, base=False): sage: P. = ProjectiveSpace(QQ, 2) sage: H = End(P) sage: f = H([x^2 + y^2, x*z, x^2 + y^2]) - sage: f.indeterminacy_points() + sage: f.indeterminacy_points() # needs sage.libs.singular [(0 : 0 : 1)] + sage: R. = QQ[] - sage: K. = NumberField(t^2 + 1) # optional - sage.rings.number_field - sage: f.indeterminacy_points(F=K) # optional - sage.rings.number_field + sage: K. = NumberField(t^2 + 1) # needs sage.rings.number_field + sage: f.indeterminacy_points(F=K) # needs sage.libs.singular sage.rings.number_field [(-a : 1 : 0), (0 : 0 : 1), (a : 1 : 0)] sage: set_verbose(None) - sage: f.indeterminacy_points(F=QQbar, base=True) # optional - sage.rings.number_field + sage: f.indeterminacy_points(F=QQbar, base=True) # needs sage.libs.singular sage.rings.number_field [(-1*I : 1 : 0), (0 : 0 : 1), (1*I : 1 : 0)] :: @@ -1993,16 +2019,17 @@ def indeterminacy_points(self, F=None, base=False): sage: P. = ProjectiveSpace(K, 2) sage: H = End(P) sage: f = H([x^2 - t^2*y^2, y^2 - z^2, x^2 - t^2*z^2]) - sage: f.indeterminacy_points(base=True) + sage: f.indeterminacy_points(base=True) # needs sage.libs.singular [(-t : -1 : 1), (-t : 1 : 1), (t : -1 : 1), (t : 1 : 1)] :: + sage: # needs sage.rings.padics sage: set_verbose(None) - sage: P. = ProjectiveSpace(Qp(3), 2) # optional - sage.rings.padics - sage: H = End(P) # optional - sage.rings.padics - sage: f = H([x^2 - 7*y^2, y^2 - z^2, x^2 - 7*z^2]) # optional - sage.rings.padics - sage: f.indeterminacy_points(base=True) # optional - sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 2) + sage: H = End(P) + sage: f = H([x^2 - 7*y^2, y^2 - z^2, x^2 - 7*z^2]) + sage: f.indeterminacy_points(base=True) # needs sage.libs.singular [(2 + 3 + 3^2 + 2*3^3 + 2*3^5 + 2*3^6 + 3^8 + 3^9 + 2*3^11 + 3^15 + 2*3^16 + 3^18 + O(3^20) : 1 + O(3^20) : 1 + O(3^20)), (2 + 3 + 3^2 + 2*3^3 + 2*3^5 + 2*3^6 + 3^8 + 3^9 + 2*3^11 + 3^15 @@ -2047,25 +2074,26 @@ def reduce_base_field(self): EXAMPLES:: - sage: K. = GF(3^4) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.finite_rings - sage: P2. = ProjectiveSpace(K, 2) # optional - sage.rings.finite_rings - sage: H = End(P) # optional - sage.rings.finite_rings - sage: H2 = Hom(P, P2) # optional - sage.rings.finite_rings - sage: H3 = Hom(P2, P) # optional - sage.rings.finite_rings - sage: f = H([x^2 + (2*t^3 + 2*t^2 + 1)*y^2, y^2]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(3^4) + sage: P. = ProjectiveSpace(K, 1) + sage: P2. = ProjectiveSpace(K, 2) + sage: H = End(P) + sage: H2 = Hom(P, P2) + sage: H3 = Hom(P2, P) + sage: f = H([x^2 + (2*t^3 + 2*t^2 + 1)*y^2, y^2]) + sage: f.reduce_base_field() Scheme endomorphism of Projective Space of dimension 1 over Finite Field in t2 of size 3^2 Defn: Defined on coordinates by sending (x : y) to (x^2 + t2*y^2 : y^2) - sage: f2 = H2([x^2 + 5*y^2, y^2, 2*x*y]) # optional - sage.rings.finite_rings - sage: f2.reduce_base_field() # optional - sage.rings.finite_rings + sage: f2 = H2([x^2 + 5*y^2, y^2, 2*x*y]) + sage: f2.reduce_base_field() Scheme morphism: From: Projective Space of dimension 1 over Finite Field of size 3 To: Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (x^2 - y^2 : y^2 : -x*y) - sage: f3 = H3([a^2 + t*b^2, c^2]) # optional - sage.rings.finite_rings - sage: f3.reduce_base_field() # optional - sage.rings.finite_rings + sage: f3 = H3([a^2 + t*b^2, c^2]) + sage: f3.reduce_base_field() Scheme morphism: From: Projective Space of dimension 2 over Finite Field in t of size 3^4 To: Projective Space of dimension 1 over Finite Field in t of size 3^4 @@ -2073,28 +2101,30 @@ def reduce_base_field(self): :: - sage: K. = CyclotomicField(4) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 + 2*y^2, y^2]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(4) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 + 2*y^2, y^2]) + sage: f.reduce_base_field() Scheme endomorphism of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^2 + 2*y^2 : y^2) :: - sage: K. = GF(5) # optional - sage.rings.finite_rings - sage: L = K.algebraic_closure() # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(L, 1) # optional - sage.rings.finite_rings - sage: H = End(P) # optional - sage.rings.finite_rings - sage: f = H([(L.gen(2))*x^2 + L.gen(4)*y^2, x*y]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(5) + sage: L = K.algebraic_closure() + sage: P. = ProjectiveSpace(L, 1) + sage: H = End(P) + sage: f = H([(L.gen(2))*x^2 + L.gen(4)*y^2, x*y]) + sage: f.reduce_base_field() Scheme endomorphism of Projective Space of dimension 1 over Finite Field in z4 of size 5^4 Defn: Defined on coordinates by sending (x : y) to ((z4^3 + z4^2 + z4 - 2)*x^2 + z4*y^2 : x*y) - sage: f = DynamicalSystem_projective([L.gen(3)*x^2 + L.gen(2)*y^2, x*y]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: f = DynamicalSystem_projective([L.gen(3)*x^2 + L.gen(2)*y^2, x*y]) + sage: f.reduce_base_field() Dynamical System of Projective Space of dimension 1 over Finite Field in z6 of size 5^6 Defn: Defined on coordinates by sending (x : y) to @@ -2103,11 +2133,12 @@ def reduce_base_field(self): TESTS:: - sage: F = GF(3).algebraic_closure() # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 1) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x^2 + y^2, y^2]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(3).algebraic_closure() + sage: P. = ProjectiveSpace(F, 1) + sage: H = Hom(P, P) + sage: f = H([x^2 + y^2, y^2]) + sage: f.reduce_base_field() Scheme endomorphism of Projective Space of dimension 1 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2) @@ -2219,11 +2250,11 @@ def image(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: f = P2.hom([x0^3, x0^2*x1, x0*x1^2], P2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x1^2 - x0*x2 sage: f = P2.hom([x0 - x1, x0 - x2, x1 - x2], P2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x0 - x1 + x2 @@ -2232,7 +2263,7 @@ def image(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: A2. = AffineSpace(QQ, 2) sage: f = P2.hom([1, x0/x1], A2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -x + 1 """ @@ -2249,10 +2280,10 @@ def _fast_eval(self, x): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x^2 + y^2, y^2, z^2 + y*z]) # optional - sage.rings.finite_rings - sage: f._fast_eval([1,1,1]) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(7), 2) + sage: H = Hom(P, P) + sage: f = H([x^2 + y^2, y^2, z^2 + y*z]) + sage: f._fast_eval([1,1,1]) [2, 1, 2] """ if self._is_prime_finite_field: @@ -2279,6 +2310,7 @@ def __call__(self, x): TESTS:: + sage: # needs sage.schemes sage: R. = QQ[] sage: C = Curve(7*x^2 + 2*y*z + z^2) sage: f, g = C.parametrization() @@ -2309,11 +2341,12 @@ def __eq__(self, other): EXAMPLES:: sage: R. = QQ[] - sage: C = Curve(7*x^2 + 2*y*z + z^2) # conic - sage: f, g = C.parametrization() - sage: f*g == C.identity_morphism() + sage: C = Curve(7*x^2 + 2*y*z + z^2) # conic # needs sage.schemes + sage: f, g = C.parametrization() # needs sage.schemes + sage: f*g == C.identity_morphism() # needs sage.schemes True + sage: # needs sage.schemes sage: C = Curve(x^2 + y^2 - z^2) sage: P. = ProjectiveSpace(QQ, 1) sage: f = C.hom([x + z, y], P) @@ -2349,7 +2382,7 @@ def representatives(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P2.subscheme(0) sage: f = X.hom([x^2*y, x^2*z, x*y*z], P2) - sage: f.representatives() + sage: f.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 0 @@ -2362,7 +2395,7 @@ def representatives(self): sage: P1. = ProjectiveSpace(QQ, 1) sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: f = X.hom([x, y], P1) - sage: f.representatives() + sage: f.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z @@ -2373,8 +2406,8 @@ def representatives(self): over Rational Field defined by: x^2 - y^2 - y*z To: Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (x : y)] - sage: g = _[0] - sage: g.representatives() + sage: g = _[0] # needs sage.libs.singular + sage: g.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z @@ -2392,7 +2425,7 @@ def representatives(self): sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: A1. = AffineSpace(QQ, 1) sage: g = X.hom([y/x], A1) - sage: g.representatives() + sage: g.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z @@ -2403,15 +2436,15 @@ def representatives(self): over Rational Field defined by: x^2 - y^2 - y*z To: Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (y/x)] - sage: g0, g1 = _ + sage: g0, g1 = _ # needs sage.libs.singular sage: emb = A1.projective_embedding(0) - sage: emb*g0 + sage: emb*g0 # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z To: Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (y + z : x) - sage: emb*g1 + sage: emb*g1 # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z @@ -2497,8 +2530,8 @@ def indeterminacy_locus(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P2.subscheme(0) sage: f = X.hom([x1,x0], P) - sage: L = f.indeterminacy_locus() - sage: L.rational_points() + sage: L = f.indeterminacy_locus() # needs sage.libs.singular + sage: L.rational_points() # needs sage.libs.singular [(0 : 0 : 1)] :: @@ -2507,7 +2540,7 @@ def indeterminacy_locus(self): sage: P1. = ProjectiveSpace(QQ, 1) sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: f = X.hom([x,y], P1) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: z, y, @@ -2519,12 +2552,12 @@ def indeterminacy_locus(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P3.subscheme(x^2 - w*y - x*z) sage: f = X.hom([x*y, y*z, z*x], P2) - sage: L = f.indeterminacy_locus() - sage: L.dimension() + sage: L = f.indeterminacy_locus() # needs sage.libs.singular + sage: L.dimension() # needs sage.libs.singular 0 - sage: L.degree() + sage: L.degree() # needs sage.libs.singular 2 - sage: L.rational_points() + sage: L.rational_points() # needs sage.libs.singular [(0 : 0 : 0 : 1), (0 : 1 : 0 : 0)] :: @@ -2533,8 +2566,8 @@ def indeterminacy_locus(self): sage: A2. = AffineSpace(QQ, 2) sage: X = P3.subscheme(x^2 - w*y - x*z) sage: f = X.hom([x/z, y/x], A2) - sage: L = f.indeterminacy_locus() - sage: L.rational_points() + sage: L = f.indeterminacy_locus() # needs sage.libs.singular + sage: L.rational_points() # needs sage.libs.singular [(0 : 0 : 0 : 1), (0 : 1 : 0 : 0)] :: @@ -2543,7 +2576,7 @@ def indeterminacy_locus(self): sage: X = P.subscheme(x - y) sage: H = End(X) sage: f = H([x^2 - 4*y^2, y^2 - z^2, 4*z^2 - x^2]) - sage: Z = f.indeterminacy_locus(); Z + sage: Z = f.indeterminacy_locus(); Z # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: z, y, @@ -2589,7 +2622,7 @@ def is_morphism(self): sage: P1. = ProjectiveSpace(QQ, 1) sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: f = X.hom([x,y], P1) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True """ return self.indeterminacy_locus().dimension() < 0 @@ -2604,7 +2637,7 @@ def image(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P2.subscheme(0) sage: f = X.hom([x1,x0], P) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: (no polynomials) @@ -2613,7 +2646,7 @@ def image(self): sage: P2. = ProjectiveSpace(QQ,2) sage: X = P2.subscheme([z^3 - x*y^2 + y^3]) sage: f = X.hom([x*z, x*y, x^2 + y*z], P2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^6 + 2*x^3*y^3 + x*y^5 + y^6 - x^3*y^2*z - y^5*z """ @@ -2665,11 +2698,11 @@ def graph(self): sage: A1. = AffineSpace(1, QQ) sage: X = A1.subscheme(0) # affine line sage: phi = X.hom([x^2], A1) - sage: mor = phi.homogenize(0) - sage: G = mor.graph(); G + sage: mor = phi.homogenize(0) # needs sage.libs.singular + sage: G = mor.graph(); G # needs sage.libs.singular Closed subscheme of Product of projective spaces P^1 x P^1 over Rational Field defined by: x1^2*x2 - x0^2*x3 - sage: G.affine_patch([0, 0]) + sage: G.affine_patch([0, 0]) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x0^2 - x1 """ @@ -2717,12 +2750,13 @@ def projective_degrees(self): EXAMPLES:: - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,1]) # optional - sage.rings.finite_rings - sage: Q = E(6, 5) # optional - sage.rings.finite_rings - sage: phi = E.scalar_multiplication(2) # optional - sage.rings.finite_rings - sage: mor = phi.as_morphism() # optional - sage.rings.finite_rings - sage: mor.projective_degrees() # optional - sage.rings.finite_rings + sage: # needs sage.schemes + sage: k = GF(11) + sage: E = EllipticCurve(k, [1,1]) + sage: Q = E(6, 5) + sage: phi = E.scalar_multiplication(2) + sage: mor = phi.as_morphism() + sage: mor.projective_degrees() (12, 3) """ X = self.domain() @@ -2759,12 +2793,13 @@ def degree(self): EXAMPLES:: - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,1]) # optional - sage.rings.finite_rings - sage: Q = E(6, 5) # optional - sage.rings.finite_rings - sage: phi = E.scalar_multiplication(2) # optional - sage.rings.finite_rings - sage: mor = phi.as_morphism() # optional - sage.rings.finite_rings - sage: mor.degree() # optional - sage.rings.finite_rings + sage: # needs sage.schemes + sage: k = GF(11) + sage: E = EllipticCurve(k, [1,1]) + sage: Q = E(6, 5) + sage: phi = E.scalar_multiplication(2) + sage: mor = phi.as_morphism() + sage: mor.degree() 4 """ return self.projective_degrees()[0] // self.image().degree() diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 05675ce2cc6..53038b21efe 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -139,8 +139,8 @@ def __init__(self, X, v, check=True): :: sage: R. = PolynomialRing(ZZ) - sage: P = ProjectiveSpace(1, R.quo(t^2 + 1)) - sage: P([2*t, 1]) + sage: P = ProjectiveSpace(1, R.quo(t^2 + 1)) # needs sage.libs.pari + sage: P([2*t, 1]) # needs sage.libs.pari (2*tbar : 1) :: @@ -177,9 +177,9 @@ def __init__(self, X, v, check=True): except AttributeError: pass if not isinstance(v, (list, tuple)): - raise TypeError("argument v (= %s) must be a scheme point, list, or tuple"%str(v)) + raise TypeError("argument v (= %s) must be a scheme point, list, or tuple" % str(v)) if len(v) != d and len(v) != d-1: - raise TypeError("v (=%s) must have %s components"%(v, d)) + raise TypeError("v (=%s) must have %s components" % (v, d)) R = X.value_ring() v = Sequence(v, R) @@ -236,9 +236,10 @@ def _richcmp_(self, right, op): :: - sage: PS = ProjectiveSpace(Zp(5), 1, 'x') # optional - sage.rings.padics - sage: P = PS([0, 1]) # optional - sage.rings.padics - sage: P == PS(0) # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: PS = ProjectiveSpace(Zp(5), 1, 'x') + sage: P = PS([0, 1]) + sage: P == PS(0) True :: @@ -261,9 +262,9 @@ def _richcmp_(self, right, op): sage: PS = ProjectiveSpace(ZZ, 1, 'x') sage: P = PS([2, 1]) - sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # optional - sage.rings.padics - sage: Q = PS2([2, 1]) # optional - sage.rings.padics - sage: P == Q # optional - sage.rings.padics + sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # needs sage.rings.padics + sage: Q = PS2([2, 1]) # needs sage.rings.padics + sage: P == Q # needs sage.rings.padics True :: @@ -284,20 +285,23 @@ def _richcmp_(self, right, op): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 + 5) # optional - sage.rings.number_field - sage: OK = K.ring_of_integers() # optional - sage.rings.number_field - sage: t = OK.gen(1) # optional - sage.rings.number_field - sage: PS. = ProjectiveSpace(OK, 1) # optional - sage.rings.number_field - sage: P = PS(2, 1 + t) # optional - sage.rings.number_field - sage: Q = PS(1 - t, 3) # optional - sage.rings.number_field - sage: P == Q # optional - sage.rings.number_field + sage: K. = NumberField(z^2 + 5) + sage: OK = K.ring_of_integers() + sage: t = OK.gen(1) + sage: PS. = ProjectiveSpace(OK, 1) + sage: P = PS(2, 1 + t) + sage: Q = PS(1 - t, 3) + sage: P == Q True Check that :trac:`17429` is fixed:: + sage: # needs sage.rings.complex_interval_field sage: R. = PolynomialRing(QQ) - sage: r = (x^2 - x - 3).polynomial(x).roots(ComplexIntervalField(), multiplicities=False) + sage: r = (x^2 - x - 3).polynomial(x).roots(ComplexIntervalField(), + ....: multiplicities=False) sage: P. = ProjectiveSpace(ComplexIntervalField(), 1) sage: P1 = P(r[0], 1) sage: H = End(P) @@ -324,9 +328,10 @@ def _richcmp_(self, right, op): :: - sage: PS = ProjectiveSpace(Zp(5), 1, 'x') # optional - sage.rings.padics - sage: P = PS([0, 1]) # optional - sage.rings.padics - sage: P != PS(0) # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: PS = ProjectiveSpace(Zp(5), 1, 'x') + sage: P = PS([0, 1]) + sage: P != PS(0) False :: @@ -349,9 +354,9 @@ def _richcmp_(self, right, op): sage: PS = ProjectiveSpace(ZZ, 1, 'x') sage: P = PS([2, 1]) - sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # optional - sage.rings.padics - sage: Q = PS2([2, 1]) # optional - sage.rings.padics - sage: P != Q # optional - sage.rings.padics + sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # needs sage.rings.padics + sage: Q = PS2([2, 1]) # needs sage.rings.padics + sage: P != Q # needs sage.rings.padics False :: @@ -396,11 +401,12 @@ def __hash__(self): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 3) # optional - sage.rings.number_field - sage: O = K.maximal_order() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: hash(P([1 + w, 2])) == hash(P([2, 1 - w])) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 3) + sage: O = K.maximal_order() + sage: P. = ProjectiveSpace(O, 1) + sage: hash(P([1 + w, 2])) == hash(P([2, 1 - w])) True TESTS:: @@ -441,8 +447,8 @@ def _matrix_times_point_(self, mat, dom): sage: P = ProjectiveSpace(QQ, 1) sage: Q = P(1,1) - sage: m = matrix(QQ, 2, 2, [1,1, 0,1]) - sage: m*Q + sage: m = matrix(QQ, 2, 2, [1,1, 0,1]) # needs sage.modules + sage: m*Q # needs sage.modules (2 : 1) :: @@ -450,25 +456,26 @@ def _matrix_times_point_(self, mat, dom): sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme(x - y) sage: Q = X(1,1) - sage: m = matrix(CC, 3, 3, [1,CC.0,0, CC.0,1,0, 1,1,1]) - sage: m*Q + sage: m = matrix(CC, 3, 3, [1,CC.0,0, CC.0,1,0, 1,1,1]) # needs sage.modules + sage: m*Q # needs sage.modules (0.333333333333333 + 0.333333333333333*I : 0.333333333333333 + 0.333333333333333*I : 1.00000000000000) :: - sage: P = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: Q = P(QQbar(sqrt(2)),1) # optional - sage.rings.number_field sage.symbolic - sage: m = matrix(ZZ, 2, 2, [1,-1, 0,1]) # optional - sage.rings.number_field sage.symbolic - sage: m*Q # optional - sage.rings.number_field sage.symbolic + sage: # needs sage.modules sage.rings.number_field sage.symbolic + sage: P = ProjectiveSpace(QQbar, 1) + sage: Q = P(QQbar(sqrt(2)),1) + sage: m = matrix(ZZ, 2, 2, [1,-1, 0,1]) + sage: m*Q (0.4142135623730951? : 1) :: sage: P = ProjectiveSpace(QQ, 1) sage: Q = P(1,1) - sage: m = matrix(QQ, 3, 2, [1,1, 0,1, 1,1]) - sage: m*Q + sage: m = matrix(QQ, 3, 2, [1,1, 0,1, 1,1]) # needs sage.modules + sage: m*Q # needs sage.modules Traceback (most recent call last): ... ValueError: matrix must be square @@ -504,6 +511,7 @@ def scale_by(self,t): :: + sage: # needs sage.libs.pari sage: R. = PolynomialRing(QQ) sage: S = R.quo(R.ideal(t^3)) sage: P. = ProjectiveSpace(S, 2) @@ -546,9 +554,10 @@ def normalize_coordinates(self): :: - sage: P = ProjectiveSpace(Zp(7), 2, 'x') # optional - sage.rings.padics - sage: p = P([-5, -15, -2]) # optional - sage.rings.padics - sage: p.normalize_coordinates(); p # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: P = ProjectiveSpace(Zp(7), 2, 'x') + sage: p = P([-5, -15, -2]) + sage: p.normalize_coordinates(); p (5 + O(7^20) : 1 + 2*7 + O(7^20) : 2 + O(7^20)) :: @@ -586,6 +595,7 @@ def normalize_coordinates(self): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 1) sage: S = R.quotient_ring(R.ideal(t^3)) sage: P. = ProjectiveSpace(S, 1) @@ -641,11 +651,12 @@ def dehomogenize(self,n): sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme(x^2 - y^2) sage: Q = X(23, 23, 46) - sage: Q.dehomogenize(2) + sage: Q.dehomogenize(2) # needs sage.libs.singular (1/2, 1/2) :: + sage: # needs sage.libs.pari sage: R. = PolynomialRing(QQ) sage: S = R.quo(R.ideal(t^3)) sage: P. = ProjectiveSpace(S, 2) @@ -655,16 +666,16 @@ def dehomogenize(self,n): :: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: Q = P(1, 3, 1) # optional - sage.rings.finite_rings - sage: Q.dehomogenize(0) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: Q = P(1, 3, 1) + sage: Q.dehomogenize(0) (3, 1) :: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: Q = P(1, 3, 0) # optional - sage.rings.finite_rings - sage: Q.dehomogenize(2) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: Q = P(1, 3, 0) + sage: Q.dehomogenize(2) Traceback (most recent call last): ... ValueError: can...t dehomogenize at 0 coordinate @@ -696,49 +707,50 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: Q = P.point([4, 4, 1/30]) - sage: Q.global_height() + sage: Q.global_height() # needs sage.symbolic 4.78749174278205 :: sage: P. = ProjectiveSpace(ZZ, 2) sage: Q = P([4, 1, 30]) - sage: Q.global_height() + sage: Q.global_height() # needs sage.symbolic 3.40119738166216 :: sage: R. = PolynomialRing(QQ) - sage: k. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: A = ProjectiveSpace(k, 2, 'z') # optional - sage.rings.number_field - sage: A([3, 5*w + 1, 1]).global_height(prec=100) # optional - sage.rings.number_field + sage: k. = NumberField(x^2 + 5) # needs sage.rings.number_field + sage: A = ProjectiveSpace(k, 2, 'z') # needs sage.rings.number_field + sage: A([3, 5*w + 1, 1]).global_height(prec=100) # needs sage.rings.number_field 2.4181409534757389986565376694 :: - sage: P. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1]) # optional - sage.rings.number_field - sage: Q.global_height() # optional - sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 2) # needs sage.rings.number_field + sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1]) # needs sage.rings.number_field + sage: Q.global_height() # needs sage.rings.number_field 0.549306144334055 :: - sage: K = UniversalCyclotomicField() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: Q = P.point([K(4/3), K.gen(7), K.gen(5)]) # optional - sage.rings.number_field - sage: Q.global_height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = UniversalCyclotomicField() + sage: P. = ProjectiveSpace(K, 2) + sage: Q = P.point([K(4/3), K.gen(7), K.gen(5)]) + sage: Q.global_height() 1.38629436111989 TESTS:: sage: P = ProjectiveSpace(QQ, 2) - sage: P(1/1, 2/3, 5/8).global_height() + sage: P(1/1, 2/3, 5/8).global_height() # needs sage.symbolic 3.17805383034795 sage: x = polygen(QQ, 'x') - sage: F. = NumberField(x^3 - 5) # optional - sage.rings.number_field - sage: P = ProjectiveSpace(F, 2) # optional - sage.rings.number_field - sage: P(u, u^2/5, 1).global_height() # optional - sage.rings.number_field + sage: F. = NumberField(x^3 - 5) # needs sage.rings.number_field + sage: P = ProjectiveSpace(F, 2) # needs sage.rings.number_field + sage: P(u, u^2/5, 1).global_height() # needs sage.rings.number_field 1.07295860828940 """ if prec is None: @@ -788,14 +800,14 @@ def local_height(self, v, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: Q = P.point([4, 4, 1/150], False) - sage: Q.local_height(5) + sage: Q.local_height(5) # needs sage.rings.real_mpfr 3.21887582486820 :: sage: P. = ProjectiveSpace(QQ, 2) sage: Q = P([4, 1, 30]) - sage: Q.local_height(2) + sage: Q.local_height(2) # needs sage.rings.real_mpfr 0.693147180559945 """ K = FractionField(self.domain().base_ring()) @@ -822,14 +834,15 @@ def local_height_arch(self, i, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: Q = P.point([4, 4, 1/150], False) - sage: Q.local_height_arch(0) + sage: Q.local_height_arch(0) # needs sage.rings.real_mpfr 1.38629436111989 :: - sage: P. = ProjectiveSpace(QuadraticField(5, 'w'), 2) # optional - sage.rings.number_field - sage: Q = P.point([4, 1, 30], False) # optional - sage.rings.number_field - sage: Q.local_height_arch(1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QuadraticField(5, 'w'), 2) + sage: Q = P.point([4, 1, 30], False) + sage: Q.local_height_arch(1) 3.401197381662155375413236691607 """ K = FractionField(self.domain().base_ring()) @@ -862,9 +875,9 @@ def multiplier(self, f, n, check=True): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([x^2, y^2, 4*w^2, 4*z^2], domain=P) + sage: f = DynamicalSystem_projective([x^2, y^2, 4*w^2, 4*z^2], domain=P) # needs sage.schemes sage: Q = P.point([4, 4, 1, 1], False) - sage: Q.multiplier(f, 1) + sage: Q.multiplier(f, 1) # needs sage.schemes [ 2 0 -8] [ 0 2 -8] [ 0 0 -2] @@ -919,103 +932,106 @@ def is_preperiodic(self, f, err=0.1, return_period=False): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([x^3 - 3*x*y^2, y^3], domain=P) + sage: f = DynamicalSystem_projective([x^3 - 3*x*y^2, y^3], domain=P) # needs sage.schemes sage: Q = P(-1, 1) - sage: Q.is_preperiodic(f) + sage: Q.is_preperiodic(f) # needs sage.libs.singular sage.schemes True :: sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme(z) - sage: f = DynamicalSystem([x^2 - y^2, y^2, z^2], domain=X) + sage: f = DynamicalSystem([x^2 - y^2, y^2, z^2], domain=X) # needs sage.schemes sage: p = X((-1, 1, 0)) - sage: p.is_preperiodic(f, return_period=True) + sage: p.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (0, 2) :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2], domain=P) + sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2], domain=P) # needs sage.schemes sage: Q = P(1, 4) - sage: Q.is_preperiodic(f, return_period=True) + sage: Q.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (1, 3) sage: Q = P(1, 1) - sage: Q.is_preperiodic(f, return_period=True) + sage: Q.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (0, 0) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x^5 + 5/4*x*y^4, y^5], domain=P) # optional - sage.rings.number_field - sage: Q = P([-1/2*a + 1/2, 1]) # optional - sage.rings.number_field - sage: Q.is_preperiodic(f) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^5 + 5/4*x*y^4, y^5], domain=P) # needs sage.schemes + sage: Q = P([-1/2*a + 1/2, 1]) + sage: Q.is_preperiodic(f) # needs sage.schemes True - sage: Q = P([a, 1]) # optional - sage.rings.number_field - sage: Q.is_preperiodic(f) # optional - sage.rings.number_field + sage: Q = P([a, 1]) + sage: Q.is_preperiodic(f) # needs sage.schemes False :: sage: P. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([ + sage: f = DynamicalSystem_projective([ # needs sage.schemes ....: -38/45*x^2 + (2*y - 7/45*z)*x + (-1/2*y^2 - 1/2*y*z + z^2), ....: -67/90*x^2 + (2*y + z*157/90)*x - y*z, ....: z^2 ....: ], domain=P) sage: Q = P([1, 3, 1]) - sage: Q.is_preperiodic(f, return_period=True) + sage: Q.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (0, 9) :: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([ + sage: f = DynamicalSystem_projective([ # needs sage.schemes ....: (-y - w)*x + (-13/30*y^2 + 13/30*w*y + w^2), ....: -1/2*x^2 + (-y + 3/2*w)*x + (-1/3*y^2 + 4/3*w*y), ....: -3/2*z^2 + 5/2*z*w + w^2, ....: w^2 ....: ], domain=P) sage: Q = P([3,0,4/3,1]) - sage: Q.is_preperiodic(f, return_period=True) + sage: Q.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (2, 24) :: + sage: # needs sage.rings.number_field sage.schemes sage.symbolic sage: from sage.misc.verbose import set_verbose sage: set_verbose(-1) - sage: P. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, z^2], # optional - sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 2) + sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, z^2], ....: domain=P) - sage: Q = P([1, 1, 1]) # optional - sage.rings.number_field sage.symbolic - sage: Q.is_preperiodic(f) # optional - sage.rings.number_field sage.symbolic + sage: Q = P([1, 1, 1]) + sage: Q.is_preperiodic(f) True :: + sage: # needs sage.rings.number_field sage.schemes sage.symbolic sage: set_verbose(-1) - sage: P. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=P) # optional - sage.rings.number_field - sage: Q = P([QQbar(sqrt(-1)), 1, 1]) # optional - sage.rings.number_field sage.symbolic - sage: Q.is_preperiodic(f) # optional - sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 2) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=P) + sage: Q = P([QQbar(sqrt(-1)), 1, 1]) + sage: Q.is_preperiodic(f) True :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2], domain=P) + sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2], domain=P) # needs sage.schemes sage: Q = P(-1,4) - sage: Q.is_preperiodic(f) + sage: Q.is_preperiodic(f) # needs sage.libs.singular sage.schemes True :: - sage: P. = ProjectiveSpace(GF(3), 2) # optional - sage.rings.finite_rings - sage: F = DynamicalSystem([x^2 - 2*y^2, y^2, z^2]) # optional - sage.rings.finite_rings - sage: Q = P(1, 1, 1) # optional - sage.rings.finite_rings - sage: Q.is_preperiodic(F, return_period=True) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(3), 2) + sage: F = DynamicalSystem([x^2 - 2*y^2, y^2, z^2]) # needs sage.schemes + sage: Q = P(1, 1, 1) + sage: Q.is_preperiodic(F, return_period=True) # needs sage.schemes (1, 1) TESTS:: @@ -1032,9 +1048,9 @@ def is_preperiodic(self, f, err=0.1, return_period=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) + sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) # needs sage.schemes sage: Q = P(11,4) - sage: Q.is_preperiodic(f, err=2) + sage: Q.is_preperiodic(f, err=2) # needs sage.libs.singular sage.schemes False """ try: @@ -1098,9 +1114,9 @@ def __init__(self, X, v, check=True): :: - sage: P = ProjectiveSpace(1, GF(7)) # optional - sage.rings.finite_rings - sage: Q = P([2, 1]) # optional - sage.rings.finite_rings - sage: Q[0].parent() # optional - sage.rings.finite_rings + sage: P = ProjectiveSpace(1, GF(7)) + sage: Q = P([2, 1]) + sage: Q[0].parent() Finite Field of size 7 :: @@ -1137,9 +1153,9 @@ def __init__(self, X, v, check=True): except AttributeError: pass if not isinstance(v, (list,tuple)): - raise TypeError("argument v (= %s) must be a scheme point, list, or tuple"%str(v)) + raise TypeError("argument v (= %s) must be a scheme point, list, or tuple" % str(v)) if len(v) != d and len(v) != d-1: - raise TypeError("v (=%s) must have %s components"%(v, d)) + raise TypeError("v (=%s) must have %s components" % (v, d)) R = X.value_ring() v = Sequence(v, R) @@ -1192,10 +1208,10 @@ def normalize_coordinates(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: Q = P.point([GF(5)(1), GF(5)(3), GF(5)(0)], False); Q # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: Q = P.point([GF(5)(1), GF(5)(3), GF(5)(0)], False); Q (1 : 3 : 0) - sage: Q.normalize_coordinates(); Q # optional - sage.rings.finite_rings + sage: Q.normalize_coordinates(); Q (2 : 1 : 0) :: @@ -1223,27 +1239,29 @@ def _number_field_from_algebraics(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage.symbolic sage: R. = PolynomialRing(QQ) - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]) # optional - sage.rings.number_field sage.symbolic - sage: S = Q._number_field_from_algebraics(); S # optional - sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 1) + sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]) + sage: S = Q._number_field_from_algebraics(); S (1/2*a^3 + a^2 - 1/2*a : 1) - sage: S.codomain() # optional - sage.rings.number_field sage.symbolic + sage: S.codomain() Projective Space of dimension 1 over Number Field in a with defining polynomial y^4 + 1 with a = 0.7071067811865475? + 0.7071067811865475?*I The following was fixed in :trac:`23808`:: + sage: # needs sage.rings.number_field sage.symbolic sage: R. = PolynomialRing(QQ) - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]);Q # optional - sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 1) + sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]);Q (-0.7071067811865475? + 1*I : 1) - sage: S = Q._number_field_from_algebraics(); S # optional - sage.rings.number_field sage.symbolic + sage: S = Q._number_field_from_algebraics(); S (1/2*a^3 + a^2 - 1/2*a : 1) - sage: T = S.change_ring(QQbar) # Used to fail # optional - sage.rings.number_field sage.symbolic - sage: T # optional - sage.rings.number_field sage.symbolic + sage: T = S.change_ring(QQbar) # Used to fail + sage: T (-0.7071067811865475? + 1.000000000000000?*I : 1) - sage: Q[0] == T[0] # optional - sage.rings.number_field sage.symbolic + sage: Q[0] == T[0] True """ from sage.schemes.projective.projective_space import is_ProjectiveSpace @@ -1281,11 +1299,12 @@ def clear_denominators(self): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 - 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: Q = P([1/w, 3, 0]) # optional - sage.rings.number_field - sage: Q.clear_denominators(); Q # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3) + sage: P. = ProjectiveSpace(K, 2) + sage: Q = P([1/w, 3, 0]) + sage: Q.clear_denominators(); Q (w : 9 : 0) :: @@ -1325,13 +1344,13 @@ def intersection_multiplicity(self, X): sage: X = P.subscheme([x*z - y^2]) sage: Y = P.subscheme([x^3 - y*w^2 + z*w^2, x*y - z*w]) sage: Q1 = X([1/2, 1/4, 1/8, 1]) - sage: Q1.intersection_multiplicity(Y) + sage: Q1.intersection_multiplicity(Y) # needs sage.libs.singular 1 sage: Q2 = X([0,0,0,1]) - sage: Q2.intersection_multiplicity(Y) + sage: Q2.intersection_multiplicity(Y) # needs sage.libs.singular 5 sage: Q3 = X([0,0,1,0]) - sage: Q3.intersection_multiplicity(Y) + sage: Q3.intersection_multiplicity(Y) # needs sage.libs.singular 6 :: @@ -1363,10 +1382,10 @@ def multiplicity(self): sage: P. = ProjectiveSpace(QQ, 4) sage: X = P.subscheme([y^6 - x^3*w^2*t + t^5*w, x^2 - t^2]) sage: Q1 = X([1,0,2,1,1]) - sage: Q1.multiplicity() + sage: Q1.multiplicity() # needs sage.libs.singular 1 sage: Q2 = X([0,0,-2,1,0]) - sage: Q2.multiplicity() + sage: Q2.multiplicity() # needs sage.libs.singular 8 """ from sage.schemes.projective.projective_space import is_ProjectiveSpace @@ -1384,27 +1403,27 @@ def __hash__(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: hash(P(2, 1, 2)) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: hash(P(2, 1, 2)) 41 :: - sage: P. = ProjectiveSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.finite_rings - sage: hash(X(1, 1, 2)) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(7), 2) + sage: X = P.subscheme(x^2 - y^2) + sage: hash(X(1, 1, 2)) 81 :: - sage: P. = ProjectiveSpace(GF(13), 1) # optional - sage.rings.finite_rings - sage: hash(P(3, 4)) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13), 1) + sage: hash(P(3, 4)) 17 :: - sage: P. = ProjectiveSpace(GF(13^3,'t'), 1) # optional - sage.rings.finite_rings - sage: hash(P(3, 4)) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13^3,'t'), 1) # needs sage.rings.finite_rings + sage: hash(P(3, 4)) # needs sage.rings.finite_rings 2201 """ p = self.codomain().base_ring().order() @@ -1420,6 +1439,7 @@ class SchemeMorphism_point_abelian_variety_field(AdditiveGroupElement, SchemeMor EXAMPLES:: + sage: # needs sage.schemes sage: E = EllipticCurve([0,0,1,-1,0]) sage: origin = E(0) sage: origin.domain() diff --git a/src/sage/schemes/projective/projective_rational_point.py b/src/sage/schemes/projective/projective_rational_point.py index b0244869d07..31dc0703b5a 100644 --- a/src/sage/schemes/projective/projective_rational_point.py +++ b/src/sage/schemes/projective/projective_rational_point.py @@ -26,8 +26,8 @@ Projective over a finite field:: sage: from sage.schemes.projective.projective_rational_point import enum_projective_finite_field - sage: E = EllipticCurve('72').change_ring(GF(19)) # optional - sage.rings.finite_rings - sage: enum_projective_finite_field(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve('72').change_ring(GF(19)) # needs sage.schemes + sage: enum_projective_finite_field(E) # needs sage.schemes [(0 : 1 : 0), (1 : 0 : 1), (3 : 0 : 1), (4 : 9 : 1), (4 : 10 : 1), (6 : 6 : 1), (6 : 13 : 1), (7 : 6 : 1), (7 : 13 : 1), (9 : 4 : 1), (9 : 15 : 1), (12 : 8 : 1), (12 : 11 : 1), (13 : 8 : 1), (13 : 11 : 1), @@ -185,22 +185,23 @@ def enum_projective_number_field(X, **kwds): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.projective.projective_rational_point import enum_projective_number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^3 - 5, 'v') # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: X = P.subscheme([x - y]) # optional - sage.rings.number_field - sage: enum_projective_number_field(X(K), bound=RR(5^(1/3)), prec=2^10) # optional - sage.rings.number_field + sage: K = NumberField(u^3 - 5, 'v') + sage: P. = ProjectiveSpace(K, 2) + sage: X = P.subscheme([x - y]) + sage: enum_projective_number_field(X(K), bound=RR(5^(1/3)), prec=2^10) [(0 : 0 : 1), (1 : 1 : 0), (-1 : -1 : 1), (1 : 1 : 1)] :: + sage: # needs sage.rings.number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 3, 'v') # optional - sage.rings.number_field - sage: A. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = A.subscheme(x - y) # optional - sage.rings.number_field - sage: from sage.schemes.projective.projective_rational_point import enum_projective_number_field - sage: enum_projective_number_field(X, bound=2) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 3, 'v') + sage: A. = ProjectiveSpace(K, 1) + sage: X = A.subscheme(x - y) + sage: enum_projective_number_field(X, bound=2) [(1 : 1)] """ B = kwds.pop('bound') @@ -244,29 +245,30 @@ def enum_projective_finite_field(X): EXAMPLES:: - sage: F = GF(53) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(2, F) # optional - sage.rings.finite_rings sage: from sage.schemes.projective.projective_rational_point import enum_projective_finite_field - sage: len(enum_projective_finite_field(P(F))) # optional - sage.rings.finite_rings + sage: F = GF(53) + sage: P. = ProjectiveSpace(2, F) + sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2 + 53 + 1 2863 :: - sage: F = GF(9, 'a') # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(2,F) # optional - sage.rings.finite_rings - sage: C = Curve(X^3 - Y^3 + Z^2*Y) # optional - sage.rings.finite_rings - sage: enum_projective_finite_field(C(F)) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(9, 'a') + sage: P. = ProjectiveSpace(2,F) + sage: C = Curve(X^3 - Y^3 + Z^2*Y) # needs sage.schemes + sage: enum_projective_finite_field(C(F)) # needs sage.schemes [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: - sage: F = GF(5) # optional - sage.rings.finite_rings - sage: P2F. = ProjectiveSpace(2, F) # optional - sage.rings.finite_rings - sage: enum_projective_finite_field(P2F) # optional - sage.rings.finite_rings + sage: F = GF(5) + sage: P2F. = ProjectiveSpace(2, F) + sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), @@ -344,15 +346,15 @@ def sieve(X, bound): sage: from sage.schemes.projective.projective_rational_point import sieve sage: P. = ProjectiveSpace(QQ, 3) sage: Y = P.subscheme([x^2 - 3^2*y^2 + z*q, x + z + 4*q]) - sage: sorted(sieve(Y, 12)) # long time + sage: sorted(sieve(Y, 12)) # long time # needs sage.libs.singular [(-4 : -4/3 : 0 : 1), (-4 : 4/3 : 0 : 1), (-1 : -1/3 : 1 : 0), (-1 : 1/3 : 1 : 0)] :: sage: from sage.schemes.projective.projective_rational_point import sieve - sage: E = EllipticCurve('37a') - sage: sorted(sieve(E, 14)) # long time + sage: E = EllipticCurve('37a') # needs sage.schemes + sage: sorted(sieve(E, 14)) # long time # needs sage.libs.singular sage.schemes [(-1 : -1 : 1), (-1 : 0 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 0), (1/4 : -5/8 : 1), (1/4 : -3/8 : 1), (1 : -1 : 1), (1 : 0 : 1), @@ -365,7 +367,7 @@ def sieve(X, bound): sage: from sage.schemes.projective.projective_rational_point import sieve sage: P. = ProjectiveSpace(2, QQ) sage: X = P.subscheme(3*x - 3/2*y) - sage: sieve(X, 3) + sage: sieve(X, 3) # needs sage.libs.singular [(-1 : -2 : 1), (-1/2 : -1 : 1), (-1/3 : -2/3 : 1), (0 : 0 : 1), (1/3 : 2/3 : 1), (1/2 : 1 : 0), (1/2 : 1 : 1), (1 : 2 : 1)] """ diff --git a/src/sage/schemes/projective/projective_space.py b/src/sage/schemes/projective/projective_space.py index eae8dd26fec..ecb34f8230a 100644 --- a/src/sage/schemes/projective/projective_space.py +++ b/src/sage/schemes/projective/projective_space.py @@ -24,7 +24,7 @@ sage: X = ProjectiveSpace(5)/QQ; X Projective Space of dimension 5 over Rational Field - sage: X/CC + sage: X/CC # needs sage.rings.real_mpfr Projective Space of dimension 5 over Complex Field with 53 bits of precision The third argument specifies the printing names of the generators of the @@ -59,7 +59,7 @@ Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x + y + z, x + y - z - sage: V.dimension() + sage: V.dimension() # needs sage.libs.singular 0 AUTHORS: @@ -141,7 +141,7 @@ def is_ProjectiveSpace(x): sage: from sage.schemes.projective.projective_space import is_ProjectiveSpace sage: is_ProjectiveSpace(ProjectiveSpace(5, names='x')) True - sage: is_ProjectiveSpace(ProjectiveSpace(5, GF(9, 'alpha'), names='x')) # optional - sage.rings.finite_rings + sage: is_ProjectiveSpace(ProjectiveSpace(5, GF(9, 'alpha'), names='x')) # needs sage.rings.finite_rings True sage: is_ProjectiveSpace(Spec(ZZ)) False @@ -170,7 +170,7 @@ def ProjectiveSpace(n, R=None, names=None): :: - sage: ProjectiveSpace(5)/GF(17) # optional - sage.rings.finite_rings + sage: ProjectiveSpace(5)/GF(17) Projective Space of dimension 5 over Finite Field of size 17 The default base ring is `\ZZ`. @@ -184,17 +184,17 @@ def ProjectiveSpace(n, R=None, names=None): :: - sage: R = GF(7)['x,y,z'] # optional - sage.rings.finite_rings - sage: P = ProjectiveSpace(R); P # optional - sage.rings.finite_rings + sage: R = GF(7)['x,y,z'] + sage: P = ProjectiveSpace(R); P Projective Space of dimension 2 over Finite Field of size 7 - sage: P.coordinate_ring() # optional - sage.rings.finite_rings + sage: P.coordinate_ring() Multivariate Polynomial Ring in x, y, z over Finite Field of size 7 - sage: P.coordinate_ring() is R # optional - sage.rings.finite_rings + sage: P.coordinate_ring() is R True :: - sage: ProjectiveSpace(3, Zp(5), 'y') # optional - sage.rings.padics + sage: ProjectiveSpace(3, Zp(5), 'y') # needs sage.rings.padics Projective Space of dimension 3 over 5-adic Ring with capped relative precision 20 :: @@ -204,8 +204,7 @@ def ProjectiveSpace(n, R=None, names=None): :: - sage: PS. = ProjectiveSpace(1, CC) - sage: PS + sage: PS. = ProjectiveSpace(1, CC); PS # needs sage.rings.real_mpfr Projective Space of dimension 1 over Complex Field with 53 bits of precision :: @@ -337,7 +336,7 @@ def __init__(self, n, R=ZZ, names=None): EXAMPLES:: - sage: ProjectiveSpace(3, Zp(5), 'y') # optional - sage.rings.padics + sage: ProjectiveSpace(3, Zp(5), 'y') # needs sage.rings.padics Projective Space of dimension 3 over 5-adic Ring with capped relative precision 20 """ AmbientSpace.__init__(self, n, R) @@ -419,7 +418,7 @@ def coordinate_ring(self): EXAMPLES:: - sage: ProjectiveSpace(3, GF(19^2,'alpha'), 'abcd').coordinate_ring() # optional - sage.rings.finite_rings + sage: ProjectiveSpace(3, GF(19^2,'alpha'), 'abcd').coordinate_ring() # needs sage.rings.finite_rings Multivariate Polynomial Ring in a, b, c, d over Finite Field in alpha of size 19^2 :: @@ -590,7 +589,7 @@ def _latex_(self): TESTS:: - sage: ProjectiveSpace(3, Zp(5), 'y')._latex_() # optional - sage.rings.padics + sage: ProjectiveSpace(3, Zp(5), 'y')._latex_() # needs sage.rings.padics '{\\mathbf P}_{\\Bold{Z}_{5}}^3' """ return "{\\mathbf P}_{%s}^%s" % (latex(self.base_ring()), @@ -622,9 +621,9 @@ def _linear_system_as_kernel(self, d, pt, m): If the degree `d` is 0, then a matrix consisting of the first unit vector is returned:: - sage: P = ProjectiveSpace(GF(5), 2, names='x') # optional - sage.rings.finite_rings - sage: pt = P([1, 1, 1]) # optional - sage.rings.finite_rings - sage: P._linear_system_as_kernel(0, pt, 3) # optional - sage.rings.finite_rings + sage: P = ProjectiveSpace(GF(5), 2, names='x') + sage: pt = P([1, 1, 1]) + sage: P._linear_system_as_kernel(0, pt, 3) # needs sage.modules [1] [0] [0] @@ -635,10 +634,10 @@ def _linear_system_as_kernel(self, d, pt, m): If the multiplicity `m` is 0, then a matrix with zero rows is returned:: - sage: P = ProjectiveSpace(GF(5), 2, names='x') # optional - sage.rings.finite_rings - sage: pt = P([1, 1, 1]) # optional - sage.rings.finite_rings - sage: M = P._linear_system_as_kernel(2, pt, 0) # optional - sage.rings.finite_rings - sage: [M.nrows(), M.ncols()] # optional - sage.rings.finite_rings + sage: P = ProjectiveSpace(GF(5), 2, names='x') + sage: pt = P([1, 1, 1]) + sage: M = P._linear_system_as_kernel(2, pt, 0) # needs sage.modules + sage: [M.nrows(), M.ncols()] # needs sage.modules [0, 6] The base ring does not need to be a field or even an integral domain. @@ -647,7 +646,7 @@ def _linear_system_as_kernel(self, d, pt, m): sage: R = Zmod(4) sage: P = ProjectiveSpace(R, 2, names='x') sage: pt = [R(1), R(3), R(0)] - sage: P._linear_system_as_kernel(3, pt, 2) + sage: P._linear_system_as_kernel(3, pt, 2) # needs sage.modules [1 3 0 1 0 0 3 0 0 0] [0 1 0 2 0 0 3 0 0 0] [0 0 1 0 3 0 0 1 0 0] @@ -656,10 +655,10 @@ def _linear_system_as_kernel(self, d, pt, m): (even when the base ring is a field and the list gives a well-defined point in projective space):: - sage: R = GF(5) # optional - sage.rings.finite_rings - sage: P = ProjectiveSpace(R, 2, names='x') # optional - sage.rings.finite_rings - sage: pt = [R(3), R(3), R(0)] # optional - sage.rings.finite_rings - sage: P._linear_system_as_kernel(3, pt, 2) # optional - sage.rings.finite_rings + sage: R = GF(5) + sage: P = ProjectiveSpace(R, 2, names='x') + sage: pt = [R(3), R(3), R(0)] + sage: P._linear_system_as_kernel(3, pt, 2) # needs sage.modules Traceback (most recent call last): ... TypeError: at least one component of pt=[3, 3, 0] must be equal to 1 @@ -673,7 +672,7 @@ def _linear_system_as_kernel(self, d, pt, m): sage: P = ProjectiveSpace(QQ, 3, names='x') sage: RPol. = PolynomialRing(QQ, 4) sage: pt = [t0,t1,1,t3] - sage: P._linear_system_as_kernel(2, pt, 2) + sage: P._linear_system_as_kernel(2, pt, 2) # needs sage.modules [ 2*t0 t1 1 t3 0 0 0 0 0 0] [ 0 t0 0 0 2*t1 1 t3 0 0 0] [ t0^2 t0*t1 t0 t0*t3 t1^2 t1 t1*t3 1 t3 t3^2] @@ -735,8 +734,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x,y,z]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x,y,z]) Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) @@ -765,8 +764,8 @@ def _point_homset(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._point_homset(Spec(GF(3)), P2) Set of rational points of Projective Space of dimension 2 over Finite Field of size 3 """ return SchemeHomset_points_projective_ring(*args, **kwds) @@ -829,9 +828,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1,2,3]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1,2,3]) (2 : 1 : 0) """ return SchemeMorphism_point_projective_ring(*args, **kwds) @@ -847,7 +846,7 @@ def _repr_(self): TESTS:: - sage: ProjectiveSpace(3, Zp(5), 'y')._repr_() # optional - sage.rings.padics + sage: ProjectiveSpace(3, Zp(5), 'y')._repr_() # needs sage.rings.padics 'Projective Space of dimension 3 over 5-adic Ring with capped relative precision 20' """ return "Projective Space of dimension %s over %s" % (self.dimension_relative(), self.base_ring()) @@ -915,14 +914,14 @@ def change_ring(self, R): sage: P. = ProjectiveSpace(2, ZZ) sage: PQ = P.change_ring(QQ); PQ Projective Space of dimension 2 over Rational Field - sage: PQ.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: PQ.change_ring(GF(5)) Projective Space of dimension 2 over Finite Field of size 5 :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: P = ProjectiveSpace(K, 2, 't') # optional - sage.rings.number_field - sage: P.change_ring(K.embeddings(QQbar)[0]) # optional - sage.rings.number_field + sage: K. = QuadraticField(2) # needs sage.rings.number_field + sage: P = ProjectiveSpace(K, 2, 't') # needs sage.rings.number_field + sage: P.change_ring(K.embeddings(QQbar)[0]) # needs sage.rings.number_field Projective Space of dimension 2 over Algebraic Field """ if isinstance(R, Map): @@ -964,9 +963,9 @@ def subscheme(self, X): sage: I = X.defining_ideal(); I Ideal (x*z^2, y^2*z, x*y^2) of Multivariate Polynomial Ring in x, y, z over Rational Field - sage: I.groebner_basis() + sage: I.groebner_basis() # needs sage.libs.singular [x*y^2, y^2*z, x*z^2] - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular 0 sage: X.base_ring() Rational Field @@ -1025,63 +1024,67 @@ def points_of_bounded_height(self, **kwds): :: sage: u = QQ['u'].0 - sage: P. = ProjectiveSpace(NumberField(u^2 - 2, 'v'), 2) # optional - sage.rings.number_field - sage: len(list(P.points_of_bounded_height(bound=2))) # optional - sage.rings.number_field + sage: P. = ProjectiveSpace(NumberField(u^2 - 2, 'v'), 2) # needs sage.rings.number_field + sage: len(list(P.points_of_bounded_height(bound=2))) # needs sage.rings.number_field 265 :: - sage: CF. = CyclotomicField(3) # optional - sage.rings.number_field - sage: R. = CF[] # optional - sage.rings.number_field - sage: L. = CF.extension(x^3 + 2) # optional - sage.rings.number_field - sage: Q. = ProjectiveSpace(L, 1) # optional - sage.rings.number_field - sage: sorted(list(Q.points_of_bounded_height(bound=1))) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF. = CyclotomicField(3) + sage: R. = CF[] + sage: L. = CF.extension(x^3 + 2) + sage: Q. = ProjectiveSpace(L, 1) + sage: sorted(list(Q.points_of_bounded_height(bound=1))) [(0 : 1), (1 : 0), (a + 1 : 1), (a : 1), (-1 : 1), (-a - 1 : 1), (-a : 1), (1 : 1)] :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: F. = NumberField(x^4 - 8*x^2 + 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.number_field - sage: all(exp(p.global_height()) <= 1 # optional - sage.rings.number_field + sage: F. = NumberField(x^4 - 8*x^2 + 3) + sage: P. = ProjectiveSpace(F, 2) + sage: all(exp(p.global_height()) <= 1 # needs sage.symbolic ....: for p in P.points_of_bounded_height(bound=1)) True :: - sage: K. = CyclotomicField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: len(list(P.points_of_bounded_height(bound=1))) # optional - sage.rings.number_field + sage: K. = CyclotomicField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: len(list(P.points_of_bounded_height(bound=1))) # needs sage.rings.number_field 57 :: sage: u = QQ['u'].0 - sage: K. = NumberField(u^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: len(list(P.points_of_bounded_height(bound=2))) # optional - sage.rings.number_field + sage: K. = NumberField(u^2 - 2) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: len(list(P.points_of_bounded_height(bound=2))) # needs sage.rings.number_field 24 :: sage: R. = QQ[] - sage: K. = NumberField(x^4 - 8*x^2 + 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: len(list(P.points_of_bounded_height(bound=2))) # optional - sage.rings.number_field + sage: K. = NumberField(x^4 - 8*x^2 + 3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: len(list(P.points_of_bounded_height(bound=2))) # needs sage.rings.number_field 108 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 + x^3 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: L = P.points_of_bounded_height(bound=1.2) # optional - sage.rings.number_field - sage: len(list(L)) # optional - sage.rings.number_field + sage: K. = NumberField(x^5 + x^3 + 1) + sage: P. = ProjectiveSpace(K, 2) + sage: L = P.points_of_bounded_height(bound=1.2) + sage: len(list(L)) 109 :: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(2) sage: P. = ProjectiveSpace(K, 1) sage: sorted(list(P.points_of_bounded_height(bound=2))) @@ -1092,6 +1095,7 @@ def points_of_bounded_height(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: P. = ProjectiveSpace(K, 1) @@ -1101,6 +1105,7 @@ def points_of_bounded_height(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: O = K.maximal_order() @@ -1110,6 +1115,7 @@ def points_of_bounded_height(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^3 - 7) sage: O = K.maximal_order() @@ -1136,6 +1142,7 @@ def points_of_bounded_height(self, **kwds): :: + sage: # needs sage.rings.number_field sage: K. = NumberField(x^2 + 1) sage: PK. = K[] sage: L. = K.extension(t^4 - i) @@ -1326,17 +1333,17 @@ def Lattes_map(self, E, m): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: E = EllipticCurve(QQ,[-1, 0]) - sage: P.Lattes_map(E, 2) + sage: E = EllipticCurve(QQ,[-1, 0]) # needs sage.schemes + sage: P.Lattes_map(E, 2) # needs sage.schemes Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (1/4*x^4 + 1/2*x^2*y^2 + 1/4*y^4 : x^3*y - x*y^3) TESTS:: - sage: P. = ProjectiveSpace(GF(37), 1) # optional - sage.rings.finite_rings - sage: E = EllipticCurve([1, 1]) # optional - sage.rings.finite_rings - sage: f = P.Lattes_map(E, 2); f # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(37), 1) + sage: E = EllipticCurve([1, 1]) # needs sage.rings.finite_rings sage.schemes + sage: f = P.Lattes_map(E, 2); f # needs sage.rings.finite_rings sage.schemes Dynamical System of Projective Space of dimension 1 over Finite Field of size 37 Defn: Defined on coordinates by sending (x : y) to (-9*x^4 + 18*x^2*y^2 - 2*x*y^3 - 9*y^4 : x^3*y + x*y^3 + y^4) @@ -1405,7 +1412,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: P.chebyshev_polynomial(5, 'first') + sage: P.chebyshev_polynomial(5, 'first') # needs sage.symbolic Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (16*x^5 - 20*x^3*y^2 + 5*x*y^4 : y^5) @@ -1413,7 +1420,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: P.chebyshev_polynomial(3, 'second') + sage: P.chebyshev_polynomial(3, 'second') # needs sage.symbolic Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (8*x^3 - 4*x*y^2 : y^3) @@ -1421,7 +1428,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: P.chebyshev_polynomial(3, 2) + sage: P.chebyshev_polynomial(3, 2) # needs sage.symbolic Traceback (most recent call last): ... ValueError: keyword 'kind' must have a value of either 'first' or 'second' @@ -1445,7 +1452,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: P.chebyshev_polynomial(3, monic=True) + sage: P.chebyshev_polynomial(3, monic=True) # needs sage.symbolic Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^3 - 3*x*y^2 : y^3) @@ -1454,7 +1461,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): sage: F. = FunctionField(QQ) sage: P. = ProjectiveSpace(F, 1) - sage: P.chebyshev_polynomial(4, monic=True) + sage: P.chebyshev_polynomial(4, monic=True) # needs sage.symbolic Dynamical System of Projective Space of dimension 1 over Rational function field in t over Rational Field Defn: Defined on coordinates by sending (y : z) to @@ -1495,8 +1502,8 @@ def veronese_embedding(self, d, CS=None, order='lex'): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: vd = P.veronese_embedding(4, order='invlex') - sage: vd + sage: vd = P.veronese_embedding(4, order='invlex') # needs sage.combinat + sage: vd # needs sage.combinat Scheme morphism: From: Projective Space of dimension 1 over Rational Field To: Projective Space of dimension 4 over Rational Field @@ -1507,14 +1514,14 @@ def veronese_embedding(self, d, CS=None, order='lex'): sage: P. = ProjectiveSpace(QQ, 2) sage: Q. = ProjectiveSpace(QQ, 5) - sage: vd = P.veronese_embedding(2, Q) - sage: vd + sage: vd = P.veronese_embedding(2, Q) # needs sage.combinat + sage: vd # needs sage.combinat Scheme morphism: From: Projective Space of dimension 2 over Rational Field To: Projective Space of dimension 5 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (x^2 : x*y : x*z : y^2 : y*z : z^2) - sage: vd(P.subscheme([])) + sage: vd(P.subscheme([])) # needs sage.combinat sage.libs.singular Closed subscheme of Projective Space of dimension 5 over Rational Field defined by: -u^2 + t*v, @@ -1577,19 +1584,19 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P1. = ProjectiveSpace(QQ, 2) sage: points_source = [P1([1, 4, 1]), P1([1, 2, 2]), P1([3, 5, 1]), P1([1, -1, 1])] sage: points_target = [P1([5, -2, 7]), P1([3, -2, 3]), P1([6, -5, 9]), P1([3, 6, 7])] - sage: m = P1.point_transformation_matrix(points_source, points_target); m + sage: m = P1.point_transformation_matrix(points_source, points_target); m # needs sage.modules [ -13/59 -128/59 -25/59] [538/177 8/59 26/177] [ -45/59 -196/59 1] - sage: [m*points_source[i] == points_target[i] for i in range(4)] + sage: [m*points_source[i] == points_target[i] for i in range(4)] # needs sage.modules [True, True, True, True] :: - sage: P. = ProjectiveSpace(GF(13), 1) # optional - sage.rings.finite_rings - sage: points_source = [P([-6, 7]), P([1, 4]), P([3, 2])] # optional - sage.rings.finite_rings - sage: points_target = [P([-1, 2]), P([0, 2]), P([-1, 6])] # optional - sage.rings.finite_rings - sage: P.point_transformation_matrix(points_source, points_target) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13), 1) + sage: points_source = [P([-6, 7]), P([1, 4]), P([3, 2])] + sage: points_target = [P([-1, 2]), P([0, 2]), P([-1, 6])] + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules [10 4] [10 1] @@ -1598,7 +1605,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(QQ, 1) sage: points_source = [P([-6, -4]), P([1, 4]), P([3, 2])] sage: points_target = [P([-1, 2]), P([0, 2]), P([-7, -3])] - sage: P.point_transformation_matrix(points_source, points_target) + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules Traceback (most recent call last): ... ValueError: source points not independent @@ -1609,7 +1616,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(R, 1) sage: points_source = [P([-6*t, 7]), P([1, 4]), P([3, 2])] sage: points_target = [P([-1, 2*t]), P([0, 2]), P([-1, 6])] - sage: P.point_transformation_matrix(points_source, points_target) + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules [ (1/3*t + 7/12)/(t^2 - 53/24*t) (-1/12*t - 7/48)/(t^2 - 53/24*t)] [(-2/3*t^2 - 7/36*t - 35/12)/(t^2 - 53/24*t) 1] @@ -1618,7 +1625,8 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P1. = ProjectiveSpace(RR, 2) sage: points_source = [P1([1, 4, 1]), P1([1, 2, 2]), P1([3, 5, 1]), P1([1, -1, 1])] sage: points_target = [P1([5, -2, 7]), P1([3, -2, 3]), P1([6, -5, 9]), P1([3, 6, 7])] - sage: P1.point_transformation_matrix(points_source, points_target) # abs tol 1e-13 + sage: P1.point_transformation_matrix(points_source, # abs tol 1e-13 # needs sage.modules + ....: points_target) [-0.0619047619047597 -0.609523809523810 -0.119047619047621] [ 0.853968253968253 0.0380952380952380 0.0412698412698421] [ -0.214285714285712 -0.933333333333333 0.280952380952379] @@ -1628,7 +1636,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P1. = ProjectiveSpace(ZZ, 2) sage: points_source = [P1([1, 4, 1]), P1([1, 2, 2]), P1([3, 5, 1]), P1([1, -1, 1])] sage: points_target = [P1([5, -2, 7]), P1([3, -2, 3]), P1([6, -5, 9]), P1([3, 6, 7])] - sage: P1.point_transformation_matrix(points_source, points_target) + sage: P1.point_transformation_matrix(points_source, points_target) # needs sage.modules [ -39 -384 -75] [ 538 24 26] [-135 -588 177] @@ -1638,7 +1646,8 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P1. = ProjectiveSpace(ZZ, 2) sage: points_source = [P1([1, 4, 1]), P1([1, 2, 2]), P1([3, 5, 1]), P1([1, -1, 1])] sage: points_target = [P1([5, -2, 7]), P1([3, -2, 3]), P1([6, -5, 9]), P1([3, 6, 7])] - sage: P1.point_transformation_matrix(points_source, points_target, normalize=False) + sage: P1.point_transformation_matrix(points_source, points_target, # needs sage.modules + ....: normalize=False) [-13/30 -64/15 -5/6] [269/45 4/15 13/45] [ -3/2 -98/15 59/30] @@ -1649,7 +1658,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(R, 1) sage: points_source = [P([-6*t, 7]), P([1, 4]), P([3, 2])] sage: points_target = [P([-1, 2*t]), P([0, 2]), P([-1, 6])] - sage: P.point_transformation_matrix(points_source, points_target) + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules [ -48*t - 84 12*t + 21] [96*t^2 + 28*t + 420 -144*t^2 + 318*t] @@ -1658,7 +1667,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(QQ, 1) sage: points_source = [P([-6, -1]), P([1, 4]), P([3, 2])] sage: points_target = [P([-1, 2]), P([0, 2]), P([-2, 4])] - sage: P.point_transformation_matrix(points_source, points_target) + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules Traceback (most recent call last): ... ValueError: target points not independent @@ -1710,7 +1719,8 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(ZZ, 2) sage: points_source = [P(1, 0, 0), P(0, 1, 0), P(0, 0, 1), P(1, -1, -1)] sage: points_target = [P(0, 1, 0), P(-2, 0, 1), P(0, 0, 1), P(1, -1, -1)] - sage: P.point_transformation_matrix(points_source, points_target, normalize=True) + sage: P.point_transformation_matrix(points_source, points_target, # needs sage.modules + ....: normalize=True) [ 0 -2 0] [-2 0 0] [ 0 1 1] @@ -1786,10 +1796,10 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): sage: P. = ProjectiveSpace(QQ, 1) sage: plane1 = P.subscheme(x) sage: plane2 = P.subscheme(y) - sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m + sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m # needs sage.modules [0 1] [1 0] - sage: plane2(m*P((0,1))) + sage: plane2(m*P((0,1))) # needs sage.modules (1 : 0) :: @@ -1797,7 +1807,7 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): sage: P. = ProjectiveSpace(QQ, 3) sage: plane1 = P.subscheme(x + 2*y + z) sage: plane2 = P.subscheme(2*x + y + z) - sage: P.hyperplane_transformation_matrix(plane1, plane2) + sage: P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules [1 0 0 0] [0 4 0 0] [0 0 2 0] @@ -1808,30 +1818,31 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): sage: P. = ProjectiveSpace(ZZ, 1) sage: plane1 = P.subscheme(x + y) sage: plane2 = P.subscheme(y) - sage: P.hyperplane_transformation_matrix(plane1, plane2) + sage: P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules [-1 0] [ 1 1] :: - sage: K. = CyclotomicField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: plane1 = P.subscheme(x - 2*v*y + z) # optional - sage.rings.number_field - sage: plane2 = P.subscheme(x + v*y + v*z) # optional - sage.rings.number_field - sage: m = P.hyperplane_transformation_matrix(plane1, plane2) # optional - sage.rings.number_field - sage: m # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: P. = ProjectiveSpace(K, 2) + sage: plane1 = P.subscheme(x - 2*v*y + z) + sage: plane2 = P.subscheme(x + v*y + v*z) + sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m # needs sage.modules [ v 0 0] [ 0 -2*v 0] [ 0 0 1] :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 3) # optional - sage.rings.number_field - sage: plane1 = P.subscheme(k*x + 2*k*y + z) # optional - sage.rings.number_field - sage: plane2 = P.subscheme(7*k*x + y + 9*z) # optional - sage.rings.number_field - sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: P. = ProjectiveSpace(K, 3) + sage: plane1 = P.subscheme(k*x + 2*k*y + z) + sage: plane2 = P.subscheme(7*k*x + y + 9*z) + sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m # needs sage.modules [ 1 0 0 0] [ 0 14*k 0 0] [ 0 0 7/9 0] @@ -1839,23 +1850,24 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): :: - sage: K. = CyclotomicField(3) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: F. = K.extension(t^5 + 2) # optional - sage.rings.number_field - sage: G. = F.absolute_field() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(G, 2) # optional - sage.rings.number_field - sage: plane1 = P.subscheme(x - 2*u*y + z) # optional - sage.rings.number_field - sage: plane2 = P.subscheme(x + u*y + z) # optional - sage.rings.number_field - sage: m = P.hyperplane_transformation_matrix(plane1, plane2) # optional - sage.rings.number_field - sage: plane2(m*P((2*u, 1, 0))) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: R. = K[] + sage: F. = K.extension(t^5 + 2) + sage: G. = F.absolute_field() + sage: P. = ProjectiveSpace(G, 2) + sage: plane1 = P.subscheme(x - 2*u*y + z) + sage: plane2 = P.subscheme(x + u*y + z) + sage: m = P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules + sage: plane2(m*P((2*u, 1, 0))) # needs sage.modules (-u : 1 : 0) :: - sage: P. = ProjectiveSpace(FiniteField(2), 2) # optional - sage.rings.finite_rings - sage: plane1 = P.subscheme(x + y + z) # optional - sage.rings.finite_rings - sage: plane2 = P.subscheme(z) # optional - sage.rings.finite_rings - sage: P.hyperplane_transformation_matrix(plane1, plane2) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(FiniteField(2), 2) + sage: plane1 = P.subscheme(x + y + z) + sage: plane2 = P.subscheme(z) + sage: P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules [1 0 0] [1 1 0] [1 1 1] @@ -1866,7 +1878,7 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): sage: P. = ProjectiveSpace(R, 2) sage: plane1 = P.subscheme(x + 9*t*y + z) sage: plane2 = P.subscheme(x + z) - sage: P.hyperplane_transformation_matrix(plane1, plane2) + sage: P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules [ 1 9*t 0] [ 1 0 0] [ 0 0 1] @@ -1971,14 +1983,14 @@ def is_linearly_independent(self, points, n=None): sage: P. = ProjectiveSpace(QQ, 2) sage: points = [P((1, 0, 1)), P((1, 2, 1)), P((1, 3, 4))] - sage: P.is_linearly_independent(points) + sage: P.is_linearly_independent(points) # needs sage.modules True :: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: points = [P((1, 0, 1)), P((1, 2, 1)), P((1, 3, 4)), P((0, 0, 1))] # optional - sage.rings.finite_rings - sage: P.is_linearly_independent(points, 2) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: points = [P((1, 0, 1)), P((1, 2, 1)), P((1, 3, 4)), P((0, 0, 1))] + sage: P.is_linearly_independent(points, 2) # needs sage.modules True :: @@ -1986,7 +1998,7 @@ def is_linearly_independent(self, points, n=None): sage: R. = QQ[] sage: P. = ProjectiveSpace(R, 2) sage: points = [P((c, 0, 1)), P((0, c, 1)), P((1, 0, 4)), P((0, 0, 1))] - sage: P.is_linearly_independent(points, 3) + sage: P.is_linearly_independent(points, 3) # needs sage.modules False :: @@ -1994,22 +2006,23 @@ def is_linearly_independent(self, points, n=None): sage: R. = QQ[] sage: P. = ProjectiveSpace(FractionField(R), 2) sage: points = [P((c, 0, 1)), P((0, c, 1)), P((1, 3, 4)), P((0, 0, 1))] - sage: P.is_linearly_independent(points, 3) + sage: P.is_linearly_independent(points, 3) # needs sage.modules True :: - sage: K. = CyclotomicField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: points = [P((k, k^2, 1)), P((0, k, 1)), P((1, 0, 4)), P((0, 0, 1))] # optional - sage.rings.number_field - sage: P.is_linearly_independent(points, 3) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: P. = ProjectiveSpace(K, 2) + sage: points = [P((k, k^2, 1)), P((0, k, 1)), P((1, 0, 4)), P((0, 0, 1))] + sage: P.is_linearly_independent(points, 3) # needs sage.modules True :: sage: P. = ProjectiveSpace(QQ, 1) sage: points = [P((1, 0)), P((1, 1))] - sage: P.is_linearly_independent(points) + sage: P.is_linearly_independent(points) # needs sage.modules True TESTS:: @@ -2054,8 +2067,8 @@ def _point_homset(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._point_homset(Spec(GF(3)), P2) Set of rational points of Projective Space of dimension 2 over Finite Field of size 3 """ return SchemeHomset_points_projective_field(*args, **kwds) @@ -2068,9 +2081,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1,2,3]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1,2,3]) (2 : 1 : 0) """ return SchemeMorphism_point_projective_field(*args, **kwds) @@ -2083,8 +2096,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x,y,z]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x,y,z]) Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) @@ -2119,7 +2132,7 @@ def subscheme_from_Chow_form(self, Ch, dim): sage: P = ProjectiveSpace(QQ, 4, 'z') sage: R. = PolynomialRing(QQ) sage: H = x1^2 + x2^2 + 5*x3*x4 - sage: P.subscheme_from_Chow_form(H, 3) + sage: P.subscheme_from_Chow_form(H, 3) # needs sage.modules Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: -5*z0*z1 + z2^2 + z3^2 @@ -2128,7 +2141,7 @@ def subscheme_from_Chow_form(self, Ch, dim): sage: P = ProjectiveSpace(QQ, 3, 'z') sage: R. = PolynomialRing(QQ) sage: H = x1 - x2 - x3 + x5 + 2*x0 - sage: P.subscheme_from_Chow_form(H, 1) + sage: P.subscheme_from_Chow_form(H, 1) # needs sage.modules Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: -z1 + z3, @@ -2138,11 +2151,12 @@ def subscheme_from_Chow_form(self, Ch, dim): :: - sage: P. = ProjectiveSpace(GF(7), 3) # optional - sage.rings.finite_rings - sage: X = P.subscheme([x3^2 + x1*x2, x2 - x0]) # optional - sage.rings.finite_rings - sage: Ch = X.Chow_form(); Ch # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: P. = ProjectiveSpace(GF(7), 3) + sage: X = P.subscheme([x3^2 + x1*x2, x2 - x0]) + sage: Ch = X.Chow_form(); Ch t0^2 - 2*t0*t3 + t3^2 - t2*t4 - t4*t5 - sage: Y = P.subscheme_from_Chow_form(Ch, 1); Y # optional - sage.rings.finite_rings + sage: Y = P.subscheme_from_Chow_form(Ch, 1); Y Closed subscheme of Projective Space of dimension 3 over Finite Field of size 7 defined by: x1*x2 + x3^2, @@ -2153,8 +2167,8 @@ def subscheme_from_Chow_form(self, Ch, dim): -2*x0*x3 + 2*x2*x3, 2*x0*x3 - 2*x2*x3, x0^2 - 2*x0*x2 + x2^2 - sage: I = Y.defining_ideal() # optional - sage.rings.finite_rings - sage: I.saturation(I.ring().ideal(list(I.ring().gens())))[0] # optional - sage.rings.finite_rings + sage: I = Y.defining_ideal() + sage: I.saturation(I.ring().ideal(list(I.ring().gens())))[0] Ideal (x0 - x2, x1*x2 + x3^2) of Multivariate Polynomial Ring in x0, x1, x2, x3 over Finite Field of size 7 """ @@ -2214,7 +2228,7 @@ def curve(self, F): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 2) - sage: P.curve([y^2 - x*z]) + sage: P.curve([y^2 - x*z]) # needs sage.schemes Projective Plane Curve over Rational Field defined by y^2 - x*z """ from sage.schemes.curves.constructor import Curve @@ -2233,7 +2247,7 @@ def line_through(self, p, q): sage: P3. = ProjectiveSpace(3, QQ) sage: p1 = P3(1, 2, 3, 4) sage: p2 = P3(4, 3, 2, 1) - sage: P3.line_through(p1, p2) + sage: P3.line_through(p1, p2) # needs sage.schemes Projective Curve over Rational Field defined by -5/4*x0 + 5/2*x1 - 5/4*x2, -5/2*x0 + 15/4*x1 - 5/4*x3, -5/4*x0 + 15/4*x2 - 5/2*x3, -5/4*x1 + 5/2*x2 - 5/4*x3 @@ -2262,9 +2276,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1,2,3]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1,2,3]) (2 : 1 : 0) """ return SchemeMorphism_point_projective_finite_field(*args, **kwds) @@ -2277,8 +2291,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x,y,z]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x,y,z]) Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) @@ -2297,15 +2311,15 @@ def __iter__(self): EXAMPLES:: - sage: FF = FiniteField(3) # optional - sage.rings.finite_rings - sage: PP = ProjectiveSpace(0, FF) # optional - sage.rings.finite_rings - sage: [ x for x in PP ] # optional - sage.rings.finite_rings + sage: FF = FiniteField(3) + sage: PP = ProjectiveSpace(0, FF) + sage: [ x for x in PP ] [(1)] - sage: PP = ProjectiveSpace(1, FF) # optional - sage.rings.finite_rings - sage: [ x for x in PP ] # optional - sage.rings.finite_rings + sage: PP = ProjectiveSpace(1, FF) + sage: [ x for x in PP ] [(0 : 1), (1 : 1), (2 : 1), (1 : 0)] - sage: PP = ProjectiveSpace(2, FF) # optional - sage.rings.finite_rings - sage: [ x for x in PP ] # optional - sage.rings.finite_rings + sage: PP = ProjectiveSpace(2, FF) + sage: [ x for x in PP ] [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), @@ -2348,12 +2362,13 @@ def rational_points(self, F=None): EXAMPLES:: - sage: P = ProjectiveSpace(1, GF(3)) # optional - sage.rings.finite_rings - sage: P.rational_points() # optional - sage.rings.finite_rings + sage: P = ProjectiveSpace(1, GF(3)) + sage: P.rational_points() [(0 : 1), (1 : 1), (2 : 1), (1 : 0)] - sage: P.rational_points(GF(3^2, 'b')) # optional - sage.rings.finite_rings - [(0 : 1), (b : 1), (b + 1 : 1), (2*b + 1 : 1), (2 : 1), (2*b : 1), - (2*b + 2 : 1), (b + 2 : 1), (1 : 1), (1 : 0)] + sage: sorted(P.rational_points(GF(3^2, 'b')), key=str) # needs sage.rings.finite_rings + [(0 : 1), (1 : 0), (1 : 1), (2 : 1), + (2*b + 1 : 1), (2*b + 2 : 1), (2*b : 1), + (b + 1 : 1), (b + 2 : 1), (b : 1)] """ if F is None: return [P for P in self] @@ -2371,8 +2386,8 @@ def rational_points_dictionary(self): EXAMPLES:: - sage: P1 = ProjectiveSpace(GF(7), 1, 'x') # optional - sage.rings.finite_rings - sage: P1.rational_points_dictionary() # optional - sage.rings.finite_rings + sage: P1 = ProjectiveSpace(GF(7), 1, 'x') + sage: P1.rational_points_dictionary() {(0 : 1): 0, (1 : 0): 7, (1 : 1): 1, diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index c247f630ff6..8970637882d 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -113,7 +113,7 @@ def point(self, v, check=True): if v is infinity or\ (isinstance(v, (list,tuple)) and len(v) == 1 and v[0] is infinity): if self.ambient_space().dimension_relative() > 1: - raise ValueError("%s not well defined in dimension > 1"%v) + raise ValueError("%s not well defined in dimension > 1" % v) v = [1, 0] # todo: update elliptic curve stuff to take point_homset as argument from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve @@ -168,6 +168,7 @@ def dimension(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2. = ProjectiveSpace(2, QQ) sage: P2.subscheme([]).dimension() 2 @@ -190,7 +191,7 @@ def dimension(self): x^2*y^2 + z^2*t^2, z^2 - w^2, 10*x^2 - z^2 + w^2 - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular 1 """ try: @@ -221,11 +222,11 @@ def affine_patch(self, i, AA=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: PP = ProjectiveSpace(2, QQ, names='X,Y,Z') sage: X,Y,Z = PP.gens() sage: C = PP.subscheme(X^3*Y + Y^3*Z + Z^3*X) - sage: U = C.affine_patch(0) - sage: U + sage: U = C.affine_patch(0); U Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: Y^3*Z + Z^3 + Y sage: U.embedding_morphism() @@ -242,8 +243,8 @@ def affine_patch(self, i, AA=None): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([x - y*z]) - sage: Y = X.projective_embedding(1).codomain() - sage: Y.affine_patch(1, A).ambient_space() == A + sage: Y = X.projective_embedding(1).codomain() # needs sage.libs.singular + sage: Y.affine_patch(1, A).ambient_space() == A # needs sage.libs.singular True :: @@ -251,7 +252,7 @@ def affine_patch(self, i, AA=None): sage: P. = ProjectiveSpace(2, ZZ) sage: S = P.subscheme([u^2 - v*w]) sage: A. = AffineSpace(2, ZZ) - sage: S.affine_patch(1, A) + sage: S.affine_patch(1, A) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Integer Ring defined by: x^2 - y """ @@ -259,7 +260,7 @@ def affine_patch(self, i, AA=None): PP = self.ambient_space() n = PP.dimension_relative() if i < 0 or i > n: - raise ValueError("Argument i (= %s) must be between 0 and %s."%(i, n)) + raise ValueError("Argument i (= %s) must be between 0 and %s." % (i, n)) try: A = self.__affine_patches[i] #assume that if you've passed in a new ambient affine space @@ -273,7 +274,7 @@ def affine_patch(self, i, AA=None): if AA is None: AA = PP.affine_patch(i) elif AA.dimension_relative() != n: - raise ValueError("Affine Space must be of the dimension %s"%(n)) + raise ValueError("Affine Space must be of the dimension %s" % (n)) phi = AA.projective_embedding(i, PP) polys = self.defining_polynomials() xi = phi.defining_polynomials() @@ -310,9 +311,9 @@ def _best_affine_patch(self, point): TESTS:: - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: S._best_affine_patch([0,1,2]) # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: P. = ProjectiveSpace(F, 2) + sage: S._best_affine_patch([0,1,2]) 2 """ point = list(point) @@ -325,7 +326,7 @@ def _best_affine_patch(self, point): i_max = 0 p_max = abs_point[i_max] for i in range(1,len(point)): - if abs_point[i]>p_max: + if abs_point[i] > p_max: i_max = i p_max = abs_point[i_max] return i_max @@ -410,6 +411,7 @@ def is_smooth(self, point=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2. = ProjectiveSpace(2, QQ) sage: cuspidal_curve = P2.subscheme([y^2*z - x^3]) sage: cuspidal_curve @@ -426,8 +428,8 @@ def is_smooth(self, point=None): TESTS:: - sage: H = P2.subscheme(x) - sage: H.is_smooth() # one of the few cases where the cone over the subvariety is smooth + sage: H = P2.subscheme(x) # needs sage.libs.singular + sage: H.is_smooth() # one of the few cases where the cone over the subvariety is smooth # needs sage.libs.singular True """ if point is not None: @@ -468,8 +470,9 @@ def orbit(self, f, N): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, (x-2*w)^2, x^2]) - sage: f.orbit(P.subscheme([x]), 5) + sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, # needs sage.schemes + ....: (x-2*w)^2, x^2]) + sage: f.orbit(P.subscheme([x]), 5) # needs sage.schemes [Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: x, Closed subscheme of Projective Space of dimension 3 over Rational Field @@ -498,9 +501,9 @@ def orbit(self, f, N): :: sage: PS. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.schemes sage: X = PS.subscheme([x - y]) - sage: X.orbit(f, [-1,2]) + sage: X.orbit(f, [-1,2]) # needs sage.schemes Traceback (most recent call last): ... TypeError: orbit bounds must be non-negative @@ -544,8 +547,8 @@ def nth_iterate(self, f, n): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([y^2, z^2, x^2, w^2]) - sage: f.nth_iterate(P.subscheme([x - w, y - z]), 3) + sage: f = DynamicalSystem_projective([y^2, z^2, x^2, w^2]) # needs sage.schemes + sage: f.nth_iterate(P.subscheme([x - w, y - z]), 3) # needs sage.schemes Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: y - z, @@ -554,9 +557,9 @@ def nth_iterate(self, f, n): :: sage: PS. = ProjectiveSpace(ZZ, 2) - sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.schemes sage: X = PS.subscheme([x - y]) - sage: X.nth_iterate(f, -2) + sage: X.nth_iterate(f, -2) # needs sage.schemes Traceback (most recent call last): ... TypeError: must be a forward orbit @@ -576,9 +579,9 @@ def nth_iterate(self, f, n): :: sage: PS. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.schemes sage: X = PS.subscheme([x - y]) - sage: X.nth_iterate(f, 2.5) + sage: X.nth_iterate(f, 2.5) # needs sage.schemes Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral RealNumber to Integer @@ -615,7 +618,7 @@ def _forward_image(self, f, check=True): sage: H = End(PS) sage: f = H([x^2, y^2 - 2*z^2, z^2]) sage: X = PS.subscheme(y - 2*z) - sage: X._forward_image(f) + sage: X._forward_image(f) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: y - 2*z @@ -627,7 +630,7 @@ def _forward_image(self, f, check=True): sage: H = End(PS) sage: f = H([y^2, x^2, w^2, z^2]) sage: X = PS.subscheme([z^2 + y*w, x - w]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Integer Ring defined by: y - z, @@ -635,11 +638,12 @@ def _forward_image(self, f, check=True): :: + sage: # needs sage.rings.real_mpfr sage: PS. = ProjectiveSpace(CC, 3) sage: H = End(PS) sage: f = H([x^2 + y^2, y^2, z^2-y^2, w^2]) sage: X = PS.subscheme([z - 2*w]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Complex Field with 53 bits of precision defined by: y + z + (-4.00000000000000)*w @@ -650,19 +654,20 @@ def _forward_image(self, f, check=True): sage: P. = ProjectiveSpace(FractionField(R), 2) sage: H = End(P) sage: f = H([x^2 + 2*y*z, t^2*y^2, z^2]) - sage: f([t^2*y - z]) + sage: f([t^2*y - z]) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by: y - 1/(t^2)*z :: + sage: # needs sage.rings.padics sage: set_verbose(-1) - sage: PS. = ProjectiveSpace(Qp(3), 2) # optional - sage.rings.padics - sage: H = End(PS) # optional - sage.rings.padics - sage: f = H([x^2, 2*y^2, z^2]) # optional - sage.rings.padics - sage: X = PS.subscheme([2*x - y, z]) # optional - sage.rings.padics - sage: f(X) # optional - sage.rings.padics + sage: PS. = ProjectiveSpace(Qp(3), 2) + sage: H = End(PS) + sage: f = H([x^2, 2*y^2, z^2]) + sage: X = PS.subscheme([2*x - y, z]) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over 3-adic Field with capped relative precision 20 defined by: z, @@ -675,7 +680,7 @@ def _forward_image(self, f, check=True): sage: H = End(P) sage: f = H([y0*x^2 + y1*z^2, y2*y^2 + y3*z^2, z^2]) sage: X = P.subscheme(x*z) - sage: X._forward_image(f) + sage: X._forward_image(f) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Fraction Field of Multivariate Polynomial Ring in y0, y1, y2, y3 over Rational Field defined by: @@ -688,7 +693,7 @@ def _forward_image(self, f, check=True): sage: H = Hom(P2, P5) sage: f = H([x^2, x*y, x*z, y^2, y*z, z^2]) # Veronese map sage: X = P2.subscheme([]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 5 over Rational Field defined by: -z4^2 + z3*z5, @@ -705,7 +710,7 @@ def _forward_image(self, f, check=True): sage: H = Hom(P2, P3) sage: X = P2.subscheme([x - y, x - z]) sage: f = H([x^2, y^2, z^2, x*y]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: w - t, @@ -719,7 +724,7 @@ def _forward_image(self, f, check=True): sage: H = Hom(P2, P1) sage: f = H([x^2, y*z]) sage: X = P2.subscheme([x - y]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: map must be a morphism @@ -730,7 +735,7 @@ def _forward_image(self, f, check=True): sage: H = End(PS) sage: f = H([x^3, x*y^2, x*z^2]) sage: X = PS.subscheme([x - y]) - sage: X._forward_image(f) + sage: X._forward_image(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: map must be a morphism @@ -742,7 +747,7 @@ def _forward_image(self, f, check=True): sage: Y = P1.subscheme([u - v]) sage: H = End(PS) sage: f = H([x^2, y^2, z^2]) - sage: Y._forward_image(f) + sage: Y._forward_image(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: subscheme must be in ambient space of domain of map @@ -801,7 +806,7 @@ def preimage(self, f, k=1, check=True): sage: H = End(PS) sage: f = H([y^2, x^2, z^2]) sage: X = PS.subscheme([x - y]) - sage: X.preimage(f) + sage: X.preimage(f) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Integer Ring defined by: -x^2 + y^2 @@ -811,7 +816,7 @@ def preimage(self, f, k=1, check=True): sage: P. = ProjectiveSpace(QQ, 4) sage: H = End(P) sage: f = H([x^2 - y^2, y^2, z^2, w^2, t^2 + w^2]) - sage: f.rational_preimages(P.subscheme([x - z, t^2, w - t])) + sage: f.rational_preimages(P.subscheme([x - z, t^2, w - t])) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: x^2 - y^2 - z^2, @@ -825,7 +830,7 @@ def preimage(self, f, k=1, check=True): sage: H = Hom(P1, P3) sage: X = P3.subscheme([u - v, 2*u - w, u + t]) sage: f = H([x^2, y^2, x^2 + y^2, x*y]) - sage: X.preimage(f) + sage: X.preimage(f) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: x^2 - y^2, @@ -839,7 +844,7 @@ def preimage(self, f, k=1, check=True): sage: H = Hom(P3, P1) sage: X = P1.subscheme([x - y]) sage: f = H([u^2, v^2]) - sage: X.preimage(f) + sage: X.preimage(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: map must be a morphism @@ -850,7 +855,7 @@ def preimage(self, f, k=1, check=True): sage: H = End(PS) sage: f = H([x^2, x^2, x^2]) sage: X = PS.subscheme([x - y]) - sage: X.preimage(f) + sage: X.preimage(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: map must be a morphism @@ -862,7 +867,7 @@ def preimage(self, f, k=1, check=True): sage: Y = P1.subscheme([u^2 - v^2]) sage: H = End(PS) sage: f = H([x^2, y^2, z^2]) - sage: Y.preimage(f) + sage: Y.preimage(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: subscheme must be in ambient space of codomain @@ -873,7 +878,7 @@ def preimage(self, f, k=1, check=True): sage: Y = P.subscheme([x - y]) sage: H = End(P) sage: f = H([x^2, y^2, z^2]) - sage: Y.preimage(f, k=2) + sage: Y.preimage(f, k=2) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^4 - y^4 @@ -920,7 +925,7 @@ def dual(self): sage: P. = ProjectiveSpace(2, QQ) sage: I = R.ideal(x^2 + y^2 + z^2) sage: X = P.subscheme(I) - sage: X.dual() + sage: X.dual() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: y0^2 + y1^2 + y2^2 @@ -934,7 +939,7 @@ def dual(self): sage: P. = ProjectiveSpace(3, QQ) sage: I = R.ideal(y^2*z^2 - 4*x*z^3 - 4*y^3*w + 18*x*y*z*w - 27*x^2*w^2) sage: X = P.subscheme(I) - sage: X.dual() + sage: X.dual() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: y2^2 - y1*y3, @@ -944,26 +949,27 @@ def dual(self): The singular locus of the quartic surface in the last example is itself supported on a twisted cubic:: - sage: X.Jacobian().radical() + sage: X.Jacobian().radical() # needs sage.libs.singular Ideal (z^2 - 3*y*w, y*z - 9*x*w, y^2 - 3*x*z) of Multivariate Polynomial Ring in x, y, z, w over Rational Field An example over a finite field:: - sage: R = PolynomialRing(GF(61), 'a,b,c') # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(2, R.base_ring()) # optional - sage.rings.finite_rings - sage: X = P.subscheme(R.ideal(a*a + 2*b*b + 3*c*c)) # optional - sage.rings.finite_rings - sage: X.dual() # optional - sage.rings.finite_rings + sage: R = PolynomialRing(GF(61), 'a,b,c') + sage: P. = ProjectiveSpace(2, R.base_ring()) + sage: X = P.subscheme(R.ideal(a*a + 2*b*b + 3*c*c)) + sage: X.dual() # needs sage.libs.singular sage.rings.finite_rings Closed subscheme of Projective Space of dimension 2 over Finite Field of size 61 defined by: y0^2 - 30*y1^2 - 20*y2^2 TESTS:: - sage: R = PolynomialRing(Qp(3), 'a,b,c') # optional - sage.rings.padics - sage: P. = ProjectiveSpace(2, R.base_ring()) # optional - sage.rings.padics - sage: X = P.subscheme(R.ideal(a*a + 2*b*b + 3*c*c)) # optional - sage.rings.padics - sage: X.dual() # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: R = PolynomialRing(Qp(3), 'a,b,c') + sage: P. = ProjectiveSpace(2, R.base_ring()) + sage: X = P.subscheme(R.ideal(a*a + 2*b*b + 3*c*c)) + sage: X.dual() Traceback (most recent call last): ... NotImplementedError: base ring must be QQ or a finite field @@ -1025,17 +1031,17 @@ def degree(self): sage: P. = ProjectiveSpace(QQ, 5) sage: X = P.subscheme([x^7 + x*y*z*t^4 - u^7]) - sage: X.degree() + sage: X.degree() # needs sage.libs.singular 7 - sage: P. = ProjectiveSpace(GF(13), 3) # optional - sage.rings.finite_rings - sage: X = P.subscheme([y^3 - w^3, x + 7*z]) # optional - sage.rings.finite_rings - sage: X.degree() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13), 3) + sage: X = P.subscheme([y^3 - w^3, x + 7*z]) + sage: X.degree() # needs sage.libs.singular 3 sage: P. = ProjectiveSpace(QQ, 4) - sage: C = P.curve([x^7 - y*z^3*w^2*u, w*x^2 - y*u^2, z^3 + y^3]) - sage: C.degree() + sage: C = P.curve([x^7 - y*z^3*w^2*u, w*x^2 - y*u^2, z^3 + y^3]) # needs sage.schemes + sage: C.degree() # needs sage.libs.singular sage.schemes 63 """ P = self.defining_ideal().hilbert_polynomial() @@ -1058,28 +1064,30 @@ def intersection_multiplicity(self, X, P): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - z^2*y^2], P) # optional - sage.rings.finite_rings - sage: D = Curve([y^4*z - x^5 - x^3*z^2], P) # optional - sage.rings.finite_rings - sage: Q1 = P([0,1,0]) # optional - sage.rings.finite_rings - sage: C.intersection_multiplicity(D, Q1) # optional - sage.rings.finite_rings + sage: # needs sage.schemes + sage: P. = ProjectiveSpace(GF(5), 2) + sage: C = Curve([x^4 - z^2*y^2], P) + sage: D = Curve([y^4*z - x^5 - x^3*z^2], P) + sage: Q1 = P([0,1,0]) + sage: C.intersection_multiplicity(D, Q1) # needs sage.libs.singular 4 - sage: Q2 = P([0,0,1]) # optional - sage.rings.finite_rings - sage: C.intersection_multiplicity(D, Q2) # optional - sage.rings.finite_rings + sage: Q2 = P([0,0,1]) + sage: C.intersection_multiplicity(D, Q2) # needs sage.libs.singular 6 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^4 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 3) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 + y^2 - z*w]) # optional - sage.rings.number_field - sage: Y = P.subscheme([y*z - x*w, z - w]) # optional - sage.rings.number_field - sage: Q1 = P([b^2,1,0,0]) # optional - sage.rings.number_field - sage: X.intersection_multiplicity(Y, Q1) # optional - sage.rings.number_field + sage: K. = NumberField(a^4 + 1) + sage: P. = ProjectiveSpace(K, 3) + sage: X = P.subscheme([x^2 + y^2 - z*w]) + sage: Y = P.subscheme([y*z - x*w, z - w]) + sage: Q1 = P([b^2,1,0,0]) + sage: X.intersection_multiplicity(Y, Q1) # needs sage.libs.singular 1 - sage: Q2 = P([1/2*b^3 - 1/2*b, 1/2*b^3 - 1/2*b, 1, 1]) # optional - sage.rings.number_field - sage: X.intersection_multiplicity(Y, Q2) # optional - sage.rings.number_field + sage: Q2 = P([1/2*b^3 - 1/2*b, 1/2*b^3 - 1/2*b, 1, 1]) + sage: X.intersection_multiplicity(Y, Q2) # needs sage.libs.singular 1 :: @@ -1088,7 +1096,7 @@ def intersection_multiplicity(self, X, P): sage: X = P.subscheme([x^2 - z^2, y^3 - w*x^2]) sage: Y = P.subscheme([w^2 - 2*x*y + z^2, y^2 - w^2]) sage: Q = P([1,1,-1,1]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: the intersection of this subscheme and (=Closed subscheme of Affine Space of dimension 3 @@ -1098,7 +1106,7 @@ def intersection_multiplicity(self, X, P): try: self.ambient_space()(P) except TypeError: - raise TypeError("(=%s) must be a point in the ambient space of this subscheme and (=%s)"%(P,X)) + raise TypeError("(=%s) must be a point in the ambient space of this subscheme and (=%s)" % (P,X)) # find an affine chart of the ambient space of this curve that contains P n = self.ambient_space().dimension_relative() for i in range(n + 1): @@ -1129,29 +1137,30 @@ def multiplicity(self, P): sage: P. = ProjectiveSpace(QQ, 4) sage: X = P.subscheme([y^2 - x*t, w^7 - t*w*x^5 - z^7]) sage: Q1 = P([0,0,1,1,1]) - sage: X.multiplicity(Q1) + sage: X.multiplicity(Q1) # needs sage.libs.singular 1 sage: Q2 = P([1,0,0,0,0]) - sage: X.multiplicity(Q2) + sage: X.multiplicity(Q2) # needs sage.libs.singular 3 sage: Q3 = P([0,0,0,0,1]) - sage: X.multiplicity(Q3) + sage: X.multiplicity(Q3) # needs sage.libs.singular 7 :: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(CC, 3) sage: X = P.subscheme([z^5*x^2*w - y^8]) sage: Q = P([2,0,0,1]) - sage: X.multiplicity(Q) + sage: X.multiplicity(Q) # needs sage.libs.singular 5 :: - sage: P. = ProjectiveSpace(GF(29), 3) # optional - sage.rings.finite_rings - sage: C = Curve([y^17 - x^5*w^4*z^8, x*y - z^2], P) # optional - sage.rings.finite_rings - sage: Q = P([3,0,0,1]) # optional - sage.rings.finite_rings - sage: C.multiplicity(Q) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(29), 3) + sage: C = Curve([y^17 - x^5*w^4*z^8, x*y - z^2], P) # needs sage.schemes + sage: Q = P([3,0,0,1]) + sage: C.multiplicity(Q) # needs sage.libs.singular sage.schemes 8 """ if self.base_ring() not in Fields(): @@ -1193,8 +1202,7 @@ def veronese_embedding(self, d, CS=None, order='lex'): sage: P. = ProjectiveSpace(QQ, 2) sage: L = P.subscheme([y - x]) - sage: v = L.veronese_embedding(2) - sage: v + sage: v = L.veronese_embedding(2); v # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: -x + y @@ -1206,17 +1214,17 @@ def veronese_embedding(self, d, CS=None, order='lex'): x0 - x3 Defn: Defined on coordinates by sending (x : y : z) to (x^2 : x*y : x*z : y^2 : y*z : z^2) - sage: v.codomain().degree() + sage: v.codomain().degree() # needs sage.libs.singular 2 sage: C = P.subscheme([y*z - x^2]) - sage: C.veronese_embedding(2).codomain().degree() + sage: C.veronese_embedding(2).codomain().degree() # needs sage.libs.singular 4 twisted cubic:: sage: P. = ProjectiveSpace(QQ, 1) sage: Q. = ProjectiveSpace(QQ, 3) - sage: P.subscheme([]).veronese_embedding(3, Q) + sage: P.subscheme([]).veronese_embedding(3, Q) # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: (no polynomials) @@ -1298,20 +1306,21 @@ def Chow_form(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 3) # optional - sage.rings.finite_rings - sage: X = P.subscheme([x3 + x1, x2 - x0, x2 - x3]) # optional - sage.rings.finite_rings - sage: X.Chow_form() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 3) + sage: X = P.subscheme([x3 + x1, x2 - x0, x2 - x3]) + sage: X.Chow_form() # needs sage.libs.singular t0 - t1 + t2 + t3 :: sage: P. = ProjectiveSpace(QQ, 3) sage: X = P.subscheme([x3^2 - 101*x1^2 - 3*x2*x0]) - sage: X.Chow_form() + sage: X.Chow_form() # needs sage.libs.singular t0^2 - 101*t2^2 - 3*t1*t3 :: + sage: # needs sage.libs.singular sage: P. = ProjectiveSpace(QQ, 3) sage: X = P.subscheme([x0*x2 - x1^2, x0*x3 - x1*x2, x1*x3 - x2^2]) sage: Ch = X.Chow_form(); Ch @@ -1393,7 +1402,7 @@ def Chow_form(self): # polynomial ring in just the plucker coordinates T2 = PolynomialRing(R.base_ring(), tvars) - alp = T.hom(tvars + (N*(d+1) +N)*[0], T2) + alp = T.hom(tvars + (N*(d+1) + N)*[0], T2) # get the degrees of the reduced generators of CH degs = [u.degree() for u in reduced] mind = max(degs) diff --git a/src/sage/schemes/riemann_surfaces/riemann_surface.py b/src/sage/schemes/riemann_surfaces/riemann_surface.py index 917de00d7b0..14599021c5d 100644 --- a/src/sage/schemes/riemann_surfaces/riemann_surface.py +++ b/src/sage/schemes/riemann_surfaces/riemann_surface.py @@ -1,3 +1,4 @@ +# sage.doctest: needs scipy sage.graphs sage.groups r""" Riemann matrices and endomorphism rings of algebraic Riemann surfaces @@ -124,6 +125,7 @@ from sage.misc.cachefunc import cached_method from sage.misc.flatten import flatten from sage.misc.functional import numerical_approx +from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod from sage.modules.free_module import VectorSpace from sage.modules.free_module_integer import IntegerLattice @@ -134,12 +136,13 @@ from sage.rings.infinity import Infinity from sage.rings.integer_ring import ZZ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.qqbar import number_field_elements_from_algebraics from sage.rings.rational_field import QQ from sage.rings.real_mpfr import RealField from sage.schemes.curves.constructor import Curve import sage.libs.mpmath.all as mpall +lazy_import('sage.rings.qqbar', 'number_field_elements_from_algebraics') + def voronoi_ghost(cpoints, n=6, CC=CDF): r""" @@ -2372,7 +2375,8 @@ def period_matrix(self): easier to test.:: sage: parent(M) - Full MatrixSpace of 3 by 6 dense matrices over Complex Field with 30 bits of precision + Full MatrixSpace of 3 by 6 dense matrices + over Complex Field with 30 bits of precision sage: M.rank() 3 @@ -2438,7 +2442,7 @@ def plot_paths(self): sage: from sage.schemes.riemann_surfaces.riemann_surface import RiemannSurface sage: R. = QQ[] sage: S = RiemannSurface(y^2 - x^3 - x) - sage: S.plot_paths() + sage: S.plot_paths() # needs sage.plot Graphics object consisting of 2 graphics primitives """ from sage.plot.point import point2d @@ -2474,8 +2478,8 @@ def plot_paths3d(self, thickness=0.01): sage: from sage.schemes.riemann_surfaces.riemann_surface import RiemannSurface sage: R. = QQ[] - sage: S = RiemannSurface(y^2-x^3-x) - sage: S.plot_paths3d() + sage: S = RiemannSurface(y^2 - x^3 - x) + sage: S.plot_paths3d() # needs sage.plot Graphics3d Object """ from sage.plot.graphics import Graphics @@ -2955,7 +2959,7 @@ def _integrate_differentials_iteratively( sage: s = sign(w_start) sage: u_edge = ((z_start, w_start), z_end) sage: J, _ = S._integrate_differentials_iteratively(u_edge) - sage: bool(J[0]+s*S._RR(sqrt(pi)*gamma(5/4)/gamma(3/4)/2)<1e-10) + sage: bool(J[0] + s*S._RR(sqrt(pi)*gamma(5/4)/gamma(3/4)/2) < 1e-10) # needs sage.symbolic True .. NOTE:: diff --git a/src/sage/schemes/toric/all.py b/src/sage/schemes/toric/all.py index 9d7c83954a7..71ad52ef5c6 100644 --- a/src/sage/schemes/toric/all.py +++ b/src/sage/schemes/toric/all.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs from sage.misc.lazy_import import lazy_import lazy_import('sage.schemes.toric.weierstrass', 'WeierstrassForm') diff --git a/src/sage/schemes/toric/chow_group.py b/src/sage/schemes/toric/chow_group.py index 8c835df37d2..ae3d245c744 100644 --- a/src/sage/schemes/toric/chow_group.py +++ b/src/sage/schemes/toric/chow_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs # -*- coding: utf-8 -*- r""" The Chow group of a toric variety @@ -862,7 +863,7 @@ def degree(self, k=None): sage: points = [[1,0,0], [0,1,0], [0,0,1], [1,-1,1], [-1,0,-1]] sage: l = LatticePolytope(points) - sage: l.show3d() + sage: l.show3d() # needs sage.plot sage: X = ToricVariety(FaceFan(l)) sage: A = X.Chow_group() sage: A.degree(2) diff --git a/src/sage/schemes/toric/divisor.py b/src/sage/schemes/toric/divisor.py index c71ca05eede..3fbdae4cdb5 100644 --- a/src/sage/schemes/toric/divisor.py +++ b/src/sage/schemes/toric/divisor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Toric divisors and divisor classes diff --git a/src/sage/schemes/toric/divisor_class.pyx b/src/sage/schemes/toric/divisor_class.pyx index d0c497d8a94..5a92fe5b38d 100644 --- a/src/sage/schemes/toric/divisor_class.pyx +++ b/src/sage/schemes/toric/divisor_class.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Toric rational divisor classes diff --git a/src/sage/schemes/toric/fano_variety.py b/src/sage/schemes/toric/fano_variety.py index 06e942c5336..a1405c966ec 100644 --- a/src/sage/schemes/toric/fano_variety.py +++ b/src/sage/schemes/toric/fano_variety.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Fano toric varieties @@ -1304,9 +1305,9 @@ def __init__(self, P_Delta, monomial_points=None, coefficient_names=None, Check that finite fields are handled correctly :trac:`14899`:: - sage: F = GF(5^2, "a") # optional - sage.rings.finite_rings - sage: X = P1xP1.change_ring(F) # optional - sage.rings.finite_rings - sage: X.anticanonical_hypersurface(monomial_points="all", # optional - sage.rings.finite_rings + sage: F = GF(5^2, "a") # needs sage.rings.finite_rings + sage: X = P1xP1.change_ring(F) # needs sage.rings.finite_rings + sage: X.anticanonical_hypersurface(monomial_points="all", # needs sage.rings.finite_rings ....: coefficients=[1]*X.Delta().npoints()) Closed subscheme of 2-d CPR-Fano toric variety covered by 4 affine patches defined by: diff --git a/src/sage/schemes/toric/homset.py b/src/sage/schemes/toric/homset.py index 4470303d8d4..bd535edf932 100644 --- a/src/sage/schemes/toric/homset.py +++ b/src/sage/schemes/toric/homset.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Set of homomorphisms between two toric varieties @@ -324,7 +325,7 @@ def is_finite(self): sage: P2 = toric_varieties.P2() sage: P2.point_set().is_finite() False - sage: P2.change_ring(GF(7)).point_set().is_finite() # optional - sage.rings.finite_rings + sage: P2.change_ring(GF(7)).point_set().is_finite() True """ variety = self.codomain() @@ -347,11 +348,11 @@ def _naive_enumerator(self, ring=None): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: next(iter(point_set._naive_enumerator())) # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: next(iter(point_set._naive_enumerator())) (0, 0, 1) - sage: next(iter(point_set)) # optional - sage.rings.finite_rings + sage: next(iter(point_set)) [0 : 0 : 1] """ from sage.schemes.toric.points import NaiveFinitePointEnumerator @@ -378,11 +379,11 @@ def _finite_field_enumerator(self, finite_field=None): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: next(iter(point_set._finite_field_enumerator())) # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: next(iter(point_set._finite_field_enumerator())) (0, 0, 1) - sage: next(iter(point_set)) # optional - sage.rings.finite_rings + sage: next(iter(point_set)) [0 : 0 : 1] """ from sage.schemes.toric.points import FiniteFieldPointEnumerator @@ -404,9 +405,9 @@ def _enumerator(self): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: point_set._enumerator() # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: point_set._enumerator() """ ring = self.domain().base_ring() @@ -448,11 +449,11 @@ class SchemeHomset_points_toric_field(SchemeHomset_points_toric_base): unity:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_field=GF(7)) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: point_set.cardinality() # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_field=GF(7)) + sage: point_set = X.point_set() + sage: point_set.cardinality() 21 - sage: sorted(X.point_set().list()) # optional - sage.rings.finite_rings + sage: sorted(X.point_set().list()) [[0 : 0 : 1], [0 : 1 : 0], [0 : 1 : 1], [0 : 1 : 3], [1 : 0 : 0], [1 : 0 : 1], [1 : 0 : 3], [1 : 1 : 0], [1 : 1 : 1], [1 : 1 : 2], [1 : 1 : 3], [1 : 1 : 4], @@ -466,9 +467,9 @@ class SchemeHomset_points_toric_field(SchemeHomset_points_toric_base): on the fiber:: sage: fan = Fan([Cone([(1,0), (1,1)]), Cone([(1,1), (0,1)])]) - sage: blowup_plane = ToricVariety(fan, base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = blowup_plane.point_set() # optional - sage.rings.finite_rings - sage: sorted(point_set.list()) # optional - sage.rings.finite_rings + sage: blowup_plane = ToricVariety(fan, base_ring=GF(3)) + sage: point_set = blowup_plane.point_set() + sage: sorted(point_set.list()) [[0 : 1 : 0], [0 : 1 : 1], [0 : 1 : 2], [1 : 0 : 0], [1 : 0 : 1], [1 : 0 : 2], [1 : 1 : 0], [1 : 1 : 1], [1 : 1 : 2], @@ -477,8 +478,8 @@ class SchemeHomset_points_toric_field(SchemeHomset_points_toric_base): Toric varieties with torus factors (that is, where the fan is not full-dimensional) also work:: - sage: F_times_Fstar = ToricVariety(Fan([Cone([(1,0)])]), base_field=GF(3)) # optional - sage.rings.finite_rings - sage: sorted(F_times_Fstar.point_set().list()) # optional - sage.rings.finite_rings + sage: F_times_Fstar = ToricVariety(Fan([Cone([(1,0)])]), base_field=GF(3)) + sage: sorted(F_times_Fstar.point_set().list()) [[0 : 1], [0 : 2], [1 : 1], [1 : 2], [2 : 1], [2 : 2]] TESTS:: @@ -500,29 +501,29 @@ def cardinality(self): sage: o = lattice_polytope.cross_polytope(3) sage: V = ToricVariety(FaceFan(o)) - sage: V.change_ring(GF(2)).point_set().cardinality() # optional - sage.rings.finite_rings + sage: V.change_ring(GF(2)).point_set().cardinality() 27 - sage: V.change_ring(GF(8, "a")).point_set().cardinality() # optional - sage.rings.finite_rings + sage: V.change_ring(GF(8, "a")).point_set().cardinality() # needs sage.rings.finite_rings 729 - sage: V.change_ring(GF(101)).point_set().cardinality() # optional - sage.rings.finite_rings + sage: V.change_ring(GF(101)).point_set().cardinality() 1061208 For non-smooth varieties over finite fields, the homogeneous rescalings are solved. This is somewhat slower:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_field=GF(7)) # optional - sage.rings.finite_rings - sage: X.point_set().cardinality() # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_field=GF(7)) + sage: X.point_set().cardinality() 21 Fulton's formula does not apply since the variety is not smooth. And, indeed, naive application gives a different result:: - sage: q = X.base_ring().order() # optional - sage.rings.finite_rings - sage: n = X.dimension() # optional - sage.rings.finite_rings - sage: d = map(len, fan().cones()) # optional - sage.rings.finite_rings - sage: sum(dk * (q-1)**(n-k) for k, dk in enumerate(d)) # optional - sage.rings.finite_rings + sage: q = X.base_ring().order() + sage: n = X.dimension() + sage: d = map(len, fan().cones()) + sage: sum(dk * (q-1)**(n-k) for k, dk in enumerate(d)) 57 Over infinite fields the number of points is not very tricky:: @@ -571,11 +572,11 @@ def __iter__(self): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: next(iter(point_set.__iter__())) # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: next(iter(point_set.__iter__())) [0 : 0 : 1] - sage: next(iter(point_set)) # syntactic sugar # optional - sage.rings.finite_rings + sage: next(iter(point_set)) # syntactic sugar [0 : 0 : 1] """ for pt in self._enumerator(): @@ -595,9 +596,9 @@ def _enumerator(self): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: point_set._enumerator() # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: point_set._enumerator() """ ambient = super()._enumerator() @@ -620,11 +621,11 @@ def __iter__(self): EXAMPLES:: - sage: P2. = toric_varieties.P2(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) # optional - sage.rings.finite_rings - sage: list(cubic.point_set()) # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(5)) + sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) + sage: list(cubic.point_set()) [[0 : 1 : 4], [1 : 0 : 4], [1 : 4 : 0], [1 : 1 : 2], [1 : 2 : 1], [1 : 3 : 3]] - sage: cubic.point_set().cardinality() # optional - sage.rings.finite_rings + sage: cubic.point_set().cardinality() 6 """ for p in self._enumerator(): @@ -640,11 +641,11 @@ def cardinality(self): EXAMPLES:: - sage: P2. = toric_varieties.P2(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) # optional - sage.rings.finite_rings - sage: list(cubic.point_set()) # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(5)) + sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) + sage: list(cubic.point_set()) [[0 : 1 : 4], [1 : 0 : 4], [1 : 4 : 0], [1 : 1 : 2], [1 : 2 : 1], [1 : 3 : 3]] - sage: cubic.point_set().cardinality() # optional - sage.rings.finite_rings + sage: cubic.point_set().cardinality() 6 """ try: diff --git a/src/sage/schemes/toric/ideal.py b/src/sage/schemes/toric/ideal.py index d2f0b094f5a..bf9eb94e331 100644 --- a/src/sage/schemes/toric/ideal.py +++ b/src/sage/schemes/toric/ideal.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Toric ideals @@ -217,7 +218,7 @@ def __init__(self, A, sage: ToricIdeal(A) Ideal (-z1^2 + z0*z2) of Multivariate Polynomial Ring in z0, z1, z2 over Rational Field - sage: ToricIdeal(A, names='x', base_ring=GF(101)) # optional - sage.rings.finite_rings + sage: ToricIdeal(A, names='x', base_ring=GF(101)) Ideal (-x1^2 + x0*x2) of Multivariate Polynomial Ring in x0, x1, x2 over Finite Field of size 101 sage: ToricIdeal(A, names='x', base_ring=FractionField(QQ['t'])) diff --git a/src/sage/schemes/toric/library.py b/src/sage/schemes/toric/library.py index 309b62e05c1..d70a3e95d5d 100644 --- a/src/sage/schemes/toric/library.py +++ b/src/sage/schemes/toric/library.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Library of toric varieties @@ -1330,7 +1331,7 @@ def torus(self, n, names='z+', base_ring=QQ): in 3-d lattice N sage: T3.gens() (z0, z1, z2) - sage: sorted(T3.change_ring(GF(3)).point_set().list()) # optional - sage.rings.finite_rings + sage: sorted(T3.change_ring(GF(3)).point_set().list()) [[1 : 1 : 1], [1 : 1 : 2], [1 : 2 : 1], [1 : 2 : 2], [2 : 1 : 1], [2 : 1 : 2], [2 : 2 : 1], [2 : 2 : 2]] """ diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py index 9a9f87a9b5e..1c8944b6dfc 100644 --- a/src/sage/schemes/toric/morphism.py +++ b/src/sage/schemes/toric/morphism.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Morphisms of toric varieties diff --git a/src/sage/schemes/toric/points.py b/src/sage/schemes/toric/points.py index 8a70350a30e..f9563bd0acc 100644 --- a/src/sage/schemes/toric/points.py +++ b/src/sage/schemes/toric/points.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs """ Enumerate points of a toric variety @@ -13,13 +14,13 @@ EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P2.point_set() # optional - sage.rings.finite_rings - sage: point_set.cardinality() # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(3)) + sage: point_set = P2.point_set() + sage: point_set.cardinality() 13 - sage: next(iter(point_set)) # optional - sage.rings.finite_rings + sage: next(iter(point_set)) [0 : 0 : 1] - sage: list(point_set)[0:5] # optional - sage.rings.finite_rings + sage: list(point_set)[0:5] [[0 : 0 : 1], [1 : 0 : 0], [0 : 1 : 0], [0 : 1 : 1], [0 : 1 : 2]] """ @@ -122,8 +123,8 @@ def __init__(self, fan, ring): sage: from sage.schemes.toric.points import NaiveFinitePointEnumerator sage: fan = toric_varieties.P2().fan() - sage: n = NaiveFinitePointEnumerator(fan, GF(3)) # optional - sage.rings.finite_rings - sage: next(iter(n)) # optional - sage.rings.finite_rings + sage: n = NaiveFinitePointEnumerator(fan, GF(3)) + sage: next(iter(n)) (0, 0, 1) """ assert ring.is_finite() @@ -144,8 +145,8 @@ def rays(self): sage: fan.rays() Empty collection in 2-d lattice N - sage: n = NaiveFinitePointEnumerator(fan, GF(3)) # optional - sage.rings.finite_rings - sage: n.rays() # optional - sage.rings.finite_rings + sage: n = NaiveFinitePointEnumerator(fan, GF(3)) + sage: n.rays() N(1, 0), N(0, 1) in 2-d lattice N @@ -159,9 +160,9 @@ def units(self): EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: ne = P2.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ne.units() # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(5)) + sage: ne = P2.point_set()._naive_enumerator() + sage: ne.units() (1, 2, 3, 4) """ return tuple(x for x in self.ring if x != 0) @@ -182,13 +183,13 @@ def roots(self, n): EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: ne = P2.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ne.roots(2) # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(5)) + sage: ne = P2.point_set()._naive_enumerator() + sage: ne.roots(2) (1, 4) - sage: ne.roots(3) # optional - sage.rings.finite_rings + sage: ne.roots(3) (1,) - sage: ne.roots(4) # optional - sage.rings.finite_rings + sage: ne.roots(4) (1, 2, 3, 4) """ return tuple(x for x in self.ring if x**n == self.ring.one()) @@ -205,11 +206,11 @@ def _Chow_group_free(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X.Chow_group().degree(1) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: X.Chow_group().degree(1) C3 x Z - sage: enum = X.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: enum._Chow_group_free() # optional - sage.rings.finite_rings + sage: enum = X.point_set()._naive_enumerator() + sage: enum._Chow_group_free() ((1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6)) """ units = self.units() @@ -233,11 +234,11 @@ def _Chow_group_torsion(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X.Chow_group().degree(1) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: X.Chow_group().degree(1) C3 x Z - sage: enum = X.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: enum._Chow_group_torsion() # optional - sage.rings.finite_rings + sage: enum = X.point_set()._naive_enumerator() + sage: enum._Chow_group_torsion() ((1, 2, 4), (1, 4, 2)) """ if self.fan.is_smooth(): @@ -266,19 +267,19 @@ def rescalings(self): EXAMPLES:: - sage: P2_123 = toric_varieties.P2_123(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: ni = P2_123.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ni.rescalings() # optional - sage.rings.finite_rings + sage: P2_123 = toric_varieties.P2_123(base_ring=GF(5)) + sage: ni = P2_123.point_set()._naive_enumerator() + sage: ni.rescalings() ((1, 1, 1), (1, 4, 4), (4, 2, 3), (4, 3, 2)) - sage: dP8 = toric_varieties.dP8(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: ni = dP8.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ni.rescalings() # optional - sage.rings.finite_rings + sage: dP8 = toric_varieties.dP8(base_ring=GF(3)) + sage: ni = dP8.point_set()._naive_enumerator() + sage: ni.rescalings() ((1, 1, 1, 1), (1, 2, 2, 2), (2, 1, 2, 1), (2, 2, 1, 2)) - sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: ni = P1xP1.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ni.rescalings() # optional - sage.rings.finite_rings + sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(3)) + sage: ni = P1xP1.point_set()._naive_enumerator() + sage: ni.rescalings() ((1, 1, 1, 1), (1, 1, 2, 2), (2, 2, 1, 1), (2, 2, 2, 2)) """ free = self._Chow_group_free() @@ -302,15 +303,15 @@ def orbit(self, point): EXAMPLES:: - sage: P2_123 = toric_varieties.P2_123(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: ne = P2_123.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: sorted(ne.orbit([1, 0, 0])) # optional - sage.rings.finite_rings + sage: P2_123 = toric_varieties.P2_123(base_ring=GF(7)) + sage: ne = P2_123.point_set()._naive_enumerator() + sage: sorted(ne.orbit([1, 0, 0])) [(1, 0, 0), (2, 0, 0), (4, 0, 0)] - sage: sorted(ne.orbit([0, 1, 0])) # optional - sage.rings.finite_rings + sage: sorted(ne.orbit([0, 1, 0])) [(0, 1, 0), (0, 6, 0)] - sage: sorted(ne.orbit([0, 0, 1])) # optional - sage.rings.finite_rings + sage: sorted(ne.orbit([0, 0, 1])) [(0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 0, 5), (0, 0, 6)] - sage: sorted(ne.orbit([1, 1, 0])) # optional - sage.rings.finite_rings + sage: sorted(ne.orbit([1, 1, 0])) [(1, 1, 0), (1, 6, 0), (2, 1, 0), (2, 6, 0), (4, 1, 0), (4, 6, 0)] """ result = set() @@ -330,9 +331,9 @@ def cone_iter(self): EXAMPLES:: - sage: dP6 = toric_varieties.dP6(base_ring=GF(11)) # optional - sage.rings.finite_rings - sage: ne = dP6.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: for cone in ne.cone_iter(): # optional - sage.rings.finite_rings + sage: dP6 = toric_varieties.dP6(base_ring=GF(11)) + sage: ne = dP6.point_set()._naive_enumerator() + sage: for cone in ne.cone_iter(): ....: print(cone.ambient_ray_indices()) (0, 1) (1, 2) @@ -363,24 +364,24 @@ def coordinate_iter(self): EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(2)) # optional - sage.rings.finite_rings - sage: ni = P2.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni.coordinate_iter()) # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(2)) + sage: ni = P2.point_set()._naive_enumerator() + sage: list(ni.coordinate_iter()) [(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)] - sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(2)) # optional - sage.rings.finite_rings - sage: ni = P1xP1.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni.coordinate_iter()) # optional - sage.rings.finite_rings + sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(2)) + sage: ni = P1xP1.point_set()._naive_enumerator() + sage: list(ni.coordinate_iter()) [(0, 1, 0, 1), (1, 0, 0, 1), (1, 0, 1, 0), (0, 1, 1, 0), (0, 1, 1, 1), (1, 0, 1, 1), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)] TESTS:: - sage: V = ToricVariety(Fan([Cone([(1,1)])]), base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: ni = V.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni.coordinate_iter()) # optional - sage.rings.finite_rings + sage: V = ToricVariety(Fan([Cone([(1,1)])]), base_ring=GF(3)) + sage: ni = V.point_set()._naive_enumerator() + sage: list(ni.coordinate_iter()) [(0, 1), (0, 2), (1, 1), (1, 2), (2, 1), (2, 2)] """ units = [x for x in self.ring if x != 0] @@ -405,15 +406,15 @@ def __iter__(self): EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(2)) # optional - sage.rings.finite_rings - sage: ni = P2.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni) # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(2)) + sage: ni = P2.point_set()._naive_enumerator() + sage: list(ni) [(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)] - sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: ni = P1xP1.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni) # optional - sage.rings.finite_rings + sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(3)) + sage: ni = P1xP1.point_set()._naive_enumerator() + sage: list(ni) [(0, 1, 0, 1), (1, 0, 0, 1), (1, 0, 1, 0), (0, 1, 1, 0), (0, 1, 1, 1), (0, 1, 1, 2), (1, 0, 1, 1), (1, 0, 1, 2), (1, 1, 0, 1), (1, 2, 0, 1), (1, 1, 1, 0), (1, 2, 1, 0), @@ -438,9 +439,9 @@ def multiplicative_generator(self): EXAMPLES:: - sage: point_set = toric_varieties.P2(base_ring=GF(5^2, 'a')).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: ffe.multiplicative_generator() # optional - sage.rings.finite_rings + sage: point_set = toric_varieties.P2(base_ring=GF(5^2, 'a')).point_set() # needs sage.rings.finite_rings + sage: ffe = point_set._finite_field_enumerator() # needs sage.rings.finite_rings + sage: ffe.multiplicative_generator() # needs sage.rings.finite_rings a """ return self.ring.multiplicative_generator() @@ -462,18 +463,18 @@ def root_generator(self, n): EXAMPLES:: - sage: point_set = toric_varieties.P2(base_ring=GF(5)).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: ffe.root_generator(2) # optional - sage.rings.finite_rings + sage: point_set = toric_varieties.P2(base_ring=GF(5)).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: ffe.root_generator(2) 4 - sage: ffe.root_generator(3) # optional - sage.rings.finite_rings + sage: ffe.root_generator(3) 1 - sage: ffe.root_generator(4) # optional - sage.rings.finite_rings + sage: ffe.root_generator(4) 2 TESTS:: - sage: for p in primes(10): # optional - sage.rings.finite_rings + sage: for p in primes(10): # needs sage.rings.finite_rings ....: for k in range(1, 5): ....: F = GF(p^k, 'a') ....: N = F.cardinality() - 1 @@ -499,13 +500,13 @@ def _Chow_group_free_generators(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X.Chow_group().degree(1) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: X.Chow_group().degree(1) C3 x Z - sage: enum = X.point_set()._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: enum._Chow_group_free() # optional - sage.rings.finite_rings + sage: enum = X.point_set()._finite_field_enumerator() + sage: enum._Chow_group_free() ((1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6)) - sage: enum._Chow_group_free_generators() # optional - sage.rings.finite_rings + sage: enum._Chow_group_free_generators() ((3, 3, 3),) """ result = [] @@ -528,13 +529,13 @@ def _Chow_group_torsion_generators(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X.Chow_group().degree(1) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: X.Chow_group().degree(1) C3 x Z - sage: enum = X.point_set()._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: enum._Chow_group_torsion() # optional - sage.rings.finite_rings + sage: enum = X.point_set()._finite_field_enumerator() + sage: enum._Chow_group_torsion() ((1, 2, 4), (1, 4, 2)) - sage: enum._Chow_group_torsion_generators() # optional - sage.rings.finite_rings + sage: enum._Chow_group_torsion_generators() ((1, 2, 4),) """ if self.fan.is_smooth(): @@ -568,19 +569,20 @@ def log(self, z): EXAMPLES:: - sage: F. = GF(5^2) # optional - sage.rings.finite_rings - sage: point_set = toric_varieties.P2_123(base_ring=F).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: z = tuple(a^i for i in range(25)); z # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(5^2) + sage: point_set = toric_varieties.P2_123(base_ring=F).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: z = tuple(a^i for i in range(25)); z (1, a, a + 3, 4*a + 3, 2*a + 2, 4*a + 1, 2, 2*a, 2*a + 1, 3*a + 1, 4*a + 4, 3*a + 2, 4, 4*a, 4*a + 2, a + 2, 3*a + 3, a + 4, 3, 3*a, 3*a + 4, 2*a + 4, a + 1, 2*a + 3, 1) - sage: ffe.log(z) # optional - sage.rings.finite_rings + sage: ffe.log(z) (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0) - sage: ffe.exp(ffe.log(z)) == z # optional - sage.rings.finite_rings + sage: ffe.exp(ffe.log(z)) == z True - sage: ffe.log(ffe.exp(range(24))) == tuple(range(24)) # optional - sage.rings.finite_rings + sage: ffe.log(ffe.exp(range(24))) == tuple(range(24)) True """ base = self.multiplicative_generator() @@ -601,15 +603,16 @@ def exp(self, powers): EXAMPLES:: - sage: F. = GF(5^2) # optional - sage.rings.finite_rings - sage: point_set = toric_varieties.P2_123(base_ring=F).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: powers = list(range(24)) # optional - sage.rings.finite_rings - sage: ffe.exp(powers) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(5^2) + sage: point_set = toric_varieties.P2_123(base_ring=F).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: powers = list(range(24)) + sage: ffe.exp(powers) (1, a, a + 3, 4*a + 3, 2*a + 2, 4*a + 1, 2, 2*a, 2*a + 1, 3*a + 1, 4*a + 4, 3*a + 2, 4, 4*a, 4*a + 2, a + 2, 3*a + 3, a + 4, 3, 3*a, 3*a + 4, 2*a + 4, a + 1, 2*a + 3) - sage: ffe.log(ffe.exp(powers)) == tuple(powers) # optional - sage.rings.finite_rings + sage: ffe.log(ffe.exp(powers)) == tuple(powers) True """ base = self.multiplicative_generator() @@ -627,13 +630,13 @@ def rescaling_log_generators(self): EXAMPLES:: - sage: point_set = toric_varieties.P2_123(base_ring=GF(5)).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: ffe.rescalings() # optional - sage.rings.finite_rings + sage: point_set = toric_varieties.P2_123(base_ring=GF(5)).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: ffe.rescalings() ((1, 1, 1), (1, 4, 4), (4, 2, 3), (4, 3, 2)) - sage: list(map(ffe.log, ffe.rescalings())) # optional - sage.rings.finite_rings + sage: list(map(ffe.log, ffe.rescalings())) [(0, 0, 0), (0, 2, 2), (2, 1, 3), (2, 3, 1)] - sage: ffe.rescaling_log_generators() # optional - sage.rings.finite_rings + sage: ffe.rescaling_log_generators() ((2, 3, 1),) """ free = self._Chow_group_free_generators() @@ -655,22 +658,22 @@ def cone_points_iter(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: cpi = ffe.cone_points_iter() # optional - sage.rings.finite_rings - sage: cone, nonzero_points, cokernel = list(cpi)[5] # optional - sage.rings.finite_rings - sage: cone # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: point_set = X.point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: cpi = ffe.cone_points_iter() + sage: cone, nonzero_points, cokernel = list(cpi)[5] + sage: cone 1-d cone of Rational polyhedral fan in 2-d lattice N - sage: cone.ambient_ray_indices() # optional - sage.rings.finite_rings + sage: cone.ambient_ray_indices() (2,) - sage: nonzero_points # optional - sage.rings.finite_rings + sage: nonzero_points [0, 1] - sage: cokernel # optional - sage.rings.finite_rings + sage: cokernel Finitely generated module V/W over Integer Ring with invariants (2) - sage: list(cokernel) # optional - sage.rings.finite_rings + sage: list(cokernel) [(0), (1)] - sage: [p.lift() for p in cokernel] # optional - sage.rings.finite_rings + sage: [p.lift() for p in cokernel] [(0, 0), (0, 1)] """ from sage.matrix.constructor import matrix, block_matrix, identity_matrix @@ -704,22 +707,22 @@ def __iter__(self): EXAMPLES:: - sage: point_set = toric_varieties.P2(base_ring=GF(2)).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: list(ffe) # optional - sage.rings.finite_rings + sage: point_set = toric_varieties.P2(base_ring=GF(2)).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: list(ffe) [(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)] sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: list(ffe) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: point_set = X.point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: list(ffe) [(1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 1, 1), (0, 1, 3), (1, 0, 1), (1, 0, 3), (1, 1, 0), (1, 3, 0), (1, 1, 1), (1, 1, 3), (1, 1, 2), (1, 1, 6), (1, 1, 4), (1, 1, 5), (1, 3, 2), (1, 3, 6), (1, 3, 4), (1, 3, 5), (1, 3, 1), (1, 3, 3)] - sage: set(point_set._naive_enumerator()) == set(ffe) # optional - sage.rings.finite_rings + sage: set(point_set._naive_enumerator()) == set(ffe) True """ nrays = len(self.rays()) @@ -741,10 +744,10 @@ def cardinality(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: ffe.cardinality() # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: point_set = X.point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: ffe.cardinality() 21 """ n = 0 @@ -826,14 +829,14 @@ def inhomogeneous_equations(self, ring, nonzero_coordinates, cokernel): EXAMPLES:: sage: R. = QQ[] - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: cone, nonzero_coordinates, cokernel = list(ffe.ambient.cone_points_iter())[5] # optional - sage.rings.finite_rings - sage: cone.ambient_ray_indices(), nonzero_coordinates # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: cone, nonzero_coordinates, cokernel = list(ffe.ambient.cone_points_iter())[5] + sage: cone.ambient_ray_indices(), nonzero_coordinates ((2,), [0, 1]) - sage: ffe.inhomogeneous_equations(R, nonzero_coordinates, cokernel) # optional - sage.rings.finite_rings + sage: ffe.inhomogeneous_equations(R, nonzero_coordinates, cokernel) [2*s^3 + 1, s^2] """ nrays = len(self.ambient.rays()) @@ -867,14 +870,14 @@ def solutions_serial(self, inhomogeneous_equations, log_range): EXAMPLES:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme(1) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: ffe.solutions_serial([s^2 - 1, s^6 - s^2], [range(6)]) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme(1) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: ffe.solutions_serial([s^2 - 1, s^6 - s^2], [range(6)]) - sage: list(_) # optional - sage.rings.finite_rings + sage: list(_) [(0,), (3,)] """ from itertools import product @@ -895,14 +898,14 @@ def solutions(self, inhomogeneous_equations, log_range): EXAMPLES:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme(1) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: ffe.solutions([s^2 - 1, s^6 - s^2], [range(6)]) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme(1) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: ffe.solutions([s^2 - 1, s^6 - s^2], [range(6)]) - sage: sorted(_) # optional - sage.rings.finite_rings + sage: sorted(_) [(0,), (3,)] """ # Do simple cases in one process (this includes most doctests) @@ -941,18 +944,18 @@ def homogeneous_coordinates(self, log_t, nonzero_coordinates, cokernel): EXAMPLES:: - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: cone, nonzero_coordinates, cokernel = list(ffe.ambient.cone_points_iter())[5] # optional - sage.rings.finite_rings - sage: cone.ambient_ray_indices(), nonzero_coordinates # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: cone, nonzero_coordinates, cokernel = list(ffe.ambient.cone_points_iter())[5] + sage: cone.ambient_ray_indices(), nonzero_coordinates ((2,), [0, 1]) - sage: ffe.homogeneous_coordinates([0], nonzero_coordinates, cokernel) # optional - sage.rings.finite_rings + sage: ffe.homogeneous_coordinates([0], nonzero_coordinates, cokernel) (1, 1, 0) - sage: ffe.homogeneous_coordinates([1], nonzero_coordinates, cokernel) # optional - sage.rings.finite_rings + sage: ffe.homogeneous_coordinates([1], nonzero_coordinates, cokernel) (1, 3, 0) - sage: ffe.homogeneous_coordinates([2], nonzero_coordinates, cokernel) # optional - sage.rings.finite_rings + sage: ffe.homogeneous_coordinates([2], nonzero_coordinates, cokernel) (1, 2, 0) """ z = [self.ambient.ring.zero()] * len(self.ambient.rays()) @@ -977,11 +980,11 @@ def __iter__(self): EXAMPLES:: - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: list(ffe) # indirect doctest # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: list(ffe) # indirect doctest [(1, 1, 6), (1, 2, 5), (1, 4, 3)] """ for cone, nonzero_coordinates, cokernel in self.ambient.cone_points_iter(): @@ -1001,10 +1004,10 @@ def cardinality(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X. = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: Y = X.subscheme(u^3 + v^3 + w^3 + u*v*w) # optional - sage.rings.finite_rings - sage: point_set = Y.point_set() # optional - sage.rings.finite_rings - sage: list(point_set) # optional - sage.rings.finite_rings + sage: X. = ToricVariety(fan, base_ring=GF(7)) + sage: Y = X.subscheme(u^3 + v^3 + w^3 + u*v*w) + sage: point_set = Y.point_set() + sage: list(point_set) [[0 : 1 : 3], [1 : 0 : 3], [1 : 3 : 0], @@ -1012,8 +1015,8 @@ def cardinality(self): [1 : 1 : 4], [1 : 3 : 2], [1 : 3 : 5]] - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: ffe.cardinality() # optional - sage.rings.finite_rings + sage: ffe = point_set._enumerator() + sage: ffe.cardinality() 7 """ n = 0 diff --git a/src/sage/schemes/toric/sheaf/constructor.py b/src/sage/schemes/toric/sheaf/constructor.py index 11a189adbf3..52f00d99815 100644 --- a/src/sage/schemes/toric/sheaf/constructor.py +++ b/src/sage/schemes/toric/sheaf/constructor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Construct sheaves on toric varieties diff --git a/src/sage/schemes/toric/sheaf/klyachko.py b/src/sage/schemes/toric/sheaf/klyachko.py index 0bff2218156..08cea1487f9 100644 --- a/src/sage/schemes/toric/sheaf/klyachko.py +++ b/src/sage/schemes/toric/sheaf/klyachko.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs """ Klyachko bundles and sheaves diff --git a/src/sage/schemes/toric/toric_subscheme.py b/src/sage/schemes/toric/toric_subscheme.py index e425ee3d0a8..acdfd05d0d1 100644 --- a/src/sage/schemes/toric/toric_subscheme.py +++ b/src/sage/schemes/toric/toric_subscheme.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Subschemes of toric space @@ -644,9 +645,9 @@ def is_nondegenerate(self): sage: P2. = toric_varieties.P2() sage: f = x^5 + 2*x*y^4 + y^5 - 2*y^3*z^2 + x*z^4 - 2*z^5 - sage: P2.change_ring(GF(5)).subscheme([f]).is_nondegenerate() # optional - sage.rings.finite_rings + sage: P2.change_ring(GF(5)).subscheme([f]).is_nondegenerate() True - sage: P2.change_ring(GF(7)).subscheme([f]).is_nondegenerate() # optional - sage.rings.finite_rings + sage: P2.change_ring(GF(7)).subscheme([f]).is_nondegenerate() False TESTS: diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py index eabb25ca4a1..82d2ec7769a 100644 --- a/src/sage/schemes/toric/variety.py +++ b/src/sage/schemes/toric/variety.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs # -*- coding: utf-8 -*- r""" Toric varieties @@ -1536,7 +1537,7 @@ def plot(self, **options): EXAMPLES:: sage: X = toric_varieties.Cube_deformation(4) - sage: X.plot() + sage: X.plot() # needs sage.plot Graphics3d Object """ if "ray_label" not in options: @@ -1849,8 +1850,8 @@ def Stanley_Reisner_ideal(self): sage: fan = Fan([[0,1,3], [3,4], [2,0], [1,2,4]], ....: [(-3, -2, 1), (0, 0, 1), (3, -2, 1), (-1, -1, 1), (1, -1, 1)]) - sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5)) # optional - sage.rings.finite_rings - sage: SR = X.Stanley_Reisner_ideal(); SR # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5)) + sage: SR = X.Stanley_Reisner_ideal(); SR Ideal (A*E, C*D, A*B*C, B*D*E) of Multivariate Polynomial Ring in A, B, C, D, E over Rational Field """ @@ -1873,8 +1874,8 @@ def linear_equivalence_ideal(self): sage: fan = Fan([[0,1,3], [3,4], [2,0], [1,2,4]], ....: [(-3, -2, 1), (0, 0, 1), (3, -2, 1), (-1, -1, 1), (1, -1, 1)]) - sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5)) # optional - sage.rings.finite_rings - sage: lin = X.linear_equivalence_ideal(); lin # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5)) + sage: lin = X.linear_equivalence_ideal(); lin Ideal (-3*A + 3*C - D + E, -2*A - 2*C - D - E, A + B + C + D + E) of Multivariate Polynomial Ring in A, B, C, D, E over Rational Field """ @@ -2411,7 +2412,7 @@ def divisor_group(self, base_ring=ZZ): sage: dP6 = toric_varieties.dP6() sage: Div = dP6.divisor_group(); Div Group of ZZ-Divisors on 2-d CPR-Fano toric variety covered by 6 affine patches - sage: Div(x) + sage: Div(x) # needs sage.symbolic V(x) """ from sage.schemes.generic.divisor_group import DivisorGroup @@ -2487,7 +2488,7 @@ def _semigroup_ring(self, cone=None, names=None): (Multivariate Polynomial Ring in z0, z1 over Rational Field, Ideal (0) of Multivariate Polynomial Ring in z0, z1 over Rational Field, 2-d cone in 2-d lattice M) - sage: P2.change_ring(GF(101))._semigroup_ring(cone) # optional - sage.rings.finite_rings + sage: P2.change_ring(GF(101))._semigroup_ring(cone) (Multivariate Polynomial Ring in z0, z1 over Finite Field of size 101, Ideal (0) of Multivariate Polynomial Ring in z0, z1 over Finite Field of size 101, 2-d cone in 2-d lattice M) @@ -2739,10 +2740,10 @@ def count_points(self): sage: o = lattice_polytope.cross_polytope(3) sage: V = ToricVariety(FaceFan(o)) - sage: V2 = V.change_ring(GF(2)) # optional - sage.rings.finite_rings - sage: V2.point_set().cardinality() # optional - sage.rings.finite_rings + sage: V2 = V.change_ring(GF(2)) + sage: V2.point_set().cardinality() 27 - sage: V2.count_points() # optional - sage.rings.finite_rings + sage: V2.count_points() 27 """ return self.point_set().cardinality() diff --git a/src/sage/schemes/toric/weierstrass.py b/src/sage/schemes/toric/weierstrass.py index ecf28546aac..137dfd3e042 100644 --- a/src/sage/schemes/toric/weierstrass.py +++ b/src/sage/schemes/toric/weierstrass.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Weierstrass form of a toric elliptic curve diff --git a/src/sage/schemes/toric/weierstrass_covering.py b/src/sage/schemes/toric/weierstrass_covering.py index 5c7b899d93a..13e3c24b2c1 100644 --- a/src/sage/schemes/toric/weierstrass_covering.py +++ b/src/sage/schemes/toric/weierstrass_covering.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Map to the Weierstrass form of a toric elliptic curve diff --git a/src/sage/schemes/toric/weierstrass_higher.py b/src/sage/schemes/toric/weierstrass_higher.py index af9d56233db..2a83234e6ca 100644 --- a/src/sage/schemes/toric/weierstrass_higher.py +++ b/src/sage/schemes/toric/weierstrass_higher.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Weierstrass for elliptic curves in higher codimension @@ -262,17 +263,17 @@ def WeierstrassMap_P3(quadratic1, quadratic2, variables=None): TESTS:: - sage: R. = GF(101)[] # optional - sage.rings.finite_rings - sage: p1 = w^2 + x^2 + y^2 + z^2 # optional - sage.rings.finite_rings - sage: p2 = a0*w^2 + a1*x^2 + a2*y^2 + a3*z^2 # optional - sage.rings.finite_rings - sage: X, Y, Z = WeierstrassMap_P3(p1, p2, [w,x,y,z]) # optional - sage.rings.finite_rings - sage: X.total_degree(), len(X.coefficients()) # optional - sage.rings.finite_rings + sage: R. = GF(101)[] + sage: p1 = w^2 + x^2 + y^2 + z^2 + sage: p2 = a0*w^2 + a1*x^2 + a2*y^2 + a3*z^2 + sage: X, Y, Z = WeierstrassMap_P3(p1, p2, [w,x,y,z]) + sage: X.total_degree(), len(X.coefficients()) (22, 4164) - sage: Y.total_degree(), len(Y.coefficients()) # optional - sage.rings.finite_rings + sage: Y.total_degree(), len(Y.coefficients()) (33, 26912) - sage: Z.total_degree(), len(Z.coefficients()) # optional - sage.rings.finite_rings + sage: Z.total_degree(), len(Z.coefficients()) (10, 24) - sage: Z # optional - sage.rings.finite_rings + sage: Z w*x*y*z*a0^3*a1^2*a2 - w*x*y*z*a0^2*a1^3*a2 - w*x*y*z*a0^3*a1*a2^2 + w*x*y*z*a0*a1^3*a2^2 + w*x*y*z*a0^2*a1*a2^3 - w*x*y*z*a0*a1^2*a2^3 - w*x*y*z*a0^3*a1^2*a3 + w*x*y*z*a0^2*a1^3*a3 + w*x*y*z*a0^3*a2^2*a3 diff --git a/src/sage/structure/coerce_actions.pyx b/src/sage/structure/coerce_actions.pyx index cdc5bddd0a6..6df2aec6695 100644 --- a/src/sage/structure/coerce_actions.pyx +++ b/src/sage/structure/coerce_actions.pyx @@ -14,7 +14,7 @@ Coerce actions import operator -from cpython.int cimport * +from cpython.long cimport * from cpython.number cimport * from cysignals.signals cimport sig_check diff --git a/src/sage/structure/list_clone.pyx b/src/sage/structure/list_clone.pyx index 61a6823fc11..ae50771c7b8 100644 --- a/src/sage/structure/list_clone.pyx +++ b/src/sage/structure/list_clone.pyx @@ -141,7 +141,7 @@ AUTHORS: # **************************************************************************** from cpython.list cimport * -from cpython.int cimport * +from cpython.long cimport * from cpython.ref cimport * from cysignals.memory cimport check_reallocarray, sig_free @@ -1391,7 +1391,7 @@ cdef class ClonableIntArray(ClonableElement): cdef list L = PyList_New(self._len) cdef object o for i in range(self._len): - o = PyInt_FromLong(self._list[i]) + o = PyLong_FromLong(self._list[i]) Py_INCREF(o) PyList_SET_ITEM(L, i, o) return L diff --git a/src/sage/symbolic/constants_c_impl.pxi b/src/sage/symbolic/constants_c_impl.pxi index b92b14318aa..3818926a9a2 100644 --- a/src/sage/symbolic/constants_c_impl.pxi +++ b/src/sage/symbolic/constants_c_impl.pxi @@ -16,9 +16,6 @@ The constant `e` # http://www.gnu.org/licenses/ #***************************************************************************** -from sage.symbolic.expression cimport Expression - - # keep exp(1) for fast access # this is initialized in the constructor of the class E below to prevent # circular imports while loading the library diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index 2300c10d125..0f251ac4e5c 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -6396,7 +6396,6 @@ cdef class Expression(Expression_abc): sage: type(u._unpack_operands()[0]) <... 'tuple'> """ - from sage.symbolic.expression import unpack_operands return unpack_operands(self) def operands(self): diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp index 35fe0606778..c4152e092e3 100644 --- a/src/sage/symbolic/ginac/numeric.cpp +++ b/src/sage/symbolic/ginac/numeric.cpp @@ -176,12 +176,7 @@ inline void py_error(const char* errmsg) { "pyerror() called but no error occurred!"); } -#if PY_MAJOR_VERSION < 3 -#define PyNumber_TrueDivide PyNumber_Divide - -#else #define PyString_FromString PyUnicode_FromString -#endif // The following variable gets changed to true once // this library has been imported by the Python @@ -491,15 +486,9 @@ static PyObject* py_tuple_from_numvector(const std::vector& vec) // class numeric /////////////////////////////////////////////////////////////////////////////// -#if PY_MAJOR_VERSION < 3 -PyObject* ZERO = PyInt_FromLong(0); // todo: never freed -PyObject* ONE = PyInt_FromLong(1); // todo: never freed -PyObject* TWO = PyInt_FromLong(2); // todo: never freed -#else PyObject* ZERO = PyLong_FromLong(0); // todo: never freed PyObject* ONE = PyLong_FromLong(1); // todo: never freed PyObject* TWO = PyLong_FromLong(2); // todo: never freed -#endif std::ostream& operator<<(std::ostream& os, const numeric& s) { switch (s.t) { @@ -811,16 +800,6 @@ void set_from(Type& t, Value& v, long& hash, mpq_t bigrat) numeric::numeric(PyObject* o, bool force_py) : basic(&numeric::tinfo_static) { if (o == nullptr) py_error("Error"); if (not force_py) { -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(o)) { - t = LONG; - v._long = PyInt_AsLong(o); - hash = (v._long==-1) ? -2 : v._long; - setflag(status_flags::evaluated | status_flags::expanded); - Py_DECREF(o); - return; - } -#endif if (PyLong_Check(o)) { t = MPZ; mpz_init(v._bigint); @@ -1533,31 +1512,6 @@ const numeric numeric::div(const numeric &other) const { return bigrat; } case PYOBJECT: -#if PY_MAJOR_VERSION < 3 - if (PyObject_Compare(other.v._pyobject, ONE) == 0 - and py_funcs.py_is_integer(other.v._pyobject) != 0) { - return *this; - } - if (PyInt_Check(v._pyobject)) { - if (PyInt_Check(other.v._pyobject)) { - // This branch happens at startup. - PyObject *o = PyNumber_TrueDivide(Integer(PyInt_AsLong(v._pyobject)), - Integer(PyInt_AsLong(other.v._pyobject))); - // I don't 100% understand why I have to incref this, - // but if I don't, Sage crashes on exit. - Py_INCREF(o); - return o; - } - if (PyLong_Check(other.v._pyobject)) { - PyObject *d = py_funcs. - py_integer_from_python_obj(other.v._pyobject); - PyObject *ans = PyNumber_TrueDivide(v._pyobject, - d); - Py_DECREF(d); - return ans; - } - } -#endif if (PyLong_Check(v._pyobject)) { PyObject *n = py_funcs. py_integer_from_python_obj(v._pyobject); @@ -1866,17 +1820,6 @@ const ex numeric::power(const numeric &exponent) const { // any PyObjects castable to long are casted if (exponent.t == PYOBJECT) { -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(exponent.v._pyobject)) { - long si = PyInt_AsLong(exponent.v._pyobject); - if (si == -1 and PyErr_Occurred()) - PyErr_Clear(); - else { - expo.t = MPZ; - mpz_set_si(expo.v._bigint, si); - } - } else -#endif if (PyLong_Check(exponent.v._pyobject)) { expo.t = MPZ; _mpz_set_pylong(expo.v._bigint, @@ -2503,49 +2446,6 @@ numeric & operator/=(numeric & lh, const numeric & rh) return lh; case PYOBJECT: { PyObject *p = lh.v._pyobject; -#if PY_MAJOR_VERSION < 3 - { - if (PyInt_Check(p)) { - if (PyInt_Check(rh.v._pyobject)) { - // This branch happens at startup. - lh.v._pyobject = PyNumber_TrueDivide(Integer(PyInt_AsLong(p)), - Integer(PyInt_AsLong(rh.v._pyobject))); - // I don't 100% understand why I have to incref this, - // but if I don't, Sage crashes on exit. - if (lh.v._pyobject == nullptr) { - lh.v._pyobject = p; - py_error("numeric operator/="); - } - lh.hash = PyObject_Hash(lh.v._pyobject); - Py_DECREF(p); - return lh; - } - if (PyLong_Check(rh.v._pyobject)) { - PyObject *d = py_funcs.py_integer_from_python_obj(rh.v._pyobject); - lh.v._pyobject = PyNumber_TrueDivide(p, d); - if (lh.v._pyobject == nullptr) { - lh.v._pyobject = p; - py_error("numeric operator/="); - } - lh.hash = PyObject_Hash(lh.v._pyobject); - Py_DECREF(d); - Py_DECREF(p); - return lh; - } - } else if (PyLong_Check(p)) { - PyObject *n = py_funcs.py_integer_from_python_obj(p); - lh.v._pyobject = PyNumber_TrueDivide(n, rh.v._pyobject); - if (lh.v._pyobject == nullptr) { - lh.v._pyobject = p; - py_error("numeric operator/="); - } - lh.hash = PyObject_Hash(lh.v._pyobject); - Py_DECREF(n); - Py_DECREF(p); - return lh; - } - } -#else { if (PyLong_Check(p)) { PyObject *n = py_funcs.py_integer_from_python_obj(p); @@ -2560,7 +2460,7 @@ numeric & operator/=(numeric & lh, const numeric & rh) return lh; } } -#endif + lh.v._pyobject = PyNumber_TrueDivide(p, rh.v._pyobject); if (lh.v._pyobject == nullptr) { lh.v._pyobject = p; diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py index aa153fd4cd5..492dd659ee6 100644 --- a/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py +++ b/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py @@ -215,11 +215,13 @@ sage: plot3d(h, (u,-1,1), (v,-1,1), aspect_ratio=[1,1,1]) Graphics3d Object -Sage example in ./graphique.tex, line 1833:: +Sage example in ./graphique.tex, line 1833. Sometimes the result +needs to be simplified to obtain a nice short expression:: sage: f(x, y) = x^2 * y / (x^4 + y^2) sage: t, theta = var('t, theta') - sage: limit(f(t * cos(theta), t * sin(theta)) / t, t=0) + sage: result = limit(f(t * cos(theta), t * sin(theta)) / t, t=0) + sage: result.full_simplify() cos(theta)^2/sin(theta) Sage example in ./graphique.tex, line 1847:: diff --git a/src/sage/topology/simplicial_complex.py b/src/sage/topology/simplicial_complex.py index d3959b55b92..d5b72a78ded 100644 --- a/src/sage/topology/simplicial_complex.py +++ b/src/sage/topology/simplicial_complex.py @@ -1993,7 +1993,7 @@ def suspension(self, n=1, is_mutable=True): rename_vertices=True) return self.suspension(1, is_mutable).suspension(int(n-1), is_mutable) - def disjoint_union(self, right, rename_vertices=True, is_mutable=True): + def disjoint_union(self, right, rename_vertices=None, is_mutable=True): """ The disjoint union of this simplicial complex with another one. @@ -2017,6 +2017,10 @@ def disjoint_union(self, right, rename_vertices=True, is_mutable=True): sage: S1.disjoint_union(S2).homology() # needs sage.modules {0: Z, 1: Z, 2: Z} """ + if rename_vertices is not None: + from sage.misc.superseded import deprecation + deprecation(35907, 'the "rename_vertices" argument is deprecated') + facets = [] for f in self._facets: facets.append(tuple(["L" + str(v) for v in f])) diff --git a/src/sage/version.py b/src/sage/version.py index dfe0f7baf9c..f0733402150 100644 --- a/src/sage/version.py +++ b/src/sage/version.py @@ -1,5 +1,5 @@ # Sage version information for Python scripts # This file is auto-generated by the sage-update-version script, do not edit! -version = '10.2.beta1' -date = '2023-09-01' -banner = 'SageMath version 10.2.beta1, Release Date: 2023-09-01' +version = '10.2.beta2' +date = '2023-09-10' +banner = 'SageMath version 10.2.beta2, Release Date: 2023-09-10' diff --git a/src/sage_docbuild/__main__.py b/src/sage_docbuild/__main__.py index d7984c7fc0f..77919ec4000 100644 --- a/src/sage_docbuild/__main__.py +++ b/src/sage_docbuild/__main__.py @@ -498,5 +498,6 @@ def excepthook(*exc_info): builder = getattr(get_builder(name), typ) builder() + if __name__ == '__main__': sys.exit(main()) diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index d488a6a13a4..0df2760c035 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -691,6 +691,7 @@ def add_page_context(app, pagename, templatename, context, doctree): context['reference_root'] = os.path.join(relpath, 'index.html') context['refsub'] = True + dangling_debug = False def debug_inf(app, message): @@ -816,6 +817,7 @@ def find_sage_dangling_links(app, env, node, contnode): newnode.append(contnode) return newnode + # lists of basic Python class which are documented as functions base_class_as_func = [ 'bool', 'complex', 'dict', 'file', 'float', @@ -842,6 +844,7 @@ def nitpick_patch_config(app): app.config.values['nitpicky'] = (False, 'sage') app.config.values['nitpick_ignore'] = ([], 'sage') + skip_picklability_check_modules = [ #'sage.misc.test_nested_class', # for test only 'sage.misc.latex', diff --git a/src/sage_docbuild/ext/sage_autodoc.py b/src/sage_docbuild/ext/sage_autodoc.py index e89b8fc9ba4..5b7db9efbbc 100644 --- a/src/sage_docbuild/ext/sage_autodoc.py +++ b/src/sage_docbuild/ext/sage_autodoc.py @@ -73,6 +73,7 @@ def getdoc(obj, *args, **kwargs): return sage_getdoc_original(obj) # ------------------------------------------------------------------ + if TYPE_CHECKING: from sphinx.ext.autodoc.directive import DocumenterBridge diff --git a/src/sage_setup/autogen/interpreters/storage.py b/src/sage_setup/autogen/interpreters/storage.py index d9e0e60273f..291398fd9d9 100644 --- a/src/sage_setup/autogen/interpreters/storage.py +++ b/src/sage_setup/autogen/interpreters/storage.py @@ -440,6 +440,7 @@ class StorageTypeSimple(StorageTypeAssignable): """ pass + ty_int = StorageTypeSimple('int') ty_double = StorageTypeSimple('double') @@ -461,6 +462,7 @@ def assign_c_from_py(self, c, py): """ return je("{{ c }} = CDE_to_dz({{ py }})", c=c, py=py) + ty_double_complex = StorageTypeDoubleComplex('double_complex') @@ -650,6 +652,7 @@ def cython_clear(self, loc): """ return je("Py_CLEAR({{ loc }})", loc=loc) + ty_python = StorageTypePython() @@ -846,6 +849,7 @@ def assign_c_from_py(self, c, py): mpfr_set({{ c }}, rn.value, MPFR_RNDN)"""), myself=self, c=c, py=py) + ty_mpfr = StorageTypeMPFR() class StorageTypeMPC(StorageTypeAutoReference): @@ -948,4 +952,5 @@ def assign_c_from_py(self, c, py): cn{{ myself.id }} = self.domain({{ py }}) mpc_set_fr_fr({{ c }}, cn.__re, cn.__im, MPC_RNDNN)""", myself=self, c=c, py=py) + ty_mpc = StorageTypeMPC() diff --git a/src/tox.ini b/src/tox.ini index 8d2ef29439d..5021d0aa691 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -109,6 +109,7 @@ description = # E111: indentation is not a multiple of four # E211: whitespace before '(' # E271: multiple spaces after keyword + # E305: expected 2 blank lines after class or function definition, found 1 # E306: expected 1 blank line before a nested definition, found 0 # E401: multiple imports on one line # E502 the backslash is redundant between brackets @@ -126,8 +127,8 @@ description = # W605: invalid escape sequence ‘x’ # See https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes deps = pycodestyle -commands = pycodestyle --select E111,E21,E222,E227,E25,E271,E303,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/} - pycodestyle --select E111,E271,E301,E306,E401,E703,E712,E713,E714,E72,W29,W391,W605, --filename *.pyx {posargs:{toxinidir}/sage/} +commands = pycodestyle --select E111,E21,E222,E227,E25,E271,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/} + pycodestyle --select E111,E271,E301,E306,E401,E502,E703,E712,E713,E714,E72,W29,W391,W605, --filename *.pyx {posargs:{toxinidir}/sage/} [pycodestyle] max-line-length = 160 diff --git a/tox.ini b/tox.ini index 99b2c278e24..f7e63767de5 100644 --- a/tox.ini +++ b/tox.ini @@ -187,6 +187,8 @@ setenv = develop: EXTRA_SAGE_PACKAGES_4=_develop $(head -n 1 build/pkgs/_develop/dependencies) minimal: SAGE_PACKAGE_LIST_ARGS=_prereq maximal: SAGE_PACKAGE_LIST_ARGS=:standard: :optional: + sitepackages: ENABLE_SYSTEM_SITE_PACKAGES=yes + sitepackages: CONFIG_CONFIGURE_ARGS_SITEPACKAGES=--enable-system-site-packages conda-environment: SAGE_PACKAGE_LIST_ARGS=_prereq # Whether to add the system packages needed for bootstrapping EXTRA_SAGE_PACKAGES_0=_bootstrap @@ -476,8 +478,9 @@ setenv = # Resulting full image:tag name # docker: FULL_BASE_IMAGE_AND_TAG={env:ARCH_IMAGE_PREFIX:}{env:BASE_IMAGE}{env:ARCH_IMAGE_SUFFIX:}:{env:ARCH_TAG_PREFIX:}{env:BASE_TAG}{env:ARCH_TAG_SUFFIX:} - docker-incremental: FULL_BASE_IMAGE_AND_TAG={env:FROM_DOCKER_REPOSITORY:ghcr.io/sagemath/sage/}sage-$(echo {envname} | sed -E "s/(docker-|-incremental)//g")-{env:FROM_DOCKER_TARGET:with-targets}:{env:FROM_DOCKER_TAG:dev} - docker-incremental: SKIP_SYSTEM_PKG_INSTALL=yes + docker-incremental: FULL_BASE_IMAGE_AND_TAG={env:FROM_DOCKER_REPOSITORY:ghcr.io/sagemath/sage/}sage-$(echo {envname} | sed -E "s/(docker-|-incremental|-sitepackages)//g")-{env:FROM_DOCKER_TARGET:with-targets}:{env:FROM_DOCKER_TAG:dev} + docker-incremental: SKIP_SYSTEM_PKG_INSTALL=yes + docker-incremental-sitepackages: SKIP_SYSTEM_PKG_INSTALL=no # docker-nobootstrap: BOOTSTRAP=./bootstrap -D ### @@ -601,12 +604,14 @@ setenv = # # Resulting full configuration args, including EXTRA_CONFIGURE_ARGS from the user environment # - CONFIGURE_ARGS=--enable-experimental-packages --enable-download-from-upstream-url {env:CONFIG_CONFIGURE_ARGS_ROOT:} {env:CONFIG_CONFIGURE_ARGS_1:} {env:CONFIG_CONFIGURE_ARGS_2:} {env:EXTRA_CONFIGURE_ARGS:} + CONFIGURE_ARGS=--enable-experimental-packages --enable-download-from-upstream-url {env:CONFIG_CONFIGURE_ARGS_ROOT:} {env:CONFIG_CONFIGURE_ARGS_SITEPACKAGES:} {env:CONFIG_CONFIGURE_ARGS_1:} {env:CONFIG_CONFIGURE_ARGS_2:} {env:EXTRA_CONFIGURE_ARGS:} # # Resulting EXTRA_SAGE_PACKAGES # ALL_EXTRA_SAGE_PACKAGES={env:EXTRA_SAGE_PACKAGES_0:} {env:EXTRA_SAGE_PACKAGES_1:} {env:EXTRA_SAGE_PACKAGES_2:} {env:EXTRA_SAGE_PACKAGES_3:} {env:EXTRA_SAGE_PACKAGES_4:} {env:EXTRA_SAGE_PACKAGES_5:} {env:EXTRA_SAGE_PACKAGES:} + sitepackages: IGNORE_MISSING_SYSTEM_PACKAGES=yes + # environment will be skipped if regular expression does not match against the sys.platform string platform = local-macos: darwin