Skip to content

Commit

Permalink
Merge pull request #218 from oscarbenjamin/pr_generic_rings
Browse files Browse the repository at this point in the history
Initial bindings for generic rings
  • Loading branch information
oscarbenjamin authored Sep 15, 2024
2 parents ae4fe25 + 90059f9 commit bbc459f
Show file tree
Hide file tree
Showing 23 changed files with 4,499 additions and 13 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Contributors (0.7.0):
- Giacomo Pope (GP)
- Joris Roos (JR)
- Edgar Costa (EC)
- Frédéric Chapoton (FC)
- Oscar Benjamin (OB)

Highlights (0.7.0):
Expand All @@ -175,18 +176,34 @@ Highlights (0.7.0):
- [gh-132](https://github.com/flintlib/python-flint/pull/132),
[gh-164](https://github.com/flintlib/python-flint/pull/164),
[gh-190](https://github.com/flintlib/python-flint/pull/190),
[gh-191](https://github.com/flintlib/python-flint/pull/191):
[gh-192](https://github.com/flintlib/python-flint/pull/192):
[gh-216](https://github.com/flintlib/python-flint/pull/216):
[gh-225](https://github.com/flintlib/python-flint/pull/225):
Add `fmpz_mpoly`, `fmpq_mpoly`, `nmod_poly` and `fmpz_mod_poly`
types for multivariate polynomials with integer, rational or
integers mod n coefficients. (JM)
integers mod `n` coefficients. (JM)
- [gh-142](https://github.com/flintlib/python-flint/pull/142)
Add `acb_theta` module for the numerical evaluation of [theta
functions](https://flintlib.org/doc/acb_theta.html) (only
available for `Flint >= 3.1`). (EC)
- [gh-218](https://github.com/flintlib/python-flint/pull/218)
An experimental interface for FLINT's generic rings has been
added. This provides access to many of FLINT's types that
are not yet wrapped by python-flint such as Gaussian integer,
number fields, qqbar, calcium, as well as both univariate and
multivariate polynomials and series over these rings (no
matrices yet though). (OB)
- [gh-129](https://github.com/flintlib/python-flint/pull/129)
[gh-208](https://github.com/flintlib/python-flint/pull/208)
Use meson/meson-python instead of setuptools as the build system
for parallel builds and better detection of build and dependency
requirements. (OB)
- [gh-201](https://github.com/flintlib/python-flint/pull/201)
[gh-202](https://github.com/flintlib/python-flint/pull/202)
The documentation has been updated and is now at
[readthedocs](https://python-flint.readthedocs.io/en/latest/).
(OB)

Compatibility break (0.7.0):

Expand All @@ -198,11 +215,23 @@ Compatibility break (0.7.0):

Other changes (0.7.0):

- [gh-215](https://github.com/flintlib/python-flint/pull/215)
[gh-219](https://github.com/flintlib/python-flint/pull/219)
The FLINT binding declarations are now fully generated
automatically from the FLINT docs. (OB)
- [gh-203](https://github.com/flintlib/python-flint/pull/203)
[gh-204](https://github.com/flintlib/python-flint/pull/204)
[gh-205](https://github.com/flintlib/python-flint/pull/205)
[gh-206](https://github.com/flintlib/python-flint/pull/206)
[gh-207](https://github.com/flintlib/python-flint/pull/207)
[gh-211](https://github.com/flintlib/python-flint/pull/211)
[gh-212](https://github.com/flintlib/python-flint/pull/212)
Various linting fixes and codebase improvements (FC and GP).
- [gh-189](https://github.com/flintlib/python-flint/pull/189)
All scalar and poly types now have `sqrt`. All poly types now
have `factor_squarefree` and `leading_coefficient` methods.
Exception types raised in a number of places were changed to
`DomainError` for better consistency.
`DomainError` for better consistency. (OB)
- [gh-196](https://github.com/flintlib/python-flint/pull/196)
Supported Python versions are 3.10-3.13 (3.9 dropped). CI
Testing added for 3.13 free-threaded CPython.
Expand Down
18 changes: 9 additions & 9 deletions bin/all_rst_to_pxd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ modules=(
"mpoly"
# "thread_pool"
# "machine_vectors"
# "gr"
# "gr_domains"
# "gr_generic"
# "gr_implementing"
# "gr_mat"
# "gr_mpoly"
# "gr_poly"
# "gr_special"
# "gr_vec"
"gr"
"gr_domains"
"gr_generic"
"gr_implementing"
"gr_mat"
"gr_mpoly"
"gr_poly"
"gr_special"
"gr_vec"
"ulong_extras"
"fmpz"
# "fmpz_extras"
Expand Down
10 changes: 9 additions & 1 deletion bin/rst_to_pxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
c_types = set(["void", "char", "short", "long", "int", "float", "double"])
type_modifers = re.compile(r"\*|(\bconst\b)|(\bunsigned\b)|(\bsigned\b)")
import_dict = {}
# gr_domains.rst lists functions that are in gr.h
doc_to_header = {'flint/gr_domains': 'flint/gr'}


def get_cython_struct_types(file):
"""
Expand Down Expand Up @@ -144,6 +147,9 @@ def get_all_types(function_list):


def has_types(line, types):
#ts = set(t for t in get_parameter_types(line) if t in types)
#if ts:
# print(ts, file=sys.stderr)
return any(t in types for t in get_parameter_types(line))


Expand Down Expand Up @@ -171,7 +177,9 @@ def generate_pxd_file(h_name, opts):
fill_import_dict(opts.flint_lib_dir)
l=[]
docdir = opts.arb_doc_dir
name = h_name
name = h_name
h_name = doc_to_header.get(h_name, h_name)

if name[:6] == "flint/":
docdir = opts.flint_doc_dir
name = name[6:]
Expand Down
151 changes: 151 additions & 0 deletions doc/source/_gr.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
**_gr** -- generic rings (unstable interface)
===============================================================================

.. note::
This module provides a preliminary experimental interface for FLINT's
generic rings. This is largely untested and the interface should be
considered unstable. In future the generic rings code will be integrated
with the rest of python-flint and this module may be removed. For now it
provides access to many FLINT types that are not wrapped yet in the rest of
python-flint.

The generic rings module provides access to the generic rings interface in
FLINT. Usage of this interface consists of creating a context object to
represent a particular domain and then using that context object to create
elements of that domain. For example to create a context for polynomials in two
variables over the Gaussian integers :math:`\mathbb{Z}[i][x,y]` we would do::

>>> from flint.types._gr import gr_fmpzi_ctx, gr_gr_mpoly_ctx
>>> ctx = gr_gr_mpoly_ctx.new(gr_fmpzi_ctx, ["x", "y"])
>>> ctx.gens()
[x, y]
>>> ctx.gens_recursive()
[I, x, y]
>>> I, x, y = ctx.gens_recursive()
>>> p = (x + y + I)**2
>>> p
x^2 + 2*x*y + (2*I)*x + y^2 + (2*I)*y - 1

Some domains such as ``gr_fmpzi_ctx`` are global and do not need to be created.
Others such as ``gr_gr_mpoly_ctx`` are created using :meth:`gr_ctx.new`.

.. autoclass :: flint.types._gr.gr_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_scalar_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_poly_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_mpoly_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr._gr_fmpz_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr._gr_fmpq_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr._gr_fmpzi_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr._gr_fexpr_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_nmod_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_fmpz_mod_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_fq_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_fq_nmod_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_fq_zech_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_nf_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_nf_fmpz_poly_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_real_qqbar_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_complex_qqbar_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_real_ca_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_complex_ca_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_real_algebraic_ca_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_complex_algebraic_ca_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_complex_extended_ca_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_real_float_arf_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_complex_float_acf_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_real_arb_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_complex_acb_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_gr_poly_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_gr_mpoly_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr_series_ctx
:members:
:undoc-members:
.. autoclass :: flint.types._gr.gr
:members:
:inherited-members:
:undoc-members:
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = 'furo'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
7 changes: 7 additions & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,10 @@ Power series types
arb_series.rst
acb_series.rst

Experimental generic rings interface
....................................

.. toctree::
:maxdepth: 2

_gr.rst
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ coverage
pytest-cov
sphinx
sphinx-rtd-theme
furo
3 changes: 3 additions & 0 deletions src/flint/flint_base/flint_base.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from flint.flintlib.types.mpoly cimport ordering_t

cdef class flint_ctx:
pass

cdef class flint_elem:
pass

Expand Down
Loading

0 comments on commit bbc459f

Please sign in to comment.