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.4.tar.gz (2.7 MB 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.4.4-cp311-cp311-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.11Windows x86-64

python_flint-0.4.4-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.4-cp311-cp311-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

python_flint-0.4.4-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.4-cp310-cp310-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.10Windows x86-64

python_flint-0.4.4-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.4-cp310-cp310-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

python_flint-0.4.4-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.4-cp39-cp39-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.9Windows x86-64

python_flint-0.4.4-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.4-cp39-cp39-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

python_flint-0.4.4-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.4.tar.gz.

File metadata

  • Download URL: python-flint-0.4.4.tar.gz
  • Upload date:
  • Size: 2.7 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.4.tar.gz
Algorithm Hash digest
SHA256 3fd61fe4c8fa58a6126e30eda110e0e378ab375c07434120b0bd512090bdb313
MD5 d2731281e76e7422e135e97edaaff687
BLAKE2b-256 b3603a0a80413061acf22c49dcb6e695f686b8ac22957f76321b90ae13c44a8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c7b9021ad0b59b5333695bf389f61dbe8c883536c59f8f7332c477dd2e7b36fe
MD5 7721545172b9f22f1a7a27def913587b
BLAKE2b-256 3d570624e745858f8930b962c79d54a598d203c1d43ed7c3f2f4508a97fc0add

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 94b39e65d7db6ad4a35bd84840ddbf0eac97ac523703769cb3b7e6d680d6f1cf
MD5 d9eff1108c18b109cd5c94809ba04e8d
BLAKE2b-256 ab2b62245bdab3c09d52c19009d9dc0d5e22644aa39fc60fc7913e08d38cc487

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 413f5261d27fbdc8c3c9f971c0726cb8b982f08884437ca7bba7b52b12eeefd9
MD5 9ef4769e96cdfcb4f772c443ea78b740
BLAKE2b-256 f2ca65ff718c4cfa0b5a0c3981b2aeb48f69fc51bb0b976741a00757bb04b763

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f75f5732aff539e95fac1dff751c341fe24bb1388bf47ffe757ee310c60ab591
MD5 07de47208701d9f02fa07ef3f1cca6bd
BLAKE2b-256 485dacd88e62acbe43549cd6ec232c43ce68106ec647b763d3fecabe52acdaa8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0997031ccd67e89b1729fcee524028bfdf02af05aabd695cd7b5cba47cf341a7
MD5 8b079ae0a6137e786a23c4f3510b4487
BLAKE2b-256 fcc29e8fe8eca36e619dfa049ea11ee512984d13abba3ef483d4357496c7ee63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0dc36684ff69a7103e3d6180d1d151814127b2e832ca37898c4d472e2d4ee402
MD5 3f48c681f8803ad8f4008d9476f4fc1c
BLAKE2b-256 07c45c72c1150d70858867b86c23b8d3659bd7acae5119d709c27d68d43c8621

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a202f1fde32c5f4c6c32da030b2c4eb36e4624cc2cf65d2928b505b07851adfc
MD5 46053fc526e90ced3ac5f3c77452dfb9
BLAKE2b-256 a20100f3f5a765c2593b2febccd2802208ec9172f610db62ae5b8655adce8f08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 22b0304e19f65f86ab34cd9779354310724e0bcaa8a8c461f35b71924e80719a
MD5 c045d2f8c2343f5d710f9164a2734eb1
BLAKE2b-256 9c4f1c3cbb02f6ce00e478d8855af2df18671be00d58d0c4d43c18166ed5e74c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_flint-0.4.4-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.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8553547e1c6c695fe1ba166db506182fc1d184e49ea32986a1b0bb50dcc23cca
MD5 b11d429802402c4a86dc6cac6398bf90
BLAKE2b-256 83d6726f1fe4aa1b2f8d020fbd6830bacfd6a89b502a67d59476660abd464464

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9dfbc3639fbf695b15e5435ceafcafc1bff46ce9be1446e69e5093da292042a9
MD5 4cfac16af0f45e31b7f79eb86afd50a8
BLAKE2b-256 c2589246c9daf2d6746bca3b3d57675d8ae44ef4eabcab143257688a2b0e6c6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57525a4bd59c041e8215f39ffd24e13051358ceabb7fffb1c7f6d75c4f594c04
MD5 b2af4f79d941b38ffe4b0f521f7cb040
BLAKE2b-256 c772ac52b9ccc57ca9eb968d6e8aeb0750e4005c7b1cb62719b658dfda2530db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 219383e690c986eba68ad17637a76bc7ec6ddf28b168e02cab8ad83bdb883e0b
MD5 e249f30ebbbc85a877355ac985febf97
BLAKE2b-256 d522fff8f5b938260337bf1caf7b1ab2588143fc94eed48d3166840e08833a94

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