Skip to content

Commit

Permalink
sagemathgh-36449: Autogenerate flint headers
Browse files Browse the repository at this point in the history
We
- write down a script to auto-generate flint header files (currently at
https://github.com/videlec/flint-header-sage-autogen)
- replace most of the files in `src/sage/libs/flint` by auto-generated
files. Doing so, the custom sage code in `src/sage/libs/flint` is always
contained in files suffixed by `_sage.pxd`/`_sage.pyx`.
- deprecate the files in `src/sage/libs/arb/`

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

sagemath#35848

#### Upstream issues and patches

- flintlib/flint#1523
- flintlib/flint#1529
- flintlib/flint#1532
- flintlib/flint#1535
- flintlib/flint#1536
- cython/cython#5779
- flintlib/flint#1653
- flintlib/flint#1655

URL: sagemath#36449
Reported by: Vincent Delecroix
Reviewer(s): Marc Mezzarobba, Matthias Köppe, Vincent Delecroix
  • Loading branch information
Release Manager committed Dec 25, 2023
2 parents d7b55b4 + 2082c34 commit d4b646b
Show file tree
Hide file tree
Showing 218 changed files with 18,927 additions and 4,582 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=2389d2b093493c568deda190ffc326ff2b835169
md5=545e80b50deb4efa46f14d0a543ba98f
cksum=169905223
sha1=0fcbe1a887ddd40214a679d17175e8b9c4885bd8
md5=9385fa8c9352373659fae328a566de73
cksum=2674333517
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
73e52a419812253c3c3ce72bab7f1a5ddf4c0461
62bc40c630f815364a0375468d19e9b00477812c
9 changes: 5 additions & 4 deletions src/doc/en/reference/libs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ FLINT
.. toctree::
:maxdepth: 1

sage/libs/flint/flint
sage/libs/flint/fmpz_poly
sage/libs/flint/arith
sage/libs/flint/qsieve
sage/libs/flint/fmpz_poly_sage
sage/libs/flint/fmpq_poly_sage
sage/libs/flint/arith_sage
sage/libs/flint/qsieve_sage
sage/libs/flint/ulong_extras_sage

Giac
----
Expand Down
1 change: 1 addition & 0 deletions src/sage/algebras/quatalg/quaternion_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ from sage.libs.gmp.mpq cimport *
from sage.libs.ntl.convert cimport mpz_to_ZZ, ZZ_to_mpz
from sage.libs.flint.fmpz cimport *
from sage.libs.flint.fmpz_poly cimport *
from sage.libs.flint.fmpz_poly_sage cimport *
from sage.libs.flint.ntl_interface cimport *

# variables for holding temporary values computed in
Expand Down
4 changes: 2 additions & 2 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def bernoulli(n, algorithm='default', num_threads=1):
if n >= 100000:
from warnings import warn
warn("flint is known to not be accurate for large Bernoulli numbers")
from sage.libs.flint.arith import bernoulli_number as flint_bernoulli
from sage.libs.flint.arith_sage import bernoulli_number as flint_bernoulli
return flint_bernoulli(n)
elif algorithm == 'pari' or algorithm == 'gp':
from sage.libs.pari.all import pari
Expand Down Expand Up @@ -6230,7 +6230,7 @@ def dedekind_sum(p, q, algorithm='default'):
- :wikipedia:`Dedekind\_sum`
"""
if algorithm == 'default' or algorithm == 'flint':
from sage.libs.flint.arith import dedekind_sum as flint_dedekind_sum
from sage.libs.flint.arith_sage import dedekind_sum as flint_dedekind_sum
return flint_dedekind_sum(p, q)

if algorithm == 'pari':
Expand Down
16 changes: 8 additions & 8 deletions src/sage/combinat/combinat.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ def bell_number(n, algorithm='flint', **options) -> Integer:
return ZZ(int(ret_mp))

elif algorithm == 'flint':
import sage.libs.flint.arith
return sage.libs.flint.arith.bell_number(n)
import sage.libs.flint.arith_sage
return sage.libs.flint.arith_sage.bell_number(n)

elif algorithm == 'gap':
from sage.libs.gap.libgap import libgap
Expand Down Expand Up @@ -576,8 +576,8 @@ def euler_number(n, algorithm='flint') -> Integer:
if algorithm == 'maxima':
return ZZ(maxima.euler(n)) # type:ignore
elif algorithm == 'flint':
import sage.libs.flint.arith
return sage.libs.flint.arith.euler_number(n)
import sage.libs.flint.arith_sage
return sage.libs.flint.arith_sage.euler_number(n)
else:
raise ValueError("algorithm must be 'flint' or 'maxima'")

Expand Down Expand Up @@ -906,8 +906,8 @@ def stirling_number1(n, k, algorithm="gap") -> Integer:
from sage.libs.gap.libgap import libgap
return libgap.Stirling1(n, k).sage()
if algorithm == 'flint':
import sage.libs.flint.arith
return sage.libs.flint.arith.stirling_number_1(n, k)
import sage.libs.flint.arith_sage
return sage.libs.flint.arith_sage.stirling_number_1(n, k)
raise ValueError("unknown algorithm: %s" % algorithm)


Expand Down Expand Up @@ -1034,8 +1034,8 @@ def stirling_number2(n, k, algorithm=None) -> Integer:
from sage.libs.gap.libgap import libgap
return libgap.Stirling2(n, k).sage()
if algorithm == 'flint':
import sage.libs.flint.arith
return sage.libs.flint.arith.stirling_number_2(n, k)
import sage.libs.flint.arith_sage
return sage.libs.flint.arith_sage.stirling_number_2(n, k)
if algorithm == 'maxima':
return ZZ(maxima.stirling2(n, k)) # type:ignore
raise ValueError("unknown algorithm: %s" % algorithm)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@

from sage.arith.misc import binomial, factorial, gcd, multinomial
from sage.libs.pari.all import pari
from sage.libs.flint.arith import number_of_partitions as flint_number_of_partitions
from sage.libs.flint.arith_sage import number_of_partitions as flint_number_of_partitions
from sage.structure.global_options import GlobalOptions
from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
Expand Down
4 changes: 2 additions & 2 deletions src/sage/features/sagemath.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ def __init__(self):
True
"""
JoinFeature.__init__(self, 'sage.libs.flint',
[PythonModule('sage.libs.flint.flint'),
PythonModule('sage.libs.arb.arith')],
[PythonModule('sage.libs.flint.arith_sage'),
PythonModule('sage.libs.flint.flint_sage')],
spkg='sagemath_flint', type='standard')


Expand Down
2 changes: 1 addition & 1 deletion src/sage/functions/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
lazy_import('sage.symbolic.constants', 'pi', as_='const_pi')
lazy_import('sage.rings.complex_double', 'CDF')

lazy_import('sage.libs.flint.arith', 'harmonic_number', as_='_flint_harmonic_number')
lazy_import('sage.libs.flint.arith_sage', 'harmonic_number', as_='_flint_harmonic_number')

lazy_import('sage.libs.mpmath.utils', 'call', as_='_mpmath_utils_call')
lazy_import('mpmath', 'harmonic', as_='_mpmath_harmonic')
Expand Down
2 changes: 2 additions & 0 deletions src/sage/graphs/matchpoly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ from sage.rings.integer cimport Integer

from sage.libs.flint.fmpz cimport *
from sage.libs.flint.fmpz_poly cimport *
from sage.libs.flint.fmpz_poly_sage cimport *


x = polygen(ZZ, 'x')

Expand Down
4 changes: 2 additions & 2 deletions src/sage/interfaces/qsieve.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sage.misc.superseded import deprecated_function_alias
import sage.libs.flint.qsieve
import sage.libs.flint.qsieve_sage

qsieve = deprecated_function_alias(1, sage.libs.flint.qsieve.qsieve)
qsieve = deprecated_function_alias(1, sage.libs.flint.qsieve_sage.qsieve)
2 changes: 1 addition & 1 deletion src/sage/libs/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
lazy_import('sage.libs.eclib.mwrank', 'set_precision', 'mwrank_set_precision')
lazy_import('sage.libs.eclib.mwrank', 'initprimes', 'mwrank_initprimes')

lazy_import('sage.libs.flint.qsieve', 'qsieve')
lazy_import('sage.libs.flint.qsieve_sage', 'qsieve')

lazy_import('sage.libs.giac.giac', 'libgiac')
Loading

0 comments on commit d4b646b

Please sign in to comment.