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.0.0. Note that as of python-flint 0.5.0 only this exact version of FLINT will work. In future it is hoped that the version requirement for python-flint will be FLINT >= 3.0.0 but at the time of writing 3.0.0 is the newest version of FLINT that has only been released recently and is the only version that is supported by python-flint.

See here for instructions on building FLINT:

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 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, 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

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.5.0.tar.gz (3.0 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.5.0-cp312-cp312-win_amd64.whl (10.9 MB view details)

Uploaded CPython 3.12Windows x86-64

python_flint-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

python_flint-0.5.0-cp312-cp312-macosx_11_0_arm64.whl (6.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

python_flint-0.5.0-cp312-cp312-macosx_10_9_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

python_flint-0.5.0-cp311-cp311-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.11Windows x86-64

python_flint-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

python_flint-0.5.0-cp311-cp311-macosx_11_0_arm64.whl (6.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

python_flint-0.5.0-cp311-cp311-macosx_10_9_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

python_flint-0.5.0-cp310-cp310-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.10Windows x86-64

python_flint-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (37.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

python_flint-0.5.0-cp310-cp310-macosx_11_0_arm64.whl (6.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

python_flint-0.5.0-cp310-cp310-macosx_10_9_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

python_flint-0.5.0-cp39-cp39-win_amd64.whl (13.2 MB view details)

Uploaded CPython 3.9Windows x86-64

python_flint-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (37.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

python_flint-0.5.0-cp39-cp39-macosx_11_0_arm64.whl (6.6 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

python_flint-0.5.0-cp39-cp39-macosx_10_9_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: python-flint-0.5.0.tar.gz
  • Upload date:
  • Size: 3.0 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.5.0.tar.gz
Algorithm Hash digest
SHA256 0358f05548d477e23c79dbe15b2449e12e4b3d76af41fb16a4c7d035065b12cd
MD5 2887420aa9628ffe26b61e49b431207f
BLAKE2b-256 facaefc70c3371676ad02ecc13c71b3463dcfc35a4c6be0dfd691d066e253b70

See more details on using hashes here.

File details

Details for the file python_flint-0.5.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for python_flint-0.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c5a0258cb5b4b5ea2f2813ae857d4d14db4dba8c4a21f78749c96d3c9c8f6058
MD5 fa278b6a80123853b42af970b457da0d
BLAKE2b-256 f34bb67ac25cea36843eddc42156f5a8ab9a5d6bdd4ad2c70830fe0fd22ee921

See more details on using hashes here.

File details

Details for the file python_flint-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b47de950d0bb40dca9b26388cdfd1e2da292f2710e8e1be33063c340de2bcf9
MD5 c68fa7160cb1ac35046776c52dcdfd70
BLAKE2b-256 fd849960c571ea74fd9e123c5342f336eca296a330905d89f7c8635ffcc12632

See more details on using hashes here.

File details

Details for the file python_flint-0.5.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for python_flint-0.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c8493287c64c5a3409b40946c1b1e0775640ad60a7d8de729e8531f41ccea4f8
MD5 af9b0be638d363ec7d6bc4dab602d156
BLAKE2b-256 eb520f010ee259659570753bed4f54c4522c7fa4ce9eff50ac5c19c9203b0fa9

See more details on using hashes here.

File details

Details for the file python_flint-0.5.0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for python_flint-0.5.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e9cef65b8b62aaed86bb0ef98b7d4c308fda1e2075385b552d8628f63c203c0f
MD5 a07fa82fe381982d41040eb9174a336f
BLAKE2b-256 f04238626a94bfdff4cbba2727461c71b1af62b79391a74b0e396b32806ccebb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9e34a7e91cb39605a944f6ebcf03343cd9c6bf24d93f7f98e64d2f912dd5a647
MD5 4919be3bed16e554427c0c21462ed936
BLAKE2b-256 82996a0c3a3a98346eb4c7ece10b0814cff8321d590edb354edbcc299fb62e4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eabb7676028bc4e12f6127165e871dd6c685a835d09bd1898b872734e461345c
MD5 a2d12b0d6f999864c25092396d0c3a43
BLAKE2b-256 7cd9e9aa1659b9e17fa94fcc10aebd274f602baf4ad0ce9ae874e523f6cbfd1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d8432d282035bfae5be90175f430c09e2ace031764b50a71b21a4c85bfe5c8b
MD5 4663c173a6dc0ab8941167c31905cd0c
BLAKE2b-256 4bdf15ec5faf1676ec597a3e436dbb95852d98a9b6346d97414f266af16c74de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d497697c7657338366505c65db304fc00dacb5993703c74b6cd6c27cd4f65a6e
MD5 f9ad4ec926bb2a9d4a3752524ad186a6
BLAKE2b-256 83f4fd913d84a03b0b59ca21c5c61863684ba53cd471d5e77a4f9dbc88cff47a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 21702eb2f17f8c015c3e0e7c5aedb4c0d08a040b20682ce145464c14ad880351
MD5 fcf91d6897e4eeeb92b705095a502f8f
BLAKE2b-256 3db7d945b8140b407eb56d0652c8e5198c8e2a4052bcd6ee50c9f037ad86af28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 20cc4ab0be304523ba3d2c889bf752f4b49ccd069155e02aaf5d4c294b60e822
MD5 2d14ce123d8635140f6da748d9ac4758
BLAKE2b-256 0b7adc49770bf84df2156d2c3144f03c447cbd1a83fa6cd21a11b4a22e3d4a52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d55ddb85cdfd9b5d9bb675bb51d8fce6dcb6ac2bca9bcf59e2c68315e18dc5a
MD5 9d6f63c8c083656293fa68d1d0b34965
BLAKE2b-256 cfc7490b413c1001f983a511234ff8268dabd0df222abb1dbf7fdfecbef13d98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 db8ba3cc8ded9c812a6a18960731cb6bae726db9dbed1fac44a893337f62f0ae
MD5 e59ad1d5582738691063f873cca6910c
BLAKE2b-256 6216392befcc001082d0951d13db56d073ca1978b84ec79ab78aea4591b182af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_flint-0.5.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 13.2 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.5.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a6020a5843f877aecc4bd595ac6d84790c102f56d2199d3de2e0f1097631af6d
MD5 55e3e8a393b4ca3356b6fab9e0420200
BLAKE2b-256 4127d6984a437f6942b337f2deef135036ffac836d369d1cda934e8813e3e9d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f345d99e3403c8cb45992f4340fffc6fb644234a97fef59e72326956f37dda8
MD5 6c57ae7006e26c049f26212448be0938
BLAKE2b-256 803f1216d3c8de7d8ea4d26df58751ec6afb0116644bb7a20f0246c74ec90eaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b32d5692b483280fc26262b4904a53e20a1ca894d008c1d13b27c646ec7095e0
MD5 d0e3532a3f76664b85e7892a3a149e4f
BLAKE2b-256 0f4d76b2c1d41ca44ccd0766bda4d7f8a36488aba1d475e1647bc947ae6db0ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_flint-0.5.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bc45c9cbb88b636fd337c43ad81ae2793768c7402a9cd503e693b4612af0db0a
MD5 c4139c7b6dd970df1c2a21c65c72ceea
BLAKE2b-256 3b0d35fb481e8160bc03a3ee4def8482f7c7090c7e897386109a7522ce30de91

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