Skip to main content

Bindings for FLINT and Arb

Project description

Python-FLINT

Python extension module wrapping FLINT (Fast Library for Number Theory) and Arb (arbitrary-precision ball arithmetic). Features:

  • Integers, rationals, integers mod n
  • Real and complex numbers with rigorous error tracking
  • Polynomials, power series and matrices over all the above types
  • Lots of mathematical functions

Documentation: http://fredrikj.net/python-flint/

Repository: https://github.com/flintlib/python-flint/

Author: Fredrik Johansson fredrik.johansson@gmail.com

Installation

Currently python-flint supports CPython versions 3.9-3.12. For Windows (x86-64) or OSX (x86-64 or arm64) or Linux (x86-64 manylinux_2_17) there are CPython binary wheels for python-flint on PyPI. For these platforms python-flint can be installed simply with pip

pip install python-flint

Alternatively python-flint can be installed using conda

conda install -c conda-forge python-flint

It is also possible to use python-flint with some PyPy versions. Binary wheels are not provided for this on PyPI but can be installed with conda.

Build from source

For other platforms or architectures installation needs to build from source. First install FLINT 3. Starting with python-flint 0.5.0 older versions of Flint such as 2.9 are not supported any more. Note that as of Flint 3 Arb no longer needs to be built separately as it is now merged into Flint.

As of e.g. Ubuntu 24.04 a new enough version of FLINT (at least version 3) can be installed from the Ubuntu repos like

sudo apt-get install libflint-dev

For older distros the version in the repos is too old and a newer version of FLINT needs to be built. See here for instructions on building FLINT:

A script that builds and installs FLINT on Ubuntu can be found here:

The latest release of Python-FLINT can then be built from source and installed using:

pip install --no-binary python-flint python-flint

Python-FLINT can also be installed from a git checkout or a source archive as follows:

pip install .

See the documentation for further notes on building and installing python-flint:

Examples

Import Python-FLINT:

>>> from flint import *

Number-theoretic functions:

>>> fmpz(1000).partitions_p()
24061467864032622473692149727991
>>> fmpq.bernoulli(64)
-106783830147866529886385444979142647942017/510

Polynomial arithmetic:

>>> a = fmpz_poly([1,2,3]); b = fmpz_poly([2,3,4]); a.gcd(a * b)
3*x^2 + 2*x + 1
>>> a = fmpz_poly(list(range(10001))); b = fmpz_poly(list(range(10000))); a.gcd(a * b).degree()
10000
>>> x = fmpz_poly([0,1]); ((1-x**2)*(1+x**3)**3*(1+x+2*x)).factor()
(-1, [(3*x + 1, 1), (x + (-1), 1), (x^2 + (-1)*x + 1, 3), (x + 1, 4)])

Matrix arithmetic:

>>> fmpz_mat([[1,1],[1,0]]) ** 10
[89, 55]
[55, 34]
>>> fmpq_mat.hilbert(10,10).det()
1/46206893947914691316295628839036278726983680000000000

Numerical evaluation:

>>> showgood(lambda: (arb.pi() * arb(163).sqrt()).exp() - 640320**3 - 744, dps=25)
-7.499274028018143111206461e-13
>>> showgood(lambda: (arb.pi() * 10**100 + arb(1)/1000).sin(), dps=25)
0.0009999998333333416666664683

Numerical integration:

>>> ctx.dps = 30
>>> acb.integral(lambda x, _: (-x**2).exp(), -100, 100) ** 2
[3.141592653589793238462643383 +/- 3.11e-28]

To do

  • Write more tests and add missing docstrings
  • Wrap missing flint types: finite fields, p-adic numbers, rational functions
  • Vector or array types (maybe)
  • Many convenience methods
  • Write generic implementations of functions missing for specific FLINT types
  • Proper handling of special values in various places (throwing Python exceptions instead of aborting, etc.)
  • Various automatic conversions
  • Conversions to and from external types (numpy, sage, sympy, mpmath, gmpy)
  • Improved printing and string input/output
  • IPython hooks (TeX pretty-printing etc.)

CHANGELOG

Next release:

  • gh-132 Add fmpz_mpoly and fmpq_mpoly types for multivariate polynomials with integer or rational coefficients.
  • gh-160 Add bits to arb and acb, add log_base to arb.
  • gh-148 Remove debug symbols to make smaller Linux binaries.
  • gh-144 Add rel_one_ccuracy_bits to arb and acb.
  • gh-142 Add acb_theta module for the numerical evaluation of theta functions (only available for Flint >= 3.1).
  • gh-137 Add erfinv and erfcinv for arb.
  • gh-129 Use meson-python instead of setuptools as the build backend.
  • gh-125 Bump Flint version to 3.1.2 (Flint 3.0.0 - 3.1.2 is supported but the wheels are built with 3.1.2).

