├── .cirrus.yml.backup ├── .coveragerc.meson ├── .coveragerc.setuptools ├── .github ├── dependabot.yml └── workflows │ ├── buildwheel.yml │ └── lint.yml ├── .gitignore ├── .readthedocs.yaml ├── LICENSE ├── MANIFEST.in ├── README.md ├── bin ├── activate ├── all_rst_to_pxd.sh ├── build_dependencies_unix.sh ├── build_inplace.sh ├── build_mingw64_wheel.sh ├── build_variables.sh ├── build_wheel.sh ├── bump_version.py ├── cibw.bat ├── cibw_before_all_linux_aarch64.sh ├── cibw_before_all_linux_x86_64.sh ├── cibw_before_all_macosx_arm64.sh ├── cibw_before_all_macosx_x86_64.sh ├── cibw_before_all_windows.sh ├── cibw_before_build_windows.sh ├── cibw_repair_wheel_command_windows.bat ├── cibw_repair_wheel_command_windows.sh ├── coverage.sh ├── coverage_setuptools.sh ├── install_flint_ubuntu.sh ├── install_latest_flint_ubuntu.sh ├── patch-arm64.diff ├── rst_to_pxd.py └── rtd_before_all_linux.sh ├── coverage_plugin.py ├── doc ├── Makefile └── source │ ├── _gr.rst │ ├── _static │ └── empty │ ├── acb.rst │ ├── acb_mat.rst │ ├── acb_poly.rst │ ├── acb_series.rst │ ├── acb_theta.rst │ ├── arb.rst │ ├── arb_mat.rst │ ├── arb_poly.rst │ ├── arb_series.rst │ ├── build.rst │ ├── conf.py │ ├── dirichlet.rst │ ├── fmpq.rst │ ├── fmpq_mat.rst │ ├── fmpq_mpoly.rst │ ├── fmpq_poly.rst │ ├── fmpq_series.rst │ ├── fmpz.rst │ ├── fmpz_mat.rst │ ├── fmpz_mod.rst │ ├── fmpz_mod_mat.rst │ ├── fmpz_mod_mpoly.rst │ ├── fmpz_mod_poly.rst │ ├── fmpz_mpoly.rst │ ├── fmpz_poly.rst │ ├── fmpz_series.rst │ ├── fq_default.rst │ ├── fq_default_poly.rst │ ├── general.rst │ ├── index.rst │ ├── install.rst │ ├── nmod.rst │ ├── nmod_mat.rst │ ├── nmod_mpoly.rst │ ├── nmod_poly.rst │ ├── nmod_series.rst │ └── workflow.rst ├── meson.build ├── meson.options ├── pyproject.toml ├── requirements-dev.txt ├── setup.py ├── src └── flint │ ├── __init__.py │ ├── flint_base │ ├── __init__.py │ ├── flint_base.pxd │ ├── flint_base.pyx │ ├── flint_context.pxd │ ├── flint_context.pyx │ └── meson.build │ ├── flintlib │ ├── README.md │ ├── __init__.py │ ├── functions │ │ ├── __init__.pxd │ │ ├── __init__.py │ │ ├── acb.pxd │ │ ├── acb_calc.pxd │ │ ├── acb_dft.pxd │ │ ├── acb_dirichlet.pxd │ │ ├── acb_elliptic.pxd │ │ ├── acb_hypgeom.pxd │ │ ├── acb_mat.pxd │ │ ├── acb_modular.pxd │ │ ├── acb_poly.pxd │ │ ├── acb_theta.pxd │ │ ├── arb.pxd │ │ ├── arb_fmpz_poly.pxd │ │ ├── arb_hypgeom.pxd │ │ ├── arb_mat.pxd │ │ ├── arb_poly.pxd │ │ ├── arf.pxd │ │ ├── arith.pxd │ │ ├── bernoulli.pxd │ │ ├── compat.pxd │ │ ├── dirichlet.pxd │ │ ├── fmpq.pxd │ │ ├── fmpq_mat.pxd │ │ ├── fmpq_mpoly.pxd │ │ ├── fmpq_mpoly_factor.pxd │ │ ├── fmpq_poly.pxd │ │ ├── fmpq_vec.pxd │ │ ├── fmpz.pxd │ │ ├── fmpz_factor.pxd │ │ ├── fmpz_lll.pxd │ │ ├── fmpz_mat.pxd │ │ ├── fmpz_mod.pxd │ │ ├── fmpz_mod_mat.pxd │ │ ├── fmpz_mod_mpoly.pxd │ │ ├── fmpz_mod_mpoly_factor.pxd │ │ ├── fmpz_mod_poly.pxd │ │ ├── fmpz_mod_poly_factor.pxd │ │ ├── fmpz_mod_vec.pxd │ │ ├── fmpz_mpoly.pxd │ │ ├── fmpz_mpoly_factor.pxd │ │ ├── fmpz_mpoly_q.pxd │ │ ├── fmpz_poly.pxd │ │ ├── fmpz_poly_factor.pxd │ │ ├── fmpz_vec.pxd │ │ ├── fq.pxd │ │ ├── fq_default.pxd │ │ ├── fq_default_mat.pxd │ │ ├── fq_default_poly.pxd │ │ ├── fq_default_poly_factor.pxd │ │ ├── fq_mat.pxd │ │ ├── fq_nmod.pxd │ │ ├── fq_nmod_mat.pxd │ │ ├── fq_nmod_poly.pxd │ │ ├── fq_nmod_poly_factor.pxd │ │ ├── fq_poly.pxd │ │ ├── fq_poly_factor.pxd │ │ ├── fq_zech.pxd │ │ ├── fq_zech_mat.pxd │ │ ├── fq_zech_poly.pxd │ │ ├── fq_zech_poly_factor.pxd │ │ ├── gr.pxd │ │ ├── gr_domains.pxd │ │ ├── gr_generic.pxd │ │ ├── gr_implementing.pxd │ │ ├── gr_mat.pxd │ │ ├── gr_mpoly.pxd │ │ ├── gr_poly.pxd │ │ ├── gr_special.pxd │ │ ├── gr_vec.pxd │ │ ├── mag.pxd │ │ ├── mpoly.pxd │ │ ├── nmod.pxd │ │ ├── nmod_mat.pxd │ │ ├── nmod_mpoly.pxd │ │ ├── nmod_mpoly_factor.pxd │ │ ├── nmod_poly.pxd │ │ ├── nmod_poly_factor.pxd │ │ ├── nmod_vec.pxd │ │ ├── partitions.pxd │ │ └── ulong_extras.pxd │ └── types │ │ ├── __init__.py │ │ ├── acb.pxd │ │ ├── acb_calc.pxd │ │ ├── acb_dirichlet.pxd │ │ ├── acb_theta.pxd │ │ ├── arb.pxd │ │ ├── arf.pxd │ │ ├── arith.pxd │ │ ├── dirichlet.pxd │ │ ├── flint.pxd │ │ ├── fmpq.pxd │ │ ├── fmpz.pxd │ │ ├── fmpz_mod.pxd │ │ ├── fmpz_mod_mat_compat.pxd │ │ ├── fmpz_mod_poly.pxd │ │ ├── fq.pxd │ │ ├── fq_default.pxd │ │ ├── fq_nmod.pxd │ │ ├── fq_zech.pxd │ │ ├── gr.pxd │ │ ├── mpoly.pxd │ │ ├── nmod.pxd │ │ └── undocumented.pxd │ ├── functions │ ├── __init__.py │ ├── meson.build │ └── showgood.pyx │ ├── meson.build │ ├── pyflint.pxd │ ├── pyflint.pyx │ ├── test │ ├── __init__.py │ ├── __main__.py │ ├── meson.build │ ├── test_all.py │ └── test_docstrings.py │ ├── types │ ├── __init__.py │ ├── _gr.pxd │ ├── _gr.pyx │ ├── acb.pxd │ ├── acb.pyx │ ├── acb_mat.pxd │ ├── acb_mat.pyx │ ├── acb_poly.pxd │ ├── acb_poly.pyx │ ├── acb_series.pxd │ ├── acb_series.pyx │ ├── acb_theta.pyx │ ├── arb.pxd │ ├── arb.pyx │ ├── arb_mat.pxd │ ├── arb_mat.pyx │ ├── arb_poly.pxd │ ├── arb_poly.pyx │ ├── arb_series.pxd │ ├── arb_series.pyx │ ├── arf.pxd │ ├── arf.pyx │ ├── dirichlet.pxd │ ├── dirichlet.pyx │ ├── fmpq.pxd │ ├── fmpq.pyx │ ├── fmpq_mat.pxd │ ├── fmpq_mat.pyx │ ├── fmpq_mpoly.pxd │ ├── fmpq_mpoly.pyx │ ├── fmpq_poly.pxd │ ├── fmpq_poly.pyx │ ├── fmpq_series.pxd │ ├── fmpq_series.pyx │ ├── fmpq_vec.pxd │ ├── fmpq_vec.pyx │ ├── fmpz.pxd │ ├── fmpz.pyx │ ├── fmpz_mat.pxd │ ├── fmpz_mat.pyx │ ├── fmpz_mod.pxd │ ├── fmpz_mod.pyx │ ├── fmpz_mod_mat.pxd │ ├── fmpz_mod_mat.pyx │ ├── fmpz_mod_mpoly.pxd │ ├── fmpz_mod_mpoly.pyx │ ├── fmpz_mod_poly.pxd │ ├── fmpz_mod_poly.pyx │ ├── fmpz_mpoly.pxd │ ├── fmpz_mpoly.pyx │ ├── fmpz_poly.pxd │ ├── fmpz_poly.pyx │ ├── fmpz_series.pxd │ ├── fmpz_series.pyx │ ├── fmpz_vec.pxd │ ├── fmpz_vec.pyx │ ├── fq_default.pxd │ ├── fq_default.pyx │ ├── fq_default_poly.pxd │ ├── fq_default_poly.pyx │ ├── meson.build │ ├── nmod.pxd │ ├── nmod.pyx │ ├── nmod_mat.pxd │ ├── nmod_mat.pyx │ ├── nmod_mpoly.pxd │ ├── nmod_mpoly.pyx │ ├── nmod_poly.pxd │ ├── nmod_poly.pyx │ ├── nmod_series.pxd │ └── nmod_series.pyx │ └── utils │ ├── __init__.py │ ├── conversion.pxd │ ├── flint_exceptions.py │ ├── meson.build │ └── typecheck.pxd └── wheels ├── LICENSE_linux_wheels.txt ├── LICENSE_macos_wheels.txt └── LICENSE_windows_wheels.txt /.cirrus.yml.backup: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | # Build arm64 wheels for OSX on Cirrus CI 3 | ######################################################### 4 | 5 | cirrus_wheels_macos_arm64_task: 6 | name: Build macOS arm64 wheels. 7 | macos_instance: 8 | image: ghcr.io/cirruslabs/macos-monterey-xcode:13.3.1 9 | env: 10 | PATH: /opt/homebrew/opt/python@3.10/bin:$PATH 11 | CIBW_ARCHS_MACOS: arm64 12 | CIBW_TEST_COMMAND: "python -m flint.test" 13 | install_pre_requirements_script: 14 | - python3 -m venv venv 15 | - venv/bin/pip install --upgrade pip 16 | - venv/bin/pip install cibuildwheel==2.16.2 17 | run_cibuildwheel_script: 18 | - venv/bin/cibuildwheel --platform macos 19 | wheels_artifacts: 20 | path: "wheelhouse/*" 21 | -------------------------------------------------------------------------------- /.coveragerc.meson: -------------------------------------------------------------------------------- 1 | [run] 2 | plugins = coverage_plugin 3 | -------------------------------------------------------------------------------- /.coveragerc.setuptools: -------------------------------------------------------------------------------- 1 | [run] 2 | plugins = Cython.Coverage 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: github-actions 9 | directory: "/" 10 | schedule: 11 | interval: "monthly" 12 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Linting 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | lint: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | python-version: ["3.12"] 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: Set up Python ${{ matrix.python-version }} 15 | uses: actions/setup-python@v5 16 | with: 17 | python-version: ${{ matrix.python-version }} 18 | 19 | - name: Install dependencies 20 | run: | 21 | pip install uv 22 | uv pip install cython-lint --upgrade --system 23 | 24 | - name: cython-lint 25 | run: | 26 | cython-lint src/ 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | build-install/* 3 | dist/* 4 | src/flint/**/*.c 5 | src/flint/*.html 6 | doc/build/* 7 | fmake* 8 | *.whl 9 | *.pyc 10 | *.pyd 11 | *.so 12 | __pycache__ 13 | MANIFEST 14 | .eggs 15 | .local 16 | *.egg-info 17 | .coverage 18 | *.swp 19 | .python-version 20 | *.DS_Store 21 | .venv 22 | .hypothesis 23 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Set the OS, Python version and other tools you might need 9 | build: 10 | os: ubuntu-24.04 11 | tools: 12 | python: "3.12" 13 | 14 | apt_packages: 15 | - libflint-dev 16 | jobs: 17 | pre_build: 18 | - pip install . 19 | 20 | # Tried to use this to build latest version of FLINT but FLINT does not build 21 | # in rtd for some reason. FLINT's configure seems to fail in all sorts of ways 22 | # even though GMP and MPFR build fine. 23 | # 24 | # commands: 25 | # - pip install -r requirements-dev.txt 26 | # - bin/build_dependencies_unix.sh --use-gmp-github-mirror 27 | # - spin build -- --pkg-config-path=.local/lib/pkgconfig -Dadd_flint_rpath=true 28 | # - spin docs 29 | # - mv doc/build/html $READTHEDOCS_OUTPUT/html 30 | 31 | # Build documentation in the "docs/" directory with Sphinx 32 | sphinx: 33 | configuration: doc/source/conf.py 34 | 35 | # Optionally build your docs in additional formats such as PDF and ePub 36 | # formats: 37 | # - pdf 38 | # - epub 39 | 40 | # Optional but recommended, declare the Python requirements required 41 | # to build your documentation 42 | # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html 43 | python: 44 | install: 45 | - requirements: requirements-dev.txt 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2014-2016 Fredrik Johansson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include CHANGES 3 | include README.md 4 | recursive-include src/flint *.pxd *.pyx *.py 5 | include doc/source/*.py 6 | include doc/source/*.rst 7 | include doc/Makefile 8 | -------------------------------------------------------------------------------- /bin/activate: -------------------------------------------------------------------------------- 1 | export C_INCLUDE_PATH=$(pwd)/.local/include 2 | export LIBRARY_PATH=$(pwd)/.local/lib 3 | export LD_LIBRARY_PATH=$(pwd)/.local/lib 4 | export PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig 5 | -------------------------------------------------------------------------------- /bin/all_rst_to_pxd.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [ $# -eq 0 ] 6 | then 7 | echo "Usage: bin/all_rst_to_pxd.sh /path/to/flint/doc/source" 8 | exit 1 9 | fi 10 | 11 | FLINT_DOC_DIR=$1 12 | 13 | modules=( 14 | # "flint" 15 | "mpoly" 16 | # "thread_pool" 17 | # "machine_vectors" 18 | "gr" 19 | "gr_domains" 20 | "gr_generic" 21 | "gr_implementing" 22 | "gr_mat" 23 | "gr_mpoly" 24 | "gr_poly" 25 | "gr_special" 26 | "gr_vec" 27 | "ulong_extras" 28 | "fmpz" 29 | # "fmpz_extras" 30 | "fmpz_factor" 31 | "fmpz_lll" 32 | "fmpz_mat" 33 | "fmpz_mpoly" 34 | "fmpz_mpoly_factor" 35 | "fmpz_mpoly_q" 36 | "fmpz_poly" 37 | "fmpz_poly_factor" 38 | # "fmpz_poly_mat" 39 | # "fmpz_poly_q" 40 | "fmpz_vec" 41 | # "long_extras" 42 | # "longlong" 43 | # "mpn_extras" 44 | # "aprcl" 45 | "arith" 46 | # "fft" 47 | # "fft_small" 48 | # "qsieve" 49 | "fmpq" 50 | "fmpq_mat" 51 | "fmpq_mpoly" 52 | "fmpq_mpoly_factor" 53 | "fmpq_poly" 54 | "fmpq_vec" 55 | "nmod" 56 | "nmod_mat" 57 | "nmod_mpoly" 58 | "nmod_mpoly_factor" 59 | "nmod_poly" 60 | "nmod_poly_factor" 61 | # "nmod_poly_mat" 62 | "nmod_vec" 63 | # "mpn_mod" 64 | "fmpz_mod" 65 | "fmpz_mod_mat" 66 | "fmpz_mod_mpoly" 67 | "fmpz_mod_mpoly_factor" 68 | "fmpz_mod_poly" 69 | "fmpz_mod_poly_factor" 70 | "fmpz_mod_vec" 71 | "dirichlet" 72 | # "dlog" 73 | # "bool_mat" 74 | # "perm" 75 | # "qfb" 76 | # "nf" 77 | # "nf_elem" 78 | # "fmpzi" 79 | # "qqbar" 80 | "mag" 81 | # "nfloat" 82 | "arf" 83 | # "acf" 84 | "arb" 85 | # "arb_calc" 86 | "arb_fmpz_poly" 87 | # "arb_fpwrap" 88 | "arb_hypgeom" 89 | "arb_mat" 90 | "arb_poly" 91 | "acb" 92 | "acb_calc" 93 | "acb_dft" 94 | "acb_dirichlet" 95 | "acb_elliptic" 96 | "acb_hypgeom" 97 | "acb_mat" 98 | "acb_modular" 99 | "acb_poly" 100 | "acb_theta" 101 | "bernoulli" 102 | # "hypgeom" 103 | "partitions" 104 | # "ca" 105 | # "ca_ext" 106 | # "ca_field" 107 | # "ca_mat" 108 | # "ca_poly" 109 | # "ca_vec" 110 | # "calcium" 111 | # "fexpr" 112 | # "fexpr_builtin" 113 | "fq" 114 | # "fq_embed" 115 | "fq_mat" 116 | "fq_poly" 117 | "fq_poly_factor" 118 | # "fq_vec" 119 | "fq_nmod" 120 | # "fq_nmod_embed" 121 | "fq_nmod_mat" 122 | # "fq_nmod_mpoly" 123 | # "fq_nmod_mpoly_factor" 124 | "fq_nmod_poly" 125 | "fq_nmod_poly_factor" 126 | # "fq_nmod_vec" 127 | "fq_zech" 128 | # "fq_zech_embed" 129 | "fq_zech_mat" 130 | "fq_zech_poly" 131 | "fq_zech_poly_factor" 132 | # "fq_zech_vec" 133 | "fq_default" 134 | "fq_default_mat" 135 | "fq_default_poly" 136 | "fq_default_poly_factor" 137 | # "padic" 138 | # "padic_mat" 139 | # "padic_poly" 140 | # "qadic" 141 | # "double_extras" 142 | # "double_interval" 143 | # "d_mat" 144 | # "d_vec" 145 | # "mpfr_mat" 146 | # "mpfr_vec" 147 | ) 148 | 149 | for module in ${modules[@]}; do 150 | echo "Processing $module" 151 | bin/rst_to_pxd.py flint/$module \ 152 | --flint-doc-dir=$FLINT_DOC_DIR \ 153 | > src/flint/flintlib/functions/$module.pxd 154 | done 155 | -------------------------------------------------------------------------------- /bin/build_inplace.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Build the flint._flint module in place. 4 | 5 | C_INCLUDE_PATH=.local/include/ LIBRARY_PATH=.local/lib/ python setup.py build_ext --inplace 6 | -------------------------------------------------------------------------------- /bin/build_mingw64_wheel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # make_wheels.sh 4 | # 5 | # Build relocatable Windows wheel for python_flint using the mingw-w64 6 | # toolchain in the MSYS2 enironment. 7 | # 8 | # - First install Python 9 | # 10 | # https://www.python.org/ftp/python/3.10.8/python-3.10.8-amd64.exe 11 | # 12 | # - Then checkout the code: 13 | # 14 | # $ git clone https://github.com/flintlib/python-flint.git 15 | # 16 | # - Then install msys2 17 | # 18 | # https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20221028.exe 19 | # 20 | # - Then open msys2, cd into the checked out repo. Make sure setup.py says 21 | # 22 | # libraries = ["arb", "flint", "mpfr", "gmp"] 23 | # 24 | # - Set the environment variable to the directory containing the installed 25 | # Python that we want to build a wheel for i.e. the one installed from 26 | # python.org. If python was on PATH then it would be 27 | # 28 | # PYTHONDIR=`dirname $(which python)` 29 | # PYTHONVER=3.10 30 | # 31 | # - Then run this script. 32 | 33 | set -o errexit 34 | 35 | # 36 | # In CI this environment variable needs to be set to the directory containing 37 | # the python.org installation of Python. If Python is installed in msys2 then 38 | # it is also necesary to set this environment variable so that it picks up the 39 | # right installation of Python i.e. the one that we want to build a wheel for. 40 | # 41 | if [[ -z "$PYTHONDIR" ]]; then 42 | PYTHONDIR=`dirname $(which python)` 43 | fi 44 | PYTHON=$PYTHONDIR/python 45 | VER="${PYTHONVER//./}" 46 | 47 | WHEELNAME=python_flint-0.6.0-cp$VER-cp$VER-win_amd64.whl 48 | 49 | $PYTHON -c 'print("hello world")' 50 | 51 | echo $PYTHONDIR 52 | ls $PYTHONDIR 53 | ls $PYTHONDIR/libs 54 | 55 | # Install the mingw-w64 toolchain 56 | pacman -S --noconfirm mingw-w64-x86_64-gcc m4 make mingw-w64-x86_64-tools-git 57 | 58 | # This takes ~30mins 59 | #bin/build_dependencies_unix.sh 60 | 61 | # Add the libpython$VER.a file to Python installation 62 | cd $PYTHONDIR 63 | gendef python$VER.dll 64 | dlltool --dllname python$VER.dll --def python$VER.def --output-lib libpython$VER.a 65 | mv libpython$VER.a libs 66 | cd - 67 | 68 | # Make a virtual environment to install the build dependencies 69 | $PYTHON -m venv .local/venv 70 | source .local/venv/Scripts/activate 71 | pip install numpy cython wheel delvewheel psutil 72 | 73 | # Pass this flag to setup.py 74 | export PYTHON_FLINT_MINGW64_TMP=true 75 | 76 | # Build the wheel 77 | C_INCLUDE_PATH=.local/include/ LIBRARY_PATH=.local/lib/ python setup.py build_ext -cmingw32 -f bdist_wheel 78 | 79 | # delvewheel requires DLLs created by mingw64 to be stripped 80 | # 81 | # https://github.com/scipy/scipy/blob/main/tools/wheels/repair_windows.sh 82 | strip .local/bin/*.dll .local/lib/*.dll 83 | 84 | # Unpack the wheel and strip the .pyd DLL inside 85 | cd dist 86 | wheel unpack $WHEELNAME 87 | rm $WHEELNAME 88 | strip python_flint-*/flint/*.pyd 89 | wheel pack python_flint-* 90 | cd .. 91 | 92 | # Make the wheel relocatable 93 | delvewheel repair dist/python_flint-0.6.0-cp$VER-cp$VER-win_amd64.whl \ 94 | --add-path .local/bin:.local/lib/ 95 | 96 | # Make a virtual enironment to test the wheel 97 | $PYTHON -m venv test_env 98 | source test_env/Scripts/activate 99 | pip install wheelhouse/$WHEELNAME 100 | python -c 'import flint; print(flint.fmpz(2) + 2)' # 2 + 2 = 4? 101 | -------------------------------------------------------------------------------- /bin/build_variables.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Create a local directory .local to be used as --prefix when building 4 | # local installs of python-flint's dependencies. This also sets the PREFIX 5 | # shell variable and environment variables giving the versions to use for each 6 | # dependency. This script should be sourced rather than executed e.g.: 7 | # 8 | # $ source bin/build_variables.sh 9 | # 10 | # This is used implicitly by the other build scripts and does not need to be 11 | # executed directly. 12 | 13 | PREFIX=$(pwd)/.local 14 | mkdir -p $PREFIX 15 | 16 | ARBVER=2.23.0 # Not needed with flint >= 3.0.0 (Arb is included in flint) 17 | 18 | YASMVER=1.3.0 # Only needed for MPIR 19 | MPIRVER=3.0.0 # MPIR build no longer works (not clear where to download from) 20 | 21 | # These are the actual dependencies used (at least by default): 22 | GMPVER=6.3.0 23 | MPFRVER=4.2.2 24 | FLINTVER='3.2.2' 25 | -------------------------------------------------------------------------------- /bin/build_wheel.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Compile a python-flint wheel using the dependencies built by 4 | # build_dependencies_unix.sh (which should be run first). 5 | 6 | set -o errexit 7 | 8 | source bin/build_variables.sh 9 | 10 | python3 -m venv $PREFIX/venv 11 | source $PREFIX/venv/bin/activate 12 | pip install -U pip 13 | pip install numpy cython wheel 14 | 15 | C_INCLUDE_PATH=.local/include/ LIBRARY_PATH=.local/lib/ pip wheel . 16 | -------------------------------------------------------------------------------- /bin/bump_version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | filenames_default = [ 4 | "pyproject.toml", 5 | "src/flint/__init__.py", 6 | "doc/source/conf.py", 7 | "src/flint/test/test_all.py", 8 | ] 9 | 10 | 11 | def main(version2=None, *filenames): 12 | """Bump version number in files. 13 | 14 | $ bin/bump_version.py 15 | Current version: 0.1.0 16 | 17 | $ bin/bump_version.py 0.1.0 0.1.1 18 | Set version 0.1.0 to 0.1.1 in: 19 | pyproject.toml 20 | src/flint/__init__.py 21 | doc/source/conf.py 22 | src/flint/test/test_all.py 23 | 24 | """ 25 | with open("pyproject.toml", "r") as f: 26 | text = f.read() 27 | version1 = text.split("version = \"")[1].split("\"")[0] 28 | 29 | if not version2: 30 | print(f"Current version: {version1}") 31 | return 32 | 33 | if not filenames: 34 | filenames = filenames_default 35 | 36 | print(f"Set version {version1} to {version2} in:") 37 | for filename in filenames: 38 | print(filename) 39 | with open(filename, "r") as f: 40 | text = f.read() 41 | with open(filename, "w") as f: 42 | f.write(text.replace(version1, version2)) 43 | 44 | 45 | if __name__ == "__main__": 46 | import sys 47 | main(*sys.argv[1:]) 48 | -------------------------------------------------------------------------------- /bin/cibw.bat: -------------------------------------------------------------------------------- 1 | rem 2 | rem This bat file can be used to test cibuildwheel locally on Windows. The 3 | rem cibw_*_windows.sh files have lines to set the PATH for working locally but 4 | rem those are commented out because they are not needed in CI. To use this 5 | rem script 6 | rem 7 | rem 1. Uncomment those lines 8 | rem 2. > pip install cibuildwheel 9 | rem 3. > bin\cibw.bat 10 | rem 11 | rem The variables defined below should match those that are set in CI except 12 | rem that C:\msys64\usr\bin\bash should just be msys2 -c in CI. 13 | rem 14 | rem It is also worth commenting out the line to build GMP etc after you have 15 | rem built those once because that is by far the slowest step. 16 | rem 17 | 18 | rem 19 | rem If this script is run repeatedly then it would fail because of any leftover 20 | rem wheels from a previous run so we delete them here. 21 | rem 22 | del /q wheelhouse\* 23 | 24 | rem override setting in pyproject.toml 25 | set CIBW_BUILD=cp39-* cp310-* cp311-* 26 | 27 | cibuildwheel --platform windows 28 | -------------------------------------------------------------------------------- /bin/cibw_before_all_linux_aarch64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cat wheels/LICENSE_linux_wheels.txt >> LICENSE 6 | 7 | yum install -y xz 8 | bin/build_dependencies_unix.sh\ 9 | --gmp gmp\ 10 | --host aarch64-pc-linux-gnu\ 11 | --use-gmp-github-mirror 12 | -------------------------------------------------------------------------------- /bin/cibw_before_all_linux_x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cat wheels/LICENSE_linux_wheels.txt >> LICENSE 6 | 7 | yum install -y xz 8 | bin/build_dependencies_unix.sh\ 9 | --gmp gmp\ 10 | --host x86_64-pc-linux-gnu\ 11 | --use-gmp-github-mirror 12 | -------------------------------------------------------------------------------- /bin/cibw_before_all_macosx_arm64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cat wheels/LICENSE_macos_wheels.txt >> LICENSE 6 | 7 | export CPPFLAGS=" --target=arm64-apple-macos11" 8 | export LDFLAGS=" -arch arm64" 9 | 10 | brew install automake libtool 11 | 12 | bin/build_dependencies_unix.sh\ 13 | --gmp gmp\ 14 | --host aarch64-apple-darwin\ 15 | --use-gmp-github-mirror 16 | -------------------------------------------------------------------------------- /bin/cibw_before_all_macosx_x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | cat wheels/LICENSE_macos_wheels.txt >> LICENSE 6 | 7 | brew install automake libtool 8 | 9 | bin/build_dependencies_unix.sh\ 10 | --gmp gmp\ 11 | --host x86_64-apple-darwin\ 12 | --use-gmp-github-mirror 13 | -------------------------------------------------------------------------------- /bin/cibw_before_all_windows.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | 5 | cat wheels/LICENSE_windows_wheels.txt >> LICENSE 6 | 7 | # Uncomment this to run cibuildwheel locally on Windows: 8 | # export PATH=$PATH:/c/msys64/usr/bin:/c/msys64/mingw64/bin 9 | 10 | # 11 | # Make a setup.cfg to specify compiling with mingw64 (even though it says 12 | # mingw32...) 13 | # 14 | 15 | # This is not needed any more for python-flint >= 0.7.0 because meson is now 16 | # used as the build system rather than setuptools: 17 | echo '[build]' > setup.cfg 18 | echo 'compiler = mingw32' >> setup.cfg 19 | cat setup.cfg 20 | 21 | # Install the mingw-w64 toolchain and build tools 22 | pacman -S --noconfirm \ 23 | mingw-w64-x86_64-gcc\ 24 | mingw-w64-x86_64-tools-git\ 25 | m4\ 26 | make\ 27 | base-devel\ 28 | autoconf-wrapper\ 29 | automake-wrapper\ 30 | libtool\ 31 | # 32 | 33 | # This is slow with MinGW: 34 | bin/build_dependencies_unix.sh --use-gmp-github-mirror 35 | -------------------------------------------------------------------------------- /bin/cibw_before_build_windows.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # This script was previously needed to make libpythonXX.a on Windows when using 5 | # MinGW and setuptools. This is no longer needed now that we use meson. 6 | # 7 | 8 | set -o errexit 9 | 10 | # Uncomment this to run cibuildwheel locally on Windows: 11 | # export PATH=$PATH:/c/msys64/usr/bin:/c/msys64/mingw64/bin 12 | 13 | # VER should be set be e.g. 310 for Python 3.10 14 | VER=`python -c 'import sys; print("%s%s" % sys.version_info[:2])'` 15 | echo VER=${VER} 16 | 17 | ################################################### 18 | # Find parent Python installation from the venv # 19 | ################################################### 20 | 21 | which python 22 | PYTHONBIN=`dirname $(which python)` 23 | PYTHONDIR=`dirname $PYTHONBIN` 24 | cfgfile=$PYTHONDIR/pyvenv.cfg 25 | homeline=`grep home $cfgfile` 26 | homepath=${homeline#*=} 27 | 28 | echo --------------------------------------------------- 29 | echo $homepath 30 | echo --------------------------------------------------- 31 | 32 | ################################################### 33 | # Find pythonXX.dll and make a .a library # 34 | ################################################### 35 | 36 | cd $homepath 37 | gendef python${VER}.dll 38 | dlltool --dllname python${VER}.dll \ 39 | --def python${VER}.def \ 40 | --output-lib libpython${VER}.a 41 | 42 | mv libpython${VER}.a libs 43 | 44 | ################################################### 45 | # Install build dependencies # 46 | ################################################### 47 | 48 | pip install cython numpy delvewheel wheel 49 | -------------------------------------------------------------------------------- /bin/cibw_repair_wheel_command_windows.bat: -------------------------------------------------------------------------------- 1 | rem 2 | rem This batch file serves the purpose of taking Windows style path arguments, 3 | rem converting them to environment variables and calling msys2. This is needed 4 | rem because otherwise in CI msys2 -c will mangle the paths turning e.g. C:\a\b 5 | rem into C:ab. 6 | rem 7 | 8 | set tempfile=tmpfile.deleteme 9 | set WHEELHOUSE=%1 10 | set WHEELNAME=%2 11 | 12 | msys2 -c bin/cibw_repair_wheel_command_windows.sh 13 | rem C:\msys64\usr\bin\bash bin/cibw_repair_wheel_command_windows.sh 14 | -------------------------------------------------------------------------------- /bin/cibw_repair_wheel_command_windows.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Repair Windows wheels. See e.g.: 4 | # 5 | # https://github.com/scipy/scipy/blob/main/tools/wheels/repair_windows.sh 6 | 7 | # 8 | # This was previously needed because delvewheel would reject wheels with 9 | # binaries generated by MinGW unless they had been stripped. This is not needed 10 | # any more with newer versions of delvewheel. 11 | # 12 | 13 | set -o errexit 14 | 15 | # Uncomment this to run cibuildwheel locally on Windows: 16 | # export PATH=$PATH:/c/msys64/usr/bin:/c/msys64/mingw64/bin 17 | 18 | # We cannot use ordinary command line arguments in CI because msys2 -c mangles 19 | # them. Instead we have a batch file to receive the arguments and convert them 20 | # into environment variables before calling this script. When running locally 21 | # this script could be run directly giving the parameters as command line 22 | # arguments instead. 23 | 24 | if [[ -z "${WHEELHOUSE}" ]]; then 25 | WHEELNAME=$1 26 | fi 27 | if [[ -z "${WHEELNAME}" ]]; then 28 | WHEELHOUSE=$2 29 | fi 30 | 31 | echo WHEELHOUSE=$WHEELHOUSE 32 | echo WHEELNAME=$WHEELNAME 33 | 34 | wheeldir=$(dirname $WHEELNAME) 35 | echo $wheeldir 36 | 37 | # delvewheel requires DLLs created by mingw64 to be stripped. This strips the 38 | # DLLs for GMP etc that will have been built in the CIBW_BEFORE_ALL step. 39 | # 40 | # Previously the Arb DLLs would have been placed in .local/lib, but as of 41 | # flint 3.0.0 all DLLs aRe in .local/bin. 42 | strip .local/bin/*.dll 43 | 44 | # Make sure to leave the wheel in the same directory 45 | wheeldir=$(dirname $WHEELNAME) 46 | pushd $wheeldir 47 | # Unpack the wheel and strip any .pyd DLLs inside 48 | wheel unpack $WHEELNAME 49 | rm $WHEELNAME 50 | strip python_flint-*/flint/*.pyd 51 | wheel pack python_flint-* 52 | popd 53 | 54 | # Make the wheel relocatable. This will fail with an error message about 55 | # --no-mangle if strip has not been applied to all mingw64-created .dll and 56 | # .pyd files that are needed for the wheel. 57 | delvewheel repair $WHEELNAME \ 58 | -w $WHEELHOUSE \ 59 | --add-path .local/bin 60 | -------------------------------------------------------------------------------- /bin/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Arguments to this script are passed to python -m flint.test e.g. to skip 4 | # doctests and run in quiet mode: 5 | # 6 | # bin/coverage.sh -qt 7 | # 8 | set -o errexit 9 | 10 | RC="--rcfile=.coveragerc.meson" 11 | 12 | # See https://github.com/cython/cython/issues/6658 13 | # Needed for Python 3.13 only but the plugin does not work with 3.13 anyway... 14 | #pip uninstall -y cython 15 | #pip install git+https://github.com/cython/cython.git@fdbca99 16 | 17 | pip uninstall -y cython 18 | pip install --pre cython # unpinned to pick up new releases in CI 19 | # pip install cython==3.1.0a1 # known working version for Python < 3.13 20 | 21 | meson setup build -Dcoverage=true 22 | spin run -- coverage run $RC -m flint.test $@ 23 | coverage report $RC -m --sort=cover 24 | coverage html $RC 25 | -------------------------------------------------------------------------------- /bin/coverage_setuptools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | RC="--rcfile=.coveragerc.setuptools" 6 | 7 | # Comment out various lines below for speed if running multiple times. 8 | 9 | # See https://github.com/cython/cython/issues/6658 10 | # Needed for Python 3.13 only 11 | pip uninstall -y cython 12 | pip install git+https://github.com/cython/cython.git@fdbca99 13 | pip install setuptools 14 | 15 | touch src/*/*/*.pyx 16 | PYTHON_FLINT_COVERAGE=1 python setup.py build_ext --inplace 17 | PYTHONPATH=src coverage run $RC -m flint.test 18 | coverage report $RC -m --sort=cover 19 | coverage html $RC 20 | -------------------------------------------------------------------------------- /bin/install_flint_ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | 5 | # 6 | # This script should work to build and install Flint from git on Ubuntu 7 | # 8 | # $ git clone https://github.com/flintlib/python-flint.git 9 | # $ cd python-flint 10 | # $ bin/install_flint_ubuntu.sh v3.1.0 11 | # 12 | # The version is a tag or branch in the Flint repository. 13 | # 14 | # Then to install an sdist from PyPI, use 15 | # 16 | # $ pip install python-flint 17 | # 18 | # To install python-flint from the git checkout 19 | # 20 | # $ pip install . 21 | # 22 | 23 | echo "Building from git: $1" 24 | GIT_REF=$1 25 | 26 | # Install runtime and build dependencies 27 | 28 | # First install their dependencies and build dependencies 29 | sudo apt-get update 30 | sudo apt-get install libgmp-dev libmpfr-dev xz-utils ninja-build 31 | 32 | # 33 | # This will default to installing in /usr/local. If you want to install in a 34 | # non-standard location then configure flint with 35 | # ./configure --disable-static --prefix=$PREFIX 36 | # If $PREFIX is not in default search paths, then at build time set 37 | # export C_INCLUDE_PATH=$PREFIX/include 38 | # and at runtime set 39 | # export LD_LIBRARY_PATH=$PREFIX/lib 40 | # 41 | echo "Installing Flint from git: $GIT_REF" 42 | git clone https://github.com/flintlib/flint.git 43 | cd flint 44 | git checkout $GIT_REF 45 | ./bootstrap.sh 46 | ./configure --disable-static 47 | make -j 48 | sudo make install 49 | cd .. 50 | 51 | ls -l /usr/local/lib 52 | sudo ldconfig /usr/local/lib 53 | -------------------------------------------------------------------------------- /bin/install_latest_flint_ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | source bin/build_variables.sh 6 | 7 | sudo apt-get update 8 | sudo apt-get install libgmp-dev libmpfr-dev xz-utils ninja-build 9 | 10 | curl -O -L https://github.com/flintlib/flint/releases/download/v$FLINTVER/flint-$FLINTVER.tar.gz 11 | tar -xzf flint-$FLINTVER.tar.gz 12 | cd flint-$FLINTVER && ./configure --disable-static && make -j$(expr $(nproc) + 1) && sudo make install 13 | 14 | ls -l /usr/local/lib 15 | sudo ldconfig /usr/local/lib 16 | -------------------------------------------------------------------------------- /bin/rtd_before_all_linux.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | apt-get install xz-utils 4 | 5 | bin/build_dependencies_unix.sh\ 6 | --gmp gmp\ 7 | --host x86_64-pc-linux-gnu\ 8 | --use-gmp-github-mirror 9 | -------------------------------------------------------------------------------- /doc/source/_gr.rst: -------------------------------------------------------------------------------- 1 | **_gr** -- generic rings (unstable interface) 2 | =============================================================================== 3 | 4 | .. note:: 5 | This module provides a preliminary experimental interface for FLINT's 6 | generic rings. This is largely untested and the interface should be 7 | considered unstable. In future the generic rings code will be integrated 8 | with the rest of python-flint and this module may be removed. For now it 9 | provides access to many FLINT types that are not wrapped yet in the rest of 10 | python-flint. 11 | 12 | The generic rings module provides access to the generic rings interface in 13 | FLINT. Usage of this interface consists of creating a context object to 14 | represent a particular domain and then using that context object to create 15 | elements of that domain. For example to create a context for polynomials in two 16 | variables over the Gaussian integers :math:`\mathbb{Z}[i][x,y]` we would do:: 17 | 18 | >>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx 19 | >>> ctx = gr_gr_mpoly_ctx.new(gr_fmpzi_ctx, ["x", "y"]) 20 | >>> ctx.gens() 21 | [x, y] 22 | 23 | # XXX: gens_recursive not available in FLINT < 3.1 24 | # >>> ctx.gens_recursive() 25 | # [I, x, y] 26 | # >>> I, x, y = ctx.gens_recursive() 27 | 28 | >>> x, y = ctx.gens() 29 | >>> p = (x + y)**2 30 | >>> p 31 | x^2 + 2*x*y + y^2 32 | 33 | Some domains such as ``gr_fmpzi_ctx`` are global and do not need to be created. 34 | Others such as ``gr_gr_mpoly_ctx`` are created using :meth:`gr_ctx.new`. 35 | 36 | .. autoclass :: flint.types._gr.gr_ctx 37 | :members: 38 | :undoc-members: 39 | 40 | .. autoclass :: flint.types._gr.gr_scalar_ctx 41 | :members: 42 | :undoc-members: 43 | 44 | .. autoclass :: flint.types._gr.gr_poly_ctx 45 | :members: 46 | :undoc-members: 47 | 48 | .. autoclass :: flint.types._gr.gr_mpoly_ctx 49 | :members: 50 | :undoc-members: 51 | 52 | .. autoclass :: flint.types._gr._gr_fmpz_ctx 53 | :members: 54 | :undoc-members: 55 | 56 | .. autoclass :: flint.types._gr._gr_fmpq_ctx 57 | :members: 58 | :undoc-members: 59 | 60 | .. autoclass :: flint.types._gr._gr_fmpzi_ctx 61 | :members: 62 | :undoc-members: 63 | 64 | .. autoclass :: flint.types._gr._gr_fexpr_ctx 65 | :members: 66 | :undoc-members: 67 | 68 | .. autoclass :: flint.types._gr.gr_nmod_ctx 69 | :members: 70 | :undoc-members: 71 | 72 | .. autoclass :: flint.types._gr.gr_fmpz_mod_ctx 73 | :members: 74 | :undoc-members: 75 | 76 | .. autoclass :: flint.types._gr.gr_fq_ctx 77 | :members: 78 | :undoc-members: 79 | 80 | .. autoclass :: flint.types._gr.gr_fq_nmod_ctx 81 | :members: 82 | :undoc-members: 83 | 84 | .. autoclass :: flint.types._gr.gr_fq_zech_ctx 85 | :members: 86 | :undoc-members: 87 | 88 | .. autoclass :: flint.types._gr.gr_nf_ctx 89 | :members: 90 | :undoc-members: 91 | 92 | .. autoclass :: flint.types._gr.gr_nf_fmpz_poly_ctx 93 | :members: 94 | :undoc-members: 95 | 96 | .. autoclass :: flint.types._gr.gr_real_qqbar_ctx 97 | :members: 98 | :undoc-members: 99 | 100 | .. autoclass :: flint.types._gr.gr_complex_qqbar_ctx 101 | :members: 102 | :undoc-members: 103 | 104 | .. autoclass :: flint.types._gr.gr_real_ca_ctx 105 | :members: 106 | :undoc-members: 107 | 108 | .. autoclass :: flint.types._gr.gr_complex_ca_ctx 109 | :members: 110 | :undoc-members: 111 | 112 | .. autoclass :: flint.types._gr.gr_real_algebraic_ca_ctx 113 | :members: 114 | :undoc-members: 115 | 116 | .. autoclass :: flint.types._gr.gr_complex_algebraic_ca_ctx 117 | :members: 118 | :undoc-members: 119 | 120 | .. autoclass :: flint.types._gr.gr_complex_extended_ca_ctx 121 | :members: 122 | :undoc-members: 123 | 124 | .. autoclass :: flint.types._gr.gr_real_float_arf_ctx 125 | :members: 126 | :undoc-members: 127 | 128 | .. autoclass :: flint.types._gr.gr_complex_float_acf_ctx 129 | :members: 130 | :undoc-members: 131 | 132 | .. autoclass :: flint.types._gr.gr_real_arb_ctx 133 | :members: 134 | :undoc-members: 135 | 136 | .. autoclass :: flint.types._gr.gr_complex_acb_ctx 137 | :members: 138 | :undoc-members: 139 | 140 | .. autoclass :: flint.types._gr.gr_gr_poly_ctx 141 | :members: 142 | :undoc-members: 143 | 144 | .. autoclass :: flint.types._gr.gr_gr_mpoly_ctx 145 | :members: 146 | :undoc-members: 147 | 148 | .. autoclass :: flint.types._gr.gr_series_ctx 149 | :members: 150 | :undoc-members: 151 | 152 | .. autoclass :: flint.types._gr.gr 153 | :members: 154 | :inherited-members: 155 | :undoc-members: 156 | -------------------------------------------------------------------------------- /doc/source/_static/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/doc/source/_static/empty -------------------------------------------------------------------------------- /doc/source/acb.rst: -------------------------------------------------------------------------------- 1 | **acb** -- complex numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.acb 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/acb_mat.rst: -------------------------------------------------------------------------------- 1 | **acb_mat** -- matrices over complex numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.acb_mat 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/acb_poly.rst: -------------------------------------------------------------------------------- 1 | **acb_poly** -- polynomials over complex numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.acb_poly 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/acb_series.rst: -------------------------------------------------------------------------------- 1 | **acb_series** -- power series over complex numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.acb_series 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/acb_theta.rst: -------------------------------------------------------------------------------- 1 | **acb_theta** -- Riemann theta functions 2 | =============================================================================== 3 | 4 | .. autofunction :: flint.types.acb_theta.acb_theta 5 | 6 | -------------------------------------------------------------------------------- /doc/source/arb.rst: -------------------------------------------------------------------------------- 1 | **arb** -- real numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.arb 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/arb_mat.rst: -------------------------------------------------------------------------------- 1 | **arb_mat** -- matrices over real numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.arb_mat 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/arb_poly.rst: -------------------------------------------------------------------------------- 1 | **arb_poly** -- polynomials over real numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.arb_poly 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/arb_series.rst: -------------------------------------------------------------------------------- 1 | **arb_series** -- power series over real numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.arb_series 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/dirichlet.rst: -------------------------------------------------------------------------------- 1 | **dirichlet_char** -- Dirichlet characters 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.dirichlet_group 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | .. autoclass :: flint.dirichlet_char 10 | :members: 11 | :inherited-members: 12 | :undoc-members: 13 | 14 | -------------------------------------------------------------------------------- /doc/source/fmpq.rst: -------------------------------------------------------------------------------- 1 | **fmpq** -- rational numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpq 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fmpq_mat.rst: -------------------------------------------------------------------------------- 1 | **fmpq_mat** -- matrices over rational numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpq_mat 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fmpq_mpoly.rst: -------------------------------------------------------------------------------- 1 | **fmpq_mpoly** -- multivariate polynomials over the rational numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpq_mpoly_ctx 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | .. autoclass :: flint.fmpq_mpoly 10 | :members: 11 | :inherited-members: 12 | :undoc-members: 13 | 14 | .. autoclass :: flint.fmpq_mpoly_vec 15 | :members: 16 | :inherited-members: 17 | :undoc-members: 18 | 19 | -------------------------------------------------------------------------------- /doc/source/fmpq_poly.rst: -------------------------------------------------------------------------------- 1 | **fmpq_poly** -- polynomials over rational numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpq_poly 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fmpq_series.rst: -------------------------------------------------------------------------------- 1 | **fmpq_series** -- power series over rational numbers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpq_series 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fmpz.rst: -------------------------------------------------------------------------------- 1 | **fmpz** -- integers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fmpz_mat.rst: -------------------------------------------------------------------------------- 1 | **fmpz_mat** -- matrices over integers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz_mat 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fmpz_mod.rst: -------------------------------------------------------------------------------- 1 | **fmpz_mod** -- integers mod n 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz_mod_ctx 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | .. autoclass :: flint.fmpz_mod 10 | :members: 11 | :inherited-members: 12 | :undoc-members: 13 | 14 | -------------------------------------------------------------------------------- /doc/source/fmpz_mod_mat.rst: -------------------------------------------------------------------------------- 1 | **fmpz_mod_mat** -- matrices over integers mod n for arbitrary n 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz_mod_mat 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fmpz_mod_mpoly.rst: -------------------------------------------------------------------------------- 1 | **fmpz_mod_mpoly** -- multivariate polynomials over the integers mod n 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz_mod_mpoly_ctx 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | .. autoclass :: flint.fmpz_mod_mpoly 10 | :members: 11 | :inherited-members: 12 | :undoc-members: 13 | 14 | .. autoclass :: flint.fmpz_mod_mpoly_vec 15 | :members: 16 | :inherited-members: 17 | :undoc-members: 18 | 19 | -------------------------------------------------------------------------------- /doc/source/fmpz_mod_poly.rst: -------------------------------------------------------------------------------- 1 | **fmpz_mod_poly** -- polynomials over integers mod n 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz_mod_poly_ctx 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | .. autoclass :: flint.fmpz_mod_poly 10 | :members: 11 | :inherited-members: 12 | :undoc-members: 13 | 14 | -------------------------------------------------------------------------------- /doc/source/fmpz_mpoly.rst: -------------------------------------------------------------------------------- 1 | **fmpz_mpoly** -- multivariate polynomials over the integers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz_mpoly_ctx 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | .. autoclass :: flint.fmpz_mpoly 10 | :members: 11 | :inherited-members: 12 | :undoc-members: 13 | 14 | .. autoclass :: flint.fmpz_mpoly_vec 15 | :members: 16 | :inherited-members: 17 | :undoc-members: 18 | 19 | -------------------------------------------------------------------------------- /doc/source/fmpz_poly.rst: -------------------------------------------------------------------------------- 1 | **fmpz_poly** -- polynomials over integers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz_poly 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fmpz_series.rst: -------------------------------------------------------------------------------- 1 | **fmpz_series** -- power series over integers 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fmpz_series 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fq_default.rst: -------------------------------------------------------------------------------- 1 | **fq_default** -- finite fields 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fq_default 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/fq_default_poly.rst: -------------------------------------------------------------------------------- 1 | **fq_default_poly** -- polynomials over finite fields 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.fq_default_poly_ctx 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | .. autoclass :: flint.fq_default_poly 10 | :members: 11 | :inherited-members: 12 | :undoc-members: 13 | 14 | -------------------------------------------------------------------------------- /doc/source/index.rst: -------------------------------------------------------------------------------- 1 | .. python-flint documentation master file, created by 2 | sphinx-quickstart on Wed Jul 18 11:49:46 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Python-FLINT 7 | ========================================================== 8 | 9 | Python extension module wrapping FLINT_ (Fast Library for Number Theory) 10 | and Arb_ (arbitrary-precision ball arithmetic). Features: 11 | 12 | .. _FLINT: http://flintlib.org/ 13 | .. _Arb: http://arblib.org/ 14 | 15 | 16 | * Integers, rationals, integers mod n 17 | * Real and complex numbers with rigorous error tracking 18 | * Polynomials and matrices over all the above types 19 | * Lots of mathematical functions 20 | 21 | Author: `Fredrik Johansson `_ 22 | 23 | Repository: https://github.com/flintlib/python-flint/ 24 | 25 | Introduction 26 | ------------ 27 | 28 | .. toctree:: 29 | :maxdepth: 2 30 | 31 | install.rst 32 | general.rst 33 | build.rst 34 | workflow.rst 35 | 36 | 37 | Reference 38 | --------- 39 | 40 | Scalar types 41 | ............ 42 | 43 | .. toctree:: 44 | :maxdepth: 1 45 | 46 | fmpz.rst 47 | fmpq.rst 48 | fmpz_mod.rst 49 | nmod.rst 50 | fq_default.rst 51 | arb.rst 52 | acb.rst 53 | dirichlet.rst 54 | 55 | Matrix types 56 | ............ 57 | 58 | .. toctree:: 59 | :maxdepth: 1 60 | 61 | fmpz_mat.rst 62 | fmpq_mat.rst 63 | nmod_mat.rst 64 | fmpz_mod_mat.rst 65 | arb_mat.rst 66 | acb_mat.rst 67 | acb_theta.rst 68 | 69 | Polynomial types 70 | ................ 71 | 72 | .. toctree:: 73 | :maxdepth: 1 74 | 75 | fmpz_poly.rst 76 | fmpz_mpoly.rst 77 | fmpq_poly.rst 78 | fmpq_mpoly.rst 79 | nmod_poly.rst 80 | nmod_mpoly.rst 81 | fmpz_mod_poly.rst 82 | fmpz_mod_mpoly.rst 83 | fq_default_poly.rst 84 | arb_poly.rst 85 | acb_poly.rst 86 | 87 | Power series types 88 | .................. 89 | 90 | .. toctree:: 91 | :maxdepth: 1 92 | 93 | fmpz_series.rst 94 | fmpq_series.rst 95 | nmod_series.rst 96 | arb_series.rst 97 | acb_series.rst 98 | 99 | Experimental generic rings interface 100 | .................................... 101 | 102 | .. toctree:: 103 | :maxdepth: 2 104 | 105 | _gr.rst 106 | -------------------------------------------------------------------------------- /doc/source/nmod.rst: -------------------------------------------------------------------------------- 1 | **nmod** -- integers mod wordsize n 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.nmod 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/nmod_mat.rst: -------------------------------------------------------------------------------- 1 | **nmod_mat** -- matrices over integers mod n 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.nmod_mat 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/nmod_mpoly.rst: -------------------------------------------------------------------------------- 1 | **nmod_mpoly** -- multivariate polynomials over the integers mod n (word-size n) 2 | ================================================================================ 3 | 4 | .. autoclass :: flint.nmod_mpoly_ctx 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | .. autoclass :: flint.nmod_mpoly 10 | :members: 11 | :inherited-members: 12 | :undoc-members: 13 | 14 | .. autoclass :: flint.nmod_mpoly_vec 15 | :members: 16 | :inherited-members: 17 | :undoc-members: 18 | 19 | -------------------------------------------------------------------------------- /doc/source/nmod_poly.rst: -------------------------------------------------------------------------------- 1 | **nmod_poly** -- polynomials over integers mod n 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.nmod_poly 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /doc/source/nmod_series.rst: -------------------------------------------------------------------------------- 1 | **nmod_series** -- power series over integers mod n 2 | =============================================================================== 3 | 4 | .. autoclass :: flint.nmod_series 5 | :members: 6 | :inherited-members: 7 | :undoc-members: 8 | 9 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project( 2 | 'python-flint', 3 | 'cython', 4 | 'c', 5 | meson_version : '>=1.1', 6 | ) 7 | # 8 | # The minimum versions are because we know that it will not work with earlier 9 | # versions. The maximum versions are because python-flint was not tested 10 | # against future versions that didn't exist at the time of release. In future 11 | # if it seems like new releases do not always break the build of python-flint 12 | # then we can consider not using a speculative upper version cap here. 13 | # 14 | flint_lower = '>=3.0' 15 | flint_upper = '<3.3' 16 | cython_lower = '>=3.0.11' 17 | cython_upper = '<3.2' 18 | 19 | py = import('python').find_installation(pure: false) 20 | dep_py = py.dependency() 21 | 22 | cc = meson.get_compiler('c') 23 | cy = meson.get_compiler('cython') 24 | 25 | gmp_dep = dependency('gmp') 26 | mpfr_dep = dependency('mpfr') 27 | flint_dep = dependency('flint') 28 | 29 | # 30 | # For the source release, we should by default fail for new untested versions 31 | # with a clear error message about the version mismatch. 32 | # 33 | # We need an option to disable this though so that we can test newer versions 34 | # of Flint. Also good to have an escape hatch for users since we don't know 35 | # that future versions of Flint will not work. 36 | # 37 | ver_message = ''' 38 | 39 | Invalid @0@ version: 40 | Version needed is: @0@ @2@, @3@ 41 | Version found is: @0@ == @1@ 42 | 43 | By default, python-flint will only build against @0@ versions that have 44 | been tested. If you are sure you want to use this version of @0@, you can 45 | disable this check with -Dflint_version_check=false. 46 | 47 | If building from the source directory using meson directly, you can do this 48 | with: 49 | 50 | meson setup build -Dflint_version_check=false 51 | 52 | If you are installing with pip, you can do this with: 53 | 54 | pip install --config-settings=setup-args="-Dflint_version_check=false" python-flint 55 | 56 | Other build frontends have similar options for passing this to meson. 57 | 58 | ''' 59 | if get_option('flint_version_check') 60 | if not (flint_dep.version().version_compare(flint_lower) and 61 | flint_dep.version().version_compare(flint_upper)) 62 | error(ver_message.format('FLINT', flint_dep.version(), flint_lower, flint_upper)) 63 | endif 64 | if not (cy.version().version_compare(cython_lower) and 65 | cy.version().version_compare(cython_upper)) 66 | error(ver_message.format('Cython', cy.version(), cython_lower, cython_upper)) 67 | endif 68 | endif 69 | 70 | # flint.pc was missing -lflint until Flint 3.1.0 71 | if flint_dep.version().version_compare('<3.1') 72 | flint_dep = cc.find_library('flint') 73 | have_acb_theta = false 74 | else 75 | have_acb_theta = true 76 | endif 77 | 78 | pyflint_deps = [dep_py, gmp_dep, mpfr_dep, flint_dep] 79 | 80 | add_project_arguments( 81 | '-X', 'embedsignature=True', 82 | '-X', 'emit_code_comments=True', 83 | language : 'cython' 84 | ) 85 | 86 | # Enable free-threading if Cython is new enough. The check should be 87 | # >= 3.1.0a1 but meson gets confused by the a1 alpha release suffix. 88 | # so we go with >= 3.1 (which will be correct once 3.1 is released). 89 | cy = meson.get_compiler('cython') 90 | if cy.version().version_compare('>=3.1') 91 | message('Enabling freethreading') 92 | add_project_arguments('-Xfreethreading_compatible=true', language : 'cython') 93 | else 94 | message('Disabling freethreading') 95 | endif 96 | 97 | if get_option('coverage') 98 | add_project_arguments('-X', 'linetrace=True', language : 'cython') 99 | add_project_arguments('-DCYTHON_TRACE=1', language : 'c') 100 | endif 101 | 102 | # Add rpaths for a local build of flint found via pkgconfig 103 | # https://github.com/mesonbuild/meson/issues/13046 104 | if get_option('add_flint_rpath') 105 | flint_lib_dir = flint_dep.get_variable(pkgconfig: 'libdir') 106 | add_project_link_arguments( 107 | '-Wl,-rpath=' + flint_lib_dir, 108 | language: 'c', 109 | ) 110 | endif 111 | 112 | subdir('src/flint') 113 | -------------------------------------------------------------------------------- /meson.options: -------------------------------------------------------------------------------- 1 | option('coverage', type : 'boolean', value : false, description : 'enable coverage build') 2 | option('add_flint_rpath', type : 'boolean', value : false) 3 | option('flint_version_check', type: 'boolean', value : true) 4 | -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | cython 2 | ninja 3 | spin 4 | meson 5 | meson-python 6 | pytest 7 | coverage 8 | pytest-cov 9 | sphinx 10 | sphinx-rtd-theme 11 | furo 12 | -------------------------------------------------------------------------------- /src/flint/__init__.py: -------------------------------------------------------------------------------- 1 | from .pyflint import * 2 | 3 | from .types.fmpz import * 4 | from .types.fmpz_poly import * 5 | from .types.fmpz_mat import * 6 | from .types.fmpz_series import * 7 | from .types.fmpz_vec import fmpz_vec 8 | 9 | from .types.fmpq import * 10 | from .types.fmpq_poly import * 11 | from .types.fmpq_mat import * 12 | from .types.fmpq_series import * 13 | from .types.fmpq_vec import fmpq_vec 14 | 15 | from .types.nmod import * 16 | from .types.nmod_poly import * 17 | from .types.nmod_mpoly import nmod_mpoly_ctx, nmod_mpoly, nmod_mpoly_vec 18 | from .types.nmod_mat import * 19 | from .types.nmod_series import * 20 | 21 | from .types.fmpz_mpoly import fmpz_mpoly_ctx, fmpz_mpoly, fmpz_mpoly_vec 22 | from .types.fmpz_mod import * 23 | from .types.fmpz_mod_poly import * 24 | from .types.fmpz_mod_mpoly import fmpz_mod_mpoly_ctx, fmpz_mod_mpoly, fmpz_mod_mpoly_vec 25 | from .types.fmpz_mod_mat import fmpz_mod_mat 26 | 27 | from .types.fmpq_mpoly import fmpq_mpoly_ctx, fmpq_mpoly, fmpq_mpoly_vec 28 | 29 | from .types.fq_default import * 30 | from .types.fq_default_poly import * 31 | 32 | from .types.arf import * 33 | from .types.arb import * 34 | from .types.arb_poly import * 35 | from .types.arb_mat import * 36 | from .types.arb_series import * 37 | from .types.acb import * 38 | from .types.acb_poly import * 39 | from .types.acb_mat import * 40 | from .types.acb_series import * 41 | 42 | from .types.dirichlet import * 43 | from .functions.showgood import good, showgood 44 | 45 | from .flint_base.flint_base import ( 46 | FLINT_VERSION as __FLINT_VERSION__, 47 | FLINT_RELEASE as __FLINT_RELEASE__, 48 | Ordering, 49 | ) 50 | 51 | __version__ = '0.7.1' 52 | -------------------------------------------------------------------------------- /src/flint/flint_base/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/flint_base/__init__.py -------------------------------------------------------------------------------- /src/flint/flint_base/flint_base.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.mpoly cimport ordering_t 2 | from flint.flintlib.types.flint cimport slong 3 | 4 | cdef class flint_ctx: 5 | pass 6 | 7 | cdef class flint_elem: 8 | pass 9 | 10 | cdef class flint_scalar(flint_elem): 11 | pass 12 | 13 | cdef class flint_poly(flint_elem): 14 | pass 15 | 16 | cdef class flint_mpoly_context(flint_elem): 17 | cdef public object py_names 18 | cdef const char ** c_names 19 | 20 | cdef class flint_mod_mpoly_context(flint_mpoly_context): 21 | cdef readonly bint __prime_modulus 22 | 23 | cdef class flint_mpoly(flint_elem): 24 | cdef _add_scalar_(self, other) 25 | cdef _sub_scalar_(self, other) 26 | cdef _mul_scalar_(self, other) 27 | 28 | cdef _add_mpoly_(self, other) 29 | cdef _sub_mpoly_(self, other) 30 | cdef _mul_mpoly_(self, other) 31 | 32 | cdef _divmod_mpoly_(self, other) 33 | cdef _truediv_scalar_(self, other) 34 | cdef _divexact_scalar_(self, other) 35 | cdef _floordiv_mpoly_(self, other) 36 | cdef _truediv_mpoly_(self, other) 37 | cdef _mod_mpoly_(self, other) 38 | 39 | cdef _rsub_scalar_(self, other) 40 | cdef _rsub_mpoly_(self, other) 41 | 42 | cdef _rdivmod_mpoly_(self, other) 43 | cdef _rfloordiv_mpoly_(self, other) 44 | cdef _rtruediv_mpoly_(self, other) 45 | cdef _rmod_mpoly_(self, other) 46 | 47 | cdef _pow_(self, other) 48 | 49 | cdef _iadd_scalar_(self, other) 50 | cdef _isub_scalar_(self, other) 51 | cdef _imul_scalar_(self, other) 52 | 53 | cdef _iadd_mpoly_(self, other) 54 | cdef _isub_mpoly_(self, other) 55 | cdef _imul_mpoly_(self, other) 56 | 57 | cdef _compose_gens_(self, ctx, slong *mapping) 58 | 59 | cdef class flint_mat(flint_elem): 60 | pass 61 | 62 | cdef class flint_series(flint_elem): 63 | pass 64 | 65 | cdef ordering_t ordering_py_to_c(ordering) 66 | cdef ordering_c_to_py(ordering_t ordering) 67 | -------------------------------------------------------------------------------- /src/flint/flint_base/flint_context.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.arf cimport ( 2 | arf_rnd_t, 3 | ) 4 | 5 | cdef class FlintContext: 6 | cdef public bint pretty 7 | cdef public long _prec 8 | cdef public long _dps 9 | cdef arf_rnd_t rnd 10 | cdef public bint unicode 11 | cdef public long _cap 12 | 13 | cdef FlintContext thectx 14 | 15 | cdef inline long getprec(long prec=0): 16 | if prec > 1: 17 | return prec 18 | else: 19 | return thectx._prec 20 | 21 | cdef inline long getcap(long cap=-1): 22 | if cap >= 0: 23 | return cap 24 | else: 25 | return thectx._cap 26 | -------------------------------------------------------------------------------- /src/flint/flint_base/meson.build: -------------------------------------------------------------------------------- 1 | pkgdir = 'flint/flint_base' 2 | 3 | pyfiles = [ 4 | '__init__.py', 5 | ] 6 | 7 | exts = [ 8 | 'flint_base', 9 | 'flint_context', 10 | ] 11 | 12 | py.install_sources( 13 | pyfiles, 14 | pure: false, 15 | subdir: pkgdir, 16 | ) 17 | 18 | foreach ext : exts 19 | py.extension_module( 20 | ext, 21 | ext + '.pyx', 22 | dependencies: pyflint_deps, 23 | install: true, 24 | subdir: pkgdir, 25 | ) 26 | endforeach 27 | -------------------------------------------------------------------------------- /src/flint/flintlib/README.md: -------------------------------------------------------------------------------- 1 | Cython declarations for functions exported by libflint 2 | ====================================================== 3 | 4 | This directory contains Cython declarations for functions exported by libflint. 5 | The declarations under the `types` directory are for the types defined in 6 | libflint and are hand-written. The declarations under the `functions` directory 7 | are for the functions defined in libflint and are generated by running: 8 | ```console 9 | $ bin/all_rst_to_pxd.sh /path/to/flint/doc/source 10 | ``` 11 | where `/path/to/flint/doc/source` is the path to the source directory of the 12 | flint documentation. This command should always be run on the FLINT docs of the 13 | version of FLINT that is used by default in python-flint's wheels which is the 14 | version shown in the `bin/build_variables.sh` script. Typically this just means 15 | the latest released version of FLINT. 16 | 17 | It is important not to edit any of the files in `functions` manually because a 18 | subsequent run of `bin/all_rst_to_pxd.sh` will overwrite them. There are 19 | several reasons why manual editing may be needed but usually it is because 20 | either: 21 | 22 | 1. The function is not documented in the FLINT docs. 23 | 2. The function is a macro and not a function. 24 | 25 | In either case, we need to manually write the declaration for the function but 26 | it cannot be done in the `functions` directory. Instead, it should be added 27 | somewhere in the `types` directory. 28 | 29 | Generally undocumented functions should be reported/fixed upstream in FLINT. 30 | 31 | It might be better to list macros (and undocumented functions) in the 32 | `bin/rst_to_pxd.py` script so that it can add them to the generated files 33 | automatically. Then we can keep them out of the hand-written code but also keep 34 | track of them with a goal of eventually getting all of them added to the FLINT 35 | docs. 36 | -------------------------------------------------------------------------------- /src/flint/flintlib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/flintlib/__init__.py -------------------------------------------------------------------------------- /src/flint/flintlib/functions/__init__.pxd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/flintlib/functions/__init__.pxd -------------------------------------------------------------------------------- /src/flint/flintlib/functions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/flintlib/functions/__init__.py -------------------------------------------------------------------------------- /src/flint/flintlib/functions/acb_calc.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.acb cimport acb_t 2 | from flint.flintlib.types.acb_calc cimport acb_calc_func_t, acb_calc_integrate_opt_t 3 | from flint.flintlib.types.arb cimport arb_t, mag_t 4 | from flint.flintlib.types.arf cimport arf_t 5 | from flint.flintlib.types.flint cimport slong 6 | 7 | 8 | 9 | cdef extern from "flint/acb_calc.h": 10 | int acb_calc_integrate(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, slong rel_goal, const mag_t abs_tol, const acb_calc_integrate_opt_t options, slong prec) 11 | void acb_calc_integrate_opt_init(acb_calc_integrate_opt_t options) 12 | int acb_calc_integrate_gl_auto_deg(acb_t res, slong * num_eval, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const mag_t tol, slong deg_limit, int flags, slong prec) 13 | void acb_calc_cauchy_bound(arb_t bound, acb_calc_func_t func, void * param, const acb_t x, const arb_t radius, slong maxdepth, slong prec) 14 | int acb_calc_integrate_taylor(acb_t res, acb_calc_func_t func, void * param, const acb_t a, const acb_t b, const arf_t inner_radius, const arf_t outer_radius, slong accuracy_goal, slong prec) 15 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/acb_dft.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.acb cimport acb_ptr, acb_srcptr 2 | from flint.flintlib.types.flint cimport slong 3 | 4 | # unknown type acb_dft_bluestein_t 5 | # unknown type acb_dft_crt_t 6 | # unknown type acb_dft_cyc_t 7 | # unknown type acb_dft_naive_t 8 | # unknown type acb_dft_pre_t 9 | # unknown type acb_dft_prod_t 10 | # unknown type acb_dft_rad2_t 11 | 12 | 13 | cdef extern from "flint/acb_dft.h": 14 | void acb_dft(acb_ptr w, acb_srcptr v, slong n, slong prec) 15 | void acb_dft_inverse(acb_ptr w, acb_srcptr v, slong n, slong prec) 16 | # void acb_dft_precomp_init(acb_dft_pre_t pre, slong len, slong prec) 17 | # void acb_dft_precomp_clear(acb_dft_pre_t pre) 18 | # void acb_dft_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) 19 | # void acb_dft_inverse_precomp(acb_ptr w, acb_srcptr v, const acb_dft_pre_t pre, slong prec) 20 | void acb_dirichlet_dft_prod(acb_ptr w, acb_srcptr v, slong * cyc, slong num, slong prec) 21 | # void acb_dft_prod_init(acb_dft_prod_t t, slong * cyc, slong num, slong prec) 22 | # void acb_dft_prod_clear(acb_dft_prod_t t) 23 | # void acb_dirichlet_dft_prod_precomp(acb_ptr w, acb_srcptr v, const acb_dft_prod_t prod, slong prec) 24 | void acb_dft_convol_naive(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) 25 | void acb_dft_convol_rad2(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) 26 | void acb_dft_convol(acb_ptr w, acb_srcptr f, acb_srcptr g, slong len, slong prec) 27 | void acb_dft_naive(acb_ptr w, acb_srcptr v, slong n, slong prec) 28 | # void acb_dft_naive_init(acb_dft_naive_t t, slong len, slong prec) 29 | # void acb_dft_naive_clear(acb_dft_naive_t t) 30 | # void acb_dft_naive_precomp(acb_ptr w, acb_srcptr v, const acb_dft_naive_t t, slong prec) 31 | void acb_dft_crt(acb_ptr w, acb_srcptr v, slong n, slong prec) 32 | # void acb_dft_crt_init(acb_dft_crt_t t, slong len, slong prec) 33 | # void acb_dft_crt_clear(acb_dft_crt_t t) 34 | # void acb_dft_crt_precomp(acb_ptr w, acb_srcptr v, const acb_dft_crt_t t, slong prec) 35 | void acb_dft_cyc(acb_ptr w, acb_srcptr v, slong n, slong prec) 36 | # void acb_dft_cyc_init(acb_dft_cyc_t t, slong len, slong prec) 37 | # void acb_dft_cyc_clear(acb_dft_cyc_t t) 38 | # void acb_dft_cyc_precomp(acb_ptr w, acb_srcptr v, const acb_dft_cyc_t t, slong prec) 39 | void acb_dft_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) 40 | void acb_dft_inverse_rad2(acb_ptr w, acb_srcptr v, int e, slong prec) 41 | # void acb_dft_rad2_init(acb_dft_rad2_t t, int e, slong prec) 42 | # void acb_dft_rad2_clear(acb_dft_rad2_t t) 43 | # void acb_dft_rad2_precomp(acb_ptr w, acb_srcptr v, const acb_dft_rad2_t t, slong prec) 44 | void acb_dft_bluestein(acb_ptr w, acb_srcptr v, slong n, slong prec) 45 | # void acb_dft_bluestein_init(acb_dft_bluestein_t t, slong len, slong prec) 46 | # void acb_dft_bluestein_clear(acb_dft_bluestein_t t) 47 | # void acb_dft_bluestein_precomp(acb_ptr w, acb_srcptr v, const acb_dft_bluestein_t t, slong prec) 48 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/acb_elliptic.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.acb cimport acb_poly_t, acb_ptr, acb_srcptr, acb_t 2 | from flint.flintlib.types.flint cimport slong 3 | 4 | 5 | 6 | cdef extern from "flint/acb_elliptic.h": 7 | void acb_elliptic_k(acb_t res, const acb_t m, slong prec) 8 | void acb_elliptic_k_jet(acb_ptr res, const acb_t m, slong len, slong prec) 9 | void _acb_elliptic_k_series(acb_ptr res, acb_srcptr m, slong mlen, slong len, slong prec) 10 | void acb_elliptic_k_series(acb_poly_t res, const acb_poly_t m, slong len, slong prec) 11 | void acb_elliptic_e(acb_t res, const acb_t m, slong prec) 12 | void acb_elliptic_pi(acb_t res, const acb_t n, const acb_t m, slong prec) 13 | void acb_elliptic_f(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) 14 | void acb_elliptic_e_inc(acb_t res, const acb_t phi, const acb_t m, int pi, slong prec) 15 | void acb_elliptic_pi_inc(acb_t res, const acb_t n, const acb_t phi, const acb_t m, int pi, slong prec) 16 | void acb_elliptic_rf(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) 17 | void acb_elliptic_rg(acb_t res, const acb_t x, const acb_t y, const acb_t z, int flags, slong prec) 18 | void acb_elliptic_rj(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) 19 | void acb_elliptic_rj_carlson(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) 20 | void acb_elliptic_rj_integration(acb_t res, const acb_t x, const acb_t y, const acb_t z, const acb_t p, int flags, slong prec) 21 | void acb_elliptic_rc1(acb_t res, const acb_t x, slong prec) 22 | void acb_elliptic_p(acb_t res, const acb_t z, const acb_t tau, slong prec) 23 | void acb_elliptic_p_prime(acb_t res, const acb_t z, const acb_t tau, slong prec) 24 | void acb_elliptic_p_jet(acb_ptr res, const acb_t z, const acb_t tau, slong len, slong prec) 25 | void _acb_elliptic_p_series(acb_ptr res, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) 26 | void acb_elliptic_p_series(acb_poly_t res, const acb_poly_t z, const acb_t tau, slong len, slong prec) 27 | void acb_elliptic_invariants(acb_t g2, acb_t g3, const acb_t tau, slong prec) 28 | void acb_elliptic_roots(acb_t e1, acb_t e2, acb_t e3, const acb_t tau, slong prec) 29 | void acb_elliptic_inv_p(acb_t res, const acb_t z, const acb_t tau, slong prec) 30 | void acb_elliptic_zeta(acb_t res, const acb_t z, const acb_t tau, slong prec) 31 | void acb_elliptic_sigma(acb_t res, const acb_t z, const acb_t tau, slong prec) 32 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/acb_modular.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.acb cimport acb_poly_t, acb_ptr, acb_srcptr, acb_t 2 | from flint.flintlib.types.arf cimport arf_t 3 | from flint.flintlib.types.flint cimport flint_rand_t, slong 4 | from flint.flintlib.types.fmpz cimport fmpz_poly_t 5 | 6 | # unknown type FILE 7 | # unknown type psl2z_t 8 | 9 | 10 | cdef extern from "flint/acb_modular.h": 11 | # void psl2z_init(psl2z_t g) 12 | # void psl2z_clear(psl2z_t g) 13 | # void psl2z_swap(psl2z_t f, psl2z_t g) 14 | # void psl2z_set(psl2z_t f, const psl2z_t g) 15 | # void psl2z_one(psl2z_t g) 16 | # int psl2z_is_one(const psl2z_t g) 17 | # void psl2z_print(const psl2z_t g) 18 | # void psl2z_fprint(FILE * file, const psl2z_t g) 19 | # int psl2z_equal(const psl2z_t f, const psl2z_t g) 20 | # void psl2z_mul(psl2z_t h, const psl2z_t f, const psl2z_t g) 21 | # void psl2z_inv(psl2z_t h, const psl2z_t g) 22 | # int psl2z_is_correct(const psl2z_t g) 23 | # void psl2z_randtest(psl2z_t g, flint_rand_t state, slong bits) 24 | # void acb_modular_transform(acb_t w, const psl2z_t g, const acb_t z, slong prec) 25 | # void acb_modular_fundamental_domain_approx_d(psl2z_t g, double x, double y, double one_minus_eps) 26 | # void acb_modular_fundamental_domain_approx_arf(psl2z_t g, const arf_t x, const arf_t y, const arf_t one_minus_eps, slong prec) 27 | # void acb_modular_fundamental_domain_approx(acb_t w, psl2z_t g, const acb_t z, const arf_t one_minus_eps, slong prec) 28 | int acb_modular_is_in_fundamental_domain(const acb_t z, const arf_t tol, slong prec) 29 | void acb_modular_fill_addseq(slong * tab, slong len) 30 | # void acb_modular_theta_transform(int * R, int * S, int * C, const psl2z_t g) 31 | void acb_modular_addseq_theta(slong * exponents, slong * aindex, slong * bindex, slong num) 32 | void acb_modular_theta_sum(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t w, int w_is_unit, const acb_t q, slong len, slong prec) 33 | void acb_modular_theta_const_sum_basecase(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) 34 | void acb_modular_theta_const_sum_rs(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong N, slong prec) 35 | void acb_modular_theta_const_sum(acb_t theta2, acb_t theta3, acb_t theta4, const acb_t q, slong prec) 36 | void acb_modular_theta_notransform(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) 37 | void acb_modular_theta(acb_t theta1, acb_t theta2, acb_t theta3, acb_t theta4, const acb_t z, const acb_t tau, slong prec) 38 | void acb_modular_theta_jet_notransform(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) 39 | void acb_modular_theta_jet(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, const acb_t z, const acb_t tau, slong len, slong prec) 40 | void _acb_modular_theta_series(acb_ptr theta1, acb_ptr theta2, acb_ptr theta3, acb_ptr theta4, acb_srcptr z, slong zlen, const acb_t tau, slong len, slong prec) 41 | void acb_modular_theta_series(acb_poly_t theta1, acb_poly_t theta2, acb_poly_t theta3, acb_poly_t theta4, const acb_poly_t z, const acb_t tau, slong len, slong prec) 42 | void acb_modular_addseq_eta(slong * exponents, slong * aindex, slong * bindex, slong num) 43 | void acb_modular_eta_sum(acb_t eta, const acb_t q, slong prec) 44 | # int acb_modular_epsilon_arg(const psl2z_t g) 45 | void acb_modular_eta(acb_t r, const acb_t tau, slong prec) 46 | void acb_modular_j(acb_t r, const acb_t tau, slong prec) 47 | void acb_modular_lambda(acb_t r, const acb_t tau, slong prec) 48 | void acb_modular_delta(acb_t r, const acb_t tau, slong prec) 49 | void acb_modular_eisenstein(acb_ptr r, const acb_t tau, slong len, slong prec) 50 | void acb_modular_elliptic_k(acb_t w, const acb_t m, slong prec) 51 | void acb_modular_elliptic_k_cpx(acb_ptr w, const acb_t m, slong len, slong prec) 52 | void acb_modular_elliptic_e(acb_t w, const acb_t m, slong prec) 53 | void acb_modular_elliptic_p(acb_t wp, const acb_t z, const acb_t tau, slong prec) 54 | void acb_modular_elliptic_p_zpx(acb_ptr wp, const acb_t z, const acb_t tau, slong len, slong prec) 55 | void acb_modular_hilbert_class_poly(fmpz_poly_t res, slong D) 56 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/arb_fmpz_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.acb cimport acb_ptr, acb_t 2 | from flint.flintlib.types.arb cimport arb_t 3 | from flint.flintlib.types.flint cimport fmpz_struct, slong, ulong 4 | from flint.flintlib.types.fmpz cimport fmpz_poly_t 5 | 6 | 7 | 8 | cdef extern from "flint/arb_fmpz_poly.h": 9 | void _arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_struct * poly, slong len, const arb_t x, slong prec) 10 | void arb_fmpz_poly_evaluate_arb_horner(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) 11 | void _arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_struct * poly, slong len, const arb_t x, slong prec) 12 | void arb_fmpz_poly_evaluate_arb_rectangular(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) 13 | void _arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_struct * poly, slong len, const arb_t x, slong prec) 14 | void arb_fmpz_poly_evaluate_arb(arb_t res, const fmpz_poly_t poly, const arb_t x, slong prec) 15 | void _arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_struct * poly, slong len, const acb_t x, slong prec) 16 | void arb_fmpz_poly_evaluate_acb_horner(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) 17 | void _arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_struct * poly, slong len, const acb_t x, slong prec) 18 | void arb_fmpz_poly_evaluate_acb_rectangular(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) 19 | void _arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_struct * poly, slong len, const acb_t x, slong prec) 20 | void arb_fmpz_poly_evaluate_acb(acb_t res, const fmpz_poly_t poly, const acb_t x, slong prec) 21 | ulong arb_fmpz_poly_deflation(const fmpz_poly_t poly) 22 | void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, ulong deflation) 23 | void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, slong prec) 24 | void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, ulong q, ulong n) 25 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/arith.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_struct, fmpz_t, nmod_t, nn_ptr, slong, ulong 2 | from flint.flintlib.types.fmpq cimport fmpq_poly_t, fmpq_struct, fmpq_t 3 | from flint.flintlib.types.fmpz cimport fmpz_mat_t, fmpz_poly_t 4 | 5 | # unknown type mpfr_t 6 | # unknown type trig_prod_t 7 | 8 | 9 | cdef extern from "flint/arith.h": 10 | void _arith_harmonic_number(fmpz_t num, fmpz_t den, slong n) 11 | void arith_harmonic_number(fmpq_t x, slong n) 12 | void arith_stirling_number_1u(fmpz_t s, ulong n, ulong k) 13 | void arith_stirling_number_1(fmpz_t s, ulong n, ulong k) 14 | void arith_stirling_number_2(fmpz_t s, ulong n, ulong k) 15 | void arith_stirling_number_1u_vec(fmpz_struct * row, ulong n, slong klen) 16 | void arith_stirling_number_1_vec(fmpz_struct * row, ulong n, slong klen) 17 | void arith_stirling_number_2_vec(fmpz_struct * row, ulong n, slong klen) 18 | void arith_stirling_number_1u_vec_next(fmpz_struct * row, const fmpz_struct * prev, slong n, slong klen) 19 | void arith_stirling_number_1_vec_next(fmpz_struct * row, const fmpz_struct * prev, slong n, slong klen) 20 | void arith_stirling_number_2_vec_next(fmpz_struct * row, const fmpz_struct * prev, slong n, slong klen) 21 | void arith_stirling_matrix_1u(fmpz_mat_t mat) 22 | void arith_stirling_matrix_1(fmpz_mat_t mat) 23 | void arith_stirling_matrix_2(fmpz_mat_t mat) 24 | void arith_bell_number(fmpz_t b, ulong n) 25 | void arith_bell_number_dobinski(fmpz_t res, ulong n) 26 | void arith_bell_number_multi_mod(fmpz_t res, ulong n) 27 | void arith_bell_number_vec(fmpz_struct * b, slong n) 28 | void arith_bell_number_vec_recursive(fmpz_struct * b, slong n) 29 | void arith_bell_number_vec_multi_mod(fmpz_struct * b, slong n) 30 | ulong arith_bell_number_nmod(ulong n, nmod_t mod) 31 | void arith_bell_number_nmod_vec(nn_ptr b, slong n, nmod_t mod) 32 | void arith_bell_number_nmod_vec_recursive(nn_ptr b, slong n, nmod_t mod) 33 | void arith_bell_number_nmod_vec_ogf(nn_ptr b, slong n, nmod_t mod) 34 | int arith_bell_number_nmod_vec_series(nn_ptr b, slong n, nmod_t mod) 35 | double arith_bell_number_size(ulong n) 36 | void _arith_bernoulli_number(fmpz_t num, fmpz_t den, ulong n) 37 | void arith_bernoulli_number(fmpq_t x, ulong n) 38 | void _arith_bernoulli_number_vec(fmpz_struct * num, fmpz_struct * den, slong n) 39 | void arith_bernoulli_number_vec(fmpq_struct * x, slong n) 40 | void arith_bernoulli_number_denom(fmpz_t den, ulong n) 41 | double arith_bernoulli_number_size(ulong n) 42 | void arith_bernoulli_polynomial(fmpq_poly_t poly, ulong n) 43 | void _arith_bernoulli_number_vec_recursive(fmpz_struct * num, fmpz_struct * den, slong n) 44 | void _arith_bernoulli_number_vec_multi_mod(fmpz_struct * num, fmpz_struct * den, slong n) 45 | void arith_euler_number(fmpz_t res, ulong n) 46 | void arith_euler_number_vec(fmpz_struct * res, slong n) 47 | double arith_euler_number_size(ulong n) 48 | void arith_euler_polynomial(fmpq_poly_t poly, ulong n) 49 | void arith_divisors(fmpz_poly_t res, const fmpz_t n) 50 | void arith_ramanujan_tau(fmpz_t res, const fmpz_t n) 51 | void arith_ramanujan_tau_series(fmpz_poly_t res, slong n) 52 | void arith_landau_function_vec(fmpz_struct * res, slong len) 53 | void arith_number_of_partitions_vec(fmpz_struct * res, slong len) 54 | void arith_number_of_partitions_nmod_vec(nn_ptr res, slong len, nmod_t mod) 55 | # void trig_prod_init(trig_prod_t prod) 56 | # void arith_hrr_expsum_factored(trig_prod_t prod, ulong k, ulong n) 57 | # void arith_number_of_partitions_mpfr(mpfr_t x, ulong n) 58 | void arith_number_of_partitions(fmpz_t x, ulong n) 59 | void arith_sum_of_squares(fmpz_t r, ulong k, const fmpz_t n) 60 | void arith_sum_of_squares_vec(fmpz_struct * r, ulong k, slong n) 61 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/bernoulli.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_t, slong, ulong 2 | from flint.flintlib.types.fmpq cimport fmpq_struct, fmpq_t 3 | 4 | # unknown type bernoulli_rev_t 5 | 6 | 7 | cdef extern from "flint/bernoulli.h": 8 | # void bernoulli_rev_init(bernoulli_rev_t iter, ulong n) 9 | # void bernoulli_rev_next(fmpz_t numer, fmpz_t denom, bernoulli_rev_t iter) 10 | # void bernoulli_rev_clear(bernoulli_rev_t iter) 11 | void bernoulli_fmpq_vec_no_cache(fmpq_struct * res, ulong a, slong num) 12 | void bernoulli_cache_compute(slong n) 13 | slong bernoulli_bound_2exp_si(ulong n) 14 | ulong bernoulli_mod_p_harvey(ulong n, ulong p) 15 | void _bernoulli_fmpq_ui_zeta(fmpz_t num, fmpz_t den, ulong n) 16 | void _bernoulli_fmpq_ui_multi_mod(fmpz_t num, fmpz_t den, ulong n, double alpha) 17 | void _bernoulli_fmpq_ui(fmpz_t num, fmpz_t den, ulong n) 18 | void bernoulli_fmpq_ui(fmpq_t b, ulong n) 19 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/compat.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong 2 | from flint.flintlib.types.fmpz_mod cimport fmpz_mod_mpoly_ctx_t, fmpz_mod_mpoly_t 3 | 4 | 5 | cdef extern from *: 6 | """ 7 | #if __FLINT_RELEASE < 30200 /* Flint < 3.2.0 */ 8 | 9 | #define compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(...) (void)0 10 | 11 | #else 12 | 13 | #define compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(...) fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(__VA_ARGS__) 14 | 15 | #endif 16 | """ 17 | void compat_fmpz_mod_mpoly_compose_fmpz_mod_mpoly_gen(fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_t B, const slong * c, const fmpz_mod_mpoly_ctx_t ctxB, const fmpz_mod_mpoly_ctx_t ctxAC) 18 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/dirichlet.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.dirichlet cimport dirichlet_char_t, dirichlet_group_t 2 | from flint.flintlib.types.flint cimport slong, ulong 3 | 4 | 5 | 6 | cdef extern from "flint/dirichlet.h": 7 | int dirichlet_group_init(dirichlet_group_t G, ulong q) 8 | void dirichlet_subgroup_init(dirichlet_group_t H, const dirichlet_group_t G, ulong h) 9 | void dirichlet_group_clear(dirichlet_group_t G) 10 | ulong dirichlet_group_size(const dirichlet_group_t G) 11 | ulong dirichlet_group_num_primitive(const dirichlet_group_t G) 12 | void dirichlet_group_dlog_precompute(dirichlet_group_t G, ulong num) 13 | void dirichlet_group_dlog_clear(dirichlet_group_t G) 14 | void dirichlet_char_init(dirichlet_char_t chi, const dirichlet_group_t G) 15 | void dirichlet_char_clear(dirichlet_char_t chi) 16 | void dirichlet_char_print(const dirichlet_group_t G, const dirichlet_char_t chi) 17 | void dirichlet_char_log(dirichlet_char_t x, const dirichlet_group_t G, ulong m) 18 | ulong dirichlet_char_exp(const dirichlet_group_t G, const dirichlet_char_t x) 19 | ulong _dirichlet_char_exp(dirichlet_char_t x, const dirichlet_group_t G) 20 | void dirichlet_char_one(dirichlet_char_t x, const dirichlet_group_t G) 21 | void dirichlet_char_first_primitive(dirichlet_char_t x, const dirichlet_group_t G) 22 | void dirichlet_char_set(dirichlet_char_t x, const dirichlet_group_t G, const dirichlet_char_t y) 23 | int dirichlet_char_next(dirichlet_char_t x, const dirichlet_group_t G) 24 | int dirichlet_char_next_primitive(dirichlet_char_t x, const dirichlet_group_t G) 25 | ulong dirichlet_index_char(const dirichlet_group_t G, const dirichlet_char_t x) 26 | void dirichlet_char_index(dirichlet_char_t x, const dirichlet_group_t G, ulong j) 27 | int dirichlet_char_eq(const dirichlet_char_t x, const dirichlet_char_t y) 28 | int dirichlet_char_eq_deep(const dirichlet_group_t G, const dirichlet_char_t x, const dirichlet_char_t y) 29 | int dirichlet_char_is_principal(const dirichlet_group_t G, const dirichlet_char_t chi) 30 | ulong dirichlet_conductor_ui(const dirichlet_group_t G, ulong a) 31 | ulong dirichlet_conductor_char(const dirichlet_group_t G, const dirichlet_char_t x) 32 | int dirichlet_parity_ui(const dirichlet_group_t G, ulong a) 33 | int dirichlet_parity_char(const dirichlet_group_t G, const dirichlet_char_t x) 34 | ulong dirichlet_order_ui(const dirichlet_group_t G, ulong a) 35 | ulong dirichlet_order_char(const dirichlet_group_t G, const dirichlet_char_t x) 36 | int dirichlet_char_is_real(const dirichlet_group_t G, const dirichlet_char_t chi) 37 | int dirichlet_char_is_primitive(const dirichlet_group_t G, const dirichlet_char_t chi) 38 | ulong dirichlet_pairing(const dirichlet_group_t G, ulong m, ulong n) 39 | ulong dirichlet_pairing_char(const dirichlet_group_t G, const dirichlet_char_t chi, const dirichlet_char_t psi) 40 | ulong dirichlet_chi(const dirichlet_group_t G, const dirichlet_char_t chi, ulong n) 41 | void dirichlet_chi_vec(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, slong nv) 42 | void dirichlet_chi_vec_order(ulong * v, const dirichlet_group_t G, const dirichlet_char_t chi, ulong order, slong nv) 43 | void dirichlet_char_mul(dirichlet_char_t chi12, const dirichlet_group_t G, const dirichlet_char_t chi1, const dirichlet_char_t chi2) 44 | void dirichlet_char_pow(dirichlet_char_t c, const dirichlet_group_t G, const dirichlet_char_t a, ulong n) 45 | void dirichlet_char_lift(dirichlet_char_t chi_G, const dirichlet_group_t G, const dirichlet_char_t chi_H, const dirichlet_group_t H) 46 | void dirichlet_char_lower(dirichlet_char_t chi_H, const dirichlet_group_t H, const dirichlet_char_t chi_G, const dirichlet_group_t G) 47 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpq_mpoly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong 2 | from flint.flintlib.types.fmpq cimport fmpq_mpoly_ctx_t, fmpq_mpoly_factor_t, fmpq_mpoly_t, fmpq_t 3 | 4 | 5 | 6 | cdef extern from "flint/fmpq_mpoly_factor.h": 7 | void fmpq_mpoly_factor_init(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) 8 | void fmpq_mpoly_factor_clear(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) 9 | slong fmpq_mpoly_factor_length(const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) 10 | void fmpq_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) 11 | void fmpq_mpoly_factor_get_base(fmpq_mpoly_t B, const fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) 12 | void fmpq_mpoly_factor_swap_base(fmpq_mpoly_t B, fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) 13 | slong fmpq_mpoly_factor_get_exp_si(fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx) 14 | void fmpq_mpoly_factor_sort(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) 15 | int fmpq_mpoly_factor_make_monic(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) 16 | int fmpq_mpoly_factor_make_integral(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx) 17 | int fmpq_mpoly_factor_squarefree(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) 18 | int fmpq_mpoly_factor(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx) 19 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpq_vec.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_bitcnt_t, flint_rand_t, fmpz_struct, fmpz_t, slong 2 | from flint.flintlib.types.fmpq cimport fmpq_struct, fmpq_t 3 | 4 | # unknown type FILE 5 | 6 | 7 | cdef extern from "flint/fmpq_vec.h": 8 | fmpq_struct * _fmpq_vec_init(slong n) 9 | void _fmpq_vec_clear(fmpq_struct * vec, slong n) 10 | void _fmpq_vec_randtest(fmpq_struct * f, flint_rand_t state, slong len, flint_bitcnt_t bits) 11 | void _fmpq_vec_randtest_uniq_sorted(fmpq_struct * vec, flint_rand_t state, slong len, flint_bitcnt_t bits) 12 | void _fmpq_vec_sort(fmpq_struct * vec, slong len) 13 | void _fmpq_vec_set_fmpz_vec(fmpq_struct * res, const fmpz_struct * vec, slong len) 14 | void _fmpq_vec_get_fmpz_vec_fmpz(fmpz_struct * num, fmpz_t den, const fmpq_struct * a, slong len) 15 | void _fmpq_vec_dot(fmpq_t res, const fmpq_struct * vec1, const fmpq_struct * vec2, slong len) 16 | # int _fmpq_vec_fprint(FILE * file, const fmpq_struct * vec, slong len) 17 | int _fmpq_vec_print(const fmpq_struct * vec, slong len) 18 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_rand_t, fmpz_t, nn_ptr, slong, ulong 2 | from flint.flintlib.types.fmpz cimport fmpz_factor_t 3 | 4 | # unknown type FILE 5 | # unknown type ecm_t 6 | 7 | 8 | cdef extern from "flint/fmpz_factor.h": 9 | void fmpz_factor_init(fmpz_factor_t factor) 10 | void fmpz_factor_clear(fmpz_factor_t factor) 11 | void _fmpz_factor_append_ui(fmpz_factor_t factor, ulong p, ulong exp) 12 | void _fmpz_factor_append(fmpz_factor_t factor, const fmpz_t p, ulong exp) 13 | void fmpz_factor(fmpz_factor_t factor, const fmpz_t n) 14 | int fmpz_factor_smooth(fmpz_factor_t factor, const fmpz_t n, slong bits, int proved) 15 | void fmpz_factor_si(fmpz_factor_t factor, slong n) 16 | int fmpz_factor_trial_range(fmpz_factor_t factor, const fmpz_t n, ulong start, ulong num_primes) 17 | int fmpz_factor_trial(fmpz_factor_t factor, const fmpz_t n, slong num_primes) 18 | void fmpz_factor_refine(fmpz_factor_t res, const fmpz_factor_t f) 19 | void fmpz_factor_expand_iterative(fmpz_t n, const fmpz_factor_t factor) 20 | int fmpz_factor_pp1(fmpz_t factor, const fmpz_t n, ulong B1, ulong B2_sqrt, ulong c) 21 | int fmpz_factor_pollard_brent_single(fmpz_t p_factor, fmpz_t n_in, fmpz_t yi, fmpz_t ai, ulong max_iters) 22 | int fmpz_factor_pollard_brent(fmpz_t factor, flint_rand_t state, fmpz_t n, ulong max_tries, ulong max_iters) 23 | # int fmpz_factor_fprint(FILE * fs, const fmpz_factor_t factor) 24 | int fmpz_factor_print(const fmpz_factor_t factor) 25 | # void fmpz_factor_ecm_init(ecm_t ecm_inf, ulong sz) 26 | # void fmpz_factor_ecm_clear(ecm_t ecm_inf) 27 | # void fmpz_factor_ecm_double(nn_ptr x, nn_ptr z, nn_ptr x0, nn_ptr z0, nn_ptr n, ecm_t ecm_inf) 28 | # void fmpz_factor_ecm_add(nn_ptr x, nn_ptr z, nn_ptr x1, nn_ptr z1, nn_ptr x2, nn_ptr z2, nn_ptr x0, nn_ptr z0, nn_ptr n, ecm_t ecm_inf) 29 | # void fmpz_factor_ecm_mul_montgomery_ladder(nn_ptr x, nn_ptr z, nn_ptr x0, nn_ptr z0, ulong k, nn_ptr n, ecm_t ecm_inf) 30 | # int fmpz_factor_ecm_select_curve(nn_ptr f, nn_ptr sigma, nn_ptr n, ecm_t ecm_inf) 31 | # int fmpz_factor_ecm_stage_I(nn_ptr f, const ulong * prime_array, ulong num, ulong B1, nn_ptr n, ecm_t ecm_inf) 32 | # int fmpz_factor_ecm_stage_II(nn_ptr f, ulong B1, ulong B2, ulong P, nn_ptr n, ecm_t ecm_inf) 33 | int fmpz_factor_ecm(fmpz_t f, ulong curves, ulong B1, ulong B2, flint_rand_t state, const fmpz_t n_in) 34 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_lll.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_bitcnt_t, flint_rand_t, fmpz_t, slong 2 | from flint.flintlib.types.fmpz cimport fmpz_lll_t, fmpz_mat_t, gram_type, rep_type 3 | 4 | # unknown type d_mat_t 5 | # unknown type fmpz_gram_t 6 | # unknown type mpf 7 | # unknown type mpf_mat_t 8 | # unknown type mpf_t 9 | 10 | 11 | cdef extern from "flint/fmpz_lll.h": 12 | void fmpz_lll_context_init_default(fmpz_lll_t fl) 13 | void fmpz_lll_context_init(fmpz_lll_t fl, double delta, double eta, rep_type rt, gram_type gt) 14 | void fmpz_lll_randtest(fmpz_lll_t fl, flint_rand_t state) 15 | double fmpz_lll_heuristic_dot(const double * vec1, const double * vec2, slong len2, const fmpz_mat_t B, slong k, slong j, slong exp_adj) 16 | # int fmpz_lll_check_babai(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double * s, d_mat_t appB, int * expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) 17 | # int fmpz_lll_check_babai_heuristic_d(int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double * s, d_mat_t appB, int * expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) 18 | # int fmpz_lll_check_babai_heuristic(int kappa, fmpz_mat_t B, fmpz_mat_t U, mpf_mat_t mu, mpf_mat_t r, mpf * s, mpf_mat_t appB, fmpz_gram_t A, int a, int zeros, int kappamax, int n, mpf_t tmp, mpf_t rtmp, flint_bitcnt_t prec, const fmpz_lll_t fl) 19 | # int fmpz_lll_advance_check_babai(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double * s, d_mat_t appB, int * expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) 20 | # int fmpz_lll_advance_check_babai_heuristic_d(int cur_kappa, int kappa, fmpz_mat_t B, fmpz_mat_t U, d_mat_t mu, d_mat_t r, double * s, d_mat_t appB, int * expo, fmpz_gram_t A, int a, int zeros, int kappamax, int n, const fmpz_lll_t fl) 21 | int fmpz_lll_shift(const fmpz_mat_t B) 22 | int fmpz_lll_d(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) 23 | int fmpz_lll_d_heuristic(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) 24 | int fmpz_lll_mpf2(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_lll_t fl) 25 | int fmpz_lll_mpf(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) 26 | int fmpz_lll_wrapper(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) 27 | int fmpz_lll_d_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) 28 | int fmpz_lll_d_heuristic_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) 29 | int fmpz_lll_mpf2_with_removal(fmpz_mat_t B, fmpz_mat_t U, flint_bitcnt_t prec, const fmpz_t gs_B, const fmpz_lll_t fl) 30 | int fmpz_lll_mpf_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) 31 | int fmpz_lll_wrapper_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) 32 | int fmpz_lll_d_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) 33 | int fmpz_lll_wrapper_with_removal_knapsack(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) 34 | int fmpz_lll_with_removal_ulll(fmpz_mat_t FM, fmpz_mat_t UM, slong new_size, const fmpz_t gs_B, const fmpz_lll_t fl) 35 | int fmpz_lll_is_reduced_d(const fmpz_mat_t B, const fmpz_lll_t fl) 36 | int fmpz_lll_is_reduced_mpfr(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) 37 | int fmpz_lll_is_reduced_d_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd) 38 | int fmpz_lll_is_reduced_mpfr_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) 39 | int fmpz_lll_is_reduced(const fmpz_mat_t B, const fmpz_lll_t fl, flint_bitcnt_t prec) 40 | int fmpz_lll_is_reduced_with_removal(const fmpz_mat_t B, const fmpz_lll_t fl, const fmpz_t gs_B, int newd, flint_bitcnt_t prec) 41 | void fmpz_lll_storjohann_ulll(fmpz_mat_t FM, slong new_size, const fmpz_lll_t fl) 42 | void fmpz_lll(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl) 43 | int fmpz_lll_with_removal(fmpz_mat_t B, fmpz_mat_t U, const fmpz_t gs_B, const fmpz_lll_t fl) 44 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_mod.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_struct, fmpz_t, slong, ulong 2 | from flint.flintlib.types.fmpz_mod cimport fmpz_mod_ctx_t, fmpz_mod_discrete_log_pohlig_hellman_t 3 | 4 | 5 | 6 | cdef extern from "flint/fmpz_mod.h": 7 | void fmpz_mod_ctx_init(fmpz_mod_ctx_t ctx, const fmpz_t n) 8 | void fmpz_mod_ctx_clear(fmpz_mod_ctx_t ctx) 9 | void fmpz_mod_ctx_set_modulus(fmpz_mod_ctx_t ctx, const fmpz_t n) 10 | void fmpz_mod_set_fmpz(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) 11 | int fmpz_mod_is_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) 12 | int fmpz_mod_is_one(const fmpz_t a, const fmpz_mod_ctx_t ctx) 13 | void fmpz_mod_add(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 14 | void fmpz_mod_add_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 15 | void fmpz_mod_add_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) 16 | void fmpz_mod_add_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) 17 | void fmpz_mod_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 18 | void fmpz_mod_sub_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 19 | void fmpz_mod_sub_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) 20 | void fmpz_mod_sub_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) 21 | void fmpz_mod_fmpz_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 22 | void fmpz_mod_ui_sub(fmpz_t a, ulong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 23 | void fmpz_mod_si_sub(fmpz_t a, slong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 24 | void fmpz_mod_neg(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) 25 | void fmpz_mod_mul(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 26 | void fmpz_mod_inv(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) 27 | int fmpz_mod_divides(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) 28 | void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, ulong e, const fmpz_mod_ctx_t ctx) 29 | int fmpz_mod_pow_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t e, const fmpz_mod_ctx_t ctx) 30 | void fmpz_mod_discrete_log_pohlig_hellman_init(fmpz_mod_discrete_log_pohlig_hellman_t L) 31 | void fmpz_mod_discrete_log_pohlig_hellman_clear(fmpz_mod_discrete_log_pohlig_hellman_t L) 32 | double fmpz_mod_discrete_log_pohlig_hellman_precompute_prime(fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t p) 33 | const fmpz_struct * fmpz_mod_discrete_log_pohlig_hellman_primitive_root(fmpz_mod_discrete_log_pohlig_hellman_t L) 34 | void fmpz_mod_discrete_log_pohlig_hellman_run(fmpz_t x, const fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t y) 35 | int fmpz_next_smooth_prime(fmpz_t a, const fmpz_t b) 36 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_mod_mpoly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_t, slong 2 | from flint.flintlib.types.fmpz_mod cimport fmpz_mod_mpoly_ctx_t, fmpz_mod_mpoly_factor_t, fmpz_mod_mpoly_t 3 | 4 | 5 | 6 | cdef extern from "flint/fmpz_mod_mpoly_factor.h": 7 | void fmpz_mod_mpoly_factor_init(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) 8 | void fmpz_mod_mpoly_factor_clear(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) 9 | void fmpz_mod_mpoly_factor_swap(fmpz_mod_mpoly_factor_t f, fmpz_mod_mpoly_factor_t g, const fmpz_mod_mpoly_ctx_t ctx) 10 | slong fmpz_mod_mpoly_factor_length(const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) 11 | void fmpz_mod_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) 12 | void fmpz_mod_mpoly_factor_get_base(fmpz_mod_mpoly_t B, const fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) 13 | void fmpz_mod_mpoly_factor_swap_base(fmpz_mod_mpoly_t B, fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) 14 | slong fmpz_mod_mpoly_factor_get_exp_si(fmpz_mod_mpoly_factor_t f, slong i, const fmpz_mod_mpoly_ctx_t ctx) 15 | void fmpz_mod_mpoly_factor_sort(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_ctx_t ctx) 16 | int fmpz_mod_mpoly_factor_squarefree(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) 17 | int fmpz_mod_mpoly_factor(fmpz_mod_mpoly_factor_t f, const fmpz_mod_mpoly_t A, const fmpz_mod_mpoly_ctx_t ctx) 18 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_mod_poly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_rand_t, fmpz_struct, fmpz_t, slong 2 | from flint.flintlib.types.fmpz cimport fmpz_factor_t 3 | from flint.flintlib.types.fmpz_mod cimport fmpz_mod_ctx_t, fmpz_mod_poly_factor_t, fmpz_mod_poly_t 4 | 5 | 6 | 7 | cdef extern from "flint/fmpz_mod_poly_factor.h": 8 | void fmpz_mod_poly_factor_init(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) 9 | void fmpz_mod_poly_factor_clear(fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) 10 | void fmpz_mod_poly_factor_realloc(fmpz_mod_poly_factor_t fac, slong alloc, const fmpz_mod_ctx_t ctx) 11 | void fmpz_mod_poly_factor_fit_length(fmpz_mod_poly_factor_t fac, slong len, const fmpz_mod_ctx_t ctx) 12 | void fmpz_mod_poly_factor_set(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) 13 | void fmpz_mod_poly_factor_print(const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) 14 | void fmpz_mod_poly_factor_insert(fmpz_mod_poly_factor_t fac, const fmpz_mod_poly_t poly, slong exp, const fmpz_mod_ctx_t ctx) 15 | void fmpz_mod_poly_factor_concat(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_factor_t fac, const fmpz_mod_ctx_t ctx) 16 | void fmpz_mod_poly_factor_pow(fmpz_mod_poly_factor_t fac, slong exp, const fmpz_mod_ctx_t ctx) 17 | int fmpz_mod_poly_is_irreducible(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 18 | int fmpz_mod_poly_is_irreducible_ddf(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 19 | int fmpz_mod_poly_is_irreducible_rabin(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 20 | int fmpz_mod_poly_is_irreducible_rabin_f(fmpz_t r, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 21 | int _fmpz_mod_poly_is_squarefree(const fmpz_struct * f, slong len, const fmpz_mod_ctx_t ctx) 22 | int _fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz_struct * f, slong len, const fmpz_mod_ctx_t ctx) 23 | int fmpz_mod_poly_is_squarefree(const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 24 | int fmpz_mod_poly_is_squarefree_f(fmpz_t fac, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 25 | int fmpz_mod_poly_factor_equal_deg_prob(fmpz_mod_poly_t factor, flint_rand_t state, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) 26 | void fmpz_mod_poly_factor_equal_deg(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t pol, slong d, const fmpz_mod_ctx_t ctx) 27 | void fmpz_mod_poly_factor_distinct_deg(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const * degs, const fmpz_mod_ctx_t ctx) 28 | void fmpz_mod_poly_factor_distinct_deg_threaded(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, slong * const * degs, const fmpz_mod_ctx_t ctx) 29 | void fmpz_mod_poly_factor_squarefree(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 30 | void fmpz_mod_poly_factor(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 31 | void fmpz_mod_poly_factor_cantor_zassenhaus(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 32 | void fmpz_mod_poly_factor_kaltofen_shoup(fmpz_mod_poly_factor_t res, const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx) 33 | void fmpz_mod_poly_factor_berlekamp(fmpz_mod_poly_factor_t factors, const fmpz_mod_poly_t f, const fmpz_mod_ctx_t ctx) 34 | void _fmpz_mod_poly_interval_poly_worker(void * arg_ptr) 35 | void fmpz_mod_poly_roots(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_mod_ctx_t ctx) 36 | int fmpz_mod_poly_roots_factored(fmpz_mod_poly_factor_t r, const fmpz_mod_poly_t f, int with_multiplicity, const fmpz_factor_t n, const fmpz_mod_ctx_t ctx) 37 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_mod_vec.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_struct, fmpz_t, slong 2 | from flint.flintlib.types.fmpz_mod cimport fmpz_mod_ctx_t 3 | 4 | 5 | 6 | cdef extern from "flint/fmpz_mod_vec.h": 7 | void _fmpz_mod_vec_set_fmpz_vec(fmpz_struct * A, const fmpz_struct * B, slong len, const fmpz_mod_ctx_t ctx) 8 | void _fmpz_mod_vec_neg(fmpz_struct * A, const fmpz_struct * B, slong len, const fmpz_mod_ctx_t ctx) 9 | void _fmpz_mod_vec_add(fmpz_struct * a, const fmpz_struct * b, const fmpz_struct * c, slong n, const fmpz_mod_ctx_t ctx) 10 | void _fmpz_mod_vec_sub(fmpz_struct * a, const fmpz_struct * b, const fmpz_struct * c, slong n, const fmpz_mod_ctx_t ctx) 11 | void _fmpz_mod_vec_scalar_mul_fmpz_mod(fmpz_struct * A, const fmpz_struct * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) 12 | void _fmpz_mod_vec_scalar_addmul_fmpz_mod(fmpz_struct * A, const fmpz_struct * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) 13 | void _fmpz_mod_vec_scalar_div_fmpz_mod(fmpz_struct * A, const fmpz_struct * B, slong len, const fmpz_t c, const fmpz_mod_ctx_t ctx) 14 | void _fmpz_mod_vec_dot(fmpz_t d, const fmpz_struct * A, const fmpz_struct * B, slong len, const fmpz_mod_ctx_t ctx) 15 | void _fmpz_mod_vec_dot_rev(fmpz_t d, const fmpz_struct * A, const fmpz_struct * B, slong len, const fmpz_mod_ctx_t ctx) 16 | void _fmpz_mod_vec_mul(fmpz_struct * A, const fmpz_struct * B, const fmpz_struct * C, slong len, const fmpz_mod_ctx_t ctx) 17 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_mpoly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_t, slong 2 | from flint.flintlib.types.fmpq cimport fmpq_t 3 | from flint.flintlib.types.fmpz cimport fmpz_mpoly_ctx_t, fmpz_mpoly_factor_t, fmpz_mpoly_t 4 | 5 | 6 | 7 | cdef extern from "flint/fmpz_mpoly_factor.h": 8 | void fmpz_mpoly_factor_init(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) 9 | void fmpz_mpoly_factor_clear(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) 10 | void fmpz_mpoly_factor_swap(fmpz_mpoly_factor_t f, fmpz_mpoly_factor_t g, const fmpz_mpoly_ctx_t ctx) 11 | slong fmpz_mpoly_factor_length(const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) 12 | void fmpz_mpoly_factor_get_constant_fmpz(fmpz_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) 13 | void fmpz_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) 14 | void fmpz_mpoly_factor_get_base(fmpz_mpoly_t B, const fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) 15 | void fmpz_mpoly_factor_swap_base(fmpz_mpoly_t B, fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) 16 | slong fmpz_mpoly_factor_get_exp_si(fmpz_mpoly_factor_t f, slong i, const fmpz_mpoly_ctx_t ctx) 17 | void fmpz_mpoly_factor_sort(fmpz_mpoly_factor_t f, const fmpz_mpoly_ctx_t ctx) 18 | int fmpz_mpoly_factor_squarefree(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) 19 | int fmpz_mpoly_factor(fmpz_mpoly_factor_t f, const fmpz_mpoly_t A, const fmpz_mpoly_ctx_t ctx) 20 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_mpoly_q.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_rand_t, fmpz_t, slong, ulong 2 | from flint.flintlib.types.fmpq cimport fmpq_t 3 | from flint.flintlib.types.fmpz cimport fmpz_mpoly_ctx_t, fmpz_mpoly_q_t, fmpz_mpoly_t 4 | 5 | 6 | # .. macro:: fmpz_mpoly_q_numref(x) 7 | # .. macro:: fmpz_mpoly_q_denref(x) 8 | 9 | cdef extern from "flint/fmpz_mpoly_q.h": 10 | void fmpz_mpoly_q_init(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) 11 | void fmpz_mpoly_q_clear(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) 12 | void fmpz_mpoly_q_swap(fmpz_mpoly_q_t x, fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) 13 | void fmpz_mpoly_q_set(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) 14 | void fmpz_mpoly_q_set_fmpq(fmpz_mpoly_q_t res, const fmpq_t x, const fmpz_mpoly_ctx_t ctx) 15 | void fmpz_mpoly_q_set_fmpz(fmpz_mpoly_q_t res, const fmpz_t x, const fmpz_mpoly_ctx_t ctx) 16 | void fmpz_mpoly_q_set_si(fmpz_mpoly_q_t res, slong x, const fmpz_mpoly_ctx_t ctx) 17 | void fmpz_mpoly_q_canonicalise(fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) 18 | int fmpz_mpoly_q_is_canonical(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) 19 | int fmpz_mpoly_q_is_zero(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) 20 | int fmpz_mpoly_q_is_one(const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) 21 | void fmpz_mpoly_q_used_vars(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) 22 | void fmpz_mpoly_q_used_vars_num(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) 23 | void fmpz_mpoly_q_used_vars_den(int * used, const fmpz_mpoly_q_t f, const fmpz_mpoly_ctx_t ctx) 24 | void fmpz_mpoly_q_zero(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) 25 | void fmpz_mpoly_q_one(fmpz_mpoly_q_t res, const fmpz_mpoly_ctx_t ctx) 26 | void fmpz_mpoly_q_gen(fmpz_mpoly_q_t res, slong i, const fmpz_mpoly_ctx_t ctx) 27 | void fmpz_mpoly_q_print_pretty(const fmpz_mpoly_q_t f, const char ** x, const fmpz_mpoly_ctx_t ctx) 28 | char * fmpz_mpoly_q_get_str_pretty(const fmpz_mpoly_q_t f, const char ** x, const fmpz_mpoly_ctx_t ctx) 29 | int fmpz_mpoly_q_set_str_pretty(fmpz_mpoly_q_t res, const char * s, const char ** x, fmpz_mpoly_ctx_t ctx) 30 | void fmpz_mpoly_q_randtest(fmpz_mpoly_q_t res, flint_rand_t state, slong length, ulong coeff_bits, slong exp_bound, const fmpz_mpoly_ctx_t ctx) 31 | int fmpz_mpoly_q_equal(const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) 32 | void fmpz_mpoly_q_neg(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) 33 | void fmpz_mpoly_q_add(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) 34 | void fmpz_mpoly_q_add_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) 35 | void fmpz_mpoly_q_add_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) 36 | void fmpz_mpoly_q_add_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) 37 | void fmpz_mpoly_q_sub(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) 38 | void fmpz_mpoly_q_sub_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) 39 | void fmpz_mpoly_q_sub_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) 40 | void fmpz_mpoly_q_sub_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) 41 | void fmpz_mpoly_q_mul(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) 42 | void fmpz_mpoly_q_mul_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) 43 | void fmpz_mpoly_q_mul_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) 44 | void fmpz_mpoly_q_mul_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) 45 | void fmpz_mpoly_q_div(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_q_t y, const fmpz_mpoly_ctx_t ctx) 46 | void fmpz_mpoly_q_div_fmpq(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpq_t y, const fmpz_mpoly_ctx_t ctx) 47 | void fmpz_mpoly_q_div_fmpz(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_t y, const fmpz_mpoly_ctx_t ctx) 48 | void fmpz_mpoly_q_div_si(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, slong y, const fmpz_mpoly_ctx_t ctx) 49 | void fmpz_mpoly_q_inv(fmpz_mpoly_q_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) 50 | void _fmpz_mpoly_q_content(fmpz_t num, fmpz_t den, const fmpz_mpoly_t xnum, const fmpz_mpoly_t xden, const fmpz_mpoly_ctx_t ctx) 51 | void fmpz_mpoly_q_content(fmpq_t res, const fmpz_mpoly_q_t x, const fmpz_mpoly_ctx_t ctx) 52 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fmpz_poly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_t, slong 2 | from flint.flintlib.types.fmpz cimport fmpz_poly_factor_t, fmpz_poly_t 3 | 4 | 5 | 6 | cdef extern from "flint/fmpz_poly_factor.h": 7 | void fmpz_poly_factor_init(fmpz_poly_factor_t fac) 8 | void fmpz_poly_factor_init2(fmpz_poly_factor_t fac, slong alloc) 9 | void fmpz_poly_factor_realloc(fmpz_poly_factor_t fac, slong alloc) 10 | void fmpz_poly_factor_fit_length(fmpz_poly_factor_t fac, slong len) 11 | void fmpz_poly_factor_clear(fmpz_poly_factor_t fac) 12 | void fmpz_poly_factor_set(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) 13 | void fmpz_poly_factor_insert(fmpz_poly_factor_t fac, const fmpz_poly_t p, slong e) 14 | void fmpz_poly_factor_concat(fmpz_poly_factor_t res, const fmpz_poly_factor_t fac) 15 | void fmpz_poly_factor_print(const fmpz_poly_factor_t fac) 16 | void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, const fmpz_poly_t F) 17 | void fmpz_poly_factor_zassenhaus_recombination(fmpz_poly_factor_t final_fac, const fmpz_poly_factor_t lifted_fac, const fmpz_poly_t F, const fmpz_t P, slong exp) 18 | void _fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, slong exp, const fmpz_poly_t f, slong cutoff, int use_van_hoeij) 19 | void fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) 20 | void _fmpz_poly_factor_quadratic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) 21 | void _fmpz_poly_factor_cubic(fmpz_poly_factor_t fac, const fmpz_poly_t f, slong exp) 22 | void fmpz_poly_factor(fmpz_poly_factor_t final_fac, const fmpz_poly_t F) 23 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fq_default_poly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong, ulong 2 | from flint.flintlib.types.fq_default cimport fq_default_ctx_t, fq_default_poly_factor_t, fq_default_poly_t, fq_default_t 3 | 4 | 5 | 6 | cdef extern from "flint/fq_default_poly_factor.h": 7 | void fq_default_poly_factor_init(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) 8 | void fq_default_poly_factor_clear(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) 9 | void fq_default_poly_factor_realloc(fq_default_poly_factor_t fac, slong alloc, const fq_default_ctx_t ctx) 10 | void fq_default_poly_factor_fit_length(fq_default_poly_factor_t fac, slong len, const fq_default_ctx_t ctx) 11 | void fq_default_poly_factor_set(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) 12 | void fq_default_poly_factor_print_pretty(const fq_default_poly_factor_t fac, const char * var, const fq_default_ctx_t ctx) 13 | void fq_default_poly_factor_print(const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) 14 | void fq_default_poly_factor_insert(fq_default_poly_factor_t fac, const fq_default_poly_t poly, slong exp, const fq_default_ctx_t ctx) 15 | void fq_default_poly_factor_concat(fq_default_poly_factor_t res, const fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) 16 | void fq_default_poly_factor_pow(fq_default_poly_factor_t fac, slong exp, const fq_default_ctx_t ctx) 17 | ulong fq_default_poly_remove(fq_default_poly_t f, const fq_default_poly_t p, const fq_default_ctx_t ctx) 18 | slong fq_default_poly_factor_length(fq_default_poly_factor_t fac, const fq_default_ctx_t ctx) 19 | void fq_default_poly_factor_get_poly(fq_default_poly_t poly, const fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) 20 | slong fq_default_poly_factor_exp(fq_default_poly_factor_t fac, slong i, const fq_default_ctx_t ctx) 21 | int fq_default_poly_is_irreducible(const fq_default_poly_t f, const fq_default_ctx_t ctx) 22 | int fq_default_poly_is_squarefree(const fq_default_poly_t f, const fq_default_ctx_t ctx) 23 | void fq_default_poly_factor_equal_deg(fq_default_poly_factor_t factors, const fq_default_poly_t pol, slong d, const fq_default_ctx_t ctx) 24 | void fq_default_poly_factor_split_single(fq_default_poly_t linfactor, const fq_default_poly_t input, const fq_default_ctx_t ctx) 25 | void fq_default_poly_factor_distinct_deg(fq_default_poly_factor_t res, const fq_default_poly_t poly, slong * const * degs, const fq_default_ctx_t ctx) 26 | void fq_default_poly_factor_squarefree(fq_default_poly_factor_t res, const fq_default_poly_t f, const fq_default_ctx_t ctx) 27 | void fq_default_poly_factor(fq_default_poly_factor_t res, fq_default_t lead, const fq_default_poly_t f, const fq_default_ctx_t ctx) 28 | void fq_default_poly_roots(fq_default_poly_factor_t r, const fq_default_poly_t f, int with_multiplicity, const fq_default_ctx_t ctx) 29 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fq_nmod_poly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_rand_t, slong, ulong 2 | from flint.flintlib.types.fq_nmod cimport fq_nmod_ctx_t, fq_nmod_poly_factor_t, fq_nmod_poly_t, fq_nmod_struct, fq_nmod_t 3 | 4 | 5 | 6 | cdef extern from "flint/fq_nmod_poly_factor.h": 7 | void fq_nmod_poly_factor_init(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) 8 | void fq_nmod_poly_factor_clear(fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) 9 | void fq_nmod_poly_factor_realloc(fq_nmod_poly_factor_t fac, slong alloc, const fq_nmod_ctx_t ctx) 10 | void fq_nmod_poly_factor_fit_length(fq_nmod_poly_factor_t fac, slong len, const fq_nmod_ctx_t ctx) 11 | void fq_nmod_poly_factor_set(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) 12 | void fq_nmod_poly_factor_print_pretty(const fq_nmod_poly_factor_t fac, const char * var, const fq_nmod_ctx_t ctx) 13 | void fq_nmod_poly_factor_print(const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) 14 | void fq_nmod_poly_factor_insert(fq_nmod_poly_factor_t fac, const fq_nmod_poly_t poly, slong exp, const fq_nmod_ctx_t ctx) 15 | void fq_nmod_poly_factor_concat(fq_nmod_poly_factor_t res, const fq_nmod_poly_factor_t fac, const fq_nmod_ctx_t ctx) 16 | void fq_nmod_poly_factor_pow(fq_nmod_poly_factor_t fac, slong exp, const fq_nmod_ctx_t ctx) 17 | ulong fq_nmod_poly_remove(fq_nmod_poly_t f, const fq_nmod_poly_t p, const fq_nmod_ctx_t ctx) 18 | int fq_nmod_poly_is_irreducible(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 19 | int fq_nmod_poly_is_irreducible_ddf(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 20 | int fq_nmod_poly_is_irreducible_ben_or(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 21 | int _fq_nmod_poly_is_squarefree(const fq_nmod_struct * f, slong len, const fq_nmod_ctx_t ctx) 22 | int fq_nmod_poly_is_squarefree(const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 23 | int fq_nmod_poly_factor_equal_deg_prob(fq_nmod_poly_t factor, flint_rand_t state, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) 24 | void fq_nmod_poly_factor_equal_deg(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t pol, slong d, const fq_nmod_ctx_t ctx) 25 | void fq_nmod_poly_factor_split_single(fq_nmod_poly_t linfactor, const fq_nmod_poly_t input, const fq_nmod_ctx_t ctx) 26 | void fq_nmod_poly_factor_distinct_deg(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, slong * const * degs, const fq_nmod_ctx_t ctx) 27 | void fq_nmod_poly_factor_squarefree(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 28 | void fq_nmod_poly_factor(fq_nmod_poly_factor_t res, fq_nmod_t lead, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 29 | void fq_nmod_poly_factor_cantor_zassenhaus(fq_nmod_poly_factor_t res, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 30 | void fq_nmod_poly_factor_kaltofen_shoup(fq_nmod_poly_factor_t res, const fq_nmod_poly_t poly, const fq_nmod_ctx_t ctx) 31 | void fq_nmod_poly_factor_berlekamp(fq_nmod_poly_factor_t factors, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 32 | void fq_nmod_poly_factor_with_berlekamp(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 33 | void fq_nmod_poly_factor_with_cantor_zassenhaus(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 34 | void fq_nmod_poly_factor_with_kaltofen_shoup(fq_nmod_poly_factor_t res, fq_nmod_t leading_coeff, const fq_nmod_poly_t f, const fq_nmod_ctx_t ctx) 35 | void fq_nmod_poly_iterated_frobenius_preinv(fq_nmod_poly_t * rop, slong n, const fq_nmod_poly_t v, const fq_nmod_poly_t vinv, const fq_nmod_ctx_t ctx) 36 | void fq_nmod_poly_roots(fq_nmod_poly_factor_t r, const fq_nmod_poly_t f, int with_multiplicity, const fq_nmod_ctx_t ctx) 37 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fq_poly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_rand_t, slong, ulong 2 | from flint.flintlib.types.fq cimport fq_ctx_t, fq_poly_factor_t, fq_poly_t, fq_struct, fq_t 3 | 4 | 5 | 6 | cdef extern from "flint/fq_poly_factor.h": 7 | void fq_poly_factor_init(fq_poly_factor_t fac, const fq_ctx_t ctx) 8 | void fq_poly_factor_clear(fq_poly_factor_t fac, const fq_ctx_t ctx) 9 | void fq_poly_factor_realloc(fq_poly_factor_t fac, slong alloc, const fq_ctx_t ctx) 10 | void fq_poly_factor_fit_length(fq_poly_factor_t fac, slong len, const fq_ctx_t ctx) 11 | void fq_poly_factor_set(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) 12 | void fq_poly_factor_print_pretty(const fq_poly_factor_t fac, const char * var, const fq_ctx_t ctx) 13 | void fq_poly_factor_print(const fq_poly_factor_t fac, const fq_ctx_t ctx) 14 | void fq_poly_factor_insert(fq_poly_factor_t fac, const fq_poly_t poly, slong exp, const fq_ctx_t ctx) 15 | void fq_poly_factor_concat(fq_poly_factor_t res, const fq_poly_factor_t fac, const fq_ctx_t ctx) 16 | void fq_poly_factor_pow(fq_poly_factor_t fac, slong exp, const fq_ctx_t ctx) 17 | ulong fq_poly_remove(fq_poly_t f, const fq_poly_t p, const fq_ctx_t ctx) 18 | int fq_poly_is_irreducible(const fq_poly_t f, const fq_ctx_t ctx) 19 | int fq_poly_is_irreducible_ddf(const fq_poly_t f, const fq_ctx_t ctx) 20 | int fq_poly_is_irreducible_ben_or(const fq_poly_t f, const fq_ctx_t ctx) 21 | int _fq_poly_is_squarefree(const fq_struct * f, slong len, const fq_ctx_t ctx) 22 | int fq_poly_is_squarefree(const fq_poly_t f, const fq_ctx_t ctx) 23 | int fq_poly_factor_equal_deg_prob(fq_poly_t factor, flint_rand_t state, const fq_poly_t pol, slong d, const fq_ctx_t ctx) 24 | void fq_poly_factor_equal_deg(fq_poly_factor_t factors, const fq_poly_t pol, slong d, const fq_ctx_t ctx) 25 | void fq_poly_factor_split_single(fq_poly_t linfactor, const fq_poly_t input, const fq_ctx_t ctx) 26 | void fq_poly_factor_distinct_deg(fq_poly_factor_t res, const fq_poly_t poly, slong * const * degs, const fq_ctx_t ctx) 27 | void fq_poly_factor_squarefree(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) 28 | void fq_poly_factor(fq_poly_factor_t res, fq_t lead, const fq_poly_t f, const fq_ctx_t ctx) 29 | void fq_poly_factor_cantor_zassenhaus(fq_poly_factor_t res, const fq_poly_t f, const fq_ctx_t ctx) 30 | void fq_poly_factor_kaltofen_shoup(fq_poly_factor_t res, const fq_poly_t poly, const fq_ctx_t ctx) 31 | void fq_poly_factor_berlekamp(fq_poly_factor_t factors, const fq_poly_t f, const fq_ctx_t ctx) 32 | void fq_poly_factor_with_berlekamp(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) 33 | void fq_poly_factor_with_cantor_zassenhaus(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) 34 | void fq_poly_factor_with_kaltofen_shoup(fq_poly_factor_t res, fq_t leading_coeff, const fq_poly_t f, const fq_ctx_t ctx) 35 | void fq_poly_iterated_frobenius_preinv(fq_poly_t * rop, slong n, const fq_poly_t v, const fq_poly_t vinv, const fq_ctx_t ctx) 36 | void fq_poly_roots(fq_poly_factor_t r, const fq_poly_t f, int with_multiplicity, const fq_ctx_t ctx) 37 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/fq_zech_poly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_rand_t, slong, ulong 2 | from flint.flintlib.types.fq_zech cimport fq_zech_ctx_t, fq_zech_poly_factor_t, fq_zech_poly_t, fq_zech_struct, fq_zech_t 3 | 4 | 5 | 6 | cdef extern from "flint/fq_zech_poly_factor.h": 7 | void fq_zech_poly_factor_init(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) 8 | void fq_zech_poly_factor_clear(fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) 9 | void fq_zech_poly_factor_realloc(fq_zech_poly_factor_t fac, slong alloc, const fq_zech_ctx_t ctx) 10 | void fq_zech_poly_factor_fit_length(fq_zech_poly_factor_t fac, slong len, const fq_zech_ctx_t ctx) 11 | void fq_zech_poly_factor_set(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) 12 | void fq_zech_poly_factor_print_pretty(const fq_zech_poly_factor_t fac, const char * var, const fq_zech_ctx_t ctx) 13 | void fq_zech_poly_factor_print(const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) 14 | void fq_zech_poly_factor_insert(fq_zech_poly_factor_t fac, const fq_zech_poly_t poly, slong exp, const fq_zech_ctx_t ctx) 15 | void fq_zech_poly_factor_concat(fq_zech_poly_factor_t res, const fq_zech_poly_factor_t fac, const fq_zech_ctx_t ctx) 16 | void fq_zech_poly_factor_pow(fq_zech_poly_factor_t fac, slong exp, const fq_zech_ctx_t ctx) 17 | ulong fq_zech_poly_remove(fq_zech_poly_t f, const fq_zech_poly_t p, const fq_zech_ctx_t ctx) 18 | int fq_zech_poly_is_irreducible(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 19 | int fq_zech_poly_is_irreducible_ddf(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 20 | int fq_zech_poly_is_irreducible_ben_or(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 21 | int _fq_zech_poly_is_squarefree(const fq_zech_struct * f, slong len, const fq_zech_ctx_t ctx) 22 | int fq_zech_poly_is_squarefree(const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 23 | int fq_zech_poly_factor_equal_deg_prob(fq_zech_poly_t factor, flint_rand_t state, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) 24 | void fq_zech_poly_factor_equal_deg(fq_zech_poly_factor_t factors, const fq_zech_poly_t pol, slong d, const fq_zech_ctx_t ctx) 25 | void fq_zech_poly_factor_split_single(fq_zech_poly_t linfactor, const fq_zech_poly_t input, const fq_zech_ctx_t ctx) 26 | void fq_zech_poly_factor_distinct_deg(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, slong * const * degs, const fq_zech_ctx_t ctx) 27 | void fq_zech_poly_factor_squarefree(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 28 | void fq_zech_poly_factor(fq_zech_poly_factor_t res, fq_zech_t lead, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 29 | void fq_zech_poly_factor_cantor_zassenhaus(fq_zech_poly_factor_t res, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 30 | void fq_zech_poly_factor_kaltofen_shoup(fq_zech_poly_factor_t res, const fq_zech_poly_t poly, const fq_zech_ctx_t ctx) 31 | void fq_zech_poly_factor_berlekamp(fq_zech_poly_factor_t factors, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 32 | void fq_zech_poly_factor_with_berlekamp(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 33 | void fq_zech_poly_factor_with_cantor_zassenhaus(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 34 | void fq_zech_poly_factor_with_kaltofen_shoup(fq_zech_poly_factor_t res, fq_zech_t leading_coeff, const fq_zech_poly_t f, const fq_zech_ctx_t ctx) 35 | void fq_zech_poly_iterated_frobenius_preinv(fq_zech_poly_t * rop, slong n, const fq_zech_poly_t v, const fq_zech_poly_t vinv, const fq_zech_ctx_t ctx) 36 | void fq_zech_poly_roots(fq_zech_poly_factor_t r, const fq_zech_poly_t f, int with_multiplicity, const fq_zech_ctx_t ctx) 37 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/gr_domains.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_rand_t, fmpz_t, slong, ulong 2 | from flint.flintlib.types.fmpq cimport fmpq_poly_t 3 | from flint.flintlib.types.fmpz cimport fmpz_poly_t 4 | from flint.flintlib.types.gr cimport gr_ctx_t, truth_t 5 | from flint.flintlib.types.mpoly cimport ordering_t 6 | 7 | 8 | 9 | cdef extern from "flint/gr.h": 10 | int gr_ctx_cmp_coercion(gr_ctx_t ctx1, gr_ctx_t ctx2) 11 | truth_t gr_ctx_is_finite(gr_ctx_t ctx) 12 | truth_t gr_ctx_is_multiplicative_group(gr_ctx_t ctx) 13 | truth_t gr_ctx_is_ring(gr_ctx_t ctx) 14 | truth_t gr_ctx_is_commutative_ring(gr_ctx_t ctx) 15 | truth_t gr_ctx_is_integral_domain(gr_ctx_t ctx) 16 | truth_t gr_ctx_is_unique_factorization_domain(gr_ctx_t ctx) 17 | truth_t gr_ctx_is_field(gr_ctx_t ctx) 18 | truth_t gr_ctx_is_algebraically_closed(gr_ctx_t ctx) 19 | truth_t gr_ctx_is_finite_characteristic(gr_ctx_t ctx) 20 | truth_t gr_ctx_is_ordered_ring(gr_ctx_t ctx) 21 | truth_t gr_ctx_is_zero_ring(gr_ctx_t ctx) 22 | truth_t gr_ctx_is_exact(gr_ctx_t ctx) 23 | truth_t gr_ctx_is_canonical(gr_ctx_t ctx) 24 | truth_t gr_ctx_has_real_prec(gr_ctx_t ctx) 25 | int gr_ctx_set_real_prec(gr_ctx_t ctx, slong prec) 26 | int gr_ctx_get_real_prec(slong * prec, gr_ctx_t ctx) 27 | void gr_ctx_init_perm(gr_ctx_t ctx, ulong n) 28 | void gr_ctx_init_psl2z(gr_ctx_t ctx) 29 | int gr_ctx_init_dirichlet_group(gr_ctx_t ctx, ulong q) 30 | void gr_ctx_init_random(gr_ctx_t ctx, flint_rand_t state) 31 | void gr_ctx_init_fmpz(gr_ctx_t ctx) 32 | void gr_ctx_init_fmpq(gr_ctx_t ctx) 33 | void gr_ctx_init_fmpzi(gr_ctx_t ctx) 34 | int gr_ctx_set_is_field(gr_ctx_t ctx, truth_t is_field) 35 | void gr_ctx_init_nmod(gr_ctx_t ctx, ulong n) 36 | void gr_ctx_init_nmod8(gr_ctx_t ctx, unsigned char n) 37 | void gr_ctx_init_nmod32(gr_ctx_t ctx, unsigned int n) 38 | void gr_ctx_init_fmpz_mod(gr_ctx_t ctx, const fmpz_t n) 39 | void gr_ctx_init_fq(gr_ctx_t ctx, const fmpz_t p, slong d, const char * var) 40 | void gr_ctx_init_fq_nmod(gr_ctx_t ctx, ulong p, slong d, const char * var) 41 | void gr_ctx_init_fq_zech(gr_ctx_t ctx, ulong p, slong d, const char * var) 42 | void gr_ctx_init_nf(gr_ctx_t ctx, const fmpq_poly_t poly) 43 | void gr_ctx_init_nf_fmpz_poly(gr_ctx_t ctx, const fmpz_poly_t poly) 44 | void gr_ctx_init_real_qqbar(gr_ctx_t ctx) 45 | void gr_ctx_init_complex_qqbar(gr_ctx_t ctx) 46 | void _gr_ctx_qqbar_set_limits(gr_ctx_t ctx, slong deg_limit, slong bits_limit) 47 | void gr_ctx_init_real_arb(gr_ctx_t ctx, slong prec) 48 | void gr_ctx_init_complex_acb(gr_ctx_t ctx, slong prec) 49 | void gr_ctx_arb_set_prec(gr_ctx_t ctx, slong prec) 50 | slong gr_ctx_arb_get_prec(gr_ctx_t ctx) 51 | void gr_ctx_init_real_ca(gr_ctx_t ctx) 52 | void gr_ctx_init_complex_ca(gr_ctx_t ctx) 53 | void gr_ctx_init_real_algebraic_ca(gr_ctx_t ctx) 54 | void gr_ctx_init_complex_algebraic_ca(gr_ctx_t ctx) 55 | void gr_ctx_ca_set_option(gr_ctx_t ctx, slong option, slong value) 56 | slong gr_ctx_ca_get_option(gr_ctx_t ctx, slong option) 57 | void gr_ctx_init_complex_extended_ca(gr_ctx_t ctx) 58 | void gr_ctx_init_real_float_arf(gr_ctx_t ctx, slong prec) 59 | void gr_ctx_init_complex_float_acf(gr_ctx_t ctx, slong prec) 60 | void gr_ctx_init_vector_gr_vec(gr_ctx_t ctx, gr_ctx_t base_type) 61 | void gr_ctx_init_vector_space_gr_vec(gr_ctx_t ctx, gr_ctx_t base_type, slong n) 62 | void gr_ctx_init_matrix_domain(gr_ctx_t ctx, gr_ctx_t base_ring) 63 | void gr_ctx_init_matrix_space(gr_ctx_t ctx, gr_ctx_t base_ring, slong n, slong m) 64 | void gr_ctx_init_matrix_ring(gr_ctx_t ctx, gr_ctx_t base_ring, slong n) 65 | void gr_ctx_init_fmpz_poly(gr_ctx_t ctx) 66 | void gr_ctx_init_fmpq_poly(gr_ctx_t ctx) 67 | void gr_ctx_init_gr_poly(gr_ctx_t ctx, gr_ctx_t base_ring) 68 | void gr_ctx_init_fmpz_mpoly(gr_ctx_t ctx, slong nvars, const ordering_t ord) 69 | void gr_ctx_init_gr_mpoly(gr_ctx_t ctx, gr_ctx_t base_ring, slong nvars, const ordering_t ord) 70 | void gr_ctx_init_series_mod_gr_poly(gr_ctx_t ctx, gr_ctx_t base_ring, slong n) 71 | void gr_ctx_init_gr_series(gr_ctx_t ctx, gr_ctx_t base_ring, slong prec) 72 | void gr_ctx_init_fmpz_mpoly_q(gr_ctx_t ctx, slong nvars, const ordering_t ord) 73 | void gr_ctx_init_fexpr(gr_ctx_t ctx) 74 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/gr_implementing.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong 2 | from flint.flintlib.types.gr cimport gr_ctx_t, gr_funcptr, truth_t 3 | 4 | # unknown type gr_method_tab_input 5 | 6 | 7 | cdef extern from "flint/gr_implementing.h": 8 | # void gr_method_tab_init(gr_funcptr * methods, gr_method_tab_input * tab) 9 | int gr_not_implemented(void) 10 | int gr_not_in_domain(void) 11 | truth_t gr_generic_ctx_predicate(gr_ctx_t ctx) 12 | truth_t gr_generic_ctx_predicate_true(gr_ctx_t ctx) 13 | truth_t gr_generic_ctx_predicate_false(gr_ctx_t ctx) 14 | void gr_test_ring(gr_ctx_t R, slong iters, int test_flags) 15 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/nmod.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_t, nmod_t, ulong 2 | 3 | # unknown type nmod_discrete_log_pohlig_hellman_t 4 | 5 | # .. macro:: NMOD_BITS(mod) 6 | # .. macro:: NMOD_CAN_USE_SHOUP(mod) 7 | # .. macro:: NMOD_RED2(r, a_hi, a_lo, mod) 8 | # .. macro:: NMOD_RED(r, a, mod) 9 | # .. macro:: NMOD2_RED2(r, a_hi, a_lo, mod) 10 | # .. macro:: NMOD_RED3(r, a_hi, a_me, a_lo, mod) 11 | # .. macro:: NMOD_MUL_PRENORM(res, a, b, mod) 12 | # .. macro:: NMOD_MUL_FULLWORD(res, a, b, mod) 13 | # .. macro:: NMOD_ADDMUL(r, a, b, mod) 14 | 15 | cdef extern from "flint/nmod.h": 16 | void nmod_init(nmod_t * mod, ulong n) 17 | ulong _nmod_add(ulong a, ulong b, nmod_t mod) 18 | ulong nmod_add(ulong a, ulong b, nmod_t mod) 19 | ulong _nmod_sub(ulong a, ulong b, nmod_t mod) 20 | ulong nmod_sub(ulong a, ulong b, nmod_t mod) 21 | ulong nmod_neg(ulong a, nmod_t mod) 22 | ulong nmod_mul(ulong a, ulong b, nmod_t mod) 23 | ulong _nmod_mul_fullword(ulong a, ulong b, nmod_t mod) 24 | ulong nmod_inv(ulong a, nmod_t mod) 25 | ulong nmod_div(ulong a, ulong b, nmod_t mod) 26 | int nmod_divides(ulong * a, ulong b, ulong c, nmod_t mod) 27 | ulong nmod_pow_ui(ulong a, ulong e, nmod_t mod) 28 | ulong nmod_pow_fmpz(ulong a, const fmpz_t e, nmod_t mod) 29 | # void nmod_discrete_log_pohlig_hellman_init(nmod_discrete_log_pohlig_hellman_t L) 30 | # void nmod_discrete_log_pohlig_hellman_clear(nmod_discrete_log_pohlig_hellman_t L) 31 | # double nmod_discrete_log_pohlig_hellman_precompute_prime(nmod_discrete_log_pohlig_hellman_t L, ulong p) 32 | # ulong nmod_discrete_log_pohlig_hellman_primitive_root(const nmod_discrete_log_pohlig_hellman_t L) 33 | # ulong nmod_discrete_log_pohlig_hellman_run(const nmod_discrete_log_pohlig_hellman_t L, ulong y) 34 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/nmod_mpoly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong, ulong 2 | from flint.flintlib.types.nmod cimport nmod_mpoly_ctx_t, nmod_mpoly_factor_t, nmod_mpoly_t 3 | 4 | 5 | 6 | cdef extern from "flint/nmod_mpoly_factor.h": 7 | void nmod_mpoly_factor_init(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) 8 | void nmod_mpoly_factor_clear(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) 9 | void nmod_mpoly_factor_swap(nmod_mpoly_factor_t f, nmod_mpoly_factor_t g, const nmod_mpoly_ctx_t ctx) 10 | slong nmod_mpoly_factor_length(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) 11 | ulong nmod_mpoly_factor_get_constant_ui(const nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) 12 | void nmod_mpoly_factor_get_base(nmod_mpoly_t p, const nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) 13 | void nmod_mpoly_factor_swap_base(nmod_mpoly_t p, nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) 14 | slong nmod_mpoly_factor_get_exp_si(nmod_mpoly_factor_t f, slong i, const nmod_mpoly_ctx_t ctx) 15 | void nmod_mpoly_factor_sort(nmod_mpoly_factor_t f, const nmod_mpoly_ctx_t ctx) 16 | int nmod_mpoly_factor_squarefree(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) 17 | int nmod_mpoly_factor(nmod_mpoly_factor_t f, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) 18 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/nmod_poly_factor.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_rand_t, nmod_t, nn_srcptr, slong, ulong 2 | from flint.flintlib.types.nmod cimport nmod_poly_factor_t, nmod_poly_t 3 | 4 | 5 | 6 | cdef extern from "flint/nmod_poly_factor.h": 7 | void nmod_poly_factor_init(nmod_poly_factor_t fac) 8 | void nmod_poly_factor_clear(nmod_poly_factor_t fac) 9 | void nmod_poly_factor_realloc(nmod_poly_factor_t fac, slong alloc) 10 | void nmod_poly_factor_fit_length(nmod_poly_factor_t fac, slong len) 11 | void nmod_poly_factor_set(nmod_poly_factor_t res, const nmod_poly_factor_t fac) 12 | void nmod_poly_factor_print(const nmod_poly_factor_t fac) 13 | void nmod_poly_factor_insert(nmod_poly_factor_t fac, const nmod_poly_t poly, slong exp) 14 | void nmod_poly_factor_concat(nmod_poly_factor_t res, const nmod_poly_factor_t fac) 15 | void nmod_poly_factor_pow(nmod_poly_factor_t fac, slong exp) 16 | int nmod_poly_is_irreducible(const nmod_poly_t f) 17 | int nmod_poly_is_irreducible_ddf(const nmod_poly_t f) 18 | int nmod_poly_is_irreducible_rabin(const nmod_poly_t f) 19 | int _nmod_poly_is_squarefree(nn_srcptr f, slong len, nmod_t mod) 20 | int nmod_poly_is_squarefree(const nmod_poly_t f) 21 | void nmod_poly_factor_squarefree(nmod_poly_factor_t res, const nmod_poly_t f) 22 | int nmod_poly_factor_equal_deg_prob(nmod_poly_t factor, flint_rand_t state, const nmod_poly_t pol, slong d) 23 | void nmod_poly_factor_equal_deg(nmod_poly_factor_t factors, const nmod_poly_t pol, slong d) 24 | void nmod_poly_factor_distinct_deg(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const * degs) 25 | void nmod_poly_factor_distinct_deg_threaded(nmod_poly_factor_t res, const nmod_poly_t poly, slong * const * degs) 26 | void nmod_poly_factor_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) 27 | void nmod_poly_factor_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) 28 | void nmod_poly_factor_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t poly) 29 | ulong nmod_poly_factor_with_berlekamp(nmod_poly_factor_t res, const nmod_poly_t f) 30 | ulong nmod_poly_factor_with_cantor_zassenhaus(nmod_poly_factor_t res, const nmod_poly_t f) 31 | ulong nmod_poly_factor_with_kaltofen_shoup(nmod_poly_factor_t res, const nmod_poly_t f) 32 | ulong nmod_poly_factor(nmod_poly_factor_t res, const nmod_poly_t f) 33 | void _nmod_poly_interval_poly_worker(void * arg_ptr) 34 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/nmod_vec.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport flint_bitcnt_t, flint_rand_t, nmod_t, nn_ptr, nn_srcptr, slong, ulong 2 | 3 | # unknown type FILE 4 | # unknown type dot_params_t 5 | 6 | # .. macro:: NMOD_VEC_DOT(res, i, len, expr1, expr2, mod, params) 7 | 8 | cdef extern from "flint/nmod_vec.h": 9 | nn_ptr _nmod_vec_init(slong len) 10 | void _nmod_vec_clear(nn_ptr vec) 11 | void _nmod_vec_randtest(nn_ptr vec, flint_rand_t state, slong len, nmod_t mod) 12 | void _nmod_vec_set(nn_ptr res, nn_srcptr vec, slong len) 13 | void _nmod_vec_zero(nn_ptr vec, slong len) 14 | void _nmod_vec_swap(nn_ptr a, nn_ptr b, slong length) 15 | void _nmod_vec_reduce(nn_ptr res, nn_srcptr vec, slong len, nmod_t mod) 16 | flint_bitcnt_t _nmod_vec_max_bits(nn_srcptr vec, slong len) 17 | int _nmod_vec_equal(nn_srcptr vec, nn_srcptr vec2, slong len) 18 | void _nmod_vec_print_pretty(nn_srcptr vec, slong len, nmod_t mod) 19 | # int _nmod_vec_fprint_pretty(FILE * file, nn_srcptr vec, slong len, nmod_t mod) 20 | int _nmod_vec_print(nn_srcptr vec, slong len, nmod_t mod) 21 | # int _nmod_vec_fprint(FILE * f, nn_srcptr vec, slong len, nmod_t mod) 22 | void _nmod_vec_add(nn_ptr res, nn_srcptr vec1, nn_srcptr vec2, slong len, nmod_t mod) 23 | void _nmod_vec_sub(nn_ptr res, nn_srcptr vec1, nn_srcptr vec2, slong len, nmod_t mod) 24 | void _nmod_vec_neg(nn_ptr res, nn_srcptr vec, slong len, nmod_t mod) 25 | void _nmod_vec_scalar_mul_nmod(nn_ptr res, nn_srcptr vec, slong len, ulong c, nmod_t mod) 26 | void _nmod_vec_scalar_mul_nmod_shoup(nn_ptr res, nn_srcptr vec, slong len, ulong c, nmod_t mod) 27 | void _nmod_vec_scalar_addmul_nmod(nn_ptr res, nn_srcptr vec, slong len, ulong c, nmod_t mod) 28 | # dot_params_t _nmod_vec_dot_params(slong len, nmod_t mod) 29 | # ulong _nmod_vec_dot(nn_srcptr vec1, nn_srcptr vec2, slong len, nmod_t mod, dot_params_t params) 30 | # ulong _nmod_vec_dot_rev(nn_srcptr vec1, nn_srcptr vec2, slong len, nmod_t mod, dot_params_t params) 31 | # ulong _nmod_vec_dot_ptr(nn_srcptr vec1, const nn_ptr * vec2, slong offset, slong len, nmod_t mod, dot_params_t params) 32 | int _nmod_vec_dot_bound_limbs(slong len, nmod_t mod) 33 | # int _nmod_vec_dot_bound_limbs_from_params(slong len, nmod_t mod, dot_params_t params) 34 | -------------------------------------------------------------------------------- /src/flint/flintlib/functions/partitions.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.arb cimport arb_t 2 | from flint.flintlib.types.arf cimport arf_t 3 | from flint.flintlib.types.flint cimport fmpz_t, slong, ulong 4 | 5 | 6 | 7 | cdef extern from "flint/partitions.h": 8 | void partitions_rademacher_bound(arf_t b, const fmpz_t n, ulong N) 9 | void partitions_hrr_sum_arb(arb_t x, const fmpz_t n, slong N0, slong N, int use_doubles) 10 | void partitions_fmpz_fmpz(fmpz_t p, const fmpz_t n, int use_doubles) 11 | void partitions_fmpz_ui(fmpz_t p, ulong n) 12 | void partitions_fmpz_ui_using_doubles(fmpz_t p, ulong n) 13 | void partitions_leading_fmpz(arb_t res, const fmpz_t n, slong prec) 14 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/flintlib/types/__init__.py -------------------------------------------------------------------------------- /src/flint/flintlib/types/acb.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong, ulong 2 | from flint.flintlib.types.arb cimport arb_struct, arb_ptr, arb_poly_t, mag_struct 3 | 4 | 5 | cdef extern from "flint/acb_types.h": 6 | 7 | ctypedef struct acb_struct: 8 | arb_struct real 9 | arb_struct imag 10 | 11 | ctypedef acb_struct acb_t[1] 12 | ctypedef acb_struct * acb_ptr 13 | ctypedef const acb_struct * acb_srcptr 14 | 15 | ctypedef struct acb_mat_struct: 16 | acb_ptr entries 17 | slong r 18 | slong c 19 | acb_ptr * rows 20 | 21 | ctypedef acb_mat_struct acb_mat_t[1] 22 | 23 | ctypedef struct acb_poly_struct: 24 | acb_ptr coeffs 25 | slong alloc 26 | slong length 27 | 28 | ctypedef acb_poly_struct acb_poly_t[1] 29 | 30 | 31 | cdef extern from "flint/acb.h": 32 | 33 | arb_ptr acb_realref(const acb_t x) 34 | arb_ptr acb_imagref(const acb_t x) 35 | 36 | 37 | cdef extern from "flint/acb_mat.h": 38 | 39 | acb_struct * acb_mat_entry(acb_mat_t mat, slong i, slong j) 40 | slong acb_mat_nrows(const acb_mat_t x) 41 | slong acb_mat_ncols(const acb_mat_t x) 42 | 43 | 44 | cdef extern from "flint/acb_poly.h": 45 | 46 | acb_ptr acb_poly_get_coeff_ptr(arb_poly_t poly, slong n) 47 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/acb_calc.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong 2 | from flint.flintlib.types.acb cimport acb_ptr, acb_t 3 | 4 | cdef extern from "flint/acb_calc.h": 5 | 6 | ctypedef int (*acb_calc_func_t)(acb_ptr out, const acb_t inp, void * param, slong order, slong prec) 7 | 8 | ctypedef struct acb_calc_integrate_opt_struct: 9 | slong deg_limit 10 | slong eval_limit 11 | slong depth_limit 12 | int use_heap 13 | int verbose 14 | 15 | ctypedef acb_calc_integrate_opt_struct acb_calc_integrate_opt_t[1] 16 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/acb_dirichlet.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ulong, slong 2 | from flint.flintlib.types.arb cimport mag_struct 3 | from flint.flintlib.types.acb cimport acb_t, acb_ptr, acb_struct 4 | 5 | cdef extern from "flint/acb_dirichlet.h": 6 | 7 | ctypedef struct acb_dirichlet_roots_struct: 8 | ulong order 9 | ulong reduced_order 10 | acb_t z 11 | slong size 12 | slong depth 13 | acb_ptr * Z 14 | int use_pow 15 | 16 | ctypedef acb_dirichlet_roots_struct acb_dirichlet_roots_t[1] 17 | 18 | ctypedef struct acb_dirichlet_hurwitz_precomp_struct: 19 | acb_struct s 20 | mag_struct err 21 | acb_ptr coeffs 22 | int deflate 23 | slong A 24 | slong N 25 | slong K 26 | 27 | ctypedef acb_dirichlet_hurwitz_precomp_struct acb_dirichlet_hurwitz_precomp_t[1] 28 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/acb_theta.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong 2 | from flint.flintlib.types.acb cimport acb_ptr, acb_srcptr, acb_t, acb_mat_t 3 | 4 | cdef extern from "flint/acb_theta.h": 5 | 6 | ctypedef struct acb_theta_eld_struct: 7 | slong dim 8 | slong ambient_dim 9 | slong * last_coords 10 | slong min 11 | slong mid 12 | slong max 13 | slong nr 14 | slong nl 15 | acb_theta_eld_struct * rchildren 16 | acb_theta_eld_struct * lchildren 17 | slong nb_pts, nb_border 18 | slong * box 19 | 20 | ctypedef acb_theta_eld_struct acb_theta_eld_t[1] 21 | ctypedef void (*acb_theta_naive_worker_t)(acb_ptr, acb_srcptr, acb_srcptr, const slong *, slong, const acb_t, const slong *, slong, slong, slong, slong) 22 | ctypedef int (*acb_theta_ql_worker_t)(acb_ptr, acb_srcptr, acb_srcptr, arb_srcptr, arb_srcptr, const acb_mat_t, slong, slong) 23 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/arb.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ulong, slong, fmpz_struct 2 | from flint.flintlib.types.arf cimport arf_struct, arf_ptr 3 | 4 | cdef extern from "flint/arb_types.h": 5 | ctypedef struct mag_struct: 6 | fmpz_struct exp 7 | ulong man 8 | 9 | ctypedef mag_struct mag_t[1] 10 | ctypedef mag_struct * mag_ptr 11 | ctypedef const mag_struct * mag_srcptr 12 | 13 | ctypedef struct arb_struct: 14 | arf_struct mid 15 | mag_struct rad 16 | 17 | ctypedef arb_struct arb_t[1] 18 | ctypedef arb_struct * arb_ptr 19 | ctypedef const arb_struct * arb_srcptr 20 | 21 | ctypedef struct arb_mat_struct: 22 | arb_ptr entries 23 | slong r 24 | slong c 25 | arb_ptr * rows 26 | 27 | ctypedef arb_mat_struct arb_mat_t[1] 28 | 29 | ctypedef struct arb_poly_struct: 30 | arb_ptr coeffs 31 | slong alloc 32 | slong length 33 | 34 | ctypedef arb_poly_struct arb_poly_t[1] 35 | 36 | cdef extern from "flint/arb_types.h": 37 | # Macros 38 | cdef arf_ptr arb_midref(const arb_t x) 39 | cdef mag_ptr arb_radref(const arb_t x) 40 | cdef const ulong ARB_STR_MORE 41 | cdef const ulong ARB_STR_NO_RADIUS 42 | cdef const ulong ARB_STR_CONDENSE 43 | 44 | cdef extern from "flint/arb_mat.h": 45 | # Macros 46 | arb_ptr arb_mat_entry(arb_mat_t mat, slong i, slong j) 47 | slong arb_mat_nrows(arb_mat_t mat) 48 | slong arb_mat_ncols(arb_mat_t mat) 49 | 50 | cdef extern from "flint/arb_poly.h": 51 | void arb_poly_set_arb(arb_poly_t poly, const arb_t c) 52 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/arf.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_struct, slong, ulong, nn_ptr 2 | 3 | cdef extern from "flint/arf.h": 4 | ctypedef enum arf_rnd_t: 5 | ARF_RND_DOWN 6 | ARF_RND_NEAR 7 | ARF_RND_FLOOR 8 | ARF_RND_CEIL 9 | ARF_RND_UP 10 | 11 | cdef extern from "flint/arf_types.h": 12 | 13 | cdef const int ARF_NOPTR_LIMBS 14 | 15 | ctypedef struct mantissa_noptr_struct: 16 | ulong d[ARF_NOPTR_LIMBS] 17 | 18 | ctypedef struct mantissa_ptr_struct: 19 | slong alloc 20 | nn_ptr d 21 | 22 | ctypedef union mantissa_struct: 23 | mantissa_noptr_struct noptr 24 | mantissa_ptr_struct ptr 25 | 26 | ctypedef struct arf_struct: 27 | fmpz_struct exp 28 | slong size 29 | mantissa_struct d 30 | 31 | ctypedef arf_struct arf_t[1] 32 | ctypedef arf_struct * arf_ptr 33 | ctypedef const arf_struct * arf_srcptr 34 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/arith.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ulong 2 | from flint.flintlib.types.fmpz cimport fmpz_poly_t 3 | from flint.flintlib.functions.fmpq_poly cimport fmpq_poly_t 4 | 5 | 6 | cdef extern from "flint/arith.h": 7 | # Macros 8 | void arith_legendre_polynomial(fmpq_poly_t v, ulong n) 9 | void arith_chebyshev_t_polynomial(fmpz_poly_t v, ulong n) 10 | void arith_chebyshev_u_polynomial(fmpz_poly_t v, ulong n) 11 | void arith_cyclotomic_polynomial(fmpz_poly_t v, ulong n) 12 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/dirichlet.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ulong 2 | from flint.flintlib.functions.nmod cimport nmod_t 3 | 4 | 5 | cdef extern from "flint/dirichlet.h": 6 | 7 | ctypedef struct dirichlet_group_struct: 8 | ulong q 9 | ulong q_even 10 | nmod_t mod 11 | ulong rad_q 12 | ulong phi_q 13 | long neven 14 | long num 15 | ulong expo 16 | void * P 17 | ulong * generators 18 | ulong * PHI 19 | ctypedef dirichlet_group_struct dirichlet_group_t[1] 20 | 21 | ctypedef struct dirichlet_char_struct: 22 | ulong n 23 | ulong * log 24 | ctypedef dirichlet_char_struct dirichlet_char_t[1] 25 | 26 | cdef ulong DIRICHLET_CHI_NULL 27 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/flint.pxd: -------------------------------------------------------------------------------- 1 | # _flint.pxd 2 | # 3 | # Define fundamental types and constants 4 | 5 | cdef extern from "Python.h": 6 | ctypedef void PyObject 7 | 8 | cdef enum: 9 | FMPZ_UNKNOWN = 0 10 | FMPZ_REF = 1 11 | FMPZ_TMP = 2 12 | 13 | 14 | # 15 | # Note: ulong and slong are used throughout Flint/Arb. They are expected to be 16 | # 32 bit unsigned and signed integer types on a 32 bit system and 64 bit on a 17 | # 64 bit system. We denote them as unsigned long and long here which would be 18 | # incorrect on 64 bit Windows but the definition here does not matter because 19 | # their actual sizes will be determined by the values from gmp.h and 20 | # flint/flint.h. Their size in bits (32 or 64) is recorded in the FLINT_BITS 21 | # macro which is defined in flint/flint.h. 22 | # 23 | 24 | cdef extern from "gmp.h": 25 | ctypedef unsigned long ulong 26 | ctypedef unsigned long mp_limb_t 27 | ctypedef long mp_size_t 28 | ctypedef long mp_exp_t 29 | ctypedef mp_limb_t* mp_ptr 30 | ctypedef mp_limb_t* mp_srcptr 31 | ctypedef unsigned long mp_bitcnt_t 32 | 33 | cdef extern from "flint/fmpz.h": 34 | ctypedef long slong 35 | ctypedef ulong flint_bitcnt_t 36 | ctypedef ulong * nn_ptr 37 | ctypedef const ulong * nn_srcptr 38 | 39 | ctypedef slong fmpz_struct 40 | ctypedef fmpz_struct fmpz_t[1] 41 | 42 | cdef extern from "flint/fmpz.h": 43 | # Macros 44 | int COEFF_IS_MPZ(fmpz_struct x) 45 | 46 | cdef extern from *: 47 | """ 48 | #if __FLINT_RELEASE < 30200 /* Flint < 3.2.0 */ 49 | 50 | /* Functions renamed in Flint 3.2.0 */ 51 | #define flint_rand_init flint_randinit 52 | #define flint_rand_clear flint_randclear 53 | 54 | #endif 55 | """ 56 | 57 | cdef extern from "flint/flint.h": 58 | # These defines are needed to work around a Cython bug. 59 | # Otherwise sizeof(ulong) will give the wrong size on 64 bit Windows. 60 | # https://github.com/cython/cython/issues/6339 61 | """ 62 | #define SIZEOF_ULONG sizeof(ulong) 63 | #define SIZEOF_SLONG sizeof(slong) 64 | """ 65 | int SIZEOF_ULONG 66 | int SIZEOF_SLONG 67 | 68 | ctypedef struct __FLINT_FILE: 69 | pass 70 | ctypedef __FLINT_FILE FLINT_FILE 71 | 72 | const char * FLINT_VERSION 73 | const int __FLINT_RELEASE 74 | 75 | const int FLINT_BITS 76 | 77 | ctypedef void * flint_rand_t 78 | void flint_rand_init(flint_rand_t state) 79 | void flint_rand_clear(flint_rand_t state) 80 | 81 | void flint_set_num_threads(long) 82 | long flint_get_num_threads() 83 | 84 | void flint_cleanup() 85 | 86 | ctypedef struct nmod_t: 87 | mp_limb_t n 88 | mp_limb_t ninv 89 | flint_bitcnt_t norm 90 | 91 | ctypedef struct fmpq: 92 | fmpz_struct num 93 | fmpz_struct den 94 | 95 | cdef extern from *: 96 | """ 97 | /* FLINT_BITS is not known until C compile time. We need to check if long 98 | * or long long matches FLINT_BITS to know which CPython function to call. 99 | */ 100 | #if FLINT_BITS == 32 && LONG_MAX == 2147483647 101 | #define pylong_as_slong PyLong_AsLongAndOverflow 102 | #elif FLINT_BITS == 64 && LLONG_MAX == 9223372036854775807 103 | #define pylong_as_slong PyLong_AsLongLongAndOverflow 104 | #else 105 | #error FLINT_BITS does not match width of long or long long. 106 | #endif 107 | """ 108 | slong pylong_as_slong(PyObject *pylong, int *overflow) 109 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/fmpq.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong, fmpz_struct, fmpz_t 2 | from flint.flintlib.types.flint cimport fmpq as fmpq_struct 3 | from flint.flintlib.types.fmpz cimport fmpz_mpoly_ctx_t, fmpz_mpoly_t 4 | 5 | cdef extern from "flint/fmpq_types.h": 6 | 7 | ctypedef fmpq_struct fmpq_t[1] 8 | 9 | ctypedef struct fmpq_mat_struct: 10 | fmpq_struct * entries 11 | slong r 12 | slong c 13 | fmpq_struct ** rows 14 | 15 | ctypedef fmpq_mat_struct fmpq_mat_t[1] 16 | 17 | ctypedef struct fmpq_poly_struct: 18 | fmpz_struct * coeffs 19 | slong alloc 20 | slong length 21 | fmpz_t den 22 | 23 | ctypedef fmpq_poly_struct fmpq_poly_t[1] 24 | 25 | ctypedef struct fmpq_mpoly_ctx_struct: 26 | fmpz_mpoly_ctx_t zctx 27 | 28 | ctypedef fmpq_mpoly_ctx_struct fmpq_mpoly_ctx_t[1] 29 | 30 | ctypedef struct fmpq_mpoly_struct: 31 | fmpq_t content 32 | fmpz_mpoly_t zpoly 33 | 34 | ctypedef fmpq_mpoly_struct fmpq_mpoly_t[1] 35 | 36 | ctypedef struct fmpq_mpoly_factor_struct: 37 | fmpq_t constant 38 | fmpq_mpoly_struct * poly 39 | fmpz_struct * exp 40 | slong num 41 | slong alloc 42 | 43 | ctypedef fmpq_mpoly_factor_struct fmpq_mpoly_factor_t[1] 44 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/fmpz.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ( 2 | mp_ptr, 3 | fmpz_struct, 4 | fmpz_t, 5 | ulong, 6 | slong, 7 | flint_bitcnt_t, 8 | ) 9 | from flint.flintlib.types.mpoly cimport mpoly_ctx_t 10 | 11 | 12 | cdef extern from "flint/fmpz_types.h": 13 | 14 | ctypedef struct fmpz_preinvn_struct: 15 | mp_ptr dinv 16 | slong n 17 | flint_bitcnt_t norm 18 | ctypedef fmpz_preinvn_struct fmpz_preinvn_t[1] 19 | 20 | ctypedef struct fmpz_factor_struct: 21 | int sign 22 | fmpz_struct * p 23 | ulong * exp 24 | slong alloc 25 | slong num 26 | ctypedef fmpz_factor_struct fmpz_factor_t[1] 27 | 28 | ctypedef struct fmpz_mat_struct: 29 | fmpz_struct * entries 30 | slong r 31 | slong c 32 | fmpz_struct ** rows 33 | ctypedef fmpz_mat_struct fmpz_mat_t[1] 34 | long fmpz_mat_nrows(fmpz_mat_t mat) 35 | long fmpz_mat_ncols(fmpz_mat_t mat) 36 | 37 | ctypedef struct fmpz_poly_struct: 38 | fmpz_struct * coeffs 39 | slong alloc 40 | slong length 41 | ctypedef fmpz_poly_struct fmpz_poly_t[1] 42 | 43 | ctypedef struct fmpz_poly_factor_struct: 44 | fmpz_struct c 45 | fmpz_poly_struct *p 46 | slong *exp 47 | slong num 48 | slong alloc 49 | ctypedef fmpz_poly_factor_struct fmpz_poly_factor_t[1] 50 | 51 | ctypedef struct fmpz_mpoly_ctx_struct: 52 | mpoly_ctx_t minfo 53 | 54 | ctypedef fmpz_mpoly_ctx_struct fmpz_mpoly_ctx_t[1] 55 | 56 | ctypedef struct fmpz_mpoly_struct: 57 | fmpz_struct * coeffs 58 | ulong * exps 59 | slong alloc 60 | slong length 61 | flint_bitcnt_t bits 62 | 63 | ctypedef fmpz_mpoly_struct fmpz_mpoly_t[1] 64 | 65 | ctypedef struct fmpz_mpoly_factor_struct: 66 | fmpz_t constant 67 | fmpz_t constant_den 68 | fmpz_mpoly_struct * poly 69 | fmpz_struct * exp 70 | slong num 71 | slong alloc 72 | 73 | ctypedef fmpz_mpoly_factor_struct fmpz_mpoly_factor_t[1] 74 | 75 | ctypedef struct fmpz_poly_q_struct: 76 | fmpz_poly_struct *num 77 | fmpz_poly_struct *den 78 | 79 | ctypedef fmpz_poly_q_struct fmpz_poly_q_t[1] 80 | 81 | ctypedef struct fmpz_mpoly_q_struct: 82 | fmpz_mpoly_struct num 83 | fmpz_mpoly_struct den 84 | 85 | ctypedef fmpz_mpoly_q_struct fmpz_mpoly_q_t[1] 86 | 87 | ctypedef struct fmpzi_struct: 88 | fmpz_struct a 89 | fmpz_struct b 90 | 91 | ctypedef fmpzi_struct fmpzi_t[1] 92 | 93 | 94 | cdef extern from "flint/fmpz_factor.h": 95 | # XXX: Missing from docs... 96 | void fmpz_factor_expand(fmpz_t n, const fmpz_factor_t factor) 97 | 98 | 99 | cdef extern from "flint/fmpz_mpoly.h": 100 | 101 | ctypedef struct fmpz_mpoly_vec_struct: 102 | fmpz_mpoly_struct * p 103 | slong alloc 104 | slong length 105 | 106 | ctypedef fmpz_mpoly_vec_struct fmpz_mpoly_vec_t[1] 107 | 108 | # Macro 109 | fmpz_mpoly_struct * fmpz_mpoly_vec_entry(fmpz_mpoly_vec_t vec, slong i) 110 | 111 | cdef extern from "flint/fmpz_lll.h": 112 | 113 | cdef enum _rep_type: 114 | GRAM 115 | Z_BASIS 116 | ctypedef _rep_type rep_type 117 | 118 | cdef enum _gram_type: 119 | APPROX 120 | EXACT 121 | ctypedef _gram_type gram_type 122 | 123 | ctypedef struct fmpz_lll_struct: 124 | double delta 125 | double eta 126 | rep_type rt 127 | gram_type gt 128 | ctypedef fmpz_lll_struct fmpz_lll_t[1] 129 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/fmpz_mod.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ulong, slong, fmpz_struct, fmpz_t, nmod_t, flint_bitcnt_t 2 | from flint.flintlib.types.fmpz cimport fmpz_struct, fmpz_preinvn_struct, fmpz_mat_struct 3 | from flint.flintlib.types.mpoly cimport mpoly_ctx_t 4 | 5 | 6 | cdef extern from "flint/fmpz_mod_types.h": 7 | 8 | ctypedef struct fmpz_mod_ctx_struct: 9 | fmpz_t n 10 | void (* add_fxn)(fmpz_t, const fmpz_t, const fmpz_t, const fmpz_mod_ctx_struct*) 11 | void (* sub_fxn)(fmpz_t, const fmpz_t, const fmpz_t, const fmpz_mod_ctx_struct*) 12 | void (* mul_fxn)(fmpz_t, const fmpz_t, const fmpz_t, const fmpz_mod_ctx_struct*) 13 | nmod_t mod 14 | ulong n_limbs[3] 15 | ulong ninv_limbs[3] 16 | fmpz_preinvn_struct * ninv_huge 17 | 18 | ctypedef fmpz_mod_ctx_struct fmpz_mod_ctx_t[1] 19 | 20 | ctypedef fmpz_mat_struct fmpz_mod_mat_struct 21 | 22 | ctypedef fmpz_mod_mat_struct fmpz_mod_mat_t[1] 23 | 24 | ctypedef struct fmpz_mod_poly_struct: 25 | fmpz_struct * coeffs 26 | slong alloc 27 | slong length 28 | 29 | ctypedef fmpz_mod_poly_struct fmpz_mod_poly_t[1] 30 | 31 | ctypedef struct fmpz_mod_poly_factor_struct: 32 | fmpz_mod_poly_struct * poly 33 | slong *exp 34 | slong num 35 | slong alloc 36 | 37 | ctypedef fmpz_mod_poly_factor_struct fmpz_mod_poly_factor_t[1] 38 | 39 | ctypedef struct fmpz_mod_mpoly_ctx_struct: 40 | mpoly_ctx_t minfo 41 | fmpz_mod_ctx_t ffinfo 42 | 43 | ctypedef fmpz_mod_mpoly_ctx_struct fmpz_mod_mpoly_ctx_t[1] 44 | 45 | ctypedef struct fmpz_mod_mpoly_struct: 46 | fmpz_struct * coeffs 47 | ulong * exps 48 | slong length 49 | flint_bitcnt_t bits 50 | slong coeffs_alloc 51 | slong exps_alloc 52 | 53 | ctypedef fmpz_mod_mpoly_struct fmpz_mod_mpoly_t[1] 54 | 55 | ctypedef struct fmpz_mod_mpoly_factor_struct: 56 | fmpz_t constant 57 | fmpz_mod_mpoly_struct * poly 58 | fmpz_struct * exp 59 | slong num 60 | slong alloc 61 | 62 | ctypedef fmpz_mod_mpoly_factor_struct fmpz_mod_mpoly_factor_t[1] 63 | 64 | 65 | cdef extern from "flint/fmpz_mod.h": 66 | 67 | ctypedef struct fmpz_mod_discrete_log_pohlig_hellman_table_entry_struct: 68 | fmpz_t gammapow 69 | ulong cm 70 | 71 | ctypedef struct fmpz_mod_discrete_log_pohlig_hellman_entry_struct: 72 | slong exp 73 | ulong prime 74 | fmpz_t gamma 75 | fmpz_t gammainv 76 | fmpz_t startingbeta 77 | fmpz_t co 78 | fmpz_t startinge 79 | fmpz_t idem 80 | ulong cbound 81 | ulong dbound 82 | fmpz_mod_discrete_log_pohlig_hellman_table_entry_struct * table # length cbound */ 83 | 84 | ctypedef struct fmpz_mod_discrete_log_pohlig_hellman_struct: 85 | fmpz_mod_ctx_t fpctx 86 | fmpz_t pm1 # p - 1 */ 87 | fmpz_t alpha # p.r. of p */ 88 | fmpz_t alphainv 89 | slong num_factors # factors of p - 1 90 | fmpz_mod_discrete_log_pohlig_hellman_entry_struct * entries 91 | 92 | ctypedef fmpz_mod_discrete_log_pohlig_hellman_struct fmpz_mod_discrete_log_pohlig_hellman_t[1] 93 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/fmpz_mod_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong, fmpz_struct, fmpz_t 2 | from flint.flintlib.types.fmpz cimport fmpz_mat_struct 3 | from flint.flintlib.types.fmpz_mod cimport fmpz_mod_ctx_struct 4 | 5 | 6 | cdef extern from "flint/fmpz_mod_poly.h": 7 | 8 | # Type definitions *********************************************************/ 9 | ctypedef struct fmpz_mod_poly_struct: 10 | fmpz_struct * coeffs 11 | slong alloc 12 | slong length 13 | 14 | ctypedef fmpz_mod_poly_struct fmpz_mod_poly_t[1] 15 | 16 | ctypedef struct fmpz_mod_poly_res_struct: 17 | fmpz_t res 18 | fmpz_t lc 19 | slong len0 20 | slong len1 21 | slong off 22 | 23 | ctypedef fmpz_mod_poly_res_struct fmpz_mod_poly_res_t[1] 24 | 25 | ctypedef struct fmpz_mod_poly_frobenius_powers_2exp_struct: 26 | fmpz_mod_poly_struct * pow 27 | slong len 28 | 29 | ctypedef fmpz_mod_poly_frobenius_powers_2exp_struct fmpz_mod_poly_frobenius_powers_2exp_t[1] 30 | 31 | ctypedef struct fmpz_mod_poly_frobenius_powers_struct: 32 | fmpz_mod_poly_struct * pow 33 | slong len 34 | 35 | ctypedef fmpz_mod_poly_frobenius_powers_struct fmpz_mod_poly_frobenius_powers_t[1] 36 | 37 | ctypedef struct fmpz_mod_poly_matrix_precompute_arg_t: 38 | fmpz_mat_struct * A 39 | fmpz_mod_poly_struct * poly1 40 | fmpz_mod_poly_struct * poly2 41 | fmpz_mod_poly_struct * poly2inv 42 | const fmpz_mod_ctx_struct * ctx 43 | 44 | ctypedef struct fmpz_mod_poly_compose_mod_precomp_preinv_arg_t: 45 | fmpz_mat_struct * A 46 | fmpz_mod_poly_struct * res 47 | fmpz_mod_poly_struct * poly1 48 | fmpz_mod_poly_struct * poly3 49 | fmpz_mod_poly_struct * poly3inv 50 | const fmpz_mod_ctx_struct * ctx 51 | 52 | # Radix conversion *********************************************************/ 53 | ctypedef struct fmpz_mod_poly_radix_struct: 54 | fmpz_struct *V 55 | fmpz_struct *W 56 | fmpz_struct **Rpow 57 | fmpz_struct **Rinv 58 | slong degR 59 | slong k 60 | fmpz_struct invL 61 | 62 | ctypedef fmpz_mod_poly_radix_struct fmpz_mod_poly_radix_t[1] 63 | 64 | # Berlekamp-Massey Algorithm - see fmpz_mod_poly/berlekamp_massey.c for more info ********/ 65 | ctypedef struct fmpz_mod_berlekamp_massey_struct: 66 | slong npoints 67 | fmpz_mod_poly_t R0, R1 68 | fmpz_mod_poly_t V0, V1 69 | fmpz_mod_poly_t qt, rt 70 | fmpz_mod_poly_t points 71 | 72 | ctypedef fmpz_mod_berlekamp_massey_struct fmpz_mod_berlekamp_massey_t[1] 73 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/fq.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport fmpz_struct, slong 2 | from flint.flintlib.types.fmpz cimport fmpz_poly_t, fmpz_poly_struct 3 | from flint.flintlib.functions.fmpz_mod cimport fmpz_mod_ctx_t 4 | from flint.flintlib.functions.fmpz_mod_poly cimport fmpz_mod_poly_t 5 | 6 | 7 | cdef extern from "flint/fq.h": 8 | # Type definitions **********************************************/ 9 | ctypedef fmpz_poly_t fq_t 10 | ctypedef fmpz_poly_struct fq_struct 11 | 12 | ctypedef struct fq_ctx_struct: 13 | fmpz_mod_ctx_t ctxp 14 | 15 | int sparse_modulus 16 | int is_conway # whether field was initialized with the Flint Conway tables (assures primitivity) 17 | 18 | fmpz_struct * a 19 | slong * j 20 | slong len 21 | 22 | fmpz_mod_poly_t modulus 23 | fmpz_mod_poly_t inv 24 | 25 | char * var 26 | ctypedef fq_ctx_struct fq_ctx_t[1] 27 | 28 | ctypedef struct fq_mat_struct: 29 | fq_struct * entries 30 | slong r 31 | slong s 32 | fq_struct ** rows 33 | ctypedef fq_mat_struct fq_mat_t[1] 34 | 35 | ctypedef struct fq_poly_struct: 36 | fq_struct * coeffs 37 | slong alloc 38 | slong length 39 | ctypedef fq_poly_struct fq_poly_t[1] 40 | 41 | ctypedef struct fq_poly_factor_struct: 42 | fq_poly_struct * poly 43 | slong * exp 44 | slong num 45 | slong alloc 46 | 47 | ctypedef fq_poly_factor_struct fq_poly_factor_t[1] 48 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/fq_default.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ulong, fmpz_t 2 | from flint.flintlib.types.nmod cimport nmod_t, nmod_mat_t, nmod_poly_t, nmod_poly_factor_t 3 | from flint.flintlib.types.fmpz_mod cimport fmpz_mod_ctx_t, fmpz_mod_mat_t, fmpz_mod_poly_t, fmpz_mod_poly_factor_t 4 | from flint.flintlib.types.fq_nmod cimport fq_nmod_t, fq_nmod_ctx_t, fq_nmod_mat_t, fq_nmod_poly_t, fq_nmod_poly_factor_t 5 | from flint.flintlib.types.fq_zech cimport fq_zech_t, fq_zech_ctx_t, fq_zech_mat_t, fq_zech_poly_t, fq_zech_poly_factor_t 6 | from flint.flintlib.types.fq cimport fq_t, fq_ctx_t, fq_mat_t, fq_poly_t, fq_poly_factor_t 7 | 8 | 9 | cdef extern from "flint/fq_default.h": 10 | 11 | ctypedef union fq_default_struct: 12 | fq_t fq 13 | fq_nmod_t fq_nmod 14 | fq_zech_t fq_zech 15 | ulong nmod 16 | fmpz_t fmpz_mod 17 | ctypedef fq_default_struct fq_default_t[1] 18 | 19 | ctypedef struct fq_default_fmpz_mod_ctx_struct: 20 | fmpz_mod_ctx_t mod 21 | fmpz_t a # minpoly is x - a 22 | 23 | ctypedef struct fq_default_nmod_ctx_struct: 24 | nmod_t mod 25 | ulong a # minpoly is x - a 26 | 27 | # This is how it is actually defined now: 28 | # ctypedef gr_ctx_struct fq_default_ctx_struct; 29 | # ctypedef fq_default_ctx_struct fq_default_ctx_t[1]; 30 | 31 | ctypedef union fq_default_ctx_struct: 32 | fq_ctx_t fq 33 | fq_nmod_ctx_t fq_nmod 34 | fq_zech_ctx_t fq_zech 35 | fq_default_nmod_ctx_struct nmod 36 | fq_default_fmpz_mod_ctx_struct fmpz_mod 37 | 38 | ctypedef fq_default_ctx_struct fq_default_ctx_t[1] 39 | 40 | ctypedef union fq_default_mat_struct: 41 | fq_mat_t fq 42 | fq_nmod_mat_t fq_nmod 43 | fq_zech_mat_t fq_zech 44 | nmod_mat_t nmod 45 | fmpz_mod_mat_t fmpz_mod 46 | ctypedef fq_default_mat_struct fq_default_mat_t[1] 47 | 48 | ctypedef union fq_default_poly_struct: 49 | fq_poly_t fq 50 | fq_nmod_poly_t fq_nmod 51 | fq_zech_poly_t fq_zech 52 | nmod_poly_t nmod 53 | fmpz_mod_poly_t fmpz_mod 54 | 55 | ctypedef fq_default_poly_struct fq_default_poly_t[1] 56 | 57 | ctypedef union fq_default_poly_factor_struct: 58 | fq_poly_factor_t fq 59 | fq_nmod_poly_factor_t fq_nmod 60 | fq_zech_poly_factor_t fq_zech 61 | nmod_poly_factor_t nmod 62 | fmpz_mod_poly_factor_t fmpz_mod 63 | 64 | ctypedef fq_default_poly_factor_struct fq_default_poly_factor_t[1] 65 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/fq_nmod.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport mp_limb_t, slong 2 | from flint.flintlib.functions.fmpz cimport fmpz_struct 3 | from flint.flintlib.functions.nmod cimport nmod_t 4 | from flint.flintlib.functions.nmod_poly cimport nmod_poly_struct, nmod_poly_t 5 | from flint.flintlib.types.mpoly cimport mpoly_ctx_t 6 | 7 | 8 | cdef extern from "flint/fq_nmod.h": 9 | # Type definitions **********************************************/ 10 | ctypedef nmod_poly_t fq_nmod_t 11 | ctypedef nmod_poly_struct fq_nmod_struct 12 | 13 | ctypedef struct fq_nmod_ctx_struct: 14 | fmpz_struct p 15 | nmod_t mod 16 | 17 | int sparse_modulus 18 | int is_conway # whether field was generated using Flint Conway table (assures primitivity 19 | 20 | mp_limb_t *a 21 | slong *j 22 | slong len 23 | 24 | nmod_poly_t modulus 25 | nmod_poly_t inv 26 | 27 | char *var 28 | ctypedef fq_nmod_ctx_struct fq_nmod_ctx_t[1] 29 | 30 | ctypedef struct fq_nmod_poly_struct: 31 | fq_nmod_struct * coeffs 32 | slong alloc 33 | slong length 34 | ctypedef fq_nmod_poly_struct fq_nmod_poly_t[1] 35 | 36 | ctypedef struct fq_nmod_poly_factor_struct: 37 | fq_nmod_poly_struct * poly 38 | slong * exp 39 | slong num 40 | slong alloc 41 | ctypedef fq_nmod_poly_factor_struct fq_nmod_poly_factor_t[1] 42 | 43 | ctypedef struct fq_nmod_mat_struct: 44 | fq_nmod_struct * entries 45 | slong r 46 | slong s 47 | fq_nmod_struct ** rows 48 | ctypedef fq_nmod_mat_struct fq_nmod_mat_t[1] 49 | 50 | ctypedef struct fq_nmod_mpoly_ctx_struct: 51 | mpoly_ctx_t minfo 52 | fq_nmod_ctx_t fqctx 53 | 54 | ctypedef fq_nmod_mpoly_ctx_struct fq_nmod_mpoly_ctx_t[1] 55 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/fq_zech.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong, ulong 2 | from flint.flintlib.types.fq_nmod cimport fq_nmod_ctx_struct 3 | 4 | 5 | cdef extern from "flint/fq_zech.h": 6 | 7 | ctypedef struct fq_zech_struct: 8 | ulong value 9 | 10 | ctypedef fq_zech_struct fq_zech_t[1] 11 | 12 | ctypedef struct fq_zech_ctx_struct: 13 | ulong qm1 # q - 1 14 | ulong qm1o2 # (q - 1) / 2 or 1 when p == 2 15 | ulong qm1opm1 # (q - 1) / (p - 1) 16 | ulong p 17 | double ppre 18 | ulong prime_root # primitive root for prime subfield 19 | ulong * zech_log_table 20 | ulong * prime_field_table 21 | ulong * eval_table 22 | 23 | fq_nmod_ctx_struct * fq_nmod_ctx 24 | int owns_fq_nmod_ctx 25 | int is_conway # whether field was generated using Flint Conway tables (assures primitivity) 26 | 27 | ctypedef fq_zech_ctx_struct fq_zech_ctx_t[1] 28 | 29 | ctypedef struct fq_zech_mat_struct: 30 | fq_zech_struct * entries 31 | slong r 32 | slong s 33 | fq_zech_struct ** rows 34 | 35 | ctypedef fq_zech_mat_struct fq_zech_mat_t[1] 36 | 37 | ctypedef struct fq_zech_poly_struct: 38 | fq_zech_struct * coeffs 39 | slong alloc 40 | slong length 41 | 42 | ctypedef fq_zech_poly_struct fq_zech_poly_t[1] 43 | 44 | ctypedef struct fq_zech_poly_factor_struct: 45 | fq_zech_poly_struct * poly 46 | slong * exp 47 | slong num 48 | slong alloc 49 | 50 | ctypedef fq_zech_poly_factor_struct fq_zech_poly_factor_t[1] 51 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/gr.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ( 2 | FLINT_FILE, 3 | slong, 4 | ulong, 5 | flint_bitcnt_t, 6 | ) 7 | 8 | cdef extern from *: 9 | """ 10 | /* 11 | * The following functions were introduced in FLINT 3.1.0 12 | */ 13 | #if __FLINT_RELEASE < 30100 14 | #define gr_div_nonunique(res, x, y, ctx) GR_UNABLE 15 | #endif 16 | 17 | /* 18 | * The following functions were introduced in FLINT 3.2.0 19 | */ 20 | #if __FLINT_RELEASE < 30200 21 | #define gr_min(res, x, y, ctx) GR_UNABLE 22 | #define gr_max(res, x, y, ctx) GR_UNABLE 23 | #define gr_le(x, y, ctx) T_UNKNOWN 24 | #define gr_lt(x, y, ctx) T_UNKNOWN 25 | #define gr_ge(x, y, ctx) T_UNKNOWN 26 | #define gr_gt(x, y, ctx) T_UNKNOWN 27 | #define gr_abs_le(x, y, ctx) T_UNKNOWN 28 | #define gr_abs_lt(x, y, ctx) T_UNKNOWN 29 | #define gr_abs_ge(x, y, ctx) T_UNKNOWN 30 | #define gr_abs_gt(x, y, ctx) T_UNKNOWN 31 | #endif 32 | """ 33 | 34 | 35 | cdef extern from "flint/gr.h": 36 | 37 | ctypedef int truth_t 38 | cdef int T_TRUE 39 | cdef int T_FALSE 40 | cdef int T_UNKNOWN 41 | 42 | # Macros 43 | cdef int GR_SUCCESS 44 | cdef int GR_DOMAIN 45 | cdef int GR_UNABLE 46 | 47 | ctypedef struct gr_stream_struct: 48 | FLINT_FILE * fp 49 | char * s 50 | slong len 51 | slong alloc 52 | 53 | ctypedef gr_stream_struct gr_stream_t[1] 54 | 55 | ctypedef int (*gr_funcptr)() 56 | 57 | cdef const int GR_CTX_STRUCT_DATA_BYTES 58 | 59 | cdef struct gr_ctx_struct: 60 | char data[GR_CTX_STRUCT_DATA_BYTES] 61 | ulong which_ring 62 | slong sizeof_elem 63 | gr_funcptr * methods 64 | ulong size_limit 65 | 66 | ctypedef gr_ctx_struct gr_ctx_t[1] 67 | 68 | ctypedef void * gr_ptr 69 | ctypedef const void * gr_srcptr 70 | ctypedef void * gr_ctx_ptr 71 | 72 | ctypedef struct gr_vec_struct: 73 | gr_ptr entries 74 | slong alloc 75 | slong length 76 | 77 | ctypedef gr_vec_struct gr_vec_t[1] 78 | 79 | ctypedef struct gr_mat_struct: 80 | gr_ptr entries 81 | slong r 82 | slong c 83 | gr_ptr * rows 84 | 85 | ctypedef gr_mat_struct gr_mat_t[1] 86 | 87 | ctypedef struct gr_poly_struct: 88 | gr_ptr coeffs 89 | slong alloc 90 | slong length 91 | 92 | ctypedef gr_poly_struct gr_poly_t[1] 93 | 94 | ctypedef struct gr_mpoly_struct: 95 | gr_ptr coeffs 96 | ulong * exps 97 | slong length 98 | flint_bitcnt_t bits # number of bits per exponent 99 | slong coeffs_alloc # abs size in ulong units 100 | slong exps_alloc # abs size in ulong units 101 | 102 | ctypedef gr_mpoly_struct gr_mpoly_t[1] 103 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/mpoly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong, FLINT_BITS 2 | 3 | cdef extern from "flint/mpoly.h": 4 | 5 | ctypedef enum ordering_t: 6 | ORD_LEX 7 | ORD_DEGLEX 8 | ORD_DEGREVLEX 9 | 10 | ctypedef struct mpoly_ctx_struct: 11 | slong nvars 12 | slong nfields 13 | ordering_t ord 14 | int deg 15 | int rev 16 | slong lut_words_per_exp[FLINT_BITS] 17 | unsigned char lut_fix_bits[FLINT_BITS] 18 | 19 | ctypedef mpoly_ctx_struct mpoly_ctx_t[1] 20 | 21 | void mpoly_ctx_init(mpoly_ctx_t ctx, slong nvars, const ordering_t ord) 22 | void mpoly_ctx_clear(mpoly_ctx_t mctx) 23 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/nmod.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport ulong, slong, nmod_t, fmpz_struct, nn_ptr, flint_bitcnt_t 2 | from flint.flintlib.types.mpoly cimport mpoly_ctx_t 3 | 4 | 5 | cdef extern from "flint/nmod_types.h": 6 | 7 | ctypedef struct nmod_mat_struct: 8 | ulong * entries 9 | slong r 10 | slong c 11 | ulong ** rows 12 | nmod_t mod 13 | 14 | ctypedef nmod_mat_struct nmod_mat_t[1] 15 | 16 | # Macros: 17 | ulong nmod_mat_entry(nmod_mat_t mat, slong i, slong j) 18 | 19 | ctypedef struct nmod_poly_struct: 20 | nn_ptr coeffs 21 | slong alloc 22 | slong length 23 | nmod_t mod 24 | 25 | ctypedef nmod_poly_struct nmod_poly_t[1] 26 | 27 | ctypedef struct nmod_poly_factor_struct: 28 | nmod_poly_struct * p 29 | slong *exp 30 | slong num 31 | slong alloc 32 | 33 | ctypedef nmod_poly_factor_struct nmod_poly_factor_t[1] 34 | 35 | ctypedef struct nmod_poly_mat_struct: 36 | nmod_poly_struct * entries 37 | slong r 38 | slong c 39 | nmod_poly_struct ** rows 40 | ulong modulus 41 | 42 | ctypedef nmod_poly_mat_struct nmod_poly_mat_t[1] 43 | 44 | ctypedef struct nmod_mpoly_ctx_struct: 45 | mpoly_ctx_t minfo 46 | nmod_t mod 47 | 48 | ctypedef nmod_mpoly_ctx_struct nmod_mpoly_ctx_t[1] 49 | 50 | ctypedef struct nmod_mpoly_struct: 51 | ulong * coeffs 52 | ulong * exps 53 | slong length 54 | flint_bitcnt_t bits 55 | slong coeffs_alloc 56 | slong exps_alloc 57 | 58 | ctypedef nmod_mpoly_struct nmod_mpoly_t[1] 59 | 60 | ctypedef struct nmod_mpoly_univar_struct: 61 | nmod_mpoly_struct * coeffs 62 | fmpz_struct * exps 63 | slong alloc 64 | slong length 65 | 66 | ctypedef nmod_mpoly_univar_struct nmod_mpoly_univar_t[1] 67 | 68 | ctypedef struct nmod_mpoly_factor_struct: 69 | ulong constant 70 | nmod_mpoly_struct * poly 71 | fmpz_struct * exp 72 | slong num 73 | slong alloc 74 | 75 | ctypedef nmod_mpoly_factor_struct nmod_mpoly_factor_t[1] 76 | -------------------------------------------------------------------------------- /src/flint/flintlib/types/undocumented.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.nmod cimport nmod_mat_t 2 | 3 | from flint.flintlib.types.flint cimport fmpz_struct 4 | from flint.flintlib.types.nmod cimport nmod_mpoly_ctx_t, nmod_mpoly_t 5 | 6 | cdef extern from "flint/nmod_types.h": 7 | int nmod_mat_is_square(const nmod_mat_t mat) 8 | 9 | cdef extern from "flint/nmod_mpoly.h": 10 | void nmod_mpoly_deflation(fmpz_struct * shift, fmpz_struct * stride, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx) 11 | void nmod_mpoly_deflate(nmod_mpoly_t A, const nmod_mpoly_t B, const fmpz_struct * shift, const fmpz_struct * stride, const nmod_mpoly_ctx_t ctx) 12 | void nmod_mpoly_inflate(nmod_mpoly_t A, const nmod_mpoly_t B, const fmpz_struct * shift, const fmpz_struct * stride, const nmod_mpoly_ctx_t ctx) 13 | -------------------------------------------------------------------------------- /src/flint/functions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/functions/__init__.py -------------------------------------------------------------------------------- /src/flint/functions/meson.build: -------------------------------------------------------------------------------- 1 | pyfiles = [ 2 | '__init__.py', 3 | ] 4 | 5 | exts = [ 6 | 'showgood', 7 | ] 8 | 9 | py.install_sources( 10 | pyfiles, 11 | pure: false, 12 | subdir: 'flint/functions', 13 | ) 14 | 15 | foreach ext : exts 16 | py.extension_module( 17 | ext, 18 | ext + '.pyx', 19 | dependencies: pyflint_deps, 20 | install: true, 21 | subdir: 'flint/functions', 22 | ) 23 | endforeach 24 | -------------------------------------------------------------------------------- /src/flint/meson.build: -------------------------------------------------------------------------------- 1 | thisdir = 'flint' 2 | 3 | pyfiles = [ 4 | '__init__.py', 5 | ] 6 | 7 | exts = [ 8 | 'pyflint', 9 | ] 10 | 11 | pkgs = [ 12 | 'flint_base', 13 | 'types', 14 | 'functions', 15 | 'utils', 16 | 'test', 17 | ] 18 | 19 | py.install_sources( 20 | pyfiles, 21 | pure: false, 22 | subdir: thisdir, 23 | ) 24 | 25 | foreach ext : exts 26 | py.extension_module( 27 | ext, 28 | ext + '.pyx', 29 | dependencies: pyflint_deps, 30 | install: true, 31 | subdir: thisdir, 32 | ) 33 | endforeach 34 | 35 | foreach pkg : pkgs 36 | subdir(pkg) 37 | endforeach 38 | -------------------------------------------------------------------------------- /src/flint/pyflint.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.functions.arf cimport arf_rnd_t 2 | from flint.flint_base.flint_base cimport flint_mat 3 | from flint.flint_base.flint_base cimport flint_mpoly 4 | from flint.flint_base.flint_base cimport flint_series 5 | from flint.flint_base.flint_base cimport flint_scalar 6 | from flint.flint_base.flint_base cimport flint_poly 7 | 8 | from flint.types.fmpz cimport fmpz 9 | from flint.flintlib.types.flint cimport * 10 | 11 | cdef flint_rand_t global_random_state 12 | 13 | cdef class Context: 14 | cdef public bint pretty 15 | cdef public long prec 16 | cdef arf_rnd_t rnd 17 | -------------------------------------------------------------------------------- /src/flint/pyflint.pyx: -------------------------------------------------------------------------------- 1 | """ 2 | Python wrapper for FLINT and Arb. 3 | """ 4 | 5 | # cimport flint 6 | cimport libc.stdlib 7 | 8 | from flint.flint_base.flint_context cimport thectx 9 | 10 | cdef flint_rand_t global_random_state 11 | flint_rand_init(global_random_state) 12 | 13 | ctx = thectx 14 | -------------------------------------------------------------------------------- /src/flint/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/test/__init__.py -------------------------------------------------------------------------------- /src/flint/test/__main__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Run the python-flint test-suite as 3 | # 4 | # python -m flint.test 5 | # 6 | 7 | import sys 8 | import doctest 9 | import traceback 10 | import argparse 11 | 12 | import flint 13 | from flint.test.test_all import all_tests 14 | from flint.test.test_docstrings import find_doctests 15 | 16 | 17 | def run_tests(verbose=None): 18 | """Run all tests 19 | 20 | This is usually called by 21 | 22 | $ python -m flint.flint 23 | """ 24 | # Show the limited output by default 25 | if verbose is None: 26 | verbose = True 27 | 28 | total = 0 29 | failed = 0 30 | 31 | for test in all_tests: 32 | 33 | if verbose: 34 | print(f'{test.__name__}...', end='', flush=True) 35 | 36 | try: 37 | test() 38 | except Exception as e: 39 | print(f'Error in {test.__name__}') 40 | if verbose: 41 | traceback.print_exc() 42 | failed += 1 43 | else: 44 | if verbose: 45 | print('OK') 46 | 47 | total += 1 48 | 49 | return failed, total 50 | 51 | 52 | def run_doctests(tests, verbose=False): 53 | runner = doctest.DocTestRunner() 54 | for module, test_set in tests: 55 | if test_set: 56 | print(f"{module}...", end="" if not verbose else "\n", flush=True) 57 | for test in test_set: 58 | if verbose: 59 | print("\tTesting:", test.name) 60 | runner.run(test) 61 | print("OK") 62 | 63 | return runner.summarize() 64 | 65 | 66 | def run_all_tests(tests=True, doctests=True, verbose=None): 67 | 68 | success = True 69 | 70 | if tests: 71 | print("Running tests...") 72 | t_failed, t_total = run_tests(verbose=verbose) 73 | 74 | if doctests: 75 | print("Running doctests...") 76 | d_failed, d_total = run_doctests(find_doctests(flint), verbose=verbose) 77 | 78 | if tests: 79 | if t_failed: 80 | print(f'flint.test: {t_failed} of {t_total} tests failed') 81 | success = False 82 | else: 83 | print(f'flint.test: all {t_total} tests passed!') 84 | 85 | if doctests: 86 | if d_failed: 87 | print(f'flint.test: {d_failed} of {d_total} doctests failed') 88 | success = False 89 | else: 90 | print(f'flint.test: all {d_total} doctests passed!') 91 | 92 | return success 93 | 94 | 95 | def main(*args): 96 | """Run the python-flint test-suite""" 97 | 98 | parser = argparse.ArgumentParser(description="Run the python-flint test-suite") 99 | parser.add_argument("--quiet", "-q", action="store_true", help="less verbose output") 100 | parser.add_argument("--verbose", "-v", action="store_true", help="more verbose output") 101 | parser.add_argument("--tests", "-t", action="store_true", help="run tests") 102 | parser.add_argument("--doctests", "-d", action="store_true", help="run doctests") 103 | args = parser.parse_args(args) 104 | 105 | if not args.tests and not args.doctests: 106 | # Default is run all tests: 107 | tests = True 108 | doctests = True 109 | else: 110 | # Either --tests or --doctests was specified 111 | tests = args.tests 112 | doctests = args.doctests 113 | 114 | # Default is show output from tests but keep the doctests quiet. 115 | if args.verbose: 116 | verbose = True 117 | elif args.quiet: 118 | verbose = False 119 | else: 120 | verbose = None 121 | 122 | success = run_all_tests(tests=tests, doctests=doctests, verbose=verbose) 123 | 124 | if not success: 125 | print("----------------------------------------") 126 | print("!!!FAILED!!!: Something is wrong with your installation of python-flint!") 127 | print("----------------------------------------") 128 | return 1 129 | else: 130 | print("----------------------------------------") 131 | print("OK: Your installation of python-flint seems to be working just fine!") 132 | print("----------------------------------------") 133 | return 0 134 | 135 | 136 | if __name__ == "__main__": 137 | sys.exit(main(*sys.argv[1:])) 138 | -------------------------------------------------------------------------------- /src/flint/test/meson.build: -------------------------------------------------------------------------------- 1 | thisdir = 'flint/test' 2 | 3 | pyfiles = [ 4 | '__init__.py', 5 | '__main__.py', 6 | 'test_all.py', 7 | 'test_docstrings.py', 8 | ] 9 | 10 | py.install_sources( 11 | pyfiles, 12 | pure: false, 13 | subdir: thisdir, 14 | ) 15 | -------------------------------------------------------------------------------- /src/flint/test/test_docstrings.py: -------------------------------------------------------------------------------- 1 | import doctest 2 | import importlib 3 | import pkgutil 4 | import re 5 | 6 | import flint 7 | 8 | dunder_test_regex = re.compile(r'^(.*?)__test__\.(.*?\.)(.*) \(line (\d+)\)$') 9 | 10 | test_flint_at_least = { 11 | "flint.types._gr.gr_ctx.gens": 30100, 12 | "flint.types._gr.gr_ctx.neg": 30100, 13 | } 14 | 15 | 16 | def find_doctests(module): 17 | finder = doctest.DocTestFinder() 18 | tests = [] 19 | for module_info in pkgutil.walk_packages(module.__path__, flint.__name__ + "."): 20 | try: 21 | module = importlib.import_module(module_info.name) 22 | 23 | res = [] 24 | for test in filter(lambda x: bool(x.examples), finder.find(module)): 25 | m = dunder_test_regex.match(test.name) 26 | if m is not None: 27 | groups = m.groups() 28 | test.name = groups[0] + groups[2] 29 | test.lineno = int(groups[3]) 30 | 31 | if ( 32 | test_flint_at_least.get("".join(groups[:3]), flint.__FLINT_RELEASE__) 33 | <= flint.__FLINT_RELEASE__ 34 | ): 35 | res.append(test) 36 | 37 | tests.append((module_info.name, res)) 38 | 39 | except Exception as e: 40 | print(f"Error importing {module_info.name}: {e}") 41 | return tests 42 | 43 | 44 | # The below definitions are only useful when pytest is a) installed, and b) being currently run. 45 | # We don't want to impose pytest on those that just want to use `python -m flint.test` 46 | try: 47 | import pytest 48 | 49 | class PyTestDocTestRunner(doctest.DocTestRunner): 50 | def report_failure(self, out, test, example, got): 51 | pytest.fail( 52 | "\n".join([ 53 | f"{test.name}, line: {test.lineno}", 54 | "Failed example:", 55 | f"\t{example.source.strip()}", 56 | "Expected:", 57 | f"\t{example.want.strip()}", 58 | "Got:", 59 | f"\t{got.strip()}" 60 | ]), 61 | pytrace=False, 62 | ) 63 | 64 | def report_unexpected_exception(self, out, test, example, exc_info): 65 | pytest.fail( 66 | "\n".join([ 67 | f"{test.name}, line: {test.lineno}", 68 | "Failed example:", 69 | f"\t{example.source.strip()}", 70 | "Exception raised:", 71 | doctest._indent(doctest._exception_traceback(exc_info)) 72 | ]), 73 | pytrace=False, 74 | ) 75 | 76 | runner = PyTestDocTestRunner() 77 | 78 | @pytest.mark.parametrize( 79 | "test", 80 | [ 81 | test for _, test_set in find_doctests(flint) 82 | for test in test_set 83 | ], 84 | ids=lambda test: test.name, 85 | ) 86 | def test_docstrings(test): 87 | runner.run(test) 88 | 89 | except ImportError: 90 | class PyTestDocTestRunner(doctest.DocTestRunner): 91 | pass 92 | 93 | runner = None 94 | 95 | def test_docstrings(test): 96 | pass 97 | -------------------------------------------------------------------------------- /src/flint/types/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/types/__init__.py -------------------------------------------------------------------------------- /src/flint/types/acb.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_scalar 2 | from flint.flintlib.functions.acb cimport acb_t 3 | 4 | cdef any_as_acb(x) 5 | cdef any_as_acb_or_notimplemented(x) 6 | cdef int acb_set_python(acb_t x, obj, bint allow_conversion) 7 | cdef class acb(flint_scalar): 8 | cdef acb_t val 9 | cpdef bint is_zero(self) 10 | cpdef bint is_finite(self) 11 | cpdef bint is_exact(self) 12 | -------------------------------------------------------------------------------- /src/flint/types/acb_mat.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mat 2 | from flint.flintlib.functions.acb_mat cimport acb_mat_t 3 | 4 | cdef class acb_mat(flint_mat): 5 | cdef acb_mat_t val 6 | cpdef long nrows(self) 7 | cpdef long ncols(self) 8 | -------------------------------------------------------------------------------- /src/flint/types/acb_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_poly 2 | 3 | from flint.flintlib.functions.acb_poly cimport acb_poly_t 4 | 5 | cdef acb_poly_set_list(acb_poly_t poly, list val, long prec) 6 | cdef class acb_poly(flint_poly): 7 | cdef acb_poly_t val 8 | cpdef long length(self) 9 | cpdef long degree(self) 10 | -------------------------------------------------------------------------------- /src/flint/types/acb_series.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_series 2 | 3 | from flint.flintlib.functions.acb_poly cimport acb_poly_t 4 | 5 | cdef class acb_series(flint_series): 6 | cdef acb_poly_t val 7 | cdef long prec 8 | cpdef long length(self) 9 | cpdef valuation(self) 10 | -------------------------------------------------------------------------------- /src/flint/types/arb.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_scalar 2 | 3 | from flint.flintlib.functions.arb cimport arb_t 4 | 5 | cdef any_as_arb_or_notimplemented(x) 6 | cdef int arb_set_python(arb_t x, obj, bint allow_conversion) except -1 7 | cdef any_as_arb(x) 8 | cdef arb_set_mpmath_mpf(arb_t x, obj) 9 | 10 | cdef class arb(flint_scalar): 11 | cdef arb_t val 12 | 13 | cpdef bint is_zero(self) 14 | cpdef bint is_finite(self) 15 | cpdef bint is_nan(self) 16 | cpdef bint is_exact(self) 17 | cpdef bint is_integer(self) 18 | -------------------------------------------------------------------------------- /src/flint/types/arb_mat.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mat 2 | from flint.flintlib.functions.arb_mat cimport arb_mat_t 3 | 4 | cdef class arb_mat(flint_mat): 5 | cdef arb_mat_t val 6 | cpdef long nrows(self) 7 | cpdef long ncols(self) 8 | -------------------------------------------------------------------------------- /src/flint/types/arb_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_poly 2 | from flint.flintlib.functions.arb_poly cimport arb_poly_t 3 | 4 | cdef arb_poly_set_list(arb_poly_t poly, list val, long prec) 5 | 6 | cdef class arb_poly(flint_poly): 7 | cdef arb_poly_t val 8 | cpdef long length(self) 9 | cpdef long degree(self) 10 | -------------------------------------------------------------------------------- /src/flint/types/arb_series.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_series 2 | 3 | from flint.flintlib.functions.arb_poly cimport arb_poly_t 4 | 5 | cdef class arb_series(flint_series): 6 | cdef arb_poly_t val 7 | cdef long prec 8 | cpdef long length(self) 9 | cpdef valuation(self) 10 | -------------------------------------------------------------------------------- /src/flint/types/arf.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.functions.arf cimport arf_t 2 | 3 | cdef class arf: 4 | cdef arf_t val 5 | cpdef bint is_finite(self) 6 | cpdef bint is_pos_inf(self) 7 | cpdef bint is_neg_inf(self) 8 | cpdef bint is_nan(self) 9 | cpdef bint is_zero(self) 10 | -------------------------------------------------------------------------------- /src/flint/types/dirichlet.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.functions.dirichlet cimport dirichlet_group_t 2 | from flint.flintlib.functions.dirichlet cimport dirichlet_char_t 3 | 4 | cdef class dirichlet_group(object): 5 | cdef dirichlet_group_t val 6 | cdef int _init 7 | 8 | cpdef long size(self) 9 | 10 | cdef class dirichlet_char(object): 11 | 12 | cdef dirichlet_char_t val 13 | cdef dirichlet_group G 14 | -------------------------------------------------------------------------------- /src/flint/types/fmpq.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_scalar 2 | from flint.flintlib.functions.fmpq cimport fmpq_t 3 | 4 | cdef int fmpq_set_any_ref(fmpq_t x, obj) 5 | cdef any_as_fmpq(obj) 6 | 7 | cdef class fmpq(flint_scalar): 8 | cdef fmpq_t val 9 | -------------------------------------------------------------------------------- /src/flint/types/fmpq_mat.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mat 2 | 3 | from flint.flintlib.functions.fmpq_mat cimport fmpq_mat_t 4 | from flint.types.fmpz cimport fmpz 5 | from flint.types.fmpq cimport fmpq 6 | from flint.types.fmpz_mat cimport fmpz_mat 7 | 8 | cdef class fmpq_mat(flint_mat): 9 | cdef fmpq_mat_t val 10 | 11 | cpdef long nrows(self) 12 | cpdef long ncols(self) 13 | cdef __mul_fmpz(self, fmpz c) 14 | cdef __mul_fmpq(self, fmpq c) 15 | cdef __mul_fmpq_mat(self, fmpq_mat other) 16 | cdef __mul_fmpz_mat(self, fmpz_mat other) 17 | cdef __mul_r_fmpz_mat(self, fmpz_mat other) 18 | -------------------------------------------------------------------------------- /src/flint/types/fmpq_mpoly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mpoly 2 | from flint.flint_base.flint_base cimport flint_mpoly_context 3 | 4 | from flint.flintlib.functions.fmpq_mpoly cimport ( 5 | fmpq_mpoly_ctx_t, 6 | fmpq_mpoly_t, 7 | fmpq_mpoly_struct, 8 | fmpq_mpoly_init, 9 | ) 10 | from flint.flintlib.types.flint cimport slong 11 | 12 | from flint.types.fmpz_mpoly cimport fmpz_mpoly_ctx 13 | 14 | cdef inline init_fmpq_mpoly(fmpq_mpoly var, fmpq_mpoly_ctx ctx): 15 | var.ctx = ctx 16 | fmpq_mpoly_init(var.val, ctx.val) 17 | var._init = True 18 | 19 | cdef inline create_fmpq_mpoly(fmpq_mpoly_ctx ctx): 20 | cdef fmpq_mpoly var 21 | var = fmpq_mpoly.__new__(fmpq_mpoly) 22 | var.ctx = ctx 23 | fmpq_mpoly_init(var.val, ctx.val) 24 | var._init = True 25 | return var 26 | 27 | cdef class fmpq_mpoly_ctx(flint_mpoly_context): 28 | cdef fmpq_mpoly_ctx_t val 29 | 30 | cdef class fmpq_mpoly(flint_mpoly): 31 | cdef fmpq_mpoly_t val 32 | cdef fmpq_mpoly_ctx ctx 33 | cdef bint _init 34 | 35 | cdef class fmpq_mpoly_vec: 36 | cdef fmpq_mpoly_struct *val 37 | cdef slong length 38 | cdef fmpq_mpoly_ctx ctx 39 | cdef fmpq_mpoly_struct **double_indirect 40 | -------------------------------------------------------------------------------- /src/flint/types/fmpq_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_poly 2 | from flint.flintlib.functions.fmpq_poly cimport fmpq_poly_t 3 | 4 | cdef fmpq_poly_set_list(fmpq_poly_t poly, list val) 5 | cdef any_as_fmpq_poly(obj) 6 | cdef class fmpq_poly(flint_poly): 7 | cdef fmpq_poly_t val 8 | cpdef long length(self) 9 | cpdef long degree(self) 10 | -------------------------------------------------------------------------------- /src/flint/types/fmpq_series.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_series 2 | from flint.flintlib.functions.fmpq_poly cimport fmpq_poly_t 3 | 4 | cdef class fmpq_series(flint_series): 5 | cdef fmpq_poly_t val 6 | cdef long prec 7 | cpdef long length(self) 8 | cpdef valuation(self) 9 | cdef bint zero_constant_term(s) 10 | cdef bint one_constant_term(s) 11 | -------------------------------------------------------------------------------- /src/flint/types/fmpq_vec.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong 2 | from flint.flintlib.types.fmpq cimport fmpq_struct 3 | 4 | cdef class fmpq_vec: 5 | cdef fmpq_struct *val 6 | cdef fmpq_struct **double_indirect 7 | cdef slong length 8 | -------------------------------------------------------------------------------- /src/flint/types/fmpq_vec.pyx: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.fmpq cimport fmpq_struct 2 | from flint.flintlib.functions.fmpq cimport fmpq_set, fmpq_init 3 | from flint.flintlib.functions.fmpq_vec cimport _fmpq_vec_init, _fmpq_vec_clear 4 | 5 | from flint.types.fmpq cimport fmpq, any_as_fmpq 6 | 7 | cimport libc.stdlib 8 | 9 | cdef class fmpq_vec: 10 | def __cinit__(self, iterable_or_len, bint double_indirect=False): 11 | if isinstance(iterable_or_len, int): 12 | self.length = iterable_or_len 13 | else: 14 | self.length = len(iterable_or_len) 15 | 16 | self.val = _fmpq_vec_init(self.length) 17 | 18 | if double_indirect: 19 | self.double_indirect = libc.stdlib.malloc(self.length * sizeof(fmpq_struct *)) 20 | if self.double_indirect is NULL: 21 | raise MemoryError("malloc returned a null pointer") 22 | 23 | for i in range(self.length): 24 | self.double_indirect[i] = &self.val[i] 25 | else: 26 | self.double_indirect = NULL 27 | 28 | def __init__(self, iterable_or_len, double_indirect: bool = False): 29 | if not isinstance(iterable_or_len, int): 30 | for i, x in enumerate(iterable_or_len): 31 | self[i] = x 32 | 33 | def __dealloc__(self): 34 | libc.stdlib.free(self.double_indirect) 35 | if self.val is not NULL: 36 | _fmpq_vec_clear(self.val, self.length) 37 | self.val = NULL 38 | 39 | def __getitem__(self, x): 40 | if not isinstance(x, int): 41 | raise TypeError("index is not integer") 42 | elif not 0 <= x < self.length: 43 | raise IndexError("index out of range") 44 | 45 | cdef fmpq z = fmpq.__new__(fmpq) 46 | fmpq_init(z.val) 47 | fmpq_set(z.val, &self.val[x]) 48 | return z 49 | 50 | def __setitem__(self, x, y): 51 | if not isinstance(x, int): 52 | raise TypeError("index is not integer") 53 | elif not 0 <= x < self.length: 54 | raise IndexError("index out of range") 55 | 56 | y = any_as_fmpq(y) 57 | if y is NotImplemented: 58 | raise TypeError("argument is not coercible to fmpq") 59 | 60 | fmpq_set(&self.val[x], (y).val) 61 | 62 | def __len__(self): 63 | return self.length 64 | 65 | def __str__(self): 66 | return self.str() 67 | 68 | def __repr__(self): 69 | return self.repr() 70 | 71 | def __iter__(self): 72 | cdef fmpq z 73 | for i in range(self.length): 74 | z = fmpq.__new__(fmpq) 75 | fmpq_set(z.val, &self.val[i]) 76 | yield z 77 | 78 | def str(self, *args): 79 | s = [None] * self.length 80 | for i in range(self.length): 81 | x = fmpq.__new__(fmpq) 82 | fmpq_init(x.val) 83 | fmpq_set(x.val, &self.val[i]) 84 | s[i] = x.str(*args) 85 | return str(s) 86 | 87 | def repr(self, *args): 88 | return f"fmpq_vec({self.str(*args)}, {self.length})" 89 | -------------------------------------------------------------------------------- /src/flint/types/fmpz.pxd: -------------------------------------------------------------------------------- 1 | from cpython.long cimport PyLong_Check 2 | from flint.flint_base.flint_base cimport flint_scalar 3 | from flint.utils.conversion cimport chars_from_str 4 | from flint.flintlib.types.flint cimport slong, pylong_as_slong 5 | from flint.flintlib.types.flint cimport PyObject 6 | from flint.flintlib.functions.fmpz cimport fmpz_t, fmpz_set_str, fmpz_set_si 7 | 8 | cdef int fmpz_set_any_ref(fmpz_t x, obj) 9 | cdef fmpz_get_intlong(fmpz_t x) 10 | 11 | cdef inline int fmpz_set_pylong(fmpz_t x, obj): 12 | cdef int overflow 13 | cdef slong longval 14 | longval = pylong_as_slong(obj, &overflow) 15 | if overflow: 16 | s = "%x" % obj 17 | fmpz_set_str(x, chars_from_str(s), 16) 18 | else: 19 | fmpz_set_si(x, longval) 20 | 21 | cdef inline int fmpz_set_python(fmpz_t x, obj): 22 | if PyLong_Check(obj): 23 | fmpz_set_pylong(x, obj) 24 | return 1 25 | return 0 26 | cdef any_as_fmpz(obj) 27 | 28 | cdef class fmpz(flint_scalar): 29 | """ 30 | The *fmpz* type represents an arbitrary-size integer. 31 | 32 | >>> fmpz(3) ** 25 33 | 847288609443 34 | 35 | """ 36 | cdef fmpz_t val 37 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_mat.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mat 2 | from flint.flintlib.functions.fmpz_mat cimport fmpz_mat_t 3 | from flint.types.fmpz cimport fmpz 4 | cdef any_as_fmpz_mat(obj) 5 | 6 | cdef class fmpz_mat(flint_mat): 7 | 8 | cdef fmpz_mat_t val 9 | cpdef long nrows(self) 10 | cpdef long ncols(self) 11 | cdef __mul_fmpz(self, fmpz c) 12 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_mod.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_scalar 2 | from flint.flintlib.functions.fmpz cimport fmpz_struct, fmpz_t 3 | from flint.flintlib.functions.fmpz_mod cimport ( 4 | fmpz_mod_ctx_t, 5 | fmpz_mod_discrete_log_pohlig_hellman_t 6 | ) 7 | 8 | cdef class fmpz_mod_ctx: 9 | cdef fmpz_mod_ctx_t val 10 | cdef bint _is_prime 11 | cdef bint _init_L 12 | cdef fmpz_mod_discrete_log_pohlig_hellman_t L 13 | 14 | cdef set_any_as_fmpz_mod(self, fmpz_t val, obj) 15 | cdef any_as_fmpz_mod(self, obj) 16 | cdef discrete_log_pohlig_hellman_run(self, fmpz_t x, fmpz_t y) 17 | 18 | cdef class fmpz_mod(flint_scalar): 19 | cdef fmpz_mod_ctx ctx 20 | cdef fmpz_t val 21 | cdef fmpz_t x_g 22 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_mod_mat.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.types.flint cimport slong 2 | from flint.flintlib.functions.fmpz cimport fmpz_t 3 | from flint.flintlib.functions.fmpz_mod_mat cimport fmpz_mod_mat_t 4 | 5 | from flint.flint_base.flint_base cimport flint_mat 6 | from flint.types.fmpz_mod cimport fmpz_mod_ctx, fmpz_mod 7 | 8 | 9 | cdef class fmpz_mod_mat(flint_mat): 10 | cdef fmpz_mod_mat_t val 11 | cdef bint _initialized 12 | cdef fmpz_mod_ctx ctx 13 | 14 | cdef void _init_empty(self, slong m, slong n, list args) 15 | cdef void _init_empty_ctx(self, slong m, slong n, fmpz_mod_ctx ctx) 16 | cdef void _init_from_list(self, slong m, slong n, list entries, list args) 17 | # cdef void _init_from_matrix(self, flint_mat M, list args) 18 | cdef void _init_from_matrix(self, M, list args) 19 | cdef fmpz_mod_ctx _parse_args(self, list args) 20 | cdef fmpz_mod_mat _new(self, slong m, slong n, fmpz_mod_ctx ctx) 21 | cdef fmpz_mod_mat _newlike(self) 22 | cdef fmpz_mod_mat _copy(self) 23 | 24 | cpdef slong nrows(self) 25 | cpdef slong ncols(self) 26 | cdef fmpz_mod _getitem(self, slong i, slong j) 27 | cdef void _setitem(self, slong i, slong j, fmpz_t e) 28 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_mod_mpoly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mpoly, flint_mod_mpoly_context 2 | 3 | from flint.flintlib.functions.fmpz_mod_mpoly cimport ( 4 | fmpz_mod_mpoly_ctx_t, 5 | fmpz_mod_mpoly_t, 6 | fmpz_mod_mpoly_init, 7 | fmpz_mod_mpoly_struct 8 | ) 9 | from flint.flintlib.types.flint cimport slong 10 | 11 | cdef inline init_fmpz_mod_mpoly(fmpz_mod_mpoly var, fmpz_mod_mpoly_ctx ctx): 12 | var.ctx = ctx 13 | fmpz_mod_mpoly_init(var.val, ctx.val) 14 | var._init = True 15 | 16 | cdef inline fmpz_mod_mpoly create_fmpz_mod_mpoly(fmpz_mod_mpoly_ctx ctx): 17 | cdef fmpz_mod_mpoly var 18 | var = fmpz_mod_mpoly.__new__(fmpz_mod_mpoly) 19 | var.ctx = ctx 20 | fmpz_mod_mpoly_init(var.val, ctx.val) 21 | var._init = True 22 | return var 23 | 24 | cdef class fmpz_mod_mpoly_ctx(flint_mod_mpoly_context): 25 | cdef fmpz_mod_mpoly_ctx_t val 26 | 27 | cdef class fmpz_mod_mpoly(flint_mpoly): 28 | cdef fmpz_mod_mpoly_t val 29 | cdef fmpz_mod_mpoly_ctx ctx 30 | cdef bint _init 31 | 32 | cdef class fmpz_mod_mpoly_vec: 33 | cdef fmpz_mod_mpoly_struct *val 34 | cdef slong length 35 | cdef fmpz_mod_mpoly_ctx ctx 36 | cdef fmpz_mod_mpoly_struct **double_indirect 37 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_mod_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.functions.fmpz_mod_poly cimport * 2 | 3 | from flint.flint_base.flint_base cimport flint_poly 4 | from flint.types.fmpz_mod cimport fmpz_mod_ctx 5 | 6 | 7 | cdef class fmpz_mod_poly_ctx: 8 | cdef fmpz_mod_ctx mod 9 | cdef any_as_fmpz_mod_poly(self, obj) 10 | cdef set_any_as_fmpz_mod_poly(self, fmpz_mod_poly_t poly, obj) 11 | cdef set_list_as_fmpz_mod_poly(self, fmpz_mod_poly_t poly, val) 12 | cdef new_ctype_poly(self) 13 | 14 | cdef class fmpz_mod_poly(flint_poly): 15 | cdef fmpz_mod_poly_t val 16 | cdef fmpz_mod_poly_ctx ctx 17 | cpdef long length(self) 18 | cpdef long degree(self) 19 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_mpoly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mpoly, flint_mpoly_context 2 | 3 | from flint.flintlib.types.fmpz cimport ( 4 | fmpz_mpoly_ctx_t, 5 | fmpz_mpoly_vec_t, 6 | fmpz_mpoly_t, 7 | fmpz_mpoly_struct, 8 | ) 9 | from flint.flintlib.functions.fmpz_mpoly cimport fmpz_mpoly_init 10 | 11 | 12 | cdef inline init_fmpz_mpoly(fmpz_mpoly var, fmpz_mpoly_ctx ctx): 13 | var.ctx = ctx 14 | fmpz_mpoly_init(var.val, ctx.val) 15 | var._init = True 16 | 17 | cdef inline fmpz_mpoly create_fmpz_mpoly(fmpz_mpoly_ctx ctx): 18 | cdef fmpz_mpoly var 19 | var = fmpz_mpoly.__new__(fmpz_mpoly) 20 | var.ctx = ctx 21 | fmpz_mpoly_init(var.val, ctx.val) 22 | var._init = True 23 | return var 24 | 25 | cdef class fmpz_mpoly_ctx(flint_mpoly_context): 26 | cdef fmpz_mpoly_ctx_t val 27 | 28 | cdef class fmpz_mpoly(flint_mpoly): 29 | cdef fmpz_mpoly_t val 30 | cdef fmpz_mpoly_ctx ctx 31 | cdef bint _init 32 | 33 | cdef class fmpz_mpoly_vec: 34 | cdef fmpz_mpoly_vec_t val 35 | cdef fmpz_mpoly_ctx ctx 36 | cdef fmpz_mpoly_struct **double_indirect 37 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_poly 2 | 3 | from flint.flintlib.functions.fmpz_poly cimport fmpz_poly_t 4 | 5 | cdef fmpz_poly_set_list(fmpz_poly_t poly, list val) 6 | 7 | cdef any_as_fmpz_poly(x) 8 | 9 | cdef class fmpz_poly(flint_poly): 10 | cdef fmpz_poly_t val 11 | cpdef long length(self) 12 | cpdef long degree(self) 13 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_series.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_series 2 | 3 | from flint.flintlib.functions.fmpz_poly cimport fmpz_poly_t 4 | 5 | cdef class fmpz_series(flint_series): 6 | cdef fmpz_poly_t val 7 | cdef long prec 8 | cpdef long length(self) 9 | cpdef valuation(self) 10 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_vec.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.functions.fmpz cimport fmpz_struct 2 | from flint.flintlib.types.flint cimport slong 3 | 4 | cdef class fmpz_vec: 5 | cdef fmpz_struct *val 6 | cdef fmpz_struct **double_indirect 7 | cdef slong length 8 | -------------------------------------------------------------------------------- /src/flint/types/fmpz_vec.pyx: -------------------------------------------------------------------------------- 1 | from flint.flintlib.functions.fmpz cimport fmpz_struct, fmpz_set, fmpz_init_set 2 | from flint.flintlib.functions.fmpz_vec cimport _fmpz_vec_init, _fmpz_vec_clear 3 | 4 | from flint.types.fmpz cimport fmpz, any_as_fmpz 5 | 6 | cimport libc.stdlib 7 | 8 | cdef class fmpz_vec: 9 | def __cinit__(self, iterable_or_len, bint double_indirect=False): 10 | if isinstance(iterable_or_len, int): 11 | self.length = iterable_or_len 12 | else: 13 | self.length = len(iterable_or_len) 14 | 15 | self.val = _fmpz_vec_init(self.length) 16 | 17 | if double_indirect: 18 | self.double_indirect = libc.stdlib.malloc(self.length * sizeof(fmpz_struct *)) 19 | if self.double_indirect is NULL: 20 | raise MemoryError("malloc returned a null pointer") 21 | 22 | for i in range(self.length): 23 | self.double_indirect[i] = &self.val[i] 24 | else: 25 | self.double_indirect = NULL 26 | 27 | def __init__(self, iterable_or_len, double_indirect: bool = False): 28 | if not isinstance(iterable_or_len, int): 29 | for i, x in enumerate(iterable_or_len): 30 | self[i] = x 31 | 32 | def __dealloc__(self): 33 | libc.stdlib.free(self.double_indirect) 34 | if self.val is not NULL: 35 | _fmpz_vec_clear(self.val, self.length) 36 | self.val = NULL 37 | 38 | def __getitem__(self, x): 39 | if not isinstance(x, int): 40 | raise TypeError("index is not integer") 41 | elif not 0 <= x < self.length: 42 | raise IndexError("index out of range") 43 | 44 | cdef fmpz z = fmpz.__new__(fmpz) 45 | fmpz_init_set(z.val, &self.val[x]) 46 | return z 47 | 48 | def __setitem__(self, x, y): 49 | if not isinstance(x, int): 50 | raise TypeError("index is not integer") 51 | elif not 0 <= x < self.length: 52 | raise IndexError("index out of range") 53 | 54 | y = any_as_fmpz(y) 55 | if y is NotImplemented: 56 | raise TypeError("argument is not coercible to fmpz") 57 | 58 | fmpz_set(&self.val[x], (y).val) 59 | 60 | def __len__(self): 61 | return self.length 62 | 63 | def __str__(self): 64 | return self.str() 65 | 66 | def __repr__(self): 67 | return self.repr() 68 | 69 | def __iter__(self): 70 | cdef fmpz z 71 | for i in range(self.length): 72 | z = fmpz.__new__(fmpz) 73 | fmpz_init_set(z.val, &self.val[i]) 74 | yield z 75 | 76 | def str(self, *args): 77 | s = [None] * self.length 78 | for i in range(self.length): 79 | x = fmpz.__new__(fmpz) 80 | fmpz_init_set(x.val, &self.val[i]) 81 | s[i] = x.str(*args) 82 | return str(s) 83 | 84 | def repr(self, *args): 85 | return f"fmpz_vec({self.str(*args)}, {self.length})" 86 | -------------------------------------------------------------------------------- /src/flint/types/fq_default.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.functions.fq_default cimport * 2 | from flint.types.fmpz cimport fmpz 3 | from flint.flint_base.flint_base cimport flint_scalar 4 | 5 | cpdef enum fq_default_type: 6 | """ 7 | Enum for the fq_default context types: 8 | 9 | - 1. `fq_default_ctx.FQ_ZECH`: Use `fq_zech_t`, 10 | - 2. `fq_default_ctx.FQ_NMOD`: Use `fq_nmod_t`, 11 | - 3. `fq_default_ctx.FQ`: Use `fq_t`. 12 | - 4. `fq_default_ctx.NMOD`: Use `nmod` for degree = 1, 13 | - 5. `fq_default_ctx.FMPZ_MOD`: Use `fmpz_mod` for degree = 1. 14 | 15 | These can be manually selected, or type: `fq_default_ctx.DEFAULT` can be used 16 | for the implementation to be automatically decided by Flint (default), 17 | """ 18 | DEFAULT = 0 19 | FQ_ZECH = 1 20 | FQ_NMOD = 2 21 | FQ = 3 22 | NMOD = 4 23 | FMPZ_MOD = 5 24 | 25 | cdef class fq_default_ctx: 26 | cdef fq_default_ctx_t val 27 | cdef readonly char *var 28 | cdef bint _initialized 29 | 30 | cdef new_ctype_fq_default(self) 31 | cdef set_list_as_fq_default(self, fq_default_t val, obj) 32 | cdef set_any_scalar_as_fq_default(self, fq_default_t fq_ele, obj) 33 | cdef set_any_as_fq_default(self, fq_default_t val, obj) 34 | cdef any_as_fq_default(self, obj) 35 | 36 | cdef _set_from_order(self, p, d, var, fq_type=*, check_prime=*) 37 | cdef _set_from_modulus(self, modulus, var, fq_type=*, check_prime=*, check_modulus=*) 38 | 39 | cdef class fq_default(flint_scalar): 40 | cdef fq_default_ctx ctx 41 | cdef fq_default_t val 42 | 43 | # Arithmetic for flint_scalar base class 44 | cpdef fq_default _neg_(fq_default self) 45 | cpdef fq_default _add_(fq_default self, fq_default other) 46 | cpdef fq_default _mul_(fq_default self, fq_default other) 47 | cpdef fq_default _sub_(fq_default self, fq_default other) 48 | cpdef fq_default _rsub_(fq_default self, fq_default other) 49 | cpdef fq_default _div_(fq_default self, fq_default other) 50 | cpdef fq_default _rdiv_(fq_default self, fq_default other) 51 | cpdef fq_default _invert_(fq_default self) 52 | -------------------------------------------------------------------------------- /src/flint/types/fq_default_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flintlib.functions.fq_default_poly cimport * 2 | from flint.flintlib.functions.fq_default_poly_factor cimport * 3 | from flint.flintlib.functions.fq_default cimport fq_default_neg 4 | 5 | from flint.flint_base.flint_base cimport flint_poly 6 | from flint.types.fq_default cimport fq_default_ctx 7 | 8 | 9 | cdef class fq_default_poly_ctx: 10 | cdef fq_default_ctx field 11 | cdef any_as_fq_default_poly(self, obj) 12 | cdef set_any_as_fq_default_poly(self, fq_default_poly_t poly, obj) 13 | cdef set_list_as_fq_default_poly(self, fq_default_poly_t poly, val) 14 | cdef new_ctype_poly(self) 15 | 16 | cdef class fq_default_poly(flint_poly): 17 | cdef fq_default_poly_t val 18 | cdef fq_default_poly_ctx ctx 19 | cpdef long length(self) 20 | cpdef long degree(self) 21 | -------------------------------------------------------------------------------- /src/flint/types/meson.build: -------------------------------------------------------------------------------- 1 | thisdir = 'flint/types' 2 | 3 | pyfiles = [ 4 | '__init__.py', 5 | ] 6 | 7 | exts = [ 8 | 'fmpz', 9 | 'fmpz_poly', 10 | 'fmpz_mat', 11 | 'fmpz_series', 12 | 'fmpz_vec', 13 | 14 | 'fmpq', 15 | 'fmpq_poly', 16 | 'fmpq_mat', 17 | 'fmpq_series', 18 | 'fmpq_vec', 19 | 20 | 'nmod', 21 | 'nmod_poly', 22 | 'nmod_mpoly', 23 | 'nmod_mat', 24 | 'nmod_series', 25 | 26 | 'fmpz_mod', 27 | 'fmpz_mod_poly', 28 | 'fmpz_mod_mat', 29 | 30 | 'fq_default', 31 | 'fq_default_poly', 32 | 33 | 'arf', 34 | 35 | 'arb', 36 | 'arb_poly', 37 | 'arb_mat', 38 | 'arb_series', 39 | 40 | 'acb', 41 | 'acb_poly', 42 | 'acb_mat', 43 | 'acb_series', 44 | 45 | 'dirichlet', 46 | 47 | 'fmpz_mpoly', 48 | 'fmpz_mod_mpoly', 49 | 'fmpq_mpoly', 50 | 51 | '_gr', 52 | ] 53 | 54 | if have_acb_theta 55 | exts += ['acb_theta'] 56 | endif 57 | 58 | py.install_sources( 59 | pyfiles, 60 | pure: false, 61 | subdir: thisdir, 62 | ) 63 | 64 | foreach ext : exts 65 | py.extension_module( 66 | ext, 67 | ext + '.pyx', 68 | dependencies: pyflint_deps, 69 | install: true, 70 | subdir: thisdir, 71 | ) 72 | endforeach 73 | -------------------------------------------------------------------------------- /src/flint/types/nmod.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_scalar 2 | from flint.flintlib.types.flint cimport mp_limb_t 3 | from flint.flintlib.functions.nmod cimport nmod_t 4 | 5 | cdef int any_as_nmod(mp_limb_t * val, obj, nmod_t mod) except -1 6 | 7 | cdef class nmod(flint_scalar): 8 | cdef mp_limb_t val 9 | cdef nmod_t mod 10 | -------------------------------------------------------------------------------- /src/flint/types/nmod_mat.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mat 2 | 3 | from flint.flintlib.functions.nmod_mat cimport nmod_mat_t 4 | from flint.flintlib.types.flint cimport mp_limb_t 5 | 6 | cdef class nmod_mat(flint_mat): 7 | cdef nmod_mat_t val 8 | cpdef long nrows(self) 9 | cpdef long ncols(self) 10 | cpdef mp_limb_t modulus(self) 11 | cdef __mul_nmod(self, mp_limb_t c) 12 | -------------------------------------------------------------------------------- /src/flint/types/nmod_mpoly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_mpoly, flint_mod_mpoly_context 2 | 3 | from flint.flintlib.functions.nmod_mpoly cimport ( 4 | nmod_mpoly_ctx_t, 5 | nmod_mpoly_t, 6 | nmod_mpoly_init, 7 | nmod_mpoly_struct 8 | ) 9 | from flint.flintlib.types.flint cimport slong, ulong 10 | 11 | cdef inline init_nmod_mpoly(nmod_mpoly var, nmod_mpoly_ctx ctx): 12 | var.ctx = ctx 13 | nmod_mpoly_init(var.val, ctx.val) 14 | var._init = True 15 | 16 | cdef inline nmod_mpoly create_nmod_mpoly(nmod_mpoly_ctx ctx): 17 | cdef nmod_mpoly var 18 | var = nmod_mpoly.__new__(nmod_mpoly) 19 | var.ctx = ctx 20 | nmod_mpoly_init(var.val, ctx.val) 21 | var._init = True 22 | return var 23 | 24 | cdef class nmod_mpoly_ctx(flint_mod_mpoly_context): 25 | cdef nmod_mpoly_ctx_t val 26 | 27 | cdef class nmod_mpoly(flint_mpoly): 28 | cdef nmod_mpoly_t val 29 | cdef nmod_mpoly_ctx ctx 30 | cdef bint _init 31 | 32 | cdef class nmod_mpoly_vec: 33 | cdef nmod_mpoly_struct *val 34 | cdef slong length 35 | cdef nmod_mpoly_ctx ctx 36 | cdef nmod_mpoly_struct **double_indirect 37 | -------------------------------------------------------------------------------- /src/flint/types/nmod_poly.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_poly 2 | 3 | from flint.flintlib.functions.nmod_poly cimport nmod_poly_t 4 | from flint.flintlib.types.flint cimport mp_limb_t 5 | 6 | cdef class nmod_poly(flint_poly): 7 | cdef nmod_poly_t val 8 | cpdef long length(self) 9 | cpdef long degree(self) 10 | cpdef mp_limb_t modulus(self) 11 | -------------------------------------------------------------------------------- /src/flint/types/nmod_series.pxd: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_series 2 | 3 | cdef class nmod_series(flint_series): 4 | pass 5 | -------------------------------------------------------------------------------- /src/flint/types/nmod_series.pyx: -------------------------------------------------------------------------------- 1 | from flint.flint_base.flint_base cimport flint_series 2 | 3 | cdef class nmod_series(flint_series): 4 | pass 5 | -------------------------------------------------------------------------------- /src/flint/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flintlib/python-flint/590c7d6ea57530e7dfb4c687e53bfe7e3f2e7eb7/src/flint/utils/__init__.py -------------------------------------------------------------------------------- /src/flint/utils/conversion.pxd: -------------------------------------------------------------------------------- 1 | cdef inline long prec_to_dps(n): 2 | return max(1, int(round(int(n)/3.3219280948873626)-1)) 3 | 4 | cdef inline long dps_to_prec(n): 5 | return max(1, int(round((int(n)+1)*3.3219280948873626))) 6 | 7 | cdef inline chars_from_str(s): 8 | return s.encode('ascii') 9 | 10 | cdef inline str_from_chars(s): 11 | return bytes(s).decode('ascii') 12 | 13 | cdef inline _str_trunc(s, trunc=0): 14 | if trunc > 0 and len(s) > 3 * trunc: 15 | left = right = trunc 16 | omitted = len(s) - left - right 17 | return s[:left] + ("{...%s digits...}" % omitted) + s[-right:] 18 | return s 19 | -------------------------------------------------------------------------------- /src/flint/utils/flint_exceptions.py: -------------------------------------------------------------------------------- 1 | class FlintError(Exception): 2 | """Generic parent class for all flint relation exceptions.""" 3 | pass 4 | 5 | 6 | class DomainError(FlintError): 7 | """ 8 | Exception intended to be called when a method is called on a 9 | ring or field for which the domain is invalid. 10 | """ 11 | pass 12 | 13 | 14 | class IncompatibleContextError(FlintError): 15 | """ 16 | Exception intended to be called when a method involves two or more 17 | incompatible contexts. 18 | """ 19 | pass 20 | 21 | 22 | class UnableError(FlintError): 23 | """ 24 | Exception intended to be called when the implementation is unable to 25 | perform the requested operation. 26 | """ 27 | pass 28 | 29 | 30 | class UnknownError(FlintError): 31 | """ 32 | Exception intended to be called when the value of a predicate is unknown. 33 | """ 34 | pass 35 | -------------------------------------------------------------------------------- /src/flint/utils/meson.build: -------------------------------------------------------------------------------- 1 | thisdir = 'flint/utils' 2 | 3 | pyfiles = [ 4 | '__init__.py', 5 | 'flint_exceptions.py', 6 | ] 7 | 8 | exts = [] 9 | 10 | py.install_sources( 11 | pyfiles, 12 | pure: false, 13 | subdir: thisdir, 14 | ) 15 | 16 | foreach ext : exts 17 | py.extension_module( 18 | ext, 19 | ext + '.pyx', 20 | dependencies: pyflint_deps, 21 | install: true, 22 | subdir: thisdir, 23 | ) 24 | endforeach 25 | -------------------------------------------------------------------------------- /src/flint/utils/typecheck.pxd: -------------------------------------------------------------------------------- 1 | from cpython.object cimport PyTypeObject, PyObject_TypeCheck 2 | 3 | cdef inline bint typecheck(object ob, object tp): 4 | return PyObject_TypeCheck(ob, tp) 5 | --------------------------------------------------------------------------------