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.
See here for instructions on building FLINT:
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 .
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.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 resultfmpz(2)
or raises an error if an exact result is not possible. Similar changes forfmpz_poly/fmpz
,fmpz_mat/fmpz
, and for polynomial division withfmpz_poly
,fmpq_poly
,nmod_poly
andfmpz_mod_poly
. - gh-106:
Add
fmpz_mod_mat
for matrices of integers modn
wheren
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 overfmpz_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 thecomplex_roots
method oracb_roots(p).roots()
to get the old behaviour of returning the complex roots. Theroots
method onfmpz_poly
andfmpq_poly
now return integer and rational roots respectively. To access complex roots on these types, use thecomplex_roots
method. Foracb_poly
, bothroots
andcomplex_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 ofarb_poly
, andnmod_poly
is no longer supported. Useacb_roots(p).roots()
to get the old behaviour of returning the roots asacb
. Note that theroots
method offmpz_poly
andfmpq_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file python-flint-0.6.0.tar.gz
.
File metadata
- Download URL: python-flint-0.6.0.tar.gz
- Upload date:
- Size: 3.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f829e00774534891b38de41bc511cf6c7d6d216544a6a84b92d9e1f159de0878 |
|
MD5 | 6473f4da8959f0ec085db62bca3e40e3 |
|
BLAKE2b-256 | 163ad129f056475191377a823efe9876656a81d563bb7463d0f8568ebee81ef6 |
File details
Details for the file python_flint-0.6.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 14.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e39cc74a54925413dc825bc69e328b7f594270a9eac95d276c0b919e77584e7 |
|
MD5 | ca4ad0c85e3c4a3ad0a4ffa0812a5a73 |
|
BLAKE2b-256 | bb92fe03310f516bbd48dbed8aa7a7c083f74d55f293d692adcb44292beccf14 |
File details
Details for the file python_flint-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 41.7 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 647d6b901e413d54cf8ef493264021d9eb8f7ad1ad9d931e5efc735c13967756 |
|
MD5 | 83b8db192ee2aef167ecf90663bafa29 |
|
BLAKE2b-256 | 22e018819822dd3b3e8539ed8c78302b323097c6784ed0494dbf50e32bd0f5e4 |
File details
Details for the file python_flint-0.6.0-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 9.8 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2584517a4a24556bd3d0a1e0bdffb5a72fa341f9202ae069e54678d38bd8851c |
|
MD5 | bc5239c97f253a8da2e089e22e7f8274 |
|
BLAKE2b-256 | d117690e5fc99a99525cf06b8be26611ba32c5c34a15db75d1e8b76926bd2b3c |
File details
Details for the file python_flint-0.6.0-cp312-cp312-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 10.8 MB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c14a30e9c1a7b9ff7fab5cc6f80cc7edb7a8c9deb80d6a0dd51f02a3c651ea2d |
|
MD5 | fa109619dd2190a670f6343f35ce8b89 |
|
BLAKE2b-256 | cc945ef1d5d5fd4e4ae7f139650c1e882042d7088659653327f7e5cf59ec4048 |
File details
Details for the file python_flint-0.6.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 16.5 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cff2c21217f9ee601430fedbb41d694271a609e8bca3f30558a9a9e004b93696 |
|
MD5 | 8b2e0c6a1f7d8dfa340c54a3e09b4166 |
|
BLAKE2b-256 | 70733e9e29455c9b222db1c3c98b3bfa92748b32a853e75acfb7f5c1a8c8f72d |
File details
Details for the file python_flint-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 41.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f30b0a0f24a1db1a5efa23e947edc54ca922bfec79d393bc8b863123bc9a84c |
|
MD5 | b863793fd948740dcd3cd8d4be90936f |
|
BLAKE2b-256 | c40850eebbe36472325bccf975c02797628e3d4b6a39d311a4fe3e3925005fe7 |
File details
Details for the file python_flint-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 9.8 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc49340fc9b95044c09668fba8f92d5b0b31f6a9500111c4cccb59ab0141746b |
|
MD5 | b0976ef04573c3f50dd38574cf7de2d3 |
|
BLAKE2b-256 | 2ede08995c5b98c797f422fe59f563b0126c6ceabbf05f1f26e52cc588a20761 |
File details
Details for the file python_flint-0.6.0-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 10.8 MB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 248a2a9c14d9e9cae8eb0dfd2016ef956536492d56cbcb21a8c1778d6730e3bc |
|
MD5 | 72f5f6cc0999e15c6ea92e1d48bf5fc4 |
|
BLAKE2b-256 | dea663ad30e7123c4bf45f4bdc42c92187a69e006dc809ee2fc413804f0cad74 |
File details
Details for the file python_flint-0.6.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 16.5 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44c8bfefa7019ef40b7b4018d38b4a652dfbc094c7754341235078171fb9aa81 |
|
MD5 | 1d4a8a123343e3d8aee72d64feab6e4b |
|
BLAKE2b-256 | 12b44721249bbcbe3e1a08702e8b9962adb837576952c42d48534609fe351a0f |
File details
Details for the file python_flint-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 41.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a99082434cbc568c7ad55fe6810eb832e04548af3d8130539ec4b78b0cc5cb9 |
|
MD5 | b10539cf0791f298dbf2a6faeeb5e8e4 |
|
BLAKE2b-256 | 890bfd9012308257304031433b1a0926044e617f3532040fbf2618b6b26e14bd |
File details
Details for the file python_flint-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 9.8 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20339504a3f368978fe25351b489ed701cf78927ded5afb384024281634caff1 |
|
MD5 | 98ddf6b02b3ce5da00ed8c16001bf4e3 |
|
BLAKE2b-256 | 9e0b3d1a07da2dff0e24c361b89d7b922cb8688b39eb577b999d14dbd613d4c9 |
File details
Details for the file python_flint-0.6.0-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 10.8 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37f4ffc1067b86c4f95f21c1c1a5a746f0e57b46af4fb7dd34fe2bdcda6ad55b |
|
MD5 | f0bc2af2bdb282d9eabae8735a90ac8f |
|
BLAKE2b-256 | 1a789af0165d78a354239341c72ba3229b605db3a4326336731eaed09b708976 |
File details
Details for the file python_flint-0.6.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 16.5 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d30e71d789240651fb2a42115e2b50ac809528ffc62810301a4fd939192bb690 |
|
MD5 | 5522d61fbd7bfb78ac11858b89c5c40c |
|
BLAKE2b-256 | ffc88ea8eaff003bcd70af262ecd28d149d0d40db7670c547d869c08cba4107a |
File details
Details for the file python_flint-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 41.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbda2aad2829e8bdba03ef8de7e0adfc700f85576a7f00519c32b40b6a4b43d7 |
|
MD5 | 0466d084b75d8cb7f89b129ee00d7cdd |
|
BLAKE2b-256 | f0aef0d404e82dd6a26aa659675ea0d814b6c5a05a3536e5cc5657c25cd167c0 |
File details
Details for the file python_flint-0.6.0-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 9.8 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d7e366a71bcbba3dfeedf6c5423acad5e9dfb8aa7e508159cac2b0c894a586c |
|
MD5 | 74117e97672598749d4619323e375d3a |
|
BLAKE2b-256 | c5683dfb1ae70a657161742fe830c541908bd79bb8d2ba295e4189646f1ffa55 |
File details
Details for the file python_flint-0.6.0-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: python_flint-0.6.0-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 10.8 MB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a74da612bb0c1f22ae1434c4afbbc3790a81a3ec606f0fac3fab284ab2df4a5 |
|
MD5 | 39bdb2b8a131d20a55022641115ec87b |
|
BLAKE2b-256 | 92ba70a58fbcb637bacf6f1cdfefdaa6d23878b265d5deaa310675eb38cf6b2a |