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:
* http://flintlib.org/
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:
* https://github.com/flintlib/python-flint/blob/master/bin/pip_install_ubuntu.sh
See the documentation for further notes on building and installing
python-flint:
* https://fredrikj.net/python-flint/setup.html
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+.
Raw data
{
"_id": null,
"home_page": "https://github.com/flintlib/python-flint",
"name": "python-flint",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Fredrik Johansson",
"author_email": "fredrik.johansson@gmail.com",
"download_url": "",
"platform": null,
"description": "Python-FLINT\n============\n\nPython extension module wrapping FLINT (Fast Library for Number Theory)\nand Arb (arbitrary-precision ball arithmetic). Features:\n\n* Integers, rationals, integers mod n\n* Real and complex numbers with rigorous error tracking\n* Polynomials, power series and matrices over all the above types\n* Lots of mathematical functions\n\nDocumentation: http://fredrikj.net/python-flint/\n\nRepository: https://github.com/flintlib/python-flint/\n\nAuthor: Fredrik Johansson <fredrik.johansson@gmail.com>\n\nInstallation\n------------\n\nCurrently python-flint supports CPython versions 3.9-3.12. For Windows (x86-64)\nor OSX (x86-64 or arm64) or Linux (x86-64 `manylinux_2_17`) there are CPython\nbinary wheels for python-flint on PyPI. For these platforms python-flint can be\ninstalled simply with `pip`\n\n pip install python-flint\n\nAlternatively python-flint can be installed using `conda`\n\n conda install -c conda-forge python-flint\n\nIt is also possible to use python-flint with some PyPy versions. Binary wheels\nare not provided for this on PyPI but can be installed with conda.\n\nBuild from source\n-----------------\n\nFor other platforms or architectures installation needs to build from source.\nFirst install FLINT 3.0.0. Note that as of python-flint 0.5.0 only this *exact*\nversion of FLINT will work. In future it is hoped that the version requirement\nfor python-flint will be FLINT >= 3.0.0 but at the time of writing 3.0.0 is the\nnewest version of FLINT that has only been released recently and is the only\nversion that is supported by python-flint.\n\nSee here for instructions on building FLINT:\n\n* http://flintlib.org/\n\nThe latest release of Python-FLINT can then be built and installed using:\n\n pip install 'cython>=3' numpy wheel\n pip install --no-build-isolation python-flint\n\nPython-FLINT can also be installed from a git checkout or a source archive\nas follows:\n\n pip install 'cython>=3' numpy wheel\n pip install --no-build-isolation .\n\nA script that builds and installs FLINT and python-flint that is tested on\nUbuntu can be found in the git repo here:\n\n* https://github.com/flintlib/python-flint/blob/master/bin/pip_install_ubuntu.sh\n\nSee the documentation for further notes on building and installing\npython-flint:\n\n* https://fredrikj.net/python-flint/setup.html\n\nExamples\n-------------------------------------\n\nImport Python-FLINT:\n\n >>> from flint import *\n\nNumber-theoretic functions:\n\n >>> fmpz(1000).partitions_p()\n 24061467864032622473692149727991\n >>> fmpq.bernoulli(64)\n -106783830147866529886385444979142647942017/510\n\nPolynomial arithmetic:\n\n >>> a = fmpz_poly([1,2,3]); b = fmpz_poly([2,3,4]); a.gcd(a * b)\n 3*x^2 + 2*x + 1\n >>> a = fmpz_poly(list(range(10001))); b = fmpz_poly(list(range(10000))); a.gcd(a * b).degree()\n 10000\n >>> x = fmpz_poly([0,1]); ((1-x**2)*(1+x**3)**3*(1+x+2*x)).factor()\n (-1, [(3*x + 1, 1), (x + (-1), 1), (x^2 + (-1)*x + 1, 3), (x + 1, 4)])\n\nMatrix arithmetic:\n\n >>> fmpz_mat([[1,1],[1,0]]) ** 10\n [89, 55]\n [55, 34]\n >>> fmpq_mat.hilbert(10,10).det()\n 1/46206893947914691316295628839036278726983680000000000\n\nNumerical evaluation:\n\n >>> showgood(lambda: (arb.pi() * arb(163).sqrt()).exp() - 640320**3 - 744, dps=25)\n -7.499274028018143111206461e-13\n >>> showgood(lambda: (arb.pi() * 10**100 + arb(1)/1000).sin(), dps=25)\n 0.0009999998333333416666664683\n\nNumerical integration:\n\n >>> ctx.dps = 30\n >>> acb.integral(lambda x, _: (-x**2).exp(), -100, 100) ** 2\n [3.141592653589793238462643383 +/- 3.11e-28]\n\nTo do\n-------------------------------------\n\n* Write more tests and add missing docstrings\n* Wrap missing flint types: finite fields, p-adic numbers, rational functions\n* Vector or array types (maybe)\n* Many convenience methods\n* Write generic implementations of functions missing for specific FLINT types\n* Proper handling of special values in various places (throwing Python\n exceptions instead of aborting, etc.)\n* Various automatic conversions\n* Conversions to and from external types (numpy, sage, sympy, mpmath, gmpy)\n* Improved printing and string input/output\n* IPython hooks (TeX pretty-printing etc.)\n\nCHANGELOG\n-------------\n\n0.5.0\n\nImportant compatibility changes:\n\n- gh-80, gh-94, gh-98: Switch from Flint 2.9 to Flint 3.\n- gh-100: Supports Python 3.12 by using setuptools instead of numpy.distutils.\n\nNew features:\n\n- gh-87: Adds `fmpz_mod_poly` type for polynomials over `fmpz_mod`.\n- gh-85: Adds discrete logarithms to `fmpz_mod`.\n- gh-83: Introduces the `fmpz_mod` type for multi-precision integer mods.\n\nBug fixes:\n\n- gh-93: Fixes a bug with `pow(int, int, fmpz)` which previously gave incorrect\n results.\n- gh-78, gh-79: minor fixes for the `nmod` type.\n\n0.4.4\n\n- gh-75, gh-77: finish bulk of the work in refactoring `python-flint` into\n submodules\n- gh-72: The roots method of `arb_poly` is not supported. Use either the\n `complex_roots` method or `acb_roots(p).roots()` to get the old behaviour of\n returning the complex roots. The `roots` method on `fmpz_poly` and\n `fmpq_poly` now return integer and rational roots respectively. To access\n complex roots on these types, use the `complex_roots` method. For `acb_poly`,\n both `roots` and `complex_roots` behave the same\n- gh-71: Include files in sdist and fix issue gh-70\n- gh-67: Continue refactoring job to introduce submodules into `python-flint`\n\n0.4.3\n\n- gh-63: The `roots` method of `arb_poly`, and `nmod_poly` is no longer\n supported. Use `acb_roots(p).roots()` to get the old behaviour of returning\n the roots as `acb`. Note that the `roots` method of `fmpz_poly` and\n `fmpq_poly` currently returns the complex roots of the polynomial.\n- gh-61: Start refactoring job to introduce submodules into `python-flint`\n\n0.4.2\n\n- gh-57: Adds manylinux wheels\n\n0.4.1\n\n- gh-47: Removes Linux wheels, updates instructions for building from source.\n\n0.4.0\n\n- gh-45: Adds wheels for Windows, OSX and manylinux but the Linux wheels are\n broken.\n\nLicense\n------------\n\nPython-FLINT is licensed MIT. FLINT and Arb are LGPL v2.1+.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Bindings for FLINT and Arb",
"version": "0.5.0",
"project_urls": {
"Homepage": "https://github.com/flintlib/python-flint"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6216392befcc001082d0951d13db56d073ca1978b84ec79ab78aea4591b182af",
"md5": "e59ad1d5582738691063f873cca6910c",
"sha256": "db8ba3cc8ded9c812a6a18960731cb6bae726db9dbed1fac44a893337f62f0ae"
},
"downloads": -1,
"filename": "python_flint-0.5.0-cp310-cp310-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "e59ad1d5582738691063f873cca6910c",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 7646511,
"upload_time": "2023-10-22T11:17:54",
"upload_time_iso_8601": "2023-10-22T11:17:54.742741Z",
"url": "https://files.pythonhosted.org/packages/62/16/392befcc001082d0951d13db56d073ca1978b84ec79ab78aea4591b182af/python_flint-0.5.0-cp310-cp310-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cfc7490b413c1001f983a511234ff8268dabd0df222abb1dbf7fdfecbef13d98",
"md5": "9d6f63c8c083656293fa68d1d0b34965",
"sha256": "3d55ddb85cdfd9b5d9bb675bb51d8fce6dcb6ac2bca9bcf59e2c68315e18dc5a"
},
"downloads": -1,
"filename": "python_flint-0.5.0-cp310-cp310-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "9d6f63c8c083656293fa68d1d0b34965",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 6613444,
"upload_time": "2023-10-22T11:44:23",
"upload_time_iso_8601": "2023-10-22T11:44:23.847002Z",
"url": "https://files.pythonhosted.org/packages/cf/c7/490b413c1001f983a511234ff8268dabd0df222abb1dbf7fdfecbef13d98/python_flint-0.5.0-cp310-cp310-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-22 11:17:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "flintlib",
"github_project": "python-flint",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "python-flint"
}