Skip to content

Commit

Permalink
Merge pull request #219 from oscarbenjamin/pr_bindings
Browse files Browse the repository at this point in the history
Backdate autogenerated bindings to FLINT 3.1.3-p1
  • Loading branch information
oscarbenjamin authored Sep 8, 2024
2 parents d4a8f7c + 14241cd commit da51f7b
Show file tree
Hide file tree
Showing 25 changed files with 419 additions and 375 deletions.
35 changes: 35 additions & 0 deletions src/flint/flintlib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Cython declarations for functions exported by libflint
======================================================

This directory contains Cython declarations for functions exported by libflint.
The declarations under the `types` directory are for the types defined in
libflint and are hand-written. The declarations under the `functions` directory
are for the functions defined in libflint and are generated by running:
```console
$ bin/all_rst_to_pxd.sh /path/to/flint/doc/source
```
where `/path/to/flint/doc/source` is the path to the source directory of the
flint documentation. This command should always be run on the FLINT docs of the
version of FLINT that is used by default in python-flint's wheels which is the
version shown in the `bin/build_variables.sh` script. Typically this just means
the latest released version of FLINT.

It is important not to edit any of the files in `functions` manually because a
subsequent run of `bin/all_rst_to_pxd.sh` will overwrite them. There are
several reasons why manual editing may be needed but usually it is because
either:

1. The function is not documented in the FLINT docs.
2. The function is a macro and not a function.

In either case, we need to manually write the declaration for the function but
it cannot be done in the `functions` directory. Instead, it should be added
somewhere in the `types` directory.

Generally undocumented functions should be reported/fixed upstream in FLINT.

It might be better to list macros (and undocumented functions) in the
`bin/rst_to_pxd.py` script so that it can add them to the generated files
automatically. Then we can keep them out of the hand-written code but also keep
track of them with a goal of eventually getting all of them added to the FLINT
docs.
1 change: 1 addition & 0 deletions src/flint/flintlib/functions/acb_poly.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ cdef extern from "flint/acb_poly.h":
void acb_poly_root_bound_fujiwara(mag_t bound, acb_poly_t poly)
void _acb_poly_root_inclusion(acb_t r, const acb_t m, acb_srcptr poly, acb_srcptr polyder, slong len, slong prec)
slong _acb_poly_validate_roots(acb_ptr roots, acb_srcptr poly, slong len, slong prec)
void _acb_poly_refine_roots_durand_kerner(acb_ptr roots, acb_srcptr poly, slong len, slong prec)
slong _acb_poly_find_roots(acb_ptr roots, acb_srcptr poly, acb_srcptr initial, slong len, slong maxiter, slong prec)
slong acb_poly_find_roots(acb_ptr roots, const acb_poly_t poly, acb_srcptr initial, slong maxiter, slong prec)
int _acb_poly_validate_real_roots(acb_srcptr roots, acb_srcptr poly, slong len, slong prec)
Expand Down
18 changes: 9 additions & 9 deletions src/flint/flintlib/functions/arb.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flint.flintlib.types.arb cimport arb_ptr, arb_srcptr, arb_t, mag_srcptr, mag_t
from flint.flintlib.types.arf cimport arf_rnd_t, arf_srcptr, arf_t
from flint.flintlib.types.flint cimport flint_bitcnt_t, flint_rand_t, fmpz_struct, fmpz_t, nn_ptr, nn_srcptr, slong, ulong
from flint.flintlib.types.flint cimport flint_bitcnt_t, flint_rand_t, fmpz_struct, fmpz_t, mp_limb_t, mp_ptr, mp_size_t, mp_srcptr, slong, ulong
from flint.flintlib.types.fmpq cimport fmpq_t

