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

Uploaded CPython 3.12Windows x86-64

python_flint-0.7.0a2-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.0a2-cp312-cp312-macosx_11_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

python_flint-0.7.0a2-cp312-cp312-macosx_10_9_x86_64.whl (8.0 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

python_flint-0.7.0a2-cp311-cp311-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.11Windows x86-64

python_flint-0.7.0a2-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.0a2-cp311-cp311-macosx_11_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

python_flint-0.7.0a2-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.0a2-cp310-cp310-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.10Windows x86-64

python_flint-0.7.0a2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

python_flint-0.7.0a2-cp310-cp310-macosx_11_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

python_flint-0.7.0a2-cp310-cp310-macosx_10_9_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

python_flint-0.7.0a2-cp39-cp39-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.9Windows x86-64

python_flint-0.7.0a2-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.0a2-cp39-cp39-macosx_11_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

python_flint-0.7.0a2-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.0a2.tar.gz.

File metadata

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

File hashes

Hashes for python_flint-0.7.0a2.tar.gz
Algorithm Hash digest
SHA256 ee5c811c5fa4c99ae9e996a933557503274c04b915d6452c076bfff9831b8b2d
MD5 1a2223f704bacfbe26953aa2e78993a5
BLAKE2b-256 f78d6379bb7eea63b9dc00a3492a30397772fa97061c95d1dadebdaeb2aa88b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a7c04b6d1cdb5d9c6810cc80db3e0ed2621eb81959295d8f65399beae96030ea
MD5 41d7bc88b1474774aae4eda88b1bf194
BLAKE2b-256 5700f72da5d7f444d2f310b30b8bde5b6acaeae90712d8ca7aa33e5c3b4d58d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fd02b9239ff8b8fdee33f749f64e0284b6bc3480da3eceb7885fb52aacff5945
MD5 7ef4d29d68b0a42eff9ac2c7faafe554
BLAKE2b-256 40fac597a93f6ee346220e8058ba1b42856ef6cee5d7b8ed2e93431dc85772ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ff7f30a35aca309c9cf62d1e926658932f7dfaea848558fe9dbc8d7e783b2656
MD5 8e4ed1cb36de6c38b849fed534350922
BLAKE2b-256 27460fda580970a1bc92d1c232e2bd7c253d388af7417be03cca35fa7bdce66c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a266384e3051cff63ff3eb5a3b0d1b5bb72f64bc3e3b19ba9e63eb8357fa2f48
MD5 6fa86833d8a4412206cf18c981041be0
BLAKE2b-256 ef86cd735ec227f4f48824db818ea9062be4dc7a769e7ebcaa73b346622a381d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fbb13a0161591f9fde2a65421b12bb068a638948f08b2cf2483957e53474e449
MD5 997faa7e694545f669b799633509fcf8
BLAKE2b-256 23495d6c51fe64516191c74f9e1b0a107c90276e2e06c48df35c366b0bd095f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd63b3f4f4b6379e4f4821b0b8529b319dc2188ab9ce17a12849f9bd496eb770
MD5 ee59247cc617118515469ae2860ff785
BLAKE2b-256 302128868ac4d10da79c94f6fe430619f06f241f30a74d479d409eb33866537e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c5f429ca4d9eaed73188cc8a81094277e12b0bf106d1ac9da3380564dc71df93
MD5 e7e7f84e3468015d6fb182cbbe807f6b
BLAKE2b-256 e28a53df76a0f0cb0499d776920c03e2067a5b26d1084b1372b8c38ebc08b126

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5c85c38a287a9b44d0d272fcbc4a3c0b27cc15430bc99a7cd92c9907cff334b0
MD5 91d7dd24208a20878f4f34f561e7dc72
BLAKE2b-256 47c7d7beee97bd77fa3ba4f7723c16f970ebc5074bf816848809c240e2cf1e8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c339df3aac7a000029222d7f0156dbd039caf8258faeb80498707f1c529e0bed
MD5 9109112b0a660adf463496226d9ad215
BLAKE2b-256 be91aa13d5a148c5e469d68d83a4c44771a1016943b3632764c3a77f70319f23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 889ef6ad51d7efa47de14f1732ddbf298acf3927f0f5741bddbf248b2da8890c
MD5 4b4ccbea138803f634c24aa70815d0d7
BLAKE2b-256 7e7f3e23086bf716b64e9b9c4244108a4636c9a3cfbcf5f6f024a7710232933a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80fea4dc4f4dc5fe50703164d227f19c84958b7d1573dbc5bc17532982d672df
MD5 10032ff4235437cb992e44a221c2417b
BLAKE2b-256 5c9fb3ce16bd98582ca18bb8b68786bbfcd24d2d450df5f4258d01cc9237aab7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bba73f06db13d287ef6ed4470e786bb9395bc0f3217acc2840b08132c717fb98
MD5 bef09f35971848ae32bcea8f1388b54d
BLAKE2b-256 ff8395d7d3903fea6e3138253116f149077322b440f4ac69a88139fbc990de03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3e56d37ef63d421bf51cb9191c69b36258b3326d01410a531ff8926714cdb187
MD5 673fdcda06863f7ebe6ef2fd3c69b89f
BLAKE2b-256 7709832572536ee263422320ec73405146149b1e811712ca6d1f520c6a474921

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab67062c01b3a51615a6ff8f0cd83c0947b72300c7a607b1ef095fc76364759a
MD5 3582a2c8dc656d23db8c0b9a5242c6b2
BLAKE2b-256 bdb5fdf72832d1491dc208c79cd610cb4a33bd2f625de361fddb94003b825b4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ba91d71da98fb62204be2069300bccbada3ab4e572d5a4970ce629db0b307e9
MD5 b24cb8c83326089b4e8024b68bb5678a
BLAKE2b-256 f95d288830420022d165d3281c4c0ca45f93790df666ea50cfb7cb3a8cb89c74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.7.0a2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0d24320c67af7281df43cf73db5e11e63ad219832f3e03a51177c5264640bb3a
MD5 e1a38e0e4fe02f3f15056ba76689dcc6
BLAKE2b-256 a5036baafecc693407cc7fec12391fe77575642a8cea88617371741813ad9d35

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