0.6.0

  • gh-112, gh-111, gh-110, gh-108: Add pyproject.toml and build dependencies. This means that python-flint can be built from source without --no-build-isolation.
  • gh-109: Use exact division for non-field domains. Now fmpz(6)/fmpz(3) returns an exact result fmpz(2) or raises an error if an exact result is not possible. Similar changes for fmpz_poly/fmpz, fmpz_mat/fmpz, and for polynomial division with fmpz_poly, fmpq_poly, nmod_poly and fmpz_mod_poly.
  • gh-106: Add fmpz_mod_mat for matrices of integers mod n where n is larger than word sized.
  • gh-104: Bump Flint from 3.0.0 to 3.0.1

0.5.0

Important compatibility changes:

  • gh-80, gh-94, gh-98: Switch from Flint 2.9 to Flint 3.
  • gh-100: Supports Python 3.12 by using setuptools instead of numpy.distutils.

New features:

  • gh-87: Adds fmpz_mod_poly type for polynomials over fmpz_mod.
  • gh-85: Adds discrete logarithms to fmpz_mod.
  • gh-83: Introduces the fmpz_mod type for multi-precision integer mods.

Bug fixes:

  • gh-93: Fixes a bug with pow(int, int, fmpz) which previously gave incorrect results.
  • gh-78, gh-79: minor fixes for the nmod type.

0.4.4

  • gh-75, gh-77: finish bulk of the work in refactoring python-flint into submodules
  • gh-72: The roots method of arb_poly is not supported. Use either the complex_roots method or acb_roots(p).roots() to get the old behaviour of returning the complex roots. The roots method on fmpz_poly and fmpq_poly now return integer and rational roots respectively. To access complex roots on these types, use the complex_roots method. For acb_poly, both roots and complex_roots behave the same
  • gh-71: Include files in sdist and fix issue gh-70
  • gh-67: Continue refactoring job to introduce submodules into python-flint

0.4.3

  • gh-63: The roots method of arb_poly, and nmod_poly is no longer supported. Use acb_roots(p).roots() to get the old behaviour of returning the roots as acb. Note that the roots method of fmpz_poly and fmpq_poly currently returns the complex roots of the polynomial.
  • gh-61: Start refactoring job to introduce submodules into python-flint

0.4.2

  • gh-57: Adds manylinux wheels

0.4.1

  • gh-47: Removes Linux wheels, updates instructions for building from source.

0.4.0

  • gh-45: Adds wheels for Windows, OSX and manylinux but the Linux wheels are broken.

License