# unknown type FILE
Expand Down Expand Up @@ -318,14 +318,14 @@ cdef extern from "flint/arb.h":
void arb_partitions_ui(arb_t res, ulong n, slong prec)
void arb_primorial_nth_ui(arb_t res, ulong n, slong prec)
void arb_primorial_ui(arb_t res, ulong n, slong prec)
void _arb_atan_taylor_naive(nn_ptr y, ulong * error, nn_srcptr x, slong xn, ulong N, int alternating)
void _arb_atan_taylor_rs(nn_ptr y, ulong * error, nn_srcptr x, slong xn, ulong N, int alternating)
void _arb_exp_taylor_naive(nn_ptr y, ulong * error, nn_srcptr x, slong xn, ulong N)
void _arb_exp_taylor_rs(nn_ptr y, ulong * error, nn_srcptr x, slong xn, ulong N)
void _arb_sin_cos_taylor_naive(nn_ptr ysin, nn_ptr ycos, ulong * error, nn_srcptr x, slong xn, ulong N)
void _arb_sin_cos_taylor_rs(nn_ptr ysin, nn_ptr ycos, ulong * error, nn_srcptr x, slong xn, ulong N, int sinonly, int alternating)
int _arb_get_mpn_fixed_mod_log2(nn_ptr w, fmpz_t q, ulong * error, const arf_t x, slong wn)
int _arb_get_mpn_fixed_mod_pi4(nn_ptr w, fmpz_t q, int * octant, ulong * error, const arf_t x, slong wn)
void _arb_atan_taylor_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N, int alternating)
void _arb_atan_taylor_rs(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N, int alternating)
void _arb_exp_taylor_naive(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N)
void _arb_exp_taylor_rs(mp_ptr y, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N)
void _arb_sin_cos_taylor_naive(mp_ptr ysin, mp_ptr ycos, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N)
void _arb_sin_cos_taylor_rs(mp_ptr ysin, mp_ptr ycos, mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N, int sinonly, int alternating)
int _arb_get_mpn_fixed_mod_log2(mp_ptr w, fmpz_t q, mp_limb_t * error, const arf_t x, mp_size_t wn)
int _arb_get_mpn_fixed_mod_pi4(mp_ptr w, fmpz_t q, int * octant, mp_limb_t * error, const arf_t x, mp_size_t wn)
slong _arb_exp_taylor_bound(slong mag, slong prec)
void arb_exp_arf_bb(arb_t z, const arf_t x, slong prec, int m1)
void _arb_exp_sum_bs_simple(fmpz_t T, fmpz_t Q, flint_bitcnt_t * Qexp, const fmpz_t x, flint_bitcnt_t r, slong N)
Expand Down
10 changes: 5 additions & 5 deletions src/flint/flintlib/functions/arf.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flint.flintlib.types.arb cimport mag_t
from flint.flintlib.types.arf cimport arf_rnd_t, arf_srcptr, arf_t
from flint.flintlib.types.flint cimport flint_rand_t, fmpz_t, nn_ptr, nn_srcptr, slong, ulong
from flint.flintlib.types.flint cimport flint_rand_t, fmpz_t, mp_limb_t, mp_ptr, mp_size_t, mp_srcptr, slong, ulong
from flint.flintlib.types.fmpq cimport fmpq_t

# unknown type FILE
Expand Down Expand Up @@ -161,8 +161,8 @@ cdef extern from "flint/arf.h":
int arf_complex_mul(arf_t e, arf_t f, const arf_t a, const arf_t b, const arf_t c, const arf_t d, slong prec, arf_rnd_t rnd)
int arf_complex_mul_fallback(arf_t e, arf_t f, const arf_t a, const arf_t b, const arf_t c, const arf_t d, slong prec, arf_rnd_t rnd)
int arf_complex_sqr(arf_t e, arf_t f, const arf_t a, const arf_t b, slong prec, arf_rnd_t rnd)
int _arf_get_integer_mpn(nn_ptr y, nn_srcptr xp, slong xn, slong exp)
int _arf_set_mpn_fixed(arf_t z, nn_srcptr xp, slong xn, slong fixn, int negative, slong prec, arf_rnd_t rnd)
int _arf_get_integer_mpn(mp_ptr y, mp_srcptr xp, mp_size_t xn, slong exp)
int _arf_set_mpn_fixed(arf_t z, mp_srcptr xp, mp_size_t xn, mp_size_t fixn, int negative, slong prec, arf_rnd_t rnd)
int _arf_set_round_ui(arf_t z, ulong x, int sgnbit, slong prec, arf_rnd_t rnd)
int _arf_set_round_uiui(arf_t z, slong * fix, ulong hi, ulong lo, int sgnbit, slong prec, arf_rnd_t rnd)
int _arf_set_round_mpn(arf_t z, slong * exp_shift, nn_srcptr x, slong xn, int sgnbit, slong prec, arf_rnd_t rnd)
int _arf_set_round_uiui(arf_t z, slong * fix, mp_limb_t hi, mp_limb_t lo, int sgnbit, slong prec, arf_rnd_t rnd)
int _arf_set_round_mpn(arf_t z, slong * exp_shift, mp_srcptr x, mp_size_t xn, int sgnbit, slong prec, arf_rnd_t rnd)
25 changes: 17 additions & 8 deletions src/flint/flintlib/functions/arith.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flint.flintlib.types.flint cimport fmpz_struct, fmpz_t, nmod_t, nn_ptr, slong, ulong
from flint.flintlib.types.flint cimport fmpz_struct, fmpz_t, mp_limb_t, mp_ptr, nmod_t, slong, ulong
from flint.flintlib.types.fmpq cimport fmpq_poly_t, fmpq_struct, fmpq_t
from flint.flintlib.types.fmpz cimport fmpz_mat_t, fmpz_poly_t

Expand All @@ -7,6 +7,7 @@ from flint.flintlib.types.fmpz cimport fmpz_mat_t, fmpz_poly_t


