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-161 Add acb.lerch_phi to compute the Lerch transcendent.
  • 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-149 Bump Flint version to 3.1.3-p1 (Flint 3.0.0 - 3.1.3-p1 is supported but the wheels are built with 3.1.3-p1).
  • 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.

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.0a4.tar.gz (250.5 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.0a4-cp312-cp312-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.12Windows x86-64

python_flint-0.7.0a4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

python_flint-0.7.0a4-cp312-cp312-macosx_10_9_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

python_flint-0.7.0a4-cp311-cp311-win_amd64.whl (10.5 MB view details)

Uploaded CPython 3.11Windows x86-64

python_flint-0.7.0a4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

python_flint-0.7.0a4-cp311-cp311-macosx_10_9_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

python_flint-0.7.0a4-cp310-cp310-win_amd64.whl (10.5 MB view details)

Uploaded CPython 3.10Windows x86-64

python_flint-0.7.0a4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

python_flint-0.7.0a4-cp310-cp310-macosx_10_9_x86_64.whl (7.8 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

python_flint-0.7.0a4-cp39-cp39-win_amd64.whl (10.5 MB view details)

Uploaded CPython 3.9Windows x86-64

python_flint-0.7.0a4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

python_flint-0.7.0a4-cp39-cp39-macosx_10_9_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: python_flint-0.7.0a4.tar.gz
  • Upload date:
  • Size: 250.5 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.0a4.tar.gz
Algorithm Hash digest
SHA256 4d92339096842a4193a178ff2ed486f827675bf53141e2e20a1f6a17b641fa4d
MD5 4a6f8f8ac84e592ef66f958e13c30a56
BLAKE2b-256 620d71b8443f53d5e0040a43875c2f5f09a3c59f2c24adc447aa2970bf96fd6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4ea1b093413ba73b85fadfc4699a55e5755b41cc241bb73c33496adf98939301
MD5 e737df771fb5162e2a2fec634398c544
BLAKE2b-256 c907f724b0b76479b8ceb33e4c6bfafd2923627f7a76a0558cc6ba700b10e07f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9cf868c3fafd102e6c230b9bfecf1db2249b40900df4102a43a0417f52ac8fa2
MD5 a939f839964e97f93c92170c82df5842
BLAKE2b-256 038b361006b912ed0606971bf1b33fdf42b18d4822d6bdaeb2cb9ee0700e213f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a6d58c560f45fb1370ae1b8980406e265046256b1678eaa6e7c2d70dcb5cc86b
MD5 a462f37e66c473a3b14cde64157a20d3
BLAKE2b-256 77ac13d9a7850051fa9a1c25e6ee667cfd24b1d3276be9ad8122d94a8cccf8b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9202bc39d1ccdfcfcc1f338d8ec20b70bd0e9112170c18479906f8d601cfb159
MD5 31e5c31843d3786ba6e3239bf19c8725
BLAKE2b-256 922771c626ff2a815150565b44554089acd5787a0f1b9d8d67602085e99c3fe9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c0d356e9e0a1f4950d3baabb47e9d88e3ce6deb0ef8d25c79ee48749bb07b40e
MD5 32e693ef171a86d8ac79e3d4ad52bf26
BLAKE2b-256 cf56942e475a76ae3436820cb284392345d108b18363d43dbf5b476aed9cadb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa4ee2742901d5e9bc785d3984fa1a4d88219915ff95fee36a8957c7e91f1d71
MD5 2f074acb4242ae5ea4d1289be29abd5a
BLAKE2b-256 6777cfe9c37623a64dc182993905bb00a6a6fe6f93eb7c06f5dfea08d67b1ebd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 634cb304d344a9df9b5d7f24c42962f9f44104b605e3856cbfacfd7ed20ac3db
MD5 1767770b5049c6c35f9fea6db9b76567
BLAKE2b-256 f28e3f1e95064ce581baa4755195f3c771a900933ec10da0aba6d94175205833

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4cc04685453cc63cd08318fe0af900c9103ac18dfad251b57b8e8a123d7fa2e8
MD5 4b995945e806130048d9836b2752beeb
BLAKE2b-256 9ae51c0646ae16bfbe33963fb178aa96d2613f9958f271efa38e4e63fd3d0d82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9e014f42949a03dcb8e84510a40990119ef0b732cca498689af1999675b4bdaf
MD5 130742a078416aace2c7fc66d1076aae
BLAKE2b-256 0a311556dfd69c4f15b06410d867ae82dc7da30d9fd307383c4038bf911288a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09551f6f4bf091afd9d48e1d44f92556e851b5107d80e60d953b317dd9cf777f
MD5 6f2459edbb0416c554665eafbde991e5
BLAKE2b-256 e3c86b4b982c4c63944b144b49eb72749a601e40eda79cb676a8a07239fd6e36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29483ed67e88ae086a91f83d023407403a8b8eda699bec00006cb1f4b50ce59e
MD5 8b423cec4c9aac8143ce3435a35918f9
BLAKE2b-256 21eea0f757cc52dd5b39c0ee7ff6d28ea3913e044274a76baccbd12cc5a5a437

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f9ad3fe32506462768147ed8b525966ce48a2560d8ccd16d25afddc0ca2e9a77
MD5 af7bb516525fc96567372b5ea69b28d5
BLAKE2b-256 6f752dbde491366a74059140415850f64c5d93a1afbdc5540dc0669b9c9fcbf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4c07f033e277380a2ab8c95b958e636e8e954fe137876125bbbc00586c80086c
MD5 73a7198aa2bfcffea045998854c157bc
BLAKE2b-256 f94c49034c8f7e476cbc4fb3174f8b1850adb599755130c2fda32365cce14789

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 41ebfa8b7a3f2d43af6964bd2dea867b5e24aae679bdbcb821d45d61a2c81022
MD5 0fe4c9b6c10699631444d83047bf7f09
BLAKE2b-256 f7689a7888acaf32e2a7c79be084d3fc2a99ecab18ef9c77c30b0b7eaad65464

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b57585542b3d48293d4974c1c4db8e087b2d960f2ec04917de32550106f3a03
MD5 de18e9e73b6bb9a862fb7e0d76e32586
BLAKE2b-256 4f407ea0f25bc2998fa35ecf0a2c7598536b97255b3409e7c6903bcf8d598960

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1320d041430109d029ce1e947c9966f7cb11292322e24cd0c0e0d736d744dbf6
MD5 07948cc90368442956a92bfbcba79147
BLAKE2b-256 7a3d445394785fa9b92e9915ce3ceff2dc90a1754f1aa8e864088a00cd5015a9

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