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/fredrik-johansson/python-flint/

Author: Fredrik Johansson fredrik.johansson@gmail.com

Installation

On Windows (x86-64) or OSX (x86-64 or arm64) there are prebuilt wheels for python-flint 0.4.1 that can be installed from PyPI using pip

pip install python-flint

There is currently a problem with the Linux wheels and so for now Linux wheels are not available on PyPI. Instead for Linux first install both FLINT 2.9.0 and Arb 2.23. Note that as of python-flint 0.4.1 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.)

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

Uploaded Source

Built Distributions

python_flint-0.4.1-cp311-cp311-win_amd64.whl (9.7 MB view details)

Uploaded CPython 3.11Windows x86-64

python_flint-0.4.1-cp311-cp311-macosx_11_0_arm64.whl (5.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

python_flint-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

python_flint-0.4.1-cp310-cp310-win_amd64.whl (9.7 MB view details)

Uploaded CPython 3.10Windows x86-64

python_flint-0.4.1-cp310-cp310-macosx_11_0_arm64.whl (5.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

python_flint-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

python_flint-0.4.1-cp39-cp39-win_amd64.whl (9.7 MB view details)

Uploaded CPython 3.9Windows x86-64

python_flint-0.4.1-cp39-cp39-macosx_11_0_arm64.whl (5.5 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

python_flint-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: python-flint-0.4.1.tar.gz
  • Upload date:
  • Size: 1.1 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.1.tar.gz
Algorithm Hash digest
SHA256 652dc0b87d2b76d9297d8c4b1284de0ad57ef97ff8784349aa2a1dc21ef6c1b8
MD5 67718aa60d187256f58da48106fe394a
BLAKE2b-256 48b0a7e5218bf54326a96407f06637f30e84f6ef51597e731996a8cc70408960

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e2799cfd3528258e87dfae68b8438169d955906ecb55a070331353d15d8731d9
MD5 26e2867bed0b1af2585d76db4b2e980c
BLAKE2b-256 b0b359a70d4f63e5575fd7e8b87487d8cdf39f329059d0bccb39299c353a9a55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c5da9a3de56a45eac674bf634f16f1f1b77a47d09123ad9c6c1b0145bd8031cd
MD5 42b07ae46e8f9f7dd733e125e340b1f4
BLAKE2b-256 24d3d0e7ed3d101d2bef36927fca17f40f9359b8bcaacd495305c48f0c651729

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fc2691ffbd553af7fcc1b8f7de3320681cbc3122100be7cfe37841fb74665a9a
MD5 b229301340c92232da0274da71b9ab9c
BLAKE2b-256 8887cd0e6c7fd3ea4dc7667cf92822cb3883244f8859117cc45fb6b5a74d53c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 45869c8d2b91ac2c5b49832962e5993fb32968ef6cd962694f1d070feffa8eaf
MD5 dd8cdc3a0d82593a4cb70e822de87e1b
BLAKE2b-256 4436f0e5e3cf2d2a146bd0f9baab75061c485be9016f76419f0ed853f7c69afc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0a57389cb39c10493baec50eeef857ff9f256c4d70491a09d1e78ce86d36e08a
MD5 517a18a045c1a9b3ba85df11becc08d5
BLAKE2b-256 8fb4e72f54323c95334ba19c1df6b59c14c1b1c0c51a34aaee1051058dc095a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 129afe7bfea6e47cff44705d924a66e62706c01bef732e402f474d431329da2c
MD5 a30a83ca8c96b49ac47a5aca93d436a5
BLAKE2b-256 8994ad472ef1e130794ed2446572a555f4ad2b91068c0c8569934085e772e2fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 99249e77c5de97fe8a1a104f7bf429047febd73ad96616a288885b107d0207aa
MD5 3649edd7f0e50c97c484e14e3c5ec81d
BLAKE2b-256 b96801cfa6507f9951b8e5e5eabb0ec5de940c79e467da5ce8b0e174114584f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67f8dc4fe493711f5d3330c69ad0c6240ecf12e81646dc4d073adb8fdb7f3e29
MD5 7be0e7592aef31e42e075d284199d9cd
BLAKE2b-256 537abae784a8172f3c2c295a1801fceeda676bd1e8c8f716f01f004da25936ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 72596f102c3eb8cb1b6b64981fa01484a2d498de98b51cb7d87b37705848e7df
MD5 05181d6cf02f9d053b263b4a141da475
BLAKE2b-256 e8d04f656b3d511b703f702cc0a2c78eb767be547b48b4a2b96f1a78203cadca

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