cdef extern from "flint/arith.h":
void arith_primorial(fmpz_t res, slong n)
void _arith_harmonic_number(fmpz_t num, fmpz_t den, slong n)
void arith_harmonic_number(fmpq_t x, slong n)
void arith_stirling_number_1u(fmpz_t s, ulong n, ulong k)
Expand All @@ -27,11 +28,11 @@ cdef extern from "flint/arith.h":
void arith_bell_number_vec(fmpz_struct * b, slong n)
void arith_bell_number_vec_recursive(fmpz_struct * b, slong n)
void arith_bell_number_vec_multi_mod(fmpz_struct * b, slong n)
ulong arith_bell_number_nmod(ulong n, nmod_t mod)
void arith_bell_number_nmod_vec(nn_ptr b, slong n, nmod_t mod)
void arith_bell_number_nmod_vec_recursive(nn_ptr b, slong n, nmod_t mod)
void arith_bell_number_nmod_vec_ogf(nn_ptr b, slong n, nmod_t mod)
int arith_bell_number_nmod_vec_series(nn_ptr b, slong n, nmod_t mod)
mp_limb_t arith_bell_number_nmod(ulong n, nmod_t mod)
void arith_bell_number_nmod_vec(mp_ptr b, slong n, nmod_t mod)
void arith_bell_number_nmod_vec_recursive(mp_ptr b, slong n, nmod_t mod)
void arith_bell_number_nmod_vec_ogf(mp_ptr b, slong n, nmod_t mod)
int arith_bell_number_nmod_vec_series(mp_ptr b, slong n, nmod_t mod)
double arith_bell_number_size(ulong n)
void _arith_bernoulli_number(fmpz_t num, fmpz_t den, ulong n)
void arith_bernoulli_number(fmpq_t x, ulong n)
Expand All @@ -46,14 +47,22 @@ cdef extern from "flint/arith.h":
void arith_euler_number_vec(fmpz_struct * res, slong n)
double arith_euler_number_size(ulong n)
void arith_euler_polynomial(fmpq_poly_t poly, ulong n)
void arith_euler_phi(fmpz_t res, const fmpz_t n)
int arith_moebius_mu(const fmpz_t n)
void arith_divisor_sigma(fmpz_t res, ulong k, const fmpz_t n)
void arith_divisors(fmpz_poly_t res, const fmpz_t n)
void arith_ramanujan_tau(fmpz_t res, const fmpz_t n)
void arith_ramanujan_tau_series(fmpz_poly_t res, slong n)
void arith_landau_function_vec(fmpz_struct * res, slong len)
void arith_dedekind_sum_naive(fmpq_t s, const fmpz_t h, const fmpz_t k)
double arith_dedekind_sum_coprime_d(double h, double k)
void arith_dedekind_sum_coprime_large(fmpq_t s, const fmpz_t h, const fmpz_t k)
void arith_dedekind_sum_coprime(fmpq_t s, const fmpz_t h, const fmpz_t k)
void arith_dedekind_sum(fmpq_t s, const fmpz_t h, const fmpz_t k)
void arith_number_of_partitions_vec(fmpz_struct * res, slong len)
void arith_number_of_partitions_nmod_vec(nn_ptr res, slong len, nmod_t mod)
void arith_number_of_partitions_nmod_vec(mp_ptr res, slong len, nmod_t mod)
# void trig_prod_init(trig_prod_t prod)
# void arith_hrr_expsum_factored(trig_prod_t prod, ulong k, ulong n)
# void arith_hrr_expsum_factored(trig_prod_t prod, mp_limb_t k, mp_limb_t n)
# void arith_number_of_partitions_mpfr(mpfr_t x, ulong n)
void arith_number_of_partitions(fmpz_t x, ulong n)
void arith_sum_of_squares(fmpz_t r, ulong k, const fmpz_t n)
Expand Down
8 changes: 4 additions & 4 deletions src/flint/flintlib/functions/fmpq_mpoly.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flint.flintlib.types.flint cimport flint_bitcnt_t, flint_rand_t, fmpz_struct, fmpz_t, slong, ulong
from flint.flintlib.types.flint cimport flint_bitcnt_t, flint_rand_t, fmpz_struct, fmpz_t, mp_limb_t, slong, ulong
from flint.flintlib.types.fmpq cimport fmpq_mpoly_ctx_t, fmpq_mpoly_struct, fmpq_mpoly_t, fmpq_poly_struct, fmpq_poly_t, fmpq_struct, fmpq_t
from flint.flintlib.types.fmpz cimport fmpz_mpoly_struct
from flint.flintlib.types.mpoly cimport ordering_t
Expand Down Expand Up @@ -95,9 +95,9 @@ cdef extern from "flint/fmpq_mpoly.h":
void fmpq_mpoly_sort_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_combine_like_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_reverse(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_randtest_bound(fmpq_mpoly_t A, flint_rand_t state, slong length, ulong coeff_bits, ulong exp_bound, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_randtest_bounds(fmpq_mpoly_t A, flint_rand_t state, slong length, ulong coeff_bits, ulong * exp_bounds, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_randtest_bits(fmpq_mpoly_t A, flint_rand_t state, slong length, ulong coeff_bits, ulong exp_bits, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_randtest_bound(fmpq_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong exp_bound, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_randtest_bounds(fmpq_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong * exp_bounds, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_randtest_bits(fmpq_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_add_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_add_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx)
void fmpq_mpoly_add_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx)
Expand Down
Loading

0 comments on commit da51f7b

Please sign in to comment.