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

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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.11Windows x86-64

python_flint-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

python_flint-0.4.2-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.2-cp310-cp310-win_amd64.whl (9.7 MB view details)

Uploaded CPython 3.10Windows x86-64

python_flint-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

python_flint-0.4.2-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.2-cp39-cp39-win_amd64.whl (9.7 MB view details)

Uploaded CPython 3.9Windows x86-64

python_flint-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (32.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

python_flint-0.4.2-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.2.tar.gz.

File metadata

  • Download URL: python-flint-0.4.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d017dd6949b6186db2d2951070e2ce795116672f51f2d79de72dd29bfb85c1fb
MD5 1618ad4a08392fbfc8d5ec26d6bc5b79
BLAKE2b-256 c9c63d171111bd7e49da39124f71b904a8ed15437dd61cb14388d36687fb6c88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7e847d516b0851b78f700064242f0a17f980ba3d42e9133ddb88531fdfe65781
MD5 d86a5b232925c182abbb10d89238c583
BLAKE2b-256 e6e2641de8f67a581bb36a771a1ade99e8906a2696df12363baa10702508a18c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1883a2374d5f71aa4b5bfb17a2f011d2f1ae88921ac374af2aeb69fec87c735d
MD5 56ce45c09c297416276e3e8cf3550a80
BLAKE2b-256 be16e37b3a18e28974a79554b7415465daf94b67622c0395652fe2ef5c507840

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 278da2feac404f15b74b9703f0e4328a536b1e71fca5d959f425d83eac084203
MD5 a83efc473815348d0c19e9a24dbd1f3d
BLAKE2b-256 37bef12b40d892316dfea29b34f9905bfaffcd7b9c0d5dbd4724f6489b1addfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b4295896dda04cb4d840c056bd1b2f8216d4a510f38b080416a85b4fde8f50d6
MD5 bceefb43ece58480aa78bef5318627be
BLAKE2b-256 02e11f056e05d43031ac69f41598358d30707d721ae27cf3474da8152a5abc43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92826f18e7e840440a203710dc2850008ab4a5fb6f9dfc6dce703d2180282d7f
MD5 b60e18f8eb0f212e85f1d2edf2bc1495
BLAKE2b-256 2617c17208e3f62000df1d3904688e7a6155aff17a6d129db0202913e3f81ab4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 52337780407363f3ac861e73ff940d708bb4ce2c611523213a02d7e097545667
MD5 d255b566a70edfc75f06e077929fe5c1
BLAKE2b-256 e0517085fa459aa5d43d50199a7ea21e93dcd4fcf6db1aebdb138e77f920049d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_flint-0.4.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 9.7 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.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bbbe2271136d05b23a35bbc310bdf03ba38af47f42d7f52c28b9b2cee7870891
MD5 07b01c58a1b93cb95a4050f8d8af5783
BLAKE2b-256 a96bf9ac4345f2d4e26c5d6e0182b6d2ace949771f1d46c3fb98f0e168b5928b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 29ea7afd4b830861f19958b142ab12239c75b58a966eacd917bd57a44b06ea46
MD5 1e84835cf8cb0d9b0c4918f0241135a1
BLAKE2b-256 8ab2a09fcaa13401400a7cb1e35831d51f6e6a0d1de2065b9b217c7e36f8962a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.4.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a6a8b5e490c0bdc62370358ab5d88c1f67aa2aa18666ecb08267721103ce4ceb
MD5 cd83501eaabab9a40a6741f7f6f150a0
BLAKE2b-256 a6ab31d6fa30f8e49b04310c7adc86ba4ed38b29d18536c30b5d797ebad2e0df

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