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

For Windows (x86-64) or OSX (x86-64 or arm64) or Linux (x86-64 manylinux_2_17) there are 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

Build from source

For other platforms or architectures installation needs to build from source. First install both FLINT 2.9.0 and Arb 2.23. Note that for python-flint 0.4 only these exact versions of FLINT and Arb will work. While some Linux distributions may provide FLINT and Arb it is unlikely that they will provide the exact versions required (e.g. for Ubuntu only Ubuntu 23.04 provides these versions at the time of writing).

See here for instructions on building FLINT and Arb:

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

pip install 'cython>=3' numpy wheel
pip install --no-build-isolation python-flint

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

pip install 'cython>=3' numpy wheel
pip install --no-build-isolation .

A script that builds and installs FLINT, Arb and Python-FLINT that is tested on Ubuntu can be found in the git repo here:

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, multiprecision integer mods, 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

0.5.0

  • 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.

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.4.3.tar.gz (2.5 MB view details)

Uploaded Source

Built Distributions

python_flint-0.4.3-cp311-cp311-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.11Windows x86-64

python_flint-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (35.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

python_flint-0.4.3-cp311-cp311-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

python_flint-0.4.3-cp311-cp311-macosx_10_9_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

python_flint-0.4.3-cp310-cp310-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.10Windows x86-64

python_flint-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (35.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

python_flint-0.4.3-cp310-cp310-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

python_flint-0.4.3-cp310-cp310-macosx_10_9_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

python_flint-0.4.3-cp39-cp39-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.9Windows x86-64

python_flint-0.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (35.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

python_flint-0.4.3-cp39-cp39-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

python_flint-0.4.3-cp39-cp39-macosx_10_9_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file python-flint-0.4.3.tar.gz.

File metadata

  • Download URL: python-flint-0.4.3.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for python-flint-0.4.3.tar.gz
Algorithm Hash digest
SHA256 e536b3c0fbe5139840600039460aaaeba93923371b28ac1db2dbf24e644472d0
MD5 c3bb2b06736310251783ce706fd07ffa
BLAKE2b-256 007bba6ed7b1d1870f32f95e90c7adcbfc1cfe4766bb9a4eb9f4734aaa94b20d

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e76a6988bfc8624eb75923c517254f55ee62077fdb1c03a858bdf0fcfd161d83
MD5 ca07065629699b043e2632ca15b82c24
BLAKE2b-256 8f2a6402c7b1c851a540e963661f647725f45a231bf5d09033e062f286e697dc

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3ece5c256590ea4f1f1f812e32cfa3dc39b0694acff2c0436dc9a0bbee7e059
MD5 15445199db1f2ad0fad735f6266f830f
BLAKE2b-256 f513a0c9ad0c04902eb56fad8e0f3509155f13c24383614a123e4d791489ea6f

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0621dc2ec6aebf5aefb9da40c43ab508ef8637ea07a8c0a11a02a91dbdd4039d
MD5 264ab9f5d9ed30fd4c603c3f30b192d9
BLAKE2b-256 1af552ce87c1d0f2afd763941a11b03be6e82eba76dd425a396ebde3caa66452

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f8e5c6092fdb8ee1bafa8edd977d1b6edc70e1792bc0561e280eb20ac485f91e
MD5 8f05c7b2e20b327de15278f01ce85864
BLAKE2b-256 d372c5416c545d18eee9c0196cd97a3bbf83d65611bad7fb0a1bf24e6b10a493

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a5f967ae04b446355c2855feecaee0853b5810829310a567b834e9b1637e4ae7
MD5 55700d6905c341fd0da1ffc5fcbd182a
BLAKE2b-256 56f5971ff096446fd648d7a82780140dee05f4aa3f51faaf32daed88a40724ef

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62baa418ec4c487379ccfe07462764f6544d51c200aec3ba8bbdddf547326e6b
MD5 9b7a604ac776007f2c9999320e0606ef
BLAKE2b-256 6780eb020f358cb925983375e3450b4ba829dd5900d4965155275e8711457cde

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f775f1dab4ddb63799d6efc1d2e1775bfdb07fbb2e79faa0fea83926dd1ba717
MD5 da2783e1698613df2392abce0376943b
BLAKE2b-256 5329b4f5c07fe122acc64c7e98a5ff0dfaa6f95586a6e16d3f0d54e5b3c321da

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0517318af2079cc54ee817da508945f2bd525d504344eb66501508c246759b8b
MD5 e72b59170bc1169fa76bb9edff0cf332
BLAKE2b-256 c6d5563786119f01f3aee6930b7b7ed37d3ce19a3f8fc8a28312e10e43197494

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: python_flint-0.4.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 12.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for python_flint-0.4.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 cf7832fcaebff5424be882e05e2db4ab1a297a83eaf036dce5d532466ede138e
MD5 d2765bdc0ecc16e76bd905332b64d5c7
BLAKE2b-256 d0736afda0e46fa46cde14aace5de7f4683726876ee186a5149ee2ac2d1d69d3

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8f62ef6ff49f9ffaf63c9a2bfa9cd93876b56a180f76760ddf4ecd063b8d4b20
MD5 df116ae54cf03f58227a84ac13583acc
BLAKE2b-256 d45f05aa5a1d54e22df675876478c9dbd6dbdf0eb1f66d3f803f0d8f367bfb67

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a062518739d2f1d836c891555fb22f8e70cc0985ad889b9f5f783526c0635b8
MD5 5434ad808d9644ffd05771e0d1c9675b
BLAKE2b-256 04802d2ad2d07c70e9b1fd9322e63cd66ad726b46f725ec7c7cdd9416c7606a9

See more details on using hashes here.

File details

Details for the file python_flint-0.4.3-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.4.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b9b73444e271924bd95ad0e1428eac081e5d58d06edcb7f851143661f6904ca0
MD5 234602573a6501be88422c960507933b
BLAKE2b-256 24a50652f830a4266d0d4c9d613ade885b52373b83be2aa550be070bc0aa32d9

See more details on using hashes here.

Supported by

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