Python-FLINT is licensed MIT. FLINT and Arb are LGPL v2.1+.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_flint-0.7.0a3.tar.gz (250.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

python_flint-0.7.0a3-cp312-cp312-win_amd64.whl (10.7 MB view details)

Uploaded CPython 3.12Windows x86-64

python_flint-0.7.0a3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

python_flint-0.7.0a3-cp312-cp312-macosx_11_0_arm64.whl (6.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

python_flint-0.7.0a3-cp312-cp312-macosx_10_9_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

python_flint-0.7.0a3-cp311-cp311-win_amd64.whl (10.8 MB view details)

Uploaded CPython 3.11Windows x86-64

python_flint-0.7.0a3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

python_flint-0.7.0a3-cp311-cp311-macosx_11_0_arm64.whl (6.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

python_flint-0.7.0a3-cp311-cp311-macosx_10_9_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

python_flint-0.7.0a3-cp310-cp310-win_amd64.whl (10.8 MB view details)

Uploaded CPython 3.10Windows x86-64

python_flint-0.7.0a3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

python_flint-0.7.0a3-cp310-cp310-macosx_11_0_arm64.whl (6.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

python_flint-0.7.0a3-cp310-cp310-macosx_10_9_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

python_flint-0.7.0a3-cp39-cp39-win_amd64.whl (10.8 MB view details)

Uploaded CPython 3.9Windows x86-64

python_flint-0.7.0a3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

python_flint-0.7.0a3-cp39-cp39-macosx_11_0_arm64.whl (6.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

python_flint-0.7.0a3-cp39-cp39-macosx_10_9_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file python_flint-0.7.0a3.tar.gz.

File metadata

  • Download URL: python_flint-0.7.0a3.tar.gz
  • Upload date:
  • Size: 250.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for python_flint-0.7.0a3.tar.gz
Algorithm Hash digest
SHA256 b0d82bb99b2e0e13e86260fcfa322b001835a4a6ea85d55e7365367ba80486ed
MD5 c941890fd73144ea50d20cb24caeb135
BLAKE2b-256 ec5d7e9597cc66e35cd6f22fd709c155329b3f16718c2fdfd52900e330a3f33b

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e31680fb634a260784673fa53301f35b634916ccfa8c5cb2583b6374a014de16
MD5 5736aa6054cf46e958a13343e7c6eedd
BLAKE2b-256 cd7f0664372ebd06843c54fb872bb823e5462d9962f70e3ffa697ec4113a7dc4

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce63e62ba07696b7f005e637f7b643a6523054969dc0ab54510a94cc85b2d9c3
MD5 f0af4aaeb481c1249a2beb17c5cef055
BLAKE2b-256 b4b4cd3091451ade787d4e0665fda9ead4fc3fbe2028d9e246bd8d69b33f85a0

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 023494c16f52093dd256a4d19ae601a259433e8eae54ed4d343956c9f5d05453
MD5 ce9f18e08401dd89ed01e47558ebb86f
BLAKE2b-256 8000d6106291ccf44903c55250cc8afb41ef9a9b26279bb920c628a37533f7a0

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 badfb8880445fb75d8aad46e229d631a3e353bcdf977d5404b5a0c4acf5b1189
MD5 c30acd19fc913756ab560a6a68246a08
BLAKE2b-256 f396921e5408a70bf57a705e66743c2fd19825e3cf69b2c679cc5f655e7d2230

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 30b6b1372710397cfe18d56a977b699f0723feb375eb883d99ac31ef1d995a4c
MD5 990943b43331d19b5ba113102d388855
BLAKE2b-256 b3f09224eab52a95c83cba07112150894877119b3d3af3ea8c1838ed2c326d7b

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7aadbd6c26273ad96252304448c6cc020bb39d1048cef35257c5c837a0095c4
MD5 795aee4ba87fed0d640745b6f8cf3b77
BLAKE2b-256 fcb35c5676418d5c46cc017514ac9b1cac6ba09b32d1c2f01772653994810208

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1398121ade6779d0ed0b64586af04c9d04286589b7a5e1e9e768986a181cb5c9
MD5 ca05fdc0372117927a9cd43947c04a91
BLAKE2b-256 382a056016394afda7bc29ea562cceddc5ed271b4963b2a83a81012081d34b78

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d0c98906c8253fc14bc1cc357f4fd360c91027f6d500c496545c193ee2e19339
MD5 a26eef9efb4984c29d8a69be61896dc1
BLAKE2b-256 9d2122662a13992ffd762224442a756a8aa3346108bc4008be7a0add1e91c4c7

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b4180dd7b800d264b6bcea788f5257869ece23270264deedbe22172b34c332d1
MD5 b697d7f3bda3ebefea3b1fd2866bf178
BLAKE2b-256 77fe85a41c89617d7c360a1852c9dd4d896d2418063d80184ec6b883c15b2f09

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 780c4842d4e5b9011f49aa2fd1f843605abc128f24ce62cbdc7387d1233fab5a
MD5 52fb1d5b97871be03bc63fc504d9c480
BLAKE2b-256 f11928cbee17b5449fb1f9c2d50cd18465ba3efc770e1daa1635ae1721ab6dcd

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bed50d8183effea99aa1e657a82d6ea036d305dd10bcfc3704e0e57a94b997e3
MD5 1544ed2016fdf7ddd4dbc70dedfca189
BLAKE2b-256 da4c7ba6303db4dad8f62084f3ddf757c8b459fd720928820e7fcea85bf4c1c8

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 691c721b67f1c06f5114a719b7c5306e094bad812ecf3b7805a7e39bb04e9bee
MD5 faf9213b4d1a2eee9c06905eee47874d
BLAKE2b-256 2eb56a9a44c3559ad093070ac09e8592249b184b04dcd6984ae6b92c7e4c9a68

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1129c9a583a8bb4401885bab21fd8eec8bad2e3e89ac2bdc30fb7bc92834bac0
MD5 abfbc9aa9f5dcf824a726e1d20c0c4c8
BLAKE2b-256 07e675995067b1f55b1af60a660811b8d2b721685723d783e8b0a2d7ffbee932

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e58c70620f9aa8fc80c4420156c5b3050de8fae5c60f657374052a00d7f10d42
MD5 0b4ee38fc39f8a3621f9865b61b7d950
BLAKE2b-256 f8f0428112e204613d1e4d63bf5b75ace67d3c9cbde9a891ac9321d9748caf65

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e3c60f58f41aacdce71bebd81ae62359ff4440ba533a428beccbb4635ac3b4e
MD5 f22cd9bc0696bfed3c6bcaaa92edfdf4
BLAKE2b-256 8623b9d08156becbf893713502dacf9b38b3fb2f540868ee6f88fff9a5390d2f

See more details on using hashes here.

File details

Details for the file python_flint-0.7.0a3-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.7.0a3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ccdf117a57085e62414d1a9ef26746b1a65484098bcc8e39e3fbf13ada256d5b
MD5 02a4d3658be97d560ff33caef4a47748
BLAKE2b-256 9f2fe0d2eef7a4c25ee71db39af71fb09e0e2c57d6745c3641ad6d3729f1035d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page